• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP unique_marker函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中unique_marker函数的典型用法代码示例。如果您正苦于以下问题:PHP unique_marker函数的具体用法?PHP unique_marker怎么用?PHP unique_marker使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: Parse_url

 /**
  * Constructor
  *
  * @access	public
  * @return	void
  */
 function Parse_url($str = '')
 {
     $EE =& get_instance();
     if ($str == '') {
         $str = $EE->TMPL->tagdata;
     }
     // ---------------------------------------
     //  Plugin Parameters
     // ---------------------------------------
     $autod = $EE->TMPL->fetch_param('find_uris', 'yes');
     $parts = $EE->TMPL->fetch_param('parts', 'scheme|host|path');
     $omit = $EE->TMPL->fetch_param('omit', '');
     $parts = trim($parts);
     $omit = explode('|', $omit);
     if (substr($parts, 0, 3) == 'not') {
         $not = explode('|', trim(substr($parts, 3)));
         $possible = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment');
         $parts = implode('|', array_diff($possible, $not));
     }
     // ---------------------------------------
     //  No auto-discovery? Just one big URL
     // ---------------------------------------
     if ($autod == 'no') {
         $str = trim($str);
         $str = $this->_parse_uri($str, $parts, $omit);
         $this->return_data = $str;
         return;
     }
     // ---------------------------------------
     //  Protect Any URLs in HTML
     // ---------------------------------------
     $easy = array();
     if (preg_match_all("/<.*?>/i", $str, $matches)) {
         $EE->load->helper('string');
         $hash = unique_marker('pi_parse_url');
         for ($i = 0, $s = count($matches['0']); $i < $s; $i++) {
             $easy[$hash . '_' . $i] = $matches['0'][$i];
             $str = str_replace($matches['0'][$i], $hash . '_' . $i, $str);
         }
     }
     // ---------------------------------------
     //  Find Any URLs Not in HTML
     // ---------------------------------------
     if (preg_match_all("#(http(s?)://|www\\.*)([a-z0-9@%_.~\\#\\/\\-\\?&=]+)[^\\s\\)\\<]+#i", $str, $matches)) {
         for ($i = 0, $s = count($matches['0']); $i < $s; $i++) {
             $uri = $this->_parse_uri($matches[0][$i], $parts, $omit);
             $str = str_replace($matches[0][$i], $uri, $str);
         }
     }
     // ---------------------------------------
     //  Replace Protected HTML
     // ---------------------------------------
     if (count($easy) > 0) {
         foreach ($easy as $key => $value) {
             $str = str_replace($key, $value, $str);
         }
     }
     $this->return_data = $str;
 }
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:65,代码来源:pi.parse_url.php


示例2: display_field

 /**
  * Display an RTE field
  *
  * @param string $data       the RTE html content
  * @param string $field_name the field name for the RTE field
  * @param array $settings   field settings:
  * 					field_ta_rows - the number of textarea rows
  * 					field_text_direction - ltr or rtl
  * 					field_fmt - xhtml, br or none
  *
  * @return string
  */
 public function display_field($data, $field_name, $settings, $container = NULL)
 {
     if (!ee()->session->cache('rte', 'loaded')) {
         ee()->javascript->output(ee()->rte_lib->build_js(0, '.WysiHat-field', NULL, REQ == 'CP'));
         ee()->session->set_cache('rte', 'loaded', TRUE);
     }
     ee()->load->helper('form');
     $field = array('name' => $field_name, 'id' => $field_name, 'rows' => $settings['field_ta_rows'], 'dir' => $settings['field_text_direction']);
     // form prepped nonsense
     $code_marker = unique_marker('code');
     $code_chunks = array();
     $data = trim($data);
     $data = htmlspecialchars_decode($data, ENT_QUOTES);
     // Collapse tags and undo any existing newline formatting. Typography
     // will change it anyways and the rte will add its own. Having this here
     // prevents growing-newline syndrome in the rte and lets us switch
     // between rte and non-rte.
     $data = preg_replace('/<br( *\\/)?>\\n*/is', "<br>\n", $data);
     $data = preg_replace("/<\\/p>\n*<p>/is", "\n\n", $data);
     $data = preg_replace("/<br>\n/is", "\n", $data);
     // most newlines we should ever have is 2
     $data = preg_replace('/\\n\\n+/', "\n\n", $data);
     // remove code chunks
     if (preg_match_all("/\\[code\\](.+?)\\[\\/code\\]/si", $data, $matches)) {
         foreach ($matches[1] as $i => $chunk) {
             $code_chunks[$i] = trim($chunk);
             $data = str_replace($matches[0][$i], $code_marker . $i, $data);
         }
     }
     // Check the RTE module and user's preferences
     if (ee()->session->userdata('rte_enabled') == 'y' and ee()->config->item('rte_enabled') == 'y') {
         $field['class'] = 'WysiHat-field';
         foreach ($code_chunks as $i => $chunk) {
             $chunk = htmlentities($chunk, ENT_QUOTES, 'UTF-8');
             $chunk = str_replace("\n", '<br>', $chunk);
             $code_chunks[$i] = $chunk;
         }
         // xhtml vs br
         ee()->load->library('typography');
         $data = ee()->typography->auto_typography($data, TRUE);
         // remove non breaking spaces. typography likes to throw those
         // in when a list is indented.
         $data = str_replace('&nbsp;', ' ', $data);
     }
     // put code chunks back
     foreach ($code_chunks as $i => $chunk) {
         $data = str_replace($code_marker . $i, '[code]' . $chunk . '[/code]', $data);
     }
     // Swap {filedir_x} with the real URL. It will be converted back
     // upon submit by the RTE Image tool.
     ee()->load->model('file_upload_preferences_model');
     $dirs = ee()->file_upload_preferences_model->get_file_upload_preferences(ee()->session->userdata('group_id'));
     foreach ($dirs as $d) {
         // tag to replace
         $filedir = "{filedir_{$d['id']}}";
         $data = str_replace($filedir, $d['url'], $data);
     }
     $field['value'] = $data;
     $return_data = form_textarea($field);
     if ($container = 'grid') {
         $return_data = '<div class="grid_full_cell_container">' . $return_data . '</div>';
     }
     return $return_data;
 }
