Exemplo n.º 1
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     $parser = new AtomParser();
     assert(!empty($url));
     $parser->parse_url($url);
     $html = '';
     $items = HTML::dl();
     foreach ($parser->feed as $feed) {
         $title = HTML::h3(HTML::a(array('href' => $feed["links"]["0"]["href"]), $feed["title"]));
         $counter = 1;
         foreach ($parser->entries as $entry) {
             $item = HTML::dt(HTML::a(array('href' => $entry["links"]["0"]["href"]), $entry["title"]));
             $items->pushContent($item);
             if (!$titleonly) {
                 $description = HTML::dd(HTML::raw(html_entity_decode($entry["content"])));
             } else {
                 $description = HTML::dd();
             }
             $items->pushContent($description);
             if ($maxitem > 0 && $counter >= $maxitem) {
                 break;
             }
             $counter++;
         }
         $html = HTML::div(array('class' => 'rss'), $title);
         $html->pushContent($items);
     }
     return $html;
 }
Exemplo n.º 2
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     /* plugin not yet has arguments - save for later (copied from UpLoad)
        $args = $this->getArgs($argstr, $request);
        extract($args);
                */
     $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' => '50')));
     $contents->pushContent(HTML::raw(" "));
     $contents->pushContent(HTML::input(array('value' => _("Convert"), 'type' => 'submit')));
     $form->pushContent($contents);
     $message = HTML();
     $userfile = $request->getUploadedFile('userfile');
     if ($userfile) {
         $userfile_name = $userfile->getName();
         $userfile_name = basename($userfile_name);
         $userfile_tmpname = $userfile->getTmpName();
         if (!preg_match("/(\\.html|\\.htm)\$/i", $userfile_name)) {
             $message->pushContent(_("Only files with extension HTML are allowed"), HTML::br(), HTML::br());
         } else {
             $message->pushContent(_("Processed {$userfile_name}"), HTML::br(), HTML::br());
             $message->pushContent(_("Copy the output below and paste it into your Wiki page."), HTML::br());
             $message->pushContent($this->_process($userfile_tmpname));
         }
     } else {
         $message->pushContent(HTML::br(), HTML::br());
     }
     $result = HTML();
     $result->pushContent($form);
     $result->pushContent($message);
     return $result;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     // works regardless of WIKIDB_NOCACHE_MARKUP
     // if WIKIDB_NOCACHE_MARKUP is false it doesn't hurt
     $request->setArg('nocache', $args['nocache']);
     return HTML::raw('');
 }
Exemplo n.º 5
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     if ($format == 'date') {
         $format = '%Y-%m-%d';
     }
     if ($format == 'time') {
         $format = '%T';
     }
     return HTML::raw(strftime($format, time()));
 }
Exemplo n.º 6
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     if (empty($this->source)) {
         return HTML::div(array('class' => "error"), "Please provide a formula to AsciiMath plugin");
     }
     if (phpversion() >= '5') {
         include "lib/ASCIIMathPHP/ASCIIMathPHP-2.0.cfg.php";
     } else {
         include "lib/ASCIIMathPHP/ASCIIMathPHP.cfg.php";
     }
     $ascii_math = new ASCIIMathPHP($symbol_arr, $this->source);
     $ascii_math->genMathML();
     return HTML::raw($ascii_math->getMathML());
 }
