Ejemplo n.º 1
0
function PurgePage(&$request)
{
    global $WikiTheme;
    $page = $request->getPage();
    $pagelink = WikiLink($page);
    if ($request->getArg('cancel')) {
        $request->redirect(WikiURL($page));
        // noreturn
    }
    $current = $page->getCurrentRevision();
    if (!$current or !($version = $current->getVersion())) {
        $html = HTML::p(array('class' => 'error'), _("Sorry, this page does not exist."));
    } elseif (!$request->isPost() || !$request->getArg('verify')) {
        $purgeB = Button('submit:verify', _("Purge Page"), 'wikiadmin');
        $cancelB = Button('submit:cancel', _("Cancel"), 'button');
        // use generic wiki button look
        $fieldset = HTML::fieldset(HTML::p(fmt("You are about to purge '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'purge')), HTML::div(array('class' => 'toolbar'), $purgeB, $WikiTheme->getButtonSeparator(), $cancelB)));
        $sample = HTML::div(array('class' => 'transclusion'));
        // simple and fast preview expanding only newlines
        foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) {
            $sample->pushContent($s, HTML::br());
        }
        $html = HTML($fieldset, HTML::div(array('class' => 'wikitext'), $sample));
    } elseif ($request->getArg('currentversion') != $version) {
        $html = HTML(HTML::p(array('class' => 'error'), _("Someone has edited the page!")), HTML::p(fmt("Since you started the purge process, someone has saved a new version of %s.  Please check to make sure you still want to permanently purge the page from the database.", $pagelink)));
    } else {
        // Real purge.
        $pagename = $page->getName();
        $dbi = $request->getDbh();
        $dbi->purgePage($pagename);
        $dbi->touch();
        $html = HTML::div(array('class' => 'feedback'), fmt("Purged page '%s' successfully.", $pagename));
    }
    GeneratePage($html, _("Purge Page"));
}
Ejemplo n.º 2
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     $html = HTML();
     if (empty($args['pages'])) {
         return $html;
     }
     $include = new WikiPlugin_IncludePage();
     if (is_string($args['exclude']) and !empty($args['exclude'])) {
         $args['exclude'] = explodePageList($args['exclude']);
         $argstr = preg_replace("/exclude=\\S*\\s/", "", $argstr);
     } elseif (is_array($args['exclude'])) {
         $argstr = preg_replace("/exclude=<\\?plugin-list.*?\\>/", "", $argstr);
     }
     if (is_string($args['pages']) and !empty($args['pages'])) {
         $args['pages'] = explodePageList($args['pages']);
         $argstr = preg_replace("/pages=\\S*\\s/", "", $argstr);
     } elseif (is_array($args['pages'])) {
         $argstr = preg_replace("/pages=<\\?plugin-list.*?\\>/", "", $argstr);
     }
     foreach ($args['pages'] as $page) {
         if (empty($args['exclude']) or !in_array($page, $args['exclude'])) {
             $html = HTML($html, $include->run($dbi, "page='{$page}' " . $argstr, $request, $basepage));
         }
     }
     return $html;
 }
Ejemplo n.º 3
0
 function chownPages(&$dbi, &$request, $pages, $newowner)
 {
     $ul = HTML::ul();
     $count = 0;
     foreach ($pages as $name) {
         $page = $dbi->getPage($name);
         if ($owner = $page->getOwner() and $newowner != $owner) {
             if (!mayAccessPage('change', $name)) {
                 $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name))));
             } else {
                 $page->set('owner', $newowner);
                 if ($page->get('owner') === $newowner) {
                     $ul->pushContent(HTML::li(fmt("Chown page '%s' to '%s'.", WikiLink($name), WikiLink($newowner))));
                     $count++;
                 } else {
                     $ul->pushContent(HTML::li(fmt("Couldn't chown page '%s' to '%s'.", WikiLink($name), $newowner)));
                 }
             }
         }
     }
     if ($count) {
         $dbi->touch();
         return HTML($ul, HTML::p(fmt("%s pages have been permanently changed.", $count)));
     } else {
         return HTML($ul, HTML::p(fmt("No pages changed.")));
     }
 }
Ejemplo n.º 4
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     $maincat = $dbi->getPage(_("CategoryCategory"));
     $bi = $maincat->getBackLinks(false);
     $bl = array();
     while ($b = $bi->next()) {
         $name = $b->getName();
         if (preg_match("/^" . _("Template") . "/", $name)) {
             continue;
         }
         $pages = $b->getBackLinks(false);
         $bl[] = array('name' => $name, 'count' => $pages->count());
     }
     usort($bl, 'cmp_by_count');
     $html = HTML::ul();
     $i = 0;
     foreach ($bl as $b) {
         $i++;
         $name = $b['name'];
         $count = $b['count'];
         if ($count < $mincount) {
             break;
         }
         if ($i > $limit) {
             break;
         }
         $wo = preg_replace("/^(" . _("Category") . "|" . _("Topic") . ")/", "", $name);
         $wo = HTML(HTML::span($wo), HTML::raw("&nbsp;"), HTML::small("(" . $count . ")"));
         $link = WikiLink($name, 'auto', $wo);
         $html->pushContent(HTML::li($link));
     }
     return $html;
 }
Ejemplo n.º 5
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     if ($numberlinks > 10 || $numberlinks < 0) {
         $numberlinks = $this->def_numberlinks;
     }
     // Get name of the current page we are on
     $thispage = $request->getArg('pagename');
     $Pages = $request->session->get("PageTrail");
     if (!is_array($Pages)) {
         $Pages = array();
     }
     if (!isset($Pages[0]) or $duplicates || $thispage != $Pages[0]) {
         array_unshift($Pages, $thispage);
         $request->session->set("PageTrail", $Pages);
     }
     $numberlinks = min(count($Pages), $numberlinks);
     if (!$invisible and $numberlinks) {
         $html = HTML::div(array('class' => 'pagetrail'));
         $html->pushContent(WikiLink($Pages[$numberlinks - 1], 'auto'));
         for ($i = $numberlinks - 2; $i >= 0; $i--) {
             if (!empty($Pages[$i])) {
                 $html->pushContent(PAGETRAIL_ARROW, WikiLink($Pages[$i], 'auto'));
             }
         }
         return $html;
     } else {
         return HTML();
     }
 }
