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


PHP StringUtils::delimiterReplace方法代码示例

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


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

示例1: formatLogEntry

 static function formatLogEntry($type, $action, $title, $sk, $parameters)
 {
     switch ($action) {
         case 'merge':
             if ($parameters[0]) {
                 $msg = 'lqt-log-action-merge-across';
             } else {
                 $msg = 'lqt-log-action-merge-down';
             }
             break;
         default:
             $msg = 'lqt-log-action-' . $action;
             break;
     }
     $options = array('parseinline');
     $forIRC = $sk === null;
     if ($forIRC) {
         global $wgContLang;
         $options['language'] = $wgContLang->getCode();
     }
     $replacements = array_merge(array($title->getPrefixedText()), $parameters);
     $html = wfMsgExt($msg, $options, $replacements);
     if ($forIRC) {
         $html = StringUtils::delimiterReplace('<', '>', '', $html);
     }
     return $html;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:27,代码来源:LogFormatter.php

示例2: 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;
}
开发者ID:renoirb,项目名称:mediawiki-1,代码行数:35,代码来源:SectionComments.php

示例3: formatLogEntry

 static function formatLogEntry($type, $action, $title, $sk, $parameters)
 {
     $msg = "lqt-log-action-{$action}";
     switch ($action) {
         case 'merge':
             if ($parameters[0]) {
                 $msg = 'lqt-log-action-merge-across';
             } else {
                 $msg = 'lqt-log-action-merge-down';
             }
             break;
         case 'move':
             $smt = new SpecialMoveThread();
             $rightsCheck = $smt->checkUserRights($parameters[1] instanceof Title ? $parameters[1] : Title::newFromText($parameters[1]), $parameters[0] instanceof Title ? $parameters[0] : Title::newFromText($parameters[0]));
             if ($rightsCheck === true) {
                 $parameters[] = Message::rawParam(Linker::link(SpecialPage::getTitleFor('MoveThread', $title), wfMessage('revertmove')->text(), array(), array('dest' => $parameters[0])));
             } else {
                 $parameters[] = '';
             }
             break;
         default:
             // Give grep a chance to find the usages:
             // lqt-log-action-move, lqt-log-action-split, lqt-log-action-subjectedit,
             // lqt-log-action-resort, lqt-log-action-signatureedit
             $msg = "lqt-log-action-{$action}";
             break;
     }
     array_unshift($parameters, $title->getPrefixedText());
     $html = wfMessage($msg, $parameters);
     if ($sk === null) {
         return StringUtils::delimiterReplace('<', '>', '', $html->inContentLanguage()->parse());
     }
     return $html->parse();
 }
开发者ID:Rikuforever,项目名称:wiki,代码行数:34,代码来源:LogFormatter.php

示例4: pre

 /**
  * Core parser tag hook function for 'pre'.
  * Text is treated roughly as 'nowiki' wrapped in an HTML 'pre' tag;
  * valid HTML attributes are passed on.
  *
  * @param string $text
  * @param array $attribs
  * @param Parser $parser
  * @return string HTML
  */
 public static function pre($text, $attribs, $parser)
 {
     // Backwards-compatibility hack
     $content = StringUtils::delimiterReplace('<nowiki>', '</nowiki>', '$1', $text, 'i');
     $attribs = Sanitizer::validateTagAttributes($attribs, 'pre');
     return Xml::openElement('pre', $attribs) . Xml::escapeTagsOnly($content) . '</pre>';
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:17,代码来源:CoreTagHooks.php

示例5: execute

 function execute($query)
 {
     global $wgRequest, $wgOut;
     $wgOut->disable();
     $this->setHeaders();
     $page_name = $query;
     $title = Title::newFromText($page_name);
     if (is_null($title)) {
         return;
     }
     if (!$title->userCan('read')) {
         return;
     }
     $article = new Article($title);
     $page_text = $article->fetchContent();
     // Remove <noinclude> sections and <includeonly> tags from text
     $page_text = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $page_text);
     $page_text = strtr($page_text, array('<includeonly>' => '', '</includeonly>' => ''));
     $orig_lines = explode("\n", $page_text);
     // ignore lines that are either blank or start with a semicolon
     $page_lines = array();
     foreach ($orig_lines as $i => $line) {
         if ($line != '' && $line[0] != ';') {
             $page_lines[] = $line;
         }
     }
     $headers = EDUtils::getValuesFromCSVLine($page_lines[0]);
     $queried_headers = array();
     foreach ($wgRequest->getValues() as $key => $value) {
         foreach ($headers as $header_index => $header_value) {
             $header_value = str_replace(' ', '_', $header_value);
             if ($key == $header_value) {
                 $queried_headers[$header_index] = $value;
             }
         }
     }
     // include header in output
     $text = $page_lines[0];
     foreach ($page_lines as $i => $line) {
         if ($i == 0) {
             continue;
         }
         $row_values = EDUtils::getValuesFromCSVLine($line);
         $found_match = true;
         foreach ($queried_headers as $i => $query_value) {
             $single_value = str_replace(' ', '_', $row_values[$i]);
             if ($single_value != $query_value) {
                 $found_match = false;
             }
         }
         if ($found_match) {
             if ($text != '') {
                 $text .= "\n";
             }
             $text .= $line;
         }
     }
     print $text;
 }