Exemplo n.º 7
0
 function showForm(&$dbi, &$request, $args)
 {
     global $WikiTheme;
     $action = $request->getPostURL();
     $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'semsearch', 'relation', 'attribute'));
     $pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
     $allrelations = $dbi->listRelations(false, false, true);
     $svalues = empty($allrelations) ? "" : join("','", $allrelations);
     $reldef = JavaScript("var semsearch_relations = new Array('" . $svalues . "')");
     $relation = HTML::input(array('name' => 'relation', 'value' => $args['relation'], 'title' => _("Filter by this relation. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'array:semsearch_relations'), '');
     $queryrel = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this link. These are pagenames. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
     $relsubmit = Button('submit:semsearch[relations]', _("Relations"), false);
     // just testing some dhtml... not yet done
     $enhancements = HTML();
     $nbsp = HTML::raw('&nbsp;');
     $this_uri = $_SERVER['REQUEST_URI'] . '#';
     $andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'and')", 'title' => _("Add an AND query")));
     $orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'or')", 'title' => _("Add an OR query")));
     if (DEBUG) {
         $enhancements = HTML::span($andbutton, $nbsp, $orbutton);
     }
     $instructions = _("Search in pages for a relation with that value (a pagename).");
     $form1 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $reldef, $hiddenfield, HiddenInputs(array('attribute' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Relation'), HTML::th(), HTML::th('Links'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($relation), HTML::td(HTML::strong(HTML::tt('  ::  '))), HTML::td($queryrel), HTML::td($nbsp, $relsubmit, $nbsp, $enhancements)))));
     $allattrs = $dbi->listRelations(false, true, true);
     if (empty($allrelations) and empty($allattrs)) {
         // be nice to the dummy.
         $this->_norelations_warning = 1;
     }
     $svalues = empty($allattrs) ? "" : join("','", $allattrs);
     $attdef = JavaScript("var semsearch_attributes = new Array('" . $svalues . "')\n" . "var semsearch_op = new Array('" . join("','", $this->_supported_operators) . "')");
     // TODO: We want some more tricks: Autofill the base unit of the selected
     // attribute into the s area.
     $attribute = HTML::input(array('name' => 'attribute', 'value' => $args['attribute'], 'title' => _("Filter by this attribute name. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_attributes'), '');
     $attr_op = HTML::input(array('name' => 'attr_op', 'value' => $args['attr_op'], 'title' => _("Comparison operator. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:2em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_op'), '');
     $queryatt = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this numeric attribute value. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'plugin:SemanticSearch page=' . $args['page'] . ' attribute=^[S] attr_op==~'), '');
     $andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'and')", 'title' => _("Add an AND query")));
     $orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'or')", 'title' => _("Add an OR query")));
     if (DEBUG) {
         $enhancements = HTML::span($andbutton, $nbsp, $orbutton);
     }
     $attsubmit = Button('submit:semsearch[attributes]', _("Attributes"), false);
     $instructions = HTML::span(_("Search in pages for an attribute with that numeric value."), "\n");
     if (DEBUG) {
         $instructions->pushContent(HTML(" ", new Button(_("Advanced..."), _("SemanticSearchAdvanced"))));
     }
     $form2 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $attdef, $hiddenfield, HiddenInputs(array('relation' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Attribute'), HTML::th('Op'), HTML::th('Value'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($attribute), HTML::td($attr_op), HTML::td($queryatt), HTML::td($nbsp, $attsubmit, $nbsp, $enhancements)))));
     return HTML($form1, $form2);
 }
Exemplo n.º 8
0
 function showForm(&$dbi, &$request, $args)
 {
     $action = $request->getPostURL();
     $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'direction'));
     $pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
     $query = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this link. These are pagenames. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
     $dirsign_switch = JavaScript("\nfunction dirsign_switch() {\n  var d = document.getElementById('dirsign')\n  d.innerHTML = (d.innerHTML == ' =&gt; ') ? ' &lt;= ' : ' =&gt; '\n}\n");
     $dirsign = " => ";
     $in = $out = array('name' => 'direction', 'type' => 'radio', 'onChange' => 'dirsign_switch()');
     $out['value'] = 'out';
     $out['id'] = 'dir_out';
     if ($args['direction'] == 'out') {
         $out['checked'] = 'checked';
     }
     $in['value'] = 'in';
     $in['id'] = 'dir_in';
     if ($args['direction'] == 'in') {
         $in['checked'] = 'checked';
         $dirsign = " <= ";
     }
     $direction = HTML(HTML::input($out), HTML::label(array('for' => 'dir_out'), _("outgoing")), HTML::input($in), HTML::label(array('for' => 'dir_in'), _("incoming")));
     /*
     $direction = HTML::select(array('name'=>'direction',
                                     'onChange' => 'dirsign_switch()'));
     $out = array('value' => 'out');
     if ($args['direction']=='out') $out['selected'] = 'selected';
     $in = array('value' => 'in');
     if ($args['direction']=='in') {
         $in['selected'] = 'selected';
         $dirsign = " <= ";
     }
     $direction->pushContent(HTML::option($out, _("outgoing")));
     $direction->pushContent(HTML::option($in, _("incoming")));
     */
     $submit = Button('submit:search', _("LinkSearch"), false);
     $instructions = _("Search in pages for links with the matching name.");
     $form = HTML::form(array('action' => $action, 'method' => 'GET', 'accept-charset' => $GLOBALS['charset']), $dirsign_switch, $hiddenfield, $instructions, HTML::br(), $pagefilter, HTML::strong(HTML::tt(array('id' => 'dirsign'), $dirsign)), $query, HTML::raw('&nbsp;'), $direction, HTML::raw('&nbsp;'), $submit);
     return $form;
 }
Exemplo n.º 9
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     if (!isset($_SERVER)) {
         $_SERVER =& $GLOBALS['HTTP_SERVER_VARS'];
     }
     $request->setArg('nocache', 'purge');
     $args = $this->getArgs($argstr, $request);
     if (!$args['page']) {
         return $this->error("No page specified");
     }
     if (!empty($args['admin']) and $request->_user->isAdmin()) {
         // reset statistics
         return $this->doPollAdmin($dbi, $request, $page);
     }
     extract($this->_args);
     $page = $dbi->getPage($args['page']);
     // check ip and last visit
     $poll = $page->get("poll");
     $ip = $_SERVER['REMOTE_ADDR'];
     $disable_submit = false;
     if (isset($poll['ip'][$ip]) and time() - $poll['ip'][$ip] < 20 * 60) {
         //view at least the result or disable the Go button
         $html = HTML(HTML::strong(_("Sorry! You must wait at least 20 minutes until you can vote again!")));
         $html->pushContent($this->doPoll($page, $request, $request->getArg('answer'), true));
         return $html;
     }
     $poll['ip'][$ip] = time();
     // purge older ip's
     foreach ($poll['ip'] as $ip => $time) {
         if (time() - $time > 21 * 60) {
             unset($poll['ip'][$ip]);
         }
     }
     $html = HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'));
     if ($request->isPost()) {
         // checkme: check if all answers are answered
         if ($request->getArg('answer') and ($args['require_all'] and count($request->getArg('answer')) == count($question) or $args['require_least'] and count($request->getArg('answer')) >= $args['require_least'])) {
             $page->set("poll", $poll);
             // update statistics and present them the user
             return $this->doPoll($page, $request, $request->getArg('answer'));
         } else {
             $html->pushContent(HTML::p(HTML::strong(_("Not enough questions answered!"))));
         }
     }
     $init = isset($question[0]) ? 0 : 1;
     for ($i = $init; $i <= count($question); $i++) {
         if (!isset($question[$i])) {
             break;
         }
         $q = $question[$i];
         if (!isset($answer[$i])) {
             trigger_error(fmt("Missing %s for %s", "answer" . "[{$i}]", "question" . "[{$i}]"), E_USER_ERROR);
         }
         $a = $answer[$i];
         if (!is_array($a)) {
             // a simple checkbox
             $html->pushContent(HTML::p(HTML::strong($q)));
             $html->pushContent(HTML::div(HTML::input(array('type' => 'checkbox', 'name' => "answer[{$i}]", 'value' => 1)), HTML::raw("&nbsp;"), $a));
         } else {
             $row = HTML();
             for ($j = 0; $j <= count($a); $j++) {
                 if (isset($a[$j])) {
                     $row->pushContent(HTML::div(HTML::input(array('type' => 'radio', 'name' => "answer[{$i}]", 'value' => $j)), HTML::raw("&nbsp;"), $a[$j]));
                 }
             }
             $html->pushContent(HTML::p(HTML::strong($q)), $row);
         }
     }
     if (!$disable_submit) {
         $html->pushContent(HTML::p(HTML::input(array('type' => 'submit', 'name' => "WikiPoll", 'value' => _("OK"))), HTML::input(array('type' => 'reset', 'name' => "reset", 'value' => _("Reset")))));
     } else {
         $html->pushContent(HTML::p(), HTML::strong(_("Sorry! You must wait at least 20 minutes until you can vote again!")));
     }
     return $html;
 }
Exemplo n.º 10
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     $source =& $this->source;
     if (empty($syntax)) {
         return $this->error(_("Syntax language not specified."));
     }
     if (!empty($source)) {
         $args = "";
         if (defined('HIGHLIGHT_DATA_DIR')) {
             $args .= " --data-dir " . HIGHLIGHT_DATA_DIR;
         }
         if ($number != 0) {
             $args .= " -l";
         }
         if ($wrap != 0) {
             $args .= " -V";
         }
         $html = HTML();
         if (!empty($color) and !preg_match('/^[\\w-]+$/', $color)) {
             $html->pushContent($this->error(fmt("invalid %s ignored", 'color')));
             $color = false;
         }
         if (!empty($color)) {
             $args .= " --style {$color} -c " . FindFile("uploads") . "/highlight-{$color}.css";
         }
         if (!empty($style)) {
             $args .= " -F {$style}";
         }
         $commandLine = HIGHLIGHT_EXE . "{$args} -q -X -f -S {$syntax}";
         if (check_php_version(4, 3, 0)) {
             $code = $this->newFilterThroughCmd($source, $commandLine);
         } else {
             $code = $this->oldFilterThroughCmd($source, $commandLine);
         }
         if (empty($code)) {
             return $this->error(fmt("Couldn't start commandline '%s'", $commandLine));
         }
         $pre = HTML::pre(HTML::raw($code));
         $pre->setAttr('class', 'tightenable top bottom');
         $html->pushContent($pre);
         $css = $GLOBALS['WikiTheme']->_CSSlink('', empty($color) ? 'highlight.css' : "uploads/highlight-{$color}.css", '');
         return HTML($css, $html);
     } else {
         return $this->error(fmt("empty source"));
     }
 }
Exemplo n.º 11
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $this->_args = $this->getArgs($argstr, $request);
     extract($this->_args);
     //trigger_error("1 p= $page a= $author");
     if ($page && $page == 'username') {
         //FIXME: use [username]!!!!!
         $page = $author;
     }
     //trigger_error("2 p= $page a= $author");
     if (!$page || !$author) {
         //user not signed in or no author specified
         return '';
     }
     //$pagelist = new PageList($info, $exclude);
     ///////////////////////////
     $nbsp = HTML::raw('&nbsp;');
     global $WikiTheme;
     // date & time formatting
     if (!($page == 'all')) {
         $p = $dbi->getPage($page);
         $t = HTML::table(array('class' => 'pagelist', 'style' => 'font-size:smaller'));
         $th = HTML::thead();
         $tb = HTML::tbody();
         $th->pushContent(HTML::tr(HTML::td(array('align' => 'right'), _("Version")), $includeminor ? HTML::td(_("Minor")) : "", HTML::td(_("Author")), HTML::td(_("Summary")), HTML::td(_("Modified"))));
         $allrevisions_iter = $p->getAllRevisions();
         while ($rev = $allrevisions_iter->next()) {
             $isminor = $rev->get('is_minor_edit');
             $authordoesmatch = $author == $rev->get('author');
             if ($authordoesmatch && (!$isminor || $includeminor && $isminor)) {
                 $difflink = Button(array('action' => 'diff', 'previous' => 'minor'), $rev->getversion(), $rev);
                 $tr = HTML::tr(HTML::td(array('align' => 'right'), $difflink, $nbsp), $includeminor ? HTML::td($nbsp, $isminor ? "minor" : "major", $nbsp) : "", HTML::td($nbsp, WikiLink($rev->get('author'), 'if_known'), $nbsp), HTML::td($nbsp, $rev->get('summary')), HTML::td(array('align' => 'right'), $WikiTheme->formatdatetime($rev->get('mtime'))));
                 $class = $isminor ? 'evenrow' : 'oddrow';
                 $tr->setAttr('class', $class);
                 $tb->pushContent($tr);
                 //$pagelist->addPage($rev->getPage());
             }
         }
         $captext = fmt($includeminor ? "History of all major and minor edits by %s to page %s." : "History of all major edits by %s to page %s.", WikiLink($author, 'auto'), WikiLink($page, 'auto'));
         $t->pushContent(HTML::caption($captext));
         $t->pushContent($th, $tb);
     } else {
         //search all pages for all edits by this author
         /////////////////////////////////////////////////////////////
         $t = HTML::table(array('class' => 'pagelist', 'style' => 'font-size:smaller'));
         $th = HTML::thead();
         $tb = HTML::tbody();
         $th->pushContent(HTML::tr(HTML::td(_("Page Name")), HTML::td(array('align' => 'right'), _("Version")), $includeminor ? HTML::td(_("Minor")) : "", HTML::td(_("Summary")), HTML::td(_("Modified"))));
         /////////////////////////////////////////////////////////////
         $allpages_iter = $dbi->getAllPages($includedeleted);
         while ($p = $allpages_iter->next()) {
             /////////////////////////////////////////////////////////////
             $allrevisions_iter = $p->getAllRevisions();
             while ($rev = $allrevisions_iter->next()) {
                 $isminor = $rev->get('is_minor_edit');
                 $authordoesmatch = $author == $rev->get('author');
                 if ($authordoesmatch && (!$isminor || $includeminor && $isminor)) {
                     $difflink = Button(array('action' => 'diff', 'previous' => 'minor'), $rev->getversion(), $rev);
                     $tr = HTML::tr(HTML::td($nbsp, $isminor ? $rev->_pagename : WikiLink($rev->_pagename, 'auto')), HTML::td(array('align' => 'right'), $difflink, $nbsp), $includeminor ? HTML::td($nbsp, $isminor ? "minor" : "major", $nbsp) : "", HTML::td($nbsp, $rev->get('summary')), HTML::td(array('align' => 'right'), $WikiTheme->formatdatetime($rev->get('mtime')), $nbsp));
                     $class = $isminor ? 'evenrow' : 'oddrow';
                     $tr->setAttr('class', $class);
                     $tb->pushContent($tr);
                     //$pagelist->addPage($rev->getPage());
                 }
             }
             /////////////////////////////////////////////////////////////
         }
         $captext = fmt($includeminor ? "History of all major and minor modifications for any page edited by %s." : "History of major modifications for any page edited by %s.", WikiLink($author, 'auto'));
         $t->pushContent(HTML::caption($captext));
         $t->pushContent($th, $tb);
     }
     //        if (!$noheader) {
     // total minor, major edits. if include minoredits was specified
     //        }
     return $t;
     //        if (!$noheader) {
     //            $pagelink = WikiLink($page, 'auto');
     //
     //            if ($pagelist->isEmpty())
     //                return HTML::p(fmt("No pages link to %s.", $pagelink));
     //
     //            if ($pagelist->getTotal() == 1)
     //                $pagelist->setCaption(fmt("One page links to %s:",
     //                                          $pagelink));
     //            else
     //                $pagelist->setCaption(fmt("%s pages link to %s:",
     //                                          $pagelist->getTotal(), $pagelink));
     //        }
     //
     //        return $pagelist;
 }
Exemplo n.º 12
0
 * is not set, any signature defined in index.php will be used. If it
 * is not defined by index.php or in here then the "Thank you for
 * editing..." screen will be omitted.
 */
// Comment this next line out to enable signature.
$WikiTheme->addImageAlias('signature', false);
/*
 * Link icons.
 */
$WikiTheme->setLinkIcon('http');
$WikiTheme->setLinkIcon('https');
$WikiTheme->setLinkIcon('ftp');
$WikiTheme->setLinkIcon('mailto');
$WikiTheme->setLinkIcon('interwiki');
$WikiTheme->setLinkIcon('*', 'url');
$WikiTheme->setButtonSeparator(HTML::raw("&nbsp;|&nbsp;"));
/**
 * WikiWords can automatically be split by inserting spaces between
 * the words. The default is to leave WordsSmashedTogetherLikeSo.
 */
$WikiTheme->setAutosplitWikiWords(false);
/*
 * You may adjust the formats used for formatting dates and times
 * below.  (These examples give the default formats.)
 * Formats are given as format strings to PHP strftime() function See
 * http://www.php.net/manual/en/function.strftime.php for details.
 * Do not include the server's zone (%Z), times are converted to the
 * user's time zone.
 */
//$WikiTheme->setDateFormat("%B %d, %Y");
//$WikiTheme->setTimeFormat("%I:%M %p");
Exemplo n.º 13
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     include_once "lib/BlockParser.php";
     // MediawikiTablePlugin markup is new.
     $markup = 2.0;
     // We allow the compact Mediawiki syntax with:
     // - multiple cells on the same line (separated by "||"),
     // - multiple header cells on the same line (separated by "!!").
     $argstr = str_replace("||", "\n| ", $argstr);
     $argstr = str_replace("!!", "\n! ", $argstr);
     $lines = preg_split('/\\n/', $argstr);
     $table = HTML::table();
     // We always generate an Id for the table.
     // This is convenient for tables of class "sortable".
     // If user provides an Id, the generated Id will be overwritten below.
     $table->setAttr("id", GenerateId("MediawikiTable"));
     if (substr($lines[0], 0, 2) == "{|") {
         // Start of table
         $lines[0] = substr($lines[0], 2);
     }
     if ($lines[0][0] != '|' and $lines[0][0] != '!') {
         $line = array_shift($lines);
         $attrs = parse_attributes($line);
         foreach ($attrs as $key => $value) {
             if (in_array($key, array("id", "class", "title", "style", "bgcolor", "frame", "rules", "border", "cellspacing", "cellpadding", "summary", "align", "width"))) {
                 $table->setAttr($key, $value);
             }
         }
     }
     if (count($lines) == 1) {
         // empty table, we only have closing "|}" line
         return HTML::raw('');
     }
     foreach ($lines as $line) {
         if (substr($line, 0, 2) == "|}") {
             // End of table
             continue;
         }
         if (substr($line, 0, 2) == "|-") {
             if (isset($row)) {
                 if (isset($cell)) {
                     if (isset($content)) {
                         if (is_numeric(trim($content))) {
                             $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($content)));
                         } else {
                             $cell->pushContent(TransformText(trim($content), $markup, $basepage));
                         }
                         unset($content);
                     }
                     $row->pushContent($cell);
                     unset($cell);
                 }
                 if (isset($thead)) {
                     $thead->pushContent($row);
                     $table->pushContent($thead);
                     unset($thead);
                     $tbody = HTML::tbody();
                 } else {
                     $tbody->pushContent($row);
                 }
             }
             $row = HTML::tr();
             $attrs = parse_attributes(substr($line, 2));
             foreach ($attrs as $key => $value) {
                 if (in_array($key, array("id", "class", "title", "style", "bgcolor", "align", "valign"))) {
                     $row->setAttr($key, $value);
                 }
             }
             continue;
         }
         // Table summary
         if (substr($line, 0, 2) == "|=") {
             $line = substr($line, 2);
             $table->setAttr("summary", trim($line));
         }
         // Table caption
         if (substr($line, 0, 2) == "|+") {
             $caption = HTML::caption();
             $line = substr($line, 2);
             $pospipe = strpos($line, "|");
             $posbracket = strpos($line, "[");
             if ($pospipe !== false && ($posbracket === false || $posbracket > $pospipe)) {
                 $attrs = parse_attributes(substr($line, 0, $pospipe));
                 foreach ($attrs as $key => $value) {
                     if (in_array($key, array("id", "class", "title", "style", "align", "lang"))) {
                         $caption->setAttr($key, $value);
                     }
                 }
                 $line = substr($line, $pospipe + 1);
             }
             $caption->pushContent(trim($line));
             $table->pushContent($caption);
         }
         if ((substr($line, 0, 1) == "|" or substr($line, 0, 1) == "!") and isset($row)) {
             if (isset($cell)) {
                 if (isset($content)) {
                     if (is_numeric(trim($content))) {
                         $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($content)));
                     } else {
                         $cell->pushContent(TransformText(trim($content), $markup, $basepage));
                     }
                     unset($content);
                 }
                 $row->pushContent($cell);
             }
             if (substr($line, 0, 1) == "!") {
                 $cell = HTML::th();
                 // Header
                 $thead = HTML::thead();
             } else {
                 $cell = HTML::td();
                 if (!isset($tbody)) {
                     $tbody = HTML::tbody();
                 }
             }
             $line = substr($line, 1);
             // If there is a "|" in the line, the start of line
             // (before the "|") is made of attributes.
             // The end of the line (after the "|") is the cell content
             // This is not true if the pipe is inside [], {{}} or {{{}}}
             // | [foo|bar]
             // The following cases must work:
             // | foo
             // | [foo|bar]
             // | class="xxx" | foo
             // | class="xxx" | [foo|bar]
             // | {{tmpl|arg=val}}
             // | {{image.png|alt}}
             // | {{{ xxx | yyy }}}
             $pospipe = strpos($line, "|");
             $posbracket = strpos($line, "[");
             $poscurly = strpos($line, "{");
             if ($pospipe !== false && ($posbracket === false || $posbracket > $pospipe) && ($poscurly === false || $poscurly > $pospipe)) {
                 $attrs = parse_attributes(substr($line, 0, $pospipe));
                 foreach ($attrs as $key => $value) {
                     if (in_array($key, array("id", "class", "title", "style", "colspan", "rowspan", "width", "height", "bgcolor", "align", "valign"))) {
                         $cell->setAttr($key, $value);
                     }
                 }
                 $line = substr($line, $pospipe + 1);
                 if (is_numeric(trim($line))) {
                     $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($line)));
                 } else {
                     $cell->pushContent(TransformText(trim($line), $markup, $basepage));
                 }
                 continue;
             }
         }
         if (isset($row) and isset($cell)) {
             $line = str_replace("?\\>", "?>", $line);
             $line = str_replace("\\~", "~", $line);
             if (empty($content)) {
                 $content = '';
             }
             $content .= $line . "\n";
         }
     }
     if (isset($row)) {
         if (isset($cell)) {
             if (isset($content)) {
                 if (is_numeric(trim($content))) {
                     $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($content)));
                 } else {
                     $cell->pushContent(TransformText(trim($content), $markup, $basepage));
                 }
             }
             $row->pushContent($cell);
         }
         $tbody->pushContent($row);
         $table->pushContent($tbody);
     }
     return $table;
 }