Ejemplo n.º 6
0
 function Textarea_Replace($textarea, $wikitext, $name = 'edit[content]')
 {
     $htmltextid = $this->_htmltextid;
     $textarea->SetAttr('id', $htmltextid);
     $out = HTML($textarea, HTML::div(array("id" => $this->_wikitextid, 'style' => 'display:none'), $wikitext), "\n");
     return $out;
 }
Ejemplo n.º 7
0
 function box($args = false, $request = false, $basepage = false)
 {
     if (!$request) {
         $request =& $GLOBALS['request'];
     }
     $stats = $this->getStats($request->_dbi, $request, 'summary');
     return $this->makeBox(_("Who is online"), HTML(HTML::Raw('&middot; '), WikiLink(_("WhoIsOnline"), 'auto', fmt("%d online users", $stats['NUM_USERS']))));
 }
Ejemplo n.º 8
0
 function _flushLine($new_tag)
 {
     $this->_flushGroup($new_tag);
     if ($this->_line) {
         $this->_lines[] = $this->_line;
     }
     $this->_line = HTML();
 }
Ejemplo n.º 9
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     $rss_parser = new RSSParser();
     if (!empty($url)) {
         $rss_parser->parse_url($url, $debug);
     }
     if (!empty($rss_parser->channel['title'])) {
         $feed = $rss_parser->channel['title'];
     }
     if (!empty($rss_parser->channel['link'])) {
         $url = $rss_parser->channel['link'];
     }
     if (!empty($rss_parser->channel['description'])) {
         $description = $rss_parser->channel['description'];
     }
     if (!empty($feed)) {
         if (!empty($url)) {
             $titre = HTML::span(HTML::a(array('href' => $rss_parser->channel['link']), $rss_parser->channel['title']));
         } else {
             $titre = HTML::span($rss_parser->channel['title']);
         }
         $th = HTML::div(array('class' => 'feed'), $titre);
         if (!empty($description)) {
             $th->pushContent(HTML::p(array('class' => 'chandesc'), HTML::raw($description)));
         }
     } else {
         $th = HTML();
     }
     if (!empty($rss_parser->channel['date'])) {
         $th->pushContent(HTML::raw("<!--" . $rss_parser->channel['date'] . "-->"));
     }
     $html = HTML::div(array('class' => 'rss'), $th);
     if ($rss_parser->items) {
         // only maxitem's
         if ($maxitem > 0) {
             $rss_parser->items = array_slice($rss_parser->items, 0, $maxitem);
         }
         foreach ($rss_parser->items as $item) {
             $cell = HTML::div(array('class' => 'rssitem'));
             if ($item['link'] and empty($item['title'])) {
                 $item['title'] = $item['link'];
             }
             $cell_title = HTML::div(array('class' => 'itemname'), HTML::a(array('href' => $item['link']), HTML::raw($item['title'])));
             $cell->pushContent($cell_title);
             if (!empty($item['description'])) {
                 $cell->pushContent(HTML::div(array('class' => 'itemdesc'), HTML::raw($item['description'])));
             }
             $html->pushContent($cell);
         }
     } else {
         $html = HTML::div(array('class' => 'rss'), HTML::em(_("no RSS items")));
     }
     if (!check_php_version(5)) {
         $rss_parser->__destruct();
     }
     return $html;
 }
Ejemplo n.º 10
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     $pagename = $args['page'];
     if (empty($args['s'])) {
         if ($request->isPost()) {
             if ($pagename != _("AppendText")) {
                 return HTML($request->redirect(WikiURL($pagename, false, 'absurl'), false));
             }
         }
         return '';
     }
     $page = $dbi->getPage($pagename);
     $message = HTML();
     if (!$page->exists()) {
         // We might want to create it?
         $message->pushContent(sprintf(_("Page could not be updated. %s doesn't exist!\n"), $pagename));
         return $message;
     }
     $current = $page->getCurrentRevision();
     $oldtext = $current->getPackedContent();
     $text = $args['s'];
     // If a "before" or "after" is specified but not found, we simply append text to the end.
     if (!empty($args['before'])) {
         $before = preg_quote($args['before'], "/");
         // Insert before
         $newtext = preg_match("/\n{$before}/", $oldtext) ? preg_replace("/(\n{$before})/", "\n" . preg_quote($text, "/") . "\\1", $oldtext) : $this->_fallback($text, $oldtext, $args['before'], $message);
     } elseif (!empty($args['after'])) {
         // Insert after
         $after = preg_quote($args['after'], "/");
         $newtext = preg_match("/\n{$after}/", $oldtext) ? preg_replace("/(\n{$after})/", "\\1\n" . preg_quote($text, "/"), $oldtext) : $this->_fallback($text, $oldtext, $args['after'], $message);
     } else {
         // Append at the end
         $newtext = $oldtext . "\n" . $text;
     }
     require_once "lib/loadsave.php";
     $meta = $current->_data;
     $meta['summary'] = sprintf(_("AppendText to %s"), $pagename);
     if ($page->save($newtext, $current->getVersion() + 1, $meta)) {
         $message->pushContent(_("Page successfully updated."), HTML::br());
     }
     // AppendText has been called from the same page that got modified
     // so we directly show the page.
     if ($request->getArg($pagename) == $pagename) {
         // TODO: Just invalidate the cache, if AppendText didn't
         // change anything before.
         //
         return $request->redirect(WikiURL($pagename, false, 'absurl'), false);
         // The user asked to be redirected to the modified page
     } elseif ($args['redirect']) {
         return $request->redirect(WikiURL($pagename, false, 'absurl'), false);
     } else {
         $link = HTML::em(WikiLink($pagename));
         $message->pushContent(HTML::Raw(sprintf(_("Go to %s."), $link->asXml())));
     }
     return $message;
 }
