当前位置: 首页>>代码示例>>PHP>>正文


PHP Content::getNativeData方法代码示例

本文整理汇总了PHP中Content::getNativeData方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::getNativeData方法的具体用法?PHP Content::getNativeData怎么用?PHP Content::getNativeData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Content的用法示例。


在下文中一共展示了Content::getNativeData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: replaceSection

 /**
  * @see Content::replaceSection()
  */
 public function replaceSection($section, Content $with, $sectionTitle = '')
 {
     wfProfileIn(__METHOD__);
     $myModelId = $this->getModel();
     $sectionModelId = $with->getModel();
     if ($sectionModelId != $myModelId) {
         wfProfileOut(__METHOD__);
         throw new MWException("Incompatible content model for section: " . "document uses {$myModelId} but " . "section uses {$sectionModelId}.");
     }
     $oldtext = $this->getNativeData();
     $text = $with->getNativeData();
     if ($section === '') {
         wfProfileOut(__METHOD__);
         return $with;
         # XXX: copy first?
     }
     if ($section == 'new') {
         # Inserting a new section
         $subject = $sectionTitle ? wfMessage('newsectionheaderdefaultlevel')->rawParams($sectionTitle)->inContentLanguage()->text() . "\n\n" : '';
         if (wfRunHooks('PlaceNewSection', array($this, $oldtext, $subject, &$text))) {
             $text = strlen(trim($oldtext)) > 0 ? "{$oldtext}\n\n{$subject}{$text}" : "{$subject}{$text}";
         }
     } else {
         # Replacing an existing section; roll out the big guns
         global $wgParser;
         $text = $wgParser->replaceSection($oldtext, $section, $text);
     }
     $newContent = new WikitextContent($text);
     wfProfileOut(__METHOD__);
     return $newContent;
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:34,代码来源:WikitextContent.php

示例2: matchEntry

 /**
  * Check whether $content contains a link to $filterEntry
  *
  * @param Content $content Content to check
  * @param string $filterEntry Domainparts, see makeRegex() for more details
  * @return int 0 if no match or 1 if there's at least one match
  */
 static function matchEntry(Content $content, $filterEntry)
 {
     if (!$content instanceof TextContent) {
         // TODO: handle other types of content too.
         //      Maybe create ContentHandler::matchFilter( LinkFilter ).
         //      Think about a common base class for LinkFilter and MagicWord.
         return 0;
     }
     $text = $content->getNativeData();
     $regex = LinkFilter::makeRegex($filterEntry);
     return preg_match($regex, $text);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:19,代码来源:LinkFilter.php

示例3: execute


//.........这里部分代码省略.........
     $result_array['title'] = $titleObj->getPrefixedText();
     if (!is_null($oldid)) {
         $result_array['revid'] = intval($oldid);
     }
     if ($params['redirects'] && !is_null($redirValues)) {
         $result_array['redirects'] = $redirValues;
     }
     if (isset($prop['text'])) {
         $result_array['text'] = array();
         $result->setContent($result_array['text'], $p_result->getText());
     }
     if (!is_null($params['summary'])) {
         $result_array['parsedsummary'] = array();
         $result->setContent($result_array['parsedsummary'], Linker::formatComment($params['summary'], $titleObj));
     }
     if (isset($prop['langlinks'])) {
         $result_array['langlinks'] = $this->formatLangLinks($p_result->getLanguageLinks());
     }
     if (isset($prop['languageshtml'])) {
         $languagesHtml = $this->languagesHtml($p_result->getLanguageLinks());
         $result_array['languageshtml'] = array();
         $result->setContent($result_array['languageshtml'], $languagesHtml);
     }
     if (isset($prop['categories'])) {
         $result_array['categories'] = $this->formatCategoryLinks($p_result->getCategories());
     }
     if (isset($prop['categorieshtml'])) {
         $categoriesHtml = $this->categoriesHtml($p_result->getCategories());
         $result_array['categorieshtml'] = array();
         $result->setContent($result_array['categorieshtml'], $categoriesHtml);
     }
     if (isset($prop['links'])) {
         $result_array['links'] = $this->formatLinks($p_result->getLinks());
     }
     if (isset($prop['templates'])) {
         $result_array['templates'] = $this->formatLinks($p_result->getTemplates());
     }
     if (isset($prop['images'])) {
         $result_array['images'] = array_keys($p_result->getImages());
     }
     if (isset($prop['externallinks'])) {
         $result_array['externallinks'] = array_keys($p_result->getExternalLinks());
     }
     if (isset($prop['sections'])) {
         $result_array['sections'] = $p_result->getSections();
     }
     if (isset($prop['displaytitle'])) {
         $result_array['displaytitle'] = $p_result->getDisplayTitle() ? $p_result->getDisplayTitle() : $titleObj->getPrefixedText();
     }
     if (isset($prop['headitems']) || isset($prop['headhtml'])) {
         $context = $this->getContext();
         $context->setTitle($titleObj);
         $context->getOutput()->addParserOutputNoText($p_result);
         if (isset($prop['headitems'])) {
             $headItems = $this->formatHeadItems($p_result->getHeadItems());
             $css = $this->formatCss($context->getOutput()->buildCssLinksArray());
             $scripts = array($context->getOutput()->getHeadScripts());
             $result_array['headitems'] = array_merge($headItems, $css, $scripts);
         }
         if (isset($prop['headhtml'])) {
             $result_array['headhtml'] = array();
             $result->setContent($result_array['headhtml'], $context->getOutput()->headElement($context->getSkin()));
         }
     }
     if (isset($prop['iwlinks'])) {
         $result_array['iwlinks'] = $this->formatIWLinks($p_result->getInterwikiLinks());
     }
     if (isset($prop['wikitext'])) {
         $result_array['wikitext'] = array();
         $result->setContent($result_array['wikitext'], $this->content->serialize($format));
         if (!is_null($this->pstContent)) {
             $result_array['psttext'] = array();
             $result->setContent($result_array['psttext'], $this->pstContent->serialize($format));
         }
     }
     if (isset($prop['properties'])) {
         $result_array['properties'] = $this->formatProperties($p_result->getProperties());
     }
     if ($params['generatexml']) {
         if ($this->content->getModel() != CONTENT_MODEL_WIKITEXT) {
             $this->dieUsage("generatexml is only supported for wikitext content", "notwikitext");
         }
         $wgParser->startExternalParse($titleObj, $popts, OT_PREPROCESS);
         $dom = $wgParser->preprocessToDom($this->content->getNativeData());
         if (is_callable(array($dom, 'saveXML'))) {
             $xml = $dom->saveXML();
         } else {
             $xml = $dom->__toString();
         }
         $result_array['parsetree'] = array();
         $result->setContent($result_array['parsetree'], $xml);
     }
     $result_mapping = array('redirects' => 'r', 'langlinks' => 'll', 'categories' => 'cl', 'links' => 'pl', 'templates' => 'tl', 'images' => 'img', 'externallinks' => 'el', 'iwlinks' => 'iw', 'sections' => 's', 'headitems' => 'hi', 'properties' => 'pp');
     $this->setIndexedTagNames($result_array, $result_mapping);
     $result->addValue(null, $this->getModuleName(), $result_array);
     if (!is_null($oldLang)) {
         $this->getContext()->setLanguage($oldLang);
         // Reset language to $oldLang
     }
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:101,代码来源:ApiParse.php

示例4: execute


//.........这里部分代码省略.........
     }
     if (isset($prop['categorieshtml'])) {
         $result_array['categorieshtml'] = $this->categoriesHtml($p_result->getCategories());
         $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'categorieshtml';
     }
     if (isset($prop['links'])) {
         $result_array['links'] = $this->formatLinks($p_result->getLinks());
     }
     if (isset($prop['templates'])) {
         $result_array['templates'] = $this->formatLinks($p_result->getTemplates());
     }
     if (isset($prop['images'])) {
         $result_array['images'] = array_keys($p_result->getImages());
     }
     if (isset($prop['externallinks'])) {
         $result_array['externallinks'] = array_keys($p_result->getExternalLinks());
     }
     if (isset($prop['sections'])) {
         $result_array['sections'] = $p_result->getSections();
     }
     if (isset($prop['displaytitle'])) {
         $result_array['displaytitle'] = $p_result->getDisplayTitle() ? $p_result->getDisplayTitle() : $titleObj->getPrefixedText();
     }
     if (isset($prop['headitems']) || isset($prop['headhtml'])) {
         $context = $this->getContext();
         $context->setTitle($titleObj);
         $context->getOutput()->addParserOutputMetadata($p_result);
         if (isset($prop['headitems'])) {
             $headItems = $this->formatHeadItems($p_result->getHeadItems());
             $css = $this->formatCss($context->getOutput()->buildCssLinksArray());
             $scripts = array($context->getOutput()->getHeadScripts());
             $result_array['headitems'] = array_merge($headItems, $css, $scripts);
         }
         if (isset($prop['headhtml'])) {
             $result_array['headhtml'] = $context->getOutput()->headElement($context->getSkin());
             $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
         }
     }
     if (isset($prop['modules'])) {
         $result_array['modules'] = array_values(array_unique($p_result->getModules()));
         $result_array['modulescripts'] = array_values(array_unique($p_result->getModuleScripts()));
         $result_array['modulestyles'] = array_values(array_unique($p_result->getModuleStyles()));
         // To be removed in 1.27
         $result_array['modulemessages'] = array();
         $this->setWarning('modulemessages is deprecated since MediaWiki 1.26');
     }
     if (isset($prop['jsconfigvars'])) {
         $result_array['jsconfigvars'] = ApiResult::addMetadataToResultVars($p_result->getJsConfigVars());
     }
     if (isset($prop['encodedjsconfigvars'])) {
         $result_array['encodedjsconfigvars'] = FormatJson::encode($p_result->getJsConfigVars(), false, FormatJson::ALL_OK);
         $result_array[ApiResult::META_SUBELEMENTS][] = 'encodedjsconfigvars';
     }
     if (isset($prop['modules']) && !isset($prop['jsconfigvars']) && !isset($prop['encodedjsconfigvars'])) {
         $this->setWarning("Property 'modules' was set but not 'jsconfigvars' " . "or 'encodedjsconfigvars'. Configuration variables are necessary " . "for proper module usage.");
     }
     if (isset($prop['indicators'])) {
         $result_array['indicators'] = (array) $p_result->getIndicators();
         ApiResult::setArrayType($result_array['indicators'], 'BCkvp', 'name');
     }
     if (isset($prop['iwlinks'])) {
         $result_array['iwlinks'] = $this->formatIWLinks($p_result->getInterwikiLinks());
     }
     if (isset($prop['wikitext'])) {
         $result_array['wikitext'] = $this->content->serialize($format);
         $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'wikitext';
         if (!is_null($this->pstContent)) {
             $result_array['psttext'] = $this->pstContent->serialize($format);
             $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'psttext';
         }
     }
     if (isset($prop['properties'])) {
         $result_array['properties'] = (array) $p_result->getProperties();
         ApiResult::setArrayType($result_array['properties'], 'BCkvp', 'name');
     }
     if (isset($prop['limitreportdata'])) {
         $result_array['limitreportdata'] = $this->formatLimitReportData($p_result->getLimitReportData());
     }
     if (isset($prop['limitreporthtml'])) {
         $result_array['limitreporthtml'] = EditPage::getPreviewLimitReport($p_result);
         $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'limitreporthtml';
     }
     if (isset($prop['parsetree']) || $params['generatexml']) {
         if ($this->content->getModel() != CONTENT_MODEL_WIKITEXT) {
             $this->dieUsage("parsetree is only supported for wikitext content", "notwikitext");
         }
         $wgParser->startExternalParse($titleObj, $popts, Parser::OT_PREPROCESS);
         $dom = $wgParser->preprocessToDom($this->content->getNativeData());
         if (is_callable(array($dom, 'saveXML'))) {
             $xml = $dom->saveXML();
         } else {
             $xml = $dom->__toString();
         }
         $result_array['parsetree'] = $xml;
         $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree';
     }
     $result_mapping = array('redirects' => 'r', 'langlinks' => 'll', 'categories' => 'cl', 'links' => 'pl', 'templates' => 'tl', 'images' => 'img', 'externallinks' => 'el', 'iwlinks' => 'iw', 'sections' => 's', 'headitems' => 'hi', 'modules' => 'm', 'indicators' => 'ind', 'modulescripts' => 'm', 'modulestyles' => 'm', 'modulemessages' => 'm', 'properties' => 'pp', 'limitreportdata' => 'lr');
     $this->setIndexedTagNames($result_array, $result_mapping);
     $result->addValue(null, $this->getModuleName(), $result_array);
 }
