Esempio n. 1
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page)) {
         return '';
     }
     $backend =& $dbi->_backend;
     $html = HTML(HTML::h3(fmt("Querying backend directly for '%s'", $page)));
     $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $pagedata = $backend->get_pagedata($page);
     if (!$pagedata) {
         // FIXME: invalid HTML
         $html->pushContent(HTML::p(fmt("No pagedata for %s", $page)));
     } else {
         $this->_fixupData($pagedata);
         $table->pushContent($this->_showhash("get_pagedata('{$page}')", $pagedata));
     }
     for ($version = $backend->get_latest_version($page); $version; $version = $backend->get_previous_version($page, $version)) {
         $vdata = $backend->get_versiondata($page, $version, true);
         $this->_fixupData($vdata);
         $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
         $table->pushContent($this->_showhash("get_versiondata('{$page}',{$version})", $vdata));
     }
     $html->pushContent($table);
     return $html;
 }
 /**
  * Display long description 
  */
 protected function displayLongDescription()
 {
     echo HTML::p(__('This plugin lists all your races. It shows you a summary of all your races and ' . 'your personal bests (over all distances with at least two results).'));
     echo HTML::p(__('In addition, it plots the trend of your results over a specific distance.' . 'If you run a race just for fun, you can mark it as a \'fun race\' to ignore it in the plot.'));
     echo HTML::info(__('You can define the activity type for races in your configuration.'));
     echo HTML::warning(__('Make sure that your activities hold the correct distance.' . 'Only races with exactly 10.00 km will be considered as a race over 10 kilometers.'));
 }
Esempio n. 3
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"));
}
 /**
  * Display long description
  */
 protected function displayLongDescription()
 {
     echo HTML::p(__('This plugin tracks your distances for chosen time ranges.'));
     echo HTML::p(__('You can set a goal (value > 0) for every time range. If it is set, you will see how much you have to run to reach it.'));
     echo HTML::p(__('A virtual Pace Bunny <em>reaches</em> the goal with a steady performance - you can see how far you are ahead or behind.'));
     echo HTML::p(__('Note: &quot;Saison&quot; refers to the current season in the german &quot;kmspiel&quot;.'));
 }
Esempio n. 5
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;
 }
 /**
  * Display long description 
  */
 protected function displayLongDescription()
 {
     echo HTML::p(__('There are different models that can be used to predict your race performances:'));
     echo HTML::fileBlock('<strong>Jack Daniels (VDOT, \'Running formula\')</strong><br>' . __('Your current VDOT is estimated based on the ratio of heart rate and pace. ' . 'This value is equivalent to specific performances.'));
     echo HTML::fileBlock('<strong>Robert Bock (CPP, \'Competitive Performance Predictor\')</strong><br>' . __('Robert Bock uses an individual coefficient for your fatigue over time/distance. ' . 'This model uses your two best results.') . '<br>' . '<small>see <a href="http://www.robert-bock.de/Sport_0/lauf_7/cpp/cpp.html">http://www.robert-bock.de/Sport_0/lauf_7/cpp/cpp.html</a></small>');
     echo HTML::fileBlock('<strong>Herbert Steffny (\'Das gro&szlig;e Laufbuch\')</strong><br>' . __('Herbert Steffny uses fixed factors to transform performances from one distance to another. ' . 'This model uses your best result.'));
     echo HTML::fileBlock('<strong>David Cameron</strong><br>' . __('David Cameron uses a fixed coefficient for the fatigue over time/distance and slightly different formulas than Robert Bock. ' . 'This model uses your best result.') . '<br>' . '<small>see <a href="http://www.infobarrel.com/Runners_Math_How_to_Predict_Your_Race_Time">http://www.infobarrel.com/Runners_Math_How_to_Predict_Your_Race_Time</a></small>');
     echo HTML::info(__('The VDOT model is the only one which considers your current shape. ' . 'The other models are based on your previous race results.'));
 }
Esempio n. 7
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"));
}
Esempio n. 8
0
 /**
  * Display list
  */
 protected function displayExporterList()
 {
     $ListView = new ExporterListView();
     $ListView->display();
     $this->displayPrivacyInfo();
     echo HTML::p('');
     $this->displayExportedFiles();
     Filesystem::checkWritePermissions('inc/export/files/');
 }
