diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index ace9291d0..fb2db0d89 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -2182,17 +2182,30 @@ class e107 list($templateId, $templateKey) = explode('/', $templateId, 2); $wrapperRegPath = 'templates/wrapper/'.$templateId; + $wrapper = self::getRegistry($wrapperRegPath); + if(empty($wrapper) || !is_array($wrapper)) $wrapper = array(); - - if($templateKey) $wrapper = (isset($wrapper[$templateKey]) ? $wrapper[$templateKey] : array()); - + + if(strpos($templateKey,'/')!==false) // quick fix support for 3 keys eg. news/view/item + { + list($templateKey,$templateKey2) = explode("/", $templateKey, 2); + if($templateKey && $templateKey2) + { + $wrapper = (isset($wrapper[$templateKey][$templateKey2]) ? $wrapper[$templateKey][$templateKey2] : array()); + } + } + else // support for 2 keys. eg. contact/form + { + if($templateKey) $wrapper = (isset($wrapper[$templateKey]) ? $wrapper[$templateKey] : array()); + } + if(null !== $scName) { $scName = strtoupper($scName); return isset($wrapper[$scName]) ? $wrapper[$scName] : ''; } - + return $wrapper; } diff --git a/e107_handlers/news_class.php b/e107_handlers/news_class.php index 82cfe57cf..67476b395 100644 --- a/e107_handlers/news_class.php +++ b/e107_handlers/news_class.php @@ -374,9 +374,10 @@ class news { // Retrieve batch sc object, set required vars $sc = e107::getScBatch('news') + ->wrapper('news/view/item') ->setScVar('news_item', $news) ->setScVar('param', $param); - + $text = e107::getParser()->parseTemplate($NEWS_PARSE, true, $sc); if ($mode == 'return') diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 6f1cfa1b5..8f451c0b4 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -756,11 +756,14 @@ class e_parse_shortcode // Do it only once per parsing cylcle and not on every doCode() loop - performance if(method_exists($this->addedCodes, 'wrapper')) { + // $cname = get_class($this->addedCodes); + $tmpWrap = e107::templateWrapper($this->addedCodes->wrapper()); if(!empty($tmpWrap)) // FIX for #3 above. { $this->wrappers = array_merge($this->wrappers,$tmpWrap); } + } @@ -782,7 +785,8 @@ class e_parse_shortcode } elseif (is_array($extraCodes)) // Array value contains the contents of a .sc file which is then parsed. ie. return " whatever "; { - $this->addedCodes = &$extraCodes; + $this->addedCodes = &$extraCodes; + /* foreach ($extraCodes as $sc => $code) { @@ -792,6 +796,8 @@ class e_parse_shortcode // print_a($this); } + + $ret = preg_replace_callback('#\{(\S[^\x02]*?\S)\}#', array(&$this, 'doCode'), $text); $this->parseSCFiles = $saveParseSCFiles; // Restore previous value $this->addedCodes = $saveCodes; @@ -822,6 +828,7 @@ class e_parse_shortcode global $pref, $e107cache, $menu_pref, $parm, $sql; $parmArray = false; + $fullShortcodeKey = null; if ($this->eVars) { @@ -837,6 +844,7 @@ class e_parse_shortcode if(preg_match('/^([A-Z_]*):(.*)/', $matches[1], $newMatch)) { + $fullShortcodeKey = $newMatch[0]; $code = $newMatch[1]; $parmStr = trim($newMatch[2]); $debugParm = $parmStr; @@ -966,7 +974,7 @@ class e_parse_shortcode // via e107::getScBatch(name)->setParserVars($eVars); // $this->callScFunc($_class, 'setParserVars', $this->eVars); $wrapper = $this->callScFunc($_class, 'wrapper', null); - + $ret = $this->callScFuncA($_class, $_method, array($parm, $sc_mode)); /*if (method_exists($this->scClasses[$_class], $_method)) @@ -1079,13 +1087,21 @@ class e_parse_shortcode } } + + if (isset($ret) && ($ret != '' || is_numeric($ret))) { // Wrapper support - see contact_template.php - if(isset($this->wrappers[$code]) && !empty($this->wrappers[$code])) + if(isset($this->wrappers[$code]) && !empty($this->wrappers[$code])) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE'] { list($pre, $post) = explode("{---}", $this->wrappers[$code], 2); $ret = $pre.$ret.$post; + + } + elseif(!empty($fullShortcodeKey) && !empty($this->wrappers[$fullShortcodeKey]) ) // eg: $NEWS_WRAPPER['view']['item']['NEWSIMAGE: item=1'] + { + list($pre, $post) = explode("{---}", $this->wrappers[$fullShortcodeKey], 2); + $ret = $pre.$ret.$post; } else { @@ -1147,12 +1163,24 @@ class e_parse_shortcode { $other = $this->debug_legacy; } - + + if(!empty($this->wrappers[$code])) + { + $other['wrapper'] = $this->wrappers[$code]; + } + elseif(!empty($this->wrappers[$fullShortcodeKey]) ) + { + $other['wrapper'] = $this->wrappers[$fullShortcodeKey]; + } + + $info = (isset($this->registered_codes[$code])) ? print_a($this->registered_codes[$code],true) : print_a($other,true); $tmp = isset($debugParm) ? $debugParm : $parm; $db_debug->logCode(2, $code, $tmp, $info); + + } @@ -1278,7 +1306,7 @@ class e_shortcode if(false === $id) $id = null; $this->wrapper = $id; - + return $this; } diff --git a/e107_plugins/news/templates/news_template.php b/e107_plugins/news/templates/news_template.php index 5d7abf958..0ae0f6279 100644 --- a/e107_plugins/news/templates/news_template.php +++ b/e107_plugins/news/templates/news_template.php @@ -83,7 +83,7 @@ $NEWS_TEMPLATE['default']['item'] = ' $NEWS_TEMPLATE['default']['item'] = ' {SETIMAGE: w=900&h=300}
by {NEWSAUTHOR}
+{GLYPH=user} {NEWSAUTHOR}