Exemplo n.º 14
0
 function chmodForm(&$header, $post_args)
 {
     $header->pushContent(HTML::p(HTML::em(_("This plugin is currently under development and does not work!"))));
     $header->pushContent(_("Chmod to permission:"));
     $header->pushContent(HTML::input(array('name' => 'admin_chmod[perm]', 'value' => $post_args['perm'])));
     $header->pushContent(' ' . _("(ugo : rwx)"));
     $header->pushContent(HTML::p());
     $checkbox = HTML::input(array('type' => 'checkbox', 'name' => 'admin_chmod[updatechildren]', 'value' => 1));
     if (!empty($post_args['updatechildren'])) {
         $checkbox->setAttr('checked', 'checked');
     }
     $header->pushContent($checkbox, HTML::raw("&nbsp;"), _("Propagate new permissions to all subpages?"), HTML::raw("&nbsp;&nbsp;"), HTML::em(_("(disable individual page permissions, enable inheritance)?")));
     $header->pushContent(HTML::hr(), HTML::p());
     return $header;
 }
Exemplo n.º 15
0
 function _lines($lines, $class, $prefix = false, $elem = false)
 {
     if (!$prefix) {
         $prefix = HTML::raw('&nbsp;');
     }
     $prefix = HTML::td(array('class' => 'prefix', 'width' => "1%"), $prefix);
     foreach ($lines as $line) {
         if (!trim($line)) {
             $line = HTML::raw('&nbsp;');
         } elseif ($elem) {
             $line = new HtmlElement($elem, $line);
         }
         $this->_block->pushContent(HTML::tr(array('valign' => 'top'), $prefix, HTML::td(array('class' => $class), $line)));
     }
 }
Exemplo n.º 16
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     //$this->_request = & $request;
     //$this->_dbi = & $dbi;
     $user = $request->getUser();
     //FIXME: fails on test with DumpHtml:RateIt
     if (!is_object($user)) {
         return HTML::raw('');
     }
     $this->userid = $user->getId();
     if (!$this->userid) {
         return HTML::raw('');
     }
     $args = $this->getArgs($argstr, $request);
     $this->dimension = $args['dimension'];
     $this->imgPrefix = $args['imgPrefix'];
     if ($this->dimension == '') {
         $this->dimension = 0;
         $args['dimension'] = 0;
     }
     if ($args['pagename']) {
         // Expand relative page names.
         $page = new WikiPageName($args['pagename'], $basepage);
         $args['pagename'] = $page->name;
     }
     if (empty($args['pagename'])) {
         return $this->error(_("no page specified"));
     }
     $this->pagename = $args['pagename'];
     $rdbi = RatingsDb::getTheRatingsDb();
     $this->_rdbi =& $rdbi;
     if ($args['mode'] === 'add') {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         $this->rating = $request->getArg('rating');
         $rdbi->addRating($this->rating, $this->userid, $this->pagename, $this->dimension);
         $this->displayActionImg('add');
     } elseif ($args['mode'] === 'delete') {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         $rdbi->deleteRating($this->userid, $this->pagename, $this->dimension);
         unset($this->rating);
         $this->displayActionImg('delete');
     } elseif (!$args['show']) {
         return $this->RatingWidgetHtml($args['pagename'], $args['version'], $args['imgPrefix'], $args['dimension'], $args['small']);
     } else {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         //extract($args);
         $this->rating = $rdbi->getRating($this->userid, $this->pagename, $this->dimension);
         $this->avg = $rdbi->getAvg($this->pagename, $this->dimension);
         $this->numusers = $rdbi->getNumUsers($this->pagename, $this->dimension);
         // Update this text on rateit in javascript. needed: NumUsers, Avg
         $html = HTML::div(HTML::span(array('class' => 'rateit'), sprintf(_("Rating: %.1f (%d votes)"), $this->avg, $this->numusers)));
         if ($args['show'] == 'top') {
             if (ENABLE_PAGE_PUBLIC) {
                 $page = $dbi->getPage($this->pagename);
                 if ($page->get('public')) {
                     $html->setAttr('class', "public");
                 }
             }
             $html->setAttr('id', "rateit-widget-top");
             $html->pushContent(HTML::br(), $this->RatingWidgetHtml($args['pagename'], $args['version'], $args['imgPrefix'], $args['dimension'], $args['small']));
         } elseif ($args['show'] == 'text') {
             if (!$WikiTheme->DUMP_MODE) {
                 $html->pushContent(HTML::br(), sprintf(_("Your rating was %.1f"), $this->rating));
             }
         } elseif ($this->rating) {
             $html->pushContent(HTML::br(), sprintf(_("Your rating was %.1f"), $this->rating));
         } else {
             $this->pred = $rdbi->getPrediction($this->userid, $this->pagename, $this->dimension);
             if (is_string($this->pred)) {
                 $html->pushContent(HTML::br(), sprintf(_("Prediction: %s"), $this->pred));
             } elseif ($this->pred) {
                 $html->pushContent(HTML::br(), sprintf(_("Prediction: %.1f"), $this->pred));
             }
         }
         //$html->pushContent(HTML::p());
         //$html->pushContent(HTML::em("(Experimental: This might be entirely bogus data)"));
         return $html;
     }
 }