Esempio n. 9
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page)) {
         return $this->error("page missing");
     }
     $backend =& $dbi->_backend;
     $this->chunk_split = true;
     $this->readonly_pagemeta = array();
     $this->hidden_pagemeta = array('_cached_html');
     $html = HTML(HTML::h3(fmt("Querying backend directly for '%s'", $page)));
     $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $pagedata = $backend->get_pagedata($page);
     if (!$pagedata) {
         // FIXME: invalid HTML
         $html->pushContent(HTML::p(fmt("No pagedata for %s", $page)));
     } else {
         $this->_fixupData($pagedata);
         $table->pushContent($this->_showhash("get_pagedata('{$page}')", $pagedata));
     }
     if (!$notallversions) {
         $version = $backend->get_latest_version($page);
         $vdata = $backend->get_versiondata($page, $version, true);
         $this->_fixupData($vdata);
         $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
         $table->pushContent($this->_showhash("get_versiondata('{$page}',{$version})", $vdata));
     } else {
         for ($version = $backend->get_latest_version($page); $version; $version = $backend->get_previous_version($page, $version)) {
             $vdata = $backend->get_versiondata($page, $version, true);
             $this->_fixupData($vdata);
             $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
             $table->pushContent($this->_showhash("get_versiondata('{$page}',{$version})", $vdata));
         }
     }
     $linkdata = $backend->get_links($page, false);
     if ($linkdata->count()) {
         $table->pushContent($this->_showhash("get_links('{$page}')", $linkdata->asArray()));
     }
     $relations = $backend->get_links($page, false, false, false, false, false, true);
     if ($relations->count()) {
         $table->pushContent($this->_showhash("get_relations('{$page}')", array()));
         while ($rel = $relations->next()) {
             $table->pushContent($this->_showhash(false, $rel));
         }
     }
     $linkdata = $backend->get_links($page, true);
     if ($linkdata->count()) {
         $table->pushContent($this->_showhash("get_backlinks('{$page}')", $linkdata->asArray()));
     }
     $html->pushContent($table);
     return $html;
 }
Esempio n. 10
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); // TODO: why?
     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;
 }
Esempio n. 11
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;
 }
Esempio n. 12
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)
     }
 }
Esempio n. 13
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;
 }
Esempio n. 14
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;
 }
Esempio n. 15
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     if (is_array($versions)) {
         // Version selection from pageinfo.php display:
         rsort($versions);
         list($version, $previous) = $versions;
     }
     // abort if page doesn't exist
     $page = $request->getPage($pagename);
     $current = $page->getCurrentRevision();
     if ($current->getVersion() < 1) {
         $html = HTML(HTML::p(fmt("I'm sorry, there is no such page as %s.", WikiLink($pagename, 'unknown'))));
         return $html;
         //early return
     }
     if ($version) {
         if (!($new = $page->getRevision($version))) {
             NoSuchRevision($request, $page, $version);
         }
         $new_version = fmt("version %d", $version);
     } else {
         $new = $current;
         $new_version = _("current version");
     }
     if (preg_match('/^\\d+$/', $previous)) {
         if (!($old = $page->getRevision($previous))) {
             NoSuchRevision($request, $page, $previous);
         }
         $old_version = fmt("version %d", $previous);
         $others = array('major', 'minor', 'author');
     } else {
         switch ($previous) {
             case 'author':
                 $old = $new;
                 while ($old = $page->getRevisionBefore($old)) {
                     if ($old->get('author') != $new->get('author')) {
                         break;
                     }
                 }
                 $old_version = _("revision by previous author");
                 $others = array('major', 'minor');
                 break;
             case 'minor':
                 $previous = 'minor';
                 $old = $page->getRevisionBefore($new);
                 $old_version = _("previous revision");
                 $others = array('major', 'author');
                 break;
             case 'major':
             default:
                 $old = $new;
                 while ($old && $old->get('is_minor_edit')) {
                     $old = $page->getRevisionBefore($old);
                 }
                 if ($old) {
                     $old = $page->getRevisionBefore($old);
                 }
                 $old_version = _("predecessor to the previous major change");
                 $others = array('minor', 'author');
                 break;
         }
     }
     $new_link = WikiLink($new, '', $new_version);
     $old_link = $old ? WikiLink($old, '', $old_version) : $old_version;
     $page_link = WikiLink($page);
     $html = HTML(HTML::p(fmt("Differences between %s and %s of %s.", $new_link, $old_link, $page_link)));
     $otherdiffs = HTML::p(_("Other diffs:"));
     $label = array('major' => _("Previous Major Revision"), 'minor' => _("Previous Revision"), 'author' => _("Previous Author"));
     foreach ($others as $other) {
         $args = array('pagename' => $pagename, 'previous' => $other);
         if ($version) {
             $args['version'] = $version;
         }
         if (count($otherdiffs->getContent()) > 1) {
             $otherdiffs->pushContent(", ");
         } else {
             $otherdiffs->pushContent(" ");
         }
         $otherdiffs->pushContent(Button($args, $label[$other]));
     }
     $html->pushContent($otherdiffs);
     if ($old and $old->getVersion() == 0) {
         $old = false;
     }
     $html->pushContent(HTML::Table($this->PageInfoRow(_("Newer page:"), $new, $request), $this->PageInfoRow(_("Older page:"), $old, $request)));
     if ($new && $old) {
         $diff = new Diff($old->getContent(), $new->getContent());
         if ($diff->isEmpty()) {
             $html->pushContent(HTML::hr(), HTML::p('[', _("Versions are identical"), ']'));
         } else {
             // New CSS formatted unified diffs (ugly in NS4).
             $fmt = new HtmlUnifiedDiffFormatter();
             // Use this for old table-formatted diffs.
             //$fmt = new TableUnifiedDiffFormatter;
             $html->pushContent($fmt->format($diff));
         }
     }
     //$html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')),
     //                 THE_END);
     return $html;
 }
Esempio n. 16
0
/**
 * Dump all pages as XHTML to a directory, as pagename.html.
 * Copies all used css files to the directory, all used images to a 
 * "images" subdirectory, and all used buttons to a "images/buttons" subdirectory.
 * The webserver must have write permissions to these directories. 
 *   chown httpd HTML_DUMP_DIR; chmod u+rwx HTML_DUMP_DIR 
 * should be enough.
 *
 * @param string directory (optional) path to dump to. Default: HTML_DUMP_DIR
 * @param string pages     (optional) Comma-seperated of glob-style pagenames to dump
 * @param string exclude   (optional) Comma-seperated of glob-style pagenames to exclude
 */
