public function extensions($value, $ext = '') { $RET = '' . trim($value); if (empty($ext)) { return '' . $value; } if ($_ = preg_match_all('|\\:([\\w\\-\\.]+)((\\=`([^`]*)`)?)|si', $ext, $ms, PREG_SET_ORDER)) { for ($c = 0; $c < count($ms); $c++) { $a = $ms[$c][1]; $v = isset($ms[$c][4]) ? $ms[$c][4] : ''; if (xbParser::isLogic($a)) { $cond = xbParser::condition($a, $value, $v); $cthen = xbParser::isLogicFunction($a) ? $v : $RET; if (isset($ms[$c + 1])) { if ($ms[$c + 1][1] == 'then') { $c++; $cthen = $ms[$c][4]; } } $celse = $RET; if (isset($ms[$c + 1])) { if ($ms[$c + 1][1] == 'else') { $c++; $celse = $ms[$c][4]; } } $RET = $cond ? $cthen : $celse; if (preg_match($this->_tags['local'], $RET)) { $RET = preg_replace_callback($this->_tags['local'], array($this, "parse_local"), $RET); } } elseif (in_array($a, array('import', 'css-link', 'js-link'))) { $RET = xbParserLibQB::jscss($a, $RET); } elseif (in_array($a, array('link', 'link-external'))) { $RET = xbParserLibQB::link($a, $RET, $v); } else { switch ($a) { case 'links': $RET = xbParser::autoLinks($RET, $v); break; case 'include': if (!empty($v)) { $_ = xbParser::path("{$RET}/{$v}"); $RET = is_file($_) ? include $_ : ''; } break; case 'ul': case 'ol': $RET = xbParser::autoList($RET, $v, $a); break; case 'for': $v = intval($v); $start = 1; if ($ms[$c + 1][1] == 'start') { $c++; $start = intval($ms[$c][4]); } $splt = ''; if ($ms[$c + 1][1] == 'splitter') { $c++; $splt = $ms[$c][4]; } $_R = array(); for ($pos = $start; $pos <= $v - $start; $pos++) { $tpls = array(array("#\\[\\+(iterator\\.index)((:?\\:([\\w\\-\\.]+)((=`([^`]*)`))?)*)\\+\\]#si", $pos)); $_R[] = $this->iteration($tpls, $RET); } $RET = implode($splt, $_R); break; case 'foreach': $v = explode(',', $v); $splt = ''; if ($ms[$c + 1][1] == 'splitter') { $c++; $splt = $ms[$c][4]; } $_R = array(); foreach ($v as $pos => $key) { $tpls = array(array("#\\[\\+(iterator\\.index)((:?\\:([\\w\\-\\.]+)((=`([^`]*)`))?)*)\\+\\]#si", $pos), array("#\\[\\+(iterator|iterator\\.key)((:?\\:([\\w\\-\\.]+)((=`([^`]*)`))?)*)\\+\\]#si", $key)); $_R[] = $this->iteration($tpls, $RET); } $RET = implode($splt, $_R); break; default: if ($_ = $this->execute($a, $v, $RET)) { $RET = $_; } } } } } return $RET; }