Web: Show active forum topics at dev info page
This commit is contained in:
parent
93495613dd
commit
4ab390e4ee
|
@ -64,6 +64,18 @@ the latest sources in a zip or tgz archive</a> from the github website.</p>
|
|||
print("</ul>\n");
|
||||
?>
|
||||
<p><a href="http://sourceforge.net/apps/trac/cppcheck/timeline">View complete Trac timeline…</a></p>
|
||||
<h2>Active Forum Topics</h2>
|
||||
<?php
|
||||
require '../site/activetopics.php';
|
||||
|
||||
$activetopics = new Forum_ActiveTopics('http://sourceforge.net/apps/phpbb/cppcheck/');
|
||||
print("<ul class=\"rssfeeditems\">\n");
|
||||
foreach ($activetopics->getTopics(0, 10) as $topic) { //for all active topics...
|
||||
print(" <li><a href=\"".$topic->getLink()."\">".$topic->getTitle()."</a><em>last post by <strong>".$topic->getLastPostUser()."</strong></em></li>\n");
|
||||
}
|
||||
print("</ul>\n");
|
||||
?>
|
||||
<p><a href="http://sourceforge.net/apps/phpbb/cppcheck/search.php?st=0&search_id=active_topics">View all active topics…</a></p>
|
||||
<h2>Doxygen</h2>
|
||||
<ul>
|
||||
<li><a href="/doxyoutput/">Output</a></li>
|
||||
|
|
|
@ -0,0 +1,188 @@
|
|||
<?php
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
class Forum_ActiveTopics {
|
||||
/**
|
||||
* ...
|
||||
* @var string ...
|
||||
*/
|
||||
private $_forumHome;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @var array ...
|
||||
*/
|
||||
private $_topics;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @param string $forumHome ...
|
||||
*/
|
||||
public function __construct($forumHome) {
|
||||
$this->_forumHome = $forumHome;
|
||||
$this->_topics = array();
|
||||
|
||||
$this->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @param int $start ...
|
||||
* @param int $end ...
|
||||
* @return array ...
|
||||
*/
|
||||
public function getTopics($start = 0, $end = 0) {
|
||||
if ($end == 0) {
|
||||
return array_slice($this->_topics, $start);
|
||||
}
|
||||
else {
|
||||
return array_slice($this->_topics, $start, $end);
|
||||
}
|
||||
//return $this->_topics;
|
||||
}
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @param int $days ...
|
||||
*/
|
||||
public function update($days = 30) {
|
||||
$this->_topics = array();
|
||||
$html = file_get_contents($this->_forumHome . 'search.php?st=' . $days . '&search_id=active_topics');
|
||||
$html = strip_tags($html, '<a><dd>');
|
||||
$html = preg_replace(array('#\t#', '#&sid=[a-z0-9]+#'), '', $html);
|
||||
if (preg_match_all('#<a href="\./(.*?)" class="topictitle">(.*?)</a>#im', $html, $matches)) {
|
||||
$lastPostUsers = array();
|
||||
if (preg_match_all('#<dd class="lastpost">\nby <a href="\./(.*?)">(.*?)</a>#i', $html, $lastPosts)) {
|
||||
$lastPostUserLinks = $lastPosts[1];
|
||||
$lastPostUserNames = $lastPosts[2];
|
||||
for ($i = 0; $i < count($lastPostUserLinks); $i++) { //for all users...
|
||||
$link = $this->_forumHome . $lastPostUserLinks[$i];
|
||||
$name = $lastPostUserNames[$i];
|
||||
|
||||
$lastPostUsers[] = new Forum_User($link, $name);
|
||||
}
|
||||
}
|
||||
$links = $matches[1];
|
||||
$titles = $matches[2];
|
||||
for ($i = 0; $i < count($links); $i++) { //for all topics...
|
||||
$link = $this->_forumHome . $links[$i];
|
||||
$title = $titles[$i];
|
||||
$lastPostUser = $lastPostUsers[$i];
|
||||
|
||||
$this->_topics[] = new Forum_Topic($link, $title, $lastPostUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Forum_Topic {
|
||||
/**
|
||||
* ...
|
||||
* @var string ...
|
||||
*/
|
||||
private $_link;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @var string ...
|
||||
*/
|
||||
private $_title;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @var Forum_User ...
|
||||
*/
|
||||
private $_lastPostUser;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @param string $link ...
|
||||
* @param string $title ...
|
||||
* @param Forum_User $lastPostUser ...
|
||||
*/
|
||||
public function __construct($link, $title, $lastPostUser = null) {
|
||||
$this->_link = $link;
|
||||
$this->_title = $title;
|
||||
$this->_lastPostUser = $lastPostUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @return string ...
|
||||
*/
|
||||
public function getLink() {
|
||||
return $this->_link;
|
||||
}
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @return string ...
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @return Forum_User ...
|
||||
*/
|
||||
public function getLastPostUser() {
|
||||
return $this->_lastPostUser;
|
||||
}
|
||||
}
|
||||
|
||||
class Forum_User {
|
||||
/**
|
||||
* ...
|
||||
* @var string ...
|
||||
*/
|
||||
private $_link;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @var string ...
|
||||
*/
|
||||
private $_name;
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @param string $link ...
|
||||
* @param string $name ...
|
||||
*/
|
||||
public function __construct($link, $name) {
|
||||
$this->_link = $link;
|
||||
$this->_name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @return string ...
|
||||
*/
|
||||
public function getLink() {
|
||||
return $this->_link;
|
||||
}
|
||||
|
||||
/**
|
||||
* ...
|
||||
* @return string ...
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* ...
|
||||
*/
|
||||
public function __toString() {
|
||||
return $this->_name;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue