当前位置: 首页>>代码示例>>PHP>>正文


PHP Tags::parse方法代码示例

本文整理汇总了PHP中Tags::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::parse方法的具体用法?PHP Tags::parse怎么用?PHP Tags::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tags的用法示例。


在下文中一共展示了Tags::parse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _parse_data_double

 /**
  * 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;
 }
开发者ID:james182,项目名称:pyrocms,代码行数:45,代码来源:Tags.php

示例2: parser_callback

 /**
  * 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;
 }
开发者ID:vmichnowicz,项目名称:pyrocms,代码行数:27,代码来源:MY_Parser.php

示例3: _parse_data_double

	/**
	 * 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;
	}
开发者ID:JamieLomas,项目名称:pyrocms,代码行数:59,代码来源:Tags.php

示例4: parser_callback

	/**
	 * 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;
	}
开发者ID:JamieLomas,项目名称:pyrocms,代码行数:43,代码来源:MY_Parser.php

示例5: parser_callback

 /**
  * 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;
 }
开发者ID:james182,项目名称:pyrocms,代码行数:70,代码来源:MY_Parser.php


注:本文中的Tags::parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。