本文整理汇总了PHP中Parser::getRandomString方法的典型用法代码示例。如果您正苦于以下问题:PHP Parser::getRandomString方法的具体用法?PHP Parser::getRandomString怎么用?PHP Parser::getRandomString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parser
的用法示例。
在下文中一共展示了Parser::getRandomString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($conf)
{
if (!isset($conf['parsers'])) {
throw new MWException(__METHOD__ . ': no parsers specified');
}
$this->conf = $conf;
$this->dtUniqPrefix = "UNIQ" . Parser::getRandomString();
}
示例2: merge
/**
* Merge another StripState object into this one. The strip marker keys
* will not be preserved. The strings in the $texts array will have their
* strip markers rewritten, the resulting array of strings will be returned.
*
* @param $otherState StripState
* @param $texts Array
* @return Array
*/
function merge($otherState, $texts)
{
$mergePrefix = Parser::getRandomString();
foreach ($otherState->data as $type => $items) {
foreach ($items as $key => $value) {
$this->data[$type]["{$mergePrefix}-{$key}"] = $value;
}
}
$this->tempMergePrefix = $mergePrefix;
$texts = preg_replace_callback($otherState->regex, array($this, 'mergeCallback'), $texts);
$this->tempMergePrefix = null;
return $texts;
}
示例3: clearState
/**
* Clear Parser state
*
* @private
*/
function clearState()
{
wfProfileIn(__METHOD__);
if ($this->mFirstCall) {
$this->firstCallInit();
}
$this->mOutput = new ParserOutput();
$this->mAutonumber = 0;
$this->mLastSection = '';
$this->mDTopen = false;
$this->mIncludeCount = array();
$this->mStripState = new StripState();
$this->mArgStack = false;
$this->mInPre = false;
$this->mInterwikiLinkHolders = array('texts' => array(), 'titles' => array());
$this->mLinkHolders = array('namespaces' => array(), 'dbkeys' => array(), 'queries' => array(), 'texts' => array(), 'titles' => array());
$this->mRevisionTimestamp = $this->mRevisionId = null;
/**
* Prefix for temporary replacement strings for the multipass parser.
* \x07 should never appear in input as it's disallowed in XML.
* Using it at the front also gives us a little extra robustness
* since it shouldn't match when butted up against identifier-like
* string constructs.
*
* Must not consist of all title characters, or else it will change
* the behaviour of <nowiki> in a link.
*/
#$this->mUniqPrefix = "\x07UNIQ" . Parser::getRandomString();
# Changed to \x7f to allow XML double-parsing -- TS
$this->mUniqPrefix = "UNIQ" . Parser::getRandomString();
# Clear these on every parse, bug 4549
$this->mTplExpandCache = $this->mTplRedirCache = $this->mTplDomCache = array();
$this->mShowToc = true;
$this->mForceTocPosition = false;
$this->mIncludeSizes = array('post-expand' => 0, 'arg' => 0);
$this->mPPNodeCount = 0;
$this->mDefaultSort = false;
$this->mHeadings = array();
# Fix cloning
if (isset($this->mPreprocessor) && $this->mPreprocessor->parser !== $this) {
$this->mPreprocessor = null;
}
wfRunHooks('ParserClearState', array(&$this));
wfProfileOut(__METHOD__);
}
示例4: insertStripItem
/**
* Add an item to the strip state
* Returns the unique tag which must be inserted into the stripped text
* The tag will be replaced with the original text in unstrip()
*
* @private
*/
function insertStripItem($text, &$state)
{
$rnd = $this->mUniqPrefix . '-item' . Parser::getRandomString();
if (!$state) {
$state = array();
}
$state['general'][$rnd] = $text;
return $rnd;
}
示例5: insertStripItem
/**
* Add an item to the strip state
* Returns the unique tag which must be inserted into the stripped text
* The tag will be replaced with the original text in unstrip()
*
* @private
*/
function insertStripItem($text, &$state)
{
$rnd = $this->mUniqPrefix . '-item' . Parser::getRandomString();
$state->general->setPair($rnd, $text);
return $rnd;
}
示例6: getFormDefinition
/**
* Parse the form definition and return it
*/
public static function getFormDefinition(Parser $parser, $form_def = null, $form_id = null)
{
if ($form_id !== null) {
$cachedDef = self::getFormDefinitionFromCache($form_id, $parser);
if ($cachedDef !== null) {
return $cachedDef;
}
}
if ($form_id !== null) {
$form_title = Title::newFromID($form_id);
$form_def = SFUtils::getPageText($form_title);
} elseif ($form_def == null) {
// No id, no text -> nothing to do
return '';
}
// 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>' => ''));
// We need to replace all SF tags in the form definition by strip items. But we can not just use
// the Parser strip state because the Parser would during parsing replace all strip items and then
// mangle them into HTML code. So we have to use our own. Which means we also can not just use
// Parser::insertStripItem() (see below).
$prefix = "UNIQ" . Parser::getRandomString();
$stripState = new StripState($prefix);
// This regexp will find any SF triple braced tags (including correct handling of contained braces), i.e.
// {{{field|foo|default={{Bar}}}}} is not a problem. When used with preg_match and friends, $matches[0] will
// contain the whole SF tag, $matches[1] will contain the tag without the enclosing triple braces.
$regexp = '#\\{\\{\\{((?>[^\\{\\}]+)|(\\{((?>[^\\{\\}]+)|(?-2))*\\}))*\\}\\}\\}#';
// replace all SF tags by strip markers
$form_def = preg_replace_callback($regexp, function (array $matches) use($stripState, $prefix) {
static $markerIndex = 0;
$rnd = "{$prefix}-item-{$markerIndex}-" . Parser::MARKER_SUFFIX;
$markerIndex++;
$stripState->addGeneral($rnd, $matches[0]);
return $rnd;
}, $form_def);
$title = is_object($parser->getTitle()) ? $parser->getTitle() : new Title();
// parse wiki-text
$output = $parser->parse($form_def, $title, $parser->getOptions());
$form_def = $stripState->unstripGeneral($output->getText());
if ($output->getCacheTime() == -1) {
$form_article = Article::newFromID($form_id);
self::purgeCache($form_article);
wfDebug("Caching disabled for form definition {$form_id}\n");
} elseif ($form_id !== null) {
self::cacheFormDefinition($form_id, $form_def, $parser);
}
return $form_def;
}