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); }
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; }
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); }