function matchArticle($content, $replaceInTemplate = false) { global $REX; $var = 'REX_ARTICLE'; $matches = $this->getVarParams($content, $var); foreach ($matches as $match) { list($param_str, $args) = $match; list($article_id, $args) = $this->extractArg('id', $args, 0); list($clang, $args) = $this->extractArg('clang', $args, '$REX[\'CUR_CLANG\']'); list($ctype, $args) = $this->extractArg('ctype', $args, -1); list($field, $args) = $this->extractArg('field', $args, ''); $tpl = ''; if ($article_id == 0) { // REX_ARTICLE[field=name] keine id -> feld von aktuellem artikel verwenden if ($field) { if (OOArticle::hasValue($field)) { $tpl = '<?php echo htmlspecialchars(' . $this->handleGlobalVarParamsSerialized($var, $args, '$this->getValue(\'' . addslashes($field) . '\')') . '); ?>'; } } else { if ($replaceInTemplate) { // aktueller Artikel darf nur in Templates, nicht in Modulen eingebunden werden // => endlossschleife $tpl = '<?php echo ' . $this->handleGlobalVarParamsSerialized($var, $args, '$this->getArticle(' . $ctype . ')') . '; ?>'; } } } else { if ($article_id > 0) { // REX_ARTICLE[field=name id=5] feld von gegebene artikel id verwenden if ($field) { if (OOArticle::hasValue($field)) { // bezeichner wählen, der keine variablen // aus modulen/templates überschreibt $varname = '$__rex_art'; $tpl = '<?php ' . $varname . ' = OOArticle::getArticleById(' . $article_id . ', ' . $clang . '); if(' . $varname . ') echo htmlspecialchars(' . $this->handleGlobalVarParamsSerialized($var, $args, $varname . '->getValue(\'' . addslashes($field) . '\')') . '); ?>'; } } else { // bezeichner wählen, der keine variablen // aus modulen/templates überschreibt $varname = '$__rex_art'; $tpl = '<?php ' . $varname . ' = new rex_article(); ' . $varname . '->setArticleId(' . $article_id . '); ' . $varname . '->setClang(' . $clang . '); echo ' . $this->handleGlobalVarParamsSerialized($var, $args, $varname . '->getArticle(' . $ctype . ')') . '; ?>'; } } } if ($tpl != '') { $content = str_replace($var . '[' . $param_str . ']', $tpl, $content); } } return $content; }