コード例 #1
0
ファイル: template_model.php プロジェクト: Gninety/Microweber
 /**
  * @desc  parses the mw tags
  * @param $layout - string
  * @param $options
  * $options ['admin'] - loads the module admin
  * @return string
  * @author	Microweber Dev Team
  * @version 1.0
  * @since Version 1.0
  */
 function parseMicrwoberTags($layout, $options = false)
 {
     /*		$function_cache_id = false;
     		
     		//$args = func_get_args ();
     		if (! empty ( $options )) {
     			foreach ( $options as $k => $v ) {
     				
     				$function_cache_id = $function_cache_id . serialize ( $k ) . serialize ( $v );
     			
     			}
     		}
     		
     		$function_cache_id = __FUNCTION__ . md5 ( $layout ) . md5 ( $function_cache_id );
     		
     		$cache_group = 'extract_tags';
     		
     		//$cache_content = CI::model ( 'core' )->cacheGetContent ( $function_cache_id, $cache_group );
     		
     		if (($cache_content) != false) {
     			
     			//return $cache_content;
     		
     		}*/
     //echo memory_get_usage() . "\n"; // 36640
     /*$cache_id =  md5 ( $layout ) . md5 ( serialize ( $options ) );
     		$cache_group = 'blocks/'.DIRECTORY_SEPARATOR.intval(PAGE_ID).DIRECTORY_SEPARATOR.'';
     		
     		
     		
     		$cache_content = CI::model ( 'core' )->cacheGetContentAndDecode ( $cache_id, $cache_group );*/
     if ($cache_content != false) {
         //return $cache_content;
     }
     static $mem = array();
     static $mem2 = array();
     $layout_md5 = md5($layout);
     $options_md5 = md5(serialize($options));
     $check = $layout_md5 . $options_md5;
     if ($mem["{$check}"] != false) {
         return $mem[$check];
     }
     //var_dump( $this->$parse_memory);
     //$layout = str_ireplace ( '<mw', '<microweber', $layout );
     $layout = CI::model('core')->replace_in_long_text('<mw', '<microweber', $layout, $use_normal_replace = true);
     $v = $layout;
     //	$tags1 = CI::model ( 'core' )->extractTags ( $v, '*', $selfclosing = true, $return_the_entire_tag = true, $charset = 'UTF-8' );
     if (strstr($layout, '<microweber') == true) {
         //$layout = $this->parseMicrwoberTags ( $layout, $options );
     }
     if (strstr($layout, '<mw') == true) {
         //$layout = $this->parseMicrwoberTags ( $layout, $options );
     }
     if (strstr($layout, '<nomw') == true) {
         $relations = array();
         $tags = CI::model('core')->extractTags($layout, 'nomw', $selfclosing = false, $return_the_entire_tag = true, $charset = 'UTF-8');
         //	p($tags);
         $matches = $tags;
         $txt_to_replace_back = array();
         if (!empty($matches)) {
             //
             foreach ($matches as $m) {
                 $hash = md5($m['full_tag']);
                 $hash = 'replace_back_' . $hash;
                 $txt_to_replace_back[$hash] = $m['full_tag'];
                 $layout = str_replace($m['full_tag'], $hash, $layout);
             }
         }
     }
     if (strstr($layout, '<block') == true) {
         $editmode = CI::model('core')->is_editmode();
         //p($editmode);
         $relations = array();
         $tags = CI::model('core')->extractTags($layout, 'block', $selfclosing = true, $return_the_entire_tag = true, $charset = 'UTF-8');
         //	p($tags);
         $matches = $tags;
         if (!empty($matches)) {
             //
             foreach ($matches as $m) {
                 //
                 if ($m['tag_name'] == 'block') {
                     $attr = $m['attributes'];
                     if ($attr['id'] != '') {
                         //	p($m);
                         $attr['id'] = trim($attr['id']);
                         $is_global = $attr['global'];
                         if ($is_global == false) {
                             $is_global2 = $attr['rel'];
                             if (trim($is_global2) == 'global') {
                                 $is_global = true;
                             }
                         }
                         if (PAGE_ID != false and $is_global == false) {
                             $try_file = TEMPLATE_DIR . 'blocks/' . PAGE_ID;
                             $try_file = normalize_path($try_file);
                             $try_file .= $attr['id'] . '.php';
                             //p($try_file);
                             if (is_file($try_file)) {
                             } else {
                                 $try_file = TEMPLATE_DIR . 'blocks/' . $attr['id'] . '.php';
                             }
                         } else {
                             $try_file = TEMPLATE_DIR . 'blocks/' . $attr['id'] . '.php';
                         }
                         $try_file_default = TEMPLATE_DIR . 'blocks/default.php';
                         if (is_file($try_file) == false) {
                             $is_admin = is_admin();
                             if ($is_admin == true) {
                                 $dir = dirname($try_file);
                                 if (is_dir($dir) == false) {
                                     @mkdir_recursive($dir);
                                 }
                                 if (!copy($try_file_default, $try_file)) {
                                     @touch($try_file);
                                     //echo "failed to copy $file...\n";
                                 }
                             }
                         }
                         if (is_file($try_file) == true) {
                             $arrts = array();
                             foreach ($attr as $att => $at) {
                                 $this->template[$att] = $at;
                                 $arrts[$att] = $at;
                             }
                             $this->template['params'] = $arrts;
                             $this->load->vars($this->template);
                             $module_file = $this->load->file($try_file, true);
                             //p($arrts);
                             /*	if ($editmode == true) {
                             				//p($m);
                             				$edtid_hash = base64_encode ( $m ['full_tag'] );
                             				if (strval ( $module_file ) != '') {
                             					$module_file = '<div class="editblock"  id="' . $attr ['id'] . '">' . $module_file . '</div>';
                             				} else {
                             					$module_file = false;
                             				}
                             			
                             			} else {
                             				if (strval ( $module_file ) != '') {
                             					$module_file = '<div class="editblock" id="' . $attr ['id'] . '">' . $module_file . '</div>';
                             				}
                             			}*/
                             if (strval($module_file) != '') {
                                 if ($is_global == true) {
                                     $str123 = ' rel="global" ';
                                 } else {
                                     $str123 = false;
                                 }
                                 $module_file = '<div class="editblock" ' . $str123 . '   id="' . $attr['id'] . '">' . $module_file . '</div>';
                             } else {
                                 //$module_file = false;
                                 $module_file = '<div class="editblock" ' . $str123 . '   id="' . $attr['id'] . '">' . '</div>';
                             }
                             if (strstr($module_file, '<block') == true) {
                                 $module_file = self::parseMicrwoberTags($module_file, $options);
                             }
                             $layout = str_replace_count($m['full_tag'], $module_file, $layout, 1);
                             //$layout = str_replace ( $m ['full_tag'], '', $layout );
                             $layout = str_replace_count('</block>', '', $layout, 1);
                             //$layout = str_replace ( '</microweber>', '', $layout );
                         }
                     }
                 }
             }
         }
     }
     //
     if (strstr($layout, '<microweber') == true) {
         $editmode = CI::model('core')->is_editmode();
         $relations = array();
         $tags = CI::model('core')->extractTags($layout, 'microweber', $selfclosing = true, $return_the_entire_tag = true, $charset = 'UTF-8');
         //	p($tags);
         $matches = $tags;
         if (!empty($matches)) {
             //
             foreach ($matches as $m) {
                 if ($m['tag_name'] == 'microweber') {
                     $attr = $m['attributes'];
                     if ($attr['module'] != '') {
                         $mmd5 = md5($attr['module']);
                         $check_if_uninstalled = MODULES_DIR . '_system/' . $mmd5 . '.php';
                         if (is_dir(MODULES_DIR . '_system/') == false) {
                             touch(MODULES_DIR . '_system/');
                         }
                         if (is_file($check_if_uninstalled) == true) {
                             //	$attr ['module'] = false;
                         }
                     }
                     if (strval($attr['module']) == '') {
                         $attr['module'] = 'non_existing';
                     }
                     //p($attr ['module']);
                     if ($attr['module'] != '') {
                         $attr['module'] = trim($attr['module']);
                         $attr['module'] = str_replace('\\', '/', $attr['module']);
                         $attr['module'] = reduce_double_slashes($attr['module']);
                         $try_file1 = MODULES_DIR . '' . $attr['module'] . '.php';
                         $try_file = MODULES_DIR . 'modules/' . $attr['module'] . '.php';
                         if ($options['admin'] == true) {
                             $try_file1 = MODULES_DIR . 'admin/' . $attr['module'] . '.php';
                             $try_filefront = MODULES_DIR . '' . $attr['module'] . '.php';
                             if (strstr($attr['module'], 'admin') == false) {
                                 $try_file1 = MODULES_DIR . 'admin/' . $attr['module'] . '.php';
                             } else {
                                 $try_file1 = MODULES_DIR . '' . $attr['module'] . '.php';
                             }
                         }
                         $try_file1 = normalize_path($try_file1, false);
                         //$a = is_file ( $try_file1 );
                         //p($try_file1);
                         //p($a);
                         if (is_file($try_file1) == false) {
                             if (is_file($try_file) == true) {
                                 $try_config_file = DEFAULT_TEMPLATE_DIR . 'modules/' . $attr['module'] . '_config.php';
                             } else {
                                 if ($options['admin'] == true) {
                                     if (strstr($attr['module'], 'admin') == false) {
                                         $try_file = MODULES_DIR . 'admin/' . '' . 'default' . '.php';
                                     } else {
                                         $try_file = MODULES_DIR . '' . '' . 'default' . '.php';
                                     }
                                 }
                             }
                             $is_admin = is_admin();
                             if ($is_admin == true) {
                                 $try_file1 = $try_filefront;
                                 $try_config_file = MODULES_DIR . '' . $attr['module'] . '_config.php';
                                 $dir = dirname($try_file1);
                                 if (is_dir($dir) == false) {
                                     mkdir_recursive($dir);
                                 }
                                 //print ( "You are trying to call module that doesnt exist in $try_file1.$try_file Please create it!" );
                                 //var_dump( $try_file, $try_file1);
                                 //exit ( "Modile file not found in $try_file1. Please create it!" );
                                 //if (! copy ( $try_file, $try_file1 )) {
                                 //echo "failed to copy $file...\n";
                                 //}
                                 $error = true;
                             } else {
                                 //print ( "You are trying to call module that doesnt exist in $try_file1.$try_file Please create it!" );
                                 $error = true;
                             }
                         } else {
                             $try_config_file = MODULES_DIR . '' . $attr['module'] . '_config.php';
                         }
                         if ($error == true) {
                             $try_file1 = MODULES_DIR . 'non_existing.php';
                             $error = false;
                         }
                         //	p($try_file1);
                         if (is_file($try_file1) == true and $error == false) {
                             $arrts = array();
                             foreach ($attr as $att => $at) {
                                 $this->template[$att] = $at;
                                 //$this->template [$att] = mw_get_var($at);
                                 $arrts[$att] = $at;
                             }
                             $no_edit = false;
                             $no_admin = false;
                             $check2 = false;
                             $mem2_md5_1 = md5(serialize($m));
                             //$mem2_md5_2 = md5 ( serialize ( $arrts ) );
                             $temp2 = false;
                             $check2 = $mem2_md5_1;
                             $check2 = strval($check2);
                             //
                             $temp1 = parse_memory_storage($check2);
                             if ($temp1 != false) {
                                 //var_dump ( $temp1 );
                                 $module_file = $temp1;
                             } else {
                                 //
                                 $try_config_file = normalize_path($try_config_file);
                                 $try_config_file = rtrim($try_config_file, '\\');
                                 $cache_this = true;
                                 $force_cache_this = false;
                                 if (is_file($try_config_file)) {
                                     $config = false;
                                     include $try_config_file;
                                     if (!empty($config)) {
                                         $check_icon = MODULES_DIR . '' . $attr['module'] . '.png';
                                         $icon = pathToURL($check_icon);
                                         //p($config);
                                         $config['icon'] = $icon;
                                         $this->template['config'] = $config;
                                         if (!empty($config['options'])) {
                                             $this->setup_module_options($config['options']);
                                         }
                                         $cache_for_session = false;
                                         if ($config['no_cache'] == true) {
                                             $cache_this = false;
                                             $do_not_cache_whole_block = true;
                                             $cache_for_session = true;
                                         }
                                         if ($config['cache'] == true) {
                                             $force_cache_this = true;
                                             $cache_for_session = true;
                                         }
                                         if ($config['no_edit'] == true) {
                                             $no_edit = true;
                                         }
                                         if ($config['no_admin'] == true) {
                                             $no_admin = true;
                                         }
                                     }
                                 }
                                 if ($arrts['no_cache'] == true) {
                                     $cache_this = false;
                                 }
                                 if ($options['no_cache'] == true) {
                                     $cache_this = false;
                                 }
                                 if ($force_cache_this == false) {
                                     if (strstr($attr['module'], 'admin/') == true) {
                                         $cache_this = false;
                                     }
                                 }
                                 if ($attr['module_id'] == true) {
                                     $mod_id = $attr['module_id'];
                                 } else {
                                     $mod_id = false;
                                 }
                                 if ($options['admin'] == true) {
                                     $cache_this = false;
                                 }
                                 $params_encoded = false;
                                 if ($force_cache_this == true) {
                                     $cache_this = true;
                                 }
                                 //var_dump($force_cache_this);
                                 if ($cache_this == true) {
                                     $cache_id = md5($try_file1) . md5(serialize($arrts));
                                     if ($cache_for_session == true) {
                                         $cache_id = md5($try_file1) . sess_id() . md5(serialize($arrts));
                                     }
                                     if ($_POST) {
                                         $cache_id = $cache_id . md5(serialize($_POST));
                                     }
                                     $cache_group = 'global/blocks/';
                                     $cache_content = CI::model('core')->cacheGetContentAndDecode($cache_id, $cache_group);
                                     if ($cache_content != false) {
                                         //var_dump($cache_content);
                                         $module_file = $cache_content;
                                     } else {
                                         $this->template['params'] = $arrts;
                                         $this->load->vars($this->template);
                                         //$module_file = $this->load->file ( $try_file1, true );
                                         $module_file = CI::file($try_file1, true);
                                         CI::model('core')->cacheWriteAndEncode($module_file, $cache_id, $cache_group);
                                     }
                                 } else {
                                     $this->template['params'] = $arrts;
                                     $this->load->vars($this->template);
                                     //$module_file = $this->load->file ( $try_file1, true );
                                     $module_file = CI::file($try_file1, true);
                                 }
                                 //$params_encoded = encode_var ( $arrts );
                                 $params_encoded = 'edit_tag';
                                 $params_module = codeClean($arrts['module']);
                             }
                             //if (($attr ['module'] != 'header') and ($attr ['module'] != 'footer')) {
                             //
                             if ($editmode == true) {
                                 //	p($m);
                                 //p( $arrts);
                                 if ($no_admin == true) {
                                     $no_admin_tag = ' no_admin="true" ';
                                 } else {
                                     $no_admin_tag = '';
                                 }
                                 if ($mod_id == true) {
                                     $mod_id_tag = ' module_id="' . $mod_id . '" ';
                                 } else {
                                     $mod_id_tag = '';
                                 }
                                 //$edtid_hash = base64_encode ( $m ['full_tag'] );
                                 $edtid_hash = 'edit_tag';
                                 if (strval($module_file) != '') {
                                     if ($options['do_not_wrap'] == true) {
                                         $module_file = $module_file;
                                     } else {
                                         if ($no_edit == false) {
                                             //$module_file = '<div onmouseup="load_edit_module_by_module_id(\'' . $mod_id . '\')" mw_params_encoded="' . $params_encoded . '"  mw_params_module="' . $params_module . '"    ' . $mod_id_tag . ' class="module" ' . $no_admin_tag . ' edit="' . $edtid_hash . '">' . $module_file . '</div>';
                                             $module_file = '<div mw_params_encoded="' . $params_encoded . '"  mw_params_module="' . $params_module . '"    ' . $mod_id_tag . ' class="module" ' . $no_admin_tag . ' edit="' . $edtid_hash . '">' . $module_file . '</div>';
                                             //$module_file = '<div mw_params_encoded="' . $params_encoded . '"  mw_params_module="' . $params_module . '"    ' . $mod_id_tag . ' class="module" ' . $no_admin_tag . ' edit="' . $edtid_hash . '">' . $module_file . '</div>';
                                         } else {
                                             $module_file = '<div  mw_params_encoded="' . $params_encoded . '" mw_params_module="' . $params_module . '"   ' . $mod_id_tag . ' ' . $no_admin_tag . '  class="module">' . $module_file . '</div>';
                                         }
                                     }
                                 } else {
                                     $module_file = false;
                                 }
                                 //	p($m ['full_tag']);
                             } else {
                                 if (strval($module_file) != '') {
                                     $module_file = '<div class="module" mw_params_encoded="' . $params_encoded . '" mw_params_module="' . $params_module . '"  >' . $module_file . '</div>';
                                 }
                             }
                             //}  ++
                             $module_file = str_replace('<mw', '<microweber', $module_file);
                             if (strstr($module_file, '<microweber') == true and $error == false) {
                                 $module_file = self::parseMicrwoberTags($module_file, $options);
                             }
                             $layout = str_replace_count($m['full_tag'], $module_file, $layout, 1);
                             //$layout = str_replace ( $m ['full_tag'], $module_file, $layout );
                             //$layout = str_replace_count ( '</microweber>', '', $layout, 1 );
                             $layout = str_replace_count('</mw>', '', $layout, 1);
                             $layout = str_replace_count('</microweber>', '', $layout, 1);
                             //$layout = str_replace ( '</mw>', '', $layout );
                             //$layout = str_replace ( '</microweber>', '', $layout );
                             //parse_memory_storage ( $check2, $layout );
                         }
                     }
                 }
             }
         }
     }
     if (strstr($layout, '<editable') == true and $error == false) {
         $editmode = CI::model('core')->is_editmode();
         //p($editmode);
         $relations = array();
         $tags = CI::model('core')->extractTags($layout, 'editable', $selfclosing = false, $return_the_entire_tag = true, $charset = 'UTF-8');
         $matches = $tags;
         if (!empty($matches)) {
             foreach ($matches as $m) {
                 if ($m['tag_name'] == 'editable') {
                     $attr = $m['attributes'];
                     $get_global = false;
                     if ($editmode == true) {
                     }
                     if ($attr['rel'] == 'global') {
                         $attr['global'] = true;
                         $get_global = true;
                     }
                     if ($attr['rel'] == 'page') {
                         $attr['page'] = PAGE_ID;
                     }
                     if ($attr['rel'] == 'post') {
                         $attr['post'] = POST_ID;
                         if ($attr['post'] == false) {
                             $attr['post'] = PAGE_ID;
                             //$attr ['page'] = PAGE_ID;
                         }
                     }
                     if ($attr['rel'] == 'category') {
                         $attr['category'] = CATEGORY_ID;
                     }
                     if ($attr['rel'] == 'module') {
                         $relate_to_module = true;
                     } else {
                         $relate_to_module = false;
                     }
                     if ($relate_to_module == false) {
                         if ($attr['page']) {
                             $data = get_page($attr['page']);
                         } else {
                             if ($attr['post']) {
                                 $data = get_post($attr['post']);
                                 if ($data == false) {
                                     $data = get_page($attr['post']);
                                 }
                                 //p ( $data );
                                 //p ( $attr );
                             } else {
                                 if ($attr['category']) {
                                     $data = get_category($attr['category']);
                                 } else {
                                     if ($attr['global']) {
                                         $get_global = true;
                                     }
                                 }
                             }
                         }
                     }
                     $cf = false;
                     $field_content = false;
                     if ($get_global == true) {
                         $field_content = CI::model('core')->optionsGetByKey($attr['field'], $return_full = false, $orderby = false);
                     } else {
                         if (strstr($attr['field'], 'custom_field_') == true) {
                             $cf = str_replace('custom_field_', '', $attr['field']);
                             $field_content = $data['custom_fields'][$cf];
                         } else {
                             $field_content = $data[$attr['field']];
                         }
                     }
                     //p($m ['full_tag']);
                     if (trim($field_content) == '') {
                         $field_content = $m['contents'];
                     } else {
                         //$quote_style = ENT_COMPAT [, string $charset = 'UTF-8' ]]
                         $field_content = htmlspecialchars_decode($field_content);
                         //$field_content = html_entity_decode ( $field_content, $quote_style = ENT_COMPAT, $charset = 'UTF-8' );
                     }
                     //	$field_content = html_entity_decode ( $field_content );
                     $field_content = htmlspecialchars_decode($field_content);
                     $attrs_to_append = false;
                     if ($editmode == true) {
                         foreach ($attr as $at_key => $at_value) {
                             $attrs_to_append .= "{$at_key}='{$at_value}' ";
                         }
                         //p($attrs_to_append);
                         $layout = str_replace_count($m['full_tag'], "<div class='edit' {$attrs_to_append}>" . $field_content . '</div>', $layout, 1);
                     } else {
                         $layout = str_replace_count($m['full_tag'], $field_content, $layout, 1);
                     }
                     $layout = str_replace('<mw', '<microweber', $layout);
                     if (strstr($layout, '<microweber') == true and $error == false) {
                         $layout = self::parseMicrwoberTags($layout, $options);
                     }
                 }
             }
         }
     }
     //{SITE_URL}
     $site_url = site_url();
     //$layout = str_replace ( '{SITE_URL}', $site_url, $layout );
     $layout = CI::model('core')->replace_in_long_text('{SITE_URL}', $site_url, $layout, true);
     $layout = CI::model('core')->replace_in_long_text('{SITEURL}', $site_url, $layout, true);
     //$layout = str_replace ( '{SITEURL}', $site_url, $layout );
     //$layout = $this->badWordsRemove ( $layout );
     if (defined('POST_ID') == true) {
         //$layout = str_replace ( '{POST_ID}', POST_ID, $layout );
         $layout = CI::model('core')->replace_in_long_text('{POST_ID}', POST_ID, $layout, true);
     }
     if (defined('PAGE_ID') == true) {
         //$layout = str_replace ( '{PAGE_ID}', PAGE_ID, $layout );
         $layout = CI::model('core')->replace_in_long_text('{PAGE_ID}', PAGE_ID, $layout, true);
     }
     if (defined('CATEGORY_ID') == true) {
         //$layout = str_replace ( '{CATEGORY_ID}', CATEGORY_ID, $layout );
         $layout = CI::model('core')->replace_in_long_text('{CATEGORY_ID}', CATEGORY_ID, $layout, true);
     }
     //	$this->load->vars ( $this->template );
     if (stristr($layout, 'content_meta_title')) {
         if (defined('POST_ID') == true) {
             $is_content = get_post(POST_ID);
             $is_content_post = $is_content;
             $layout = str_ireplace('{POST_ID}', POST_ID, $layout);
         }
         if ($is_content == false) {
             if (defined('PAGE_ID') == true) {
                 $is_content = get_page(PAGE_ID);
                 $is_content_page = $is_content;
             }
         }
         if ($is_content['content_meta_title']) {
             $content_meta_title = $is_content['content_meta_title'];
         } elseif ($is_content['content_title']) {
             $content_meta_title = codeClean($is_content['content_title']);
         } else {
             $content_meta_title = CI::model('core')->optionsGetByKey('content_meta_title');
         }
         $layout = str_ireplace('{content_meta_title}', $content_meta_title, $layout);
         if ($is_content['content_meta_keywords']) {
             $content_meta_title = $is_content['content_meta_keywords'];
         } else {
             $content_meta_title = CI::model('core')->optionsGetByKey('content_meta_keywords');
         }
         $layout = str_ireplace('{content_meta_keywords}', $content_meta_title, $layout);
         if ($is_content['content_meta_description']) {
             $content_meta_title = $is_content['content_meta_description'];
         } elseif ($is_content['content_description']) {
             $content_meta_title = codeClean($is_content['content_description']);
         } elseif ($is_content['content_body']) {
             $content_meta_title = codeClean($is_content['content_body']);
         } else {
             $content_meta_title = CI::model('core')->optionsGetByKey('content_meta_title');
         }
         $layout = str_ireplace('{content_description}', $content_meta_title, $layout);
     }
     if (is_file(ACTIVE_TEMPLATE_DIR . 'controllers/pre_layout_display.php')) {
         include ACTIVE_TEMPLATE_DIR . 'controllers/pre_layout_display.php';
     }
     if (strstr($layout, '<editable') == true or strstr($layout, '<mw') == true or strstr($layout, '<microweber') == true or strstr($layout, '<block') == true and $error == false) {
         $layout = self::parseMicrwoberTags($layout, $options);
     }
     if (!empty($txt_to_replace_back)) {
         foreach ($txt_to_replace_back as $k => $v) {
             //	$v = html_entity_decode($v);
             $layout = str_replace($k, $v, $layout);
         }
         $layout = str_replace('<nomw>', '', $layout);
         $layout = str_replace('</nomw>', '', $layout);
     }
     if (empty($relations)) {
         $layout = str_ireplace('</head>', $prepend_to_head . '</head>', $layout);
         //$layout= '<div class="mw_module">'.$layout.'</div>';
         $mem[$check] = $layout;
         //if ($do_not_cache_whole_block == false) {
         //CI::model ( 'core' )->cacheWriteAndEncode ( $layout, $cache_id, $cache_group );
         //}
         //CI::model ( 'core' )->cacheWrite ( $layout, $function_cache_id, $cache_group );
         return $layout;
     } else {
         //if ($do_not_cache_whole_block == false) {
         //CI::model ( 'core' )->cacheWriteAndEncode ( $v, $cache_id, $cache_group );
         //}
         //CI::model ( 'core' )->cacheWrite ( $v, $function_cache_id, $cache_group );
         $mem[$check] = $v;
         return $v;
     }
     //p($relations);
 }
