本文整理汇总了PHP中Title::getArticleId方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getArticleId方法的具体用法?PHP Title::getArticleId怎么用?PHP Title::getArticleId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getArticleId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: getContext
public function getContext(Title $title, $skinName)
{
$wrapper = new GlobalStateWrapper(['wgTitle' => $title]);
$wg = F::app()->wg;
return $wrapper->wrap(function () use($title, $wg, $skinName) {
$wikiFactoryHub = WikiFactoryHub::getInstance();
$hubService = new HubService();
$adPageTypeService = new AdEngine2PageTypeService();
$wikiaPageType = new WikiaPageType();
$sevenOneMediaCombinedUrl = null;
if (!empty($wg->AdDriverUseSevenOneMedia)) {
// TODO: implicitly gets the skin from the context!
$sevenOneMediaCombinedUrl = ResourceLoader::makeCustomURL($wg->Out, ['wikia.ext.adengine.sevenonemedia'], 'scripts');
}
$monetizationServiceAds = null;
if (!empty($wg->AdDriverUseMonetizationService) && !empty($wg->EnableMonetizationModuleExt)) {
$monetizationServiceAds = F::app()->sendRequest('MonetizationModule', 'index')->getData()['data'];
}
$langCode = $title->getPageLanguage()->getCode();
return ['opts' => $this->filterOutEmptyItems(['adsInContent' => $wg->EnableAdsInContent, 'delayBtf' => $wg->AdDriverDelayBelowTheFold, 'enableAdsInMaps' => $wg->AdDriverEnableAdsInMaps, 'pageType' => $adPageTypeService->getPageType(), 'paidAssetDropConfig' => $wg->PaidAssetDropConfig, 'showAds' => $adPageTypeService->areAdsShowableOnPage(), 'trackSlotState' => $wg->AdDriverTrackState, 'usePostScribe' => $wg->Request->getBool('usepostscribe', false)]), 'targeting' => $this->filterOutEmptyItems(['enablePageCategories' => array_search($langCode, $wg->AdPageLevelCategoryLangs) !== false, 'pageArticleId' => $title->getArticleId(), 'pageIsArticle' => !!$title->getArticleId(), 'pageIsHub' => $wikiaPageType->isWikiaHub(), 'pageName' => $title->getPrefixedDBKey(), 'pageType' => $wikiaPageType->getPageType(), 'sevenOneMediaSub2Site' => $wg->AdDriverSevenOneMediaOverrideSub2Site, 'skin' => $skinName, 'wikiCategory' => $wikiFactoryHub->getCategoryShort($wg->CityId), 'wikiCustomKeyValues' => $wg->DartCustomKeyValues, 'wikiDbName' => $wg->DBname, 'wikiDirectedAtChildren' => $wg->WikiDirectedAtChildrenByFounder || $wg->WikiDirectedAtChildrenByStaff, 'wikiIsCorporate' => $wikiaPageType->isCorporatePage(), 'wikiIsTop1000' => $wg->AdDriverWikiIsTop1000, 'wikiLanguage' => $langCode, 'wikiVertical' => $hubService->getCategoryInfoForCity($wg->CityId)->cat_name]), 'providers' => $this->filterOutEmptyItems(['monetizationService' => $wg->AdDriverUseMonetizationService, 'monetizationServiceAds' => $monetizationServiceAds, 'sevenOneMedia' => $wg->AdDriverUseSevenOneMedia, 'sevenOneMediaCombinedUrl' => $sevenOneMediaCombinedUrl, 'taboola' => $wg->AdDriverUseTaboola]), 'slots' => $this->filterOutEmptyItems(['exitstitial' => $wg->EnableOutboundScreenExt, 'exitstitialRedirectDelay' => $wg->OutboundScreenRedirectDelay, 'invisibleHighImpact' => $wg->AdDriverEnableInvisibleHighImpactSlot]), 'forcedProvider' => $wg->AdDriverForcedProvider];
});
}
示例3: userCanVote
public function userCanVote()
{
$pageId = $this->mTitle->getArticleId();
$oFauxRequest = new FauxRequest(['action' => 'query', 'list' => 'wkvoteart', 'wkpage' => $pageId, 'wkuservote' => 1]);
$oApi = new ApiMain($oFauxRequest);
$oApi->execute();
$aResult = $oApi->GetResultData();
if (isset($aResult['query']['wkvoteart'][$pageId]['uservote'])) {
$result = false;
} else {
$result = true;
}
return $result;
}
示例4: inCat
/**
* check if $page belongs to $category
* @param $page Title current page
* @param $category String category to check (not a title object!)
* @param $parser Parser
* @return boolean If $page is a member of $category
*/
private static function inCat( Title $page, $category, Parser $parser ) {
if ( $category === '' ) return false;
$catTitle = Title::makeTitleSafe(
NS_CATEGORY,
$category
);
if ( !$catTitle ) return false;
$catDBkey = $catTitle->getDBkey();
if ( !isset( $parser->pageInCat_cache ) ) {
$parser->pageInCat_cache = array();
} else {
if ( isset( $parser->pageInCat_cache[$catDBkey] ) ) {
# been there done that, return cached value
return $parser->pageInCat_cache[$catDBkey];
} elseif( isset( $parser->pageInCat_onlyCache ) && $parser->pageInCat_onlyCache ) {
# All categories have been preloaded into cache, so
# we must have hit a cat not in page.
# Mark it so can be checked for correctness later.
$parser->PageInCat_cache[$catDBkey] = false;
return false;
}
}
$pageId = $page->getArticleId();
if ( !$pageId ) {
// page hasn't yet been saved (preview)
// add to the cache list so the other hook
// will warn about incorrect value.
// Important to do this after checking cache
// in case categories were pre-loaded during preview.
$parser->pageInCat_cache[$catDBkey] = false;
return false;
}
if ( !$parser->incrementExpensiveFunctionCount() ) {
# expensive function limit reached.
return false;
}
if ( self::inCatCheckDb( $pageId, $catDBkey ) ) {
$parser->pageInCat_cache[$catDBkey] = true;
return true;
} /* else if false */
$parser->pageInCat_cache[$catDBkey] = false;
return false;
}
示例5: storeBackLinkText
static function storeBackLinkText($skin, Title $target, array $options, &$text, array &$attribs, &$ret)
{
wfProfileIn(__METHOD__);
global $wgArticle;
$targetArticleId = $target->getArticleId();
if (!is_int($targetArticleId) || $wgArticle === null || $targetArticleId === 0) {
wfProfileOut(__METHOD__);
return true;
}
$sourceArticleId = $wgArticle->getId();
self::$sourceArticleIds = array_unique(self::$sourceArticleIds + array($sourceArticleId));
$backlinkRowSignature = sprintf("(%s,%s,'%s',", $sourceArticleId, $targetArticleId, mysql_real_escape_string(substr($text, 0, 255)));
self::$backlinkRows[$backlinkRowSignature] = isset(self::$backlinkRows[$backlinkRowSignature]) ? self::$backlinkRows[$backlinkRowSignature] + 1 : 1;
wfProfileOut(__METHOD__);
return true;
}
示例6: getLineHtml
/**
* Gets the HTML fragment for a watched page.
*
* @param Title $title The title of the watched page
* @param int $ts When the page was last touched
* @param string $thumb An HTML fragment for the page's thumbnaiL
* @return string
*/
public static function getLineHtml(Title $title, $ts, $thumb)
{
$titleText = $title->getPrefixedText();
if ($ts) {
$ts = new MWTimestamp($ts);
$lastModified = wfMessage('mobile-frontend-watchlist-modified', $ts->getHumanTimestamp())->text();
$className = 'title';
} else {
$className = 'title new';
$lastModified = '';
}
$html = Html::openElement('li', array('class' => 'page-summary', 'title' => $titleText, 'data-id' => $title->getArticleId())) . Html::openElement('a', array('href' => $title->getLocalUrl(), 'class' => $className));
$html .= $thumb;
$html .= Html::element('h3', array(), $titleText) . Html::element('div', array('class' => 'info'), $lastModified) . Html::closeElement('a') . Html::closeElement('li');
return $html;
}
开发者ID:GoProjectOwner,项目名称:mediawiki-extensions-MobileFrontend,代码行数:24,代码来源:SpecialMobileEditWatchlist.php
示例7: onArticleFromTitle
/**
* @param Title $title
* @param WikiPage $article
* @return bool
*/
public function onArticleFromTitle(Title &$title, &$article)
{
if ($title->exists() && $title->getNamespace() != NS_FILE && $title->getNamespace() != NS_CATEGORY) {
$key = $this->generateCacheKey($title->getArticleId());
$this->switches = $this->app->wg->memc->get($key);
if (empty($this->switches)) {
$article = F::build('Article', array($title));
$this->switches = array();
foreach ($this->magicWords as $wordID) {
$magicWord = MagicWord::get($wordID);
$this->switches[$wordID] = 0 < $magicWord->match($article->getRawText());
}
$this->app->wg->memc->set($key, $this->switches, self::CACHE_DURATION);
}
$this->process();
}
return true;
}
示例8: onArticleFromTitle
/**
* @param Title $title
* @param WikiPage $article
* @return bool
*/
public static function onArticleFromTitle(Title &$title, &$article)
{
global $wgLandingPagesAsContentMagicWords;
$app = F::app();
if ($title->exists() && $title->getNamespace() != NS_FILE && $title->getNamespace() != NS_CATEGORY) {
$key = self::generateCacheKey($title->getArticleId());
self::$switches = $app->wg->memc->get($key);
if (empty(self::$switches)) {
$article = new Article($title);
self::$switches = array();
$magicWords = array_keys($wgLandingPagesAsContentMagicWords);
foreach ($magicWords as $wordID) {
$magicWord = MagicWord::get($wordID);
self::$switches[$wordID] = 0 < $magicWord->match($article->getRawText());
}
$app->wg->memc->set($key, self::$switches, self::CACHE_DURATION);
}
self::process();
}
return true;
}
示例9: pageCountInfo
/**
* Return the total number of edits and number of unique editors
* on a given page. If page does not exist, returns false.
*
* @param Title $title
* @return array
* @private
*/
function pageCountInfo($title)
{
$id = $title->getArticleId();
if ($id == 0) {
return false;
}
$dbr =& wfGetDB(DB_SLAVE);
$rev_clause = array('rev_page' => $id);
$edits = $dbr->selectField('revision', 'COUNT(rev_page)', $rev_clause, __METHOD__, $this->getSelectOptions());
$authors = $dbr->selectField('revision', 'COUNT(DISTINCT rev_user_text)', $rev_clause, __METHOD__, $this->getSelectOptions());
return array('edits' => $edits, 'authors' => $authors);
}
示例10: mergePage
/**
* Merge page histories
*
* @param integer $id The page_id
* @param Title $newTitle The new title
*/
private function mergePage($id, Title $newTitle)
{
$destId = $newTitle->getArticleId();
$this->db->begin(__METHOD__);
$this->db->update('revision', array('rev_page' => $destId), array('rev_page' => $id), __METHOD__);
$this->db->delete('page', array('page_id' => $id), __METHOD__);
// @fixme Need WikiPage::doDeleteUpdates() or similar to avoid orphan
// rows in the links tables.
$this->db->commit(__METHOD__);
return true;
}
示例11: insertTrace
/**
* Inserts a trace of the user action into the database
* @global string $wgDBtype
* @param Title $oTitle
* @param User $oUser
* @param Request $oRequest
* @return boolean
*/
public function insertTrace($oTitle, $oUser, $oRequest)
{
if (wfReadOnly()) {
return true;
}
if ($oUser->getId() == 0) {
return true;
}
// Anonymous user
$sPageTitle = $oTitle->getText();
if ($sPageTitle == '-') {
return true;
}
// otherwise strange '-' with page_id 0 are logged
$iPageId = $oTitle->getArticleId();
$iPageNamespaceId = $oTitle->getNamespace();
$iCurrentTimestamp = time();
$vLastLoggedPageHash = $oRequest->getSessionData($this->mExtensionKey . '::lastLoggedPageHash');
$vLastLoggedTime = $oRequest->getSessionData($this->mExtensionKey . '::lastLoggedTime');
$sCurrentPageHash = md5($iPageId . $iPageNamespaceId . $sPageTitle);
//this combination should be pretty unique, even with specialpages.
$iMaxIdleTime = BsConfig::get('MW::WhoIsOnline::MaxIdleTime');
$iInterval = BsConfig::get('MW::WhoIsOnline::Interval');
if ($vLastLoggedPageHash == $sCurrentPageHash && $vLastLoggedTime + $iMaxIdleTime + $iInterval + $iMaxIdleTime * 0.1 > $iCurrentTimestamp) {
return true;
}
//log action
wfProfileIn('BS::' . __METHOD__);
$oRequest->setSessionData($this->mExtensionKey . '::lastLoggedPageHash', $sCurrentPageHash);
$oRequest->setSessionData($this->mExtensionKey . '::lastLoggedTime', $iCurrentTimestamp);
$iRemoveEntriesAfter = 2592000;
$dbw = wfGetDB(DB_MASTER);
$dbw->delete('bs_whoisonline', array('wo_timestamp < ' . ($iCurrentTimestamp - $iRemoveEntriesAfter)));
$aNewRow = array();
$aNewRow['wo_page_id'] = $oTitle->getArticleId();
$aNewRow['wo_page_namespace'] = $oTitle->getNamespace();
$aNewRow['wo_page_title'] = $sPageTitle;
$aNewRow['wo_user_id'] = $oUser->getId();
$aNewRow['wo_user_name'] = $oUser->getName();
$aNewRow['wo_user_real_name'] = $oUser->getRealName();
$aNewRow['wo_timestamp'] = $iCurrentTimestamp;
$aNewRow['wo_action'] = $oRequest->getVal('action', 'view');
global $wgDBtype;
if ($wgDBtype == 'oracle') {
$aNewRow['wo_id'] = 0;
}
$dbw->insert('bs_whoisonline', $aNewRow);
wfProfileOut('BS::' . __METHOD__);
return true;
}
示例12: newFromTitle
/**
* Return instance of this class for given title from RelatedVideos namespace
*/
public static function newFromTitle(Title $title)
{
$id = $title->getArticleId();
return new self($id, $title);
}
示例13: undeleteComplete
/**
* Hook
*
* @param Title $oTitle -- instance of Title class
* @param User $User -- current user
* @param string $reason -- undeleting reason
*
* @static
* @access public
*
* @return true -- because it's hook
*/
public static function undeleteComplete($oTitle, $oUser, $reason)
{
wfProfileIn(__METHOD__);
if ($oTitle instanceof Title) {
if (in_array($oTitle->getNamespace(), array(NS_BLOG_ARTICLE, NS_BLOG_ARTICLE_TALK))) {
$aProps = $oTitle->aProps;
$pageId = $oTitle->getArticleId();
if (!empty($aProps)) {
BlogArticle::setProps($pageId, $aProps);
}
}
}
wfProfileOut(__METHOD__);
return true;
}
示例14: getAndCalcPageRatings
/**
* Gets the summary data for all ratings on the specified page.
*
* @since 0.1
*
* @param Title $page
*
* @return array
*/
protected static function getAndCalcPageRatings( Title $page ) {
$tags = array();
foreach ( self::getTagNames() as $tagName => $tagId ) {
$tags[$tagId] = array( 'count' => 0, 'total' => 0, 'name' => $tagName );
}
$dbr = wfGetDb( DB_SLAVE );
$votes = $dbr->select(
'votes',
array(
'vote_prop_id',
'vote_value'
),
array(
'vote_page_id' => $page->getArticleId()
)
);
foreach( $votes as $vote ) {
$tags[$vote->vote_prop_id]['count']++;
$tags[$vote->vote_prop_id]['total'] += $vote->vote_value;
}
foreach ( $tags as &$tag ) {
$tag['avarage'] = $tag['count'] > 0 ? $tag['total'] / $tag['count'] : 0;
}
return $tags;
}
示例15: formatRevisionRow
private function formatRevisionRow($row, $earliestLiveTime, $remaining)
{
$rev = Revision::newFromArchiveRow($row, array('page' => $this->mTargetObj->getArticleId()));
$stxt = '';
$ts = wfTimestamp(TS_MW, $row->ar_timestamp);
// Build checkboxen...
if ($this->mAllowed) {
if ($this->mInvert) {
if (in_array($ts, $this->mTargetTimestamp)) {
$checkBox = Xml::check("ts{$ts}");
} else {
$checkBox = Xml::check("ts{$ts}", true);
}
} else {
$checkBox = Xml::check("ts{$ts}");
}
} else {
$checkBox = '';
}
$user = $this->getUser();
// Build page & diff links...
if ($this->mCanView) {
$titleObj = $this->getTitle();
# Last link
if (!$rev->userCan(Revision::DELETED_TEXT, $this->getUser())) {
$pageLink = htmlspecialchars($this->getLanguage()->userTimeAndDate($ts, $user));
$last = $this->msg('diff')->escaped();
} elseif ($remaining > 0 || $earliestLiveTime && $ts > $earliestLiveTime) {
$pageLink = $this->getPageLink($rev, $titleObj, $ts);
$last = Linker::linkKnown($titleObj, $this->msg('diff')->escaped(), array(), array('target' => $this->mTargetObj->getPrefixedText(), 'timestamp' => $ts, 'diff' => 'prev'));
} else {
$pageLink = $this->getPageLink($rev, $titleObj, $ts);
$last = $this->msg('diff')->escaped();
}
} else {
$pageLink = htmlspecialchars($this->getLanguage()->userTimeAndDate($ts, $user));
$last = $this->msg('diff')->escaped();
}
// User links
$userLink = Linker::revUserTools($rev);
// Revision text size
$size = $row->ar_len;
if (!is_null($size)) {
$stxt = Linker::formatRevisionSize($size);
}
// Edit summary
$comment = Linker::revComment($rev);
// Revision delete links
$revdlink = Linker::getRevDeleteLink($user, $rev, $this->mTargetObj);
return "<li>{$checkBox} {$revdlink} ({$last}) {$pageLink} . . {$userLink} {$stxt} {$comment}</li>";
}