/** * Parser Callback * * @param string $module * @param string $attribute * @param string $content * * @return mixed */ public function parser_callback($module, $attribute, $content) { $return_view = NULL; $parsed_return = ''; $output = self::get_view($module, $attribute); $return_view = $output; //loop it up, if its array no use in the template, gotta work it here. if (is_array($output)) { // Need to make sure we have a array and no objects inside the array too. $parser = new Lex_Parser(); $parser->scopeGlue(':'); foreach ($output as $result) { $parsed_return .= $parser->parse($content, $result, array($this, 'parser_callback')); } unset($parser); $return_view = $parsed_return; } return $return_view; }
/** * Callback from template parser * * @param array * @return mixed */ public function parser_callback($plugin, $attributes, $content, $data) { $this->_ci->load->library('plugins'); $return_data = ''; // Check if there were local data callbacks defined if (isset($data['_callbacks'][$plugin])) { $callback = $data['_callbacks'][$plugin]; if (is_callable($callback)) { $return_data = call_user_func_array($callback, array($plugin, $attributes, $content, $data)); } } else { if (isset($this->callbacks[$plugin])) { $callback = $this->callbacks[$plugin]; if (is_callable($callback)) { $return_data = call_user_func_array($callback, array($plugin, $attributes, $content, $data)); } } else { // Locate and process plugin $return_data = $this->_ci->plugins->locate($plugin, $attributes, $content, $data); } } if (is_array($return_data)) { if (!$this->_is_multi($return_data)) { $return_data = $this->_make_multi($return_data); } // Check if plugin has made any changes to the default content if (isset($return_data['_content'])) { $content = $return_data['_content']; unset($return_data['_content']); } $parsed_return = ''; $parser = new Lex_Parser(); $parser->scopeGlue(':'); foreach ($return_data as $result) { // Check if there was content declared for the result // If no _content declared in result array use default content if (isset($result['_content'])) { $rendered_content = $result['_content']; unset($result['_content']); } else { $rendered_content = $content; } $parsed_return .= $parser->parse($rendered_content, $result, array($this, 'parser_callback')); } unset($parser); $return_data = $parsed_return; } return $return_data ? $return_data : NULL; }