Exemplo n.º 17
0
 function _lines($lines, $class, $prefix = false, $elem = false)
 {
     if (!$prefix) {
         $prefix = HTML::raw('&nbsp;');
     }
     $div = HTML::div(array('class' => 'difftext'));
     foreach ($lines as $line) {
         if ($elem) {
             $line = new HtmlElement($elem, $line);
         }
         $div->pushContent(HTML::div(array('class' => $class), HTML::tt(array('class' => 'prefix'), $prefix), $line, HTML::raw('&nbsp;')));
     }
     $this->_block->pushContent($div);
 }
Exemplo n.º 18
0
 function image_tile()
 {
     $el = new HTML('img');
     $tag = func_get_args();
     $params = "<img src='../ImageTile.php?url=" . $tag[0]['src'];
     if (!@empty($tag[0]['width'])) {
         $params .= "&width=" . $tag[0]['width'];
     }
     if (!@empty($tag[0]['height'])) {
         $params .= "&height=" . $tag[0]['height'];
     }
     if (!@empty($tag[0]['width'])) {
         $params .= "' width='" . $tag[0]['width'];
     }
     if (!@empty($tag[0]['height'])) {
         $params .= "' height='" . $tag[0]['height'];
     }
     $params .= "' alt='" . $tag[0]['alt'] . "' />";
     return $el->raw($params);
 }
