本文整理汇总了PHP中Article::getRawText方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::getRawText方法的具体用法?PHP Article::getRawText怎么用?PHP Article::getRawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::getRawText方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addProperty
/**
* Adds a property.
*
* @since 1.1
*
* @param string $titleName The name of the property
* @param string $propertyProperties A string of properties to assign to the propery (such as "has type")
*/
protected function addProperty($titleName, $propertyProperties)
{
$title = Title::newFromText($titleName, SMW_NS_PROPERTY);
if (!$title->exists()) {
$article = new Article($title, 0);
$article->doEdit($article->getRawText() . $propertyProperties, '');
// TODO: add summary
}
}
示例2: upload
function upload()
{
$details = null;
$this->content = 'error';
$up = new UploadFromFile();
$up->initializeFromRequest($this->wg->request);
$permErrors = $up->verifyPermissions($this->wg->user);
if ($permErrors !== true) {
$this->status = self::UPLOAD_PERMISSION_ERROR;
$this->statusMessage = $this->uploadMessage($this->status, null);
} else {
if (empty($this->wg->EnableUploads)) {
// BugId:6122
$this->statusMessage = wfMsg('uploaddisabled');
} else {
$details = $up->verifyUpload();
$this->status = is_array($details) ? $details['status'] : UploadBase::UPLOAD_VERIFICATION_ERROR;
$this->statusMessage = '';
if ($this->status > 0) {
$this->statusMessage = $this->uploadMessage($this->status, $details);
} else {
$titleText = $this->request->getVal('title');
$sectionNumber = $this->request->getVal('section', 0);
$this->status = $up->performUpload('', '', '', $this->wg->user);
$mainArticle = new Article(Title::newFromText($titleText));
if ($sectionNumber == 0) {
$mainArticle->updateArticle($this->getWikiText($up->getTitle()->getText(), self::LEFT) . $mainArticle->getRawText(), '', false, false);
} else {
$firstSectionText = $mainArticle->getSection($mainArticle->getRawText(), $sectionNumber);
$matches = array();
if (preg_match('/={2,3}[^=]+={2,3}/', $firstSectionText, $matches)) {
$firstSectionText = trim(str_replace($matches[0], '', $firstSectionText));
$newSectionText = $mainArticle->replaceSection($sectionNumber, $matches[0] . "\n" . $this->getWikiText($up->getTitle()->getText(), self::LEFT) . $firstSectionText);
$mainArticle->updateArticle($newSectionText, '', false, false);
}
}
$this->content = $this->renderImage($up->getTitle()->getText(), self::LEFT);
}
}
}
}
示例3: 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;
}
示例4: includePage
function includePage($title)
{
global $wgParser, $wgUser;
$pageTitle = Title::newFromText($title);
if (!$pageTitle->exists()) {
echo 'The page [[' . $title . ']] was not found.';
} else {
$article = new Article($pageTitle);
$wgParserOptions = new ParserOptions($wgUser);
$parserOutput = $wgParser->parse($article->getRawText(), $pageTitle, $wgParserOptions);
echo $parserOutput->getText();
}
}
示例5: showDiff
/**
* Get a diff between the current contents of the edit box and the
* version of the page we're editing from.
*
* If this is a section edit, we'll replace the section as for final
* save and then make a comparison.
*/
function showDiff()
{
global $wgUser, $wgContLang, $wgParser, $wgOut;
$oldtext = $this->mArticle->getRawText();
$newtext = $this->mArticle->replaceSection($this->section, $this->textbox1, $this->summary, $this->edittime);
wfRunHooks('EditPageGetDiffText', array($this, &$newtext));
$popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
$newtext = $wgParser->preSaveTransform($newtext, $this->mTitle, $wgUser, $popts);
if ($oldtext !== false || $newtext != '') {
$oldtitle = wfMsgExt('currentrev', array('parseinline'));
$newtitle = wfMsgExt('yourtext', array('parseinline'));
$de = new DifferenceEngine($this->mArticle->getContext());
$de->setText($oldtext, $newtext);
$difftext = $de->getDiff($oldtitle, $newtitle);
$de->showDiffStyle();
} else {
$difftext = '';
}
$wgOut->addHTML('<div id="wikiDiff">' . $difftext . '</div>');
}
示例6: getGeolocationButtonParams
/**
* Returns geolocation button params
*/
private function getGeolocationButtonParams($refreshCache = false)
{
$sMemcKey = wfMemcKey($this->app->wg->title->getText(), $this->app->wg->title->getNamespace(), 'GeolocationButtonParams');
// use user default
if (empty($iWidth)) {
$wopt = $this->app->wg->user->getGlobalPreference('thumbsize');
if (!isset($this->app->wg->thumbLimits[$wopt])) {
$wopt = User::getDefaultOption('thumbsize');
}
$iWidth = $this->app->wg->thumbLimits[$wopt];
}
$aResult = array('align' => 'right', 'width' => $iWidth);
$aMemcResult = $this->app->wg->memc->get($sMemcKey);
$refreshCache = true;
// FIXME
if ($refreshCache || empty($aMemcResult)) {
$oArticle = new Article($this->app->wg->title);
$sRawText = $oArticle->getRawText();
$aMatches = array();
$string = $this->app->wg->contLang->getNsText(NS_IMAGE) . '|' . MWNamespace::getCanonicalName(NS_IMAGE);
$iFound = preg_match('#\\[\\[(' . $string . '):[^\\]]*|thumb[^\\]]*\\]\\]#', $sRawText, $aMatches);
if (!empty($iFound)) {
reset($aMatches);
$sMatch = current($aMatches);
$sMatch = str_replace('[[', '', $sMatch);
$sMatch = str_replace(']]', '', $sMatch);
$aMatch = explode('|', $sMatch);
foreach ($aMatch as $element) {
if ($element == 'left') {
$aResult['align'] = $element;
}
if (substr($element, -2) == 'px' && (int) substr($element, 0, -2) > 0) {
$aResult['width'] = (int) substr($element, 0, -2);
}
}
}
$iExpires = 60 * 60 * 24;
$this->app->wg->memc->set($sMemcKey, $aResult, $iExpires);
} else {
$aResult['align'] = $aMemcResult['align'];
if (!empty($aMemcResult['width'])) {
$aResult['width'] = $aMemcResult['width'];
}
}
// get default image width
return $aResult;
}
示例7: beforePageDisplayHTML
//.........这里部分代码省略.........
}
}
if (self::$enableImages == 1) {
$disableImages = $wgRequest->getCookie('disableImages');
if ($disableImages) {
$wgRequest->response()->setcookie('disableImages', '');
}
$location = str_replace('?enableImages=1', '', str_replace('&enableImages=1', '', $wgRequest->getFullRequestURL()));
$location = str_replace('&mfi=1', '', str_replace('&mfi=0', '', $location));
$location = $this->getRelativeURL($location);
$wgRequest->response()->header('Location: ' . $location . '&mfi=1');
}
self::$format = $wgRequest->getText('format');
self::$callback = $wgRequest->getText('callback');
self::$requestedSegment = $wgRequest->getText('seg', 0);
self::$search = $wgRequest->getText('search');
self::$searchField = $wgRequest->getText('search', '');
$device = new DeviceDetection();
if ($xDevice) {
$formatName = $xDevice;
} else {
$formatName = $device->formatName($userAgent, $acceptHeader);
}
self::$device = $device->format($formatName);
if (self::$device['view_format'] === 'wml') {
$this->contentFormat = 'WML';
} elseif (self::$device['view_format'] === 'html') {
$this->contentFormat = 'XHTML';
}
if (self::$useFormat === 'mobile-wap') {
$this->contentFormat = 'WML';
}
if ($mobileAction == 'leave_feedback') {
echo $this->renderLeaveFeedbackXHTML();
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'leave_feedback_post') {
$this->getMsg();
$subject = $wgRequest->getText('subject', '');
$message = $wgRequest->getText('message', '');
$token = $wgRequest->getText('edittoken', '');
$title = Title::newFromText(self::$messages['mobile-frontend-feedback-page']);
if ($title->userCan('edit') && !$wgUser->isBlockedFrom($title) && $wgUser->matchEditToken($token)) {
$article = new Article($title, 0);
$rawtext = $article->getRawText();
$rawtext .= "\n== {$subject} == \n {$message} ~~~~ \n <small>User agent: {$userAgent}</small> ";
$article->doEdit($rawtext, '');
}
$location = str_replace('&mobileaction=leave_feedback_post', '', $wgRequest->getFullRequestURL() . '¬iceid=1&useformat=mobile');
$location = $this->getRelativeURL($location);
$wgRequest->response()->header('Location: ' . $location);
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'disable_mobile_site' && $this->contentFormat == 'XHTML') {
echo $this->renderDisableMobileSiteXHTML();
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'opt_in_mobile_site' && $this->contentFormat == 'XHTML') {
echo $this->renderOptInMobileSiteXHTML();
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'opt_out_mobile_site' && $this->contentFormat == 'XHTML') {
echo $this->renderOptOutMobileSiteXHTML();
wfProfileOut(__METHOD__);
exit;
}
if ($mobileAction == 'opt_in_cookie') {
wfIncrStats('mobile.opt_in_cookie_set');
$this->setOptInOutCookie('1');
$this->disableCaching();
$location = wfExpandUrl(Title::newMainPage()->getFullURL(), PROTO_CURRENT);
$wgRequest->response()->header('Location: ' . $location);
}
if ($mobileAction == 'opt_out_cookie') {
$this->setOptInOutCookie('');
}
$this->getMsg();
$this->disableCaching();
$this->sendXDeviceVaryHeader();
$this->sendApplicationVersionVaryHeader();
$this->checkUserStatus();
$this->checkUserLoggedIn();
if (self::$title->isSpecial('Userlogin') && self::$isBetaGroupMember) {
self::$wsLoginToken = $wgRequest->getSessionData('wsLoginToken');
$q = array('action' => 'submitlogin', 'type' => 'login');
$returnToVal = $wgRequest->getVal('returnto');
if ($returnToVal) {
$q['returnto'] = $returnToVal;
}
self::$wsLoginFormAction = self::$title->getLocalURL($q);
}
$this->setDefaultLogo();
ob_start(array($this, 'DOMParse'));
wfProfileOut(__METHOD__);
return true;
}
示例8: mvd_consistancy_check
function mvd_consistancy_check()
{
//get all 2009 streams:
$dbr = wfGetDB(DB_READ);
$streams = array();
$result = $dbr->select('mv_streams', '*', 'date_start_time >= ' . mktime(0, 0, 0, 1, 1, 2009), __METHOD__);
if ($dbr->numRows($result) == 0) {
die("no streams found" . "\n" . $dbr->lastQuery() . "\n");
}
while ($stream = $dbr->fetchObject($result)) {
//get all the mvds for this stream
$mvd_res = $dbr->select('mv_mvd_index', '*', array('stream_id' => $stream->id));
while ($mvd = $dbr->fetchObject($mvd_res)) {
//make sure the article exists:
$mvdTitle = Title::newFromText($mvd->wiki_title, MV_NS_MVD);
if ($mvdTitle->exists()) {
//update the text:
$mvdArticle = new Article($mvdTitle);
$text = $mvdArticle->getRawText();
//find the spoken by or speech by text:
$sb_pat = '/\\[\\[Spoken By(\\:.)([^\\]]*)]]/i';
preg_match($sb_pat, $text, $matches);
if (isset($matches[2])) {
$replacement = $matches[2] == 'Unknown' ? '' : '[[Spoken By::' . str_replace('_', ' ', $matches[2]) . ']]';
$text = preg_replace($sb_pat, $replacement, $text);
}
//do the same for speech by
$sb_pat = '/\\[\\[Speech by(\\:.)([^\\]]*)]]/i';
preg_match($sb_pat, $text, $matches);
if (isset($matches[2])) {
$replacement = $matches[2] == 'Unknown' ? '' : '[[Speech by::' . str_replace('_', ' ', $matches[2]) . ']]';
$text = preg_replace($sb_pat, $replacement, $text);
}
//trim all double spaces
$text = preg_replace('/[\\s]+/', ' ', $text);
//uc upper words:
//$text = preg_replace("/[^A-Z]\.(\s)(\\w)/e", '".$1".strtoupper("$2")', $text);
do_update_wiki_page($mvdTitle, trim($text), '', true);
} else {
print "orphaned mvd: {$mvd->wiki_title} (should remove) \n";
}
}
//die('only update one stream at a time');
}
}
示例9: modalArticle
/**
* render template on GET. if POSTed, add content to article page
* @requestParam string articleurl
* @requestParam string reason
* @requestParam string cancel [true/false]
* @responseParam string result [ok/error]
* @responseParam string msg - result message
* @responseParam string errParam - error param
*/
public function modalArticle()
{
if ($this->request->getVal('submit', false) && $_COOKIE['wikicitiesUserID'] == $_SESSION['wsUserID']) {
$hubname = $this->request->getVal('hubname', '');
$articleUrl = trim($this->request->getVal('articleurl', ''));
$reason = trim($this->request->getVal('reason', ''));
$submissiondate = date('r');
if ($this->request->getVal('cancel', false)) {
return;
} else {
if (strlen($articleUrl) < 10) {
$this->result = 'error';
$this->errParam = 'articleurl';
$this->msg = $this->wf->msg('wikiahubs-error-invalid-article-url-length');
return;
} else {
if (empty($reason) || strlen($reason) > 140) {
$this->result = 'error';
$this->errParam = 'reason';
$this->msg = $this->wf->msg('wikiahubs-error-invalid-reason-length');
return;
}
}
}
$title = Title::newFromText($hubname . '/Suggested_content');
$article = new Article($title);
$username = $this->wg->user->getName();
$content = "{$articleUrl} | {$reason} | {$username} | {$submissiondate} \n\n" . $article->getRawText();
$summary = "Hubs: {$username} suggests article";
$status = $article->doEdit($content, $summary);
$this->result = 'ok';
$this->msg = $this->wf->msg('wikiahubs-suggest-article-success');
}
}
示例10: getRawDescription
/**
* @desc Returns raw (unparsed) wikitext.
*
* @return string raw wikitext
*/
public function getRawDescription()
{
$oArticle = new Article($this->getTitle());
return $oArticle->getRawText();
}
示例11: newFromTitle
/**
* Create a math object from article text
* @param Title $title Title of the article
*/
public static function newFromTitle( $title ) {
$article = new Article( $title, 0 );
return new self( $article->getRawText() );
}
示例12: showDiff
/**
* Get a diff between the current contents of the edit box and the
* version of the page we're editing from.
*
* If this is a section edit, we'll replace the section as for final
* save and then make a comparison.
*/
function showDiff()
{
global $wgUser, $wgContLang, $wgParser, $wgOut;
$oldtitlemsg = 'currentrev';
# if message does not exist, show diff against the preloaded default
if ($this->mTitle->getNamespace() == NS_MEDIAWIKI && !$this->mTitle->exists()) {
$oldtext = $this->mTitle->getDefaultMessageText();
if ($oldtext !== false) {
$oldtitlemsg = 'defaultmessagetext';
}
} else {
$oldtext = $this->mArticle->getRawText();
}
$newtext = $this->mArticle->replaceSection($this->section, $this->textbox1, $this->summary, $this->edittime);
wfRunHooks('EditPageGetDiffText', array($this, &$newtext));
$popts = ParserOptions::newFromUserAndLang($wgUser, $wgContLang);
$newtext = $wgParser->preSaveTransform($newtext, $this->mTitle, $wgUser, $popts);
if ($oldtext !== false || $newtext != '') {
$oldtitle = wfMessage($oldtitlemsg)->parse();
$newtitle = wfMessage('yourtext')->parse();
$de = new DifferenceEngine($this->mArticle->getContext());
$de->setText($oldtext, $newtext);
$difftext = $de->getDiff($oldtitle, $newtitle);
$de->showDiffStyle();
} else {
$difftext = '';
}
$wgOut->addHTML('<div id="wikiDiff">' . $difftext . '</div>');
}
示例13: getStatsFromArticle
/**
* get stats from article
* @param string $articleName
* @return integer stats
*/
public function getStatsFromArticle($articleName)
{
$this->wf->ProfileIn(__METHOD__);
$title = Title::newFromText($articleName);
$article = new Article($title);
$content = $article->getRawText();
$stats = empty($content) ? 0 : $content;
$this->wf->ProfileOut(__METHOD__);
return intval($stats);
}
示例14: getResult
/**
* Glues the content of <qpinterpret> tags together, checks "lang" attribute
* and calls appropriate interpretator to evaluate the user answer
*
* @param $interpArticle _existing_ Article with interpretation script enclosed in <qpinterp> tags
* @param $injectVars array with the following possible keys:
* key 'answer' array of user selected categories for
* every proposal & question of the poll;
* key 'usedQuestions' array of used questions for randomized polls
* or false, when the poll questions were not randomized
* @return instance of qp_InterpResult class (interpretation result)
*/
static function getResult( Article $interpArticle, array $injectVars ) {
global $wgParser, $wgContLang;
$matches = array();
# extract <qpinterpret> tags from the article content
$wgParser->extractTagsAndParams( array( qp_Setup::$interpTag ), $interpArticle->getRawText(), $matches );
$interpResult = new qp_InterpResult();
# glue content of all <qpinterpret> tags at the page together
$interpretScript = '';
$lang = '';
foreach ( $matches as &$match ) {
list( $tagName, $content, $attrs ) = $match;
# basic checks for lang attribute (only lang="php" is implemented yet)
# however we do not want to limit interpretation language,
# so the attribute is enforced to use
if ( !isset( $attrs['lang'] ) ) {
return $interpResult->setError( wfMsg( 'qp_error_eval_missed_lang_attr' ) );
}
if ( $lang == '' ) {
$lang = $attrs['lang'];
} elseif ( $attrs['lang'] != $lang ) {
return $interpResult->setError( wfMsg( 'qp_error_eval_mix_languages', $lang, $attrs['lang'] ) );
}
if ( $tagName == qp_Setup::$interpTag ) {
$interpretScript .= $content;
}
}
switch ( $lang ) {
case 'php' :
$result = qp_Eval::interpretAnswer( $interpretScript, $injectVars, $interpResult );
if ( $result instanceof qp_InterpResult ) {
# evaluation error (environment error) , return it;
return $interpResult;
}
break;
default :
return $interpResult->setError( wfMsg( 'qp_error_eval_unsupported_language', $lang ) );
}
/*** process the result ***/
if ( !is_array( $result ) ) {
return $interpResult->setError( wfMsg( 'qp_error_interpretation_no_return' ) );
}
if ( isset( $result['options'] ) &&
is_array( $result['options'] ) &&
array_key_exists( 'store_erroneous', $result['options'] ) ) {
$interpResult->storeErroneous = (boolean) $result['options']['store_erroneous'];
}
if ( isset( $result['error'] ) && is_array( $result['error'] ) ) {
# initialize $interpResult->qpcErrors[] member array
foreach ( $result['error'] as $qidx => $question ) {
if ( is_array( $question ) ) {
foreach ( $question as $pidx => $prop_error ) {
# integer indicates proposal id; string - proposal name
if ( is_array( $prop_error ) ) {
# separate error messages list for proposal categories
foreach ( $prop_error as $cidx => $cat_error ) {
$interpResult->setQPCerror( $cat_error, $qidx, $pidx, $cidx );
}
} else {
# error message for the whole proposal line
$interpResult->setQPCerror( $prop_error, $qidx, $pidx );
}
}
}
}
}
if ( isset( $result['errmsg'] ) && trim( strval( $result['errmsg'] ) ) != '' ) {
# script-generated error message for the whole answer
return $interpResult->setError( (string) $result['errmsg'] );
}
# if there were question/proposal errors, return them;
if ( $interpResult->isError() ) {
return $interpResult->setDefaultErrorMessage();
}
$interpCount = 0;
foreach ( qp_Setup::$show_interpretation as $interpType => $show ) {
if ( isset( $result[$interpType] ) ) {
$interpCount++;
}
}
if ( $interpCount == 0 ) {
return $interpResult->setError( wfMsg( 'qp_error_interpretation_no_return' ) );
}
$interpResult->structured = isset( $result['structured'] ) ? serialize( $result['structured'] ) : '';
if ( strlen( $interpResult->structured ) > qp_Setup::$field_max_len['serialized_interpretation'] ) {
# serialized structured interpretation is too long and
# this type of interpretation cannot be truncated
unset( $interpResult->structured );
return $interpResult->setError( wfMsg( 'qp_error_structured_interpretation_is_too_long' ) );
//.........这里部分代码省略.........