function PageHome(&$skeleton) { $articles = Entities::retrieveGroupedEntities(ARTICLES); $itemlist = new ItemList($skeleton); $itemlist->setBorders(array('top' => '-', 'bottom' => '-', 'left' => '+', 'right' => '+')); $ascii_article = new Article($skeleton, current($articles)); $skeleton->addWidget($ascii_article); $count = 0; while ($article = next($articles)) { ++$count; $text = ""; $text .= "[url="; $text .= Common::urlFor('view_article', array('token' => $article->getToken())) . ']'; $text .= "[b]" . $article->getCategory() . "[/b]"; $text .= "/" . $article->getTitle() . '[/url]'; $text .= " (" . $article->getDate() . ")"; if ($count < count($articles) - 1) { $text .= "\n"; } $itemlist->setText($text); } if ($count > 0) { $skeleton->addWidget($itemlist); } }
function PageStat(&$skeleton) { $itemlist = new ItemList($skeleton); $db = Stat::loadDb(); $itemlist->setBorders(array('top' => '-', 'bottom' => '-', 'left' => '+', 'right' => '+')); $itemlist->setText("Number of page viewed: " . $db['total_pages']); $skeleton->addWidget($itemlist); }
function SearchArticles($pattern, $skeleton) { $matches = 0; $articles = Entities::retrieveGroupedEntities(ARTICLES); $itemlist = new ItemList($skeleton); foreach ($articles as $article) { if (stristr($article->getContent(), $pattern)) { ++$matches; $link = Common::urlFor('view_article', array('token' => $article->getToken())); $itemlist->setText('<a href="' . $link . '">' . $article->getTitle() . '</a>'); } } $skeleton->addWidget($itemlist); return $matches; }