function chownPages(&$dbi, &$request, $pages, $newowner) { $ul = HTML::ul(); $count = 0; foreach ($pages as $name) { $page = $dbi->getPage($name); if ($owner = $page->getOwner() and $newowner != $owner) { if (!mayAccessPage('change', $name)) { $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name)))); } else { $page->set('owner', $newowner); if ($page->get('owner') === $newowner) { $ul->pushContent(HTML::li(fmt("Chown page '%s' to '%s'.", WikiLink($name), WikiLink($newowner)))); $count++; } else { $ul->pushContent(HTML::li(fmt("Couldn't chown page '%s' to '%s'.", WikiLink($name), $newowner))); } } } } if ($count) { $dbi->touch(); return HTML($ul, HTML::p(fmt("%s pages have been permanently changed.", $count))); } else { return HTML($ul, HTML::p(fmt("No pages changed."))); } }
function renamePages(&$dbi, &$request, $pages, $from, $to, $updatelinks = false) { $ul = HTML::ul(); $count = 0; $post_args = $request->getArg('admin_rename'); $options = array('regex' => @$post_args['regex'], 'icase' => @$post_args['icase']); foreach ($pages as $name) { if ($newname = $this->renameHelper($name, $from, $to, $options) and $newname != $name) { if ($dbi->isWikiPage($newname)) { $ul->pushContent(HTML::li(fmt("Page %s already exists. Ignored.", WikiLink($newname)))); } elseif (!mayAccessPage('change', $name)) { $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name)))); } elseif ($dbi->renamePage($name, $newname, $updatelinks)) { /* not yet implemented for all backends */ $ul->pushContent(HTML::li(fmt("Renamed page '%s' to '%s'.", $name, WikiLink($newname)))); $count++; } else { $ul->pushContent(HTML::li(fmt("Couldn't rename page '%s' to '%s'.", $name, $newname))); } } else { $ul->pushContent(HTML::li(fmt("Couldn't rename page '%s' to '%s'.", $name, $newname))); } } if ($count) { $dbi->touch(); return HTML($ul, HTML::p(fmt("%s pages have been permanently renamed.", $count))); } else { return HTML($ul, HTML::p(fmt("No pages renamed."))); } }
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")); }
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(" "), HTML::small("(" . $count . ")")); $link = WikiLink($name, 'auto', $wo); $html->pushContent(HTML::li($link)); } return $html; }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); if ($numberlinks > 10 || $numberlinks < 0) { $numberlinks = $this->def_numberlinks; } // Get name of the current page we are on $thispage = $request->getArg('pagename'); $Pages = $request->session->get("PageTrail"); if (!is_array($Pages)) { $Pages = array(); } if (!isset($Pages[0]) or $duplicates || $thispage != $Pages[0]) { array_unshift($Pages, $thispage); $request->session->set("PageTrail", $Pages); } $numberlinks = min(count($Pages), $numberlinks); if (!$invisible and $numberlinks) { $html = HTML::div(array('class' => 'pagetrail')); $html->pushContent(WikiLink($Pages[$numberlinks - 1], 'auto')); for ($i = $numberlinks - 2; $i >= 0; $i--) { if (!empty($Pages[$i])) { $html->pushContent(PAGETRAIL_ARROW, WikiLink($Pages[$i], 'auto')); } } return $html; } else { return HTML(); } }
function pageLink(&$rev, $link_text = false) { if (!$link_text and $rev->get('pagetype') == 'wikiblog') { $link_text = $rev->get('summary'); } return WikiLink($rev, 'auto', $link_text); }
function box($args = false, $request = false, $basepage = false) { if (!$request) { $request =& $GLOBALS['request']; } $stats = $this->getStats($request->_dbi, $request, 'summary'); return $this->makeBox(_("Who is online"), HTML(HTML::Raw('· '), WikiLink(_("WhoIsOnline"), 'auto', fmt("%d online users", $stats['NUM_USERS'])))); }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); // Any text that is returned will not be further transformed, // so use html where necessary. $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')), THE_END); return $html; }
function run($dbi, $argstr, &$request, $basepage) { if (is_array($argstr)) { // can do with array also. $args =& $argstr; if (!isset($args['order'])) { $args['order'] = 'reverse'; } } else { $args = $this->getArgs($argstr, $request); } $user = $request->getUser(); if (empty($args['user'])) { if ($user->isAuthenticated()) { $args['user'] = $user->UserName(); } else { $args['user'] = ''; } } if (!$args['user'] or $args['user'] == ADMIN_USER) { if (BLOG_EMPTY_DEFAULT_PREFIX) { $args['user'] = ''; } else { $args['user'] = ADMIN_USER; } // "Admin/Blogs/day" pages } $parent = empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR; $sp = HTML::Raw('· '); $prefix = $parent . $this->_blogPrefix('wikiblog'); if ($args['month']) { $prefix .= SUBPAGE_SEPARATOR . $args['month']; } $pages = $dbi->titleSearch(new TextSearchQuery("^" . $prefix, true, 'posix')); $html = HTML(); $i = 0; while ($page = $pages->next() and $i < $args['count']) { $rev = $page->getCurrentRevision(false); if ($rev->get('pagetype') != 'wikiblog') { continue; } $i++; $blog = $this->_blog($rev); //$html->pushContent(HTML::h3(WikiLink($page, 'known', $rev->get('summary')))); $html->pushContent($rev->getTransformedContent('wikiblog')); } if ($args['user'] == $user->UserName()) { $html->pushContent(WikiLink(_("WikiBlog"), 'known', "New entry")); } if (!$i) { return HTML(HTML::h3(_("No Blog Entries")), $html); } if (!$args['noheader']) { return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))), $html); } else { return $html; } }
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")); }
function run($dbi, $argstr, $request, $basepage) { $args = $this->getArgs($argstr, $request); $pages = false; // Todo: extend given _GET args if ($args['debug']) { $timer = new DebugTimer(); } $caption = _("All pages in this wiki (%d total):"); if (!empty($args['owner'])) { $pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'], $args['sortby'], $args['limit']); if ($args['owner']) { $caption = fmt("List of pages owned by [%s] (%d total):", WikiLink($args['owner'] == '[]' ? $request->_user->getAuthenticatedId() : $args['owner'], 'if_known'), count($pages)); } } elseif (!empty($args['author'])) { $pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'], $args['sortby'], $args['limit']); if ($args['author']) { $caption = fmt("List of pages last edited by [%s] (%d total):", WikiLink($args['author'] == '[]' ? $request->_user->getAuthenticatedId() : $args['author'], 'if_known'), count($pages)); } } elseif (!empty($args['creator'])) { $pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'], $args['sortby'], $args['limit']); if ($args['creator']) { $caption = fmt("List of pages created by [%s] (%d total):", WikiLink($args['creator'] == '[]' ? $request->_user->getAuthenticatedId() : $args['creator'], 'if_known'), count($pages)); } //} elseif ($pages) { // $args['count'] = count($pages); } else { if (!$request->getArg('count')) { $args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']); } else { $args['count'] = $request->getArg('count'); } } if (empty($args['count']) and !empty($pages)) { $args['count'] = count($pages); } $pagelist = new PageList($args['info'], $args['exclude'], $args); if (!$args['noheader']) { $pagelist->setCaption($caption); } // deleted pages show up as version 0. if ($args['include_empty']) { $pagelist->_addColumn('version'); } if ($pages !== false) { $pagelist->addPageList($pages); } else { $pagelist->addPages($dbi->getAllPages($args['include_empty'], $args['sortby'], $args['limit'])); } if ($args['debug']) { return HTML($pagelist, HTML::p(fmt("Elapsed time: %s s", $timer->getStats()))); } else { return $pagelist; } }
function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); extract($args); // fix deprecated arg if (is_integer($pages)) { $numpages = $pages; $pages = false; // fix new pages handling in arg preprozessor. } elseif (is_array($pages)) { $numpages = (int) $pages[0]; if ($numpages > 0 and !$dbi->isWikiPage($numpages)) { $pages = false; } else { $numpages = 1; } } $allpages = $dbi->getAllPages(false, $sortby, $limit, $exclude); $pagearray = $allpages->asArray(); better_srand(); // Start with a good seed. if ($numpages == 1 && $pagearray) { $page = $pagearray[array_rand($pagearray)]; $pagename = $page->getName(); if ($redirect) { $request->redirect(WikiURL($pagename, false, 'absurl')); } // noreturn if ($hidename) { return WikiLink($pagename, false, _("RandomPage")); } else { return WikiLink($pagename); } } $numpages = min(max(1, (int) $numpages), 20, count($pagearray)); $pagelist = new PageList($info, $exclude, $args); $shuffle = array_rand($pagearray, $numpages); if (is_array($shuffle)) { foreach ($shuffle as $i) { if (isset($pagearray[$i])) { $pagelist->addPage($pagearray[$i]); } } } else { // if $numpages = 1 if (isset($pagearray[$shuffle])) { $pagelist->addPage($pagearray[$shuffle]); } } return $pagelist; }
function chmarkupPages(&$dbi, &$request, $pages, $newmarkup) { $result = HTML::div(); $ul = HTML::ul(); $count = 0; foreach ($pages as $name) { $page = $dbi->getPage($name); $current = $page->getCurrentRevision(); $markup = $current->get('markup'); if (!$markup or $newmarkup != $markup) { if (!mayAccessPage('change', $name)) { $result->setAttr('class', 'error'); $result->pushContent(HTML::p(fmt("Access denied to change page '%s'.", WikiLink($name)))); } else { $version = $current->getVersion(); $meta = $current->_data; $meta['markup'] = $newmarkup; // convert text? $text = $current->getPackedContent(); $meta['summary'] = sprintf(_("Change markup type from %s to %s"), $markup, $newmarkup); $meta['is_minor_edit'] = 1; $meta['author'] = $request->_user->UserName(); unset($meta['mtime']); // force new date $page->save($text, $version + 1, $meta); $current = $page->getCurrentRevision(); if ($current->get('markup') === $newmarkup) { $ul->pushContent(HTML::li(fmt("change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup))); $count++; } else { $ul->pushContent(HTML::li(fmt("Couldn't change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup))); } } } } if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); if ($count == 1) { $result->pushContent(HTML::p("One page has been permanently changed:")); } else { $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); } $result->pushContent($ul); return $result; } else { $result->setAttr('class', 'error'); $result->pushContent(HTML::p("No pages changed.")); return $result; } }
function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); extract($args); if (empty($page) && empty($prefix) && empty($suffix)) { return ''; } if ($prefix) { $suffix = false; $descrip = fmt("Page names with prefix '%s'", $prefix); } elseif ($suffix) { $descrip = fmt("Page names with suffix '%s'", $suffix); } elseif ($page) { $words = preg_split('/[\\s:-;.,]+/', SplitPagename($page)); $words = preg_grep('/\\S/', $words); $prefix = reset($words); $suffix = end($words); $descrip = fmt("These pages share an initial or final title word with '%s'", WikiLink($page, 'auto')); } // Search for pages containing either the suffix or the prefix. $search = $match = array(); if (!empty($prefix)) { $search[] = $this->_quote($prefix); $match[] = '^' . preg_quote($prefix, '/'); } if (!empty($suffix)) { $search[] = $this->_quote($suffix); $match[] = preg_quote($suffix, '/') . '$'; } if ($search) { $query = new TextSearchQuery(join(' OR ', $search)); } else { $query = new NullTextSearchQuery(); } // matches nothing $match_re = '/' . join('|', $match) . '/'; $pagelist = new PageList($info, $exclude, $args); if (!$noheader) { $pagelist->setCaption($descrip); } $pages = $dbi->titleSearch($query); while ($page = $pages->next()) { $name = $page->getName(); if (!preg_match($match_re, $name)) { continue; } $pagelist->addPage($page); } return $pagelist; }
function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); if ($args['basepage']) { $pagename = $args['basepage']; } else { $pagename = $request->getArg('pagename'); } // FIXME: explodePageList from stdlib doesn't seem to work as // expected when there are no subpages. (see also // UnfoldSubPages plugin) $subpages = explodePageList($pagename . SUBPAGE_SEPARATOR . '*'); if (!$subpages) { return $this->error(_("The current page has no subpages defined.")); } extract($args); $content = HTML(); $subpages = array_reverse($subpages); if ($maxpages) { $subpages = array_slice($subpages, 0, $maxpages); } $descrip = fmt("SubPages of %s:", WikiLink($pagename, 'auto')); if ($info) { $info = explode(",", $info); if (in_array('count', $info)) { $args['types']['count'] = new _PageList_Column_ListSubpages_count('count', _("#"), 'center'); } } $pagelist = new PageList($info, $exclude, $args); if (!$noheader) { $pagelist->setCaption($descrip); } foreach ($subpages as $page) { // A page cannot include itself. Avoid doublettes. static $included_pages = array(); if (in_array($page, $included_pages)) { $content->pushContent(HTML::p(sprintf(_("recursive inclusion of page %s ignored"), $page))); continue; } array_push($included_pages, $page); //if ($relative) { // TODO: add relative subpage name display to PageList class //} $pagelist->addPage($page); array_pop($included_pages); } $content->pushContent($pagelist); return $content; }
function box($args = false, $request = false, $basepage = false) { if (!$request) { $request =& $GLOBALS['request']; } if (!isset($args['limit'])) { $args['limit'] = 15; } $args['format'] = 'box'; $args['show_minor'] = true; $args['show_major'] = true; $args['show_deleted'] = false; $args['show_all'] = true; $args['days'] = 90; return $this->makeBox(WikiLink(_("RecentEdits"), '', _("Recent Edits")), $this->format($this->getChanges($request->_dbi, $args), $args)); }
function chownPages(&$dbi, &$request, $pages, $newowner) { $result = HTML::div(); $ul = HTML::ul(); $count = 0; foreach ($pages as $name) { $page = $dbi->getPage($name); $current = $page->getCurrentRevision(); if ($owner = $page->getOwner() and $newowner != $owner) { if (!mayAccessPage('change', $name)) { $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name)))); } else { $version = $current->getVersion(); $meta = $current->_data; $text = $current->getPackedContent(); $meta['summary'] = "Change page owner from '" . $owner . "' to '" . $newowner . "'"; $meta['is_minor_edit'] = 1; $meta['author'] = $request->_user->UserName(); unset($meta['mtime']); // force new date $page->set('owner', $newowner); $page->save($text, $version + 1, $meta); if ($page->get('owner') === $newowner) { $ul->pushContent(HTML::li(fmt("Change owner of page '%s' to '%s'.", WikiLink($name), WikiLink($newowner)))); $count++; } else { $ul->pushContent(HTML::li(fmt("Could not change owner of page '%s' to '%s'.", WikiLink($name), $newowner))); } } } } if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); if ($count == 1) { $result->pushContent(HTML::p("One page has been permanently changed:")); } else { $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); } $result->pushContent($ul); return $result; } else { $result->setAttr('class', 'error'); $result->pushContent(HTML::p("No pages changed.")); return $result; } }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); if (!$lang) { return $this->error(_("This internal action page cannot viewed.") . "\n" . _("You can only use it via the _WikiTranslation plugin.")); } $this->lang = $lang; //action=save if (!empty($translate) and isset($translate['submit']) and $request->isPost()) { $trans = $translate["content"]; if (empty($trans) or $trans == $pagename) { $header = HTML(HTML::h2(_("Translation Error!")), HTML::p(_("Your translated text is either empty or equal to the untranslated text. Please try again."))); } else { //save translation in a users subpage $user = $request->getUser(); $homepage = $user->_HomePagehandle; $transpagename = $homepage->getName() . SUBPAGE_SEPARATOR . _("ContributedTranslations"); $page = $dbi->getPage($transpagename); $current = $page->getCurrentRevision(); $version = $current->getVersion(); if ($version) { $text = $current->getPackedContent() . "\n"; $meta = $current->_data; } else { $text = ''; $meta = array('markup' => 2.0, 'author' => $user->getId()); } $text .= $user->getId() . " " . Iso8601DateTime() . "\n" . "* " . sprintf(_("Translate '%s' to '%s' in *%s*"), $pagename, $trans, $lang); $text .= "\n <verbatim>locale/po/{$lang}.po:\n msgid \"" . $pagename . "\"\n msgstr \"" . $trans . "\"\n </verbatim>"; $meta['summary'] = sprintf(_("Translate %s to %s in %s"), substr($pagename, 0, 15), substr($trans, 0, 15), $lang); $page->save($text, $version + 1, $meta); // TODO: admin notification return HTML(HTML::h2(_("Thanks for adding this translation!")), HTML::p(fmt("Your translated text doesn't yet appear in this %s, but the Administrator will pick it up and add to the installation.", WIKI_NAME)), fmt("Your translation is stored in %s", WikiLink($transpagename))); } } $trans = $this->translate($pagename, $lang, 'en'); //Todo: google lookup or at least a google lookup button. if (isset($header)) { $header = HTML($header, fmt("From english to %s: ", HTML::strong($lang))); } else { $header = fmt("From english to %s: ", HTML::strong($lang)); } $button_label = _("Translate"); $buttons = HTML::p(Button('submit:translate[submit]', $button_label, 'wikiadmin'), Button('submit:translate[cancel]', _("Cancel"), 'button')); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, HTML::textarea(array('class' => 'wikiedit', 'name' => 'translate[content]', 'id' => 'translate[content]', 'rows' => 4, 'cols' => $request->getPref('editWidth')), $trans), HiddenInputs($request->getArgs(), false, array('translate')), HiddenInputs(array('translate[action]' => $pagename, 'require_authority_for_post' => WIKIAUTH_BOGO)), $buttons); }
function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); extract($args); $pagename = $page; $page = $request->getPage(); $current = $page->getCurrentRevision(); if ($current->getVersion() < 1) { return fmt("I'm sorry, there is no such page as %s.", WikiLink($pagename, 'unknown')); } if (!empty($version)) { if (!($revision = $page->getRevision($version))) { NoSuchRevision($request, $page, $version); } } else { $revision = $current; } $template = new Template('info', $request, array('revision' => $revision)); return $template; }
function setExternalPages(&$dbi, &$request, $pages) { $result = HTML::div(); $ul = HTML::ul(); $count = 0; foreach ($pages as $name) { $page = $dbi->getPage($name); $current = $page->getCurrentRevision(); $external = $current->get('external'); if (!$external) { $external = 0; } $external = (bool) $external; if (!$external) { if (!mayAccessPage('change', $name)) { $result->setAttr('class', 'error'); $result->pushContent(HTML::p(fmt("Access denied to change page '%s'.", WikiLink($name)))); } else { $version = $current->getVersion(); $page->set('external', (bool) 1); $ul->pushContent(HTML::li(fmt("change page '%s' to external.", WikiLink($name)))); $count++; } } } if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); if ($count == 1) { $result->pushContent(HTML::p("One page has been permanently changed:")); } else { $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); } $result->pushContent($ul); return $result; } else { $result->setAttr('class', 'error'); $result->pushContent(HTML::p("No pages changed.")); return $result; } }
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) } }
function chmarkupPages(&$dbi, &$request, $pages, $newmarkup) { $ul = HTML::ul(); $count = 0; foreach ($pages as $name) { $page = $dbi->getPage($name); $current = $page->getCurrentRevision(); $markup = $current->get('markup'); if (!$markup or $newmarkup != $markup) { if (!mayAccessPage('change', $name)) { $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name)))); } else { $version = $current->getVersion(); $meta = $current->_data; $meta['markup'] = $newmarkup; // convert text? $text = $current->getPackedContent(); $meta['summary'] = sprintf(_("WikiAdminMarkup from %s to %s"), $markup, $newmarkup); $page->save($text, $version + 1, $meta); $current = $page->getCurrentRevision(); if ($current->get('markup') === $newmarkup) { $ul->pushContent(HTML::li(fmt("change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup))); $count++; } else { $ul->pushContent(HTML::li(fmt("Couldn't change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup))); } } } } if ($count) { $dbi->touch(); return HTML($ul, HTML::p(fmt("%s pages have been permanently changed.", $count))); } else { return HTML($ul, HTML::p(fmt("No pages changed."))); } }
function _arrayToTable($array, &$request) { $thead = HTML::thead(); $label[0] = _("Wiki Name"); $label[1] = _("Search"); $thead->pushContent(HTML::tr(HTML::th($label[0]), HTML::th($label[1]))); $tbody = HTML::tbody(); $dbi = $request->getDbh(); if ($array) { foreach ($array as $moniker => $interurl) { $monikertd = HTML::td(array('class' => 'interwiki-moniker'), $dbi->isWikiPage($moniker) ? WikiLink($moniker) : $moniker); $w = new WikiPluginLoader(); $p = $w->getPlugin('ExternalSearch'); $argstr = sprintf('url="%s"', addslashes($interurl)); $searchtd = HTML::td($p->run($dbi, $argstr, $request, $basepage)); $tbody->pushContent(HTML::tr($monikertd, $searchtd)); } } $table = HTML::table(); $table->setAttr('class', 'interwiki-map'); $table->pushContent($thead); $table->pushContent($tbody); return $table; }
function handleAction() { $action = $this->getArg('action'); if ($this->isPost() and !$this->_user->isAdmin() and $action != 'browse') { $page = $this->getPage(); if ($page->get('moderation')) { require_once "lib/WikiPlugin.php"; $loader = new WikiPluginLoader(); $plugin = $loader->getPlugin("ModeratedPage"); if ($plugin->handler($this, $page)) { $CONTENT = HTML::div(array('class' => 'wiki-edithelp'), fmt("%s: action forwarded to a moderator.", $action), HTML::br(), _("This action requires moderator approval. Please be patient.")); if (!empty($plugin->_tokens['CONTENT'])) { $plugin->_tokens['CONTENT']->pushContent(HTML::br(), _("You must wait for moderator approval.")); } else { $plugin->_tokens['CONTENT'] = $CONTENT; } require_once "lib/Template.php"; $title = WikiLink($page->getName()); $title->pushContent(' : ', WikiLink(_("ModeratedPage"))); GeneratePage(Template('browse', $plugin->_tokens), $title, $page->getCurrentRevision()); $this->finish(); } } } $method = "action_{$action}"; if (method_exists($this, $method)) { $this->{$method}(); } elseif ($page = $this->findActionPage($action)) { $this->actionpage($page); } else { $this->finish(fmt("%s: Bad action", $action)); } }
function _GetOrgData($OrganisationShortName, $revision_number = false) { $this->CI->load->library('image'); $this->CI->load->model('slideshow'); $data = array(); $orgs = $this->CI->directory_model->GetDirectoryOrganisationByEntryName($OrganisationShortName, $revision_number); foreach ($orgs as $org) { $slideshow_array = $this->CI->slideshow->getPhotos($org['organisation_entity_id']); $slideshow = array(); foreach ($slideshow_array->result() as $slide) { $slideshow[] = array('title' => $slide->photo_title, 'id' => $slide->photo_id, 'url' => $this->CI->image->getPhotoURL($slide->photo_id, 'slideshow')); } $data['organisation'] = array('id' => $org['organisation_entity_id'], 'name' => $org['organisation_name'], 'slideshow' => $slideshow, 'shortname' => $org['organisation_directory_entry_name'], 'description' => $org['organisation_description'], 'type' => $org['organisation_type_name'], 'type_codename' => $org['organisation_type_codename'], 'website' => $org['organisation_url'], 'open_times' => $org['organisation_opening_hours'], 'email_address' => $org['organisation_email_address'], 'postal_address' => $org['organisation_postal_address'], 'postcode' => $org['organisation_postcode'], 'phone_internal' => $org['organisation_phone_internal'], 'phone_external' => $org['organisation_phone_external'], 'fax_number' => $org['organisation_fax_number'], 'revision_id' => $org['organisation_revision_id'], 'location' => $org['organisation_location_id'], 'location_lat' => $org['location_lat'], 'location_lng' => $org['location_lng']); if (isset($org['subscription_member'])) { $data['organisation']['subscription'] = array('member' => $org['subscription_member'], 'membership_requested' => $org['subscription_membership_requested'], 'calendar' => $org['subscription_calendar']); } if (NULL === $org['organisation_yorkipedia_entry']) { $data['organisation']['yorkipedia'] = NULL; } else { $data['organisation']['yorkipedia'] = array('url' => WikiLink('yorkipedia', $org['organisation_yorkipedia_entry']), 'title' => $org['organisation_yorkipedia_entry']); } } return $data; }
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; }
function LoadFileOrDir(&$request) { $source = $request->getArg('source'); $finder = new FileFinder(); $source = $finder->slashifyPath($source); $page = rawurldecode(basename($source)); StartLoadDump($request, fmt("Loading '%s'", HTML(dirname($source), dirname($source) ? "/" : "", WikiLink($page, 'auto')))); echo "<dl>\n"; LoadAny($request, $source); echo "</dl>\n"; EndLoadDump($request); }
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; }
function box($args = false, $request = false, $basepage = false) { if (!$request) { $request =& $GLOBALS['request']; } if (!$request->_user->isSignedIn()) { return; } if (!isset($args)) { $args = array(); } $args['small'] = 1; $argstr = ''; foreach ($args as $key => $value) { $argstr .= $key . "=" . $value; } $widget = $this->run($request->_dbi, $argstr, $request, $basepage); return $this->makeBox(WikiLink(_("RateIt"), '', _("Rate It")), $widget); }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); if ($exclude) { if (!is_array($exclude)) { $exclude = explode(',', $exclude); } } if ($page == _("WantedPages")) { $page = ""; } // The PageList class can't handle the 'count' column needed // for this table $this->pagelist = array(); // There's probably a more memory-efficient way to do this (eg // a tailored SQL query via the backend, but this gets the job // done. if (!$page) { $include_empty = false; $allpages_iter = $dbi->getAllPages($include_empty, $sortby, $limit); while ($page_handle = $allpages_iter->next()) { $name = $page_handle->getName(); if ($name == _("InterWikiMap")) { continue; } if (!in_array($name, $exclude)) { $this->_iterateLinks($page_handle, $dbi); } } } else { if ($page && ($pageisWikiPage = $dbi->isWikiPage($page))) { //only get WantedPages links for one page $page_handle = $dbi->getPage($page); $this->_iterateLinks($page_handle, $dbi); if (!$request->getArg('count')) { $args['count'] = count($this->pagelist); } else { $args['count'] = $request->getArg('count'); } } } ksort($this->pagelist); arsort($this->pagelist); $this->_rows = HTML(); $caption = false; $this->_messageIfEmpty = _("<none>"); if ($page) { // link count always seems to be 1 for a single page so // omit count column foreach ($this->pagelist as $key => $val) { $row = HTML::li(WikiLink((string) $key, 'unknown')); $this->_rows->pushContent($row); } if (!$noheader) { if ($pageisWikiPage) { $pagelink = WikiLink($page); } else { $pagelink = WikiLink($page, 'unknown'); } $c = count($this->pagelist); $caption = fmt("Wanted Pages for %s (%d total):", $pagelink, $c); } return $this->_generateList($caption); } else { $spacer = new RawXml(" "); // Clicking on the number in the links column does a // FullTextSearch for the citations of the WantedPage // link. foreach ($this->pagelist as $key => $val) { $key = (string) $key; // TODO: Not sure why, but this // string cast type-coersion // does seem necessary here. // Enclose any FullTextSearch keys containing a space // with quotes in oder to request a defnitive search. $searchkey = strstr($key, ' ') === false ? $key : "\"{$key}\""; $row = HTML::tr(HTML::td(array('align' => 'right'), Button(array('s' => $searchkey), $val, _("FullTextSearch")), HTML::td(HTML($spacer, WikiLink($key, 'unknown'))))); $this->_rows->pushContent($row); } $c = count($this->pagelist); if (!$noheader) { $caption = sprintf(_("Wanted Pages in this wiki (%d total):"), $c); } $this->_columns = array(_("Count"), _("Page Name")); if ($c > 0) { return $this->_generateTable($caption); } else { return HTML(HTML::p($caption), HTML::p($messageIfEmpty)); } } }