Exemplo n.º 19
0
 function _showvalue($key, $val, $prefix = '')
 {
     return $val ? $val : HTML::raw('&nbsp;');
 }
Exemplo n.º 20
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if ($since) {
         $since = strtotime($since);
     }
     if ($month) {
         $since = strtotime($month);
         $since = mktime(0, 0, 0, date("m", $since), 1, date("Y", $since));
         $until = mktime(23, 59, 59, date("m", $since) + 1, 0, date("Y", $since));
     } else {
         $until = 0;
     }
     $iter = $dbi->getAllPages(false, '-mtime');
     $pages = array();
     while ($page = $iter->next()) {
         $pagename = $page->getName();
         if (!$page->exists()) {
             continue;
         }
         $rev = $page->getRevision(1, false);
         $date = $rev->get('mtime');
         //$author = $rev->get('author_id');
         $author = $page->getOwner();
         if (defined('DEBUG') && DEBUG && $debug) {
             echo "<i>{$pagename}, ", strftime("%Y-%m-%d %h:%m:%s", $date), ", {$author}</i><br />\n";
         }
         if ($userid and !preg_match("/" . $userid . "/", $author)) {
             continue;
         }
         if ($since and $date < $since) {
             continue;
         }
         if ($until and $date > $until) {
             continue;
         }
         if (!$comments and preg_match("/\\/Comment/", $pagename)) {
             continue;
         }
         $monthnum = strftime("%Y%m", $date);
         if (!isset($pages[$monthnum])) {
             $pages[$monthnum] = array('author' => array(), 'month' => strftime("%B, %Y", $date));
         }
         if (!isset($pages[$monthnum]['author'][$author])) {
             $pages[$monthnum]['author'][$author] = array('count' => 0, 'pages' => array());
         }
         $pages[$monthnum]['author'][$author]['count']++;
         $pages[$monthnum]['author'][$author]['pages'][] = $pagename;
     }
     $iter->free();
     $html = HTML::table(HTML::col(array('span' => 2, 'align' => 'left')));
     $nbsp = HTML::raw('&nbsp;');
     krsort($pages);
     foreach ($pages as $monthname => $parr) {
         $html->pushContent(HTML::tr(HTML::td(array('colspan' => 2), HTML::strong($parr['month']))));
         uasort($parr['author'], 'cmp_by_count');
         foreach ($parr['author'] as $user => $authorarr) {
             $count = $authorarr['count'];
             $id = preg_replace("/ /", "_", 'pages-' . $monthname . '-' . $user);
             $html->pushContent(HTML::tr(HTML::td($nbsp, $nbsp, HTML::img(array('id' => "{$id}-img", 'src' => $WikiTheme->_findData("images/folderArrowClosed.png"), 'onclick' => "showHideFolder('{$id}')", 'alt' => _("Click to hide/show"), 'title' => _("Click to hide/show"))), $nbsp, $user), HTML::td($count)));
             if ($links) {
                 $pagelist = HTML();
                 foreach ($authorarr['pages'] as $p) {
                     $pagelist->pushContent(WikiLink($p), ', ');
                 }
             } else {
                 $pagelist = join(', ', $authorarr['pages']);
             }
             $html->pushContent(HTML::tr(array('id' => $id . '-body', 'style' => 'display:none; background-color: #eee;'), HTML::td(array('colspan' => 2, 'style' => 'font-size:smaller'), $pagelist)));
         }
     }
     return $html;
 }
Exemplo n.º 21
0
 function markup($match)
 {
     // Remove <nowiki> and </nowiki>
     return HTML::raw(substr($match, 8, -9));
 }
Exemplo n.º 22
0
 function __date($dbi, $time)
 {
     $args =& $this->args;
     $page_for_date = $args['prefix'] . strftime($args['date_format'], $time);
     $t = localtime($time, 1);
     $td = HTML::td(array('align' => 'center'));
     $mday = $t['tm_mday'];
     if ($mday == $this->_today) {
         $mday = HTML::strong($mday);
         $td->setAttr('class', 'cal-today');
     } else {
         if ($dbi->isWikiPage($page_for_date)) {
             $this->_links[] = $page_for_date;
             $td->setAttr('class', 'cal-day');
         }
     }
     if ($dbi->isWikiPage($page_for_date)) {
         $this->_links[] = $page_for_date;
         $date = HTML::a(array('class' => 'cal-day', 'href' => WikiURL($page_for_date), 'title' => $page_for_date), HTML::em($mday));
     } else {
         $date = HTML::a(array('class' => 'cal-hide', 'rel' => 'nofollow', 'href' => WikiURL($page_for_date, array('action' => 'edit')), 'title' => sprintf(_("Edit %s"), $page_for_date)), $mday);
     }
     $td->pushContent(HTML::raw('&nbsp;'), $date, HTML::raw('&nbsp;'));
     return $td;
 }
