本文整理汇总了PHP中MWNamespace::getSubject方法的典型用法代码示例。如果您正苦于以下问题:PHP MWNamespace::getSubject方法的具体用法?PHP MWNamespace::getSubject怎么用?PHP MWNamespace::getSubject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::getSubject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* main()
*/
public function execute($par)
{
global $wgOut;
$fname = 'SpecialAdvancedRandom::execute';
wfProfileIn($fname);
list($page, $namespace) = $this->extractParamaters($par);
$ft = Title::newFromText($page);
if (is_null($ft)) {
$this->redirect(Title::newMainPage());
wfProfileOut($fname);
return;
}
$rand = wfRandom();
$dbr = wfGetDB(DB_SLAVE);
if ($ft->getNamespace() == NS_TEMPLATE) {
$res = $dbr->selectRow(array('page', 'templatelinks'), array('page_namespace', 'page_title', 'page_random'), array('page_id = tl_from', 'tl_namespace' => NS_TEMPLATE, 'page_namespace' => $namespace, 'tl_title' => $ft->getDBkey(), "page_random > {$rand}"), $fname, array('ORDER BY' => 'page_random', 'USE INDEX' => array('page' => 'page_random')));
} else {
$res = $dbr->selectRow(array('page', 'pagelinks'), array('page_namespace', 'page_title', 'page_random'), array('page_id = pl_from', 'pl_namespace' => $ft->getNamespace(), 'page_namespace' => $namespace, 'pl_title' => $ft->getDBkey(), "page_random > {$rand}"), $fname, array('ORDER BY' => 'page_random', 'USE INDEX' => array('page' => 'page_random')));
}
$title =& Title::makeTitle(MWNamespace::getSubject($namespace), $res->page_title);
if (is_null($title) || $title->getText() == '') {
$title = Title::newMainPage();
}
$this->redirect($title);
wfProfileOut($fname);
}
示例2: onGetNotificationMessage
public static function onGetNotificationMessage($nc, &$msg, $isMain, $data, $authors, $userCount, $myName)
{
if (empty($data->article_title_ns) || MWNamespace::getSubject($data->article_title_ns) != NS_WIKIA_FORUM_BOARD) {
return true;
}
if (!$isMain) {
if ($data->parent_username == $myName) {
$replyTo = "your";
} else {
$replyTo = "someone";
}
$secondUser = '';
if ($userCount == 2) {
$secondUser = $nc->getDisplayname($authors[1]['displayname']);
}
$params = [$nc->getDisplayname($data->msg_author_displayname), $secondUser, $data->article_title_text, $myName];
// Messages that can be used here:
// * forum-notification-user1-reply-to-your
// * forum-notification-user2-reply-to-your
// * forum-notification-user3-reply-to-your
// * forum-notification-user1-reply-to-someone
// * forum-notification-user2-reply-to-someone
// * forum-notification-user3-reply-to-someone
$msgKey = "forum-notification-user{$userCount}-reply-to-{$replyTo}";
} else {
$msgKey = 'forum-notification-newmsg-on-followed-wall';
$params = [$nc->getDisplayname($data->msg_author_displayname), $data->wall_displayname];
}
$msg = wfMessage($msgKey, $params)->text();
return true;
}
示例3: thread
public function thread()
{
wfProfileIn(__METHOD__);
$this->addAsset();
$title = $this->request->getVal('title', $this->app->wg->Title);
$id = $this->request->getVal('id', null);
$this->getThread($id);
$this->response->setVal('showNewMessage', false);
$this->response->setVal('type', 'Thread');
$this->response->setVal('condenseMessage', false);
if (count($this->threads) > 0) {
$wn = new WallNotifications();
foreach ($this->threads as $key => $val) {
$all = $wn->markRead($this->wg->User->getId(), $this->wg->CityId, $key);
break;
}
}
$this->response->setVal('renderUserTalkArchiveAnchor', false);
$this->response->setVal('greeting', '');
$title = Title::newFromId($id);
if (!empty($title) && $title->exists() && in_array(MWNamespace::getSubject($title->getNamespace()), $this->app->wg->WallNS)) {
$wallMessage = WallMessage::newFromTitle($title);
$wallMessage->load();
$this->app->wg->Out->setPageTitle($wallMessage->getMetaTitle());
}
// TODO: keep the varnish cache and do purging on post
$this->response->setCacheValidity(WikiaResponse::CACHE_DISABLED);
wfProfileOut(__METHOD__);
}
示例4: thread
public function thread()
{
wfProfileIn(__METHOD__);
$this->addAsset();
$title = $this->request->getVal('title', $this->app->wg->Title);
$id = $this->request->getVal('id', null);
$this->getThread($id);
$this->response->setVal('showNewMessage', false);
$this->response->setVal('type', 'Thread');
$this->response->setVal('condenseMessage', false);
if (count($this->threads) > 0) {
$wn = F::build('WallNotifications', array());
foreach ($this->threads as $key => $val) {
$all = $wn->markRead($this->wg->User->getId(), $this->wg->CityId, $key);
break;
}
}
$this->response->setVal('renderUserTalkArchiveAnchor', false);
$this->response->setVal('greeting', '');
$title = F::build('Title', array($id), 'newFromId');
if (!empty($title) && $title->exists() && in_array(MWNamespace::getSubject($title->getNamespace()), $this->app->wg->WallNS)) {
$wallMessage = F::build('WallMessage', array($title), 'newFromTitle');
$wallMessage->load();
$this->app->wg->Out->setPageTitle($wallMessage->getMetaTitle());
}
wfProfileOut(__METHOD__);
}
示例5: testGetSubject
/**
* @covers MWNamespace::getSubject
*/
public function testGetSubject()
{
// Special namespaces are their own subjects
$this->assertEquals(NS_MEDIA, MWNamespace::getSubject(NS_MEDIA));
$this->assertEquals(NS_SPECIAL, MWNamespace::getSubject(NS_SPECIAL));
$this->assertEquals(NS_MAIN, MWNamespace::getSubject(NS_TALK));
$this->assertEquals(NS_USER, MWNamespace::getSubject(NS_USER_TALK));
}
示例6: onGetMailNotificationMessage
public function onGetMailNotificationMessage($notification, &$data, $key, $watcherName, $author_signature, $textNoHtml, $text)
{
if (empty($notification->data->article_title_ns) || MWNamespace::getSubject($notification->data->article_title_ns) != NS_WIKIA_FORUM_BOARD) {
return true;
}
$data = array('$WATCHER' => $watcherName, '$BOARDNAME' => $notification->data->article_title_text, '$WIKI' => $notification->data->wikiname, '$AUTHOR_NAME' => $notification->data->msg_author_displayname, '$AUTHOR' => $notification->data->msg_author_username, '$AUTHOR_SIGNATURE' => $author_signature, '$MAIL_SUBJECT' => wfMsg('forum-mail-notification-subject', array('$1' => $notification->data->thread_title, '$2' => $notification->data->wikiname)), '$METATITLE' => $notification->data->thread_title, '$MESSAGE_LINK' => $notification->data->url, '$MESSAGE_NO_HTML' => $textNoHtml, '$MESSAGE_HTML' => $text, '$MSG_KEY_SUBJECT' => 'forum-' . $key, '$MSG_KEY_BODY' => 'forum-mail-notification-body', '$MSG_KEY_GREETING' => 'forum-mail-notification-html-greeting');
return true;
}
示例7: onAfterWallWikiActivityFilter
/**
* change the message in WikiActivity for forum namespace
*/
public function onAfterWallWikiActivityFilter(&$item, $wmessage)
{
if (!empty($item['ns']) && MWNamespace::getSubject($item['ns']) == NS_WIKIA_FORUM_BOARD) {
$app = F::App();
$board = $wmessage->getArticleTitle();
$item['wall-msg'] = wfMsg('forum-wiki-activity-msg', '<a href="' . $board->getFullURL() . '">' . wfMsg('forum-wiki-activity-msg-name', $board->getText()) . '</a>');
}
return true;
}
示例8: removeFavorite
/**
* Same as addFavorite, only the opposite.
* @return bool
*/
public function removeFavorite()
{
$success = false;
$dbw = wfGetDB(DB_MASTER);
$dbw->delete('favoritelist', array('fl_user' => $this->id, 'fl_namespace' => MWNamespace::getSubject($this->ns), 'fl_title' => $this->ti), __METHOD__);
if ($dbw->affectedRows()) {
$success = true;
}
return $success;
}
示例9: getParentPage
function getParentPage($articleComment)
{
$titleText = $articleComment->getTitle()->getDBkey();
$parts = explode('/@', $titleText);
$titleText = $parts[0];
$namespace = MWNamespace::getSubject($articleComment->getTitle()->getNamespace());
$title = Title::newFromText($titleText, $namespace);
if ($title instanceof Title) {
// create message wall if not exist
if (!$title->exists() && $namespace == NS_USER_WALL) {
$title = WallMessage::addMessageWall($title);
echo ".....Wall message NOT found.\n\tAdded wall message '{$titleText}' (" . $title->getArticleID() . ")";
return $title->getArticleId();
}
}
return $title->getArticleID();
}
示例10: removeWatch
/**
* Same as addWatch, only the opposite.
* @return bool
*/
public function removeWatch()
{
$success = false;
$dbw = wfGetDB(DB_MASTER);
$dbw->delete('watchlist', array('wl_user' => $this->id, 'wl_namespace' => MWNamespace::getSubject($this->ns), 'wl_title' => $this->ti), __METHOD__);
if ($dbw->affectedRows()) {
$success = true;
}
# the following code compensates the new behaviour, introduced by the
# enotif patch, that every single watched page needs now to be listed
# in watchlist namespace:page and namespace_talk:page had separate
# entries: clear them
$dbw->delete('watchlist', array('wl_user' => $this->id, 'wl_namespace' => MWNamespace::getTalk($this->ns), 'wl_title' => $this->ti), __METHOD__);
if ($dbw->affectedRows()) {
$success = true;
}
return $success;
}
示例11: register
function register()
{
global $wgContLang, $wgNamespaceAliases, $wgNonincludableNamespaces;
$lib = array('loadSiteStats' => array($this, 'loadSiteStats'), 'getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup'));
$info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion());
if (!self::$namespacesCache) {
$namespaces = array();
$namespacesByName = array();
foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
$canonical = MWNamespace::getCanonicalName($ns);
$namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !($wgNonincludableNamespaces && in_array($ns, $wgNonincludableNamespaces)), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'aliases' => array());
if ($ns >= NS_MAIN) {
$namespaces[$ns]['subject'] = MWNamespace::getSubject($ns);
$namespaces[$ns]['talk'] = MWNamespace::getTalk($ns);
$namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns);
} else {
$namespaces[$ns]['subject'] = $ns;
}
$namespacesByName[strtr($title, ' ', '_')] = $ns;
if ($canonical) {
$namespacesByName[$canonical] = $ns;
}
}
$aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases());
foreach ($aliases as $title => $ns) {
if (!isset($namespacesByName[$title])) {
$ct = count($namespaces[$ns]['aliases']);
$namespaces[$ns]['aliases'][$ct + 1] = $title;
$namespacesByName[$title] = $ns;
}
}
$namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->text();
self::$namespacesCache = $namespaces;
}
$info['namespaces'] = self::$namespacesCache;
if (self::$siteStatsLoaded) {
$stats = $this->loadSiteStats();
$info['stats'] = $stats[0];
}
$this->getEngine()->registerInterface('mw.site.lua', $lib, $info);
}
示例12: register
function register()
{
global $wgContLang, $wgNamespaceAliases, $wgDisableCounters;
$lib = array('getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup'), 'interwikiMap' => array($this, 'interwikiMap'));
$info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion());
if (!self::$namespacesCache || self::$namespacesCacheLang !== $wgContLang->getCode()) {
$namespaces = array();
$namespacesByName = array();
foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
$canonical = MWNamespace::getCanonicalName($ns);
$namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !MWNamespace::isNonincludable($ns), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'defaultContentModel' => MWNamespace::getNamespaceContentModel($ns), 'aliases' => array());
if ($ns >= NS_MAIN) {
$namespaces[$ns]['subject'] = MWNamespace::getSubject($ns);
$namespaces[$ns]['talk'] = MWNamespace::getTalk($ns);
$namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns);
} else {
$namespaces[$ns]['subject'] = $ns;
}
$namespacesByName[strtr($title, ' ', '_')] = $ns;
if ($canonical) {
$namespacesByName[$canonical] = $ns;
}
}
$aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases());
foreach ($aliases as $title => $ns) {
if (!isset($namespacesByName[$title]) && isset($namespaces[$ns])) {
$ct = count($namespaces[$ns]['aliases']);
$namespaces[$ns]['aliases'][$ct + 1] = $title;
$namespacesByName[$title] = $ns;
}
}
$namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->inContentLanguage()->text();
self::$namespacesCache = $namespaces;
self::$namespacesCacheLang = $wgContLang->getCode();
}
$info['namespaces'] = self::$namespacesCache;
$info['stats'] = array('pages' => (int) SiteStats::pages(), 'articles' => (int) SiteStats::articles(), 'files' => (int) SiteStats::images(), 'edits' => (int) SiteStats::edits(), 'views' => $wgDisableCounters ? null : (int) SiteStats::views(), 'users' => (int) SiteStats::users(), 'activeUsers' => (int) SiteStats::activeUsers(), 'admins' => (int) SiteStats::numberingroup('sysop'));
return $this->getEngine()->registerInterface('mw.site.lua', $lib, $info);
}
示例13: regenerateData
/**
* Regenerate / invalidate service cache for current page
*/
public function regenerateData()
{
global $wgMemc;
wfProfileIn(__METHOD__);
wfDebug(__METHOD__ . ": page #{$this->pageId}\n");
// invalidate cached data from getMostLinkedCategories()
$wgMemc->delete($this->getKey('mostlinkedcategories'));
// invalidate cached data from getCurrentRevision()
$wgMemc->delete($this->getKey('current-revision'));
// invalidate cached data from getPreviousEdits()
$wgMemc->delete($this->getKey('previous-edits'));
// invalidate cached data from getCommentsCount()
$title = Title::newFromId($this->pageId, Title::GAID_FOR_UPDATE);
if (!empty($title)) {
$pageName = $title->getPrefixedText();
wfDebug(__METHOD__ . ": page '{$pageName}' has been touched\n");
// invalidate cache with number of comments / talk page revisions
if ($title->isTalkPage()) {
if (self::isArticleCommentsEnabled() && ArticleComment::isTitleComment($title)) {
// get subject page for this article comment
$parts = ArticleComment::explode($title->getText());
$title = Title::newFromText($parts['title'], MWNamespace::getSubject($title->getNamespace()));
wfDebug(__METHOD__ . ": article comment added\n");
} else {
// get subject page for this talk page
$title = $title->getSubjectPage();
}
$contentPageName = $title->getPrefixedText();
wfDebug(__METHOD__ . ": talk page / article comment for '{$contentPageName}' has been touched\n");
$contentPageService = new self($title->getArticleId());
$contentPageService->regenerateCommentsCount();
}
}
wfProfileOut(__METHOD__);
return true;
}
示例14: removeWatch
/**
* Same as addWatch, only the opposite.
* @return bool
*/
public function removeWatch()
{
wfProfileIn(__METHOD__);
// Only loggedin user can have a watchlist
if (wfReadOnly() || $this->mUser->isAnon() || !$this->isAllowed('editmywatchlist')) {
wfProfileOut(__METHOD__);
return false;
}
$success = false;
$dbw = wfGetDB(DB_MASTER);
$dbw->delete('watchlist', array('wl_user' => $this->getUserId(), 'wl_namespace' => MWNamespace::getSubject($this->getTitleNs()), 'wl_title' => $this->getTitleDBkey()), __METHOD__);
if ($dbw->affectedRows()) {
$success = true;
}
# the following code compensates the new behavior, introduced by the
# enotif patch, that every single watched page needs now to be listed
# in watchlist namespace:page and namespace_talk:page had separate
# entries: clear them
$dbw->delete('watchlist', array('wl_user' => $this->getUserId(), 'wl_namespace' => MWNamespace::getTalk($this->getTitleNs()), 'wl_title' => $this->getTitleDBkey()), __METHOD__);
if ($dbw->affectedRows()) {
$success = true;
}
$this->watched = false;
wfProfileOut(__METHOD__);
return $success;
}
示例15: powerSearchBox
/**
* Generates the power search box at [[Special:Search]]
*
* @param string $term search term
* @param $opts array
* @return String: HTML form
*/
protected function powerSearchBox( $term, $opts ) {
global $wgContLang;
// Groups namespaces into rows according to subject
$rows = array();
foreach ( SearchEngine::searchableNamespaces() as $namespace => $name ) {
$subject = MWNamespace::getSubject( $namespace );
if ( !array_key_exists( $subject, $rows ) ) {
$rows[$subject] = "";
}
$name = $wgContLang->getConverter()->convertNamespace( $namespace );
if ( $name == '' ) {
$name = $this->msg( 'blanknamespace' )->text();
}
$rows[$subject] .=
Xml::openElement(
'td', array( 'style' => 'white-space: nowrap' )
) .
Xml::checkLabel(
$name,
"ns{$namespace}",
"mw-search-ns{$namespace}",
in_array( $namespace, $this->namespaces )
) .
Xml::closeElement( 'td' );
}
$rows = array_values( $rows );
$numRows = count( $rows );
// Lays out namespaces in multiple floating two-column tables so they'll
// be arranged nicely while still accommodating different screen widths
$namespaceTables = '';
for ( $i = 0; $i < $numRows; $i += 4 ) {
$namespaceTables .= Xml::openElement(
'table',
array( 'cellpadding' => 0, 'cellspacing' => 0 )
);
for ( $j = $i; $j < $i + 4 && $j < $numRows; $j++ ) {
$namespaceTables .= Xml::tags( 'tr', null, $rows[$j] );
}
$namespaceTables .= Xml::closeElement( 'table' );
}
$showSections = array( 'namespaceTables' => $namespaceTables );
// Show redirects check only if backend supports it
if ( $this->getSearchEngine()->supports( 'list-redirects' ) ) {
$showSections['redirects'] =
Xml::checkLabel( $this->msg( 'powersearch-redir' )->text(), 'redirs', 'redirs', $this->searchRedirects );
}
wfRunHooks( 'SpecialSearchPowerBox', array( &$showSections, $term, $opts ) );
$hidden = '';
unset( $opts['redirs'] );
foreach ( $opts as $key => $value ) {
$hidden .= Html::hidden( $key, $value );
}
// Return final output
return Xml::openElement(
'fieldset',
array( 'id' => 'mw-searchoptions', 'style' => 'margin:0em;' )
) .
Xml::element( 'legend', null, $this->msg( 'powersearch-legend' )->text() ) .
Xml::tags( 'h4', null, $this->msg( 'powersearch-ns' )->parse() ) .
Html::element( 'div', array( 'id' => 'mw-search-togglebox' ) ) .
Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
implode( Xml::element( 'div', array( 'class' => 'divider' ), '', false ), $showSections ) .
$hidden .
Xml::closeElement( 'fieldset' );
}