本文整理汇总了PHP中Page::getTitle方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::getTitle方法的具体用法?PHP Page::getTitle怎么用?PHP Page::getTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::getTitle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* @since 2.0
*
* @return boolean
*/
public function process()
{
// Avoid having "noarticletext" info being generated for predefined
// properties as we are going to display an introductory text
if ($this->article->getTitle()->getNamespace() === SMW_NS_PROPERTY) {
return DIProperty::newFromUserLabel($this->article->getTitle()->getText())->isUserDefined();
}
return true;
}
示例2: __construct
public function __construct(Page $page)
{
if ($page instanceof Page) {
$this->output = str_replace('{{ title }}', $page->getTitle(), $this->html);
$this->output = str_replace('{{ description }}', $page->getDescription(), $this->output);
}
}
示例3: getRevIncludes
/**
* Get template and image versions from parsing a revision
* @param Page $article
* @param Revision $rev
* @param User $user
* @param string $regen use 'regen' to force regeneration
* @return array( templateIds, fileSHA1Keys )
* templateIds like ParserOutput->mTemplateIds
* fileSHA1Keys like ParserOutput->mImageTimeKeys
*/
public static function getRevIncludes(Page $article, Revision $rev, User $user, $regen = '')
{
global $wgParser, $wgMemc;
wfProfileIn(__METHOD__);
$versions = false;
$key = self::getCacheKey($article->getTitle(), $rev->getId());
if ($regen !== 'regen') {
// check cache
$versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article, 'allowStale');
}
if (!is_array($versions)) {
// cache miss
$pOut = false;
if ($rev->isCurrent()) {
$parserCache = ParserCache::singleton();
# Try current version parser cache (as anon)...
$pOut = $parserCache->get($article, $article->makeParserOptions($user));
if ($pOut == false && $rev->getUser()) {
// try the user who saved the change
$author = User::newFromId($rev->getUser());
$pOut = $parserCache->get($article, $article->makeParserOptions($author));
}
}
// ParserOutput::mImageTimeKeys wasn't always there
if ($pOut == false || !FlaggedRevs::parserOutputIsVersioned($pOut)) {
$title = $article->getTitle();
$pOpts = ParserOptions::newFromUser($user);
// Note: tidy off
$pOut = $wgParser->parse($rev->getText(), $title, $pOpts, true, true, $rev->getId());
}
# Get the template/file versions used...
$versions = array($pOut->getTemplateIds(), $pOut->getFileSearchOptions());
# Save to cache (check cache expiry for dynamic elements)...
$data = FlaggedRevs::makeMemcObj($versions);
$wgMemc->set($key, $data, $pOut->getCacheExpiry());
} else {
$tVersions =& $versions[0];
// templates
# Do a link batch query for page_latest...
$lb = new LinkBatch();
foreach ($tVersions as $ns => $tmps) {
foreach ($tmps as $dbKey => $revIdDraft) {
$lb->add($ns, $dbKey);
}
}
$lb->execute();
# Update array with the current page_latest values.
# This kludge is there since $newTemplates (thus $revIdDraft) is cached.
foreach ($tVersions as $ns => &$tmps) {
foreach ($tmps as $dbKey => &$revIdDraft) {
$title = Title::makeTitle($ns, $dbKey);
$revIdDraft = (int) $title->getLatestRevID();
}
}
}
wfProfileOut(__METHOD__);
return $versions;
}
示例4: getRevIncludes
/**
* Get template and image versions from parsing a revision
* @param Page $article
* @param Revision $rev
* @param User $user
* @param string $regen use 'regen' to force regeneration
* @return array( templateIds, fileSHA1Keys )
* templateIds like ParserOutput->mTemplateIds
* fileSHA1Keys like ParserOutput->mImageTimeKeys
*/
public static function getRevIncludes(Page $article, Revision $rev, User $user, $regen = '')
{
global $wgMemc;
wfProfileIn(__METHOD__);
$key = self::getCacheKey($article->getTitle(), $rev->getId());
if ($regen === 'regen') {
$versions = false;
// skip cache
} elseif ($rev->isCurrent()) {
// Check cache entry against page_touched
$versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article);
} else {
// Old revs won't always be invalidated with template/file changes.
// Also, we don't care if page_touched changed due to a direct edit.
$versions = FlaggedRevs::getMemcValue($wgMemc->get($key), $article, 'allowStale');
if (is_array($versions)) {
// entry exists
// Sanity check that the cache is reasonably up to date
list($templates, $files) = $versions;
if (self::templatesStale($templates) || self::filesStale($files)) {
$versions = false;
// no good
}
}
}
if (!is_array($versions)) {
// cache miss
$pOut = false;
if ($rev->isCurrent()) {
$parserCache = ParserCache::singleton();
# Try current version parser cache for this user...
$pOut = $parserCache->get($article, $article->makeParserOptions($user));
if ($pOut == false) {
# Try current version parser cache for the revision author...
$optsUser = $rev->getUser() ? User::newFromId($rev->getUser()) : 'canonical';
$pOut = $parserCache->get($article, $article->makeParserOptions($optsUser));
}
}
// ParserOutput::mImageTimeKeys wasn't always there
if ($pOut == false || !FlaggedRevs::parserOutputIsVersioned($pOut)) {
$content = $rev->getContent(Revision::RAW);
if (!$content) {
// Just for extra sanity
$pOut = new ParserOutput();
} else {
$pOut = $content->getParserOutput($article->getTitle(), $rev->getId(), ParserOptions::newFromUser($user));
}
}
# Get the template/file versions used...
$versions = array($pOut->getTemplateIds(), $pOut->getFileSearchOptions());
# Save to cache (check cache expiry for dynamic elements)...
$data = FlaggedRevs::makeMemcObj($versions);
$wgMemc->set($key, $data, $pOut->getCacheExpiry());
}
wfProfileOut(__METHOD__);
return $versions;
}
示例5: mapPageToDto
/**
* @param page Page
* @return PageDto
*/
public function mapPageToDto(Page $page)
{
$pageDto = new PageDto();
$pageDto->setId($page->getId());
$pageDto->setTitle($page->getTitle());
$pageDto->setName($page->getName());
$pageDto->setDescription($page->getDescription());
$pageDto->setPosition($page->getPosition());
return $pageDto;
}
示例6: storePage
public static function storePage(Page $page, $rootUrl)
{
$mysqli = self::connect();
$query = "INSERT INTO news_retriever_page (date, title, siteroot, pageurl, content) VALUES(?,?,?,?,?)";
$statement = $mysqli->prepare($query);
$date = $page->getDate()->format('Y-m-d');
$title = $page->getTitle();
$content = $page->getPageAsHtml();
$statement->bind_param('sssss', $date, $title, $rootUrl, $page->getPageUrl(), $content);
$statement->execute();
$mysqli->close();
}
示例7: addRevision
/**
* Adds a revision to a page, while returning the resuting revision's id
*
* @param $page WikiPage: page to add the revision to
* @param $text string: revisions text
* @param $text string: revisions summare
*
* @throws MWExcepion
*/
protected function addRevision(Page $page, $text, $summary)
{
$status = $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle()), $summary);
if ($status->isGood()) {
$value = $status->getValue();
$revision = $value['revision'];
$revision_id = $revision->getId();
$text_id = $revision->getTextId();
if ($revision_id > 0 && $text_id > 0) {
return array($revision_id, $text_id);
}
}
throw new MWException("Could not determine revision id (" . $status->getWikiText() . ")");
}
示例8: addRevision
/**
* Adds a revision to a page, while returning the resuting revision's id
*
* @param Page $page Page to add the revision to
* @param string $text Revisions text
* @param string $summary Revisions summary
* @param string $model The model ID (defaults to wikitext)
*
* @throws MWException
* @return array
*/
protected function addRevision(Page $page, $text, $summary, $model = CONTENT_MODEL_WIKITEXT)
{
$status = $page->doEditContent(ContentHandler::makeContent($text, $page->getTitle(), $model), $summary);
if ($status->isGood()) {
$value = $status->getValue();
$revision = $value['revision'];
$revision_id = $revision->getId();
$text_id = $revision->getTextId();
if ($revision_id > 0 && $text_id > 0) {
return [$revision_id, $text_id];
}
}
throw new MWException("Could not determine revision id (" . $status->getWikiText(false, false, 'en') . ")");
}
示例9: wfReadOnly
function __construct(Page $article)
{
global $wgUser;
// Set instance variables.
$this->mArticle = $article;
$this->mTitle = $article->getTitle();
$this->mApplicableTypes = $this->mTitle->getRestrictionTypes();
// Check if the form should be disabled.
// If it is, the form will be available in read-only to show levels.
$this->mPermErrors = $this->mTitle->getUserPermissionsErrors('protect', $wgUser);
$this->disabled = wfReadOnly() || $this->mPermErrors != array();
$this->disabledAttrib = $this->disabled ? array('disabled' => 'disabled') : array();
$this->loadData();
}
示例10: doWork
/**
* @return bool
*/
public function doWork()
{
global $wgUseFileCache;
// @todo several of the methods called on $this->page are not declared in Page, but present
// in WikiPage and delegated by Article.
$isCurrent = $this->revid === $this->page->getLatest();
if ($this->content !== null) {
$content = $this->content;
} elseif ($isCurrent) {
// XXX: why use RAW audience here, and PUBLIC (default) below?
$content = $this->page->getContent(Revision::RAW);
} else {
$rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
if ($rev === null) {
$content = null;
} else {
// XXX: why use PUBLIC audience here (default), and RAW above?
$content = $rev->getContent();
}
}
if ($content === null) {
return false;
}
// Reduce effects of race conditions for slow parses (bug 46014)
$cacheTime = wfTimestampNow();
$time = -microtime(true);
$this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions);
$time += microtime(true);
// Timing hack
if ($time > 3) {
// TODO: Use Parser's logger (once it has one)
$logger = MediaWiki\Logger\LoggerFactory::getInstance('slow-parse');
$logger->info('{time} {title}', array('time' => number_format($time, 2), 'title' => $this->page->getTitle()->getPrefixedDBkey()));
}
if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) {
ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid);
}
// Make sure file cache is not used on uncacheable content.
// Output that has magic words in it can still use the parser cache
// (if enabled), though it will generally expire sooner.
if (!$this->parserOutput->isCacheable()) {
$wgUseFileCache = false;
}
if ($isCurrent) {
$this->page->triggerOpportunisticLinksUpdate($this->parserOutput);
}
return true;
}
示例11: doWork
/**
* @return bool
*/
public function doWork()
{
global $wgUseFileCache;
// @todo several of the methods called on $this->page are not declared in Page, but present
// in WikiPage and delegated by Article.
$isCurrent = $this->revid === $this->page->getLatest();
if ($this->content !== null) {
$content = $this->content;
} elseif ($isCurrent) {
// XXX: why use RAW audience here, and PUBLIC (default) below?
$content = $this->page->getContent(Revision::RAW);
} else {
$rev = Revision::newFromTitle($this->page->getTitle(), $this->revid);
if ($rev === null) {
$content = null;
} else {
// XXX: why use PUBLIC audience here (default), and RAW above?
$content = $rev->getContent();
}
}
if ($content === null) {
return false;
}
// Reduce effects of race conditions for slow parses (bug 46014)
$cacheTime = wfTimestampNow();
$time = -microtime(true);
$this->parserOutput = $content->getParserOutput($this->page->getTitle(), $this->revid, $this->parserOptions);
$time += microtime(true);
// Timing hack
if ($time > 3) {
wfDebugLog('slow-parse', sprintf("%-5.2f %s", $time, $this->page->getTitle()->getPrefixedDBkey()));
}
if ($this->cacheable && $this->parserOutput->isCacheable() && $isCurrent) {
ParserCache::singleton()->save($this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid);
}
// Make sure file cache is not used on uncacheable content.
// Output that has magic words in it can still use the parser cache
// (if enabled), though it will generally expire sooner.
if (!$this->parserOutput->isCacheable() || $this->parserOutput->containsOldMagic()) {
$wgUseFileCache = false;
}
if ($isCurrent) {
$this->page->doCascadeProtectionUpdates($this->parserOutput);
}
return true;
}
示例12: render
/**
* @param Page $page
*/
public function render(Page $page)
{
$this->config = $page->getConfig();
$header = '<!DOCTYPE html>' . PHP_EOL;
$header .= '<html >' . PHP_EOL;
$header .= '<head lang = "en">' . PHP_EOL;
$header .= '<meta charset = "UTF-8">' . PHP_EOL;
$header .= '<meta name = "viewport" content = "initial-scale=1.0"/>' . PHP_EOL;
$style_sheets = array_merge($this->config->getGlobalStyleSheets(), $page->getStyleSheets());
foreach ($style_sheets as $style_sheet) {
$header .= '<link href="' . $this->getStyleSheetPath($style_sheet) . '" type="text/css" rel="stylesheet">' . PHP_EOL;
}
$java_scripts = array_merge($this->config->getGlobalJavaScripts(), $page->getJavaScripts());
foreach ($java_scripts as $java_script) {
$header .= '<script src="' . $this->getJavaScriptPath($java_script) . '" type="text/JavaScript"></script>' . PHP_EOL;
}
$header .= '<title>' . $page->getTitle() . '</title>' . PHP_EOL;
$header .= '</head>' . PHP_EOL;
$header .= '<body>' . PHP_EOL;
echo $header;
}
示例13: extract
function estetico_vision_func($atts)
{
extract(shortcode_atts(array("title" => "", "content_text" => "", "icon" => "", "custom_icon" => null, "content_pull" => null, "page_id" => null), $atts));
if ($content_pull == "current_pages" && $page_id != null) {
try {
$page = new Page($page_id);
$title = !empty($title) ? $title : $page->getTitle();
$content_text = !empty($content_text) ? $content_text : $page->getExcerpt();
} catch (Exception $ex) {
}
}
if ($custom_icon) {
$custom_icon = wp_get_attachment_image($custom_icon, array(70, 70), true);
$icon = 'custom-icon';
}
$output = '';
$output .= '<div class="vision">';
$output .= '<b class="icon rounded ' . $icon . '">' . $custom_icon . '</b>';
$output .= '<h6>' . $title . '</h6>';
$output .= '<p>' . $content_text . '</p>';
$output .= '</div>';
return $output;
}
示例14: Page
$s = new Page($title);
// adding to ttcs.tex
if ($s->discussion != '') {
$ttcsTex .= '\\ttcdwiki{' . $pureTitle . '}' . PHP_EOL;
} else {
if ($s->technologies != '') {
$ttcsTex .= '\\ttcdtwiki{' . $pureTitle . '}' . PHP_EOL;
} else {
$ttcsTex .= '\\ttcwiki{' . $pureTitle . '}' . PHP_EOL;
}
}
$fTtcMacro = fopen($ttcsFolder . $ttcTexTit, 'w+');
echo 'Saving macro for "' . $title . '"... ';
$ttcMacroTex = $s->toTexMacro();
$ttcMacroTex = formatter::intLinks($ttcMacroTex, $titles);
$ttcMacroTex .= "\\newcommand{\\" . str_replace('_', '', str_replace(' ', '', $s->getTitle())) . "TtcLabel}{" . str_replace('_', '', str_replace(' ', '', $s->getTitle())) . "}" . PHP_EOL;
//var_dump($links);
fwrite($fTtcMacro, $ttcMacroTex);
fclose($fTtcMacro);
echo 'DONE' . PHP_EOL;
echo 'Getting BibTex... ';
foreach ($s->bibs as $bib) {
$newbib = '';
$i = 0;
foreach (preg_split('/\\r\\n|\\r|\\n/', $bib) as $bibline) {
if ($i != 0 && startsWith('title', ltrim($bibline))) {
$bibline = preg_replace('/([A-Z]+)/', '{\\1}', $bibline);
}
$newbib .= $bibline . PHP_EOL;
$i += 1;
}
示例15: getTitle
/**
* Shortcut to get the Title object from the page
* @return Title
*/
final public function getTitle() {
return $this->page->getTitle();
}