Exemplo n.º 23
0
 function title()
 {
     extract($this->_args);
     return array($show_minor ? _("RecentEdits") : _("RecentChanges"), ' ', $this->rss_icon(), HTML::raw('&nbsp;'), $this->rss2_icon(), $this->sidebar_link());
 }
Exemplo n.º 24
0
 function setaclForm(&$header, $post_args, $pagehash)
 {
     $acl = $post_args['acl'];
     //FIXME: find intersection of all pages perms, not just from the last pagename
     $pages = array();
     foreach ($pagehash as $name => $checked) {
         if ($checked) {
             $pages[] = $name;
         }
     }
     $perm_tree = pagePermissions($name);
     $table = pagePermissionsAclFormat($perm_tree, !empty($pages));
     $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br());
     $first_page = $GLOBALS['request']->_dbi->getPage($name);
     $owner = $first_page->getOwner();
     list($type, $perm) = pagePermissionsAcl($perm_tree[0], $perm_tree);
     //if (DEBUG) $header->pushContent(HTML::pre("Permission tree for $name:\n",print_r($perm_tree,true)));
     if ($type == 'inherited') {
         $type = sprintf(_("page permission inherited from %s"), $perm_tree[1][0]);
     } elseif ($type == 'page') {
         $type = _("individual page permission");
     } elseif ($type == 'default') {
         $type = _("default page permission");
     }
     $header->pushContent(HTML::strong(_("Type") . ': '), HTML::tt($type), HTML::br());
     $header->pushContent(HTML::strong(_("ACL") . ': '), HTML::tt($perm->asAclLines()), HTML::br());
     $header->pushContent(HTML::p(HTML::strong(_("Description") . ': '), _("Selected Grant checkboxes allow access, unselected checkboxes deny access."), _("To ignore delete the line."), _("To add check 'Add' near the dropdown list.")));
     $header->pushContent($table);
     //
     // display array of checkboxes for existing perms
     // and a dropdown for user/group to add perms.
     // disabled if inherited,
     // checkbox to disable inheritance,
     // another checkbox to progate new permissions to all childs (if there exist some)
     //Todo:
     // warn if more pages are selected and they have different perms
     //$header->pushContent(HTML::input(array('name' => 'admin_setacl[acl]',
     //                                       'value' => $post_args['acl'])));
     $header->pushContent(HTML::br());
     if (!empty($pages) and defined('EXPERIMENTAL') and EXPERIMENTAL) {
         $checkbox = HTML::input(array('type' => 'checkbox', 'name' => 'admin_setacl[updatechildren]', 'value' => 1));
         if (!empty($post_args['updatechildren'])) {
             $checkbox->setAttr('checked', 'checked');
         }
         $header->pushContent($checkbox, _("Propagate new permissions to all subpages?"), HTML::raw("&nbsp;&nbsp;"), HTML::em(_("(disable individual page permissions, enable inheritance)?")), HTML::br(), HTML::em(_("(Currently not working)")));
     }
     $header->pushContent(HTML::hr());
     return $header;
 }
Exemplo n.º 25
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();
}
Exemplo n.º 26
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $this->_args = $this->getArgs($argstr, $request);
     extract($this->_args);
     if (!$page) {
         return '';
     }
     $hidden_pagemeta = array('_cached_html');
     $readonly_pagemeta = array('hits');
     $dbi = $request->getDbh();
     $p = $dbi->getPage($page);
     $pagemeta = $p->getMetaData();
     // Look at arguments to see if submit was entered. If so,
     // process this request before displaying.
     //
     if ($request->isPost() and $request->_user->isAdmin() and $request->getArg('metaedit')) {
         $metafield = trim($request->getArg('metafield'));
         $metavalue = trim($request->getArg('metavalue'));
         if (!in_array($metafield, $readonly_pagemeta)) {
             if (preg_match('/^(.*?)\\[(.*?)\\]$/', $metafield, $matches)) {
                 list(, $array_field, $array_key) = $matches;
                 $array_value = $pagemeta[$array_field];
                 $array_value[$array_key] = $metavalue;
                 $p->set($array_field, $array_value);
             } else {
                 $p->set($metafield, $metavalue);
             }
         }
         $dbi->touch();
         $url = $request->getURLtoSelf(false, array('metaedit', 'metafield', 'metavalue'));
         $request->redirect($url);
         // The rest of the output will not be seen due to the
         // redirect.
     }
     // Now we show the meta data and provide entry box for new data.
     $html = HTML();
     $html->pushContent(fmt("Existing page-level metadata for %s:", $page));
     $dl = HTML::dl();
     foreach ($pagemeta as $key => $val) {
         if (is_string($val) and substr($val, 0, 2) == 'a:') {
             $dl->pushContent(HTML::dt("\n{$key} => {$val}\n", $dl1 = HTML::dl()));
             foreach (unserialize($val) as $akey => $aval) {
                 $dl1->pushContent(HTML::dt(HTML::strong("{$key}" . '[' . $akey . "] => {$aval}\n")));
             }
             $dl->pushContent($dl1);
         } elseif (is_array($val)) {
             $dl->pushContent(HTML::dt("\n{$key}:\n", $dl1 = HTML::dl()));
             foreach ($val as $akey => $aval) {
                 $dl1->pushContent(HTML::dt(HTML::strong("{$key}" . '[' . $akey . "] => {$aval}\n")));
             }
             $dl->pushContent($dl1);
         } elseif (in_array($key, $hidden_pagemeta)) {
         } elseif (in_array($key, $readonly_pagemeta)) {
             $dl->pushContent(HTML::dt(array('style' => 'background: #dddddd'), "{$key} => {$val}\n"));
         } else {
             $dl->pushContent(HTML::dt(HTML::strong("{$key} => {$val}\n")));
         }
     }
     $html->pushContent($dl);
     if ($request->_user->isAdmin()) {
         $action = $request->getPostURL();
         $hiddenfield = HiddenInputs($request->getArgs());
         $instructions = _("Add or change a page-level metadata 'key=>value' pair. Note that you can remove a key by leaving the value-box empty.");
         $keyfield = HTML::input(array('name' => 'metafield'), '');
         $valfield = HTML::input(array('name' => 'metavalue'), '');
         $button = Button('submit:metaedit', _("Submit"), false);
         $form = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $hiddenfield, $instructions, HTML::br(), $keyfield, ' => ', $valfield, HTML::raw('&nbsp;'), $button);
         $html->pushContent(HTML::br(), $form);
     } else {
         $html->pushContent(HTML::em(_("Requires WikiAdmin privileges to edit.")));
     }
     return $html;
 }