function DumpHtmlToDir(&$request)
{
    $directory = $request->getArg('directory');
    if (empty($directory)) {
        $directory = HTML_DUMP_DIR;
    }
    // See lib/plugin/WikiForm.php:87
    if (empty($directory)) {
        $request->finish(_("You must specify a directory to dump to"));
    }
    // see if we can access the directory the user wants us to use
    if (!file_exists($directory)) {
        if (!mkdir($directory, 0755)) {
            $request->finish(fmt("Cannot create directory '%s'", $directory));
        } else {
            $html = HTML::p(fmt("Created directory '%s' for the page dump...", $directory));
        }
    } else {
        $html = HTML::p(fmt("Using directory '%s'", $directory));
    }
    $request->_TemplatesProcessed = array();
    StartLoadDump($request, _("Dumping Pages"), $html);
    $thispage = $request->getArg('pagename');
    // for "Return to ..."
    $dbi =& $request->_dbi;
    if ($exclude = $request->getArg('exclude')) {
        // exclude which pagenames
        $excludeList = explodePageList($exclude);
    } else {
        $excludeList = array();
    }
    if ($pages = $request->getArg('pages')) {
        // which pagenames
        if ($pages == '[]') {
            // current page
            $pages = $thispage;
        }
        $page_iter = new WikiDB_Array_PageIterator(explodePageList($pages));
        // not at admin page: dump only the current page
    } elseif ($thispage != _("PhpWikiAdministration")) {
        $page_iter = new WikiDB_Array_PageIterator(array($thispage));
    } else {
        $page_iter = $dbi->getAllPages(false, false, false, $excludeList);
    }
    global $WikiTheme;
    if (defined('HTML_DUMP_SUFFIX')) {
        $WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX;
    }
    $WikiTheme->DUMP_MODE = 'HTML';
    $_bodyAttr = @$WikiTheme->_MoreAttr['body'];
    unset($WikiTheme->_MoreAttr['body']);
    // check if the dumped file will be accessible from outside
    $doc_root = $request->get("DOCUMENT_ROOT");
    $ldir = NormalizeLocalFileName($directory);
    $wikiroot = NormalizeLocalFileName('');
    if (string_starts_with($ldir, $doc_root)) {
        $link_prefix = substr($directory, strlen($doc_root)) . "/";
    } elseif (string_starts_with($ldir, $wikiroot)) {
        $link_prefix = NormalizeWebFileName(substr($directory, strlen($wikiroot))) . "/";
    } else {
        $prefix = '';
        if (isWindows()) {
            $prefix = '/' . substr($doc_root, 0, 2);
            // add drive where apache is installed
        }
        $link_prefix = "file://" . $prefix . $directory . "/";
    }
    $request_args = $request->args;
    $timeout = !$request->getArg('start_debug') ? 20 : 240;
    while ($page = $page_iter->next()) {
        $request->args = $request_args;
        // some plugins might change them (esp. on POST)
        longer_timeout($timeout);
        // Reset watchdog
        $pagename = $page->getName();
        if (!isa($request, 'MockRequest')) {
            PrintXML(HTML::br(), $pagename, ' ... ');
            flush();
        }
        if (in_array($pagename, $excludeList)) {
            if (!isa($request, 'MockRequest')) {
                PrintXML(_("Skipped."));
                flush();
            }
            continue;
        }
        $request->setArg('pagename', $pagename);
        // Template::_basepage fix
        $filename = FilenameForPage($pagename) . $WikiTheme->HTML_DUMP_SUFFIX;
        $msg = HTML();
        $revision = $page->getCurrentRevision();
        $template = new Template('browse', $request, array('revision' => $revision, 'CONTENT' => $revision->getTransformedContent()));
        $data = GeneratePageasXML($template, $pagename);
        if (!($fd = fopen($directory . "/" . $filename, "wb"))) {
            $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing", "{$directory}/{$filename}")));
            $request->finish($msg);
        }
        $num = fwrite($fd, $data, strlen($data));
        if ($page->getName() != $filename) {
            $link = LinkURL($link_prefix . $filename, $filename);
            $msg->pushContent(HTML::small(_("saved as "), $link, " ... "));
        }
        $msg->pushContent(HTML::small(fmt("%s bytes written", $num), "\n"));
        if (!isa($request, 'MockRequest')) {
            PrintXML($msg);
        }
        flush();
        $request->chunkOutput();
        assert($num == strlen($data));
        fclose($fd);
        if (USECACHE) {
            $request->_dbi->_cache->invalidate_cache($pagename);
            unset($request->_dbi->_cache->_pagedata_cache);
            unset($request->_dbi->_cache->_versiondata_cache);
            unset($request->_dbi->_cache->_glv_cache);
        }
        unset($request->_dbi->_cache->_backend->_page_data);
        unset($msg);
        unset($revision->_transformedContent);
        unset($revision);
        unset($template->_request);
        unset($template);
        unset($data);
    }
    $page_iter->free();
    if (!empty($WikiTheme->dumped_images) and is_array($WikiTheme->dumped_images)) {
        @mkdir("{$directory}/images");
        foreach ($WikiTheme->dumped_images as $img_file) {
            if ($img_file and $from = $WikiTheme->_findFile($img_file, true) and basename($from)) {
                $target = "{$directory}/images/" . basename($img_file);
                if (copy($WikiTheme->_path . $from, $target)) {
                    _copyMsg($from, fmt("... copied to %s", $target));
                } else {
                    _copyMsg($from, fmt("... not copied to %s", $target));
                }
            } else {
                _copyMsg($from, _("... not found"));
            }
        }
    }
    if (!empty($WikiTheme->dumped_buttons) and is_array($WikiTheme->dumped_buttons)) {
        // Buttons also
        @mkdir("{$directory}/images/buttons");
        foreach ($WikiTheme->dumped_buttons as $text => $img_file) {
            if ($img_file and $from = $WikiTheme->_findFile($img_file, true) and basename($from)) {
                $target = "{$directory}/images/buttons/" . basename($img_file);
                if (copy($WikiTheme->_path . $from, $target)) {
                    _copyMsg($from, fmt("... copied to %s", $target));
                } else {
                    _copyMsg($from, fmt("... not copied to %s", $target));
                }
            } else {
                _copyMsg($from, _("... not found"));
            }
        }
    }
    if (!empty($WikiTheme->dumped_css) and is_array($WikiTheme->dumped_css)) {
        foreach ($WikiTheme->dumped_css as $css_file) {
            if ($css_file and $from = $WikiTheme->_findFile(basename($css_file), true) and basename($from)) {
                $target = "{$directory}/" . basename($css_file);
                if (copy($WikiTheme->_path . $from, $target)) {
                    _copyMsg($from, fmt("... copied to %s", $target));
                } else {
                    _copyMsg($from, fmt("... not copied to %s", $target));
                }
            } else {
                _copyMsg($from, _("... not found"));
            }
        }
    }
    $WikiTheme->HTML_DUMP_SUFFIX = '';
    $WikiTheme->DUMP_MODE = false;
    $WikiTheme->_MoreAttr['body'] = $_bodyAttr;
    $request->setArg('pagename', $thispage);
    // Template::_basepage fix
    EndLoadDump($request);
}
Esempio n. 17
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     $user =& $request->_user;
     if (isa($request, 'MockRequest')) {
         return '';
     }
     if (!$request->isActionPage($request->getArg('pagename')) and (!isset($user->_prefs->_method) or !in_array($user->_prefs->_method, array('ADODB', 'SQL'))) or in_array($request->getArg('action'), array('zip', 'ziphtml', 'dumphtml')) or isa($user, '_ForbiddenUser')) {
         $no_args = $this->getDefaultArguments();
         // ?
         //            foreach ($no_args as $key => $value) {
         //                $no_args[$value] = false;
         //            }
         $no_args['errmsg'] = HTML(HTML::h2(_("Error: The user HomePage must be a valid WikiWord. Sorry, UserPreferences cannot be saved."), HTML::hr()));
         $no_args['isForm'] = false;
         return Template('userprefs', $no_args);
     }
     $userid = $user->UserName();
     if ($user->isAuthenticated() and !empty($userid)) {
         $pref =& $request->_prefs;
         $args['isForm'] = true;
         //trigger_error("DEBUG: reading prefs from getPreferences".print_r($pref));
         if ($request->isPost()) {
             $errmsg = '';
             $delete = $request->getArg('delete');
             if ($delete and $request->getArg('verify')) {
                 // deleting prefs, verified
                 $default_prefs = $pref->defaultPreferences();
                 $default_prefs['userid'] = $user->UserName();
                 $user->setPreferences($default_prefs);
                 $request->_setUser($user);
                 $request->setArg("verify", false);
                 $request->setArg("delete", false);
                 $alert = new Alert(_("Message"), _("Your UserPreferences have been successfully deleted."));
                 $alert->show();
                 return;
             } elseif ($delete and !$request->getArg('verify')) {
                 return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs(array('verify' => 1)), HiddenInputs($request->getArgs()), HTML::p(_("Do you really want to delete all your UserPreferences?")), HTML::p(Button('submit:delete', _("Yes"), 'delete'), HTML::Raw('&nbsp;'), Button('cancel', _("Cancel"))));
             } elseif ($rp = $request->getArg('pref')) {
                 // replace only changed prefs in $pref with those from request
                 if (!empty($rp['passwd']) and $rp['passwd2'] != $rp['passwd']) {
                     $errmsg = _("Wrong password. Try again.");
                 } else {
                     //trigger_error("DEBUG: reading prefs from request".print_r($rp));
                     //trigger_error("DEBUG: writing prefs with setPreferences".print_r($pref));
                     if (empty($rp['passwd'])) {
                         unset($rp['passwd']);
                     }
                     // fix to set system pulldown's. empty values don't get posted
                     if (empty($rp['theme'])) {
                         $rp['theme'] = '';
                     }
                     if (empty($rp['lang'])) {
                         $rp['lang'] = '';
                     }
                     $num = $user->setPreferences($rp);
                     if (!empty($rp['passwd'])) {
                         $passchanged = false;
                         if ($user->mayChangePass()) {
                             if (method_exists($user, 'storePass')) {
                                 $passchanged = $user->storePass($rp['passwd']);
                             }
                             if (!$passchanged and method_exists($user, 'changePass')) {
                                 $passchanged = $user->changePass($rp['passwd']);
                             }
                             if ($passchanged) {
                                 $errmsg = _("Password updated.");
                             } else {
                                 $errmsg = _("Password was not changed.");
                             }
                         } else {
                             $errmsg = _("Password cannot be changed.");
                         }
                     }
                     if (!$num) {
                         $errmsg .= " " . _("No changes.");
                     } else {
                         $request->_setUser($user);
                         $pref = $user->_prefs;
                         $errmsg .= sprintf(_("%d UserPreferences fields successfully updated."), $num);
                     }
                 }
                 $args['errmsg'] = HTML(HTML::h2($errmsg), HTML::hr());
             }
         }
         $args['available_themes'] = listAvailableThemes();
         $args['available_languages'] = listAvailableLanguages();
         return Template('userprefs', $args);
     } else {
         // wrong or unauthenticated user
         return $request->_notAuthorized(WIKIAUTH_BOGO);
         //return $user->PrintLoginForm ($request, $args, false, false);
     }
 }
