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 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 { // 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) { 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 run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; $args = $this->getArgs($argstr, $request); if (empty($args['page'])) { $args['page'] = "*"; } $form = $this->showForm($dbi, $request, $args); extract($args); if (empty($s)) { return $form; } $pagequery = new TextSearchQuery($page, $args['case_exact'], $args['regex']); $linkquery = new TextSearchQuery($s, $args['case_exact'], $args['regex']); $links = $dbi->linkSearch($pagequery, $linkquery, $direction == 'in' ? 'linkfrom' : 'linkto'); $pagelist = new PageList($args['info'], $args['exclude'], $args); $pagelist->_links = array(); while ($link = $links->next()) { $pagelist->addPage($link['pagename']); $pagelist->_links[] = $link; } $pagelist->addColumnObject(new _PageList_Column_LinkSearch_link('link', _("Link"), $pagelist)); if (!$noheader) { // We put the form into the caption just to be able to return one pagelist object, // and to still have the convenience form at the top. we could workaround this by // putting the form as WikiFormRich into the actionpage. but thid doesnt look as // nice as this here. $pagelist->setCaption(HTML($noform ? '' : HTML($form, HTML::hr()), fmt("LinkSearch result for \"%s\" in pages \"%s\", direction %s", $s, $page, $direction))); } return $pagelist; }
function run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; $this->_supported_operators = array(':=', '<', '<=', '>', '>=', '!=', '==', '=~'); $args = $this->getArgs($argstr, $request); $posted = $request->getArg('semsearch'); $request->setArg('semsearch', false); if ($request->isPost() and isset($posted['help'])) { $request->redirect(WikiURL(_("Help/SemanticSearchAdvancedPlugin"), array('redirectfrom' => $basepage), true)); } $allrelations = $dbi->listRelations(); $form = $this->showForm($dbi, $request, $args, $allrelations); if (isset($this->_norelations_warning)) { $form->pushContent(HTML::div(array('class' => 'warning'), _("Warning:") . $this->_norelations_warning)); } extract($args); // For convenience, peace and harmony we allow GET requests also. if (!$args['s']) { // check for good GET request return $form; } // nobody called us, so just display our form // In reality we have to iterate over all found pages. // To makes things shorter extract the next AND required expr and // iterate only over this, then recurse into the next AND expr. // => Split into an AND and OR expression tree. $parsed_relations = $this->detectRelationsAndAttributes($args['s']); $regex = ''; if ($parsed_relations) { $regex = preg_grep("/[\\*\\?]/", $parsed_relations); } else { $this->error("Invalid query: No relations or attributes in the query {$s} found"); } $pagelist = new PageList($args['info'], $args['exclude'], $args); if (!$noheader) { $pagelist->setCaption(HTML($noform ? '' : HTML($form, HTML::hr()), fmt("Semantic %s Search Result for \"%s\" in pages \"%s\"", '', $s, $page))); } if (!$regex and $missing = array_diff($parsed_relations, $allrelations)) { return $pagelist; } $relquery = new TextSearchQuery(join(" ", $parsed_relations)); if (!$relquery->match(join(" ", $allrelations))) { return $pagelist; } $pagequery = new TextSearchQuery($page, $args['case_exact'], $args['regex']); // if we have only numeric or text ops we can optimize. //$parsed_attr_ops = $this->detectAttrOps($args['s']); //TODO: writeme $linkquery = new TextSearchQuery($s, $args['case_exact'], $args['regex']); $links = $dbi->linkSearch($pagequery, $linkquery, 'relation', $relquery); $pagelist->_links = array(); while ($link = $links->next()) { $pagelist->addPage($link['pagename']); $pagelist->_links[] = $link; } $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_relation('relation', _("Relation"), $pagelist)); $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_link('link', _("Link"), $pagelist)); return $pagelist; }
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 getDiff() { require_once 'lib/diff.php'; $html = HTML(); $diff = new Diff($this->current->getContent(), explode("\n", $this->getContent())); if ($diff->isEmpty()) { $html->pushContent(HTML::hr(), HTML::p('[', _("Versions are identical"), ']')); } else { // New CSS formatted unified diffs $fmt = new HtmlUnifiedDiffFormatter(); $html->pushContent($fmt->format($diff)); } return $html; }
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 showDiff(&$request) { $pagename = $request->getArg('pagename'); if (is_array($versions = $request->getArg('versions'))) { // Version selection from pageinfo.php display: rsort($versions); list($version, $previous) = $versions; } else { $version = $request->getArg('version'); $previous = $request->getArg('previous'); } // abort if page doesn't exist $dbi = $request->getDbh(); $page = $request->getPage(); $current = $page->getCurrentRevision(false); if ($current->getVersion() < 1) { $html = HTML::div(array('class' => 'wikitext', 'id' => 'difftext'), HTML::p(fmt("I'm sorry, there is no such page as %s.", WikiLink($pagename, 'unknown')))); require_once 'lib/Template.php'; GeneratePage($html, sprintf(_("Diff: %s"), $pagename), false); return; //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::div(array('class' => 'wikitext', 'id' => 'difftext'), 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('action' => 'diff', '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(PageInfoRow(_("Newer page:"), $new, $request, empty($version)), PageInfoRow(_("Older page:"), $old, $request, false))); 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)); } $html->pushContent(HTML::hr(), HTML::h2($new_version)); require_once "lib/BlockParser.php"; $html->pushContent(TransformText($new, $new->get('markup'), $pagename)); } require_once 'lib/Template.php'; GeneratePage($html, sprintf(_("Diff: %s"), $pagename), $new); }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); $page = $dbi->getPage($pagename); $current = $page->getCurrentRevision(); $source = $current->getPackedContent(); if (empty($source)) { return $this->error(fmt("empty source")); } if ($basepage == _("SpellCheck")) { return $this->error(fmt("Cannot SpellCheck myself")); } $lang = $page->get('lang'); if (empty($lang)) { $lang = $GLOBALS['LANG']; } $html = HTML(); if (!function_exists('pspell_new_config')) { // use the aspell commandline interface include_once "lib/WikiPluginCached.php"; $args = ""; $source = preg_replace("/^/m", "^", $source); if (ASPELL_DATA_DIR) { $args .= " --data-dir=" . ASPELL_DATA_DIR; } // MAYBE TODO: do we have the language dictionary? $args .= " --lang=" . $lang; // use -C or autosplit wikiwords in the text $commandLine = ASPELL_EXE . " -a -C {$args} "; $cache = new WikiPluginCached(); $code = $cache->filterThroughCmd($source, $commandLine); if (empty($code)) { return $this->error(fmt("Couldn't start commandline '%s'", $commandLine)); } $sugg = array(); foreach (preg_split("/\n/", $code) as $line) { if (preg_match("/^& (\\w+) \\d+ \\d+: (.+)\$/", $line, $m)) { $sugg[$m[1]] = preg_split("/, /", $m[2]); } } /*$pre = HTML::pre(HTML::raw($code)); $html->pushContent($pre);*/ } else { $sugg = pspell_check($source, $lang); } //$html->pushContent(HTML::hr(),HTML::h1(_("Spellcheck"))); $page = $request->getPage(); if ($version) { $revision = $page->getRevision($version); if (!$revision) { NoSuchRevision($request, $page, $version); } } else { $revision = $page->getCurrentRevision(); } $GLOBALS['request']->setArg('suggestions', $sugg); include_once "lib/BlockParser.php"; $ori_html = TransformText($revision, $revision->get('markup'), $page); $GLOBALS['request']->setArg('suggestions', false); $html->pushContent($ori_html, HTML::hr(), HTML::h1(_("SpellCheck result"))); $list = HTML::ul(); foreach ($sugg as $word => $suggs) { $w = HTML::span(array('class' => 'spell-wrong'), $word); // TODO: optional replace-link. jscript or request button with word replace. $r = HTML(); foreach ($suggs as $s) { $r->pushContent(HTML::a(array('class' => 'spell-sugg', 'href' => "javascript:do_replace('{$word}','{$s}')"), $s), ", "); } $list->pushContent(HTML::li($w, ": ", $r)); } $html->pushContent($list); return $html; }
function RevertPage(&$request) { $mesg = HTML::div(); $pagename = $request->getArg('pagename'); $version = $request->getArg('version'); if (!$version) { PrintXML(HTML::p(fmt("Revert"), " ", WikiLink($pagename)), HTML::p(_("missing required version argument"))); return; } $dbi =& $request->_dbi; $page = $dbi->getPage($pagename); $current = $page->getCurrentRevision(); $currversion = $current->getVersion(); if ($currversion == 0) { $mesg->pushContent(' ', _("no page content")); PrintXML(HTML::p(fmt("Revert"), " ", WikiLink($pagename)), $mesg); flush(); return; } if ($currversion == $version) { $mesg->pushContent(' ', _("same version page")); PrintXML(HTML::p(fmt("Revert"), " ", WikiLink($pagename)), $mesg); flush(); return; } if ($request->getArg('cancel')) { $mesg->pushContent(' ', _("Cancelled")); PrintXML(HTML::p(fmt("Revert"), " ", WikiLink($pagename)), $mesg); flush(); return; } if (!$request->getArg('verify')) { $mesg->pushContent(HTML::p(fmt("Are you sure to revert %s to version {$version}?", WikiLink($pagename))), HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs($request->getArgs(), false, array('verify')), HiddenInputs(array('verify' => 1)), Button('submit:verify', _("Yes"), 'button'), HTML::Raw(' '), Button('submit:cancel', _("Cancel"), 'button'))); $rev = $page->getRevision($version); $html = HTML(HTML::fieldset($mesg), HTML::hr(), $rev->getTransformedContent()); $template = Template('browse', array('CONTENT' => $html)); GeneratePage($template, $pagename, $rev); $request->checkValidators(); flush(); return; } $rev = $page->getRevision($version); $content = $rev->getPackedContent(); $versiondata = $rev->_data; $versiondata['summary'] = sprintf(_("revert to version %d"), $version); $new = $page->save($content, $currversion + 1, $versiondata); $dbi->touch(); $mesg = HTML::span(); $pagelink = WikiLink($pagename); $mesg->pushContent(fmt("Revert: %s", $pagelink), fmt("- version %d saved to database as version %d", $version, $new->getVersion())); // Force browse of current page version. $request->setArg('version', false); $template = Template('savepage', array()); $template->replace('CONTENT', $new->getTransformedContent()); GeneratePage($template, $mesg, $new); flush(); }
function run($dbi, $argstr, &$request, $basepage) { /* ignore fatal on loading */ /* global $ErrorManager; $ErrorManager->pushErrorHandler(new WikiMethodCb($this,'_error_handler')); */ // Require the XML_FOAF_Parser class. This is a pear library not included with phpwiki. // see doc/README.foaf if (findFile('XML/FOAF/Parser.php', 'missing_ok')) { require_once 'XML/FOAF/Parser.php'; } //$ErrorManager->popErrorHandler(); if (!class_exists('XML_FOAF_Parser')) { return $this->error(_("required pear library XML/FOAF/Parser.php not found in include_path")); } extract($this->getArgs($argstr, $request)); // Get our FOAF File from the foaf plugin argument or $_GET['foaf'] if (empty($foaf)) { $foaf = $request->getArg('foaf'); } $chooser = HTML::form(array('method' => 'get', 'action' => $request->getURLtoSelf()), HTML::h4(_("FOAF File URI")), HTML::input(array('id' => 'foaf', 'name' => 'foaf', 'type' => 'text', 'size' => '80', 'value' => $foaf)), HTML::br(), HTML::input(array('id' => 'pretty', 'name' => 'pretty', 'type' => 'radio', 'checked' => 'checked'), _("Pretty HTML")), HTML::input(array('id' => 'original', 'name' => 'original', 'type' => 'radio'), _("Original URL (Redirect)")), HTML::br(), HTML::input(array('type' => 'submit', 'value' => _("Parse FOAF")))); if (empty($foaf)) { return $chooser; } else { //Error Checking if (substr($foaf, 0, 7) != "http://") { return $this->error(_("foaf must be a URI starting with http://")); } // Start of output if (!empty($original)) { $request->redirect($foaf); } else { $foaffile = url_get_contents($foaf); if (!$foaffile) { //TODO: get errormsg return HTML(HTML::p("Resource isn't available: Something went wrong, probably a 404!")); } // Create new Parser object $parser = new XML_FOAF_Parser(); // Parser FOAF into $foaffile $parser->parseFromMem($foaffile); $a = $parser->toArray(); $html = HTML(HTML::h1(@$a[0]["name"]), HTML::table(HTML::thead(), HTML::tbody(@$a[0]["title"] ? HTML::tr(HTML::td(_("Title")), HTML::td($a[0]["title"])) : null, @$a[0]["homepage"][0] ? $this->iterateHTML($a[0], "homepage", $a["dc"]) : null, @$a[0]["weblog"][0] ? $this->iterateHTML($a[0], "weblog", $a["dc"]) : null, HTML::tr(HTML::td("Full Name"), @$a[0]["name"][0] ? HTML::td(@$a[0]["name"]) : null), @$a[0]["nick"][0] ? $this->iterateHTML($a[0], "nick", $a["dc"]) : null, @$a[0]["mboxsha1sum"][0] ? $this->iterateHTML($a[0], "mboxsha1sum", $a["dc"]) : null, @$a[0]["depiction"][0] ? $this->iterateHTML($a[0], "depiction", $a["dc"]) : null, @$a[0]["seealso"][0] ? $this->iterateHTML($a[0], "seealso", $a["dc"]) : null, HTML::tr(HTML::td("Source"), HTML::td(HTML::a(array('href' => @$foaf), "RDF")))))); if (DEBUG) { $html->pushContent(HTML::hr(), $chooser); } return $html; } } }
function run($dbi, $argstr, &$request, $basepage) { $this->disallowed_extensions = explode("\n", "ad[ep]\nasd\nba[st]\nchm\ncmd\ncom\ncgi\ncpl\ncrt\ndll\neml\nexe\nhlp\nhta\nin[fs]\nisp\njse?\nlnk\nmd[betw]\nms[cipt]\nnws\nocx\nops\npcd\np[ir]f\nphp\npl\npy\nreg\nsc[frt]\nsh[bsm]?\nswf\nurl\nvb[esx]?\nvxd\nws[cfh]"); //removed "\{[[:xdigit:]]{8}(?:-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}\}" $args = $this->getArgs($argstr, $request); extract($args); $file_dir = getUploadFilePath(); //$url_prefix = SERVER_NAME . DATA_PATH; $form = HTML::form(array('action' => $request->getPostURL(), 'enctype' => 'multipart/form-data', 'method' => 'post')); $contents = HTML::div(array('class' => 'wikiaction')); $contents->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => MAX_UPLOAD_SIZE))); /// MV add pv /// @todo: have a generic method to transmit pv if (!empty($_REQUEST['pv'])) { $contents->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'pv', 'value' => $_REQUEST['pv']))); } $contents->pushContent(HTML::input(array('name' => 'userfile', 'type' => 'file', 'size' => '50'))); $contents->pushContent(HTML::raw(" ")); $contents->pushContent(HTML::input(array('value' => _("Upload"), 'type' => 'submit'))); $form->pushContent($contents); $message = HTML(); if ($request->isPost() and $this->only_authenticated) { // Make sure that the user is logged in. $user = $request->getUser(); if (!$user->isAuthenticated()) { $message->pushContent(HTML::h2(_("ACCESS DENIED: You must log in to upload files.")), HTML::br(), HTML::br()); $result = HTML(); $result->pushContent($form); $result->pushContent($message); return $result; } } $userfile = $request->getUploadedFile('userfile'); if ($userfile) { $userfile_name = $userfile->getName(); $userfile_name = trim(basename($userfile_name)); $userfile_tmpname = $userfile->getTmpName(); $err_header = HTML::h2(fmt("ERROR uploading '%s': ", $userfile_name)); /// MV add /// Wiki attachments $wa = new WikiAttachment(GROUP_ID); $rev = $wa->createRevision($userfile_name, $userfile->getSize(), $userfile->getType(), $userfile->getTmpName()); if ($rev >= 0) { $prev = $rev + 1; $interwiki = new PageType_interwikimap(); $link = $interwiki->link("Upload:{$prev}/{$userfile_name}"); $message->pushContent(HTML::h2(_("File successfully uploaded."))); $message->pushContent(HTML::ul(HTML::li($link))); // the upload was a success and we need to mark this event in the "upload log" if ($logfile) { $upload_log = $file_dir . basename($logfile); $this->log($userfile, $upload_log, $message); } if ($autolink) { require_once "lib/loadsave.php"; $pagehandle = $dbi->getPage($page); if ($pagehandle->exists()) { // don't replace default contents $current = $pagehandle->getCurrentRevision(); $version = $current->getVersion(); $text = $current->getPackedContent(); $newtext = $text . "\n* [Upload:{$userfile_name}]"; $meta = $current->_data; $meta['summary'] = sprintf(_("uploaded %s"), $userfile_name); $pagehandle->save($newtext, $version + 1, $meta); } } } else { $message->pushContent($err_header); $message->pushContent(HTML::br(), _("Uploading failed."), HTML::br()); } } else { $message->pushContent(HTML::br(), HTML::br()); } /// {{{ Codendi Specific // URL arguments if (array_key_exists('offset', $_REQUEST)) { $offset = $_REQUEST['offset']; } else { $offset = 0; } if (array_key_exists('limit', $_REQUEST)) { $limit = $_REQUEST['limit']; } else { $limit = 10; } $attchTab = HTML::table(array('border' => '1', 'width' => '100%')); $attchTab->pushContent(HTML::tr(HTML::th(_("Attachment")), HTML::th(_("Number of revision")))); $wai =& WikiAttachment::getListWithCounter(GROUP_ID, user_getid(), array('offset' => $offset, 'nb' => $limit)); $wai->rewind(); while ($wai->valid()) { $wa =& $wai->current(); $filename = basename($wa->getFilename()); $url = getUploadDataPath() . urlencode($filename); $line = HTML::tr(); $line->pushContent(HTML::td(HTML::a(array('href' => $url), "Attach:" . $filename))); $line->pushContent(HTML::td($wa->count())); $attchTab->pushContent($line); $wai->next(); } $attchList = HTML(); $attchList->pushContent(HTML::hr(), HTML::h2(_("Attached files"))); $attchList->pushContent($attchTab); $url = WikiURL("UpLoad"); if (!empty($_REQUEST['pv'])) { $url .= '&pv=' . $_REQUEST['pv']; } $attchList->pushContent(HTML::a(array('href' => $url . '&offset=' . ($offset - $limit)), "<- Previous")); $attchList->pushContent(" - "); $attchList->pushContent(HTML::a(array('href' => $url . '&offset=' . ($offset + $limit)), "Next ->")); /// }}} //$result = HTML::div( array( 'class' => 'wikiaction' ) ); $result = HTML(); $result->pushContent($form); $result->pushContent($message); $result->pushContent($attchList); return $result; }
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) { $args = $this->getArgs($argstr, $request); $user =& $request->_user; if (isa($request, 'MockRequest')) { return ''; } if (!$request->isActionPage($request->getArg('pagename')) and (!isset($user->_prefs->_method) or !in_array($user->_prefs->_method, array('ADODB', 'SQL'))) or in_array($request->getArg('action'), array('zip', 'ziphtml', 'dumphtml')) or isa($user, '_ForbiddenUser')) { $no_args = $this->getDefaultArguments(); // ? // foreach ($no_args as $key => $value) { // $no_args[$value] = false; // } $no_args['errmsg'] = HTML(HTML::h2(_("Error: The user HomePage must be a valid WikiWord. Sorry, UserPreferences cannot be saved."), HTML::hr())); $no_args['isForm'] = false; return Template('userprefs', $no_args); } $userid = $user->UserName(); if ($user->isAuthenticated() and !empty($userid)) { $pref =& $request->_prefs; $args['isForm'] = true; //trigger_error("DEBUG: reading prefs from getPreferences".print_r($pref)); if ($request->isPost()) { $errmsg = ''; $delete = $request->getArg('delete'); if ($delete and $request->getArg('verify')) { // deleting prefs, verified $default_prefs = $pref->defaultPreferences(); $default_prefs['userid'] = $user->UserName(); $user->setPreferences($default_prefs); $request->_setUser($user); $request->setArg("verify", false); $request->setArg("delete", false); $alert = new Alert(_("Message"), _("Your UserPreferences have been successfully deleted.")); $alert->show(); return; } elseif ($delete and !$request->getArg('verify')) { return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs(array('verify' => 1)), HiddenInputs($request->getArgs()), HTML::p(_("Do you really want to delete all your UserPreferences?")), HTML::p(Button('submit:delete', _("Yes"), 'delete'), HTML::Raw(' '), Button('cancel', _("Cancel")))); } elseif ($rp = $request->getArg('pref')) { // replace only changed prefs in $pref with those from request if (!empty($rp['passwd']) and $rp['passwd2'] != $rp['passwd']) { $errmsg = _("Wrong password. Try again."); } else { //trigger_error("DEBUG: reading prefs from request".print_r($rp)); //trigger_error("DEBUG: writing prefs with setPreferences".print_r($pref)); if (empty($rp['passwd'])) { unset($rp['passwd']); } // fix to set system pulldown's. empty values don't get posted if (empty($rp['theme'])) { $rp['theme'] = ''; } if (empty($rp['lang'])) { $rp['lang'] = ''; } $num = $user->setPreferences($rp); if (!empty($rp['passwd'])) { $passchanged = false; if ($user->mayChangePass()) { if (method_exists($user, 'storePass')) { $passchanged = $user->storePass($rp['passwd']); } if (!$passchanged and method_exists($user, 'changePass')) { $passchanged = $user->changePass($rp['passwd']); } if ($passchanged) { $errmsg = _("Password updated."); } else { $errmsg = _("Password was not changed."); } } else { $errmsg = _("Password cannot be changed."); } } if (!$num) { $errmsg .= " " . _("No changes."); } else { $request->_setUser($user); $pref = $user->_prefs; $errmsg .= sprintf(_("%d UserPreferences fields successfully updated."), $num); } } $args['errmsg'] = HTML(HTML::h2($errmsg), HTML::hr()); } } $args['available_themes'] = listAvailableThemes(); $args['available_languages'] = listAvailableLanguages(); return Template('userprefs', $args); } else { // wrong or unauthenticated user return $request->_notAuthorized(WIKIAUTH_BOGO); //return $user->PrintLoginForm ($request, $args, false, false); } }
function chmodForm(&$header, $post_args) { $header->pushContent(HTML::p(HTML::em(_("This plugin is currently under development and does not work!")))); $header->pushContent(_("Chmod to permission:")); $header->pushContent(HTML::input(array('name' => 'admin_chmod[perm]', 'value' => $post_args['perm']))); $header->pushContent(' ' . _("(ugo : rwx)")); $header->pushContent(HTML::p()); $checkbox = HTML::input(array('type' => 'checkbox', 'name' => 'admin_chmod[updatechildren]', 'value' => 1)); if (!empty($post_args['updatechildren'])) { $checkbox->setAttr('checked', 'checked'); } $header->pushContent($checkbox, HTML::raw(" "), _("Propagate new permissions to all subpages?"), HTML::raw(" "), HTML::em(_("(disable individual page permissions, enable inheritance)?"))); $header->pushContent(HTML::hr(), HTML::p()); return $header; }
function run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; $this->_supported_operators = array(':=', '<', '<=', '>', '>=', '!=', '==', '=~'); $this->_text_operators = array(':=', '==', '=~', '!='); $args = $this->getArgs($argstr, $request); if (empty($args['page'])) { $args['page'] = "*"; } if (!isset($args['s'])) { // it might be (integer) 0 $args['s'] = "*"; } $posted = $request->getArg("semsearch"); $form = $this->showForm($dbi, $request, $args); if (isset($this->_norelations_warning)) { $form->pushContent(HTML::div(array('class' => 'warning'), _("Warning:"), HTML::br(), _("No relations nor attributes in the whole wikidb defined!"), "\n", fmt("See %s", WikiLink(_("Help:SemanticRelations"))))); } extract($args); // for convenience and harmony we allow GET requests also. if (!$request->isPost()) { if ($relation or $attribute) { // check for good GET request } else { return $form; } // nobody called us, so just display our supadupa form } $pagequery = $this->regex_query($page, $args['case_exact'], $args['regex']); // we might want to check for semsearch['relations'] and semsearch['attributes'] also if (empty($relation) and empty($attribute)) { // so we just clicked without selecting any relation. // hmm. check which button we clicked, before we do the massive alltogether search. if (isset($posted['relations']) and $posted['relations']) { $relation = '*'; } elseif (isset($posted['attributes']) and $posted['attributes']) { $attribute = '*'; // here we have to check for invalid text operators. ignore it then if (!in_array($attr_op, $this->_text_operators)) { $attribute = ''; } } } $searchtype = "Text"; if (!empty($relation)) { $querydesc = $relation . "::" . $s; $linkquery = $this->regex_query($s, $args['case_exact'], $args['regex']); $relquery = $this->regex_query($relation, $args['case_exact'], $args['regex']); $links = $dbi->linkSearch($pagequery, $linkquery, 'relation', $relquery); $pagelist = new PageList($info, $exclude, $args); $pagelist->_links = array(); while ($link = $links->next()) { $pagelist->addPage($link['pagename']); $pagelist->_links[] = $link; } // default (=empty info) wants all three. but we want to be able to override this. // $pagelist->_columns_seen is the exploded info if (!$info or $info and isset($pagelist->_columns_seen['relation'])) { $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_relation('relation', _("Relation"), $pagelist)); } if (!$args['info'] or $args['info'] and isset($pagelist->_columns_seen['linkto'])) { $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_link('linkto', _("Link"), $pagelist)); } } // can we merge two different pagelist? if (!empty($attribute)) { $relquery = $this->regex_query($attribute, $args['case_exact'], $args['regex']); if (!in_array($attr_op, $this->_supported_operators)) { return HTML($form, $this->error(fmt("Illegal operator: %s", HTML::tt($attr_op)))); } $s_base = preg_replace("/,/", "", $s); $units = new Units(); if (!is_numeric($s_base)) { $s_base = $units->basevalue($s_base); $is_numeric = is_numeric($s_base); } else { $is_numeric = true; } // check which type to search with: // at first check if forced text matcher if ($attr_op == '=~') { if ($s == '*') { $s = '.*'; } // help the poor user. we need pcre syntax. $linkquery = new TextSearchQuery("{$s}", $args['case_exact'], 'pcre'); $querydesc = "{$attribute} {$attr_op} {$s}"; } elseif ($is_numeric) { // do comparison with numbers /* We want to search for multiple attributes also. linkSearch can do this. * But we have to construct the query somehow. (that's why we try the AND OR dhtml) * population < 1 million AND area > 50 km2 * Here we check only for one attribute per page. * See SemanticSearchAdvanced for the full expression. */ // it might not be the best idea to use '*' as variable to expand. hmm. if ($attribute == '*') { $attribute = '_star_'; } $searchtype = "Numeric"; $query = $attribute . " " . $attr_op . " " . $s_base; $linkquery = new SemanticAttributeSearchQuery($query, $attribute, $units->baseunit($s)); if ($attribute == '_star_') { $attribute = '*'; } $querydesc = $attribute . " " . $attr_op . " " . $s; // no number or unit: check other text matchers or '*' MATCH_ALL } elseif (in_array($attr_op, $this->_text_operators)) { if ($attr_op == '=~') { if ($s == '*') { $s = '.*'; } // help the poor user. we need pcre syntax. $linkquery = new TextSearchQuery("{$s}", $args['case_exact'], 'pcre'); } else { $linkquery = $this->regex_query($s, $args['case_exact'], $args['regex']); } $querydesc = "{$attribute} {$attr_op} {$s}"; // should we fail or skip when the user clicks on Relations? } elseif (isset($posted['relations']) and $posted['relations']) { $linkquery = false; // skip } else { $querydesc = $attribute . " " . $attr_op . " " . $s; return HTML($form, $this->error(fmt("Only text operators can be used with strings: %s", HTML::tt($querydesc)))); } if ($linkquery) { $links = $dbi->linkSearch($pagequery, $linkquery, 'attribute', $relquery); if (empty($relation)) { $pagelist = new PageList($args['info'], $args['exclude'], $args); $pagelist->_links = array(); } while ($link = $links->next()) { $pagelist->addPage($link['pagename']); $pagelist->_links[] = $link; } // default (=empty info) wants all three. but we want to override this. if (!$args['info'] or $args['info'] and isset($pagelist->_columns_seen['attribute'])) { $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_relation('attribute', _("Attribute"), $pagelist)); } if (!$args['info'] or $args['info'] and isset($pagelist->_columns_seen['value'])) { $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_link('value', _("Value"), $pagelist)); } } } if (!isset($pagelist)) { $querydesc = _("<empty>"); $pagelist = new PageList(); } if (!$noheader) { // We put the form into the caption just to be able to return one pagelist object, // and to still have the convenience form at the top. we could workaround this by // putting the form as WikiFormRich into the actionpage. but thid doesnt look as // nice as this here. $pagelist->setCaption(HTML($noform ? '' : HTML($form, HTML::hr()), fmt("Semantic %s Search Result for \"%s\" in pages \"%s\"", $searchtype, $querydesc, $page))); } return $pagelist; }
function finish($errormsg = false) { static $in_exit = 0; if ($in_exit) { exit; } // just in case CloseDataBase calls us $in_exit = true; global $ErrorManager; $ErrorManager->flushPostponedErrors(); if (!empty($errormsg)) { PrintXML(HTML::br(), HTML::hr(), HTML::h2(_("Fatal PhpWiki Error")), $errormsg); // HACK: echo "\n</body></html>"; } if (is_object($this->_user)) { $this->_user->page = $this->getArg('pagename'); $this->_user->action = $this->getArg('action'); unset($this->_user->_HomePagehandle); unset($this->_user->_auth_dbi); } Request::finish(); exit; }
function run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; $args = $this->getArgs($argstr, $request); extract($args); if (empty($page)) { $page = $request->getArg('pagename'); } $relhtml = HTML(); if ($args['relations'] != '') { $relfilter = explode(",", $args['relations']); } else { $relfilter = array(); } if ($args['attributes'] != '') { $attfilter = explode(",", $args['attributes']); } else { $attfilter = array(); } foreach (explodePageList($page) as $pagename) { $p = $dbi->getPage($pagename); if ($args['relations'] != '0') { $links = $p->getRelations(); // iter of pagelinks // TODO: merge same relations together located_in::here, located_in::there while ($object = $links->next()) { if ($related = $object->get('linkrelation')) { // a page name if ($relfilter and !in_array($related, $relfilter)) { continue; } $rellink = WikiLink($related, false, $related); $rellink->setAttr('class', $rellink->getAttr('class') . ' relation'); $relhtml->pushContent($pagename . " ", $rellink, HTML::span(array('class' => 'relation-symbol'), "::"), WikiLink($object->_pagename), " ", $WikiTheme->makeActionButton(array('relation' => $related, 's' => $object->_pagename), '+', _("SemanticSearch")), count($relfilter) > 3 ? HTML::br() : " "); } } if (!empty($relhtml->_content) and !$noheader) { $relhtml = HTML(HTML::hr(), HTML::h3(fmt("Semantic relations for %s", $pagename)), $relhtml); } } $atthtml = HTML(); if ($args['attributes'] != '0') { if ($attributes = $p->get('attributes')) { // a hash of unique pairs foreach ($attributes as $att => $val) { if ($attfilter and !in_array($att, $attfilter)) { continue; } $rellink = WikiLink($att, false, $att); $rellink->setAttr('class', $rellink->getAttr('class') . ' relation'); $searchlink = $WikiTheme->makeActionButton(array('attribute' => $att, 's' => $val), $val, _("SemanticSearch")); $searchlink->setAttr('class', $searchlink->getAttr('class') . ' attribute'); if (!$noheader) { $atthtml->pushContent("{$pagename} "); } $atthtml->pushContent(HTML::span(array('class' => 'attribute ' . $att), $rellink, HTML::span(array('class' => 'relation-symbol'), ":="), $searchlink), count($attfilter) > 3 ? HTML::br() : " "); } if (!$noheader) { $relhtml = HTML($relhtml, HTML::hr(), HTML::h3(fmt("Attributes of %s", $pagename)), $atthtml); } else { $relhtml = HTML($relhtml, $atthtml); } } } } if ($nohelp) { return $relhtml; } return HTML($relhtml, HTML::hr(), WikiLink(_("Help/SemanticRelations"), false, HTML::em(_("Help/SemanticRelations"))), " - ", HTML::em(_("Find out how to add relations and attributes to pages."))); }