예제 #1
0
파일: Tags.php 프로젝트: james182/pyrocms
 /**
  * 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 = '';
     foreach ($tag['segments'] as $segment) {
         if (!is_array($data) or !isset($data[$segment])) {
             return FALSE;
         }
         $data = $data[$segment];
     }
     $temp = new Tags();
     foreach ($data as $val) {
         $return = $temp->parse($tag['content'], $val);
         $return_data .= $return['content'];
     }
     unset($temp);
     return $return_data;
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
파일: Tags.php 프로젝트: JamieLomas/pyrocms
	/**
	 * 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;
	}
예제 #4
0
	/**
	 * 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;
	}
예제 #5
0
 /**
  * Callback from template parser
  *
  * @param	array
  * @return 	mixed
  */
 public function parser_callback($data)
 {
     if (!isset($data['segments'][0]) or !isset($data['segments'][1])) {
         return FALSE;
     }
     // Setup our paths from the data array
     $class = $data['segments'][0];
     $method = $data['segments'][1];
     $addon = strtolower($class);
     $return_data = '';
     // Get active add-ons
     $this->_ci->load->model('modules/module_m');
     $addons = $this->_ci->module_m->get_all();
     foreach ($addons as $item) {
         // First check core addons then 3rd party
         if ($item['is_core'] == 1) {
             $addon_path = APPPATH . 'modules/' . $class . '/libraries/' . ucfirst($class) . '.plugin' . EXT;
             if (!file_exists($addon_path)) {
                 log_message('error', 'Unable to load: ' . $class);
                 $return = FALSE;
             } else {
                 include_once $addon_path;
                 $class_name = 'Plugin_' . $class;
                 $class_init = new $class_name();
                 $return_data = $this->_process($class_init, $method, $data);
             }
             break;
         } else {
             $addon_path = ADDONPATH . 'modules/' . $class . '/libraries/' . $class . '.plugin' . EXT;
             if (!file_exists($addon_path)) {
                 log_message('error', 'Unable to load: ' . $class);
                 $return = FALSE;
             } else {
                 // Load it up
                 include_once $addon_path;
                 $class_name = 'Plugin_' . $class;
                 $class_init = new $class_name();
                 // How about a language file?
                 $lang_path = ADDONPATH . 'modules/' . $class . '/language/' . $this->_ci->config->item('language') . '/' . $addon . '_lang' . EXT;
                 if (file_exists($lang_path)) {
                     $this->_ci->lang->load($addon . '/' . $addon);
                 }
                 // Now the fun stuff!
                 $return_data = $this->_process($class_init, $method, $data);
             }
             break;
         }
     }
     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();
         foreach ($return_data as $result) {
             $parsed = $simpletags->parse($content, $result);
             $parsed_return .= $parsed['content'];
         }
         unset($simpletags);
         $return_data = $parsed_return;
     }
     return $return_data;
 }