Esempio n. 18
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     //if ($request->getArg('action') != 'browse')
     //    return $this->disabled("(action != 'browse')");
     $args = $this->getArgs($argstr, $request);
     $this->_args = $args;
     extract($args);
     $this->preSelectS($args, $request);
     $info = $args['info'];
     $this->debug = $args['debug'];
     // array_multisort($this->_list, SORT_NUMERIC, SORT_DESC);
     $pagename = $request->getArg('pagename');
     // GetUrlToSelf() with all given params
     //$uri = $GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']; // without s would be better.
     //$uri = $request->getURLtoSelf();//false, array('verify'));
     $form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'POST'));
     if ($request->getArg('WikiAdminSelect') == _("Go")) {
         $p = false;
     } else {
         $p = $request->getArg('p');
     }
     //$p = @$GLOBALS['HTTP_POST_VARS']['p'];
     $form->pushContent(HTML::p(array('class' => 'wikitext'), _("Select: "), HTML::input(array('type' => 'text', 'name' => 's', 'value' => $args['s'])), HTML::input(array('type' => 'submit', 'name' => 'WikiAdminSelect', 'value' => _("Go")))));
     if ($request->isPost() && !$request->getArg('wikiadmin') && !empty($p)) {
         $this->_list = array();
         // List all selected pages again.
         foreach ($p as $page => $name) {
             $this->_list[$name] = 1;
         }
     } elseif ($request->isPost() and $request->_user->isAdmin() and !empty($p) and $request->getArg('action') == 'WikiAdminSelect' and $request->getArg('wikiadmin')) {
         // handle external plugin
         $loader = new WikiPluginLoader();
         $a = array_keys($request->getArg('wikiadmin'));
         $plugin_action = $a[0];
         $single_arg_plugins = array("Remove");
         if (in_array($plugin_action, $single_arg_plugins)) {
             $plugin = $loader->getPlugin($plugin_action);
             $ul = HTML::ul();
             foreach ($p as $page => $name) {
                 $plugin_args = "run_page={$name}";
                 $request->setArg($plugin_action, 1);
                 $request->setArg('p', array($page => $name));
                 // if the plugin requires more args than the pagename,
                 // then this plugin will not return. (Rename, SearchReplace, ...)
                 $action_result = $plugin->run($dbi, $plugin_args, $request, $basepage);
                 $ul->pushContent(HTML::li(fmt("Selected page '%s' passed to '%s'.", $name, $select)));
                 $ul->pushContent(HTML::ul(HTML::li($action_result)));
             }
         } else {
             // redirect to the plugin page.
             // in which page is this plugin?
             $plugin_action = preg_replace("/^WikiAdmin/", "", $plugin_action);
             $args = array();
             foreach ($p as $page => $x) {
                 $args["p[{$page}]"] = 1;
             }
             header("Location: " . WikiURL(_("PhpWikiAdministration") . "/" . _($plugin_action), $args, 1));
             exit;
         }
     } elseif (empty($args['s'])) {
         // List all pages to select from.
         $this->_list = $this->collectPages($this->_list, $dbi, $args['sortby'], $args['limit']);
     }
     $pagelist = new PageList_Selectable($info, $args['exclude'], $args);
     $pagelist->addPageList($this->_list);
     $form->pushContent($pagelist->getContent());
     foreach ($args as $k => $v) {
         if (!in_array($k, array('s', 'WikiAdminSelect', 'action', 'verify'))) {
             $form->pushContent(HiddenInputs(array($k => $v)));
         }
         // plugin params
     }
     /*
     foreach ($_GET as $k => $v) {
         if (!in_array($k,array('s','WikiAdminSelect','action')))
             $form->pushContent(HiddenInputs(array($k => $v))); // debugging params, ...
     }
     */
     if (!$request->getArg('verify')) {
         $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'verify')));
         $form->pushContent(Button('submit:verify', _("Select pages"), 'wikiadmin'), Button('submit:cancel', _("Cancel"), 'button'));
     } else {
         global $WikiTheme;
         $form->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'action', 'value' => 'WikiAdminSelect')));
         // Add the Buttons for all registered WikiAdmin plugins
         $plugin_dir = 'lib/plugin';
         if (defined('PHPWIKI_DIR')) {
             $plugin_dir = PHPWIKI_DIR . "/{$plugin_dir}";
         }
         $fs = new fileSet($plugin_dir, 'WikiAdmin*.php');
         $actions = $fs->getFiles();
         foreach ($actions as $f) {
             $f = preg_replace('/.php$/', '', $f);
             $s = preg_replace('/^WikiAdmin/', '', $f);
             if (!in_array($s, array("Select", "Utils"))) {
                 // disable Select and Utils
                 $form->pushContent(Button("submit:wikiadmin[{$f}]", _($s), "wikiadmin"));
                 $form->pushContent($WikiTheme->getButtonSeparator());
             }
         }
         $form->pushContent(Button('submit:cancel', _("Cancel"), 'button'));
     }
     if (!$request->getArg('select')) {
         return $form;
     } else {
         //return $action_result;
     }
 }
