function summaryAsHTML($rev) { if (!($summary = $this->summary($rev))) { return ''; } return HTML::strong(array('class' => 'wiki-summary'), "(", TransformLinks($summary, $rev->get('markup'), $rev->getPageName()), ")"); }
function highlight_line($line, $hilight_re) { while (preg_match("/^(.*?)({$hilight_re})/i", $line, $m)) { $line = substr($line, strlen($m[0])); $html[] = $m[1]; // prematch $html[] = HTML::strong(array('class' => 'search-term'), $m[2]); // match } $html[] = $line; // postmatch return $html; }
function showForm(&$dbi, &$request, $args) { $action = $request->getPostURL(); $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'direction')); $pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), ''); $query = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this link. These are pagenames. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), ''); $dirsign_switch = JavaScript("\nfunction dirsign_switch() {\n var d = document.getElementById('dirsign')\n d.innerHTML = (d.innerHTML == ' => ') ? ' <= ' : ' => '\n}\n"); $dirsign = " => "; $in = $out = array('name' => 'direction', 'type' => 'radio', 'onChange' => 'dirsign_switch()'); $out['value'] = 'out'; $out['id'] = 'dir_out'; if ($args['direction'] == 'out') { $out['checked'] = 'checked'; } $in['value'] = 'in'; $in['id'] = 'dir_in'; if ($args['direction'] == 'in') { $in['checked'] = 'checked'; $dirsign = " <= "; } $direction = HTML(HTML::input($out), HTML::label(array('for' => 'dir_out'), _("outgoing")), HTML::input($in), HTML::label(array('for' => 'dir_in'), _("incoming"))); /* $direction = HTML::select(array('name'=>'direction', 'onChange' => 'dirsign_switch()')); $out = array('value' => 'out'); if ($args['direction']=='out') $out['selected'] = 'selected'; $in = array('value' => 'in'); if ($args['direction']=='in') { $in['selected'] = 'selected'; $dirsign = " <= "; } $direction->pushContent(HTML::option($out, _("outgoing"))); $direction->pushContent(HTML::option($in, _("incoming"))); */ $submit = Button('submit:search', _("LinkSearch"), false); $instructions = _("Search in pages for links with the matching name."); $form = HTML::form(array('action' => $action, 'method' => 'GET', 'accept-charset' => $GLOBALS['charset']), $dirsign_switch, $hiddenfield, $instructions, HTML::br(), $pagefilter, HTML::strong(HTML::tt(array('id' => 'dirsign'), $dirsign)), $query, HTML::raw(' '), $direction, HTML::raw(' '), $submit); return $form; }
function format_revision($rev) { static $doublettes = array(); if (isset($doublettes[$rev->getPageName()])) { return; } $doublettes[$rev->getPageName()] = 1; $args =& $this->_args; $class = 'rc-' . $this->importance($rev); $time = $this->time($rev); if (!$rev->get('is_minor_edit')) { $time = HTML::strong(array('class' => 'pageinfo-majoredit'), $time); } $line = HTML::li(array('class' => $class)); if ($args['difflinks']) { $line->pushContent($this->diffLink($rev), ' '); } if ($args['historylinks']) { $line->pushContent($this->historyLink($rev), ' '); } $line->pushContent($this->pageLink($rev), ' ', $time, ' ', ' . . . . ', _("latest comment by "), $this->authorLink($rev)); return $line; }
function showWatchList($pagelist) { return HTML::strong(HTML::tt(empty($pagelist) ? _("<empty>") : $pagelist)); }
/** * Handle AntiSpam here. How? http://wikiblacklist.blogspot.com/ * Need to check dynamically some blacklist wikipage settings * (plugin WikiAccessRestrictions) and some static blacklist. * DONE: * Always: More then 20 new external links * ENABLE_SPAMASSASSIN: content patterns by babycart (only php >= 4.3 for now) * ENABLE_SPAMBLOCKLIST: content domain blacklist */ function isSpam() { $current =& $this->current; $request =& $this->request; $oldtext = $current->getPackedContent(); $newtext =& $this->_content; // FIXME: in longer texts the NUM_SPAM_LINKS number should be increased. // better use a certain text : link ratio. // 1. Not more then 20 new external links if (defined("NUM_SPAM_LINKS")) { if ($this->numLinks($newtext) - $this->numLinks($oldtext) >= NUM_SPAM_LINKS) { // Allow strictly authenticated users? // TODO: mail the admin? $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML($this->getSpamMessage(), HTML::p(HTML::strong(_("Too many external links.")))); return true; } } // 2. external babycart (SpamAssassin) check // This will probably prevent from discussing sex or viagra related topics. So beware. if (ENABLE_SPAMASSASSIN) { include_once "lib/spam_babycart.php"; if ($babycart = check_babycart($newtext, $request->get("REMOTE_ADDR"), $this->user->getId())) { // TODO: mail the admin if (is_array($babycart)) { $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML($this->getSpamMessage(), HTML::p(HTML::em(_("SpamAssassin reports: "), join("\n", $babycart)))); } return true; } } // 3. extract (new) links and check surbl for blocked domains if (ENABLE_SPAMBLOCKLIST and $this->numLinks($newtext)) { include_once "lib/SpamBlocklist.php"; include_once "lib/InlineParser.php"; $parsed = TransformLinks($newtext); foreach ($parsed->_content as $link) { if (isa($link, 'Cached_ExternalLink')) { $uri = $link->_getURL($this->page->getName()); if ($res = IsBlackListed($uri)) { // TODO: mail the admin $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML($this->getSpamMessage(), HTML::p(HTML::strong(_("External links contain blocked domains:")), HTML::ul(HTML::li(sprintf(_("%s is listed at %s"), $res[2], $res[0]))))); return true; } } } } return false; }
function displayPage(&$request, $template = false) { global $WikiTheme, $pv; $pagename = $request->getArg('pagename'); $version = $request->getArg('version'); $page = $request->getPage(); if ($version) { $revision = $page->getRevision($version); if (!$revision) { NoSuchRevision($request, $page, $version); } } else { $revision = $page->getCurrentRevision(); } if (isSubPage($pagename)) { $pages = explode(SUBPAGE_SEPARATOR, $pagename); $last_page = array_pop($pages); // deletes last element from array as side-effect $pageheader = HTML::span(HTML::a(array('href' => WikiURL($pages[0]), 'class' => 'pagetitle'), $WikiTheme->maybeSplitWikiWord($pages[0] . SUBPAGE_SEPARATOR))); $first_pages = $pages[0] . SUBPAGE_SEPARATOR; array_shift($pages); foreach ($pages as $p) { if ($pv != 2) { //Add the Backlink in page title $pageheader->pushContent(HTML::a(array('href' => WikiURL($first_pages . $p), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($p . SUBPAGE_SEPARATOR))); } else { // Remove Backlinks $pageheader->pushContent(HTML::h1($pagename)); } $first_pages .= $p . SUBPAGE_SEPARATOR; } if ($pv != 2) { $backlink = HTML::a(array('href' => WikiURL($pagename, array('action' => _("BackLinks"))), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($last_page)); $backlink->addTooltip(sprintf(_("BackLinks for %s"), $pagename)); } else { $backlink = HTML::h1($pagename); } $pageheader->pushContent($backlink); } else { if ($pv != 2) { $pageheader = HTML::a(array('href' => WikiURL($pagename, array('action' => _("BackLinks"))), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($pagename)); $pageheader->addTooltip(sprintf(_("BackLinks for %s"), $pagename)); } else { $pageheader = HTML::h1($pagename); //Remove Backlinks } if ($request->getArg('frame')) { $pageheader->setAttr('target', '_top'); } } // {{{ Codendi hook to insert stuff between navbar and header $eM =& EventManager::instance(); $ref_html = ''; $crossref_fact = new CrossReferenceFactory($pagename, ReferenceManager::REFERENCE_NATURE_WIKIPAGE, GROUP_ID); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { $ref_html .= '<h3>' . $GLOBALS['Language']->getText('cross_ref_fact_include', 'references') . '</h3>'; $ref_html .= $crossref_fact->getHTMLDisplayCrossRefs(); } $additional_html = false; $eM->processEvent('wiki_before_content', array('html' => &$additional_html, 'group_id' => GROUP_ID, 'wiki_page' => $pagename)); if ($additional_html) { $beforeHeader = HTML(); $beforeHeader->pushContent($additional_html); $beforeHeader->pushContent(HTML::raw($ref_html)); $toks['BEFORE_HEADER'] = $beforeHeader; } else { $beforeHeader = HTML(); $beforeHeader->pushContent(HTML::raw($ref_html)); $toks['BEFORE_HEADER'] = $beforeHeader; } // }}} /Codendi hook $pagetitle = SplitPagename($pagename); if ($redirect_from = $request->getArg('redirectfrom')) { $redirect_message = HTML::span(array('class' => 'redirectfrom'), fmt("(Redirected from %s)", RedirectorLink($redirect_from))); // abuse the $redirected template var for some status update notice } elseif ($request->getArg('errormsg')) { $redirect_message = $request->getArg('errormsg'); $request->setArg('errormsg', false); } $request->appendValidators(array('pagerev' => $revision->getVersion(), '%mtime' => $revision->get('mtime'))); /* // FIXME: This is also in the template... if ($request->getArg('action') != 'pdf' and !headers_sent()) { // FIXME: enable MathML/SVG/... support if (ENABLE_XHTML_XML and (!isBrowserIE() and strstr($request->get('HTTP_ACCEPT'),'application/xhtml+xml'))) header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']); else header("Content-Type: text/html; charset=" . $GLOBALS['charset']); } */ $page_content = $revision->getTransformedContent(); // if external searchengine (google) referrer, highlight the searchterm // FIXME: move that to the transformer? // OR: add the searchhightplugin line to the content? if ($result = isExternalReferrer($request)) { if (DEBUG and !empty($result['query'])) { //$GLOBALS['SearchHighlightQuery'] = $result['query']; /* simply add the SearchHighlight plugin to the top of the page. This just parses the wikitext, and doesn't highlight the markup */ include_once 'lib/WikiPlugin.php'; $loader = new WikiPluginLoader(); $xml = $loader->expandPI('<' . '?plugin SearchHighlight s="' . $result['query'] . '"?' . '>', $request, $markup); if ($xml and is_array($xml)) { foreach (array_reverse($xml) as $line) { array_unshift($page_content->_content, $line); } array_unshift($page_content->_content, HTML::div(_("You searched for: "), HTML::strong($result['query']))); } if (0) { /* Parse the transformed (mixed HTML links + strings) lines? This looks like overkill. */ require_once "lib/TextSearchQuery.php"; $query = new TextSearchQuery($result['query']); $hilight_re = $query->getHighlightRegexp(); //$matches = preg_grep("/$hilight_re/i", $revision->getContent()); // FIXME! for ($i = 0; $i < count($page_content->_content); $i++) { $found = false; $line = $page_content->_content[$i]; if (is_string($line)) { while (preg_match("/^(.*?)({$hilight_re})/i", $line, $m)) { $found = true; $line = substr($line, strlen($m[0])); $html[] = $m[1]; // prematch $html[] = HTML::strong(array('class' => 'search-term'), $m[2]); // match } } if ($found) { $html[] = $line; // postmatch $page_content->_content[$i] = HTML::span(array('class' => 'search-context'), $html); } } } } } $toks['CONTENT'] = new Template('browse', $request, $page_content); $toks['TITLE'] = $pagetitle; // <title> tag $toks['HEADER'] = $pageheader; // h1 with backlink $toks['revision'] = $revision; if (!empty($redirect_message)) { $toks['redirected'] = $redirect_message; } $toks['ROBOTS_META'] = 'index,follow'; $toks['PAGE_DESCRIPTION'] = $page_content->getDescription(); $toks['PAGE_KEYWORDS'] = GleanKeywords($page); if (!$template) { $template = new Template('html', $request); } $template->printExpansion($toks); $page->increaseHitCount(); if ($request->getArg('action') != 'pdf') { $request->checkValidators(); } flush(); }
function run($dbi, $argstr, &$request, $basepage) { if ($request->getArg('action') != 'browse') { if (!$request->getArg('action') == _("PhpWikiAdministration/Markup")) { return $this->disabled("(action != 'browse')"); } } $args = $this->getArgs($argstr, $request); $this->_args = $args; $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_markup'); if (!$request->isPost() and empty($post_args['markup'])) { $post_args['markup'] = $args['markup']; } $next_action = 'select'; $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } if ($p && $request->isPost() && !empty($post_args['button']) && 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->chmarkupPages($dbi, $request, array_keys($p), $post_args['markup']); } if ($post_args['action'] == 'select') { if (!empty($post_args['markup'])) { $next_action = 'verify'; } foreach ($p as $name => $c) { $pages[$name] = 1; } } } if ($next_action == 'select' and empty($pages)) { $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } 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 markup type of the selected files?")))); $header = $this->chmarkupForm($header, $post_args); } else { $button_label = _("Change markup type"); $header->pushContent(HTML::legend(_("Select the pages to change the markup type"))); $header = $this->chmarkupForm($header, $post_args); } $buttons = HTML::p(Button('submit:admin_markup[button]', $button_label, 'wikiadmin'), Button('submit:admin_markup[cancel]', _("Cancel"), 'button')); $header->pushContent($buttons); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_markup')), HiddenInputs(array('admin_markup[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN))); }
function summaryAsHTML($rev) { if (!($summary = $this->summary($rev))) { return ''; } return HTML::strong(array('class' => 'wiki-summary'), "[", $summary, "]"); }
function run($dbi, $argstr, &$request, $basepage) { if ($request->getArg('action') != 'browse') { if ($request->getArg('action') != _("PhpWikiAdministration/Rename")) { return $this->disabled("(action != 'browse')"); } } $args = $this->getArgs($argstr, $request); $this->_args = $args; $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_rename'); $next_action = 'select'; $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } if ($p && $request->isPost() && !empty($post_args['rename']) && 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->renamePages($dbi, $request, array_keys($p), $post_args['from'], $post_args['to'], !empty($post_args['updatelinks'])); } if ($post_args['action'] == 'select') { if (!empty($post_args['from'])) { $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']); } if ($next_action == 'verify') { $args['info'] = "checkbox,pagename,renamed_pagename"; } $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('renamed_pagename' => new _PageList_Column_renamed_pagename('rename', _("Rename to"))))); $pagelist->addPageList($pages); $header = HTML::p(); if ($next_action == 'verify') { $button_label = _("Yes"); $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently rename the selected files?")))); $header = $this->renameForm($header, $post_args); } else { $button_label = _("Rename selected pages"); $header->pushContent(HTML::p(_("Select the pages to rename:"))); if (!$post_args and count($pages) == 1) { list($post_args['from'], ) = array_keys($pages); $post_args['to'] = $post_args['from']; } $header = $this->renameForm($header, $post_args); } $buttons = HTML::p(Button('submit:admin_rename[rename]', $button_label, 'wikiadmin'), Button('submit:admin_rename[cancel]', _("Cancel"), 'button')); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_rename')), HiddenInputs(array('admin_rename[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), $buttons); }
function setaclForm(&$header, $post_args, $pagehash) { $acl = $post_args['acl']; //FIXME: find intersection of all pages perms, not just from the last pagename $pages = array(); foreach ($pagehash as $name => $checked) { if ($checked) { $pages[] = $name; } } $perm_tree = pagePermissions($name); $table = pagePermissionsAclFormat($perm_tree, !empty($pages)); $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br()); $first_page = $GLOBALS['request']->_dbi->getPage($name); $owner = $first_page->getOwner(); list($type, $perm) = pagePermissionsAcl($perm_tree[0], $perm_tree); //if (DEBUG) $header->pushContent(HTML::pre("Permission tree for $name:\n",print_r($perm_tree,true))); if ($type == 'inherited') { $type = sprintf(_("page permission inherited from %s"), $perm_tree[1][0]); } elseif ($type == 'page') { $type = _("individual page permission"); } elseif ($type == 'default') { $type = _("default page permission"); } $header->pushContent(HTML::strong(_("Type") . ': '), HTML::tt($type), HTML::br()); $header->pushContent(HTML::strong(_("ACL") . ': '), HTML::tt($perm->asAclLines()), HTML::br()); $header->pushContent(HTML::p(HTML::strong(_("Description") . ': '), _("Selected Grant checkboxes allow access, unselected checkboxes deny access."), _("To ignore delete the line."), _("To add check 'Add' near the dropdown list."))); $header->pushContent($table); // // display array of checkboxes for existing perms // and a dropdown for user/group to add perms. // disabled if inherited, // checkbox to disable inheritance, // another checkbox to progate new permissions to all childs (if there exist some) //Todo: // warn if more pages are selected and they have different perms //$header->pushContent(HTML::input(array('name' => 'admin_setacl[acl]', // 'value' => $post_args['acl']))); $header->pushContent(HTML::br()); if (!empty($pages) and defined('EXPERIMENTAL') and EXPERIMENTAL) { $checkbox = HTML::input(array('type' => 'checkbox', 'name' => 'admin_setacl[updatechildren]', 'value' => 1)); if (!empty($post_args['updatechildren'])) { $checkbox->setAttr('checked', 'checked'); } $header->pushContent($checkbox, _("Propagate new permissions to all subpages?"), HTML::raw(" "), HTML::em(_("(disable individual page permissions, enable inheritance)?")), HTML::br(), HTML::em(_("(Currently not working)"))); } $header->pushContent(HTML::hr()); return $header; }
function run($dbi, $argstr, &$request, $basepage) { $this->_args = $this->getArgs($argstr, $request); extract($this->_args); if (!$page) { return ''; } $hidden_pagemeta = array('_cached_html'); $readonly_pagemeta = array('hits'); $dbi = $request->getDbh(); $p = $dbi->getPage($page); $pagemeta = $p->getMetaData(); // Look at arguments to see if submit was entered. If so, // process this request before displaying. // if ($request->isPost() and $request->_user->isAdmin() and $request->getArg('metaedit')) { $metafield = trim($request->getArg('metafield')); $metavalue = trim($request->getArg('metavalue')); if (!in_array($metafield, $readonly_pagemeta)) { if (preg_match('/^(.*?)\\[(.*?)\\]$/', $metafield, $matches)) { list(, $array_field, $array_key) = $matches; $array_value = $pagemeta[$array_field]; $array_value[$array_key] = $metavalue; $p->set($array_field, $array_value); } else { $p->set($metafield, $metavalue); } } $dbi->touch(); $url = $request->getURLtoSelf(false, array('metaedit', 'metafield', 'metavalue')); $request->redirect($url); // The rest of the output will not be seen due to the // redirect. } // Now we show the meta data and provide entry box for new data. $html = HTML(); $html->pushContent(fmt("Existing page-level metadata for %s:", $page)); $dl = HTML::dl(); foreach ($pagemeta as $key => $val) { if (is_string($val) and substr($val, 0, 2) == 'a:') { $dl->pushContent(HTML::dt("\n{$key} => {$val}\n", $dl1 = HTML::dl())); foreach (unserialize($val) as $akey => $aval) { $dl1->pushContent(HTML::dt(HTML::strong("{$key}" . '[' . $akey . "] => {$aval}\n"))); } $dl->pushContent($dl1); } elseif (is_array($val)) { $dl->pushContent(HTML::dt("\n{$key}:\n", $dl1 = HTML::dl())); foreach ($val as $akey => $aval) { $dl1->pushContent(HTML::dt(HTML::strong("{$key}" . '[' . $akey . "] => {$aval}\n"))); } $dl->pushContent($dl1); } elseif (in_array($key, $hidden_pagemeta)) { } elseif (in_array($key, $readonly_pagemeta)) { $dl->pushContent(HTML::dt(array('style' => 'background: #dddddd'), "{$key} => {$val}\n")); } else { $dl->pushContent(HTML::dt(HTML::strong("{$key} => {$val}\n"))); } } $html->pushContent($dl); if ($request->_user->isAdmin()) { $action = $request->getPostURL(); $hiddenfield = HiddenInputs($request->getArgs()); $instructions = _("Add or change a page-level metadata 'key=>value' pair. Note that you can remove a key by leaving the value-box empty."); $keyfield = HTML::input(array('name' => 'metafield'), ''); $valfield = HTML::input(array('name' => 'metavalue'), ''); $button = Button('submit:metaedit', _("Submit"), false); $form = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $hiddenfield, $instructions, HTML::br(), $keyfield, ' => ', $valfield, HTML::raw(' '), $button); $html->pushContent(HTML::br(), $form); } else { $html->pushContent(HTML::em(_("Requires WikiAdmin privileges to edit."))); } return $html; }
function setaclForm(&$header, $pagehash) { $pages = array(); foreach ($pagehash as $name => $checked) { if ($checked) { $pages[] = $name; } } $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br()); return $header; }
function error($message) { return HTML::div(array('class' => 'errors'), HTML::strong(fmt("Plugin %s failed.", $this->getName())), ' ', $message); }
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'), 'wrap' => 'virtual'), $trans), HiddenInputs($request->getArgs(), false, array('translate')), HiddenInputs(array('translate[action]' => $pagename, 'require_authority_for_post' => WIKIAUTH_BOGO)), $buttons); }
function asEditableTable($type) { global $WikiTheme; if (!isset($this->_group)) { $this->_group =& $GLOBALS['request']->getGroup(); } $table = HTML::table(); $table->pushContent(HTML::tr(HTML::th(array('align' => 'left'), _("Access")), HTML::th(array('align' => 'right'), _("Group/User")), HTML::th(_("Grant")), HTML::th(_("Del/+")), HTML::th(_("Description")))); $allGroups = $this->_group->_specialGroups(); foreach ($this->_group->getAllGroupsIn() as $group) { if (!in_array($group, $this->_group->specialGroups())) { $allGroups[] = $group; } } //array_unique(array_merge($this->_group->getAllGroupsIn(), $deletesrc = $WikiTheme->_findData('images/delete.png'); $addsrc = $WikiTheme->_findData('images/add.png'); $nbsp = HTML::raw(' '); foreach ($this->perm as $access => $groups) { //$permlist = HTML::table(array('class' => 'cal','valign' => 'top')); $first_only = true; $newperm = HTML::input(array('type' => 'checkbox', 'name' => "acl[_new_perm][{$access}]", 'value' => 1)); $addbutton = HTML::input(array('type' => 'checkbox', 'name' => "acl[_add_group][{$access}]", 'title' => _("Add this ACL"), 'value' => 1)); $newgroup = HTML::select(array('name' => "acl[_new_group][{$access}]", 'style' => 'text-align: right;', 'size' => 1)); foreach ($allGroups as $groupname) { if (!isset($groups[$groupname])) { $newgroup->pushContent(HTML::option(array('value' => $groupname), $this->groupName($groupname))); } } if (empty($groups)) { $addbutton->setAttr('checked', 'checked'); $newperm->setAttr('checked', 'checked'); $table->pushContent(HTML::tr(array('valign' => 'top'), HTML::td(HTML::strong($access . ":")), HTML::td($newgroup), HTML::td($nbsp, $newperm), HTML::td($nbsp, $addbutton), HTML::td(HTML::em(getAccessDescription($access))))); } foreach ($groups as $group => $bool) { $checkbox = HTML::input(array('type' => 'checkbox', 'name' => "acl[{$access}][{$group}]", 'title' => _("Allow / Deny"), 'value' => 1)); if ($bool) { $checkbox->setAttr('checked', 'checked'); } $checkbox = HTML(HTML::input(array('type' => 'hidden', 'name' => "acl[{$access}][{$group}]", 'value' => 0)), $checkbox); $deletebutton = HTML::input(array('type' => 'checkbox', 'name' => "acl[_del_group][{$access}][{$group}]", 'style' => 'background: #aaa url(' . $deletesrc . ')', 'title' => _("Delete this ACL"), 'value' => 1)); if ($first_only) { $table->pushContent(HTML::tr(HTML::td(HTML::strong($access . ":")), HTML::td(array('class' => 'cal-today', 'align' => 'right'), HTML::strong($this->groupName($group))), HTML::td(array('align' => 'center'), $nbsp, $checkbox), HTML::td(array('align' => 'right', 'style' => 'background: #aaa url(' . $deletesrc . ') no-repeat'), $deletebutton), HTML::td(HTML::em(getAccessDescription($access))))); $first_only = false; } else { $table->pushContent(HTML::tr(HTML::td(), HTML::td(array('class' => 'cal-today', 'align' => 'right'), HTML::strong($this->groupName($group))), HTML::td(array('align' => 'center'), $nbsp, $checkbox), HTML::td(array('align' => 'right', 'style' => 'background: #aaa url(' . $deletesrc . ') no-repeat'), $deletebutton), HTML::td())); } } if (!empty($groups)) { $table->pushContent(HTML::tr(array('valign' => 'top'), HTML::td(array('align' => 'right'), _("add ")), HTML::td($newgroup), HTML::td(array('align' => 'center'), $nbsp, $newperm), HTML::td(array('align' => 'right', 'style' => 'background: #ccc url(' . $addsrc . ') no-repeat'), $addbutton), HTML::td(HTML::small(_("Check to add this ACL"))))); } } if ($type == 'default') { $table->setAttr('style', 'border: dotted thin black; background-color:#eee;'); } elseif ($type == 'inherited') { $table->setAttr('style', 'border: dotted thin black; background-color:#ddd;'); } elseif ($type == 'page') { $table->setAttr('style', 'border: solid thin black; font-weight: bold;'); } return $table; }
function run($dbi, $argstr, &$request, $basepage) { return $this->disabled("This action is blocked by administrator. Sorry for the inconvenience !"); if (!DEBUG) { return $this->disabled("WikiAdminChmod not yet enabled. Set DEBUG to try it."); } $args = $this->getArgs($argstr, $request); $this->_args = $args; $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_chmod'); $next_action = 'select'; $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } if ($p && $request->isPost() && !empty($post_args['chmod']) && empty($post_args['cancel'])) { // without individual PagePermissions: if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } if ($post_args['action'] == 'verify') { // Real action return $this->chmodPages($dbi, $request, array_keys($p), $post_args['perm']); } if ($post_args['action'] == 'select') { if (!empty($post_args['perm'])) { $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']); } if ($next_action == 'verify') { $args['info'] = "checkbox,pagename,perm,author,mtime"; } $args['types'] = array('perm' => new _PageList_Column_chmod_perm('perm', _("Permission"))); $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args); $pagelist->addPageList($pages); $header = HTML::p(); if ($next_action == 'verify') { $button_label = _("Yes"); $header = $this->chmodForm($header, $post_args); $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently change the selected files?")))); } else { $button_label = _("Chmod"); $header = $this->chmodForm($header, $post_args); $header->pushContent(HTML::p(_("Select the pages to change:"))); } $buttons = HTML::p(Button('submit:admin_chmod[chmod]', $button_label, 'wikiadmin'), Button('submit:admin_chmod[cancel]', _("Cancel"), 'button')); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_chmod')), HiddenInputs(array('admin_chmod[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), $buttons); }
function _do_syncwiki(&$request, $args) { global $charset; longer_timeout(240); if (!function_exists('wiki_xmlrpc_post')) { include_once "lib/XmlRpcClient.php"; } $userid = $request->_user->_userid; $dbh = $request->getDbh(); $merge_point = $dbh->get('mergepoint'); if (empty($merge_point)) { $page = $dbh->getPage("ReleaseNotes"); // this is usually the latest official page $last = $page->getCurrentRevision(false); $merge_point = $last->get("mtime"); // for testing: 1160396075 $dbh->set('mergepoint', $merge_point); } //TODO: remote auth, set session cookie $pagelist = wiki_xmlrpc_post('wiki.getRecentChanges', iso8601_encode($merge_point, 1), $args['url'], $args); $html = HTML(); //$html->pushContent(HTML::div(HTML::em("check RPC2 interface..."))); if (gettype($pagelist) === "array") { //$request->_deferredPageChangeNotification = array(); $request->discardOutput(); StartLoadDump($request, _("Syncing this PhpWiki")); PrintXML(HTML::strong(fmt("Download all externally changed sources."))); echo "<br />\n"; PrintXML(fmt("Retrieving from external url %s wiki.getRecentChanges(%s)...", $args['url'], iso8601_encode($merge_point, 1))); echo "<br />\n"; $ouriter = $dbh->mostRecent(array('since' => $merge_point)); //$ol = HTML::ol(); $done = array(); foreach ($pagelist as $ext) { $reaction = _("<unknown>"); // compare existance and dates with local page $extdate = iso8601_decode($ext['lastModified']->scalar, 1); // TODO: urldecode ??? $name = utf8_decode($ext['name']); $our = $dbh->getPage($name); $done[$name] = 1; $ourrev = $our->getCurrentRevision(false); $rel = '<=>'; if (!$our->exists()) { // we might have deleted or moved it on purpose? // check date of latest revision if there's one, and > mergepoint if ($ourrev->getVersion() > 1 and $ourrev->get('mtime') > $merge_point) { // our was deleted after sync, and changed after last sync. $this->_addConflict('delete', $args, $our, $extdate); $reaction = _(" skipped") . " (" . "locally deleted or moved" . ")"; } else { $reaction = $this->_import($args, $our, $extdate); } } else { $ourdate = $ourrev->get('mtime'); if ($extdate > $ourdate and $ourdate < $merge_point) { $rel = '>'; $reaction = $this->_import($args, $our, $extdate); } elseif ($extdate > $ourdate and $ourdate >= $merge_point) { $rel = '>'; // our is older then external but newer than last sync $reaction = $this->_addConflict('import', $args, $our, $extdate); } elseif ($extdate < $ourdate and $extdate < $merge_point) { $rel = '>'; $reaction = $this->_export($args, $our); } elseif ($extdate < $ourdate and $extdate >= $merge_point) { $rel = '>'; // our is newer and external is also newer $reaction = $this->_addConflict('export', $args, $our, $extdate); } else { $rel = '=='; $reaction = _("same date"); } } /*$ol->pushContent(HTML::li(HTML::strong($name)," ", $extdate,"<=>",$ourdate," ", HTML::strong($reaction))); */ PrintXML(HTML::strong($name), " ", $extdate, " {$rel} ", $ourdate, " ", HTML::strong($reaction), HTML::br()); $request->chunkOutput(); } //$html->pushContent($ol); } else { $html->pushContent("xmlrpc error: wiki.getRecentChanges returned " . "(" . gettype($pagelist) . ") " . $pagelist); trigger_error("xmlrpc error: wiki.getRecentChanges returned " . "(" . gettype($pagelist) . ") " . $pagelist, E_USER_WARNING); EndLoadDump($request); return $this->error($html); } if (empty($args['noexport'])) { PrintXML(HTML::strong(fmt("Now upload all locally newer pages."))); echo "<br />\n"; PrintXML(fmt("Checking all local pages newer than %s...", iso8601_encode($merge_point, 1))); echo "<br />\n"; while ($our = $ouriter->next()) { $name = $our->getName(); if ($done[$name]) { continue; } $reaction = _(" skipped"); $ext = wiki_xmlrpc_post('wiki.getPageInfo', $name, $args['url']); if (is_array($ext)) { $extdate = iso8601_decode($ext['lastModified']->scalar, 1); $ourdate = $our->get('mtime'); if ($extdate < $ourdate and $extdate < $merge_point) { $reaction = $this->_export($args, $our); } elseif ($extdate < $ourdate and $extdate >= $merge_point) { // our newer and external newer $reaction = $this->_addConflict($args, $our, $extdate); } } else { $reaction = 'xmlrpc error'; } PrintXML(HTML::strong($name), " ", $extdate, " < ", $ourdate, " ", HTML::strong($reaction), HTML::br()); $request->chunkOutput(); } PrintXML(HTML::strong(fmt("Now upload all locally newer uploads."))); echo "<br />\n"; PrintXML(fmt("Checking all local uploads newer than %s...", iso8601_encode($merge_point, 1))); echo "<br />\n"; $this->_fileList = array(); $prefix = getUploadFilePath(); $this->_dir($prefix); $len = strlen($prefix); foreach ($this->_fileList as $path) { // strip prefix $file = substr($path, $len); $ourdate = filemtime($path); $oursize = filesize($path); $reaction = _(" skipped"); $ext = wiki_xmlrpc_post('wiki.getUploadedFileInfo', $file, $args['url']); if (is_array($ext)) { $extdate = iso8601_decode($ext['lastModified']->scalar, 1); $extsize = $ext['size']; if (empty($extsize) or $extdate < $ourdate) { $timeout = $oursize * 0.0002; // assume 50kb/sec upload speed $reaction = $this->_upload($args, $path, $timeout); } } else { $reaction = 'xmlrpc error wiki.getUploadedFileInfo not supported'; } PrintXML(HTML::strong($name), " ", "{$extdate} ({$extsize}) < {$ourdate} ({$oursize})", HTML::strong($reaction), HTML::br()); $request->chunkOutput(); } } $dbh->set('mergepoint', time()); EndLoadDump($request); return ''; //$html; }
function showForm(&$dbi, &$request, $args) { global $WikiTheme; $action = $request->getPostURL(); $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'semsearch', 'relation', 'attribute')); $pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), ''); $allrelations = $dbi->listRelations(false, false, true); $svalues = empty($allrelations) ? "" : join("','", $allrelations); $reldef = JavaScript("var semsearch_relations = new Array('" . $svalues . "')"); $relation = HTML::input(array('name' => 'relation', 'value' => $args['relation'], 'title' => _("Filter by this relation. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'array:semsearch_relations'), ''); $queryrel = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this link. These are pagenames. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), ''); $relsubmit = Button('submit:semsearch[relations]', _("Relations"), false); // just testing some dhtml... not yet done $enhancements = HTML(); $nbsp = HTML::raw(' '); $this_uri = $_SERVER['REQUEST_URI'] . '#'; $andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'and')", 'title' => _("Add an AND query"))); $orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'or')", 'title' => _("Add an OR query"))); if (DEBUG) { $enhancements = HTML::span($andbutton, $nbsp, $orbutton); } $instructions = _("Search in pages for a relation with that value (a pagename)."); $form1 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $reldef, $hiddenfield, HiddenInputs(array('attribute' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Relation'), HTML::th(), HTML::th('Links'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($relation), HTML::td(HTML::strong(HTML::tt(' :: '))), HTML::td($queryrel), HTML::td($nbsp, $relsubmit, $nbsp, $enhancements))))); $allattrs = $dbi->listRelations(false, true, true); if (empty($allrelations) and empty($allattrs)) { // be nice to the dummy. $this->_norelations_warning = 1; } $svalues = empty($allattrs) ? "" : join("','", $allattrs); $attdef = JavaScript("var semsearch_attributes = new Array('" . $svalues . "')\n" . "var semsearch_op = new Array('" . join("','", $this->_supported_operators) . "')"); // TODO: We want some more tricks: Autofill the base unit of the selected // attribute into the s area. $attribute = HTML::input(array('name' => 'attribute', 'value' => $args['attribute'], 'title' => _("Filter by this attribute name. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_attributes'), ''); $attr_op = HTML::input(array('name' => 'attr_op', 'value' => $args['attr_op'], 'title' => _("Comparison operator. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:2em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_op'), ''); $queryatt = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this numeric attribute value. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'plugin:SemanticSearch page=' . $args['page'] . ' attribute=^[S] attr_op==~'), ''); $andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'and')", 'title' => _("Add an AND query"))); $orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'or')", 'title' => _("Add an OR query"))); if (DEBUG) { $enhancements = HTML::span($andbutton, $nbsp, $orbutton); } $attsubmit = Button('submit:semsearch[attributes]', _("Attributes"), false); $instructions = HTML::span(_("Search in pages for an attribute with that numeric value."), "\n"); if (DEBUG) { $instructions->pushContent(HTML(" ", new Button(_("Advanced..."), _("SemanticSearchAdvanced")))); } $form2 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $attdef, $hiddenfield, HiddenInputs(array('relation' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Attribute'), HTML::th('Op'), HTML::th('Value'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($attribute), HTML::td($attr_op), HTML::td($queryatt), HTML::td($nbsp, $attsubmit, $nbsp, $enhancements))))); return HTML($form1, $form2); }
function MacOSX_PH_revision_formatter(&$fmt, &$rev) { $class = 'rc-' . $fmt->importance($rev); return HTML::li(array('class' => $class), $fmt->diffLink($rev), ' ', $fmt->pageLink($rev), ' ', $rev->get('is_minor_edit') ? $fmt->time($rev) : HTML::strong($fmt->time($rev)), ' . . . ', $fmt->summaryAsHTML($rev), ' -- ', $fmt->authorLink($rev), $rev->get('is_minor_edit') ? HTML::em(" (" . _("minor edit") . ")") : ''); }
function run($dbi, $argstr, &$request, $basepage) { if ($request->getArg('action') != 'browse') { if ($request->getArg('action') != _("PhpWikiAdministration/MassRevert")) { return $this->disabled("(action != 'browse')"); } } $args = $this->getArgs($argstr, $request); if (!is_numeric($args['min_age'])) { $args['min_age'] = -1; } $this->_args =& $args; /*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_revert'); $next_action = 'select'; $pages = array(); if ($p && $request->isPost() && !empty($post_args['revert']) && empty($post_args['cancel'])) { // check individual PagePermissions if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } if ($post_args['action'] == 'verify') { // Real delete. return $this->revertPages($request, array_keys($p)); } if ($post_args['action'] == 'select') { $next_action = 'verify'; foreach ($p as $name => $c) { $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name); $pages[$name] = $c; } } } elseif ($p && is_array($p) && !$request->isPost()) { // from WikiAdminSelect $next_action = 'verify'; foreach ($p as $name => $c) { $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name); $pages[$name] = $c; } $request->setArg('p', false); } if ($next_action == 'select') { // List all pages to select from. $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array('types' => array('revert' => new _PageList_Column_revert('revert', _("Revert")), 'diff' => new _PageList_Column_diff('diff', _("Changes"))))); $pagelist->addPageList($pages); $header = HTML::p(); if ($next_action == 'verify') { $button_label = _("Yes"); $header->pushContent(HTML::strong(_("Are you sure you want to overwrite the selected files with the previous version?"))); } else { $button_label = _("Revert selected pages"); $header->pushContent(_("Permanently remove the selected files:"), HTML::br()); if ($args['min_age'] > 0) { $header->pushContent(fmt("Also pages which have been deleted at least %s days.", $args['min_age'])); } else { $header->pushContent(_("List all pages.")); } if ($args['max_age'] > 0) { $header->pushContent(" ", fmt("(Pages which have been deleted at least %s days are already checked.)", $args['max_age'])); } } $buttons = HTML::p(Button('submit:admin_revert[revert]', $button_label, 'wikiadmin'), Button('submit:admin_revert[cancel]', _("Cancel"), 'button')); // TODO: quick select by regex javascript? return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_revert')), HiddenInputs(array('admin_revert[action]' => $next_action, 'require_authority_for_post' => WIKIAUTH_ADMIN)), $buttons); }
function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); if (isa($request, 'MockRequest')) { return ''; } $user =& $request->_user; $post_args = $request->getArg('admin_reset'); $userid = $request->getArg('user'); $isadmin = $user->isAdmin(); if ($request->isPost()) { if (!$userid) { $alert = new Alert(_("Warning:"), _("You need to specify the userid!")); $alert->show(); return $this->doForm($request); } @($reset = $post_args['reset']); if ($reset and $userid and !empty($post_args['verify'])) { if ($user->isAdmin()) { return $this->doReset($userid); } else { return $this->doEmail($request, $userid); } } elseif ($reset and empty($post_args['verify'])) { $buttons = HTML::p(Button('submit:admin_reset[reset]', $isadmin ? _("Yes") : _("Send email"), $isadmin ? 'wikiadmin' : 'button'), HTML::Raw(' '), Button('submit:admin_reset[cancel]', _("Cancel"), 'button')); $header = HTML::strong("Verify"); if (!$user->isAdmin()) { // check for email if ($userid == $user->UserName() and $user->isAuthenticated()) { $alert = new Alert(_("Already logged in"), HTML(fmt("Changing passwords is done at "), WikiLink(_("UserPreferences")))); $alert->show(); return; } $thisuser = WikiUser($userid); $prefs = $thisuser->getPreferences(); $email = $prefs->get('email'); if (!$email) { $alert = new Alert(_("Error"), HTML(fmt("No email stored for user %s.", $userid), HTML::br(), fmt("You need to ask an Administrator to reset this password. See below: "), HTML::br(), WikiLink(ADMIN_USER))); $alert->show(); return; } $verified = $thisuser->_prefs->_prefs['email']->getraw('emailVerified'); if (!$verified) { $header->pushContent(HTML::br(), "Warning: This users email address is unverified!"); } } return $this->doForm($request, $header, HTML(HTML::hr(), fmt("Do you really want to reset the password of user %s?", $userid), $isadmin ? '' : _("An email will be sent."), HiddenInputs(array('admin_reset[verify]' => 1, 'user' => $userid)), $buttons)); } else { return $this->doForm($request); } } else { return $this->doForm($request); } }
function run($dbi, $argstr, &$request, $basepage) { if (!isset($_SERVER)) { $_SERVER =& $GLOBALS['HTTP_SERVER_VARS']; } $request->setArg('nocache', 'purge'); $args = $this->getArgs($argstr, $request); if (!$args['page']) { return $this->error("No page specified"); } if (!empty($args['admin']) and $request->_user->isAdmin()) { // reset statistics return $this->doPollAdmin($dbi, $request, $page); } extract($this->_args); $page = $dbi->getPage($args['page']); // check ip and last visit $poll = $page->get("poll"); $ip = $_SERVER['REMOTE_ADDR']; $disable_submit = false; if (isset($poll['ip'][$ip]) and time() - $poll['ip'][$ip] < 20 * 60) { //view at least the result or disable the Go button $html = HTML(HTML::strong(_("Sorry! You must wait at least 20 minutes until you can vote again!"))); $html->pushContent($this->doPoll($page, $request, $request->getArg('answer'), true)); return $html; } $poll['ip'][$ip] = time(); // purge older ip's foreach ($poll['ip'] as $ip => $time) { if (time() - $time > 21 * 60) { unset($poll['ip'][$ip]); } } $html = HTML::form(array('action' => $request->getPostURL(), 'method' => 'post')); if ($request->isPost()) { // checkme: check if all answers are answered if ($request->getArg('answer') and ($args['require_all'] and count($request->getArg('answer')) == count($question) or $args['require_least'] and count($request->getArg('answer')) >= $args['require_least'])) { $page->set("poll", $poll); // update statistics and present them the user return $this->doPoll($page, $request, $request->getArg('answer')); } else { $html->pushContent(HTML::p(HTML::strong(_("Not enough questions answered!")))); } } $init = isset($question[0]) ? 0 : 1; for ($i = $init; $i <= count($question); $i++) { if (!isset($question[$i])) { break; } $q = $question[$i]; if (!isset($answer[$i])) { trigger_error(fmt("Missing %s for %s", "answer" . "[{$i}]", "question" . "[{$i}]"), E_USER_ERROR); } $a = $answer[$i]; if (!is_array($a)) { // a simple checkbox $html->pushContent(HTML::p(HTML::strong($q))); $html->pushContent(HTML::div(HTML::input(array('type' => 'checkbox', 'name' => "answer[{$i}]", 'value' => 1)), HTML::raw(" "), $a)); } else { $row = HTML(); for ($j = 0; $j <= count($a); $j++) { if (isset($a[$j])) { $row->pushContent(HTML::div(HTML::input(array('type' => 'radio', 'name' => "answer[{$i}]", 'value' => $j)), HTML::raw(" "), $a[$j])); } } $html->pushContent(HTML::p(HTML::strong($q)), $row); } } if (!$disable_submit) { $html->pushContent(HTML::p(HTML::input(array('type' => 'submit', 'name' => "WikiPoll", 'value' => _("OK"))), HTML::input(array('type' => 'reset', 'name' => "reset", 'value' => _("Reset"))))); } else { $html->pushContent(HTML::p(), HTML::strong(_("Sorry! You must wait at least 20 minutes until you can vote again!"))); } return $html; }
function __date($dbi, $time) { $args =& $this->args; $page_for_date = $args['prefix'] . strftime($args['date_format'], $time); $t = localtime($time, 1); $td = HTML::td(array('align' => 'center')); $mday = $t['tm_mday']; if ($mday == $this->_today) { $mday = HTML::strong($mday); $td->setAttr('class', 'cal-today'); } else { if ($dbi->isWikiPage($page_for_date)) { $this->_links[] = $page_for_date; $td->setAttr('class', 'cal-day'); } } if ($dbi->isWikiPage($page_for_date)) { $this->_links[] = $page_for_date; $date = HTML::a(array('class' => 'cal-day', 'href' => WikiURL($page_for_date), 'title' => $page_for_date), HTML::em($mday)); } else { $date = HTML::a(array('class' => 'cal-hide', 'rel' => 'nofollow', 'href' => WikiURL($page_for_date, array('action' => 'edit')), 'title' => sprintf(_("Edit %s"), $page_for_date)), $mday); } $td->pushContent(HTML::raw(' '), $date, HTML::raw(' ')); return $td; }
function LoadDir(&$request, $dirname, $files = false, $exclude = false) { $fileset = new LimitedFileSet($dirname, $files, $exclude); if (!$files and $skiplist = $fileset->getSkippedFiles()) { PrintXML(HTML::dt(HTML::strong(_("Skipping")))); $list = HTML::ul(); foreach ($skiplist as $file) { $list->pushContent(HTML::li(WikiLink($file))); } PrintXML(HTML::dd($list)); } // Defer HomePage loading until the end. If anything goes wrong // the pages can still be loaded again. $files = $fileset->getFiles(); if (in_array(HOME_PAGE, $files)) { $files = array_diff($files, array(HOME_PAGE)); $files[] = HOME_PAGE; } $timeout = !$request->getArg('start_debug') ? 20 : 120; foreach ($files as $file) { longer_timeout($timeout); // longer timeout per page if (substr($file, -1, 1) != '~') { // refuse to load backup files LoadFile($request, "{$dirname}/{$file}"); } } }
function run($dbi, $argstr, &$request, $basepage) { // no action=replace support yet if ($request->getArg('action') != 'browse') { return $this->disabled("(action != 'browse')"); } $args = $this->getArgs($argstr, $request); $this->_args = $args; //TODO: support p from <!plugin-list !> $this->preSelectS($args, $request); $p = $request->getArg('p'); if (!$p) { $p = $this->_list; } $post_args = $request->getArg('admin_replace'); $next_action = 'select'; $pages = array(); if ($p && !$request->isPost()) { $pages = $p; } if ($p && $request->isPost() && empty($post_args['cancel'])) { // without individual PagePermissions: if (!ENABLE_PAGEPERM and !$request->_user->isAdmin()) { $request->_notAuthorized(WIKIAUTH_ADMIN); $this->disabled("! user->isAdmin"); } if ($post_args['action'] == 'verify' and !empty($post_args['from'])) { // Real action return $this->searchReplacePages($dbi, $request, array_keys($p), $post_args['from'], $post_args['to']); } if ($post_args['action'] == 'select') { if (!empty($post_args['from'])) { $next_action = 'verify'; } foreach ($p as $name => $c) { $pages[$name] = 1; } } } if ($next_action == 'select' and empty($pages)) { // List all pages to select from. //TODO: check for permissions and list only the allowed $pages = $this->collectPages($pages, $dbi, $args['sortby'], $args['limit'], $args['exclude']); } if ($next_action == 'verify') { $args['info'] = "checkbox,pagename,hi_content"; } $pagelist = new PageList_Selectable($args['info'], $args['exclude'], array_merge($args, array('types' => array('hi_content' => new _PageList_Column_content('rev:hi_content', _("Content")))))); $pagelist->addPageList($pages); $header = HTML::p(); if (empty($post_args['from'])) { $header->pushContent(HTML::p(HTML::em(_("Warning: The search string cannot be empty!")))); } if ($next_action == 'verify') { $button_label = _("Yes"); $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently search & replace text in the selected files?")))); $this->replaceForm($header, $post_args); } else { $button_label = _("Search & Replace"); $this->replaceForm($header, $post_args); $header->pushContent(HTML::p(_("Select the pages to search:"))); } $buttons = HTML::p(Button('submit:admin_replace[rename]', $button_label, 'wikiadmin'), Button('submit:admin_replace[cancel]', _("Cancel"), 'button')); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $pagelist->getContent(), HiddenInputs($request->getArgs(), false, array('admin_replace')), HiddenInputs(array('admin_replace[action]' => $next_action)), ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), $buttons); }
function getDocumentPath($id, $group_id, $referrer_id = null) { $parents = array(); $html = HTML(); $hp =& Codendi_HTMLPurifier::instance(); $item_factory =& $this->_getItemFactory($group_id); $item =& $item_factory->getItemFromDb($id); $reference =& $item; if ($reference && $referrer_id != $id) { while ($item && $item->getParentId() != 0) { $item =& $item_factory->getItemFromDb($item->getParentId()); $parents[] = array('id' => $item->getId(), 'title' => $item->getTitle()); } $parents = array_reverse($parents); $item_url = '/plugins/docman/?group_id=' . $group_id . '&sort_update_date=0&action=show&id='; foreach ($parents as $parent) { $html->pushContent(HTML::a(array('href' => $item_url . $parent['id'], 'target' => '_blank'), HTML::strong($parent['title']))); $html->pushContent(' / '); } $md_uri = '/plugins/docman/?group_id=' . $group_id . '&action=details&id=' . $id; //Add a pen icon linked to document properties. $pen_icon = HTML::a(array('href' => $md_uri), HTML::img(array('src' => util_get_image_theme("ic/edit.png")))); $html->pushContent(HTML::a(array('href' => $item_url . $reference->getId()), HTML::strong($reference->getTitle()))); $html->pushContent($pen_icon); $html->pushContent(HTML::br()); } return $html; }
function run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; $args = $this->getArgs($argstr, $request); extract($args); if ($since) { $since = strtotime($since); } if ($month) { $since = strtotime($month); $since = mktime(0, 0, 0, date("m", $since), 1, date("Y", $since)); $until = mktime(23, 59, 59, date("m", $since) + 1, 0, date("Y", $since)); } else { $until = 0; } $iter = $dbi->getAllPages(false, '-mtime'); $pages = array(); while ($page = $iter->next()) { $pagename = $page->getName(); if (!$page->exists()) { continue; } $rev = $page->getRevision(1, false); $date = $rev->get('mtime'); //$author = $rev->get('author_id'); $author = $page->getOwner(); if (defined('DEBUG') && DEBUG && $debug) { echo "<i>{$pagename}, ", strftime("%Y-%m-%d %h:%m:%s", $date), ", {$author}</i><br />\n"; } if ($userid and !preg_match("/" . $userid . "/", $author)) { continue; } if ($since and $date < $since) { continue; } if ($until and $date > $until) { continue; } if (!$comments and preg_match("/\\/Comment/", $pagename)) { continue; } $monthnum = strftime("%Y%m", $date); if (!isset($pages[$monthnum])) { $pages[$monthnum] = array('author' => array(), 'month' => strftime("%B, %Y", $date)); } if (!isset($pages[$monthnum]['author'][$author])) { $pages[$monthnum]['author'][$author] = array('count' => 0, 'pages' => array()); } $pages[$monthnum]['author'][$author]['count']++; $pages[$monthnum]['author'][$author]['pages'][] = $pagename; } $iter->free(); $html = HTML::table(HTML::col(array('span' => 2, 'align' => 'left'))); $nbsp = HTML::raw(' '); krsort($pages); foreach ($pages as $monthname => $parr) { $html->pushContent(HTML::tr(HTML::td(array('colspan' => 2), HTML::strong($parr['month'])))); uasort($parr['author'], 'cmp_by_count'); foreach ($parr['author'] as $user => $authorarr) { $count = $authorarr['count']; $id = preg_replace("/ /", "_", 'pages-' . $monthname . '-' . $user); $html->pushContent(HTML::tr(HTML::td($nbsp, $nbsp, HTML::img(array('id' => "{$id}-img", 'src' => $WikiTheme->_findData("images/folderArrowClosed.png"), 'onclick' => "showHideFolder('{$id}')", 'alt' => _("Click to hide/show"), 'title' => _("Click to hide/show"))), $nbsp, $user), HTML::td($count))); if ($links) { $pagelist = HTML(); foreach ($authorarr['pages'] as $p) { $pagelist->pushContent(WikiLink($p), ', '); } } else { $pagelist = join(', ', $authorarr['pages']); } $html->pushContent(HTML::tr(array('id' => $id . '-body', 'style' => 'display:none; background-color: #eee;'), HTML::td(array('colspan' => 2, 'style' => 'font-size:smaller'), $pagelist))); } } return $html; }
function run($dbi, $argstr, &$request, $basepage) { return $this->disabled("This action is blocked by administrator. Sorry for the inconvenience !"); 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), $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"; } */ $pagelist = new PageList_Selectable($args['info'], $args['exclude'], $args); $pagelist->addPageList($pages); $header = HTML::p(); if ($next_action == 'verify') { $button_label = _("Yes"); $header->pushContent(HTML::p(HTML::strong(_("Are you sure you want to permanently chown the selected files?")))); $header = $this->chownForm($header, $post_args); } else { $button_label = _("Chown selected pages"); $header->pushContent(HTML::p(_("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')); 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)), $buttons); }
/** * HomePage was not found so first-time install is supposed to run. * - import all pgsrc pages. * - Todo: installer interface to edit config/config.ini settings * - Todo: ask for existing old index.php to convert to config/config.ini * - Todo: theme-specific pages: * blog - HomePage, ADMIN_USER/Blogs */ function SetupWiki(&$request) { global $GenericPages, $LANG; //FIXME: This is a hack (err, "interim solution") // This is a bogo-bogo-login: Login without // saving login information in session state. // This avoids logging in the unsuspecting // visitor as ADMIN_USER // // This really needs to be cleaned up... // (I'm working on it.) $real_user = $request->_user; if (ENABLE_USER_NEW) { $request->_user = new _BogoUser(ADMIN_USER); } else { $request->_user = new WikiUser($request, ADMIN_USER, WIKIAUTH_BOGO); } StartLoadDump($request, _("Loading up virgin wiki")); $pgsrc = FindLocalizedFile(WIKI_PGSRC); $default_pgsrc = FindFile(DEFAULT_WIKI_PGSRC); $request->setArg('overwrite', true); if ($default_pgsrc != $pgsrc) { LoadAny($request, $default_pgsrc, $GenericPages); } $request->setArg('overwrite', false); LoadAny($request, $pgsrc); $dbi =& $request->_dbi; // Ensure that all mandatory pages are loaded $finder = new FileFinder(); if (!FUSIONFORGE) { $mandatory = explode(':', 'SandBox:Template/Category:Template/Talk:SpecialPages:CategoryCategory:CategoryActionPage:Help/OldTextFormattingRules:Help/TextFormattingRules:PhpWikiAdministration'); } else { if (WIKI_NAME == "help") { $mandatory = explode(':', 'SandBox:Template/Category:Template/Talk:SpecialPages:CategoryCategory:CategoryActionPage:Help/TextFormattingRules:PhpWikiAdministration'); } else { $mandatory = explode(':', 'SandBox:Template/UserPage:Template/Category:Template/Talk:SpecialPages:CategoryCategory:CategoryActionPage:TextFormattingRules:PhpWikiAdministration'); } } foreach (array_merge($mandatory, $GLOBALS['AllActionPages'], array(constant('HOME_PAGE'))) as $f) { $page = gettext($f); $epage = urlencode($page); if (!$dbi->isWikiPage($page)) { // translated version provided? if ($lf = FindLocalizedFile($pgsrc . $finder->_pathsep . $epage, 1)) { LoadAny($request, $lf); } else { // load english version of required action page LoadAny($request, FindFile(DEFAULT_WIKI_PGSRC . $finder->_pathsep . urlencode($f))); $page = $f; } } if (!$dbi->isWikiPage($page)) { trigger_error(sprintf("Mandatory file %s couldn't be loaded!", $page), E_USER_WARNING); } } $pagename = _("InterWikiMap"); $map = $dbi->getPage($pagename); $map->set('locked', true); PrintXML(HTML::p(HTML::em(WikiLink($pagename)), HTML::strong(" locked"))); EndLoadDump($request); }