本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}