本文整理汇总了PHP中WikiLink函数的典型用法代码示例。如果您正苦于以下问题:PHP WikiLink函数的具体用法?PHP WikiLink怎么用?PHP WikiLink使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了WikiLink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: chownPages
function chownPages(&$dbi, &$request, $pages, $newowner)
{
$ul = HTML::ul();
$count = 0;
foreach ($pages as $name) {
$page = $dbi->getPage($name);
if ($owner = $page->getOwner() and $newowner != $owner) {
if (!mayAccessPage('change', $name)) {
$ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name))));
} else {
$page->set('owner', $newowner);
if ($page->get('owner') === $newowner) {
$ul->pushContent(HTML::li(fmt("Chown page '%s' to '%s'.", WikiLink($name), WikiLink($newowner))));
$count++;
} else {
$ul->pushContent(HTML::li(fmt("Couldn't chown page '%s' to '%s'.", WikiLink($name), $newowner)));
}
}
}
}
if ($count) {
$dbi->touch();
return HTML($ul, HTML::p(fmt("%s pages have been permanently changed.", $count)));
} else {
return HTML($ul, HTML::p(fmt("No pages changed.")));
}
}
示例2: renamePages
function renamePages(&$dbi, &$request, $pages, $from, $to, $updatelinks = false)
{
$ul = HTML::ul();
$count = 0;
$post_args = $request->getArg('admin_rename');
$options = array('regex' => @$post_args['regex'], 'icase' => @$post_args['icase']);
foreach ($pages as $name) {
if ($newname = $this->renameHelper($name, $from, $to, $options) and $newname != $name) {
if ($dbi->isWikiPage($newname)) {
$ul->pushContent(HTML::li(fmt("Page %s already exists. Ignored.", WikiLink($newname))));
} elseif (!mayAccessPage('change', $name)) {
$ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name))));
} elseif ($dbi->renamePage($name, $newname, $updatelinks)) {
/* not yet implemented for all backends */
$ul->pushContent(HTML::li(fmt("Renamed page '%s' to '%s'.", $name, WikiLink($newname))));
$count++;
} else {
$ul->pushContent(HTML::li(fmt("Couldn't rename page '%s' to '%s'.", $name, $newname)));
}
} else {
$ul->pushContent(HTML::li(fmt("Couldn't rename page '%s' to '%s'.", $name, $newname)));
}
}
if ($count) {
$dbi->touch();
return HTML($ul, HTML::p(fmt("%s pages have been permanently renamed.", $count)));
} else {
return HTML($ul, HTML::p(fmt("No pages renamed.")));
}
}
示例3: PurgePage
function PurgePage(&$request)
{
global $WikiTheme;
$page = $request->getPage();
$pagelink = WikiLink($page);
if ($request->getArg('cancel')) {
$request->redirect(WikiURL($page));
// noreturn
}
$current = $page->getCurrentRevision();
if (!$current or !($version = $current->getVersion())) {
$html = HTML::p(array('class' => 'error'), _("Sorry, this page does not exist."));
} elseif (!$request->isPost() || !$request->getArg('verify')) {
$purgeB = Button('submit:verify', _("Purge Page"), 'wikiadmin');
$cancelB = Button('submit:cancel', _("Cancel"), 'button');
// use generic wiki button look
$fieldset = HTML::fieldset(HTML::p(fmt("You are about to purge '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'purge')), HTML::div(array('class' => 'toolbar'), $purgeB, $WikiTheme->getButtonSeparator(), $cancelB)));
$sample = HTML::div(array('class' => 'transclusion'));
// simple and fast preview expanding only newlines
foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) {
$sample->pushContent($s, HTML::br());
}
$html = HTML($fieldset, HTML::div(array('class' => 'wikitext'), $sample));
} elseif ($request->getArg('currentversion') != $version) {
$html = HTML(HTML::p(array('class' => 'error'), _("Someone has edited the page!")), HTML::p(fmt("Since you started the purge process, someone has saved a new version of %s. Please check to make sure you still want to permanently purge the page from the database.", $pagelink)));
} else {
// Real purge.
$pagename = $page->getName();
$dbi = $request->getDbh();
$dbi->purgePage($pagename);
$dbi->touch();
$html = HTML::div(array('class' => 'feedback'), fmt("Purged page '%s' successfully.", $pagename));
}
GeneratePage($html, _("Purge Page"));
}
示例4: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
extract($args);
$maincat = $dbi->getPage(_("CategoryCategory"));
$bi = $maincat->getBackLinks(false);
$bl = array();
while ($b = $bi->next()) {
$name = $b->getName();
if (preg_match("/^" . _("Template") . "/", $name)) {
continue;
}
$pages = $b->getBackLinks(false);
$bl[] = array('name' => $name, 'count' => $pages->count());
}
usort($bl, 'cmp_by_count');
$html = HTML::ul();
$i = 0;
foreach ($bl as $b) {
$i++;
$name = $b['name'];
$count = $b['count'];
if ($count < $mincount) {
break;
}
if ($i > $limit) {
break;
}
$wo = preg_replace("/^(" . _("Category") . "|" . _("Topic") . ")/", "", $name);
$wo = HTML(HTML::span($wo), HTML::raw(" "), HTML::small("(" . $count . ")"));
$link = WikiLink($name, 'auto', $wo);
$html->pushContent(HTML::li($link));
}
return $html;
}
示例5: run
function run($dbi, $argstr, &$request, $basepage)
{
extract($this->getArgs($argstr, $request));
if ($numberlinks > 10 || $numberlinks < 0) {
$numberlinks = $this->def_numberlinks;
}
// Get name of the current page we are on
$thispage = $request->getArg('pagename');
$Pages = $request->session->get("PageTrail");
if (!is_array($Pages)) {
$Pages = array();
}
if (!isset($Pages[0]) or $duplicates || $thispage != $Pages[0]) {
array_unshift($Pages, $thispage);
$request->session->set("PageTrail", $Pages);
}
$numberlinks = min(count($Pages), $numberlinks);
if (!$invisible and $numberlinks) {
$html = HTML::div(array('class' => 'pagetrail'));
$html->pushContent(WikiLink($Pages[$numberlinks - 1], 'auto'));
for ($i = $numberlinks - 2; $i >= 0; $i--) {
if (!empty($Pages[$i])) {
$html->pushContent(PAGETRAIL_ARROW, WikiLink($Pages[$i], 'auto'));
}
}
return $html;
} else {
return HTML();
}
}
示例6: pageLink
function pageLink(&$rev, $link_text = false)
{
if (!$link_text and $rev->get('pagetype') == 'wikiblog') {
$link_text = $rev->get('summary');
}
return WikiLink($rev, 'auto', $link_text);
}
示例7: box
function box($args = false, $request = false, $basepage = false)
{
if (!$request) {
$request =& $GLOBALS['request'];
}
$stats = $this->getStats($request->_dbi, $request, 'summary');
return $this->makeBox(_("Who is online"), HTML(HTML::Raw('· '), WikiLink(_("WhoIsOnline"), 'auto', fmt("%d online users", $stats['NUM_USERS']))));
}
示例8: run
function run($dbi, $argstr, &$request, $basepage)
{
extract($this->getArgs($argstr, $request));
// Any text that is returned will not be further transformed,
// so use html where necessary.
$html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')), THE_END);
return $html;
}
示例9: run
function run($dbi, $argstr, &$request, $basepage)
{
if (is_array($argstr)) {
// can do with array also.
$args =& $argstr;
if (!isset($args['order'])) {
$args['order'] = 'reverse';
}
} else {
$args = $this->getArgs($argstr, $request);
}
$user = $request->getUser();
if (empty($args['user'])) {
if ($user->isAuthenticated()) {
$args['user'] = $user->UserName();
} else {
$args['user'] = '';
}
}
if (!$args['user'] or $args['user'] == ADMIN_USER) {
if (BLOG_EMPTY_DEFAULT_PREFIX) {
$args['user'] = '';
} else {
$args['user'] = ADMIN_USER;
}
// "Admin/Blogs/day" pages
}
$parent = empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR;
$sp = HTML::Raw('· ');
$prefix = $parent . $this->_blogPrefix('wikiblog');
if ($args['month']) {
$prefix .= SUBPAGE_SEPARATOR . $args['month'];
}
$pages = $dbi->titleSearch(new TextSearchQuery("^" . $prefix, true, 'posix'));
$html = HTML();
$i = 0;
while ($page = $pages->next() and $i < $args['count']) {
$rev = $page->getCurrentRevision(false);
if ($rev->get('pagetype') != 'wikiblog') {
continue;
}
$i++;
$blog = $this->_blog($rev);
//$html->pushContent(HTML::h3(WikiLink($page, 'known', $rev->get('summary'))));
$html->pushContent($rev->getTransformedContent('wikiblog'));
}
if ($args['user'] == $user->UserName()) {
$html->pushContent(WikiLink(_("WikiBlog"), 'known', "New entry"));
}
if (!$i) {
return HTML(HTML::h3(_("No Blog Entries")), $html);
}
if (!$args['noheader']) {
return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))), $html);
} else {
return $html;
}
}
示例10: RemovePage
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"));
}
示例11: run
function run($dbi, $argstr, $request, $basepage)
{
$args = $this->getArgs($argstr, $request);
$pages = false;
// Todo: extend given _GET args
if ($args['debug']) {
$timer = new DebugTimer();
}
$caption = _("All pages in this wiki (%d total):");
if (!empty($args['owner'])) {
$pages = PageList::allPagesByOwner($args['owner'], $args['include_empty'], $args['sortby'], $args['limit']);
if ($args['owner']) {
$caption = fmt("List of pages owned by [%s] (%d total):", WikiLink($args['owner'] == '[]' ? $request->_user->getAuthenticatedId() : $args['owner'], 'if_known'), count($pages));
}
} elseif (!empty($args['author'])) {
$pages = PageList::allPagesByAuthor($args['author'], $args['include_empty'], $args['sortby'], $args['limit']);
if ($args['author']) {
$caption = fmt("List of pages last edited by [%s] (%d total):", WikiLink($args['author'] == '[]' ? $request->_user->getAuthenticatedId() : $args['author'], 'if_known'), count($pages));
}
} elseif (!empty($args['creator'])) {
$pages = PageList::allPagesByCreator($args['creator'], $args['include_empty'], $args['sortby'], $args['limit']);
if ($args['creator']) {
$caption = fmt("List of pages created by [%s] (%d total):", WikiLink($args['creator'] == '[]' ? $request->_user->getAuthenticatedId() : $args['creator'], 'if_known'), count($pages));
}
//} elseif ($pages) {
// $args['count'] = count($pages);
} else {
if (!$request->getArg('count')) {
$args['count'] = $dbi->numPages($args['include_empty'], $args['exclude']);
} else {
$args['count'] = $request->getArg('count');
}
}
if (empty($args['count']) and !empty($pages)) {
$args['count'] = count($pages);
}
$pagelist = new PageList($args['info'], $args['exclude'], $args);
if (!$args['noheader']) {
$pagelist->setCaption($caption);
}
// deleted pages show up as version 0.
if ($args['include_empty']) {
$pagelist->_addColumn('version');
}
if ($pages !== false) {
$pagelist->addPageList($pages);
} else {
$pagelist->addPages($dbi->getAllPages($args['include_empty'], $args['sortby'], $args['limit']));
}
if ($args['debug']) {
return HTML($pagelist, HTML::p(fmt("Elapsed time: %s s", $timer->getStats())));
} else {
return $pagelist;
}
}
示例12: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
extract($args);
// fix deprecated arg
if (is_integer($pages)) {
$numpages = $pages;
$pages = false;
// fix new pages handling in arg preprozessor.
} elseif (is_array($pages)) {
$numpages = (int) $pages[0];
if ($numpages > 0 and !$dbi->isWikiPage($numpages)) {
$pages = false;
} else {
$numpages = 1;
}
}
$allpages = $dbi->getAllPages(false, $sortby, $limit, $exclude);
$pagearray = $allpages->asArray();
better_srand();
// Start with a good seed.
if ($numpages == 1 && $pagearray) {
$page = $pagearray[array_rand($pagearray)];
$pagename = $page->getName();
if ($redirect) {
$request->redirect(WikiURL($pagename, false, 'absurl'));
}
// noreturn
if ($hidename) {
return WikiLink($pagename, false, _("RandomPage"));
} else {
return WikiLink($pagename);
}
}
$numpages = min(max(1, (int) $numpages), 20, count($pagearray));
$pagelist = new PageList($info, $exclude, $args);
$shuffle = array_rand($pagearray, $numpages);
if (is_array($shuffle)) {
foreach ($shuffle as $i) {
if (isset($pagearray[$i])) {
$pagelist->addPage($pagearray[$i]);
}
}
} else {
// if $numpages = 1
if (isset($pagearray[$shuffle])) {
$pagelist->addPage($pagearray[$shuffle]);
}
}
return $pagelist;
}
示例13: chmarkupPages
function chmarkupPages(&$dbi, &$request, $pages, $newmarkup)
{
$result = HTML::div();
$ul = HTML::ul();
$count = 0;
foreach ($pages as $name) {
$page = $dbi->getPage($name);
$current = $page->getCurrentRevision();
$markup = $current->get('markup');
if (!$markup or $newmarkup != $markup) {
if (!mayAccessPage('change', $name)) {
$result->setAttr('class', 'error');
$result->pushContent(HTML::p(fmt("Access denied to change page '%s'.", WikiLink($name))));
} else {
$version = $current->getVersion();
$meta = $current->_data;
$meta['markup'] = $newmarkup;
// convert text?
$text = $current->getPackedContent();
$meta['summary'] = sprintf(_("Change markup type from %s to %s"), $markup, $newmarkup);
$meta['is_minor_edit'] = 1;
$meta['author'] = $request->_user->UserName();
unset($meta['mtime']);
// force new date
$page->save($text, $version + 1, $meta);
$current = $page->getCurrentRevision();
if ($current->get('markup') === $newmarkup) {
$ul->pushContent(HTML::li(fmt("change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup)));
$count++;
} else {
$ul->pushContent(HTML::li(fmt("Couldn't change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup)));
}
}
}
}
if ($count) {
$dbi->touch();
$result->setAttr('class', 'feedback');
if ($count == 1) {
$result->pushContent(HTML::p("One page has been permanently changed:"));
} else {
$result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count)));
}
$result->pushContent($ul);
return $result;
} else {
$result->setAttr('class', 'error');
$result->pushContent(HTML::p("No pages changed."));
return $result;
}
}
示例14: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
extract($args);
if (empty($page) && empty($prefix) && empty($suffix)) {
return '';
}
if ($prefix) {
$suffix = false;
$descrip = fmt("Page names with prefix '%s'", $prefix);
} elseif ($suffix) {
$descrip = fmt("Page names with suffix '%s'", $suffix);
} elseif ($page) {
$words = preg_split('/[\\s:-;.,]+/', SplitPagename($page));
$words = preg_grep('/\\S/', $words);
$prefix = reset($words);
$suffix = end($words);
$descrip = fmt("These pages share an initial or final title word with '%s'", WikiLink($page, 'auto'));
}
// Search for pages containing either the suffix or the prefix.
$search = $match = array();
if (!empty($prefix)) {
$search[] = $this->_quote($prefix);
$match[] = '^' . preg_quote($prefix, '/');
}
if (!empty($suffix)) {
$search[] = $this->_quote($suffix);
$match[] = preg_quote($suffix, '/') . '$';
}
if ($search) {
$query = new TextSearchQuery(join(' OR ', $search));
} else {
$query = new NullTextSearchQuery();
}
// matches nothing
$match_re = '/' . join('|', $match) . '/';
$pagelist = new PageList($info, $exclude, $args);
if (!$noheader) {
$pagelist->setCaption($descrip);
}
$pages = $dbi->titleSearch($query);
while ($page = $pages->next()) {
$name = $page->getName();
if (!preg_match($match_re, $name)) {
continue;
}
$pagelist->addPage($page);
}
return $pagelist;
}
示例15: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
if ($args['basepage']) {
$pagename = $args['basepage'];
} else {
$pagename = $request->getArg('pagename');
}
// FIXME: explodePageList from stdlib doesn't seem to work as
// expected when there are no subpages. (see also
// UnfoldSubPages plugin)
$subpages = explodePageList($pagename . SUBPAGE_SEPARATOR . '*');
if (!$subpages) {
return $this->error(_("The current page has no subpages defined."));
}
extract($args);
$content = HTML();
$subpages = array_reverse($subpages);
if ($maxpages) {
$subpages = array_slice($subpages, 0, $maxpages);
}
$descrip = fmt("SubPages of %s:", WikiLink($pagename, 'auto'));
if ($info) {
$info = explode(",", $info);
if (in_array('count', $info)) {
$args['types']['count'] = new _PageList_Column_ListSubpages_count('count', _("#"), 'center');
}
}
$pagelist = new PageList($info, $exclude, $args);
if (!$noheader) {
$pagelist->setCaption($descrip);
}
foreach ($subpages as $page) {
// A page cannot include itself. Avoid doublettes.
static $included_pages = array();
if (in_array($page, $included_pages)) {
$content->pushContent(HTML::p(sprintf(_("recursive inclusion of page %s ignored"), $page)));
continue;
}
array_push($included_pages, $page);
//if ($relative) {
// TODO: add relative subpage name display to PageList class
//}
$pagelist->addPage($page);
array_pop($included_pages);
}
$content->pushContent($pagelist);
return $content;
}