/** * Callback from template parser * * @param array * @return mixed */ public function parser_callback($data) { $this->_ci->load->library('plugins'); $return_data = $this->_ci->plugins->locate($data); if (is_array($return_data) && $return_data) { if ( ! $this->_is_multi($return_data)) { $return_data = $this->_make_multi($return_data); } $content = $data['content']; $parsed_return = ''; $simpletags = new Tags; $simpletags->set_trigger(config_item('tags_trigger').':'); foreach ($return_data as $result) { if ($data['skip_content']) { $simpletags->set_skip_content($data['skip_content']); } $parsed = $simpletags->parse($content, $result, array($this, 'parser_callback')); $parsed_return .= $parsed['content']; } unset($simpletags); $return_data = $parsed_return; } return $return_data ? $return_data : NULL; }
/** * Callback from template parser * * @param array * @return mixed */ public function parser_callback($data) { $this->_ci->load->library('plugins'); $return_data = $this->_ci->plugins->locate($data); if (is_array($return_data)) { if (!$this->_is_multi($return_data)) { $return_data = $this->_make_multi($return_data); } $content = $data['content']; $parsed_return = ''; $simpletags = new Tags(); $simpletags->set_trigger('pyro:'); foreach ($return_data as $result) { $parsed = $simpletags->parse($content, $result, array($this, 'parser_callback')); $parsed_return .= $parsed['content']; } unset($simpletags); $return_data = $parsed_return; } return $return_data; }
/** * Get the data pertaining to the given double tag. This will * loop through arrays of given data * * Example Data: * $data = array( * 'books' => array( * array( * 'title' => 'PHP for Dummies', * 'author' => 'John Doe' * ), * array( * 'title' => 'CodeIgniter for Dummies', * 'author' => 'Jane Doe' * ) * ) * ); * * Example Tags: * {books} * {title} by {author}<br /> * {/books} * * @access private * @param array The double tag * @param array The data to parse * @return mixed Either the data for the tag or FALSE */ private function _parse_data_double($tag, $data) { $return_data = ''; $new_data = $data; foreach ($tag['segments'] as $segment) { if ( ! is_array($new_data) OR ! isset($new_data[$segment])) { return FALSE; } $new_data = $new_data[$segment]; } $temp = new Tags; $temp->set_trigger($this->_trigger); foreach ($new_data as $val) { if ( ! is_array($val)) { $val = array($val); } // We add the array element to the full data array so that full data // tags can work within double data tags $val = $val + $data; $return = $temp->parse($tag['content'], $val, $this->_current_callback); $return_data .= $return['content']; } unset($temp); return $return_data; }