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


PHP NNText::strReplaceOnce方法代码示例

本文整理汇总了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);
 }
开发者ID:naka211,项目名称:kkvn,代码行数:14,代码来源:article.php

示例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;
 }
开发者ID:naka211,项目名称:kkvn,代码行数:19,代码来源:tags.php

示例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);
 }
开发者ID:naka211,项目名称:kkvn,代码行数:40,代码来源:articles.php


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