开发者ID:kentonquatman,项目名称:iofa,代码行数:76,代码来源:Rte_lib.php


示例3: initialize

 /**
  * Initialize
  *
  * Reset all class properties - call after loading and before use
  * since CI will return the existing class when it's requested each time
  * inheriting the previous use's properties
  *
  * @return	void
  */
 public function initialize($config = array())
 {
     // reset class properties
     $this->single_line_pgfs = TRUE;
     // Whether to treat single lines as paragraphs in auto-xhtml
     $this->text_format = 'xhtml';
     // xhtml, markdown, br, none, or lite
     $this->html_format = 'safe';
     // safe, all, none
     $this->auto_links = 'y';
     $this->allow_img_url = 'n';
     $this->parse_images = TRUE;
     $this->allow_headings = TRUE;
     $this->encode_email = TRUE;
     $this->encode_type = 'javascript';
     // javascript or noscript
     $this->use_span_tags = TRUE;
     $this->popup_links = FALSE;
     $this->bounce = '';
     $this->smiley_array = FALSE;
     $this->parse_smileys = TRUE;
     $this->highlight_code = TRUE;
     $this->convert_curly = TRUE;
     // Convert Curly Brackets Into Entities
     $this->emoticon_url = '';
     $this->site_index = '';
     $this->word_censor = FALSE;
     $this->censored_words = array();
     $this->censored_replace = '';
     $this->text_fmt_types = array('xhtml', 'markdown', 'br', 'none', 'lite');
     $this->text_fmt_plugins = array();
     $this->html_fmt_types = array('safe', 'all', 'none');
     $this->yes_no_syntax = array('y', 'n');
     $this->code_chunks = array();
     $this->code_counter = 0;
     $this->http_hidden = unique_marker('typography_url_protect');
     // hash to protect URLs in [url] BBCode
     $this->safe_img_src_end = unique_marker('typography_img_src_end');
     // hash to mark end of image URLs during sanitizing of image tags
     foreach ($config as $key => $val) {
         $this->{$key} = $val;
     }
     /** -------------------------------------
     		/**  Allowed tags
     		/** -------------------------------------*/
     // Note: The decoding array is associative, allowing more precise mapping
     $this->safe_encode = array('b', 'i', 'em', 'del', 'ins', 'strong', 'pre', 'code', 'blockquote');
     $this->safe_decode = array('b' => 'b', 'i' => 'i', 'em' => 'em', 'del' => 'del', 'ins' => 'ins', 'strong' => 'strong', 'pre' => 'pre', 'code' => 'code', 'blockquote' => 'blockquote', 'quote' => 'blockquote', 'QUOTE' => 'blockquote');
     // enable quote protection within braces for EE {variable="attributes"}
     $this->protect_braced_quotes = TRUE;
     if ($this->allow_headings == TRUE) {
         foreach (array('h2', 'h3', 'h4', 'h5', 'h6') as $val) {
             $this->safe_encode[] = $val;
             $this->safe_decode[$val] = $val;
         }
     }
     /** -------------------------------------
     		/**  Fetch emoticon prefs
     		/** -------------------------------------*/
     if (ee()->config->item('enable_emoticons') == 'y') {
         $this->_fetch_emotions_prefs();
     }
     /* -------------------------------------------
     		/*	Hidden Configuration Variables
     		/*	- popup_link => Have links created by Typography class open in a new window (y/n)
     		/* -------------------------------------------*/
     if (ee()->config->item('popup_link') !== FALSE) {
         $this->popup_links = ee()->config->item('popup_link') == 'y' ? TRUE : FALSE;
     }
     /** -------------------------------------
     		/**  Fetch word censoring prefs
     		/** -------------------------------------*/
     if (ee()->config->item('enable_censoring') == 'y') {
         $this->_fetch_word_censor_prefs();
     }
     /** -------------------------------------
     		/**  Fetch plugins
     		/** -------------------------------------*/
     ee()->load->model('addons_model');
     $this->text_fmt_plugins = ee()->addons_model->get_plugin_formatting();
 }
开发者ID:realfluid,项目名称:umbaugh,代码行数:90,代码来源:EE_Typography.php


示例4: parse