Ejemplo n.º 11
0
function RemovePage(&$request)
{
    global $WikiTheme;
    $page = $request->getPage();
    $pagelink = WikiLink($page);
    if ($request->getArg('cancel')) {
        $request->redirect(WikiURL($page));
        // noreturn
    }
    $current = $page->getCurrentRevision();
    if (!$current or !($version = $current->getVersion())) {
        $html = HTML(HTML::h2(_("Already deleted")), HTML::p(_("Sorry, this page is not in the database.")));
    } elseif (!$request->isPost() || !$request->getArg('verify')) {
        $removeB = Button('submit:verify', _("Remove Page"), 'wikiadmin');
        $cancelB = Button('submit:cancel', _("Cancel"), 'button');
        // use generic wiki button look
        $html = HTML(HTML::h2(fmt("You are about to remove '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'remove')), HTML::div(array('class' => 'toolbar'), $removeB, $WikiTheme->getButtonSeparator(), $cancelB)), HTML::hr());
        $sample = HTML::div(array('class' => 'transclusion'));
        // simple and fast preview expanding only newlines
        foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) {
            $sample->pushContent($s, HTML::br());
        }
        $html->pushContent(HTML::div(array('class' => 'wikitext'), $sample));
    } elseif ($request->getArg('currentversion') != $version) {
        $html = HTML(HTML::h2(_("Someone has edited the page!")), HTML::p(fmt("Since you started the deletion process, someone has saved a new version of %s.  Please check to make sure you still want to permanently remove the page from the database.", $pagelink)));
    } else {
        // Codendi specific: remove the deleted wiki page from ProjectWantedPages
        $projectPageName = 'ProjectWantedPages';
        $pagename = $page->getName();
        $dbi = $request->getDbh();
        require_once PHPWIKI_DIR . "/lib/loadsave.php";
        $pagehandle = $dbi->getPage($projectPageName);
        if ($pagehandle->exists()) {
            // don't replace default contents
            $current = $pagehandle->getCurrentRevision();
            $version = $current->getVersion();
            $text = $current->getPackedContent();
            $meta = $current->_data;
        }
        $text = str_replace("* [{$pagename}]", "", $text);
        $meta['summary'] = $GLOBALS['Language']->getText('wiki_lib_wikipagewrap', 'page_added', array($pagename));
        $meta['author'] = user_getname();
        $pagehandle->save($text, $version + 1, $meta);
        //Codendi specific: remove permissions for this page @codenditodo: may be transferable otherwhere.
        require_once 'common/wiki/lib/WikiPage.class.php';
        $wiki_page = new WikiPage(GROUP_ID, $_REQUEST['pagename']);
        $wiki_page->resetPermissions();
        // Real delete.
        //$pagename = $page->getName();
        $dbi = $request->getDbh();
        $dbi->deletePage($pagename);
        $dbi->touch();
        $link = HTML::a(array('href' => 'javascript:history.go(-2)'), _("Back to the previous page."));
        $html = HTML(HTML::h2(fmt("Removed page '%s' successfully.", $pagename)), HTML::div($link), HTML::hr());
    }
    GeneratePage($html, _("Remove Page"));
}
Ejemplo n.º 12
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if (!$args['pagename']) {
         return $this->error(_("No pagename specified"));
     }
     // Get our form args.
     $comment = $request->getArg("comment");
     $request->setArg('comment', false);
     if ($request->isPost() and !empty($comment['addcomment'])) {
         $this->add($request, $comment, 'comment');
         // noreturn
     }
     if ($args['jshide'] and isBrowserIE() and browserDetect("Mac")) {
         //trigger_error(_("jshide set to 0 on Mac IE"), E_USER_NOTICE);
         $args['jshide'] = 0;
     }
     // Now we display previous comments and/or provide entry box
     // for new comments
     $html = HTML();
     if ($args['jshide']) {
         $div = HTML::div(array('id' => 'comments', 'style' => 'display:none;'));
         //$list->setAttr('style','display:none;');
         $div->pushContent(Javascript("\nfunction togglecomments(a) {\n  comments=document.getElementById('comments');\n  if (comments.style.display=='none') {\n    comments.style.display='block';\n    a.title='" . _("Click to hide the comments") . "';\n  } else {\n    comments.style.display='none';\n    a.title='" . _("Click to display all comments") . "';\n  }\n}"));
         $html->pushContent(HTML::h4(HTML::a(array('name' => 'comment-header', 'class' => 'wikiaction', 'title' => _("Click to display"), 'onclick' => "togglecomments(this)"), _("Comments"))));
     } else {
         $div = HTML::div(array('id' => 'comments'));
     }
     foreach (explode(',', $args['mode']) as $show) {
         if (!empty($seen[$show])) {
             continue;
         }
         $seen[$show] = 1;
         switch ($show) {
             case 'show':
                 $show = $this->showAll($request, $args, 'comment');
                 //if ($args['jshide']) $show->setAttr('style','display:none;');
                 $div->pushContent($show);
                 break;
             case 'add':
                 global $WikiTheme;
                 if (!$WikiTheme->DUMP_MODE) {
                     $add = $this->showForm($request, $args, 'addcomment');
                     //if ($args['jshide']) $add->setAttr('style','display:none;');
                     $div->pushContent($add);
                 }
                 break;
             default:
                 return $this->error(sprintf("Bad mode ('%s')", $show));
         }
     }
     $html->pushContent($div);
     return $html;
 }
Ejemplo n.º 13
0
 function run($dbi, $argstr, $request)
 {
     extract($this->getArgs($argstr, $request));
     // Any text that is returned will not be further transformed,
     // so use html where necessary.
     if (empty($jid)) {
         $html = HTML();
     } else {
         $html = HTML::img(array('src' => urlencode($scripturl) . '&jid=' . urlencode($jid) . '&type=' . urlencode($type) . '&iconset=' . $iconset));
     }
     return $html;
 }
Ejemplo n.º 14
0
 function _DebugPrintArray(&$array)
 {
     $html = HTML();
     foreach ($array as $line) {
         ob_start();
         print_r($line);
         $s = HTML::pre(ob_get_contents());
         ob_end_clean();
         $html->pushContent($s);
     }
     return $html;
 }
Ejemplo n.º 15
0
 function Textarea($textarea, $wikitext, $name = 'edit[content]')
 {
     global $request;
     $htmltextid = $this->_htmltextid;
     $textarea->SetAttr('id', $htmltextid);
     $iframe0 = new RawXml('<iframe id="iframe0" src="blank.htm" height="0" width="0" frameborder="0"></iframe>');
     if ($request->getArg('mode') and $request->getArg('mode') == 'wysiwyg') {
         $out = HTML(HTML::div(array('class' => 'hint'), _("Warning: This Wikiwyg editor has only Beta quality!")), $textarea, $iframe0, "\n");
     } else {
         $out = HTML($textarea, $iframe0, "\n");
     }
     return $out;
 }
Ejemplo n.º 16
0
function sendHTMLPage()
{
    $menu = MainMenu::getInstance();
    $page = Page::getInstance();
    if ($page->getError()) {
        header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
        error_page();
        exit;
    }
    header("Content-Type: text/html; charset=utf-8");
    if (sendHeaders()) {
        echo HTML();
    }
}
Ejemplo n.º 17
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if ($args['basepage']) {
         $pagename = $args['basepage'];
     } else {
         $pagename = $request->getArg('pagename');
     }
     // FIXME: explodePageList from stdlib doesn't seem to work as
     // expected when there are no subpages. (see also
     // UnfoldSubPages plugin)
     $subpages = explodePageList($pagename . SUBPAGE_SEPARATOR . '*');
     if (!$subpages) {
         return $this->error(_("The current page has no subpages defined."));
     }
     extract($args);
     $content = HTML();
     $subpages = array_reverse($subpages);
     if ($maxpages) {
         $subpages = array_slice($subpages, 0, $maxpages);
     }
     $descrip = fmt("SubPages of %s:", WikiLink($pagename, 'auto'));
     if ($info) {
         $info = explode(",", $info);
         if (in_array('count', $info)) {
             $args['types']['count'] = new _PageList_Column_ListSubpages_count('count', _("#"), 'center');
         }
     }
     $pagelist = new PageList($info, $exclude, $args);
     if (!$noheader) {
         $pagelist->setCaption($descrip);
     }
     foreach ($subpages as $page) {
         // A page cannot include itself. Avoid doublettes.
         static $included_pages = array();
         if (in_array($page, $included_pages)) {
             $content->pushContent(HTML::p(sprintf(_("recursive inclusion of page %s ignored"), $page)));
             continue;
         }
         array_push($included_pages, $page);
         //if ($relative) {
         // TODO: add relative subpage name display to PageList class
         //}
         $pagelist->addPage($page);
         array_pop($included_pages);
     }
     $content->pushContent($pagelist);
     return $content;
 }
