本文整理汇总了PHP中Title::getDBkey方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getDBkey方法的具体用法?PHP Title::getDBkey怎么用?PHP Title::getDBkey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getDBkey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newFromTitle
/**
* @param $title Title
* @param $repo ForeignApiRepo
* @return ForeignAPIFile|null
*/
static function newFromTitle( Title $title, $repo ) {
$data = $repo->fetchImageQuery( array(
'titles' => 'File:' . $title->getDBkey(),
'iiprop' => self::getProps(),
'prop' => 'imageinfo',
'iimetadataversion' => MediaHandler::getMetadataVersion()
) );
$info = $repo->getImageInfo( $data );
if ( $info ) {
$lastRedirect = isset( $data['query']['redirects'] )
? count( $data['query']['redirects'] ) - 1
: -1;
if ( $lastRedirect >= 0 ) {
$newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to'] );
$img = new self( $newtitle, $repo, $info, true );
if ( $img ) {
$img->redirectedFrom( $title->getDBkey() );
}
} else {
$img = new self( $title, $repo, $info, true );
}
return $img;
} else {
return null;
}
}
示例2: saveContent
/**
* @return bool|int|null
*/
protected function saveContent()
{
global $wgLogRestrictions;
$dbw = wfGetDB(DB_MASTER);
$log_id = $dbw->nextSequenceValue('logging_log_id_seq');
$this->timestamp = $now = wfTimestampNow();
$data = array('log_id' => $log_id, 'log_type' => $this->type, 'log_action' => $this->action, 'log_timestamp' => $dbw->timestamp($now), 'log_user' => $this->doer->getId(), 'log_user_text' => $this->doer->getName(), 'log_namespace' => $this->target->getNamespace(), 'log_title' => $this->target->getDBkey(), 'log_page' => $this->target->getArticleId(), 'log_comment' => $this->comment, 'log_params' => $this->params);
$dbw->insert('logging', $data, __METHOD__);
$newId = !is_null($log_id) ? $log_id : $dbw->insertId();
# And update recentchanges
if ($this->updateRecentChanges) {
$titleObj = SpecialPage::getTitleFor('Log', $this->type);
RecentChange::notifyLog($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
} elseif ($this->sendToUDP) {
# Don't send private logs to UDP
if (isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] != '*') {
return true;
}
# Notify external application via UDP.
# We send this to IRC but do not want to add it the RC table.
$titleObj = SpecialPage::getTitleFor('Log', $this->type);
$rc = RecentChange::newLogEntry($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
$rc->notifyRC2UDP();
}
return $newId;
}
示例3: invalidateBasePages
/**
* Invalidate the base pages for this title, so that any SubPageList
* there gets refreshed after doing a subpage delete, move or creation.
*
* @since 0.3
*
* @param Title $title
*/
protected static function invalidateBasePages( Title $title ) {
global $egSPLAutorefresh;
if ( !$egSPLAutorefresh ) {
return;
}
$slashPosition = strpos( $title->getDBkey(), '/' );
if ( $slashPosition !== false ) {
$baseTitleText = substr( $title->getDBkey(), 0, $slashPosition );
$titleArray = self::getBaseSubPages(
$baseTitleText,
$title->getNamespace()
);
foreach ( $titleArray as $parentTitle ) {
// No point in invalidating the page itself
if ( $parentTitle->getArticleID() != $title->getArticleID() ) {
$parentTitle->invalidateCache();
}
}
$baseTitle = Title::newFromText( $baseTitleText, $title->getNamespace() );
if ( $baseTitle->getArticleID() != $title->getArticleID() ) {
$baseTitle->invalidateCache();
}
}
}
示例4: __construct
/**
* Creates the category service object
* @param $title Title|string Title object os category name
*/
public function __construct($title)
{
if (!$title instanceof Title) {
$title = Title::makeTitle(NS_CATEGORY, $title);
}
$this->title = $title;
$this->dbkey = $this->title->getDBkey();
}
示例5: isSitemapPage
/**
* Check if the page is sitemap page
* @param Title $title
* @return bool
*/
public function isSitemapPage($title)
{
if (WikiaPageType::isCorporatePage() && $title->getDBkey() == self::SITEMAP_PAGE) {
return true;
}
return false;
}
示例6: getExhibitionItems
public function getExhibitionItems(Title $title)
{
wfProfileIn(__METHOD__);
if (class_exists('CategoryDataService')) {
$cacheKey = $this->getExhibitionItemsCacheKey($title->getText());
$items = $this->wg->memc->get($cacheKey);
if (!is_array($items)) {
$exh = CategoryDataService::getMostVisited($title->getDBkey(), null, self::EXHIBITION_ITEMS_LIMIT);
$ids = array_keys($exh);
$length = count($ids);
$items = array();
for ($i = 0; $i < $length; $i++) {
$pageId = $ids[$i];
$imgRespnse = $this->app->sendRequest('ImageServing', 'index', array('ids' => array($pageId), 'height' => 150, 'width' => 150, 'count' => 1));
$img = $imgRespnse->getVal('result');
if (!empty($img[$pageId])) {
$img = $img[$pageId][0]['url'];
} else {
$img = false;
}
$oTitle = Title::newFromID($pageId);
$items[] = ['img' => $img, 'title' => $oTitle->getText(), 'url' => $oTitle->getFullURL()];
}
$this->wg->memc->set($cacheKey, $items, self::CACHE_TTL_EXHIBITION);
}
wfProfileOut(__METHOD__);
return $items;
}
wfProfileOut(__METHOD__);
return false;
}
示例7: mGetText
/**
* Get the text to display in the language box for specific language and
* level.
*
* @param $name string
* @param $language String: Language code of language to use.
* @param $level String: Level to use.
* @return String: Text for display, in wikitext format.
*/
protected static function mGetText($name, $language, $level)
{
wfProfileIn(__METHOD__);
global $wgBabelMainCategory, $wgBabelCategoryNames;
if ($wgBabelCategoryNames[$level] === false) {
$categoryLevel = self::$title->getFullText();
} else {
$categoryLevel = ':Category:' . self::mReplaceCategoryVariables($wgBabelCategoryNames[$level], $language);
}
if ($wgBabelMainCategory === false) {
$categoryMain = self::$title->getFullText();
} else {
$categoryMain = ':Category:' . self::mReplaceCategoryVariables($wgBabelMainCategory, $language);
}
// Give grep a chance to find the usages:
// babel-0-n, babel-1-n, babel-2-n, babel-3-n, babel-4-n, babel-5-n, babel-N-n
$text = wfMessage("babel-{$level}-n", $categoryLevel, $categoryMain, '', self::$title->getDBkey())->inLanguage($language)->text();
$fallbackLanguage = Language::getFallbackfor($language);
$fallback = wfMessage("babel-{$level}-n", $categoryLevel, $categoryMain, '', self::$title->getDBkey())->inLanguage($fallbackLanguage ? $fallbackLanguage : $language)->text();
// Give grep a chance to find the usages:
// babel-0, babel-1, babel-2, babel-3, babel-4, babel-5, babel-N
if ($text == $fallback) {
$text = wfMessage("babel-{$level}", $categoryLevel, $categoryMain, $name, self::$title->getDBkey())->inLanguage($language)->text();
}
wfProfileOut(__METHOD__);
return $text;
}
示例8: isLocalSource
/**
* Check if the given local page title is a spam regex source.
* @param Title $title
* @return bool
*/
function isLocalSource($title)
{
global $wgDBname;
if ($title->getNamespace() == NS_MEDIAWIKI) {
$sources = array("Spam-blacklist", "Spam-whitelist");
if (in_array($title->getDBkey(), $sources)) {
return true;
}
}
$thisHttp = wfExpandUrl($title->getFullUrl('action=raw'), PROTO_HTTP);
$thisHttpRegex = '/^' . preg_quote($thisHttp, '/') . '(?:&.*)?$/';
foreach ($this->files as $fileName) {
$matches = array();
if (preg_match('/^DB: (\\w*) (.*)$/', $fileName, $matches)) {
if ($wgDBname == $matches[1]) {
if ($matches[2] == $title->getPrefixedDbKey()) {
// Local DB fetch of this page...
return true;
}
}
} elseif (preg_match($thisHttpRegex, $fileName)) {
// Raw view of this page
return true;
}
}
return false;
}
示例9: getMinAndMaxForCat
/**
* Get the lowest and highest timestamp for a category.
*
* @param Title $category
* @return array The lowest and highest timestamp
* @throws MWException If category has no entries.
*/
protected function getMinAndMaxForCat(Title $category)
{
$dbr = wfGetDB(DB_REPLICA);
$res = $dbr->selectRow('categorylinks', ['low' => 'MIN( cl_timestamp )', 'high' => 'MAX( cl_timestamp )'], ['cl_to' => $this->category->getDBkey()], __METHOD__, ['LIMIT' => 1]);
if (!$res) {
throw new MWException('No entries in category');
}
return [wfTimestamp(TS_UNIX, $res->low), wfTimestamp(TS_UNIX, $res->high)];
}
示例10: getTitles
/**
* return the page titles of the subpages in an array
* @return array all titles
* @private
*/
function getTitles() {
wfProfileIn( __METHOD__ );
$dbr = wfGetDB( DB_SLAVE );
$conditions = array();
$options = array();
$order = strtoupper( $this->order );
if( $this->ordermethod == 'title' ) {
$options['ORDER BY'] = 'page_title ' . $order;
} elseif( $this->ordermethod == 'lastedit' ) {
$options['ORDER BY'] = 'page_touched ' . $order;
}
if( $this->parent !== -1) {
$this->ptitle = Title::newFromText( $this->parent );
# note that non-existent pages may nevertheless have valid subpages
# on the other hand, not checking that the page exists can let input through which causes database errors
if ( $this->ptitle instanceof Title && $this->ptitle->exists() && $this->ptitle->userCanRead() ) {
$parent = $this->ptitle->getDBkey();
$this->parent = $parent;
$this->namespace = $this->ptitle->getNsText();
$nsi = $this->ptitle->getNamespace();
} else {
$this->error( wfMsg('spl3_debug','parent') );
return null;
}
} else {
$this->ptitle = $this->title;
$parent = $this->title->getDBkey();
$this->parent = $parent;
$this->namespace = $this->title->getNsText();
$nsi = $this->title->getNamespace();
}
// don't let list cross namespaces
if ( strlen( $nsi ) > 0 ) {
$conditions['page_namespace'] = $nsi;
}
$conditions['page_is_redirect'] = 0;
$conditions[] = 'page_title ' . $dbr->buildLike( $parent . '/', $dbr->anyString() );
$fields = array();
$fields[] = 'page_title';
$fields[] = 'page_namespace';
$res = $dbr->select( 'page', $fields, $conditions, __METHOD__, $options );
$titles = array();
foreach ( $res as $row ) {
$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
if( $title ) {
$titles[] = $title;
}
}
wfProfileOut( __METHOD__ );
return $titles;
}
示例11: isFuzzy
/**
* Check if a title is marked as fuzzy.
* @return bool If title is marked fuzzy.
*/
public function isFuzzy()
{
$dbr = wfGetDB(DB_SLAVE);
$tables = array('page', 'revtag');
$field = 'rt_type';
$conds = array('page_namespace' => $this->title->getNamespace(), 'page_title' => $this->title->getDBkey(), 'rt_type' => RevTag::getType('fuzzy'), 'page_id=rt_page', 'page_latest=rt_revision');
$res = $dbr->selectField($tables, $field, $conds, __METHOD__);
return $res !== false;
}
示例12: compose
/**
* Compose a mail to a given user and either queue it for sending, or send it now,
* depending on settings.
*
* Call sendMails() to send any mails that were queued.
* @param $user User
*/
private function compose(\User $user)
{
if ($this->getEmailExtensionController() !== false) {
$this->sendUsingEmailExtension($user);
} else {
\Wikia\Logger\WikiaLogger::instance()->notice('Sending via UserMailer', ['page' => $this->title->getDBkey(), 'summary' => $this->summary, 'action' => $this->action, 'subject' => $this->subject]);
$this->sendUsingUserMailer($user);
}
wfRunHooks('NotifyOnPageChangeComplete', [$this->title, $this->timestamp, &$user]);
}
示例13: doCategoryQuery
function doCategoryQuery()
{
$dbr = wfGetDB(DB_SLAVE, 'category');
$this->nextPage = array('page' => null, 'subcat' => null, 'file' => null);
$this->flip = array('page' => false, 'subcat' => false, 'file' => false);
foreach (array('page', 'subcat', 'file') as $type) {
# Get the sortkeys for start/end, if applicable. Note that if
# the collation in the database differs from the one
# set in $wgCategoryCollation, pagination might go totally haywire.
$extraConds = array('cl_type' => $type);
if ($this->from[$type] !== null) {
$extraConds[] = 'cl_sortkey >= ' . $dbr->addQuotes($this->collation->getSortKey($this->from[$type]));
} elseif ($this->until[$type] !== null) {
$extraConds[] = 'cl_sortkey < ' . $dbr->addQuotes($this->collation->getSortKey($this->until[$type]));
$this->flip[$type] = true;
}
/* Wikia change begin - @author: TomekO */
/* Changed by MoLi (1.19 ugrade) */
wfRunHooks('CategoryViewer::beforeCategoryData', array(&$extraConds));
/* Wikia change end */
$res = $dbr->select(array('page', 'categorylinks', 'category'), array('page_id', 'page_title', 'page_namespace', 'page_len', 'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title', 'cat_subcats', 'cat_pages', 'cat_files', 'cl_sortkey_prefix', 'cl_collation'), array_merge(array('cl_to' => $this->title->getDBkey()), $extraConds), __METHOD__, array('USE INDEX' => array('categorylinks' => 'cl_sortkey'), 'LIMIT' => is_integer($this->limit) ? $this->limit + 1 : null, 'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey'), array('categorylinks' => array('INNER JOIN', 'cl_from = page_id'), 'category' => array('LEFT JOIN', 'cat_title = page_title AND page_namespace = ' . NS_CATEGORY)));
$count = 0;
foreach ($res as $row) {
$title = Title::newFromRow($row);
if ($row->cl_collation === '') {
// Hack to make sure that while updating from 1.16 schema
// and db is inconsistent, that the sky doesn't fall.
// See r83544. Could perhaps be removed in a couple decades...
$humanSortkey = $row->cl_sortkey;
} else {
$humanSortkey = $title->getCategorySortkey($row->cl_sortkey_prefix);
}
if (++$count > $this->limit && is_integer($this->limit)) {
# We've reached the one extra which shows that there
# are additional pages to be had. Stop here...
$this->nextPage[$type] = $humanSortkey;
break;
}
if ($title->getNamespace() == NS_CATEGORY) {
$cat = Category::newFromRow($row, $title);
$this->addSubcategoryObject($cat, $humanSortkey, $row->page_len);
} elseif ($title->getNamespace() == NS_FILE) {
$this->addImage($title, $humanSortkey, $row->page_len, $row->page_is_redirect);
} else {
# <Wikia>
if (wfRunHooks("CategoryViewer::addPage", array(&$this, &$title, &$row, $humanSortkey))) {
$this->addPage($title, $humanSortkey, $row->page_len, $row->page_is_redirect);
}
# </Wikia>
}
}
}
}
示例14: load
/**
* Loads a file object from the filearchive table
* @return true on success or null
*/
public function load()
{
if ($this->dataLoaded) {
return true;
}
$conds = array();
if ($this->id > 0) {
$conds['fa_id'] = $this->id;
}
if ($this->key) {
$conds['fa_storage_group'] = $this->group;
$conds['fa_storage_key'] = $this->key;
}
if ($this->title) {
$conds['fa_name'] = $this->title->getDBkey();
}
if (!count($conds)) {
throw new MWException("No specific information for retrieving archived file");
}
if (!$this->title || $this->title->getNamespace() == NS_FILE) {
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select('filearchive', array('fa_id', 'fa_name', 'fa_archive_name', 'fa_storage_key', 'fa_storage_group', 'fa_size', 'fa_bits', 'fa_width', 'fa_height', 'fa_metadata', 'fa_media_type', 'fa_major_mime', 'fa_minor_mime', 'fa_description', 'fa_user', 'fa_user_text', 'fa_timestamp', 'fa_deleted'), $conds, __METHOD__, array('ORDER BY' => 'fa_timestamp DESC'));
if ($res == false || $dbr->numRows($res) == 0) {
// this revision does not exist?
return;
}
$ret = $dbr->resultObject($res);
$row = $ret->fetchObject();
// initialize fields for filestore image object
$this->id = intval($row->fa_id);
$this->name = $row->fa_name;
$this->archive_name = $row->fa_archive_name;
$this->group = $row->fa_storage_group;
$this->key = $row->fa_storage_key;
$this->size = $row->fa_size;
$this->bits = $row->fa_bits;
$this->width = $row->fa_width;
$this->height = $row->fa_height;
$this->metadata = $row->fa_metadata;
$this->mime = "{$row->fa_major_mime}/{$row->fa_minor_mime}";
$this->media_type = $row->fa_media_type;
$this->description = $row->fa_description;
$this->user = $row->fa_user;
$this->user_text = $row->fa_user_text;
$this->timestamp = $row->fa_timestamp;
$this->deleted = $row->fa_deleted;
} else {
throw new MWException('This title does not correspond to an image page.');
}
$this->dataLoaded = true;
$this->exists = true;
return true;
}
示例15: updateWatchlistTimestamp
/**
* @param User $editor The editor that triggered the update. Their notification
* timestamp will not be updated(they have already seen it)
* @param Title $title The title to update timestamps for
* @param string $timestamp Set the update timestamp to this value
* @return int[]
*/
public static function updateWatchlistTimestamp(User $editor, Title $title, $timestamp)
{
global $wgEnotifWatchlist, $wgShowUpdatedMarker;
if (!$wgEnotifWatchlist && !$wgShowUpdatedMarker) {
return array();
}
$dbw = wfGetDB(DB_MASTER);
$res = $dbw->select(array('watchlist'), array('wl_user'), array('wl_user != ' . intval($editor->getID()), 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey(), 'wl_notificationtimestamp IS NULL'), __METHOD__);
$watchers = array();
foreach ($res as $row) {
$watchers[] = intval($row->wl_user);
}
if ($watchers) {
// Update wl_notificationtimestamp for all watching users except the editor
$fname = __METHOD__;
$dbw->onTransactionIdle(function () use($dbw, $timestamp, $watchers, $title, $fname) {
$dbw->update('watchlist', array('wl_notificationtimestamp' => $dbw->timestamp($timestamp)), array('wl_user' => $watchers, 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey()), $fname);
});
}
return $watchers;
}