Esempio n. 19
0
 function chownForm(&$header, $post_args)
 {
     $header->pushContent(_("Chown") . " ");
     $header->pushContent(' ' . _("to") . ': ');
     $header->pushContent(HTML::input(array('name' => 'admin_chown[user]', 'value' => $post_args['user'])));
     $header->pushContent(HTML::p());
     return $header;
 }
Esempio n. 20
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     if (is_array($versions)) {
         // Version selection from pageinfo.php display:
         rsort($versions);
         list($version, $previous) = $versions;
     }
     // Check if user is allowed to get the Page.
     if (!mayAccessPage('view', $pagename)) {
         return $this->error(sprintf(_("Illegal access to page %s: no read access"), $pagename));
     }
     // abort if page doesn't exist
     $page = $request->getPage($pagename);
     $current = $page->getCurrentRevision();
     if ($current->getVersion() < 1) {
         $html = HTML(HTML::p(fmt("I'm sorry, there is no such page as %s.", WikiLink($pagename, 'unknown'))));
         return $html;
         //early return
     }
     if ($version) {
         if (!($new = $page->getRevision($version))) {
             NoSuchRevision($request, $page, $version);
         }
         $new_version = fmt("version %d", $version);
     } else {
         $new = $current;
         $new_version = _("current version");
     }
     if (preg_match('/^\\d+$/', $previous)) {
         if (!($old = $page->getRevision($previous))) {
             NoSuchRevision($request, $page, $previous);
         }
         $old_version = fmt("version %d", $previous);
         $others = array('major', 'minor', 'author');
     } else {
         switch ($previous) {
             case 'author':
                 $old = $new;
                 while ($old = $page->getRevisionBefore($old)) {
                     if ($old->get('author') != $new->get('author')) {
                         break;
                     }
                 }
                 $old_version = _("revision by previous author");
                 $others = array('major', 'minor');
                 break;
             case 'minor':
                 $previous = 'minor';
                 $old = $page->getRevisionBefore($new);
                 $old_version = _("previous revision");
                 $others = array('major', 'author');
                 break;
             case 'major':
             default:
                 $old = $new;
                 while ($old && $old->get('is_minor_edit')) {
                     $old = $page->getRevisionBefore($old);
                 }
                 if ($old) {
                     $old = $page->getRevisionBefore($old);
                 }
                 $old_version = _("predecessor to the previous major change");
                 $others = array('minor', 'author');
                 break;
         }
     }
     $new_link = WikiLink($new, '', $new_version);
     $old_link = $old ? WikiLink($old, '', $old_version) : $old_version;
     $page_link = WikiLink($page);
     $html = HTML(HTML::p(fmt("Differences between %s and %s of %s.", $new_link, $old_link, $page_link)));
     $otherdiffs = HTML::p(_("Other diffs:"));
     $label = array('major' => _("Previous Major Revision"), 'minor' => _("Previous Revision"), 'author' => _("Previous Author"));
     foreach ($others as $other) {
         $args = array('pagename' => $pagename, 'previous' => $other);
         if ($version) {
             $args['version'] = $version;
         }
         if (count($otherdiffs->getContent()) > 1) {
             $otherdiffs->pushContent(", ");
         } else {
             $otherdiffs->pushContent(" ");
         }
         $otherdiffs->pushContent(Button($args, $label[$other]));
     }
     $html->pushContent($otherdiffs);
     if ($old and $old->getVersion() == 0) {
         $old = false;
     }
     $html->pushContent(HTML::Table($this->PageInfoRow(_("Newer page:"), $new, $request), $this->PageInfoRow(_("Older page:"), $old, $request)));
     if ($new && $old) {
         $diff = new Diff($old->getContent(), $new->getContent());
         if ($diff->isEmpty()) {
             $html->pushContent(HTML::hr(), HTML::p(_("Content of versions "), $old->getVersion(), _(" and "), $new->getVersion(), _(" is identical.")));
             // If two consecutive versions have the same content, it is because the page was
             // renamed, or metadata changed: ACL, owner, markup.
             // We give the reason by printing the summary.
             if ($new->getVersion() - $old->getVersion() == 1) {
                 $html->pushContent(HTML::p(_("Version "), $new->getVersion(), _(" was created because: "), $new->get('summary')));
             }
         } else {
             $fmt = new HtmlUnifiedDiffFormatter();
             $html->pushContent($fmt->format($diff));
         }
     }
     return $html;
 }