开发者ID:huatuoorg,项目名称:mediawiki,代码行数:101,代码来源:ApiParse.php

示例5: contentToString

 /**
  * Converts the given Content object to a string.
  *
  * This uses Content::getNativeData() if $content is an instance of TextContent,
  * or Content::getTextForSearchIndex() otherwise.
  *
  * The hook 'AbuseFilter::contentToString' can be used to override this
  * behavior.
  *
  * @param Content $content
  *
  * @return string a suitable string representation of the content.
  */
 static function contentToString(Content $content)
 {
     $text = null;
     if (wfRunHooks('AbuseFilter-contentToString', array($content, &$text))) {
         $text = $content instanceof TextContent ? $content->getNativeData() : $content->getTextForSearchIndex();
     }
     if (is_string($text)) {
         // bug 20310
         // XXX: Is this really needed? Should we rather apply PST?
         $text = str_replace("\r\n", "\n", $text);
     } else {
         $text = '';
     }
     return $text;
 }
开发者ID:aahashderuffy,项目名称:extensions,代码行数:28,代码来源:AbuseFilter.class.php

示例6: serializeContent

 /**
  * Returns the content's text as-is.
  *
  * @param Content $content
  * @param string $format The serialization format to check
  *
  * @return mixed
  */
 public function serializeContent(Content $content, $format = null)
 {
     $this->checkFormat($format);
     return $content->getNativeData();
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:13,代码来源:TextContentHandler.php

示例7: diff

 /**
  * Diff this content object with another content object.
  *
  * @since 1.21
  *
  * @param Content $that The other content object to compare this content
  * object to.
  * @param Language $lang The language object to use for text segmentation.
  *    If not given, $wgContentLang is used.
  *
  * @return Diff A diff representing the changes that would have to be
  *    made to this content object to make it equal to $that.
  */
 public function diff(Content $that, Language $lang = null)
 {
     global $wgContLang;
     $this->checkModelID($that->getModel());
     // @todo could implement this in DifferenceEngine and just delegate here?
     if (!$lang) {
         $lang = $wgContLang;
     }
     $otext = $this->getNativeData();
     $ntext = $that->getNativeData();
     # Note: Use native PHP diff, external engines don't give us abstract output
     $ota = explode("\n", $lang->segmentForDiff($otext));
     $nta = explode("\n", $lang->segmentForDiff($ntext));
     $diff = new Diff($ota, $nta);
     return $diff;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:29,代码来源:TextContent.php

示例8: onArticleAfterFetchContentObject

 public static function onArticleAfterFetchContentObject(Article &$article, Content &$content)
 {
     $text = $content->getNativeData();
     $matches = null;
     $pattern = '/{{Tab(.*?)}}/ius';
     if (preg_match_all($pattern, $text, $matches)) {
         foreach ($matches[0] as $match) {
             if (strpos($match, '=')) {
                 $url = str_replace('=', '=', $match);
                 $text = str_replace($match, $url, $text);
             }
         }
     }
     $content = new WikitextContent($text);
     return true;
 }
开发者ID:xianyinchen,项目名称:MediaWiki-WikiEditor,代码行数:16,代码来源:WikiEditor.hooks.php


注:本文中的Content::getNativeData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。