//.........这里部分代码省略.........
     $parser_components = $this->_parser->components();
     $dt = 0;
     ee()->load->library('typography');
     ee()->typography->initialize(array('convert_curly' => FALSE));
     ee()->load->helper('date');
     foreach ($entries as $row) {
         $tagdata = $orig_tagdata;
         $this->_count = $count;
         $row['count'] = $count + 1;
         $row['page_uri'] = '';
         $row['page_url'] = '';
         $row['total_results'] = $total_results;
         $row['absolute_count'] = $absolute_offset + $row['count'];
         $row['absolute_results'] = $absolute_results === NULL ? $total_results : $absolute_results;
         $row['comment_subscriber_total'] = isset($subscriber_totals[$row['entry_id']]) ? $subscriber_totals[$row['entry_id']] : 0;
         if ($site_pages !== FALSE && isset($site_pages[$row['site_id']]['uris'][$row['entry_id']])) {
             $row['page_uri'] = $site_pages[$row['site_id']]['uris'][$row['entry_id']];
             $row['page_url'] = ee()->functions->create_page_url($site_pages[$row['site_id']]['url'], $site_pages[$row['site_id']]['uris'][$row['entry_id']]);
         }
         // -------------------------------------------------------
         // Loop start callback. Do what you want.
         // Currently in use in the channel module for the
         // channel_entries_tagdata hook.
         // -------------------------------------------------------
         if (isset($callbacks['tagdata_loop_start'])) {
             $tagdata = call_user_func($callbacks['tagdata_loop_start'], $tagdata, $row);
         }
         // -------------------------------------------------------
         // Row data callback. Do what you want.
         // Currently in use in the channel module for the
         // channel_entries_row hook.
         // -------------------------------------------------------
         if (isset($callbacks['entry_row_data'])) {
             $row = call_user_func($callbacks['entry_row_data'], $tagdata, $row);
         }
         // Reset custom date fields
         // Since custom date fields columns are integer types by default, if they
         // don't contain any data they return a zero.
         // This creates a problem if conditionals are used with those fields.
         // For example, if an admin has this in a template:  {if mydate == ''}
         // Since the field contains a zero it would never evaluate TRUE.
         // Therefore we'll reset any zero dates to nothing.
         if (isset($channel->dfields[$row['site_id']]) && count($channel->dfields[$row['site_id']]) > 0) {
             foreach ($channel->dfields[$row['site_id']] as $dkey => $dval) {
                 // While we're at it, kill any formatting
                 $row['field_ft_' . $dval] = 'none';
                 if (isset($row['field_id_' . $dval]) and $row['field_id_' . $dval] == 0) {
                     $row['field_id_' . $dval] = '';
                 }
             }
         }
         $this->_row = $row;
         // conditionals!
         $cond = $this->_get_conditional_data($row, $prefix, $channel);
         //  Parse Variable Pairs
         foreach ($pairs as $key => $val) {
             $this->_tag = $key;
             $this->_tag_options = $val;
             foreach ($parser_components->pair() as $k => $component) {
                 if (!$pre->is_disabled($component)) {
                     $tagdata = $component->replace($tagdata, $this, $pre->pair_data($component));
                 }
             }
         }
         // Run parsers that just process tagdata once (relationships, for example)
         foreach ($parser_components->once() as $k => $component) {
             if (!$pre->is_disabled($component)) {
                 $tagdata = $component->replace($tagdata, $this, $pre->once_data($component));
             }
         }
         // We swap out the conditionals after pairs are parsed so they don't interfere
         // with the string replace
         $tagdata = ee()->functions->prep_conditionals($tagdata, $cond);
         //  Parse individual variable tags
         foreach ($singles as $key => $val) {
             $this->_tag = $key;
             $this->_tag_options = $val;
             foreach ($parser_components->single() as $k => $component) {
                 if (!$pre->is_disabled($component)) {
                     $tagdata = $component->replace($tagdata, $this, $pre->single_data($component));
                 }
             }
         }
         // do we need to replace any curly braces that we protected in custom fields?
         if (strpos($tagdata, unique_marker('channel_bracket_open')) !== FALSE) {
             $tagdata = str_replace(array(unique_marker('channel_bracket_open'), unique_marker('channel_bracket_close')), array('{', '}'), $tagdata);
         }
         // -------------------------------------------------------
         // Loop end callback. Do what you want.
         // Used by relationships to parse children and by the
         // channel module for the channel_entries_tagdata_end hook
         // -------------------------------------------------------
         if (isset($callbacks['tagdata_loop_end'])) {
             $tagdata = call_user_func($callbacks['tagdata_loop_end'], $tagdata, $row);
         }
         $result .= $tagdata;
         $count++;
     }
     return $result;
 }
开发者ID:realfluid,项目名称:umbaugh,代码行数:101,代码来源:Parser.php