コード例 #2
0
ファイル: content_model.php プロジェクト: Gninety/Microweber
 function getPostByURL($content_id, $url, $no_recursive = false)
 {
     //  header("Content-type: text/plain; charset=UTF-8");
     $function_cache_id = false;
     $args = func_get_args();
     foreach ($args as $k => $v) {
         $function_cache_id = $function_cache_id . serialize($k) . serialize($v);
     }
     $function_cache_id = __FUNCTION__ . md5($function_cache_id);
     $content_id = intval($content_id);
     $cache_group = 'content/' . $content_id;
     $cache_content = CI::model('core')->cacheGetContentAndDecode($function_cache_id, $cache_group);
     if ($cache_content != false) {
         return $cache_content;
     }
     global $cms_db_tables;
     if (strval($url) == '') {
         return false;
     }
     $id = array();
     $id['id'] = $content_id;
     $id = $this->contentGetById($id);
     $the_real_url = str_replace_count($id['content_url'], '', $url, 1);
     $the_real_url = trim_slashes($the_real_url);
     $url = $the_real_url;
     $table = $cms_db_tables['table_content'];
     $url = strtolower($url);
     //$content_url_md5 = md5 ( $url );
     $sql = "SELECT id, content_url from {$table} where content_url='{$url}' and content_type='post'   order by updated_on desc limit 0,1 ";
     $q = CI::model('core')->dbQuery($sql, md5($sql), 'content/global');
     $result = $q;
     if (!empty($result)) {
         $content = $result[0];
         $content = $content['id'];
     } else {
         return false;
     }
     $data = array();
     $data['id'] = $content;
     $content = $this->contentGetByIdAndCache($data['id']);
     if (empty($content)) {
         return false;
     } else {
         CI::model('core')->cacheWriteAndEncode($content, $function_cache_id, $cache_group);
         return $content;
     }
 }
コード例 #3
0
ファイル: Encoding.php プロジェクト: robtuley/knotwerk
 function testStrReplaceCountOverLimit()
 {
     $str = 'Iñtôërnâtiônàliôzætôiøn';
     $expected = 'Iñttëstërnâtitëstnàliôzætôiøn';
     $replace = str_replace_count('ô', 'tëst', $str, 2);
     $this->assertSame($replace, $expected);
 }