本文整理汇总了PHP中Title::getArticleID方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getArticleID方法的具体用法?PHP Title::getArticleID怎么用?PHP Title::getArticleID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getArticleID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Title $Title
* @param User $User
* @param int $articleId
* @param string $text
*/
public function __construct($Title, $User, $articleId = 0, $text = '')
{
global $wgEnableBlogArticles;
/**
* initialization
*/
$this->mPageNs = $Title->getNamespace();
if (empty($articleId)) {
$this->mPageId = $Title->getArticleID();
if (empty($this->mPageId)) {
$Title->getArticleID(Title::GAID_FOR_UPDATE);
}
} else {
$this->setPageId($articleId);
}
if (is_object($User)) {
$this->mUserId = intval($User->getID());
} else {
$this->mUserId = intval($User);
}
$this->mIsContent = $Title->isContentPage() && ($wgEnableBlogArticles && !in_array($this->mPageNs, array(NS_BLOG_ARTICLE, NS_BLOG_ARTICLE_TALK, NS_BLOG_LISTING, NS_BLOG_LISTING_TALK)));
$this->mDate = date('Y-m-d');
if ($text) {
$this->mText = preg_replace('/\\[\\[[^\\:\\]]+\\:[^\\]]*\\]\\]/', '', $text);
}
}
示例2: saveContent
/**
* @return int log_id of the inserted log entry
*/
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, $this->getRcCommentIRC());
} elseif ($this->sendToUDP) {
# Don't send private logs to UDP
if (isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] != '*') {
return $newId;
}
# 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, $this->getRcCommentIRC());
$rc->notifyRC2UDP();
}
return $newId;
}
示例3: getQueryConditions
/**
* Returns a list of query conditions that should be run against the revision table
*
* @return array List of conditions
*/
protected function getQueryConditions()
{
$conds = array();
if ($this->title) {
$conds['rev_page'] = $this->title->getArticleID();
}
if ($this->offset) {
$dbr = wfGetDB(DB_SLAVE, self::DB_REVISIONS_TABLE);
$conds[] = 'rev_timestamp <= ' . $dbr->addQuotes($this->offset);
}
return $conds;
}
示例4: assertValidPageAddedToCategory
/**
* @throws \Email\Check
*/
protected function assertValidPageAddedToCategory()
{
if (!$this->pageAddedToCategory instanceof \Title) {
throw new Check("Invalid value passed for pageAddedToCategory (param: pageTitle)");
}
if (!$this->pageAddedToCategory->exists()) {
// Check master DB just in case the page was just created and it
// hasn't been replicated to the slave yet
if ($this->pageAddedToCategory->getArticleID(\Title::GAID_FOR_UPDATE) == 0) {
throw new Check("pageAddedToCategory doesn't exist.");
}
}
}
示例5: isItemFixed
/**
* Checks if a given article has been fixed by a user
* inside a productivity loop.
* @param Title $title
* @return bool
*/
public function isItemFixed(Title $title)
{
if ($title->getArticleID() !== 0) {
return $this->removeFixedItem(ucfirst(self::INSIGHT_TYPE), $title);
}
return false;
}
示例6: getArticleID
/**
* Get MediaWiki's ID for this value or 0 if not available.
*
* @return integer
*/
public function getArticleID()
{
if ($this->m_id === false) {
$this->m_id = !is_null($this->getTitle()) ? $this->m_title->getArticleID() : 0;
}
return $this->m_id;
}
示例7: classifyTemplate
/**
* Performs all actions required to log all information required to have a given template
* classified and have them stored in an accessible way.
* @param string $type A type that you want to classify the template as.
* @param bool $value Value of the classification. If false, the type will be set to unclassified.
* @param int $actor Specifies if the recognition was made by a machine or a human
* @return bool
* @throws MWException
*/
public function classifyTemplate($type, $value, $actor = self::CLASSIFICATION_ACTOR_HUMAN)
{
/**
* Check if the fetched $type is valid
* and if the user is permitted to perform templatedraft related actions.
*/
$prop = self::getClassificationProp($type);
if (!$prop || !$this->title->userCan('templatedraft')) {
return false;
}
/**
* SET THE PRIMARY PAGE PROPERTY
*
* If the $value equals false it means somebody has just made a negative recognition
* (e.g. the template is NOT an infobox). In this case, we set the primary property to
* unclassified to mark that the template has been reviewed, but we do not have a definite
* information on its type.
*/
if (!$value) {
$type = self::TEMPLATE_UNCLASSIFIED;
}
Wikia::setProps($this->title->getArticleID(), [self::TEMPLATE_CLASSIFICATION_MAIN_PROP => $type]);
/**
* SET THE SECONDARY PAGE PROPERTY
*
* This property is used to log more detailed information on the performed action.
*/
$data = ['value' => (bool) $value, 'actor' => $actor, 'actor-id' => $this->wg->User->getId(), 'timestamp' => wfTimestamp()];
Wikia::setProps($this->title->getArticleID(), [$prop => json_encode($data)]);
/**
* Since Wikia::setProps fails silently we can return true at this point.
*/
return true;
}
示例8: getProps
/**
* getProps -- get props for comment article
*
*/
public function getProps()
{
if ((!$this->mProps || !is_array($this->mProps)) && class_exists('BlogArticle')) {
$this->mProps = BlogArticle::getProps($this->mTitle->getArticleID());
}
return $this->mProps;
}
示例9: doCascadeProtectionUpdates
/**
* Updates cascading protections
*
* @param $parserOutput ParserOutput object for the current version
*/
public function doCascadeProtectionUpdates(ParserOutput $parserOutput)
{
if (wfReadOnly() || !$this->mTitle->areRestrictionsCascading()) {
return;
}
// templatelinks table may have become out of sync,
// especially if using variable-based transclusions.
// For paranoia, check if things have changed and if
// so apply updates to the database. This will ensure
// that cascaded protections apply as soon as the changes
// are visible.
# Get templates from templatelinks
$id = $this->mTitle->getArticleID();
$tlTemplates = array();
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select(array('templatelinks'), array('tl_namespace', 'tl_title'), array('tl_from' => $id), __METHOD__);
foreach ($res as $row) {
$tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true;
}
# Get templates from parser output.
$poTemplates = array();
foreach ($parserOutput->getTemplates() as $ns => $templates) {
foreach ($templates as $dbk => $id) {
$poTemplates["{$ns}:{$dbk}"] = true;
}
}
# Get the diff
$templates_diff = array_diff_key($poTemplates, $tlTemplates);
if (count($templates_diff) > 0) {
# Whee, link updates time.
# Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output.
$u = new LinksUpdate($this->mTitle, $parserOutput, false);
$u->doUpdate();
}
}
示例10: getPageCoordinates
/**
* Returns primary coordinates of the given page, if any
* @param Title $title
* @return Coord|false: Coordinates or false
*/
public static function getPageCoordinates(Title $title)
{
$coords = self::getAllCoordinates($title->getArticleID(), array('gt_primary' => 1));
if ($coords) {
return $coords[0];
}
return false;
}
示例11: isItemFixed
/**
* Checks if a given article has been fixed by a user
* inside a productivity loop.
* @param Title $title
* @return bool
*/
public function isItemFixed(Title $title)
{
$dbr = wfGetDB(DB_MASTER);
$row = $dbr->selectRow('pagelinks', '*', ['pl_from' => $title->getArticleID()]);
if ($row) {
return $this->removeFixedItem(ucfirst(self::INSIGHT_TYPE), $title);
}
return false;
}
示例12: wfGetDB
function __construct(SpecialMergeHistory $form, $conds, Title $source, Title $dest)
{
$this->mForm = $form;
$this->mConds = $conds;
$this->title = $source;
$this->articleID = $source->getArticleID();
$dbr = wfGetDB(DB_REPLICA);
$maxtimestamp = $dbr->selectField('revision', 'MIN(rev_timestamp)', ['rev_page' => $dest->getArticleID()], __METHOD__);
$this->maxTimestamp = $maxtimestamp;
parent::__construct($form->getContext());
}
示例13: testClearCache
/**
* Test that getting all properties clears the single properties
* that have been cached by getting a property, saving a new value for
* the property, getting all properties (which clears the cached single
* properties), then getting the property again. The new value for the
* property rather than the cached value of the property should be
* returned.
*/
public function testClearCache()
{
$pageProps = PageProps::getInstance();
$page1ID = $this->title1->getArticleID();
$pageProps->getProperty($this->title1, "property1");
$new_value = "another value";
$this->setProperty($page1ID, "property1", $new_value);
$pageProps->getProperties($this->title1);
$result = $pageProps->getProperty($this->title1, "property1");
$this->assertArrayHasKey($page1ID, $result, "Found property");
$this->assertEquals($result[$page1ID], "another value", "Clear cache");
}
示例14: doUpdates
/**
* Driver function that handles updating assessment data in database
* @param Title $titleObj Title object of the subject page
* @param array $assessmentData Data for all assessments compiled
*/
public static function doUpdates($titleObj, $assessmentData)
{
global $wgUpdateRowsPerQuery;
$factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
$ticket = $factory->getEmptyTransactionTicket(__METHOD__);
$pageId = $titleObj->getArticleID();
$revisionId = $titleObj->getLatestRevID();
// Compile a list of projects to find out which ones to be deleted afterwards
$projects = array();
foreach ($assessmentData as $parserData) {
// For each project, get the corresponding ID from page_assessments_projects table
$projectId = self::getProjectId($parserData[0]);
if ($projectId === false) {
$projectId = self::insertProject($parserData[0]);
}
$projects[$parserData[0]] = $projectId;
}
$projectsInDb = self::getAllProjects($pageId, self::READ_LATEST);
$toInsert = array_diff($projects, $projectsInDb);
$toDelete = array_diff($projectsInDb, $projects);
$toUpdate = array_intersect($projects, $projectsInDb);
$i = 0;
// Add and update records to the database
foreach ($assessmentData as $parserData) {
$projectId = $projects[$parserData[0]];
if ($projectId) {
$class = $parserData[1];
$importance = $parserData[2];
$values = array('pa_page_id' => $pageId, 'pa_project_id' => $projectId, 'pa_class' => $class, 'pa_importance' => $importance, 'pa_page_revision' => $revisionId);
if (in_array($projectId, $toInsert)) {
self::insertRecord($values);
} elseif (in_array($projectId, $toUpdate)) {
self::updateRecord($values);
}
// Check for database lag if there's a huge number of assessments
if ($i > 0 && $i % $wgUpdateRowsPerQuery == 0) {
$factory->commitAndWaitForReplication(__METHOD__, $ticket);
}
$i++;
}
}
// Delete records from the database
foreach ($toDelete as $project) {
$values = array('pa_page_id' => $pageId, 'pa_project_id' => $project);
self::deleteRecord($values);
// Check for database lag if there's a huge number of deleted assessments
if ($i > 0 && $i % $wgUpdateRowsPerQuery == 0) {
$factory->commitAndWaitForReplication(__METHOD__, $ticket);
}
$i++;
}
return;
}
示例15: newFromTarget
public static function newFromTarget(Title $target)
{
$pageid = $target->getArticleID();
$dbr = wfGetDB(DB_SLAVE);
$res = $dbr->select('indexes', array('in_namespace', 'in_title'), array('in_from' => $pageid), __METHOD__);
if (!$res->numRows()) {
return null;
}
$ind = new IndexFunction();
$row = $res->fetchRow();
$ind->mFrom = Title::makeTitle($row->in_namespace, $row->in_title);
return $ind;
}