cvs: docweb /include init.inc.php lib_general.inc.php /templates/all/www/shared header.tpl.php
[email protected] ("Sean Coates")
| Newsgroups | php.doc.web |
|---|---|
| Message-ID | <cvssean1106519346@cvsserver> |
sean Sun Jan 23 17:29:06 2005 EDT
Modified files:
/docweb/include init.inc.php lib_general.inc.php
/docweb/templates/all/www/shared header.tpl.php
Log:
bug counts (needs PEAR::XML_RSS)
http://cvs.php.net/diff.php/docweb/include/init.inc.php?r1=1.8&r2=1.9&ty=u
Index: docweb/include/init.inc.php
diff -u docweb/include/init.inc.php:1.8 docweb/include/init.inc.php:1.9
--- docweb/include/init.inc.php:1.8 Fri Jan 21 11:58:19 2005
+++ docweb/include/init.inc.php Sun Jan 23 17:29:05 2005
@@ -18,7 +18,7 @@
| Gabor Hojtsy <[email protected]> |
| Sean Coates <[email protected]> |
+----------------------------------------------------------------------+
-$Id: init.inc.php,v 1.8 2005/01/21 16:58:19 sean Exp $
+$Id: init.inc.php,v 1.9 2005/01/23 22:29:05 sean Exp $
*/
error_reporting(E_ALL);
@@ -26,6 +26,9 @@
// get paths
require_once(dirname(realpath(__FILE__)) . '/../build-ops.php');
+// RSS cache is considered stale after (seconds):
+define('RSS_STALE_CACHE_BUGS', 300); // 300 = 5mins
+
// project & language config
require_once('lib_proj_lang.inc.php');
@@ -83,3 +86,5 @@
// template engine
require_once('docweb_template.class.php');
}
+
+?>
http://cvs.php.net/diff.php/docweb/include/lib_general.inc.php?r1=1.36&r2=1.37&ty=u
Index: docweb/include/lib_general.inc.php
diff -u docweb/include/lib_general.inc.php:1.36 docweb/include/lib_general.inc.php:1.37
--- docweb/include/lib_general.inc.php:1.36 Fri Jan 21 19:07:59 2005
+++ docweb/include/lib_general.inc.php Sun Jan 23 17:29:05 2005
@@ -18,7 +18,7 @@
| Gabor Hojtsy <[email protected]> |
| Sean Coates <[email protected]> |
+----------------------------------------------------------------------+
-$Id: lib_general.inc.php,v 1.36 2005/01/22 00:07:59 sean Exp $
+$Id: lib_general.inc.php,v 1.37 2005/01/23 22:29:05 sean Exp $
*/
function is_translation($project, $language)
@@ -64,6 +64,15 @@
// Set proper encoding with HTTP header first
header("Content-type: text/html; charset=$encoding");
+ // bugs for count
+ if ($bugs = get_bugs_rss()) {
+ $showBugs = true;
+ $bugCount = $bugs['count'];
+ $bugsLink = $bugs['link'];
+ } else {
+ $showBugs = $bugCount = $bugsLink = false;
+ }
+
return DocWeb_Template::get(
'shared/header.tpl.php',
array(
@@ -79,6 +88,9 @@
'locallinks' => $locallinks,
'extlinks' => $extlinks,
'page_title' => $page_title,
+ 'showBugs' => $showBugs,
+ 'bugCount' => $bugCount,
+ 'bugsLink' => $bugsLink,
)
);
}
@@ -245,4 +257,57 @@
array('links' => $links, 'Language' => &$GLOBALS['Language'])
);
}
+
+function get_bugs_rss($project=SITE)
+{
+ // set up proper RSS URLs
+ switch ($project)
+ {
+ case 'php':
+ $RSS_URL = 'http://bugs.php.net/rss/search.php?boolean=0'
+ .'&limit=All&order_by=status&direction=ASC&cmd=display'
+ .'&status=Open&bug_type%5B%5D=Documentation+problem'
+ .'&bug_age=0';
+ $link = 'http://bugs.php.net/search.php?boolean=0'
+ .'&limit=All&order_by=status&direction=ASC&cmd=display'
+ .'&status=Open&bug_type%5B%5D=Documentation+problem'
+ .'&bug_age=0';
+ break;
+
+ case 'livedocs':
+ $RSS_URL = 'http://bugs.php.net/rss/search.php?boolean=0'
+ .'&limit=All&order_by=status&direction=ASC&cmd=display'
+ .'&status=Open&bug_type%5B%5D=Livedocs+problem'
+ .'&bug_age=0';
+ $link = 'http://bugs.php.net/search.php?boolean=0'
+ .'&limit=All&order_by=status&direction=ASC&cmd=display'
+ .'&status=Open&bug_type%5B%5D=Livedocs+problem'
+ .'&bug_age=0';
+ break;
+
+ default:
+ return false;
+ }
+
+ // local cache
+ $localFile = FILES_DIR . "bugs_{$project}.rss";
+
+ if (!(is_readable($localFile) &&
+ (filemtime($localFile) > time() - RSS_STALE_CACHE_BUGS))) {
+ // cache miss: download (& cache) rss
+ file_put_contents($localFile, file_get_contents($RSS_URL));
+ }
+
+ require_once "XML/RSS.php";
+
+ $RSS =& new XML_RSS($localFile);
+ $RSS->parse();
+ $items = $RSS->getItems();
+ return array(
+ 'count' => count($items),
+ 'link' => $link,
+ 'items' => $items,
+ );
+}
+
?>
http://cvs.php.net/diff.php/docweb/templates/all/www/shared/header.tpl.php?r1=1.4&r2=1.5&ty=u
Index: docweb/templates/all/www/shared/header.tpl.php
diff -u docweb/templates/all/www/shared/header.tpl.php:1.4 docweb/templates/all/www/shared/header.tpl.php:1.5
--- docweb/templates/all/www/shared/header.tpl.php:1.4 Sun Oct 31 13:01:33 2004
+++ docweb/templates/all/www/shared/header.tpl.php Sun Jan 23 17:29:05 2005
@@ -36,6 +36,10 @@
<dd><?php echo $locallinks; ?></dd>
<dt>&docweb.common.header.offsite-context-nav;</dt>
<dd><?php echo $extlinks; ?></dd>
+ <?php if ($showBugs) { ?>
+ <dt>&docweb.common.header.project-doc-bugs;</dt>
+ <dd><a href="<?php echo $bugsLink; ?>"><?php echo $bugCount; ?> &docweb.common.header.open-bugs;</a></dd>
+ <?php } ?>
</dl>
</div>
</div>