示例5: prep_conditionals

 /**
  * Prep conditionals
  *
  * @access	public
  * @param	string
  * @param	string
  * @param	string
  * @param	string
  * @return	array
  */
 function prep_conditionals($str, $vars, $safety = 'n', $prefix = '')
 {
     if (isset(ee()->TMPL->embed_vars)) {
         // If this is being called from a module tag, embedded variables
         // aren't going to be available yet.  So this is a quick workaround
         // to ensure advanced conditionals using embedded variables can do
         // their thing in mod tags.
         $vars = array_merge($vars, ee()->TMPL->embed_vars);
     }
     if (count($vars) == 0) {
         return $str;
     }
     $switch = array();
     $protect = array();
     $prep_id = $this->random('alpha', 3);
     $embedded_tags = stristr($str, LD . 'exp:') ? TRUE : FALSE;
     $valid = array('!=', '==', '<=', '>=', '<', '>', '<>', '%', 'AND', 'XOR', 'OR', '&&', '||', ')', '(', 'TRUE', 'FALSE');
     $str = str_replace(LD . 'if:else' . RD, unique_marker('if_else_safety'), $str);
     // The ((else)*if) is actually faster than (elseif|if) in PHP 5.0.4,
     // but only by a half a thousandth of a second.  However, why not be
     // as efficient as possible?  It also gives me a chance to catch some
     // user error mistakes.
     if (preg_match_all("/" . preg_quote(LD) . "((if:else)*if)\\s+(.*?)" . preg_quote(RD) . "/s", $str, $matches)) {
         // PROTECT QUOTED TEXT
         // That which is in quotes should be protected and ignored as it will screw
         // up the parsing if the variable is found within a string
         if (preg_match_all('/([\\"\'])([^\\1]*?)\\1/s', implode(' ', $matches[3]), $quote_matches)) {
             foreach ($quote_matches[0] as $ii => $quote_match) {
                 $md5_key = (string) hexdec($prep_id . md5($quote_match));
                 $protect[$quote_match] = $md5_key;
                 // To better protect quotes inside conditional quotes, we need to
                 // determine which kind of quote to surround the newly-encoded string
                 $surrounding_quote = surrounding_character($quote_match);
                 if ($surrounding_quote != '"' and $surrounding_quote != "'" or $surrounding_quote === FALSE) {
                     $surrounding_quote = '"';
                 }
                 // We do these conversions on variables below, so we need
                 // to also do them on the hardcoded values to make sure
                 // the conditionals resolve as expected.
                 // e.g. {if location == "pony's house"}
                 $quote_match = $surrounding_quote . str_replace(array("'", '"', '(', ')', '$', '{', '}', "\n", "\r", '\\'), array('&#39;', '&#34;', '&#40;', '&#41;', '&#36;', '', '', '', '', '&#92;'), $quote_matches[2][$ii]) . $surrounding_quote;
                 $switch[$md5_key] = $quote_match;
             }
             $matches[3] = str_replace(array_keys($protect), array_values($protect), $matches[3]);
             // Remove quoted values altogether to find variables...
             $matches['t'] = str_replace($valid, ' ', str_replace(array_values($protect), '', $matches[3]));
         } else {
             $matches['t'] = str_replace($valid, ' ', $matches[3]);
         }
         // Find what we need, nothing more!!
         $data = array();
         foreach ($matches['t'] as $cond) {
             if (trim($cond) == '') {
                 continue;
             }
             $x = preg_split("/\\s+/", trim($cond));
             $i = 0;
             do {
                 if (array_key_exists($x[$i], $vars)) {
                     $data[$x[$i]] = trim($vars[$x[$i]]);
                 } elseif ($embedded_tags === TRUE && !is_numeric($x[$i])) {
                     $data[$x[$i]] = $x[$i];
                 } elseif (strncmp($x[$i], 'embed:', 6) == 0) {
                     $data[$x[$i]] = '';
                 }
                 if ($i > 500) {
                     break;
                 }
                 ++$i;
             } while (isset($x[$i]));
         }
         // This should prevent, for example, the variable 'comment' from
         // overwriting the variable 'comments'.
         uksort($data, array($this, 'reverse_key_sort'));
         if ($safety == 'y') {
             // Make sure we have the same amount of opening conditional tags
             // as closing conditional tags.
             $tstr = preg_replace("/<script.*?" . ">.*?<\\/script>/is", '', $str);
             $opening = substr_count($tstr, LD . 'if') - substr_count($tstr, LD . 'if:elseif');
             $closing = substr_count($tstr, LD . '/if' . RD);
             if ($opening > $closing) {
                 $str .= str_repeat(LD . '/if' . RD, $opening - $closing);
             }
         }
         // Prep the data array to remove characters we do not want
         // And also just add the quotes around the value for good measure.
         foreach ($data as $key => &$value) {
             if (is_array($value)) {
                 continue;
             }
//.........这里部分代码省略.........
开发者ID:ktbartholomew,项目名称:keithbartholomew.com,代码行数:101,代码来源:Functions.php


示例6: convert_curly_brackets

 /** -------------------------------------
 	/**  Prevents EE Tags and Variables from being parsed
 	/** -------------------------------------*/
 function convert_curly_brackets($str)
 {
     /** ------------------------------------
     		/**  Protect <script> tags
     		/** ------------------------------------*/
     $protected = array();
     $front_protect = unique_marker('wiki_front_protect');
     $back_protect = unique_marker('wiki_back_protect');
     if (stristr($str, '<script') && preg_match_all("/<script.*?" . ">.*?<\\/script>/is", $str, $matches)) {
         for ($i = 0, $s = count($matches['0']); $i < $s; ++$i) {
             $protected[$front_protect . $i . $back_protect] = $matches['0'][$i];
         }
         $str = str_replace(array_values($protected), array_keys($protected), $str);
     }
     /** ------------------------------------
     		/**  Encode all other curly brackets
     		/** ------------------------------------*/
     $str = str_replace(array(LD, RD), array('&#123;', '&#125;'), $str);
     /** ------------------------------------
     		/**  Convert back and return
     		/** ------------------------------------*/
     if (count($protected) > 0) {
         $str = str_replace(array_keys($protected), array_values($protected), $str);
     }
     return $str;
 }
开发者ID:stb74,项目名称:eeguide,代码行数:29,代码来源:mod.wiki.php


示例7: display_field

 /**
  * Display an RTE field
  *
  * @param string $data       the RTE html content
  * @param string $field_name the field name for the RTE field
  * @param array $settings   field settings:
  * 					field_ta_rows - the number of textarea rows
  * 					field_text_direction - ltr or rtl
  * 					field_fmt - xhtml, br or none
  *
  * @return string
  */
 public function display_field($data, $field_name, $settings, $container = NULL)
 {
     if (!ee()->session->cache('rte', 'loaded')) {
         ee()->javascript->output(ee()->rte_lib->build_js(0, '.WysiHat-field', NULL, REQ == 'CP'));
         ee()->session->set_cache('rte', 'loaded', TRUE);
     }
     ee()->load->helper('form');
     $field = array('name' => $field_name, 'id' => $field_name, 'rows' => $settings['field_ta_rows'], 'dir' => $settings['field_text_direction'], 'class' => 'has-rte');
     // form prepped nonsense
     $code_marker = unique_marker('code');
     $code_chunks = array();
     $data = trim($data);
     $data = htmlspecialchars_decode($data, ENT_QUOTES);
     $data = $this->clean_data($data);
     // Check the RTE module and user's preferences
     if (ee()->session->userdata('rte_enabled') == 'y' and ee()->config->item('rte_enabled') == 'y') {
         $field['class'] .= ' WysiHat-field';
         foreach ($code_chunks as $i => $chunk) {
             $chunk = htmlentities($chunk, ENT_QUOTES, 'UTF-8');
             $chunk = str_replace("\n", '<br>', $chunk);
             $code_chunks[$i] = $chunk;
         }
         // xhtml vs br
         ee()->load->library('typography');
         $data = ee()->typography->auto_typography($data, TRUE);
         // remove non breaking spaces. typography likes to throw those
         // in when a list is indented.
         $data = str_replace('&nbsp;', ' ', $data);
     }
     // put code chunks back
     foreach ($code_chunks as $i => $chunk) {
         $data = str_replace($code_marker . $i, '[code]' . $chunk . '[/code]', $data);
     }
     // Swap {filedir_x} with the real URL. It will be converted back
     // upon submit by the RTE Image tool.
     ee()->load->model('file_upload_preferences_model');
     $dirs = ee()->file_upload_preferences_model->get_file_upload_preferences(ee()->session->userdata('group_id'));
     foreach ($dirs as $d) {
         // tag to replace
         $filedir = "{filedir_{$d['id']}}";
         $data = str_replace($filedir, $d['url'], $data);
     }
     $field['value'] = $data;
     $return_data = form_textarea($field);
     return $return_data;
 }
开发者ID:vigm,项目名称:advancedMD,代码行数:58,代码来源:Rte_lib.php


示例8: replace

 /**
  * Replace all of the custom channel fields.
  *
  * @param String	The tagdata to be parsed
  * @param Object	The channel parser object
  * @param Mixed		The results from the preparse method
  *
  * @return String	The processed tagdata
  */
 public function replace($tagdata, EE_Channel_data_parser $obj, $ft_api)
 {
     $tag = $obj->tag();
     $data = $obj->row();
     $prefix = $obj->prefix();
     $site_id = $data['site_id'];
     $cfields = $obj->channel()->cfields;
     $rfields = $obj->channel()->rfields;
     $rfields = isset($rfields[$site_id]) ? $rfields[$site_id] : array();
     $cfields = isset($cfields[$site_id]) ? $cfields[$site_id] : array();
     $cfields = array_diff_key($cfields, $rfields);
     if (empty($cfields)) {
         return $tagdata;
     }
     $field = ee()->api_channel_fields->get_single_field($tag, $prefix);
     if (isset($cfields[$field['field_name']])) {
         $entry = '';
         $field_id = $cfields[$field['field_name']];
         if (isset($data['field_id_' . $field_id]) && $data['field_id_' . $field_id] !== '') {
             $modifier = $field['modifier'];
             $parse_fnc = $modifier ? 'replace_' . $modifier : 'replace_tag';
             $obj = $ft_api->setup_handler($field_id, TRUE);
             if ($obj) {
                 $_ft_path = $ft_api->ft_paths[$ft_api->field_type];
                 ee()->load->add_package_path($_ft_path, FALSE);
                 $obj->_init(array('row' => $data, 'content_id' => $data['entry_id'], 'content_type' => 'channel'));
                 $data = $ft_api->apply('pre_process', array($data['field_id_' . $field_id]));
                 if (method_exists($obj, $parse_fnc)) {
                     $entry = $ft_api->apply($parse_fnc, array($data, $field['params'], FALSE));
                 } elseif (method_exists($obj, 'replace_tag_catchall')) {
                     $entry = $ft_api->apply('replace_tag_catchall', array($data, $field['params'], FALSE, $modifier));
                 }
                 ee()->load->remove_package_path($_ft_path);
             } else {
                 // Couldn't find a fieldtype
                 $entry = ee()->typography->parse_type(ee()->functions->encode_ee_tags($data['field_id_' . $field_id]), array('text_format' => $data['field_ft_' . $field_id], 'html_format' => $data['channel_html_formatting'], 'auto_links' => $data['channel_auto_link_urls'], 'allow_img_url' => $data['channel_allow_img_urls']));
             }
             // prevent accidental parsing of other channel variables in custom field data
             if (strpos($entry, '{') !== FALSE) {
                 $entry = str_replace(array('{', '}'), array(unique_marker('channel_bracket_open'), unique_marker('channel_bracket_close')), $entry);
             }
             $tagdata = str_replace(LD . $tag . RD, $entry, $tagdata);
         }
         $tagdata = str_replace(LD . $tag . RD, '', $tagdata);
     }
     return $tagdata;
 }
开发者ID:nigelpeters,项目名称:css-recruitment-ee,代码行数:56,代码来源:Custom_field.php


示例9: protectJavascript

 /**
  * Protect compressed javascript.
  *
  * @see `$this->enableProtectJavascript()` for why we do this.
  *
  * @param String $str The raw template string
  * @return String     The template string with javascript escaped
  */
 private function protectJavascript($str)
 {
     if ($this->protect_javascript === FALSE) {
         return $str;
     }
     $js_protect = unique_marker('tmpl_script');
     if (stristr($str, '<script') && preg_match_all('/<script.*?>.*?<\\/script>/is', $str, $matches)) {
         foreach ($matches[0] as $i => $match) {
             $this->protected_javascript[$js_protect . $i] = $match;
         }
         $str = str_replace(array_values($this->protected_javascript), array_keys($this->protected_javascript), $str);
     }
     return $str;
 }
开发者ID:kentonquatman,项目名称:iofa,代码行数:22,代码来源:Runner.php


示例10: parse_channel_entries


//.........这里部分代码省略.........
                     preg_match_all("/" . LD . "REL\\[" . $val . "\\](.+?)REL" . RD . "/", $tagdata, $matches);
                     foreach ($matches[1] as $match) {
                         $tagdata = preg_replace("/" . LD . "REL\\[" . $val . "\\](.+?)REL" . RD . "/", $this->EE->TMPL->related_data[$match]['no_rel_content'], $tagdata);
                     }
                 } else {
                     for ($j = 0; $j < count($match[1]); $j++) {
                         $this->related_entries[] = $row['field_id_' . $this->cfields[$row['site_id']][$val]] . '_' . $match[1][$j];
                         $tagdata = preg_replace("/" . LD . "REL\\[" . $val . "\\](.+?)REL" . RD . "/", LD . "REL[" . $row['field_id_' . $this->cfields[$row['site_id']][$val]] . "][" . $val . "]\\1REL" . RD, $tagdata);
                     }
                     $tagdata = $this->EE->TMPL->swap_var_single($val, '', $tagdata);
                 }
             }
             // Clean up any unparsed relationship fields
             if (isset($this->rfields[$row['site_id']]) && count($this->rfields[$row['site_id']]) > 0) {
                 $tagdata = preg_replace("/" . LD . "REL\\[" . preg_quote($val, '/') . "\\](.+?)REL" . RD . "/", "", $tagdata);
             }
             // parse custom channel fields
             $params = array();
             $parse_fnc = 'replace_tag';
             $parse_fnc_catchall = 'replace_tag_catchall';
             $replace = $key;
             if (($spc = strpos($key, ' ')) !== FALSE) {
                 $params = $this->EE->functions->assign_parameters($key);
                 $val = $key = substr($key, 0, $spc);
             }
             if (($cln = strpos($key, ':')) !== FALSE) {
                 $modifier = substr($key, $cln + 1);
                 $parse_fnc = 'replace_' . $modifier;
                 $val = $key = substr($key, 0, $cln);
             }
             if (isset($this->cfields[$row['site_id']][$key])) {
                 if (!isset($row['field_id_' . $this->cfields[$row['site_id']][$val]]) or $row['field_id_' . $this->cfields[$row['site_id']][$val]] == '') {
                     $entry = '';
                 } else {
                     $this->EE->load->library('api');
                     $this->EE->api->instantiate('channel_fields');
                     $field_id = $this->cfields[$row['site_id']][$key];
                     if ($this->EE->api_channel_fields->setup_handler($field_id)) {
                         $this->EE->api_channel_fields->apply('_init', array(array('row' => $row)));
                         $data = $this->EE->api_channel_fields->apply('pre_process', array($row['field_id_' . $field_id]));
                         if ($this->EE->api_channel_fields->check_method_exists($parse_fnc)) {
                             $entry = $this->EE->api_channel_fields->apply($parse_fnc, array($data, $params, FALSE));
                         } elseif ($this->EE->api_channel_fields->check_method_exists($parse_fnc_catchall)) {
                             $entry = $this->EE->api_channel_fields->apply($parse_fnc_catchall, array($data, $params, FALSE, $modifier));
                         } else {
                             $entry = '';
                             $this->EE->TMPL->log_item('Unable to find parse type for custom field: ' . $parse_fnc);
                         }
                     } else {
                         // Couldn't find a fieldtype
                         $entry = $this->EE->typography->parse_type($this->EE->functions->encode_ee_tags($row['field_id_' . $this->cfields[$row['site_id']][$val]]), array('text_format' => $row['field_ft_' . $this->cfields[$row['site_id']][$val]], 'html_format' => $row['channel_html_formatting'], 'auto_links' => $row['channel_auto_link_urls'], 'allow_img_url' => $row['channel_allow_img_urls']));
                     }
                 }
                 // prevent accidental parsing of other channel variables in custom field data
                 if (strpos($entry, '{') !== FALSE) {
                     $this->EE->load->helper('string');
                     $tagdata = $this->EE->TMPL->swap_var_single($replace, str_replace(array('{', '}'), array(unique_marker('channel_bracket_open'), unique_marker('channel_bracket_close')), $entry), $tagdata);
                 } else {
                     $tagdata = $this->EE->TMPL->swap_var_single($replace, $entry, $tagdata);
                 }
             }
             //  parse custom member fields
             if (isset($this->mfields[$val]) && array_key_exists('m_field_id_' . $value[0], $row)) {
                 if (!isset($processed_member_fields[$row['member_id']]['m_field_id_' . $this->mfields[$val][0]])) {
                     $processed_member_fields[$row['member_id']]['m_field_id_' . $this->mfields[$val][0]] = $this->EE->typography->parse_type($row['m_field_id_' . $this->mfields[$val][0]], array('text_format' => $this->mfields[$val][1], 'html_format' => 'safe', 'auto_links' => 'y', 'allow_img_url' => 'n'));
                 }
                 $tagdata = $this->EE->TMPL->swap_var_single($val, $processed_member_fields[$row['member_id']]['m_field_id_' . $this->mfields[$val][0]], $tagdata);
             }
         }
         // END SINGLE VARIABLES
         // do we need to replace any curly braces that we protected in custom fields?
         if (strpos($tagdata, unique_marker('channel_bracket_open')) !== FALSE) {
             $tagdata = str_replace(array(unique_marker('channel_bracket_open'), unique_marker('channel_bracket_close')), array('{', '}'), $tagdata);
         }
         // -------------------------------------------
         // 'channel_entries_tagdata_end' hook.
         //  - Take the final results of an entry's parsing and do what you wish
         //
         if ($this->EE->extensions->active_hook('channel_entries_tagdata_end') === TRUE) {
             $tagdata = $this->EE->extensions->call('channel_entries_tagdata_end', $tagdata, $row, $this);
             if ($this->EE->extensions->end_script === TRUE) {
                 return $tagdata;
             }
         }
         //
         // -------------------------------------------
         $this->return_data .= $tagdata;
     }
     // END FOREACH LOOP
     // Kill multi_field variable
     if (strpos($this->return_data, 'multi_field=') !== FALSE) {
         $this->return_data = preg_replace("/" . LD . "multi_field\\=[\"'](.+?)[\"']" . RD . "/s", "", $this->return_data);
     }
     // Do we have backspacing?
     if ($back = $this->EE->TMPL->fetch_param('backspace')) {
         if (is_numeric($back)) {
             $this->return_data = substr($this->return_data, 0, -$back);
         }
     }
 }
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:101,代码来源:mod.channel.php