Exemplo 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;
 }
Exemplo n.º 28
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     include_once 'lib/InlineParser.php';
     $table = array();
     $lines = preg_split('/\\s*?\\n\\s*/', $argstr);
     foreach ($lines as $line) {
         if (!$line) {
             continue;
         }
         $line = trim($line);
         // If line ends with a '|', remove it
         if ($line[strlen($line) - 1] == '|') {
             $line = substr($line, 0, -1);
         }
         if ($line[0] != '|') {
             // trigger_error(sprintf(_("Line %s does not begin with a '|'."), $line), E_USER_WARNING);
         } else {
             $table[] = $this->_parse_row($line, $basepage);
         }
     }
     $nbrows = sizeof($table);
     // If table is empty, do not generate table markup
     if ($nbrows == 0) {
         return HTML::raw('');
     }
     $nbcols = sizeof($table[0]);
     for ($i = 0; $i < $nbrows; $i++) {
         for ($j = 0; $j < $nbcols; $j++) {
             if (preg_match('/@@/', $table[$i][$j])) {
                 $table[$i][$j] = compute_tablecell($table, $i, $j, $nbrows, $nbcols);
             }
         }
     }
     $htmltable = HTML::table(array('class' => "bordered"));
     foreach ($table as $row) {
         $htmlrow = HTML::tr();
         foreach ($row as $cell) {
             if ($cell && $cell[0] == '=') {
                 $cell = trim(substr($cell, 1));
                 $htmlrow->pushContent(HTML::th(TransformInline($cell, 2.0, $basepage)));
             } else {
                 if (is_numeric($cell)) {
                     $htmlrow->pushContent(HTML::td(array('style' => "text-align:right"), $cell));
                 } else {
                     $htmlrow->pushContent(HTML::td(TransformInline($cell, 2.0, $basepage)));
                 }
             }
         }
         $htmltable->pushContent($htmlrow);
     }
     return $htmltable;
 }
Exemplo n.º 29
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     if (defined('CHARSET')) {
         $rss_parser = new RSSParser(CHARSET);
     } else {
         $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);
             $cell_author = HTML::raw($item['author']);
             $cell_pubDate = HTML::raw($item['pubDate']);
             $cell_authordate = HTML::div(array('class' => 'authordate'), $cell_author, HTML::raw(" - "), $cell_pubDate);
             $cell->pushContent($cell_authordate);
             if (!$titleonly && !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;
 }
Exemplo n.º 30
0
function _upgrade_db_init(&$dbh)
{
    global $request, $DBParams, $DBAuthParams;
    if (!in_array($DBParams['dbtype'], array('SQL', 'ADODB', 'PDO'))) {
        return;
    }
    if (DBADMIN_USER) {
        // if need to connect as the root user, for CREATE and ALTER privileges
        $AdminParams = $DBParams;
        if ($DBParams['dbtype'] == 'SQL') {
            $dsn = DB::parseDSN($AdminParams['dsn']);
        } else {
            // ADODB or PDO
            $dsn = parseDSN($AdminParams['dsn']);
        }
        $AdminParams['dsn'] = sprintf("%s://%s:%s@%s/%s", $dsn['phptype'], DBADMIN_USER, DBADMIN_PASSWD, $dsn['hostspec'], $dsn['database']);
        if (DEBUG & _DEBUG_SQL and $DBParams['dbtype'] == 'PDO') {
            echo "<br>\nDBParams['dsn']: '", $DBParams['dsn'], "'";
            echo "<br>\ndsn: '", print_r($dsn), "'";
            echo "<br>\nAdminParams['dsn']: '", $AdminParams['dsn'], "'";
        }
        $dbh = WikiDB::open($AdminParams);
    } elseif ($dbadmin = $request->getArg('dbadmin')) {
        if (empty($dbadmin['user']) or isset($dbadmin['cancel'])) {
            $dbh =& $request->_dbi;
        } else {
            $AdminParams = $DBParams;
            if ($DBParams['dbtype'] == 'SQL') {
                $dsn = DB::parseDSN($AdminParams['dsn']);
            } else {
                $dsn = parseDSN($AdminParams['dsn']);
            }
            $AdminParams['dsn'] = sprintf("%s://%s:%s@%s/%s", $dsn['phptype'], $dbadmin['user'], $dbadmin['passwd'], $dsn['hostspec'], $dsn['database']);
            $dbh = WikiDB::open($AdminParams);
        }
    } else {
        // Check if the privileges are enough. Need CREATE and ALTER perms.
        // And on windows: SELECT FROM mysql, possibly: UPDATE mysql.
        $form = HTML::form(array("method" => "post", "action" => $request->getPostURL(), "accept-charset" => $GLOBALS['charset']), HTML::p(_("Upgrade requires database privileges to CREATE and ALTER the phpwiki database."), HTML::br(), _("And on windows at least the privilege to SELECT FROM mysql, and possibly UPDATE mysql")), HiddenInputs(array('action' => 'upgrade')), HTML::table(array("cellspacing" => 4), HTML::tr(HTML::td(array('align' => 'right'), _("DB admin user:"******"dbadmin[user]", 'size' => 12, 'maxlength' => 256, 'value' => 'root')))), HTML::tr(HTML::td(array('align' => 'right'), _("DB admin password:"******"dbadmin[passwd]", 'type' => 'password', 'size' => 12, 'maxlength' => 256)))), HTML::tr(HTML::td(array('align' => 'center', 'colspan' => 2), Button("submit:", _("Submit"), 'wikiaction'), HTML::raw('&nbsp;'), Button("submit:dbadmin[cancel]", _("Cancel"), 'button')))));
        $form->printXml();
        echo "</div><!-- content -->\n";
        echo asXML(Template("bottom"));
        echo "</body></html>\n";
        $request->finish();
        exit;
    }
}