本文整理汇总了PHP中Article::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::getContent方法的具体用法?PHP Article::getContent怎么用?PHP Article::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::getContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Show the special page
*
* @param $par Mixed: parameter passed to the page or null
*/
public function execute($par)
{
global $wgOut, $wgUser, $wgRequest;
// Set page title and other stuff
$this->setHeaders();
# Show a message if the database is in read-only mode
if (wfReadOnly()) {
$wgOut->readOnlyPage();
return;
}
# If user is blocked, s/he doesn't need to access this page
if ($wgUser->isBlocked()) {
throw new UserBlockedError($this->getUser()->mBlock);
}
$title = $wgRequest->getVal('wpTitle');
$category = $wgRequest->getVal('wpCategory');
if (empty($title) || empty($category)) {
return;
}
$oTitle = Title::newFromText($title);
if (!is_object($oTitle)) {
return;
}
$oArticle = new Article($oTitle);
if ($oTitle->exists()) {
$text = $oArticle->getContent();
} else {
$text = self::getCreateplate($category);
}
$text .= "\n[[Category:" . $category . ']]';
$oArticle->doEdit($text, wfMsgForContent('createincategory-comment', $category));
$wgOut->redirect($oTitle->getFullUrl());
}
示例2: run
/**
* Run a dtImport job
* @return boolean success
*/
function run()
{
wfProfileIn(__METHOD__);
if (is_null($this->title)) {
$this->error = "dtImport: Invalid title";
wfProfileOut(__METHOD__);
return false;
}
$article = new Article($this->title);
if (!$article) {
$this->error = 'dtImport: Article not found "' . $this->title->getPrefixedDBkey() . '"';
wfProfileOut(__METHOD__);
return false;
}
$for_pages_that_exist = $this->params['for_pages_that_exist'];
if ($for_pages_that_exist == 'skip' && $this->title->exists()) {
return true;
}
// change global $wgUser variable to the one specified by
// the job only for the extent of this import
global $wgUser;
$actual_user = $wgUser;
$wgUser = User::newFromId($this->params['user_id']);
$text = $this->params['text'];
if ($for_pages_that_exist == 'append' && $this->title->exists()) {
$text = $article->getContent() . "\n" . $text;
}
$edit_summary = $this->params['edit_summary'];
$article->doEdit($text, $edit_summary);
$wgUser = $actual_user;
wfProfileOut(__METHOD__);
return true;
}
示例3: run
/**
* Run a refreshLinks job
* @return boolean success
*/
function run()
{
global $wgTitle, $wgUser, $wgLang, $wrGedcomExportDirectory;
$wgTitle = $this->title;
// FakeTitle (the default) generates errors when accessed, and sometimes I log wgTitle, so set it to something else
$wgUser = User::newFromName('WeRelate agent');
// set the user
$treeId = $this->params['tree_id'];
$treeName = $this->params['name'];
$treeUser = $this->params['user'];
$filename = "{$wrGedcomExportDirectory}/{$treeId}.ged";
$ge = new GedcomExporter();
$error = $ge->exportGedcom($treeId, $filename);
if ($error) {
$this->error = $error;
return false;
}
// leave a message for the tree requester
$userTalkTitle = Title::newFromText($treeUser, NS_USER_TALK);
$article = new Article($userTalkTitle, 0);
if ($article->getID() != 0) {
$text = $article->getContent();
} else {
$text = '';
}
$title = Title::makeTitle(NS_SPECIAL, 'Trees');
$msg = wfMsg('GedcomExportReady', $wgLang->date(wfTimestampNow(), true, false), $treeName, $title->getFullURL(wfArrayToCGI(array('action' => 'downloadExport', 'user' => $treeUser, 'name' => $treeName))));
$text .= "\n\n" . $msg;
$success = $article->doEdit($text, 'GEDCOM export ready');
if (!$success) {
$this->error = 'Unable to edit user talk page: ' . $treeUser;
return false;
}
return true;
}
示例4: initialize
protected function initialize()
{
global $wgParser;
$article = new Article($this->mOriginTitle);
$content = $article->getContent();
$this->parse($content);
}
示例5: onAddCommentsFormDiv
/**
* adding the flag table to the comments form
*
* @global SFFormPrinter $sfgFormPrinter from SMW
* @global Article $wgArticle
* @param String $sHtml
* @return boolean
*/
function onAddCommentsFormDiv(&$sHtml)
{
global $sfgFormPrinter, $wgArticle, $webplatformSectionCommentsSMW;
$sHtml .= '<a id="comments-flag-link">' . wfMessage('comments-flag-link')->text() . '</a>';
$sHtml .= '<div id="comment-flags">';
$sFormName = $webplatformSectionCommentsSMW['form'];
//$sPageName = 'Comments';
$oTitle = Title::newFromText($sFormName, SF_NS_FORM);
$oArticle = new Article($oTitle, 0);
$sFormDefinition = $oArticle->getContent();
$sFormDefinition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $sFormDefinition);
$aHtml = $sfgFormPrinter->formHTML($sFormDefinition, false, true, $oTitle->getArticleID(), $wgArticle->fetchContent());
//, $wgArticle->getTitle()->getArticleID(), $wgArticle->fetchContent(), $wgArticle->getTitle()->getText(), null );
$aMatches = array();
preg_match_all('#<table.*?</table>#is', $aHtml[0], $aMatches);
$index = null;
foreach ($aMatches[0] as $key => $value) {
$bPos = strrpos($value, $webplatformSectionCommentsSMW['template'] . '[');
if ($bPos !== false) {
$index = $key;
break;
}
}
$sHtml .= $aMatches[0][$index];
$sHtml .= '</div>';
return true;
}
示例6: assertArticle
public function assertArticle(Article $article, $hash, $title, $author, $publicationDate, $content)
{
$this->assertEquals($article->getHash(), $hash);
$this->assertEquals($article->getTitle(), $title);
$this->assertEquals($article->getAuthor(), $author);
$this->assertEquals($article->getPublicationDate(), $publicationDate);
$this->assertEquals($article->getContent(), $content);
}
示例7: getParam
/**
* Fetches the content of a defined MediaWiki message.
*
* @param $name String: name of the MediaWiki message
* @return string or nothing
*/
static function getParam( $name ) {
$nameTitle = Title::newFromText( $name, NS_MEDIAWIKI );
if ( $nameTitle->exists() ) {
$article = new Article( $nameTitle );
return $article->getContent();
} else {
return '';
}
}
示例8: isArticleAnswered
public function isArticleAnswered()
{
global $wgContLang;
if (!self::isQuestion()) {
return false;
}
$article = new Article($this->title);
$content = $article->getContent();
return self::isContentAnswered($content);
}
示例9: getTextById
function getTextById($id)
{
$title = $this->getTitleObject('id', $id);
if ($title == '') {
return '';
}
$rev = new Article($title, 0);
$text = $rev->getContent();
return $text;
}
示例10: addArticle
public function addArticle($month, $day, $year, $page)
{
$lines = array();
$temp = "";
$head = array();
$article = new Article(Title::newFromText($page));
if (!$article->exists()) {
return "";
}
$redirectCount = 0;
if ($article->isRedirect() && $this->setting('disableredirects')) {
return '';
}
while ($article->isRedirect() && $redirectCount < 10) {
$redirectedArticleTitle = Title::newFromRedirect($article->getContent());
$article = new Article($redirectedArticleTitle);
$redirectCount += 1;
}
$body = $article->fetchContent(0, false, false);
if (strlen(trim($body)) == 0) {
return "";
}
$lines = split("\n", $body);
$cntLines = count($lines);
// dont use section events... only line 1 of the page
if ($this->setting('disablesectionevents')) {
$key = $lines[0];
//initalize the key
$head[$key] = "";
$cntLines = 0;
}
for ($i = 0; $i < $cntLines; $i++) {
$line = $lines[$i];
if (substr($line, 0, 2) == '==') {
$arr = split("==", $line);
$key = $arr[1];
$head[$key] = "";
$temp = "";
} else {
if ($i == 0) {
// $i=0 means this is a one event page no (==event==) data
$key = $line;
//initalize the key
$head[$key] = "";
} else {
$temp .= "{$line}\n";
$head[$key] = Common::cleanWiki($temp);
}
}
}
while (list($event, $body) = each($head)) {
$this->buildEvent($month, $day, $year, trim($event), $page, $body);
}
}
示例11: efCondTemplateLoadPage
function efCondTemplateLoadPage($p)
{
$title = Title::newFromText($p);
if ($title->getArticleID() == 0) {
$text = "<b>[[" . $p . ']]</b>';
} else {
$article = new Article($title);
$text = $article->getContent();
}
return $text;
}
示例12: getPageText
/**
* Returns the contents of the specified wiki page, at either the
* specified revision (if there is one) or the latest revision
* (otherwise).
*/
public static function getPageText($title, $revisionID = null)
{
if (method_exists('Revision', 'getContent')) {
// MW >= 1.21
$revision = Revision::newFromTitle($title, $revisionID);
return $revision->getContent()->getNativeData();
} else {
$article = new Article($title, $revisionID);
return $article->getContent();
}
}
示例13: setup
function setup()
{
global $wgParser, $wgHooks, $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions, $wgSecurityExtraActions, $wgSecurityExtraGroups, $wgRestrictionTypes, $wgRestrictionLevels, $wgGroupPermissions, $wgSecurityRenderInfo, $wgSecurityAllowUnreadableLinks, $wgSecurityGroupsArticle;
# Add our hooks
$wgHooks['UserGetRights'][] = $this;
$wgHooks['ImgAuthBeforeStream'][] = $this;
$wgParser->setFunctionHook('ifusercan', array($this, 'ifUserCan'));
$wgParser->setFunctionHook('ifgroup', array($this, 'ifGroup'));
if ($wgSecurityRenderInfo) {
$wgHooks['OutputPageBeforeHTML'][] = $this;
}
if ($wgSecurityAllowUnreadableLinks) {
$wgHooks['BeforePageDisplay'][] = $this;
}
# Add a new log type
$wgLogTypes[] = 'security';
$wgLogNames['security'] = 'securitylogpage';
$wgLogHeaders['security'] = 'securitylogpagetext';
$wgLogActions['security/deny'] = 'securitylogentry';
# Each extra action is also a restriction type
foreach ($wgSecurityExtraActions as $k => $v) {
$wgRestrictionTypes[] = $k;
}
# Add extra available groups if $wgSecurityGroupsArticle is set
if ($wgSecurityGroupsArticle) {
$groups = new Article(Title::newFromText($wgSecurityGroupsArticle, NS_MEDIAWIKI));
if (preg_match_all("/^\\*?\\s*(.+?)\\s*(\\|\\s*(.+))?\$/m", $groups->getContent(), $match)) {
foreach ($match[1] as $i => $k) {
$v = $match[3][$i];
if ($v) {
$wgSecurityExtraGroups[strtolower($k)] = $v;
} else {
$wgSecurityExtraGroups[strtolower($k)] = '';
}
}
}
}
# Ensure the new groups show up in rights management
# - note that 1.13 does a strange check in the ProtectionForm::buildSelector
# $wgUser->isAllowed($key) where $key is an item from $wgRestrictionLevels
# this requires that we treat the extra groups as an action and make sure its allowed by the user
foreach ($wgSecurityExtraGroups as $k => $v) {
if (is_numeric($k)) {
$k = strtolower($v);
}
$wgRestrictionLevels[] = $k;
$wgGroupPermissions[$k][$k] = true;
# members of $k must be allowed to perform $k
$wgGroupPermissions['sysop'][$k] = true;
# sysops must be allowed to perform $k as well
}
}
示例14: update
public function update(Article $article)
{
$id = $article->getId();
$content = mysqli_real_escape_string($article->getContent());
$id_author = $article->getUser()->getId();
$query = "UPDATE article SET content='" . $content . "', id_user='" . $id_user . "' WHERE id='" . $id . "'";
$res = mysqli_query($this->db, $query);
if ($res) {
return $this->findById($id);
} else {
return "Internal Server Error";
}
}
示例15: execute
function execute($par)
{
global $wgOut, $wgRequest, $wgParser, $wgTitle, $wgUser;
$year = isset($_GET['year']) ? $_REQUEST['year'] : null;
$month = isset($_GET['month']) ? $_REQUEST['month'] : null;
$day = isset($_GET['day']) ? $_REQUEST['day'] : null;
if ($year == "") {
$year = date("Y");
}
if ($month == "") {
$month = date("m");
}
# Don't show the navigation if we're including the page
if (!$this->mIncluding) {
$this->setHeaders();
$wgOut->addWikiText(wfMsg('events-header'));
}
if ($day == "") {
$wgOut->AddWikiText('<calendar>upcoming=off</calendar>');
$day = "__";
}
//build the SQL query
$dbr =& wfGetDB(DB_SLAVE);
$sPageTable = $dbr->tableName('page');
$categorylinks = $dbr->tableName('categorylinks');
$sSqlSelect = "SELECT page_namespace, page_title, page_id, clike1.cl_to catlike1 ";
$sSqlSelectFrom = "FROM {$sPageTable} INNER JOIN {$categorylinks} AS c1 ON page_id = c1.cl_from AND c1.cl_to='Events' INNER JOIN {$categorylinks} " . "AS clike1 ON page_id = clike1.cl_from AND clike1.cl_to LIKE '{$year}/{$month}/{$day}'";
$sSqlWhere = ' WHERE page_is_redirect = 0 ';
$sSqlOrderby = ' ORDER BY catlike1 ASC';
//DEBUG: output SQL query
//$wgOut->addHTML('[' . $sSqlSelect . $sSqlSelectFrom . $sSqlWhere . $sSqlOrderby . ']');
$res = $dbr->query($sSqlSelect . $sSqlSelectFrom . $sSqlWhere . $sSqlOrderby);
$sk =& $wgUser->getSkin();
while ($row = $dbr->fetchObject($res)) {
$title = Title::makeTitle($row->page_namespace, $row->page_title);
$wgOut->addHTML('<div class="eventsblock">');
$title_text = $title->getSubpageText();
$wgOut->addHTML('<b>' . $sk->makeKnownLinkObj($title, $title_text) . '</b><br>');
$wl_article = new Article($title);
$wl = $wl_article->getContent();
$parserOptions = ParserOptions::newFromUser($wgUser);
$parserOptions->setEditSection(false);
$parserOptions->setTidy(true);
$parserOutput = $wgParser->parse($wl, $title, $parserOptions);
$previewHTML = $parserOutput->getText();
$wgOut->addHTML($previewHTML);
$wgOut->addHTML('</div>');
}
}