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


PHP Sanitizer::decodeCharReferences方法代码示例

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


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

示例1: _stripMarkup

 /**
  * Strip markup to show plaintext
  * @param string $text
  * @return string
  * @access private
  */
 function _stripMarkup($text)
 {
     global $wgContLang;
     $text = substr($text, 0, 4096);
     // don't bother with long text...
     $text = str_replace("'''", "", $text);
     $text = str_replace("''", "", $text);
     $text = preg_replace('#__[a-z0-9_]+__#i', '', $text);
     // magic words
     $cleanChar = "[^|\\[\\]]";
     $subLink = "\\[\\[{$cleanChar}*(?:\\|{$cleanChar}*)*\\]\\]";
     $pipeContents = "(?:{$cleanChar}|{$subLink})*";
     $text = preg_replace_callback("#\n\t\t\t\\[\\[\n\t\t\t\t({$cleanChar}*)\n\t\t\t\t(?:\\|({$pipeContents}))?\n\t\t\t\t(?:\\|{$pipeContents})*\n\t\t\t\\]\\]\n\t\t\t#six", array($this, '_stripLink'), $text);
     $protocols = wfUrlProtocols();
     $text = preg_replace('#\\[(?:$protocols).*? (.*?)\\]#s', '$1', $text);
     // URL links
     $text = preg_replace('#</?[a-z0-9]+.*?>#s', '', $text);
     // HTML-style tags
     $text = preg_replace('#\\{\\|.*?\\|\\}#s', '', $text);
     // tables
     $text = preg_replace('#^:.*$#m', '', $text);
     // indented lines near start are usually disambigs or notices
     $text = Sanitizer::decodeCharReferences($text);
     return trim($text);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:31,代码来源:IndexAbstracts.php

示例2: generateDBKey

 private static function generateDBKey($title, $conn)
 {
     if (get_magic_quotes_gpc()) {
         $title = stripslashes($title);
     }
     $title = Sanitizer::decodeCharReferences($title);
     $title = mb_strtoupper(mb_substr($title, 0, 1)) . mb_substr($title, 1);
     return mysql_real_escape_string(str_replace(' ', '_', $title), $conn);
 }
开发者ID:k-hasan-19,项目名称:wiki,代码行数:9,代码来源:AutoCompleter.php

示例3: newFromText

 /**
  * static constructor, Create new Title from name of page
  */
 public static function newFromText($text, $namespace, $city_id)
 {
     $filteredText = Sanitizer::decodeCharReferences($text);
     $title = new GlobalTitle();
     $title->mText = $filteredText;
     $title->mDbkeyform = str_replace(' ', '_', $filteredText);
     $title->mUrlform = wfUrlencode($title->mDbkeyform);
     $title->mTextform = str_replace('_', ' ', $title->mText);
     $title->mNamespace = $namespace;
     $title->mCityId = $city_id;
     return $title;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:15,代码来源:GlobalTitle.php

示例4: escapeFragmentForURL

 /**
  * For compatibility with version < 1.9.0
  */
 static function escapeFragmentForURL($fragment)
 {
     global $mgVersion;
     if ($mgVersion < 10900) {
         $fragment = str_replace(' ', '_', $fragment);
         $fragment = urlencode(Sanitizer::decodeCharReferences($fragment));
         $replaceArray = array('%3A' => ':', '%2F' => '/', '%' => '.');
         return strtr($fragment, $replaceArray);
     } else {
         return Title::escapeFragmentForURL($fragment);
     }
 }
开发者ID:Avalanche85,项目名称:mw-extensions,代码行数:15,代码来源:MultiLanguageManager_body.php

示例5: getResultText

 protected function getResultText(SMWQueryResult $res, $outputmode)
 {
     $result = '';
     if ($outputmode == SMW_OUTPUT_FILE) {
         // make CSV file
         $csv = fopen('php://temp', 'r+');
         if ($this->mShowHeaders) {
             $header_items = array();
             foreach ($res->getPrintRequests() as $pr) {
                 $header_items[] = $pr->getLabel();
             }
             fputcsv($csv, $header_items, $this->m_sep);
         }
         while ($row = $res->getNext()) {
             $row_items = array();
             foreach ($row as $field) {
                 $growing = array();
                 while (($object = $field->getNextDataValue()) !== false) {
                     $growing[] = Sanitizer::decodeCharReferences($object->getWikiValue());
                 }
                 $row_items[] = implode(',', $growing);
             }
             fputcsv($csv, $row_items, $this->m_sep);
         }
         rewind($csv);
         $result .= stream_get_contents($csv);
     } else {
         // just make link to feed
         if ($this->getSearchLabel($outputmode)) {
             $label = $this->getSearchLabel($outputmode);
         } else {
             $label = wfMsgForContent('smw_csv_link');
         }
         $link = $res->getQueryLink($label);
         $link->setParameter('csv', 'format');
         $link->setParameter($this->m_sep, 'sep');
         if (array_key_exists('mainlabel', $this->params) && $this->params['mainlabel'] !== false) {
             $link->setParameter($this->params['mainlabel'], 'mainlabel');
         }
         $link->setParameter($this->mShowHeaders ? 'show' : 'hide', 'headers');
         if (array_key_exists('limit', $this->params)) {
             $link->setParameter($this->params['limit'], 'limit');
         } else {
             // use a reasonable default limit
             $link->setParameter(100, 'limit');
         }
         $result .= $link->getText($outputmode, $this->mLinker);
         $this->isHTML = $outputmode == SMW_OUTPUT_HTML;
         // yes, our code can be viewed as HTML if requested, no more parsing needed
     }
     return $result;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:52,代码来源:SMW_QP_CSV.php

示例6: parseResponse

 protected function parseResponse(TranslationQueryResponse $reply)
 {
     $body = $reply->getBody();
     $response = FormatJson::decode($body);
     if (!is_object($response)) {
         throw new TranslationWebServiceException('Invalid json: ' . serialize($body));
     } elseif ($response->code !== 200) {
         throw new TranslationWebServiceException($response->message);
     }
     $text = Sanitizer::decodeCharReferences($response->text[0]);
     $text = $this->unwrapUntranslatable($text);
     return trim($text);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:13,代码来源:YandexWebService.php

示例7: getName

 /**
  * Return the original filename of the uploaded file
  *
  * @return string|null Filename or null if non-existent
  */
 public function getName()
 {
     if (!$this->exists()) {
         return null;
     }
     global $wgContLang;
     $name = $this->fileInfo['name'];
     # Safari sends filenames in HTML-encoded Unicode form D...
     # Horrid and evil! Let's try to make some kind of sense of it.
     $name = Sanitizer::decodeCharReferences($name);
     $name = $wgContLang->normalize($name);
     wfDebug(__METHOD__ . ": {$this->fileInfo['name']} normalized to '{$name}'\n");
     return $name;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:19,代码来源:WebRequestUpload.php

示例8: newFromText

 /**
  * @desc Static constructor, Create new Title from name of page
  *
  * @param String $text
  * @param Integer $namespace (default NS_MAIN)
  * @param Integer|null $city_id a wiki id; we allow null because of compatibility with Title::newFromText()
  *
  * @throws Exception when $city_id parameter is null
  *
  * @return GlobalTitle
  */
 public static function newFromText($text, $namespace = NS_MAIN, $city_id = null)
 {
     if ($city_id === null) {
         // we allow to pass null in the method definition because of Strict Compatibility with Title::newFromText()
         throw new \Exception('Invalid $city_id.');
     }
     $filteredText = Sanitizer::decodeCharReferences($text);
     $title = new GlobalTitle();
     $title->mText = $filteredText;
     $title->mDbkeyform = str_replace(' ', '_', $filteredText);
     $title->mUrlform = wfUrlencode($title->mDbkeyform);
     $title->mTextform = str_replace('_', ' ', $title->mText);
     $title->mNamespace = $namespace;
     $title->mCityId = $city_id;
     return $title;
 }
开发者ID:yusufchang,项目名称:app,代码行数:27,代码来源:GlobalTitle.php

示例9: processRow

 protected function processRow($row)
 {
     global $wgContLang;
     $source = $row->img_name;
     // do nothing for videos, regardless of anything else
     if ('VIDEO' == $row->img_media_type && 'video' == $row->img_major_mime && 'swf' == $row->img_minor_mime) {
         $this->log("omitting video row '{$source}'");
         return $this->progress(0);
     }
     if ($source == '') {
         // Ye olde empty rows. Just kill them.
         $this->killRow($source);
         return $this->progress(1);
     }
     $cleaned = $source;
     // About half of old bad image names have percent-codes
     $cleaned = rawurldecode($cleaned);
     // We also have some HTML entities there
     $cleaned = Sanitizer::decodeCharReferences($cleaned);
     // Some are old latin-1
     $cleaned = $wgContLang->checkTitleEncoding($cleaned);
     // Many of remainder look like non-normalized unicode
     $cleaned = $wgContLang->normalize($cleaned);
     $title = Title::makeTitleSafe(NS_FILE, $cleaned);
     if (is_null($title)) {
         $this->output("page {$source} ({$cleaned}) is illegal.\n");
         $safe = $this->buildSafeTitle($cleaned);
         if ($safe === false) {
             return $this->progress(0);
         }
         $this->pokeFile($source, $safe);
         return $this->progress(1);
     }
     if ($title->getDBkey() !== $source) {
         $munged = $title->getDBkey();
         $this->output("page {$source} ({$munged}) doesn't match self.\n");
         $this->pokeFile($source, $munged);
         return $this->progress(1);
     }
     return $this->progress(0);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:41,代码来源:cleanupImages.php

示例10: handleRow

 protected function handleRow($row)
 {
     $template_params = array();
     $field_num = 0;
     foreach ($row as $field) {
         $field_num++;
         $key = $field->getPrintRequest()->getLabel();
         if (empty($key)) {
             $key = $field_num;
         }
         $value = array();
         while (($object = $field->getNextDataValue()) !== false) {
             $value[] = Sanitizer::decodeCharReferences($object->getWikiValue());
         }
         $template_params[$key] = $value;
     }
     if (isset($template_params['To']) && count($template_params['To']) > 0) {
         $data = array('title' => $this->pageTitle, 'params' => $template_params, 'template' => $this->params['template']);
         $row = $this->emailsTable->newRow($data);
         $row->save();
     }
 }
开发者ID:ATCARES,项目名称:SemanticMailMerge,代码行数:22,代码来源:ResultFormat.php

示例11: categoryLinkHook

 static function categoryLinkHook($parser, $holders, $markers, Title $title, $titleText, &$sortText = null, &$leadingColon = false)
 {
     global $wgContLang;
     # When a category link starts with a : treat it as a normal link
     if ($leadingColon) {
         return true;
     }
     if (isset($sortText) && $markers->findMarker($sortText)) {
         # There are links inside of the sortText
         # For backwards compatibility the deepest links are dominant so this
         # link should not be handled
         $sortText = $markers->expand($sortText);
         # Return false so that this link is reverted back to WikiText
         return false;
     }
     if (!isset($sortText)) {
         $sortText = $parser->getDefaultSort();
     }
     $sortText = Sanitizer::decodeCharReferences($sortText);
     $sortText = str_replace("\n", '', $sortText);
     $sortText = $wgContLang->convertCategoryKey($sortText);
     $parser->mOutput->addCategory($title->getDBkey(), $sortText);
     return '';
 }
开发者ID:rocLv,项目名称:conference,代码行数:24,代码来源:CoreLinkFunctions.php

示例12: processPage

 function processPage($row)
 {
     global $wgContLang;
     $source = $row->img_name;
     if ($source == '') {
         // Ye olde empty rows. Just kill them.
         $this->killRow($source);
         return $this->progress(1);
     }
     $cleaned = $source;
     // About half of old bad image names have percent-codes
     $cleaned = rawurldecode($cleaned);
     // We also have some HTML entities there
     $cleaned = Sanitizer::decodeCharReferences($cleaned);
     // Some are old latin-1
     $cleaned = $wgContLang->checkTitleEncoding($cleaned);
     // Many of remainder look like non-normalized unicode
     $cleaned = UtfNormal::cleanUp($cleaned);
     $title = Title::makeTitleSafe(NS_FILE, $cleaned);
     if (is_null($title)) {
         $this->log("page {$source} ({$cleaned}) is illegal.");
         $safe = $this->buildSafeTitle($cleaned);
         if ($safe === false) {
             return $this->progress(0);
         }
         $this->pokeFile($source, $safe);
         return $this->progress(1);
     }
     if ($title->getDBkey() !== $source) {
         $munged = $title->getDBkey();
         $this->log("page {$source} ({$munged}) doesn't match self.");
         $this->pokeFile($source, $munged);
         return $this->progress(1);
     }
     $this->progress(0);
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:36,代码来源:cleanupImages.php

示例13: createFormLink

 static function createFormLink(&$parser, $specialPageName, $params)
 {
     // Set defaults.
     $inFormName = $inLinkStr = $inLinkType = $inTooltip = $inQueryStr = $inTargetName = '';
     if ($specialPageName == 'RunQuery') {
         $inLinkStr = wfMessage('runquery')->text();
     }
     $classStr = "";
     $inQueryArr = array();
     $positionalParameters = false;
     // assign params
     // - support unlabelled params, for backwards compatibility
     // - parse and sanitize all parameter values
     foreach ($params as $i => $param) {
         $elements = explode('=', $param, 2);
         // set param_name and value
         if (count($elements) > 1 && !$positionalParameters) {
             $param_name = trim($elements[0]);
             // parse (and sanitize) parameter values
             $value = trim($parser->recursiveTagParse($elements[1]));
         } else {
             $param_name = null;
             // parse (and sanitize) parameter values
             $value = trim($parser->recursiveTagParse($param));
         }
         if ($param_name == 'form') {
             $inFormName = $value;
         } elseif ($param_name == 'link text') {
             $inLinkStr = $value;
         } elseif ($param_name == 'link type') {
             $inLinkType = $value;
         } elseif ($param_name == 'query string') {
             // Change HTML-encoded ampersands directly to
             // URL-encoded ampersands, so that the string
             // doesn't get split up on the '&'.
             $inQueryStr = str_replace('&amp;', '%26', $value);
             parse_str($inQueryStr, $arr);
             $inQueryArr = self::array_merge_recursive_distinct($inQueryArr, $arr);
         } elseif ($param_name == 'tooltip') {
             $inTooltip = Sanitizer::decodeCharReferences($value);
         } elseif ($param_name == 'target') {
             $inTargetName = $value;
         } elseif ($param_name == null && $value == 'popup') {
             self::loadScriptsForPopupForm($parser);
             $classStr = 'popupformlink';
         } elseif ($param_name !== null && !$positionalParameters) {
             $value = urlencode($value);
             parse_str("{$param_name}={$value}", $arr);
             $inQueryArr = self::array_merge_recursive_distinct($inQueryArr, $arr);
         } elseif ($i == 0) {
             $inFormName = $value;
             $positionalParameters = true;
         } elseif ($i == 1) {
             $inLinkStr = $value;
         } elseif ($i == 2) {
             $inLinkType = $value;
         } elseif ($i == 3) {
             // Change HTML-encoded ampersands directly to
             // URL-encoded ampersands, so that the string
             // doesn't get split up on the '&'.
             $inQueryStr = str_replace('&amp;', '%26', $value);
             parse_str($inQueryStr, $arr);
             $inQueryArr = self::array_merge_recursive_distinct($inQueryArr, $arr);
         }
     }
     $ad = SFUtils::getSpecialPage($specialPageName);
     $link_url = $ad->getTitle()->getLocalURL() . "/{$inFormName}";
     if (!empty($inTargetName)) {
         $link_url .= "/{$inTargetName}";
     }
     $link_url = str_replace(' ', '_', $link_url);
     $hidden_inputs = "";
     if (!empty($inQueryArr)) {
         // Special handling for the buttons - query string
         // has to be turned into hidden inputs.
         if ($inLinkType == 'button' || $inLinkType == 'post button') {
             $query_components = explode('&', http_build_query($inQueryArr, '', '&'));
             foreach ($query_components as $query_component) {
                 $var_and_val = explode('=', $query_component, 2);
                 if (count($var_and_val) == 2) {
                     $hidden_inputs .= Html::hidden(urldecode($var_and_val[0]), urldecode($var_and_val[1]));
                 }
             }
         } else {
             $link_url .= strstr($link_url, '?') ? '&' : '?';
             $link_url .= str_replace('+', '%20', http_build_query($inQueryArr, '', '&'));
         }
     }
     if ($inLinkType == 'button' || $inLinkType == 'post button') {
         $formMethod = $inLinkType == 'button' ? 'get' : 'post';
         $str = Html::rawElement('form', array('action' => $link_url, 'method' => $formMethod, 'class' => $classStr), '<button ' . Html::expandAttributes(array('type' => 'submit', 'value' => $inLinkStr)) . '>' . $inLinkStr . '</button>' . $hidden_inputs);
     } else {
         // If a target page has been specified but it doesn't
         // exist, make it a red link.
         if (!empty($inTargetName)) {
             $targetTitle = Title::newFromText($inTargetName);
             if (is_null($targetTitle) || !$targetTitle->exists()) {
                 $classStr .= " new";
             }
         }
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:SF_Utils.php

示例14: guessSectionNameFromWikiText

 /**
  * Try to guess the section anchor name based on a wikitext fragment
  * presumably extracted from a heading, for example "Header" from
  * "== Header ==".
  */
 public function guessSectionNameFromWikiText($text)
 {
     # Strip out wikitext links(they break the anchor)
     $text = $this->stripSectionName($text);
     $headline = Sanitizer::decodeCharReferences($text);
     # strip out HTML
     $headline = StringUtils::delimiterReplace('<', '>', '', $headline);
     $headline = trim($headline);
     $sectionanchor = '#' . urlencode(str_replace(' ', '_', $headline));
     $replacearray = array('%3A' => ':', '%' => '.');
     return str_replace(array_keys($replacearray), array_values($replacearray), $sectionanchor);
 }
开发者ID:josephdye,项目名称:wikireader,代码行数:17,代码来源:Parser.php

示例15: escapeFragmentForURL

 /**
  * Escape a text fragment, say from a link, for a URL
  */
 static function escapeFragmentForURL($fragment)
 {
     $fragment = str_replace(' ', '_', $fragment);
     $fragment = urlencode(Sanitizer::decodeCharReferences($fragment));
     $replaceArray = array('%3A' => ':', '%' => '.');
     return strtr($fragment, $replaceArray);
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:10,代码来源:Title.php


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