开发者ID:wjamn,项目名称:mediawiki-extensions-ExternalData,代码行数:59,代码来源:ED_GetData.php

示例6: pre

 /**
  * Core parser tag hook function for 'pre'.
  * Text is treated roughly as 'nowiki' wrapped in an HTML 'pre' tag;
  * valid HTML attributes are passed on.
  *
  * @param string $text
  * @param array $attribs
  * @param Parser $parser
  * @return string HTML
  */
 public static function pre($text, $attribs, $parser)
 {
     // Backwards-compatibility hack
     $content = StringUtils::delimiterReplace('<nowiki>', '</nowiki>', '$1', $text, 'i');
     $attribs = Sanitizer::validateTagAttributes($attribs, 'pre');
     // We need to let both '"' and '&' through,
     // for strip markers and entities respectively.
     $content = str_replace(['>', '<'], ['&gt;', '&lt;'], $content);
     return Html::rawElement('pre', $attribs, $content);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:20,代码来源:CoreTagHooks.php

示例7: showFormPreview

 /**
  * Appends a preview of the actual form, when a page in the "Form"
  * namespace is previewed.
  *
  * @author Solitarius
  * @since 2.4
  *
  * @param EditPage $editpage
  * @param WebRequest $request
  *
  * @return true
  */
 public static function showFormPreview(EditPage $editpage, WebRequest $request)
 {
     global $wgOut, $sfgFormPrinter;
     wfDebug(__METHOD__ . ": enter.\n");
     wfProfileIn(__METHOD__);
     // Exit if we're not in preview mode.
     if (!$editpage->preview) {
         wfProfileOut(__METHOD__);
         return true;
     }
     // Exit if we aren't in the "Form" namespace.
     if ($editpage->getArticle()->getTitle()->getNamespace() != SF_NS_FORM) {
         wfProfileOut(__METHOD__);
         return true;
     }
     $editpage->previewTextAfterContent .= Html::element('h2', null, wfMessage('sf-preview-header')->text()) . "\n" . '<div class="previewnote" style="font-weight: bold">' . $wgOut->parse(wfMessage('sf-preview-note')->text()) . "</div>\n<hr />\n";
     $form_definition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $editpage->textbox1);
     list($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) = $sfgFormPrinter->formHTML($form_definition, null, false, null, null, "Semantic Forms form preview dummy title", null);
     SFUtils::addJavascriptAndCSS();
     $editpage->previewTextAfterContent .= '<div style="margin-top: 15px">' . $form_text . "</div>";
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:35,代码来源:SF_Utils.php

示例8: printForm

 private function printForm(&$parameters, WebRequest &$request)
 {
     global $wgOut, $sfgFormPrinter;
     // Prepare parameters for SFFormPrinter::formHTML
     // there is no ONE target page
     $targetTitle = null;
     // formDefinition
     $formName = $request->getText('form');
     // if query string did not contain these variables, try the URL
     if ($formName === '') {
         $queryparts = explode('/', $parameters);
         $formName = isset($queryparts[0]) ? $queryparts[0] : null;
         // if the form name wasn't in the URL either, throw an error
         if (is_null($formName) || $formName === '') {
             throw new SPSException(SPSUtils::buildMessage('spserror-noformname'));
         }
     }
     $formTitle = Title::makeTitleSafe(SF_NS_FORM, $formName);
     if (!$formTitle->exists()) {
         throw new SPSException(SPSUtils::buildMessage('spserror-formunknown', $formName));
     }
     $formArticle = new Article($formTitle);
     $formDefinition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $formArticle->getContent());
     // formSubmitted
     $formSubmitted = false;
     // pageContents
     $pageContents = null;
     // get 'preload' query value, if it exists
     if ($request->getCheck('preload')) {
         $pageContents = SFFormUtils::getPreloadedText($request->getVal('preload'));
     } else {
         // let other extensions preload the page, if they want
         wfRunHooks('sfEditFormPreloadText', array(&$pageContents, $targetTitle, $formTitle));
     }
     // pageIsSource
     $pageIsSource = $pageContents != null;
     // pageNameFormula
     // parse the form to see if it has a 'page name' value set
     $matches;
     if (preg_match('/{{{info.*page name\\s*=\\s*(.*)}}}/m', $formDefinition, $matches)) {
         $pageNameElements = SFUtils::getFormTagComponents($matches[1]);
         $pageNameFormula = $pageNameElements[0];
     } else {
         return 'sf_formedit_badurl';
     }
     // get the iterator parameters
     $iteratorData = $this->buildIteratorParameters($request);
     // Call SFFormPrinter::formHTML
     list($formText, $javascriptText, $dataText, $formPageTitle, $generatedPageName) = $sfgFormPrinter->formHTML($formDefinition, $formSubmitted, $pageIsSource, $formArticle->getID(), $pageContents, '', $pageNameFormula);
     // Set Special page main header;
     // override the default title for this page if a title was specified in the form
     if ($formPageTitle != null) {
         $wgOut->setPageTitle($formPageTitle);
     } else {
         $wgOut->setPageTitle(SPSUtils::buildMessage('sf_formedit_createtitlenotarget', $formTitle->getText()));
     }
     $preFormHtml = '';
     wfRunHooks('sfHTMLBeforeForm', array(&$targetTitle, &$preFormHtml));
     $text = '<form name="createbox" id="sfForm" action="" method="post" class="createbox">' . $preFormHtml . "\n" . SFFormUtils::hiddenFieldHTML('iteratordata', $iteratorData) . $formText;
     SFUtils::addJavascriptAndCSS();
     if (!empty($javascriptText)) {
         $wgOut->addScript('		<script type="text/javascript">' . "\n{$javascriptText}\n" . '</script>' . "\n");
     }
     $wgOut->addHTML($text);
     return null;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:66,代码来源:SPSSpecialSeriesEdit.php

示例9: getAllFieldsCargo

 function getAllFieldsCargo($templateTitle)
 {
     $cargoFieldsOfTemplateParams = array();
     $templateFields = array();
     // First, get the table name, and fields, declared for this
     // template.
     $templatePageID = $templateTitle->getArticleID();
     $tableSchemaString = CargoUtils::getPageProp($templatePageID, 'CargoFields');
     // See if there even is DB storage for this template - if not,
     // exit.
     if (is_null($tableSchemaString)) {
         return null;
     }
     $tableSchema = CargoTableSchema::newFromDBString($tableSchemaString);
     $tableName = CargoUtils::getPageProp($templatePageID, 'CargoTableName');
     // Then, match template params to Cargo table fields, by
     // parsing call(s) to #cargo_store.
     $templateText = SFUtils::getPageText($templateTitle);
     // Ignore 'noinclude' sections and 'includeonly' tags.
     $templateText = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $templateText);
     $templateText = strtr($templateText, array('<includeonly>' => '', '</includeonly>' => ''));
     // Let's find every #cargo_store tag.
     // Unfortunately, it doesn't seem possible to use a regexp
     // search for this, because it's hard to know which set of
     // double brackets represents the end of such a call. Instead,
     // we'll do some manual parsing.
     $cargoStoreLocations = array();
     $curPos = 0;
     while (true) {
         $newPos = strpos($templateText, "#cargo_store:", $curPos);
         if ($newPos === false) {
             break;
         }
         $curPos = $newPos + 13;
         $cargoStoreLocations[] = $curPos;
     }
     $cargoStoreCalls = array();
     foreach ($cargoStoreLocations as $locNum => $startPos) {
         $numUnclosedBrackets = 2;
         if ($locNum < count($cargoStoreLocations) - 1) {
             $lastPos = $cargoStoreLocations[$locNum + 1];
         } else {
             $lastPos = strlen($templateText) - 1;
         }
         $curCargoStoreCall = '';
         $curPos = $startPos;
         while ($curPos <= $lastPos) {
             $curChar = $templateText[$curPos];
             $curCargoStoreCall .= $curChar;
             if ($curChar == '}') {
                 $numUnclosedBrackets--;
             } elseif ($curChar == '{') {
                 $numUnclosedBrackets++;
             }
             if ($numUnclosedBrackets == 0) {
                 break;
             }
             $curPos++;
         }
         $cargoStoreCalls[] = $curCargoStoreCall;
     }
     foreach ($cargoStoreCalls as $cargoStoreCall) {
         if (preg_match_all('/([^|{]*?)=\\s*{{{([^|}]*)/mis', $cargoStoreCall, $matches)) {
             foreach ($matches[1] as $i => $cargoFieldName) {
                 $templateParameter = trim($matches[2][$i]);
                 $cargoFieldsOfTemplateParams[$templateParameter] = $cargoFieldName;
             }
         }
     }
     // Now, combine the two sets of information into an array of
     // SFTemplateFields objects.
     $fieldDescriptions = $tableSchema->mFieldDescriptions;
     foreach ($cargoFieldsOfTemplateParams as $templateParameter => $cargoField) {
         $templateField = SFTemplateField::create($templateParameter, $templateParameter);
         if (array_key_exists($cargoField, $fieldDescriptions)) {
             $fieldDescription = $fieldDescriptions[$cargoField];
             $templateField->setCargoFieldData($tableName, $cargoField, $fieldDescription);
         }
         $templateFields[] = $templateField;
     }
     return $templateFields;
 }