Ejemplo n.º 18
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     $h = HTML();
     $this->_generatePageheader($info, $h);
     if (!REQUIRE_ADMIN || $request->_user->isadmin()) {
         $h->pushContent(HTML::h2(_("Plugins")));
         $table = HTML::table(array('class' => "pagelist"));
         $this->_generateColheadings($info, $table);
         $this->_generateTableBody($info, $dbi, $request, $table);
         $h->pushContent($table);
     } else {
         $h->pushContent(fmt("You must be an administrator to %s.", _("use this plugin")));
     }
     return $h;
 }
Ejemplo n.º 19
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     $output = HTML(HTML::h1("Group Info"));
     $group = WikiGroup::getGroup();
     $allGroups = $group->getAllGroupsIn();
     foreach ($allGroups as $g) {
         $members = $group->getMembersOf($g);
         $output->pushContent(HTML::h3($g . " - members: " . sizeof($members) . " - isMember: " . ($group->isMember($g) ? "yes" : "no")));
         foreach ($members as $m) {
             $output->pushContent($m);
             $output->pushContent(HTML::br());
         }
     }
     $output->pushContent(HTML::p("--- the end ---"));
     return $output;
 }
Ejemplo n.º 20
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (!$url && !$file) {
         return $this->error(_("Both 'url' or 'file' parameters missing."));
     } elseif ($url && $file) {
         return $this->error(_("Choose only one of 'url' or 'file' parameters."));
     } elseif ($file) {
         // $url = SERVER_URL . getUploadDataPath() . '/' . $file;
         $url = getUploadDataPath() . '/' . $file;
     }
     if (string_ends_with($url, ".ogg")) {
         return HTML::video(array('autoplay' => 'true', 'controls' => 'true', 'src' => $url), _("Your browser does not understand the HTML 5 video tag."));
     }
     $html = HTML();
     if (isBrowserIE()) {
         $object = HTML::object(array('id' => 'flowplayer', 'classid' => 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000', 'width' => $width, 'height' => $height));
         $param = HTML::param(array('name' => 'movie', 'value' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.2.4.swf')));
         $object->pushContent($param);
         $param = HTML::param(array('name' => "allowfullscreen", 'value' => "true"));
         $object->pushContent($param);
         $param = HTML::param(array('name' => "allowscriptaccess", 'value' => "false"));
         $object->pushContent($param);
         $flashvars = "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}";
         $param = HTML::param(array('name' => 'flashvars', 'value' => $flashvars));
         $object->pushContent($param);
         $embed = HTML::embed(array('type' => 'application/x-shockwave-flash', 'width' => $width, 'height' => $height, 'src' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.2.4.swf'), 'flashvars' => $flashvars));
         $object->pushContent($embed);
         $html->pushContent($object);
     } else {
         $object = HTML::object(array('data' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.2.4.swf'), 'type' => "application/x-shockwave-flash", 'width' => $width, 'height' => $height));
         $param = HTML::param(array('name' => "allowfullscreen", 'value' => "true"));
         $object->pushContent($param);
         $param = HTML::param(array('name' => "allowscriptaccess", 'value' => "false"));
         $object->pushContent($param);
         $value = "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}";
         $param = HTML::param(array('name' => "flashvars", 'value' => $value));
         $object->pushContent($param);
         $html->pushContent($object);
     }
     return $html;
 }
Ejemplo n.º 21
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if (!$args['pagename']) {
         return $this->error(_("No pagename specified"));
     }
     // Get our form args.
     $forum = $request->getArg('forum');
     $request->setArg('forum', false);
     if ($request->isPost() and !empty($forum['add'])) {
         return $this->add($request, $forum, 'wikiforum');
     }
     // Now we display previous comments and/or provide entry box
     // for new comments
     $html = HTML();
     foreach (explode(',', $args['mode']) as $show) {
         if (!empty($seen[$show])) {
             continue;
         }
         $seen[$show] = 1;
         switch ($show) {
             case 'summary':
                 // main page: list of all titles
                 $html->pushContent($this->showTopics($request, $args));
                 break;
             case 'show':
                 // list of all contents
                 $html->pushContent($this->showAll($request, $args, 'wikiforum'));
                 break;
             case 'add':
                 // add to or create a new thread
                 $html->pushContent($this->showForm($request, $args, 'forumadd'));
                 break;
             default:
                 return $this->error(sprintf("Bad mode ('%s')", $show));
         }
     }
     // FIXME: on empty showTopics() and mode!=add and mode!=summary provide a showForm() here.
     return $html;
 }
Ejemplo n.º 22
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request, false);
     $page =& $args['page'];
     if (ENABLE_AJAX) {
         if ($args['state']) {
             $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
         } else {
             $html = HTML(HTML::p(array('class' => 'transclusion-title'), fmt(" %s :", WikiLink($page))), HTML::div(array('class' => 'transclusion'), ''));
         }
         $ajaxuri = WikiURL($page, array('format' => 'xml'));
     } else {
         $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage);
     }
     $header = $html->_content[0];
     $body = $html->_content[1];
     $id = 'DynInc-' . MangleXmlIdentifier($page);
     $body->setAttr('id', $id . '-body');
     $png = $WikiTheme->_findData('images/folderArrow' . ($args['state'] ? 'Open' : 'Closed') . '.png');
     $icon = HTML::img(array('id' => $id . '-img', 'src' => $png, 'onclick' => ENABLE_AJAX ? "showHideAsync('" . $ajaxuri . "','{$id}')" : "showHideFolder('{$id}')", 'alt' => _("Click to hide/show"), 'title' => _("Click to hide/show")));
     $header = HTML::p(array('class' => 'transclusion-title', 'style' => "text-decoration: none;"), $icon, fmt(" %s :", WikiLink($page)));
     if ($args['state']) {
         // show base
         $body->setAttr('style', 'display:block');
         return HTML($header, $body);
     } else {
         // do not show base
         $body->setAttr('style', 'display:none');
         if (ENABLE_AJAX) {
             return HTML($header, $body);
         } else {
             return HTML($header, $body);
         }
         // sync (load but display:none)
     }
 }
Ejemplo n.º 23
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request);
     if (empty($this->source)) {
         return '';
     }
     $html = HTML();
     if (empty($WikiTheme->_asciiSVG)) {
         $js = JavaScript('', array('src' => $WikiTheme->_findData('ASCIIsvg.js')));
         if (empty($WikiTheme->_headers_printed)) {
             $WikiTheme->addMoreHeaders($js);
         } else {
             $html->pushContent($js);
         }
         $WikiTheme->_asciiSVG = 1;
         // prevent duplicates
     }
     // extract <script>
     if (preg_match("/^(.*)<script>(.*)<\\/script>/ism", $this->source, $m)) {
         $this->source = $m[1];
         $args['script'] = $m[2];
     }
     $embedargs = array('width' => $args['width'], 'height' => $args['height'], 'script' => $this->source);
     // additional onmousemove argument
     if ($args['onmousemove']) {
         $embedargs['onmousemove'] = $args['onmousemove'];
     }
     // we need script='data' and not script="data"
     $embed = new AsciiSVG_HTML("embed", $embedargs);
     $html->pushContent($embed);
     if ($args['script']) {
         $html->pushContent(JavaScript($args['script']));
     }
     return $html;
 }
Ejemplo n.º 24
0
 function chmarkupPages(&$dbi, &$request, $pages, $newmarkup)
 {
     $ul = HTML::ul();
     $count = 0;
     foreach ($pages as $name) {
         $page = $dbi->getPage($name);
         $current = $page->getCurrentRevision();
         $markup = $current->get('markup');
         if (!$markup or $newmarkup != $markup) {
             if (!mayAccessPage('change', $name)) {
                 $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name))));
             } else {
                 $version = $current->getVersion();
                 $meta = $current->_data;
                 $meta['markup'] = $newmarkup;
                 // convert text?
                 $text = $current->getPackedContent();
                 $meta['summary'] = sprintf(_("WikiAdminMarkup from %s to %s"), $markup, $newmarkup);
                 $page->save($text, $version + 1, $meta);
                 $current = $page->getCurrentRevision();
                 if ($current->get('markup') === $newmarkup) {
                     $ul->pushContent(HTML::li(fmt("change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup)));
                     $count++;
                 } else {
                     $ul->pushContent(HTML::li(fmt("Couldn't change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup)));
                 }
             }
         }
     }
     if ($count) {
         $dbi->touch();
         return HTML($ul, HTML::p(fmt("%s pages have been permanently changed.", $count)));
     } else {
         return HTML($ul, HTML::p(fmt("No pages changed.")));
     }
 }
Ejemplo n.º 25
0
 function chmodPages(&$dbi, &$request, $pages, $permstring)
 {
     $ul = HTML::ul();
     $count = 0;
     $acl = chmodHelper($permstring);
     if ($perm = new PagePermission($acl)) {
         foreach ($pages as $name) {
             if ($perm->store($dbi->getPage($name))) {
                 $ul->pushContent(HTML::li(fmt("chmod page '%s' to '%s'.", $name, $permstring)));
                 $count++;
             } else {
                 $ul->pushContent(HTML::li(fmt("Couldn't chmod page '%s' to '%s'.", $name, $permstring)));
             }
         }
     } else {
         $ul->pushContent(HTML::li(fmt("Invalid chmod string")));
     }
     if ($count) {
         $dbi->touch();
         return HTML($ul, HTML::p(fmt("%s pages have been changed.", $count)));
     } else {
         return HTML($ul, HTML::p(fmt("No pages changed.")));
     }
 }
Ejemplo n.º 26
0
function actionPage(&$request, $action)
{
    global $WikiTheme;
    $pagename = $request->getArg('pagename');
    $version = $request->getArg('version');
    $page = $request->getPage();
    $revision = $page->getCurrentRevision();
    $dbi = $request->getDbh();
    $actionpage = $dbi->getPage($action);
    $actionrev = $actionpage->getCurrentRevision();
    $pagetitle = HTML(fmt("%s: %s", $actionpage->getName(), $WikiTheme->linkExistingWikiWord($pagename, false, $version)));
    $validators = new HTTP_ValidatorSet(array('pageversion' => $revision->getVersion(), '%mtime' => $revision->get('mtime')));
    $request->appendValidators(array('pagerev' => $revision->getVersion(), '%mtime' => $revision->get('mtime')));
    $request->appendValidators(array('actionpagerev' => $actionrev->getVersion(), '%mtime' => $actionrev->get('mtime')));
    $transformedContent = $actionrev->getTransformedContent();
    $template = Template('browse', array('CONTENT' => $transformedContent));
    /*
        if (!headers_sent()) {
            //FIXME: does not work yet. document.write not supported (signout button)
            // http://www.w3.org/People/mimasa/test/xhtml/media-types/results
            if (ENABLE_XHTML_XML 
                and (!isBrowserIE() and
                     strstr($request->get('HTTP_ACCEPT'),'application/xhtml+xml')))
                header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']);
            else
                header("Content-Type: text/html; charset=" . $GLOBALS['charset']);
        }
    */
    /* Tell google (and others) not to take notice of action pages */
    if (GOOGLE_LINKS_NOFOLLOW) {
        $args = array('ROBOTS_META' => "noindex,nofollow");
    }
    GeneratePage($template, $pagetitle, $revision, $args);
    $request->checkValidators();
    flush();
}
Ejemplo n.º 27
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $this->allowed_extensions = explode("\n", "7z\navi\nbmp\nbz2\nc\ncfg\ndiff\ndoc\ndocx\nflv\ngif\nh\nics\nini\njpeg\njpg\nkmz\nmp3\nodg\nodp\nods\nodt\nogg\npatch\npdf\npng\nppt\npptx\nrar\nsvg\ntar\ntar.gz\ntxt\nxls\nxlsx\nxml\nxsd\nzip");
     $this->disallowed_extensions = explode("\n", "ad[ep]\nasd\nba[st]\nchm\ncmd\ncom\ncgi\ncpl\ncrt\ndll\neml\nexe\nhlp\nhta\nin[fs]\nisp\njse?\nlnk\nmd[betw]\nms[cipt]\nnws\nocx\nops\npcd\np[ir]f\nphp\\d?\nphtml\npl\npy\nreg\nsc[frt]\nsh[bsm]?\nswf\nurl\nvb[esx]?\nvxd\nws[cfh]");
     //removed "\{[[:xdigit:]]{8}(?:-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}\}"
     $args = $this->getArgs($argstr, $request);
     extract($args);
     $file_dir = getUploadFilePath();
     $file_dir .= "/";
     $form = HTML::form(array('action' => $request->getPostURL(), 'enctype' => 'multipart/form-data', 'method' => 'post'));
     $contents = HTML::div(array('class' => 'wikiaction'));
     $contents->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => MAX_UPLOAD_SIZE)));
     $contents->pushContent(HTML::input(array('name' => 'userfile', 'type' => 'file', 'size' => $size)));
     if ($mode == 'edit') {
         $contents->pushContent(HTML::input(array('name' => 'action', 'type' => 'hidden', 'value' => 'edit')));
         $contents->pushContent(HTML::raw(" "));
         $contents->pushContent(HTML::input(array('value' => _("Upload"), 'name' => 'edit[upload]', 'type' => 'submit')));
     } else {
         $contents->pushContent(HTML::raw(" "));
         $contents->pushContent(HTML::input(array('value' => _("Upload"), 'type' => 'submit')));
     }
     $form->pushContent($contents);
     $message = HTML();
     if ($request->isPost() and $this->only_authenticated) {
         // Make sure that the user is logged in.
         $user = $request->getUser();
         if (!$user->isAuthenticated()) {
             if (defined('FUSIONFORGE') and FUSIONFORGE) {
                 $message->pushContent(HTML::div(array('class' => 'error'), HTML::p(_("You cannot upload files.")), HTML::ul(HTML::li(_("Check you are logged in.")), HTML::li(_("Check you are in the right project.")), HTML::li(_("Check you are a member of the current project.")))));
             } else {
                 $message->pushContent(HTML::div(array('class' => 'error'), HTML::p(_("ACCESS DENIED: You must log in to upload files."))));
             }
             $result = HTML();
             $result->pushContent($form);
             $result->pushContent($message);
             return $result;
         }
     }
     $userfile = $request->getUploadedFile('userfile');
     if ($userfile) {
         $userfile_name = $userfile->getName();
         $userfile_name = trim(basename($userfile_name));
         if (UPLOAD_USERDIR) {
             $file_dir .= $request->_user->_userid;
             if (!file_exists($file_dir)) {
                 mkdir($file_dir, 0775);
             }
             $file_dir .= "/";
             $u_userfile = $request->_user->_userid . "/" . $userfile_name;
         } else {
             $u_userfile = $userfile_name;
         }
         $u_userfile = preg_replace("/ /", "%20", $u_userfile);
         $userfile_tmpname = $userfile->getTmpName();
         $err_header = HTML::div(array('class' => 'error'), HTML::p(fmt("ERROR uploading '%s'", $userfile_name)));
         if (preg_match("/(\\." . join("|\\.", $this->disallowed_extensions) . ")(\\.|\$)/i", $userfile_name)) {
             $message->pushContent($err_header);
             $message->pushContent(HTML::p(fmt("Files with extension %s are not allowed.", join(", ", $this->disallowed_extensions))));
         } elseif (!DISABLE_UPLOAD_ONLY_ALLOWED_EXTENSIONS and !preg_match("/(\\." . join("|\\.", $this->allowed_extensions) . ")\$/i", $userfile_name)) {
             $message->pushContent($err_header);
             $message->pushContent(HTML::p(fmt("Only files with the extension %s are allowed.", join(", ", $this->allowed_extensions))));
         } elseif (preg_match("/[^._a-zA-Z0-9- ]/", strip_accents($userfile_name))) {
             $message->pushContent($err_header);
             $message->pushContent(HTML::p(_("Invalid filename. File names may only contain alphanumeric characters and dot, underscore, space or dash.")));
         } elseif (file_exists($file_dir . $userfile_name)) {
             $message->pushContent($err_header);
             $message->pushContent(HTML::p(fmt("There is already a file with name %s uploaded.", $u_userfile)));
         } elseif ($userfile->getSize() > MAX_UPLOAD_SIZE) {
             $message->pushContent($err_header);
             $message->pushContent(HTML::p(_("Sorry but this file is too big.")));
         } elseif (move_uploaded_file($userfile_tmpname, $file_dir . $userfile_name) or IsWindows() and rename($userfile_tmpname, $file_dir . $userfile_name)) {
             $interwiki = new PageType_interwikimap();
             $link = $interwiki->link("Upload:{$u_userfile}");
             $message->pushContent(HTML::div(array('class' => 'feedback'), HTML::p(_("File successfully uploaded.")), HTML::p($link)));
             // the upload was a success and we need to mark this event in the "upload log"
             if ($logfile) {
                 $upload_log = $file_dir . basename($logfile);
                 $this->log($userfile, $upload_log, $message);
             }
             if ($autolink) {
                 require_once "lib/loadsave.php";
                 $pagehandle = $dbi->getPage($page);
                 if ($pagehandle->exists()) {
                     // don't replace default contents
                     $current = $pagehandle->getCurrentRevision();
                     $version = $current->getVersion();
                     $text = $current->getPackedContent();
                     $newtext = $text . "\n* Upload:{$u_userfile}";
                     // don't inline images
                     $meta = $current->_data;
                     $meta['summary'] = sprintf(_("uploaded %s"), $u_userfile);
                     $pagehandle->save($newtext, $version + 1, $meta);
                 }
             }
         } else {
             $message->pushContent($err_header);
             $message->pushContent(HTML::br(), _("Uploading failed."), HTML::br());
         }
     } else {
         $message->pushContent(HTML::br(), _("No file selected. Please select one."), HTML::br());
     }
     //$result = HTML::div( array( 'class' => 'wikiaction' ) );
     $result = HTML();
     $result->pushContent($form);
     $result->pushContent($message);
     return $result;
 }
