本文整理汇总了PHP中MWNamespace::getTalk方法的典型用法代码示例。如果您正苦于以下问题:PHP MWNamespace::getTalk方法的具体用法?PHP MWNamespace::getTalk怎么用?PHP MWNamespace::getTalk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::getTalk方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}
示例4: getDestinationTitle
/**
* Get the preferred destination title for a given target page.
* @param integer $ns The destination namespace ID
* @param string $name The conflicting prefix
* @param integer $sourceNs The source namespace
* @param integer $sourceDbk The source DB key (i.e. page_title)
* @param array $options Associative array of validated command-line options
* @return Title|false
*/
private function getDestinationTitle($ns, $name, $sourceNs, $sourceDbk, $options)
{
$dbk = substr($sourceDbk, strlen("{$name}:"));
if ($ns == 0) {
// An interwiki; try an alternate encoding with '-' for ':'
$dbk = "{$name}-" . $dbk;
}
$destNS = $ns;
if ($sourceNs == NS_TALK && MWNamespace::isSubject($ns)) {
// This is an associated talk page moved with the --move-talk feature.
$destNS = MWNamespace::getTalk($destNS);
}
$newTitle = Title::makeTitleSafe($destNS, $dbk);
if (!$newTitle || !$newTitle->canExist()) {
return false;
}
return $newTitle;
}
示例5: moveComment
/**
* move one comment
*
* @access public
* @static
*
* @param $oCommentTitle Title
* @param $oNewTitle title
*/
private static function moveComment($oCommentTitle, &$oNewTitle, $reason = '')
{
global $wgUser;
wfProfileIn(__METHOD__);
if (!is_object($oCommentTitle)) {
wfProfileOut(__METHOD__);
return array('invalid title');
}
$currentUser = $wgUser;
$wgUser = User::newFromName(self::MOVE_USER);
$parts = self::explode($oCommentTitle->getDBkey());
$commentTitleText = implode('/', $parts['partsOriginal']);
$newCommentTitle = Title::newFromText(sprintf('%s/%s', $oNewTitle->getText(), $commentTitleText), MWNamespace::getTalk($oNewTitle->getNamespace()));
$error = $oCommentTitle->moveTo($newCommentTitle, false, $reason, false);
$wgUser = $currentUser;
wfProfileOut(__METHOD__);
return $error;
}
示例6: onAfterLanguageGetNamespaces
public function onAfterLanguageGetNamespaces(&$namespaces)
{
wfProfileIn(__METHOD__);
$app = F::App();
$title = $app->wg->Title;
if (empty($title) || !$title->isSpecial('Allpages')) {
wfProfileOut(__METHOD__);
return true;
}
foreach ($app->wg->WallNS as $val) {
$ns = MWNamespace::getTalk($val);
if (!empty($namespaces[$ns])) {
unset($namespaces[$ns]);
}
}
wfProfileOut(__METHOD__);
return true;
}
示例7: getTalkPage
/**
* Get a Title object associated with the talk page of this article
*
* @return Title The object for the talk page
*/
public function getTalkPage()
{
return Title::makeTitle(MWNamespace::getTalk($this->getNamespace()), $this->getDBkey());
}
示例8: getTSIDs
/**
* Get talk page IDs (if requested) and subject page IDs (if requested)
* and put them in $talkids and $subjectids
*/
private function getTSIDs()
{
$getTitles = $this->talkids = $this->subjectids = array();
$db = $this->getDB();
foreach ($this->everything as $t) {
if (MWNamespace::isTalk($t->getNamespace())) {
if ($this->fld_subjectid) {
$getTitles[] = $t->getSubjectPage();
}
} else {
if ($this->fld_talkid) {
$getTitles[] = $t->getTalkPage();
}
}
}
if (!count($getTitles)) {
return;
}
// Construct a custom WHERE clause that matches
// all titles in $getTitles
$lb = new LinkBatch($getTitles);
$this->resetQueryParams();
$this->addTables('page');
$this->addFields(array('page_title', 'page_namespace', 'page_id'));
$this->addWhere($lb->constructSet('page', $db));
$res = $this->select(__METHOD__);
while ($row = $db->fetchObject($res)) {
if (MWNamespace::isTalk($row->page_namespace)) {
$this->talkids[MWNamespace::getSubject($row->page_namespace)][$row->page_title] = intval($row->page_id);
} else {
$this->subjectids[MWNamespace::getTalk($row->page_namespace)][$row->page_title] = intval($row->page_id);
}
}
}
示例9: removeWatch
/**
* Same as addWatch, only the opposite.
* @return bool
*/
public function removeWatch()
{
// Only loggedin user can have a watchlist
if (wfReadOnly() || $this->mUser->isAnon()) {
return false;
}
$success = false;
$dbw = wfGetDB(DB_MASTER);
$dbw->delete('watchlist', array('wl_user' => $this->userID, 'wl_namespace' => MWNamespace::getSubject($this->nameSpace), 'wl_title' => $this->databaseKey), __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->userID, 'wl_namespace' => MWNamespace::getTalk($this->nameSpace), 'wl_title' => $this->databaseKey), __METHOD__);
// No errors, update the global_watchlist table.
if ($dbw->affectedRows()) {
wfRunHooks('WatchedItem::updateWatch', array($this, $this->userID));
}
return $success;
}
示例10: loadThreadListFromDB
private function loadThreadListFromDB($master = true)
{
wfProfileIn(__METHOD__);
// get list of threads (article IDs) on Message Wall
$dbr = wfGetDB($master ? DB_MASTER : DB_SLAVE);
$query = '';
// page_latest condition is for BugId:22821
$query = "\n\t\t\tselect page.page_id, page.page_title from page\n\t\t\tleft join page_wikia_props\n\t\t\ton page.page_id = page_wikia_props.page_id\n\t\t\tand (page_wikia_props.propname = " . WPP_WALL_ADMINDELETE . "\n\t\t\t or page_wikia_props.propname = " . WPP_WALL_REMOVE . "\n\t\t\t or page_wikia_props.propname = " . WPP_WALL_ARCHIVE . ")\n\t\t\twhere page_wikia_props.page_id is null\n\t\t\tand page.page_title" . $dbr->buildLike(sprintf("%s/%s", $this->mTitle->getDBkey(), ARTICLECOMMENT_PREFIX), $dbr->anyString()) . " \n\t\t\tand page.page_title NOT " . $dbr->buildLike(sprintf("%s/%s%%/%s", $this->mTitle->getDBkey(), ARTICLECOMMENT_PREFIX, ARTICLECOMMENT_PREFIX), $dbr->anyString()) . "\n\t\t\tand page.page_title not like '%@%@%'\n\t\t\tand page.page_namespace = " . MWNamespace::getTalk($this->mTitle->getNamespace()) . "\n\t\t\tand page.page_latest > 0\n\t\t\torder by page.page_id desc";
$res = $dbr->query($query);
$this->mThreadMapping = array();
$this->mThreadMappingRev = array();
while ($row = $dbr->fetchObject($res)) {
$this->mThreadMapping[$row->page_title] = $row->page_id;
$this->mThreadMappingRev[$row->page_id] = $row->page_title;
}
wfProfileOut(__METHOD__);
}
示例11: getCommentArticleTitle
/**
* Returns comment article title.
*/
public function getCommentArticleTitle() {
if ( $this->mCommentTitle ) {
return $this->mCommentTitle;
} elseif ( $this->mCommentPage ) {
return Title::newFromID( $this->mCommentPage, Title::GAID_FOR_UPDATE );
} else {
$it = $this->mItem->mTitle;
return Title::makeTitle(
MWNamespace::getTalk( $it->getNamespace() ),
$it->getText() . '/c' . self::padID( $this->mID )
);
}
}
示例12: removeGlobalWatch
/**
* Hook function calls when watch was removed from database
* @param $oWatchItem WatchedItem: object
* @param $success Boolean: removed successfully
* @return bool (always true)
*/
public static function removeGlobalWatch($oWatchItem, $success)
{
global $wgEnableScribeReport, $wgCityId;
wfProfileIn(__METHOD__);
if (empty($wgEnableScribeReport)) {
wfProfileOut(__METHOD__);
return true;
}
if (!$oWatchItem instanceof WatchedItem) {
wfProfileOut(__METHOD__);
return true;
}
if (!$success) {
/* some errors when update in local watchlist table */
wfProfileOut(__METHOD__);
return true;
}
if ($oWatchItem->id == 0) {
wfProfileOut(__METHOD__);
return true;
}
foreach (array(MWNamespace::getSubject($oWatchItem->ns), MWNamespace::getTalk($oWatchItem->ns)) as $ns) {
$params = array('wl_user' => $oWatchItem->id, 'wl_namespace' => $ns, 'wl_title' => $oWatchItem->ti, 'wl_wikia' => $wgCityId);
try {
$message = array('method' => 'removeWatch', 'params' => $params);
$data = json_encode($message);
WScribeClient::singleton('trigger')->send($data);
} catch (Exception $e) {
Wikia::log(__METHOD__, 'scribeClient exception', $e->getMessage());
}
}
wfProfileOut(__METHOD__);
return true;
}
示例13: __construct
/**
* Constructor.
* @param $title Title object.
*/
function __construct( $title ) {
$origns = $title->getNamespace();
$this->mIsTalk = MWNamespace::isTalk( $origns );
$ns = MWNamespace::getSubject( $origns );
$tns = MWNamespace::getTalk( $origns );
if ( strpos( $title->getText(), '/' ) !== false ) {
# If title contains a '/', treat as a wikilog article title.
list( $this->mWikilogName, $this->mItemName ) =
explode( '/', $title->getText(), 2 );
if ( strpos( $this->mItemName, '/' ) !== false ) {
list( $this->mItemName, $this->mTrailing ) =
explode( '/', $this->mItemName, 2 );
}
$rawtitle = "{$this->mWikilogName}/{$this->mItemName}";
$this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName );
$this->mItemTitle = Title::makeTitle( $ns, $rawtitle );
$this->mItemTalkTitle = Title::makeTitle( $tns, $rawtitle );
} else {
# Title doesn't contain a '/', treat as a wikilog name.
$this->mWikilogName = $title->getText();
$this->mWikilogTitle = Title::makeTitle( $ns, $this->mWikilogName );
$this->mItemName = null;
$this->mItemTitle = null;
$this->mItemTalkTitle = null;
}
}
示例14: getWatchlist
protected function getWatchlist($name, $titleDbkey, $ns = NS_USER_WALL)
{
//TODO: add some caching
$userTitle = Title::newFromText($name, MWNamespace::getSubject($ns));
$dbw = $this->getLocalDB(true);
$res = $dbw->select(array('watchlist'), array('wl_user'), array('wl_title' => array($titleDbkey, $userTitle->getDBkey()), 'wl_namespace' => array(MWNamespace::getSubject($ns), MWNamespace::getTalk($ns)), "((wl_wikia_addedtimestamp > '2012-01-31' and wl_namespace = " . MWNamespace::getSubject($ns) . ") or ( wl_namespace = " . MWNamespace::getTalk($ns) . " ))"), __METHOD__);
$users = array();
while ($row = $dbw->fetchObject($res)) {
$userId = intval($row->wl_user);
$users[$userId] = $userId;
}
return $users;
}
示例15: upgradeWatchlist
function upgradeWatchlist()
{
$chunksize = 100;
list($watchlist, $watchlist_temp) = $this->dbw->tableNamesN('watchlist', 'watchlist_temp');
$this->log('Migrating watchlist table to watchlist_temp...');
$this->dbw->query("CREATE TABLE {$watchlist_temp} (\n -- Key to user_id\n wl_user int(5) unsigned NOT NULL,\n\n -- Key to page_namespace/page_title\n -- Note that users may watch patches which do not exist yet,\n -- or existed in the past but have been deleted.\n wl_namespace int NOT NULL default '0',\n wl_title varchar(255) binary NOT NULL default '',\n\n -- Timestamp when user was last sent a notification e-mail;\n -- cleared when the user visits the page.\n -- FIXME: add proper null support etc\n wl_notificationtimestamp varchar(14) binary NOT NULL default '0',\n\n UNIQUE KEY (wl_user, wl_namespace, wl_title),\n KEY namespace_title (wl_namespace,wl_title)\n\n) TYPE=InnoDB;", __METHOD__);
// Fix encoding for Latin-1 upgrades, add some fields,
// and double article to article+talk pairs
$numwatched = $this->dbw->selectField('watchlist', 'count(*)', '', __METHOD__);
$this->setChunkScale($chunksize, $numwatched * 2, 'watchlist_temp', __METHOD__);
$result = $this->dbr->select('watchlist', array('wl_user', 'wl_namespace', 'wl_title'), '', __METHOD__);
$add = array();
foreach ($result as $row) {
$add[] = array('wl_user' => $row->wl_user, 'wl_namespace' => MWNamespace::getSubject($row->wl_namespace), 'wl_title' => $this->conv($row->wl_title), 'wl_notificationtimestamp' => '0');
$this->addChunk($add);
$add[] = array('wl_user' => $row->wl_user, 'wl_namespace' => MWNamespace::getTalk($row->wl_namespace), 'wl_title' => $this->conv($row->wl_title), 'wl_notificationtimestamp' => '0');
$this->addChunk($add);
}
$this->lastChunk($add);
$this->log('Done converting watchlist.');
$this->cleanupSwaps[] = 'watchlist';
}