1 <?php
if (!defined('PmWiki')) exit();
4 CachedNumberOfArticles script adds support for printing number of pages in wiki
5 - add (:numberofarticles:) tag functionality
6 - this version uses WikiDir->ls() to obtin number of articles
8 Copyright 2006-2011 Anomen (ludek_h@seznam.cz)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published
11 by the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
15 $RecipeInfo['CachedNumberOfArticles']['Version'] = '2011-10-13';
17 Markup('numberofarticles','inline','/\(:numberofarticles(\s+refresh)?\s*:\)/e',
18 "Keep(getNumArticles('$1'))");
20 $NOAFile = "$WorkDir/.noa";
22 function refreshNumArticles()
27 $count = count($WikiDir->ls());
29 $f = fopen($NOAFile, 'w');
33 return "<!--fresh-->$count\n";
36 function getNumArticles($refresh)
41 if (!empty($refresh)) {
42 return refreshNumArticles();
44 } else if (FALSE === ($content = @file
($NOAFile))) {
45 return refreshNumArticles();
48 return implode('', $content);