开发者ID:paladox,项目名称:mediawiki-extensions-SemanticForms,代码行数:82,代码来源:SF_TemplateInForm.php

示例10: doAction

 /**
  * Depending on the requested action this method will try to store/preview
  * the data in mOptions or retrieve the edit form.
  *
  * The form and target page will be available in mOptions after execution of
  * the method.
  *
  * Errors and warnings are logged in the API result under the 'errors' key.
  * The general request status is maintained in mStatus.
  *
  * @global $wgRequest
  * @global $wgOut
  * @global $sfgFormPrinter
  * @throws MWException
  */
 public function doAction()
 {
     global $wgOut, $wgRequest, $sfgFormPrinter;
     // if the wiki is read-only, do not save
     if (wfReadOnly()) {
         if ($this->mAction === self::ACTION_SAVE) {
             throw new MWException(wfMessage('sf_autoedit_readonly', wfReadOnlyReason())->parse());
         }
         // even if not saving notify client anyway. Might want to dislay a notice
         $this->logMessage(wfMessage('sf_autoedit_readonly', wfReadOnlyReason())->parse(), self::NOTICE);
     }
     // find the title of the form to be used
     $formTitle = $this->getFormTitle();
     // get the form content
     $formContent = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', WikiPage::factory($formTitle)->getRawText());
     // signals that the form was submitted
     // always true, else we would not be here
     $isFormSubmitted = $this->mAction === self::ACTION_SAVE || $this->mAction === self::ACTION_PREVIEW;
     // the article id of the form to be used
     $formArticleId = $formTitle->getArticleID();
     // source of the data is a page
     $isPageSource = true;
     // the name of the target page; might be empty when using the one-step-process
     $targetName = $this->mOptions['target'];
     // if the target page was not specified, try finding the page name formula
     // (Why is this not done in SFFormPrinter::formHTML?)
     if ($targetName === '') {
         // parse the form to see if it has a 'page name' value set
         if (preg_match('/{{{info.*page name\\s*=\\s*(.*)}}}/m', $formContent, $matches)) {
             $pageNameElements = SFUtils::getFormTagComponents($matches[1]);
             $targetNameFormula = $pageNameElements[0];
         } else {
             throw new MWException(wfMessage('sf_autoedit_notargetspecified')->parse());
         }
         $targetTitle = null;
     } else {
         $targetNameFormula = null;
         $targetTitle = Title::newFromText($targetName);
     }
     $preloadContent = '';
     // save $wgRequest for later restoration
     $oldRequest = $wgRequest;
     // preload data if not explicitly excluded and if the preload page exists
     if (!isset($this->mOptions['preload']) || $this->mOptions['preload'] !== false) {
         if (!isset($this->mOptions['preload']) || $this->mOptions['preload'] === true) {
             $preloadTitle = Title::newFromText($targetName);
         } else {
             $preloadTitle = Title::newFromText($this->mOptions['preload']);
         }
         if ($preloadTitle !== null && $preloadTitle->exists()) {
             // the content of the page that was specified to be used for preloading
             $preloadContent = WikiPage::factory($preloadTitle)->getRawText();
             wfRunHooks('sfEditFormPreloadText', array(&$preloadContent, $targetTitle, $formTitle));
             $isPageSource = true;
             // spoof $wgRequest for SFFormPrinter::formHTML
             $wgRequest = new FauxRequest($this->mOptions, true);
             // save wgOut for later restoration
             $oldOut = $wgOut;
             // spoof wgOut; if we took the general $wgOut some JS modules
             // might attach themselves twice and thus be called twice
             $wgOut = new OutputPage(RequestContext::getMain());
             // call SFFormPrinter::formHTML to get at the form html of the existing page
             list($formHTML, $formJS, $targetContent, $form_page_title, $generatedTargetNameFormula) = $sfgFormPrinter->formHTML($formContent, $isFormSubmitted, $isPageSource, $formArticleId, $preloadContent, $targetName, $targetNameFormula);
             // restore wgOut
             $wgOut = $oldOut;
             // parse the data to be preloaded from the form html of the
             // existing page
             $data = $this->parseDataFromHTMLFrag($formHTML);
             // and merge/overwrite it with the new data
             $this->mOptions = SFUtils::array_merge_recursive_distinct($data, $this->mOptions);
         } else {
             if (isset($this->mOptions['preload'])) {
                 $this->logMessage(wfMessage('sf_autoedit_invalidpreloadspecified', $this->mOptions['preload'])->parse(), self::WARNING);
             }
         }
     }
     // we already preloaded stuff for saving/previewing, do not do it again
     if ($this->mAction === self::ACTION_SAVE || $this->mAction === self::ACTION_PREVIEW) {
         $preloadContent = '';
         $isPageSource = false;
     }
     // spoof wgRequest for SFFormPrinter::formHTML
     $wgRequest = new FauxRequest($this->mOptions, true);
     // get wikitext for submitted data and form
     list($formHTML, $formJS, $targetContent, $generatedFormName, $generatedTargetNameFormula) = $sfgFormPrinter->formHTML($formContent, $isFormSubmitted, $isPageSource, $formArticleId, $preloadContent, $targetName, $targetNameFormula);
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:SF_AutoeditAPI.php

示例11: checkCss

    /**
     * Pick apart some CSS and check it for forbidden or unsafe structures.
     * Returns a sanitized string. This sanitized string will have
     * character references and escape sequences decoded and comments
     * stripped (unless it is itself one valid comment, in which case the value
     * will be passed through). If the input is just too evil, only a comment
     * complaining about evilness will be returned.
     *
     * Currently URL references, 'expression', 'tps' are forbidden.
     *
     * NOTE: Despite the fact that character references are decoded, the
     * returned string may contain character references given certain
     * clever input strings. These character references must
     * be escaped before the return value is embedded in HTML.
     *
     * @param string $value
     * @return string
     */
    static function checkCss($value)
    {
        // Decode character references like &#123;
        $value = Sanitizer::decodeCharReferences($value);
        // Decode escape sequences and line continuation
        // See the grammar in the CSS 2 spec, appendix D.
        // This has to be done AFTER decoding character references.
        // This means it isn't possible for this function to return
        // unsanitized escape sequences. It is possible to manufacture
        // input that contains character references that decode to
        // escape sequences that decode to character references, but
        // it's OK for the return value to contain character references
        // because the caller is supposed to escape those anyway.
        static $decodeRegex;
        if (!$decodeRegex) {
            $space = '[\\x20\\t\\r\\n\\f]';
            $nl = '(?:\\n|\\r\\n|\\r|\\f)';
            $backslash = '\\\\';
            $decodeRegex = "/ {$backslash}\n\t\t\t\t(?:\n\t\t\t\t\t({$nl}) |  # 1. Line continuation\n\t\t\t\t\t([0-9A-Fa-f]{1,6}){$space}? |  # 2. character number\n\t\t\t\t\t(.) | # 3. backslash cancelling special meaning\n\t\t\t\t\t() | # 4. backslash at end of string\n\t\t\t\t)/xu";
        }
        $value = preg_replace_callback($decodeRegex, array(__CLASS__, 'cssDecodeCallback'), $value);
        // Normalize Halfwidth and Fullwidth Unicode block that IE6 might treat as ascii
        $value = preg_replace_callback('/[!-[]-z]/u', function ($matches) {
            $cp = utf8ToCodepoint($matches[0]);
            if ($cp === false) {
                return '';
            }
            return chr($cp - 65248);
            // ASCII range \x21-\x7A
        }, $value);
        // Convert more characters IE6 might treat as ascii
        // U+0280, U+0274, U+207F, U+029F, U+026A, U+207D, U+208D
        $value = str_replace(array('ʀ', 'ɴ', 'ⁿ', 'ʟ', 'ɪ', '⁽', '₍'), array('r', 'n', 'n', 'l', 'i', '(', '('), $value);
        // Let the value through if it's nothing but a single comment, to
        // allow other functions which may reject it to pass some error
        // message through.
        if (!preg_match('! ^ \\s* /\\* [^*\\/]* \\*/ \\s* $ !x', $value)) {
            // Remove any comments; IE gets token splitting wrong
            // This must be done AFTER decoding character references and
            // escape sequences, because those steps can introduce comments
            // This step cannot introduce character references or escape
            // sequences, because it replaces comments with spaces rather
            // than removing them completely.
            $value = StringUtils::delimiterReplace('/*', '*/', ' ', $value);
            // Remove anything after a comment-start token, to guard against
            // incorrect client implementations.
            $commentPos = strpos($value, '/*');
            if ($commentPos !== false) {
                $value = substr($value, 0, $commentPos);
            }
        }
        // S followed by repeat, iteration, or prolonged sound marks,
        // which IE will treat as "ss"
        $value = preg_replace('/s(?:
				\\xE3\\x80\\xB1 | # U+3031
				\\xE3\\x82\\x9D | # U+309D
				\\xE3\\x83\\xBC | # U+30FC
				\\xE3\\x83\\xBD | # U+30FD
				\\xEF\\xB9\\xBC | # U+FE7C
				\\xEF\\xB9\\xBD | # U+FE7D
				\\xEF\\xBD\\xB0   # U+FF70
			)/ix', 'ss', $value);
        // Reject problematic keywords and control characters
        if (preg_match('/[\\000-\\010\\013\\016-\\037\\177]/', $value)) {
            return '/* invalid control char */';
        } elseif (preg_match('! expression
				| filter\\s*:
				| accelerator\\s*:
				| -o-link\\s*:
				| -o-link-source\\s*:
				| -o-replace\\s*:
				| url\\s*\\(
				| image\\s*\\(
				| image-set\\s*\\(
			!ix', $value)) {
            return '/* insecure input */';
        }
        return $value;
    }
开发者ID:krinkle,项目名称:toollabs-base,代码行数:97,代码来源:Sanitizer.php

示例12: formSerialize

 public function formSerialize($form_def = '', $source_is_page = false, $existing_page_content = null, $page_title = null)
 {
     //	public function formSerialize($form_def, $source_is_page, $existing_page_content = null, $page_title = null, $page_name_formula = null) {
     global $wgRequest, $wgUser, $wgParser;
     global $sfgTabIndex;
     // used to represent the current tab index in the form
     global $sfgFieldNum;
     // used for setting various HTML IDs
     global $sfgJSValidationCalls;
     // array of Javascript calls to determine if page can be saved
     # define a var for all fields
     $__fields = array();
     // initialize some variables
     $sfgTabIndex = 1;
     $sfgFieldNum = 1;
     $source_page_matches_this_form = false;
     $form_page_title = NULL;
     // $form_is_partial is true if:
     // (a) 'partial' == 1 in the arguments
     // (b) 'partial form' is found in the form definition
     // in the latter case, it may remain false until close to the end of
     // the parsing, so we have to assume that it will become a possibility
     $form_is_partial = false;
     $new_text = "";
     // if we have existing content and we're not in an active replacement
     // situation, preserve the original content. We do this because we want
     // to pass the original content on IF this is a partial form
     // TODO: A better approach here would be to pass the revision id of the
     // existing page content through the replace value, which would
     // minimize the html traffic and would allow us to do a concurrent
     // update check.  For now, we pass it through the hidden text field...
     if (!$wgRequest->getCheck('partial')) {
         $original_page_content = $existing_page_content;
     } else {
         $original_page_content = null;
         if ($wgRequest->getCheck('free_text')) {
             $existing_page_content = $wgRequest->getVal('free_text');
             $form_is_partial = true;
         }
     }
     // disable all form elements if user doesn't have edit permission -
     // two different checks are needed, because editing permissions can be
     // set in different ways
     // HACK - sometimes we don't know the page name in advance, but we still
     // need to set a title here for testing permissions
     if ($page_title == '') {
         $this->mPageTitle = Title::newFromText("Semantic Forms permissions test");
     } else {
         $this->mPageTitle = Title::newFromText($page_title);
     }
     if ($wgUser->isAllowed('edit') && $this->mPageTitle->userCanEdit()) {
         $form_is_disabled = false;
         $form_text = "";
         // show "Your IP address will be recorded" warning if user is
         // anonymous - wikitext for bolding has to be replaced with HTML
         if ($wgUser->isAnon()) {
             $anon_edit_warning = preg_replace("/'''(.*)'''/", "<strong>\$1</strong>", wfMsg('anoneditwarning'));
             $form_text .= "<p>{$anon_edit_warning}</p>\n";
         }
     } else {
         $form_is_disabled = true;
         // display a message to the user explaining why they can't edit the
         // page - borrowed heavily from EditPage.php
         if ($wgUser->isAnon()) {
             $skin = $wgUser->getSkin();
             $loginTitle = SpecialPage::getTitleFor('Userlogin');
             $loginLink = $skin->makeKnownLinkObj($loginTitle, wfMsgHtml('loginreqlink'));
             $form_text = wfMsgWikiHtml('whitelistedittext', $loginLink);
         } else {
             $form_text = wfMsg('protectedpagetext');
         }
     }
     $javascript_text = "";
     $sfgJSValidationCalls = array();
     $fields_javascript_text = "";
     // Remove <noinclude> sections and <includeonly> tags from form definition
     $form_def = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $form_def);
     $form_def = strtr($form_def, array('<includeonly>' => '', '</includeonly>' => ''));
     // parse wiki-text
     // add '<nowiki>' tags around every triple-bracketed form definition
     // element, so that the wiki parser won't touch it - the parser will
     // remove the '<nowiki>' tags, leaving us with what we need
     global $sfgDisableWikiTextParsing;
     if (!$sfgDisableWikiTextParsing) {
         $form_def = "__NOEDITSECTION__" . strtr($form_def, array('{{{' => '<nowiki>{{{', '}}}' => '}}}</nowiki>'));
         $wgParser->mOptions = new ParserOptions();
         $wgParser->mOptions->initialiseFromUser($wgUser);
         $form_def = $wgParser->parse($form_def, $this->mPageTitle, $wgParser->mOptions)->getText();
     }
     // turn form definition file into an array of sections, one for each
     // template definition (plus the first section)
     $form_def_sections = array();
     $start_position = 0;
     $section_start = 0;
     $free_text_was_included = false;
     $free_text_preload_page = null;
     $all_values_for_template = array();
     // unencode and HTML-encoded representations of curly brackets and
     // pipes - this is a hack to allow for forms to include templates
     // that themselves contain form elements - the escaping is needed
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:SF_DataAPI.php

示例13: stripSectionName

 /**
  * Strips a text string of wikitext for use in a section anchor
  *
  * Accepts a text string and then removes all wikitext from the
  * string and leaves only the resultant text (i.e. the result of
  * [[User:WikiSysop|Sysop]] would be "Sysop" and the result of
  * [[User:WikiSysop]] would be "User:WikiSysop") - this is intended
  * to create valid section anchors by mimicing the output of the
  * parser when headings are parsed.
  *
  * @param string $text text string to be stripped of wikitext
  * for use in a Section anchor
  * @return string Filtered text string
  */
 public function stripSectionName($text)
 {
     # Strip internal link markup
     $text = preg_replace('/\\[\\[:?([^[|]+)\\|([^[]+)\\]\\]/', '$2', $text);
     $text = preg_replace('/\\[\\[:?([^[]+)\\|?\\]\\]/', '$1', $text);
     # Strip external link markup
     # @todo FIXME: Not tolerant to blank link text
     # I.E. [https://www.mediawiki.org] will render as [1] or something depending
     # on how many empty links there are on the page - need to figure that out.
     $text = preg_replace('/\\[(?i:' . $this->mUrlProtocols . ')([^ ]+?) ([^[]+)\\]/', '$2', $text);
     # Parse wikitext quotes (italics & bold)
     $text = $this->doQuotes($text);
     # Strip HTML tags
     $text = StringUtils::delimiterReplace('<', '>', '', $text);
     return $text;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:30,代码来源:Parser.php

示例14: getAllFields

 /**
  * Get the fields of the template, along with the semantic property
  * attached to each one (if any), by parsing the text of the template.
  */
 function getAllFields()
 {
     global $wgContLang;
     $templateFields = array();
     $fieldNamesArray = array();
     // The way this works is that fields are found and then stored
     // in an array based on their location in the template text, so
     // that they can be returned in the order in which they appear
     // in the template, not the order in which they were found.
     // Some fields can be found more than once (especially if
     // they're part of an "#if" statement), so they're only
     // recorded the first time they're found.
     $template_title = Title::makeTitleSafe(NS_TEMPLATE, $this->mTemplateName);
     $template_article = null;
     if (isset($template_title)) {
         $template_article = new Article($template_title, 0);
     }
     if (isset($template_article)) {
         $templateText = $template_article->getContent();
         // Ignore 'noinclude' sections and 'includeonly' tags.
         $templateText = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $templateText);
         $templateText = strtr($templateText, array('<includeonly>' => '', '</includeonly>' => ''));
         // First, look for "arraymap" parser function calls
         // that map a property onto a list.
         if ($ret = preg_match_all('/{{#arraymap:{{{([^|}]*:?[^|}]*)[^\\[]*\\[\\[([^:]*:?[^:]*)::/mis', $templateText, $matches)) {
             foreach ($matches[1] as $i => $field_name) {
                 if (!in_array($field_name, $fieldNamesArray)) {
                     $propertyName = $matches[2][$i];
                     $this->handlePropertySettingInTemplate($field_name, $propertyName, true, $templateFields, $templateText);
                     $fieldNamesArray[] = $field_name;
                 }
             }
         } elseif ($ret === false) {
             // There was an error in the preg_match_all()
             // call - let the user know about it.
             if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
                 print 'Semantic Forms error: backtrace limit exceeded during parsing! Please increase the value of <a href="http://www.php.net/manual/en/pcre.configuration.php#ini.pcre.backtrack-limit">pcre.backtrack-limit</a> in the PHP settings.';
             }
         }
         // Second, look for normal property calls.
         if (preg_match_all('/\\[\\[([^:|\\[\\]]*:*?[^:|\\[\\]]*)::{{{([^\\]\\|}]*).*?\\]\\]/mis', $templateText, $matches)) {
             foreach ($matches[1] as $i => $propertyName) {
                 $field_name = trim($matches[2][$i]);
                 if (!in_array($field_name, $fieldNamesArray)) {
                     $propertyName = trim($propertyName);
                     $this->handlePropertySettingInTemplate($field_name, $propertyName, false, $templateFields, $templateText);
                     $fieldNamesArray[] = $field_name;
                 }
             }
         }
         // Then, get calls to #set and #set_internal
         // (thankfully, they have basically the same syntax).
         if (preg_match_all('/#(set|set_internal):(.*?}}})\\s*}}/mis', $templateText, $matches)) {
             foreach ($matches[2] as $match) {
                 if (preg_match_all('/([^|{]*?)=\\s*{{{([^|}]*)/mis', $match, $matches2)) {
                     foreach ($matches2[1] as $i => $propertyName) {
                         $fieldName = trim($matches2[2][$i]);
                         if (!in_array($fieldName, $fieldNamesArray)) {
                             $propertyName = trim($propertyName);
                             $this->handlePropertySettingInTemplate($fieldName, $propertyName, false, $templateFields, $templateText);
                             $fieldNamesArray[] = $fieldName;
                         }
                     }
                 }
             }
         }
         // Then, get calls to #declare.
         if (preg_match_all('/#declare:(.*?)}}/mis', $templateText, $matches)) {
             foreach ($matches[1] as $match) {
                 $setValues = explode('|', $match);
                 foreach ($setValues as $valuePair) {
                     $keyAndVal = explode('=', $valuePair);
                     if (count($keyAndVal) == 2) {
                         $propertyName = trim($keyAndVal[0]);
                         $fieldName = trim($keyAndVal[1]);
                         if (!in_array($fieldName, $fieldNamesArray)) {
                             $this->handlePropertySettingInTemplate($fieldName, $propertyName, false, $templateFields, $templateText);
                             $fieldNamesArray[] = $fieldName;
                         }
                     }
                 }
             }
         }
         // Finally, get any non-semantic fields defined.
         if (preg_match_all('/{{{([^|}]*)/mis', $templateText, $matches)) {
             foreach ($matches[1] as $fieldName) {
                 $fieldName = trim($fieldName);
                 if (!empty($fieldName) && !in_array($fieldName, $fieldNamesArray)) {
                     $cur_pos = stripos($templateText, $fieldName);
                     $templateFields[$cur_pos] = SFTemplateField::create($fieldName, $wgContLang->ucfirst($fieldName));
                     $fieldNamesArray[] = $fieldName;
                 }
             }
         }
     }
     ksort($templateFields);
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:SF_TemplateInForm.php

示例15: compute

 function compute($vars)
 {
     $parameters = $this->mParameters;
     $result = null;
     switch ($this->mMethod) {
         case 'diff':
             $text1Var = $parameters['oldtext-var'];
             $text2Var = $parameters['newtext-var'];
             $text1 = $vars->getVar($text1Var)->toString();
             $text2 = $vars->getVar($text2Var)->toString();
             $result = wfDiff($text1, $text2);
             $result = trim(preg_replace("/^\\\\ No newline at end of file\n/m", '', $result));
             break;
         case 'diff-split':
             $diff = $vars->getVar($parameters['diff-var'])->toString();
             $line_prefix = $parameters['line-prefix'];
             $diff_lines = explode("\n", $diff);
             $interest_lines = array();
             foreach ($diff_lines as $line) {
                 if (substr($line, 0, 1) === $line_prefix) {
                     $interest_lines[] = substr($line, strlen($line_prefix));
                 }
             }
             $result = $interest_lines;
             break;
         case 'links-from-wikitext':
             // This should ONLY be used when sharing a parse operation with the edit.
             $article = $parameters['article'];
             if ($article) {
                 $textVar = $parameters['text-var'];
                 $new_text = $vars->getVar($textVar)->toString();
                 $editInfo = $article->prepareTextForEdit($new_text);
                 $links = array_keys($editInfo->output->getExternalLinks());
                 $result = $links;
                 break;
             }
             // Otherwise fall back to database
         // Otherwise fall back to database
         case 'links-from-wikitext-nonedit':
         case 'links-from-wikitext-or-database':
             $article = self::articleFromTitle($parameters['namespace'], $parameters['title']);
             if ($vars->getVar('context')->toString() == 'filter') {
                 $links = $this->getLinksFromDB($article);
                 wfDebug("AbuseFilter: loading old links from DB\n");
             } else {
                 wfDebug("AbuseFilter: loading old links from Parser\n");
                 $textVar = $parameters['text-var'];
                 $wikitext = $vars->getVar($textVar)->toString();
                 $editInfo = $this->parseNonEditWikitext($wikitext, $article);
                 $links = array_keys($editInfo->output->getExternalLinks());
             }
             $result = $links;
             break;
         case 'link-diff-added':
         case 'link-diff-removed':
             $oldLinkVar = $parameters['oldlink-var'];
             $newLinkVar = $parameters['newlink-var'];
             $oldLinks = $vars->getVar($oldLinkVar)->toString();
             $newLinks = $vars->getVar($newLinkVar)->toString();
             $oldLinks = explode("\n", $oldLinks);
             $newLinks = explode("\n", $newLinks);
             if ($this->mMethod == 'link-diff-added') {
                 $result = array_diff($newLinks, $oldLinks);
             }
             if ($this->mMethod == 'link-diff-removed') {
                 $result = array_diff($oldLinks, $newLinks);
             }
             break;
         case 'parse-wikitext':
             // Should ONLY be used when sharing a parse operation with the edit.
             $article = $parameters['article'];
             if ($article) {
                 $textVar = $parameters['wikitext-var'];
                 $new_text = $vars->getVar($textVar)->toString();
                 $editInfo = $article->prepareTextForEdit($new_text);
                 $newHTML = $editInfo->output->getText();
                 // Kill the PP limit comments. Ideally we'd just remove these by not setting the
                 // parser option, but then we can't share a parse operation with the edit, which is bad.
                 $result = preg_replace('/<!--\\s*NewPP limit report[^>]*-->\\s*$/si', '', $newHTML);
                 break;
             }
             // Otherwise fall back to database
         // Otherwise fall back to database
         case 'parse-wikitext-nonedit':
             $article = self::articleFromTitle($parameters['namespace'], $parameters['title']);
             $textVar = $parameters['wikitext-var'];
             $text = $vars->getVar($textVar)->toString();
             $editInfo = $this->parseNonEditWikitext($text, $article);
             $result = $editInfo->output->getText();
             break;
         case 'strip-html':
             $htmlVar = $parameters['html-var'];
             $html = $vars->getVar($htmlVar)->toString();
             $result = StringUtils::delimiterReplace('<', '>', '', $html);
             break;
         case 'load-recent-authors':
             $cutOff = $parameters['cutoff'];
             $title = Title::makeTitle($parameters['namespace'], $parameters['title']);
             if (!$title->exists()) {
                 $result = '';
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:AbuseFilterVariableHolder.php


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