示例11: advanced_conditionals

 /**
  * Process Advanced Conditionals
  *
  * The syntax is generally: {if whatever = ""}Dude{if:elseif something != ""}Yo{if:else}
  *
  * The final processing of Advanced Conditionals.  Takes all of the member variables and uncachable
  * variables and preps the conditionals with them.  Then, it converts the conditionals to PHP so that
  * PHP can do all of the really heavy lifting for us.
  *
  * @param	string
  * @return	string
  */
 public function advanced_conditionals($str)
 {
     if (stristr($str, LD . 'if') === FALSE) {
         return $str;
     }
     /* ---------------------------------
     		/*	Hidden Configuration Variables
     		/*  - protect_javascript => Prevents advanced conditional parser from processing anything in <script> tags
     		/* ---------------------------------*/
     if (ee()->config->item('protect_javascript') == 'n') {
         $this->protect_javascript = FALSE;
     }
     $user_vars = array('member_id', 'group_id', 'group_description', 'group_title', 'username', 'screen_name', 'email', 'ip_address', 'location', 'total_entries', 'total_comments', 'private_messages', 'total_forum_posts', 'total_forum_topics', 'total_forum_replies');
     for ($i = 0, $s = count($user_vars), $data = array(); $i < $s; ++$i) {
         $data[$user_vars[$i]] = ee()->session->userdata[$user_vars[$i]];
         $data['logged_in_' . $user_vars[$i]] = ee()->session->userdata[$user_vars[$i]];
     }
     // Define an alternate variable for {group_id} since some tags use
     // it natively, causing it to be unavailable as a global
     $data['member_group'] = $data['logged_in_member_group'] = ee()->session->userdata['group_id'];
     // Logged in and logged out variables
     $data['logged_in'] = ee()->session->userdata['member_id'] == 0 ? 'FALSE' : 'TRUE';
     $data['logged_out'] = ee()->session->userdata['member_id'] != 0 ? 'FALSE' : 'TRUE';
     // current time
     $data['current_time'] = ee()->localize->now;
     // Member Group in_group('1') function, Super Secret!  Shhhhh!
     if (preg_match_all("/in_group\\(([^\\)]+)\\)/", $str, $matches)) {
         $groups = is_array(ee()->session->userdata['group_id']) ? ee()->session->userdata['group_id'] : array(ee()->session->userdata['group_id']);
         for ($i = 0, $s = count($matches[0]); $i < $s; ++$i) {
             $check = explode('|', str_replace(array('"', "'"), '', $matches[1][$i]));
             $str = str_replace($matches[0][$i], count(array_intersect($check, $groups)) > 0 ? 'TRUE' : 'FALSE', $str);
         }
     }
     // Final Prep, Safety On
     $str = ee()->functions->prep_conditionals($str, array_merge($this->segment_vars, $this->embed_vars, ee()->config->_global_vars, $data), 'y');
     // Protect Already Existing Unparsed PHP
     $opener = unique_marker('tmpl_php_open');
     $closer = unique_marker('tmpl_php_close');
     $str = str_replace(array('<?', '?' . '>'), array($opener . '?', '?' . $closer), $str);
     // Protect <script> tags
     $protected = array();
     $front_protect = unique_marker('tmpl_script_open');
     $back_protect = unique_marker('tmpl_script_close');
     if ($this->protect_javascript !== FALSE && stristr($str, '<script') && preg_match_all("/<script.*?" . ">.*?<\\/script>/is", $str, $matches)) {
         for ($i = 0, $s = count($matches[0]); $i < $s; ++$i) {
             $protected[$front_protect . $i . $back_protect] = $matches[0][$i];
         }
         $str = str_replace(array_values($protected), array_keys($protected), $str);
     }
     // Convert EE Conditionals to PHP
     $str = str_replace(array(LD . '/if' . RD, LD . 'if:else' . RD), array('<?php endif; ?' . '>', '<?php else : ?' . '>'), $str);
     if (strpos($str, LD . 'if') !== FALSE) {
         $str = preg_replace("/" . preg_quote(LD) . "((if:(else))*if)\\s+(.*?)" . preg_quote(RD) . "/s", '<?php \\3if(\\4) : ?' . '>', $str);
     }
     $str = $this->parse_template_php($str);
     // Unprotect <script> tags
     if (count($protected) > 0) {
         $str = str_replace(array_keys($protected), array_values($protected), $str);
     }
     // Unprotect Already Existing Unparsed PHP
     $str = str_replace(array($opener . '?', '?' . $closer), array('<' . '?', '?' . '>'), $str);
     return $str;
 }