Esempio n. 21
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();
     }
     $this->userid = $user->getId();
     $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"));
         $actionImg = $WikiTheme->_path . $this->actionImgPath();
         $rdbi->addRating($request->getArg('rating'), $this->userid, $this->pagename, $this->dimension);
         if (!empty($request->_is_buffering_output)) {
             ob_end_clean();
         }
         // discard any previous output
         // delete the cache
         $page = $request->getPage();
         //$page->set('_cached_html', false);
         $request->cacheControl('MUST-REVALIDATE');
         $dbi->touch();
         //fake validators without args
         $request->appendValidators(array('wikiname' => WIKI_NAME, 'args' => wikihash('')));
         header('Content-type: image/png');
         readfile($actionImg);
         exit;
     } elseif ($args['mode'] === 'delete') {
         //if (!$user->isSignedIn()) return $this->error(_("You must sign in"));
         $actionImg = $WikiTheme->_path . $this->actionImgPath();
         $rdbi->deleteRating($this->userid, $this->pagename, $this->dimension);
         if (!empty($request->_is_buffering_output)) {
             ob_end_clean();
         }
         // discard any previous output
         // delete the cache
         $page = $request->getPage();
         //$page->set('_cached_html', false);
         $request->cacheControl('MUST-REVALIDATE');
         $dbi->touch();
         //fake validators without args
         $request->appendValidators(array('wikiname' => WIKI_NAME, 'args' => wikihash('')));
         header('Content-type: image/png');
         readfile($actionImg);
         exit;
     } 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);
         $rating = $rdbi->getRating();
         $html = HTML::p($this->pagename . ": " . sprintf(_("Rated by %d users | Average rating %.1f stars"), $rdbi->getNumUsers($this->pagename, $this->dimension), $rdbi->getAvg($this->pagename, $this->dimension)), HTML::br());
         if ($rating) {
             $html->pushContent(sprintf(_("Your rating was %.1f"), $rating));
         } else {
             $pred = $rdbi->getPrediction($this->userid, $this->pagename, $this->dimension);
             if (is_string($pred)) {
                 $html->pushContent(sprintf(_("%s prediction for you is %s stars"), WIKI_NAME, $pred));
             } elseif ($pred) {
                 $html->pushContent(sprintf(_("%s prediction for you is %.1f stars"), WIKI_NAME, $pred));
             }
         }
         //$html->pushContent(HTML::p());
         //$html->pushContent(HTML::em("(Experimental: This might be entirely bogus data)"));
         return $html;
     }
 }
Esempio n. 22
0
 function _generateList($caption)
 {
     $list = HTML();
     $c = count($this->pagelist);
     if ($caption) {
         $list->pushContent(HTML::p($caption));
     }
     if ($c > 0) {
         $list->pushContent(HTML::ul($this->_rows));
     } else {
         $list->pushContent(HTML::p($this->_messageIfEmpty));
     }
     return $list;
 }
Esempio n. 23
0
tag('small');
tag('div');
tag('p');
tag('span');
tag('pre');
tag('code');
tag('em');
tag('ul');
tag('li');
tag('h1');
tag('h2');
tag('h3');
tag('h4');
tag('h5');
tag('h6');
tag('blockquote');
tag('footer');
tag_open('tr_open');
HTML::macro('named_anchor', function ($name) {
    return HTML::a('', ['name' => $name]);
});
HTML::macro('pcode', function ($innards) {
    return HTML::p(HTML::code($innards));
});
HTML::macro('nbsp', function ($total = 1) {
    $html = '';
    for ($i = 0; $i < $total; $i++) {
        $html .= '&nbsp;';
    }
    return $html;
});
 /**
  * Display long description
  */
 protected function displayLongDescription()
 {
     echo HTML::p(__('This plugin shows summaries for all weeks, months or years to compare your overall training.'));
 }
Esempio n. 25
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;
 }
Esempio n. 26
0
 function _formatMap($pagetext)
 {
     $map = $this->_getMap($pagetext);
     if (!$map) {
         return HTML::p("<No interwiki map found>");
     }
     // Shouldn't happen.
     $mon_attr = array('class' => 'interwiki-moniker');
     $url_attr = array('class' => 'interwiki-url');
     $thead = HTML::thead(HTML::tr(HTML::th($mon_attr, _("Moniker")), HTML::th($url_attr, _("InterWiki Address"))));
     foreach ($map as $moniker => $interurl) {
         $rows[] = HTML::tr(HTML::td($mon_attr, new Cached_WikiLinkIfKnown($moniker)), HTML::td($url_attr, HTML::tt($interurl)));
     }
     return HTML::table(array('class' => 'interwiki-map'), $thead, HTML::tbody(false, $rows));
 }
Esempio n. 27
0
 function description()
 {
     return HTML::p(false, $this->pre_description(), fmt(" (to pages linked from \"%s\")", $this->_args['page']));
 }
Esempio n. 28
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (!$src) {
         return $this->error(fmt("%s parameter missing", "'src'"));
     }
     // FIXME: Better recursion detection.
     // FIXME: Currently this doesnt work at all.
     if ($src == $request->getURLtoSelf()) {
         return $this->error(fmt("recursive inclusion of url %s", $src));
     }
     if (!IsSafeURL($src)) {
         return $this->error(_("Bad url in src: remove all of <, >, \""));
     }
     $params = array('title' => _("Transcluded page"), 'src' => $src, 'width' => "100%", 'height' => $height, 'marginwidth' => 0, 'marginheight' => 0, 'class' => 'transclude', "onload" => "adjust_iframe_height(this);");
     $noframe_msg[] = fmt("See: %s", HTML::a(array('href' => $src), $src));
     $noframe_msg = HTML::div(array('class' => 'transclusion'), HTML::p(array(), $noframe_msg));
     $iframe = HTML::div(HTML::iframe($params, $noframe_msg));
     /* This doesn't work very well...  maybe because CSS screws up NS4 anyway...
        $iframe = new HtmlElement('ilayer', array('src' => $src), $iframe);
        */
     return HTML(HTML::p(array('class' => 'transclusion-title'), fmt("Transcluded from %s", LinkURL($src))), $this->_js(), $iframe);
 }
Esempio n. 29
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     if ($request->getArg('action') != 'browse') {
         if (!$request->getArg('action') == _("PhpWikiAdministration/Chown")) {
             return $this->disabled("(action != 'browse')");
         }
     }
     $args = $this->getArgs($argstr, $request);
     $this->_args = $args;
     if (empty($args['user'])) {
         $args['user'] = $request->_user->UserName();
     }
     /*if (!empty($args['exclude']))
           $exclude = explodePageList($args['exclude']);
       else
       $exclude = false;*/
     $this->preSelectS($args, $request);
     $p = $request->getArg('p');
     if (!$p) {
         $p = $this->_list;
     }
     $post_args = $request->getArg('admin_chown');
     if (!$request->isPost() and empty($post_args['user'])) {
         $post_args['user'] = $args['user'];
     }
     $next_action = 'select';
     $pages = array();
     if ($p && !$request->isPost()) {
         $pages = $p;
     }
     if ($p && $request->isPost() && !empty($post_args['chown']) && empty($post_args['cancel'])) {
         // without individual PagePermissions:
         if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) {
             $request->_notAuthorized(WIKIAUTH_ADMIN);
             $this->disabled("! user->isAdmin");
         }
         // DONE: error message if not allowed.
         if ($post_args['action'] == 'verify') {
             // Real action
             return $this->chownPages($dbi, $request, array_keys($p), trim($post_args['user']));
         }
         if ($post_args['action'] == 'select') {
             if (!empty($post_args['user'])) {
                 $next_action = 'verify';
             }
             foreach ($p as $name => $c) {
                 $pages[$name] = 1;
             }
         }
     }
     if ($next_action == 'select' and empty($pages)) {
         // List all pages to select from.
         $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']);
     }
     /* // let the user decide which info
         if ($next_action == 'verify') {
            $args['info'] = "checkbox,pagename,owner,mtime";
        }
        */
     if ($next_action == 'select') {
         $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args);
     } else {
         $pagelist = new PageList_Unselectable($args['info'], $args['exclude'], $args);
     }
     $pagelist->addPageList($pages);
     $header = HTML::fieldset();
     if ($next_action == 'verify') {
         $button_label = _("Yes");
         $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently change the owner of the selected pages?"))));
         $header = $this->chownForm($header, $post_args);
     } else {
         $button_label = _("Change owner of selected pages");
         $header->pushContent(HTML::legend(_("Select the pages to change the owner")));
         $header = $this->chownForm($header, $post_args);
     }
     $buttons = HTML::p(Button('submit:admin_chown[chown]', $button_label, 'wikiadmin'), Button('submit:admin_chown[cancel]', _("Cancel"), 'button'));
     $header->pushContent($buttons);
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_chown')), HiddenInputs(array('admin_chown[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)));
 }
Esempio n. 30
0
 function checkEmailConfirmation()
 {
     global $request;
     $wikidb = $request->getDbh();
     $data = $wikidb->get('ConfirmEmail');
     $id = $request->getArg('id');
     if (empty($data[$id])) {
         // id not found
         return HTML(HTML::h1("Confirm E-mail address"), HTML::h1("Sorry! Wrong URL"));
     }
     // upgrade the user
     $userid = $data['userid'];
     $email = $data['email'];
     $u = $request->getUser();
     if ($u->UserName() == $userid) {
         // lucky: current user (session)
         $prefs = $u->getPreferences();
         $request->_user->_level = WIKIAUTH_USER;
         $request->_prefs->set('emailVerified', true);
     } else {
         // not current user
         if (ENABLE_USER_NEW) {
             $u = WikiUser($userid);
             $u->getPreferences();
             $prefs =& $u->_prefs;
         } else {
             $u = new WikiUser($request, $userid);
             $prefs = $u->getPreferences();
         }
         $u->_level = WIKIAUTH_USER;
         $request->setUser($u);
         $request->_prefs->set('emailVerified', true);
     }
     unset($data[$id]);
     $wikidb->set('ConfirmEmail', $data);
     return HTML(HTML::h1("Confirm E-mail address"), HTML::p("Your e-mail address has now been confirmed."));
 }