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, &$count = 0, $first = 0, $last = 0) { if (preg_match_all('#\\{if:.*?\\{/if\\}#si', $string, $matches, PREG_SET_ORDER) < 1) { return; } 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, $article, $count, $first, $last); // replace if block with the IF value $string = nnText::strReplaceOnce($match['0'], $replace, $string); } }
private function replaceArticleTag(&$string, &$match, $art = null) { $parts = explode('|', $match['4']); $match['4'] = trim(array_shift($parts)); $ignores = array(); foreach ($parts as $p) { if (strpos($p, '=') === false) { continue; } list($key, $val) = explode('=', $p, 2); $key = trim($key); $val = trim($val); if (!in_array($key, array('ignore_language', 'ignore_access', 'ignore_state'))) { continue; } $val = str_replace(array('\\{', '\\}'), array('{', '}'), $val); $ignores[$key] = $val; } $html = $this->processMatch($string, $art, $match, $ignores); $string = nnText::strReplaceOnce($match['0'], $html, $string); }
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); }