开发者ID:nigelpeters,项目名称:css-recruitment-ee,代码行数:75,代码来源:Template.php


示例12: display_field

 /**
  * Display an RTE field
  * 
  * @param string $data       the RTE html content
  * @param string $field_name the field name for the RTE field
  * @param array $settings   field settings:
  * 					field_ta_rows - the number of textarea rows
  * 					field_text_direction - ltr or rtl
  * 					field_fmt - xhtml, br or none
  * 
  * @return string	
  */
 public function display_field($data, $field_name, $settings)
 {
     $this->EE->load->helper('form');
     $field = array('name' => $field_name, 'id' => $field_name, 'rows' => $settings['field_ta_rows'], 'dir' => $settings['field_text_direction']);
     // form prepped nonsense
     $data = htmlspecialchars_decode($data, ENT_QUOTES);
     $code_marker = unique_marker('code');
     $code_chunks = array();
     $field_ft = isset($settings['field_fmt']) ? $settings['field_fmt'] : '';
     if ($field_ft == 'xhtml') {
         $data = trim($data);
         // Undo any existing newline formatting. Typography will change
         // it anyways and the rtf will add its own. Having this here
         // prevents growing-newline syndrome in the rtf and lets us switch
         // between rtf and non-rtf.
         $data = preg_replace("/<\\/p>\n*<p>/is", "\n\n", $data);
         $data = preg_replace("/<br( \\/)?>\n/is", "\n", $data);
     }
     // remove code chunks
     if (preg_match_all("/\\[code\\](.+?)\\[\\/code\\]/si", $data, $matches)) {
         foreach ($matches[1] as $i => $chunk) {
             $code_chunks[] = trim($chunk);
             $data = str_replace($matches[0][$i], $code_marker . $i, $data);
         }
     }
     // Check the RTE module and user's preferences
     if ($this->EE->session->userdata('rte_enabled') == 'y' and $this->EE->config->item('rte_enabled') == 'y') {
         $field['class'] = 'WysiHat-field';
         foreach ($code_chunks as &$chunk) {
             $chunk = htmlentities($chunk, ENT_QUOTES, 'UTF-8');
             $chunk = str_replace("\n", '<br>', $chunk);
         }
         // xhtml vs br
         if ($settings['field_fmt'] == 'xhtml') {
             $this->EE->load->library('typography');
             $data = $this->EE->typography->_format_newlines($data);
             // Remove double paragraph tags
             $data = preg_replace("/(<\\/?p>)\\1/is", "\\1", $data);
         }
     }
     // put code chunks back
     foreach ($code_chunks as $i => $chunk) {
         $data = str_replace($code_marker . $i, '[code]' . $chunk . '[/code]', $data);
     }
     // Swap {filedir_x} with the real URL. It will be converted back
     // upon submit by the RTE Image tool.
     $this->EE->load->model('file_upload_preferences_model');
     $dirs = $this->EE->file_upload_preferences_model->get_file_upload_preferences($this->EE->session->userdata('group_id'));
     foreach ($dirs as $d) {
         // tag to replace
         $filedir = "{filedir_{$d['id']}}";
         $data = str_replace($filedir, $d['url'], $data);
     }
     $data = htmlspecialchars($data, ENT_QUOTES);
     $field['value'] = $data;
     return form_textarea($field);
 }
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:69,代码来源:Rte_lib.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP units2pt函数代码示例发布时间:2022-05-23
下一篇:
PHP unique_id函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap