本文整理汇总了PHP中NNText::strReplaceOnce方法的典型用法代码示例。如果您正苦于以下问题:PHP NNText::strReplaceOnce方法的具体用法?PHP NNText::strReplaceOnce怎么用?PHP NNText::strReplaceOnce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NNText
的用法示例。
在下文中一共展示了NNText::strReplaceOnce方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replace
public function replace(&$string, &$match, $art = null)
{
$groups = explode('|', $match['4']);
$match['4'] = trim(array_shift($groups));
$ignores = array();
foreach ($groups as $group) {
if (strpos($group, '=') === false) {
continue;
}
$this->helpers->get('process')->getIgnoreSetting($ignores, $group);
}
$html = $this->helpers->get('process')->processMatch($string, $art, $match, $ignores);
$string = NNText::strReplaceOnce($match['0'], $html, $string);
}
示例2: handleIfStatements
public function handleIfStatements(&$string, &$article)
{
if (preg_match_all('#\\{if:.*?\\{/if\\}#si', $string, $matches, PREG_SET_ORDER) < 1) {
return;
}
$this->data->article = $article;
if (strpos($string, 'text') !== false) {
$article->text = (isset($article->introtext) ? $article->introtext : '') . (isset($article->introtext) ? $article->fulltext : '');
}
foreach ($matches as $match) {
if (preg_match_all('#\\{(if|else *?if|else)(?:\\:([^\\}]+))?\\}(.*?)(?=\\{(?:else|\\/if))#si', $match['0'], $ifs, PREG_SET_ORDER) < 1) {
continue;
}
$replace = $this->getIfResult($ifs);
// replace if block with the IF value
$string = NNText::strReplaceOnce($match['0'], $replace, $string);
}
$article = $this->data->article;
}
示例3: replace
public function replace(&$string, &$match, $art = null)
{
// Check for categories...
$groups = explode('|', $match['4']);
$data = array();
$ignores = array();
foreach ($groups as $group) {
if (!($set_data = $this->getDataByGroup($group, $ignores))) {
continue;
}
$data[] = $set_data;
}
$ids = array();
foreach ($data as $dat) {
$ids = array_merge($ids, $this->getArticleIdsByData($dat, $ignores));
}
$html = array();
$total = count($ids);
$this->helpers->get('tags')->data->article = $art;
$this->helpers->get('tags')->data->total = $total;
// Process empty category to allow for {if:empty} result
if (!$total) {
$data = $match;
$data['4'] = 0;
$html[] = $this->processMatch($string, $art, $data, $ignores);
}
// Process articles from category
foreach ($ids as $i => $id) {
$data = $match;
$data['4'] = trim($id);
$count = $i + 1;
$this->helpers->get('tags')->data->count = $count;
$this->helpers->get('tags')->data->even = !($count % 2);
$this->helpers->get('tags')->data->uneven = $count % 2;
$this->helpers->get('tags')->data->first = $count == 1;
$this->helpers->get('tags')->data->last = $count >= $total;
$html[] = $this->processMatch($string, $art, $data, $ignores);
}
$string = NNText::strReplaceOnce($match['0'], implode('', $html), $string);
}