Ejemplo n.º 28
0
 function format($changes)
 {
     include_once 'lib/InlineParser.php';
     $last_date = '';
     $first = true;
     $html = HTML();
     $counter = 1;
     $sp = HTML::Raw("\n&nbsp;&middot;&nbsp;");
     while ($rev = $changes->next()) {
         // enforce view permission
         if (mayAccessPage('view', $rev->_pagename)) {
             if ($link = $this->pageLink($rev)) {
                 // some entries may be empty
                 // (/Blog/.. interim pages)
                 $html->pushContent($sp, $link, HTML::br());
             }
             if ($first) {
                 $this->setValidators($rev);
             }
             $first = false;
         }
     }
     if ($first) {
         $html->pushContent(HTML::p(array('class' => 'rc-empty'), $this->empty_message()));
     }
     return $html;
 }
Ejemplo n.º 29
0
} else {
    foreach ($examples as $example) {
        $example_data = file_get_contents($example['path']);
        $example_data = str_replace('	', '  ', $example_data);
        $example_data = str_replace('$example_video_path', '\'' . addslashes($example_video_path) . '\'', $example_data);
        $example_data = str_replace('$example_audio_path', '\'' . addslashes($example_audio_path) . '\'', $example_data);
        $example_data = str_replace(BASE, './', $example_data);
        ?>

	<div class="span9 pull-right">
		<h4><?php 
        echo HTML($example['name']);
        ?>
</h4>
		<p><?php 
        echo nl2br(HTML($example['description']));
        ?>
</p>
		<p><?php 
        echo HTML($example['path']);
        ?>
</p>
		<pre class="prettyprint"><code><?php 
        echo HTML($example_data);
        ?>
</code></pre>
	</div>

<?php 
    }
}
Ejemplo n.º 30
0
function displayPage(&$request, $template = false)
{
    global $WikiTheme, $pv;
    $pagename = $request->getArg('pagename');
    $version = $request->getArg('version');
    $page = $request->getPage();
    if ($version) {
        $revision = $page->getRevision($version);
        if (!$revision) {
            NoSuchRevision($request, $page, $version);
        }
    } else {
        $revision = $page->getCurrentRevision();
    }
    if (isSubPage($pagename)) {
        $pages = explode(SUBPAGE_SEPARATOR, $pagename);
        $last_page = array_pop($pages);
        // deletes last element from array as side-effect
        $pageheader = HTML::span(HTML::a(array('href' => WikiURL($pages[0]), 'class' => 'pagetitle'), $WikiTheme->maybeSplitWikiWord($pages[0] . SUBPAGE_SEPARATOR)));
        $first_pages = $pages[0] . SUBPAGE_SEPARATOR;
        array_shift($pages);
        foreach ($pages as $p) {
            if ($pv != 2) {
                //Add the Backlink in page title
                $pageheader->pushContent(HTML::a(array('href' => WikiURL($first_pages . $p), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($p . SUBPAGE_SEPARATOR)));
            } else {
                // Remove Backlinks
                $pageheader->pushContent(HTML::h1($pagename));
            }
            $first_pages .= $p . SUBPAGE_SEPARATOR;
        }
        if ($pv != 2) {
            $backlink = HTML::a(array('href' => WikiURL($pagename, array('action' => _("BackLinks"))), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($last_page));
            $backlink->addTooltip(sprintf(_("BackLinks for %s"), $pagename));
        } else {
            $backlink = HTML::h1($pagename);
        }
        $pageheader->pushContent($backlink);
    } else {
        if ($pv != 2) {
            $pageheader = HTML::a(array('href' => WikiURL($pagename, array('action' => _("BackLinks"))), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($pagename));
            $pageheader->addTooltip(sprintf(_("BackLinks for %s"), $pagename));
        } else {
            $pageheader = HTML::h1($pagename);
            //Remove Backlinks
        }
        if ($request->getArg('frame')) {
            $pageheader->setAttr('target', '_top');
        }
    }
    // {{{ Codendi hook to insert stuff between navbar and header
    $eM =& EventManager::instance();
    $ref_html = '';
    $crossref_fact = new CrossReferenceFactory($pagename, ReferenceManager::REFERENCE_NATURE_WIKIPAGE, GROUP_ID);
    $crossref_fact->fetchDatas();
    if ($crossref_fact->getNbReferences() > 0) {
        $ref_html .= '<h3>' . $GLOBALS['Language']->getText('cross_ref_fact_include', 'references') . '</h3>';
        $ref_html .= $crossref_fact->getHTMLDisplayCrossRefs();
    }
    $additional_html = false;
    $eM->processEvent('wiki_before_content', array('html' => &$additional_html, 'group_id' => GROUP_ID, 'wiki_page' => $pagename));
    if ($additional_html) {
        $beforeHeader = HTML();
        $beforeHeader->pushContent($additional_html);
        $beforeHeader->pushContent(HTML::raw($ref_html));
        $toks['BEFORE_HEADER'] = $beforeHeader;
    } else {
        $beforeHeader = HTML();
        $beforeHeader->pushContent(HTML::raw($ref_html));
        $toks['BEFORE_HEADER'] = $beforeHeader;
    }
    // }}} /Codendi hook
    $pagetitle = SplitPagename($pagename);
    if ($redirect_from = $request->getArg('redirectfrom')) {
        $redirect_message = HTML::span(array('class' => 'redirectfrom'), fmt("(Redirected from %s)", RedirectorLink($redirect_from)));
        // abuse the $redirected template var for some status update notice
    } elseif ($request->getArg('errormsg')) {
        $redirect_message = $request->getArg('errormsg');
        $request->setArg('errormsg', false);
    }
    $request->appendValidators(array('pagerev' => $revision->getVersion(), '%mtime' => $revision->get('mtime')));
    /*
        // FIXME: This is also in the template...
        if ($request->getArg('action') != 'pdf' and !headers_sent()) {
          // FIXME: enable MathML/SVG/... support
          if (ENABLE_XHTML_XML
                 and (!isBrowserIE()
                      and strstr($request->get('HTTP_ACCEPT'),'application/xhtml+xml')))
                header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']);
            else
                header("Content-Type: text/html; charset=" . $GLOBALS['charset']);
        }
    */
    $page_content = $revision->getTransformedContent();
    // if external searchengine (google) referrer, highlight the searchterm
    // FIXME: move that to the transformer?
    // OR: add the searchhightplugin line to the content?
    if ($result = isExternalReferrer($request)) {
        if (DEBUG and !empty($result['query'])) {
            //$GLOBALS['SearchHighlightQuery'] = $result['query'];
            /* simply add the SearchHighlight plugin to the top of the page. 
               This just parses the wikitext, and doesn't highlight the markup */
            include_once 'lib/WikiPlugin.php';
            $loader = new WikiPluginLoader();
            $xml = $loader->expandPI('<' . '?plugin SearchHighlight s="' . $result['query'] . '"?' . '>', $request, $markup);
            if ($xml and is_array($xml)) {
                foreach (array_reverse($xml) as $line) {
                    array_unshift($page_content->_content, $line);
                }
                array_unshift($page_content->_content, HTML::div(_("You searched for: "), HTML::strong($result['query'])));
            }
            if (0) {
                /* Parse the transformed (mixed HTML links + strings) lines?
                     This looks like overkill.
                   */
                require_once "lib/TextSearchQuery.php";
                $query = new TextSearchQuery($result['query']);
                $hilight_re = $query->getHighlightRegexp();
                //$matches = preg_grep("/$hilight_re/i", $revision->getContent());
                // FIXME!
                for ($i = 0; $i < count($page_content->_content); $i++) {
                    $found = false;
                    $line = $page_content->_content[$i];
                    if (is_string($line)) {
                        while (preg_match("/^(.*?)({$hilight_re})/i", $line, $m)) {
                            $found = true;
                            $line = substr($line, strlen($m[0]));
                            $html[] = $m[1];
                            // prematch
                            $html[] = HTML::strong(array('class' => 'search-term'), $m[2]);
                            // match
                        }
                    }
                    if ($found) {
                        $html[] = $line;
                        // postmatch
                        $page_content->_content[$i] = HTML::span(array('class' => 'search-context'), $html);
                    }
                }
            }
        }
    }
    $toks['CONTENT'] = new Template('browse', $request, $page_content);
    $toks['TITLE'] = $pagetitle;
    // <title> tag
    $toks['HEADER'] = $pageheader;
    // h1 with backlink
    $toks['revision'] = $revision;
    if (!empty($redirect_message)) {
        $toks['redirected'] = $redirect_message;
    }
    $toks['ROBOTS_META'] = 'index,follow';
    $toks['PAGE_DESCRIPTION'] = $page_content->getDescription();
    $toks['PAGE_KEYWORDS'] = GleanKeywords($page);
    if (!$template) {
        $template = new Template('html', $request);
    }
    $template->printExpansion($toks);
    $page->increaseHitCount();
    if ($request->getArg('action') != 'pdf') {
        $request->checkValidators();
    }
    flush();
}