function PageInfoRow($label, $rev, &$request) { global $WikiTheme, $WikiNameRegexp; $row = HTML::tr(HTML::td(array('align' => 'right'), $label)); if ($rev) { $author = $rev->get('author'); $dbi = $request->getDbh(); $iswikipage = isWikiWord($author) && $dbi->isWikiPage($author); $authorlink = $iswikipage ? WikiLink($author) : $author; $linked_version = WikiLink($rev, 'existing', $rev->getVersion()); $row->pushContent(HTML::td(fmt("version %s", $linked_version)), HTML::td($WikiTheme->getLastModifiedMessage($rev, false)), HTML::td(fmt("by %s", $authorlink))); } else { $row->pushContent(HTML::td(array('colspan' => '3'), _("None"))); } return $row; }
/** A BogoLoginUser requires no password at all * But if there's one stored, we override it with the PersonalPagePassUser instead */ function checkPass($submitted_password) { if ($this->_prefs->get('passwd')) { if (isset($this->_prefs->_method) and $this->_prefs->_method == 'HomePage') { $user = new _PersonalPagePassUser($this->_userid, $this->_prefs); if ($user->checkPass($submitted_password)) { if (!check_php_version(5)) { eval("\$this = \$user;"); } // /*PHP5 patch*/$this = $user; $user = UpgradeUser($this, $user); $this->_level = WIKIAUTH_USER; return $this->_level; } else { $this->_level = WIKIAUTH_ANON; return $this->_level; } } else { $stored_password = $this->_prefs->get('passwd'); if ($this->_checkPass($submitted_password, $stored_password)) { $this->_level = WIKIAUTH_USER; return $this->_level; } elseif (USER_AUTH_POLICY === 'strict') { $this->_level = WIKIAUTH_FORBIDDEN; return $this->_level; } else { return $this->_tryNextPass($submitted_password); } } } if (isWikiWord($this->_userid)) { $this->_level = WIKIAUTH_BOGO; } else { $this->_level = WIKIAUTH_ANON; } return $this->_level; }
function userExists() { if (isWikiWord($this->_userid)) { $this->_level = WIKIAUTH_BOGO; return true; } else { $this->_level = WIKIAUTH_ANON; return false; } }
function findActionPage($action) { static $cache; // check for translated version, as per users preferred language // (or system default in case it is not en) $translation = gettext($action); if (isset($cache) and isset($cache[$translation])) { return $cache[$translation]; } // check for cached translated version if ($this->_isActionPage($translation)) { return $cache[$action] = $translation; } // Allow for, e.g. action=LikePages if (!isWikiWord($action)) { return $cache[$action] = false; } // check for translated version (default language) global $LANG; if ($LANG != "en") { require_once "lib/WikiPlugin.php"; require_once "lib/plugin/_WikiTranslation.php"; $trans = new WikiPlugin__WikiTranslation(); $trans->lang = $LANG; $default = $trans->translate_to_en($action, $LANG); if ($this->_isActionPage($default)) { return $cache[$action] = $default; } } else { $default = $translation; } // check for english version if ($action != $translation and $action != $default) { if ($this->_isActionPage($action)) { return $cache[$action] = $action; } } trigger_error("{$action}: Cannot find action page", E_USER_NOTICE); return $cache[$action] = false; }
function authorHasPage($author) { global $WikiNameRegexp, $request; $dbi = $request->getDbh(); return isWikiWord($author) && $dbi->isWikiPage($author); }
function pagesPulldown($query, $case_exact = false, $regex = 'auto') { require_once 'lib/TextSearchQuery.php'; $dbi =& $GLOBALS['request']->_dbi; $page_iter = $dbi->titleSearch(new TextSearchQuery($query, $case_exact, $regex)); if ($page_iter->count() > 0) { global $WikiTheme; $pages = array(); while ($p = $page_iter->next()) { $page = $p->getName(); if (DISABLE_MARKUP_WIKIWORD or !isWikiWord($page)) { $pages[] = "['{$page}', '%5B" . $page . "%5D']"; } else { $pages[] = "['{$page}', '{$page}']"; } } return HTML("\n", HTML::img(array('class' => "toolbar", 'id' => 'tb-pages', 'src' => $WikiTheme->getImageURL("ed_pages.png"), 'title' => _("AddPageLink"), 'alt' => _("AddPageLink"), 'onclick' => "showPulldown('" . _("Insert PageLink") . "',[" . join(",", $pages) . "],'" . _("Insert") . "','" . _("Close") . "','tb-pages')"))); } return ''; }
function PageInfoRow($label, $rev, &$request, $is_current = false) { global $WikiTheme; $row = HTML::tr(HTML::td(array('align' => 'right'), $label)); if ($rev) { $author = $rev->get('author'); $dbi = $request->getDbh(); $iswikipage = isWikiWord($author) && $dbi->isWikiPage($author); $authorlink = $iswikipage ? WikiLink($author) : $author; $version = $rev->getVersion(); $linked_version = WikiLink($rev, 'existing', $version); if ($is_current) { $revertbutton = HTML(); } else { $revertbutton = $WikiTheme->makeActionButton(array('action' => 'revert', 'version' => $version), false, $rev); } $row->pushContent(HTML::td(fmt("version %s", $linked_version)), HTML::td($WikiTheme->getLastModifiedMessage($rev, false)), HTML::td(fmt("by %s", $authorlink)), HTML::td($revertbutton)); } else { $row->pushContent(HTML::td(array('colspan' => '4'), _("None"))); } return $row; }
function getSpecialMembersOf($group) { //$request = &$this->request; $all = $this->_allUsers(); $users = array(); switch ($group) { case GROUP_EVERY: return $all; case GROUP_ANONYMOUS: return $users; case GROUP_BOGOUSER: foreach ($all as $u) { if (isWikiWord($u)) { $users[] = $u; } } return $users; case GROUP_SIGNED: foreach ($all as $u) { $user = WikiUser($u); if ($user->isSignedIn()) { $users[] = $u; } } return $users; case GROUP_AUTHENTICATED: foreach ($all as $u) { $user = WikiUser($u); if ($user->isAuthenticated()) { $users[] = $u; } } return $users; case GROUP_ADMIN: foreach ($all as $u) { $user = WikiUser($u); if (isset($user->_level) and $user->_level == WIKIAUTH_ADMIN) { $users[] = $u; } } return $users; case GROUP_OWNER: case GROUP_CREATOR: // this could get complex so just return an empty array return false; default: trigger_error(__sprintf("Unknown special group '%s'", $group), E_USER_WARNING); } }
/** * Translate the various special groups to the actual users settings * (userid, group membership). */ function isMember($user, $group) { global $request; if ($group === ACL_EVERY) { return true; } if (!isset($this->_group)) { $member =& $request->getGroup(); } else { $member =& $this->_group; } //$user = & $request->_user; if ($group === ACL_ADMIN) { // WIKI_ADMIN or member of _("Administrators") return $user->isAdmin() or $user->isAuthenticated() and $member->isMember(GROUP_ADMIN); } if ($group === ACL_ANONYMOUS) { return !$user->isSignedIn(); } if ($group === ACL_BOGOUSER) { if (ENABLE_USER_NEW) { return isa($user, '_BogoUser') or isWikiWord($user->_userid) and $user->_level >= WIKIAUTH_BOGO; } else { return isWikiWord($user->UserName()); } } if ($group === ACL_HASHOMEPAGE) { return $user->hasHomePage(); } if ($group === ACL_SIGNED) { return $user->isSignedIn(); } if ($group === ACL_AUTHENTICATED) { return $user->isAuthenticated(); } if ($group === ACL_OWNER) { if (!$user->isAuthenticated()) { return false; } $page = $request->getPage(); $owner = $page->getOwner(); return $owner === $user->UserName() or $member->isMember($owner); } if ($group === ACL_CREATOR) { if (!$user->isAuthenticated()) { return false; } $page = $request->getPage(); $creator = $page->getCreator(); return $creator === $user->UserName() or $member->isMember($creator); } /* Or named groups or usernames. Note: We don't seperate groups and users here. Users overrides groups with the same name. */ return $user->UserName() === $group or $member->isMember($group); }
function _getValue($page_handle, &$revision_handle) { $author = $page_handle->getCreator(); if (isWikiWord($author) && $this->dbi->isWikiPage($author)) { return WikiLink($author); } else { return $author; } }
function run($dbi, $argstr, &$request, $basepage) { $this->args = $this->getArgs($argstr, $request); extract($this->args); $this->request =& $request; if (!$from_lang) { $from_lang = $request->getPref('lang'); } if (!$from_lang) { $from_lang = $GLOBALS['LANG']; } $this->lang = $from_lang; if (empty($languages)) { $available_languages = listAvailableLanguages(); if ($from_lang == 'en') { // "en" is always the first. array_shift($available_languages); } // put from_lang to the very end. if (in_array($from_lang, $available_languages)) { $languages = $available_languages; } else { $languages = array_merge($available_languages, array($from_lang)); } } elseif (strstr($languages, ',')) { $languages = explode(',', $languages); } else { $languages = array($languages); } if (in_array('zh', $languages) or in_array('ja', $languages)) { // If the current charset != utf-8 the text will not be displayed correctly. // But here we cannot change the header anymore. So we can decide to ignore them, // or display them with all the errors. //FIXME: do iconv the ob if ($GLOBALS['charset'] != 'utf-8' and !defined('NEED_ICONV_TO')) { define('NEED_ICONV_TO', 'utf-8'); //either the extension or external //$GLOBALS['charset'] = 'utf-8'; } } $to_lang = $languages[0]; if (!empty($string) and count($languages) == 1) { return $this->translate($string, $to_lang, $from_lang); } if (!empty($page)) { $pagename = $page; if ($dbi->isWikiPage($pagename)) { $url = ''; // google can only translate from english and french if (in_array($from_lang, array('en', 'fr'))) { $url = "http://translate.google.com/translate"; $url .= "?langpair=" . urlencode($from_lang . "|" . $to_lang); $url .= "&u=" . urlencode(WikiURL($pagename, false, true)); } // redirect or transclude? if ($url) { return $request->redirect($url); } return HTML(fmt("TODO: Google can only translate from english and french. Find a translation service for %s to language %s", WikiURL($pagename, false, true), $to_lang)); } else { return $this->error(fmt("%s is empty", $pagename)); } } $pagelist = new PageList('', $exclude, $this->args); $pagelist->_columns[0]->_heading = "{$from_lang}"; foreach ($languages as $lang) { if ($lang == $from_lang) { continue; } $field = "custom:{$lang}"; $pagelist->addColumnObject(new _PageList_Column_customlang($field, $from_lang, $this)); } if (!empty($string)) { $pagelist->addPage($string); return $pagelist; } switch ($what) { case 'allpages': $pagelist->addPages($dbi->getAllPages($include_empty, $sortby, $limit, $exclude)); break; case 'pages': // not all pages, only the pgsrc pages if (!is_array($exclude)) { $exclude = $pagelist->explodePageList($exclude, false, $sortby, $limit, $exclude); } $path = FindLocalizedFile(WIKI_PGSRC); $pgsrc = new fileSet($path); foreach ($pgsrc->getFiles($exclude, $sortby, $limit) as $pagename) { $pagename = urldecode($pagename); if (substr($pagename, -1, 1) == '~') { continue; } if (in_array($pagename, $exclude)) { continue; } // exclude page. if ($match != '*' and !glob_match($match, $pagename)) { continue; } $page_handle = $dbi->getPage($pagename); $pagelist->addPage($page_handle); } break; case 'wikiwords': if (!isset($this->_locales[$from_lang])) { $this->init_locale($from_lang); } $locale =& $this->_locales[$from_lang]; if (is_array($locale)) { $count = 0; foreach ($locale as $from => $to) { if ($match != '*' and !glob_match($match, $from)) { continue; } if (isWikiWord($from)) { $count++; $pagelist->addPage($from); if ($limit and $count > $limit) { break; } } } } break; // all Button texts, which need a localized .png // where to get them from? templates/*.tmpl: Button() // and WikiLink(?,'button') // navbar links, actionpages, and admin requests // all Button texts, which need a localized .png // where to get them from? templates/*.tmpl: Button() // and WikiLink(?,'button') // navbar links, actionpages, and admin requests case 'buttons': $buttons = $GLOBALS['AllActionPages']; $fileset = new FileSet(FindFile("themes/MacOSX/buttons/en"), "*.png"); foreach ($fileset->getFiles() as $file) { $b = urldecode(substr($file, 0, -4)); if (!in_array($b, $buttons)) { $buttons[] = $b; } } $count = 0; foreach ($buttons as $button) { $pagelist->addPage($button); if ($limit and ++$count > $limit) { break; } } break; } return $pagelist; }