- Timestamp:
- Mar 23, 2009, 9:39:37 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/xpress_block_render.php
r134 r135 158 158 } 159 159 160 function xpress_block_cache_refresh() 161 { 162 global $xoops_db; 163 $mid = get_xpress_modid(); 164 $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid AND visible = 1"; 165 $blocks = $xoops_db->get_results($sql); 166 $mydirname = get_xpress_dir_name(); 167 require_once get_xpress_dir_path() . '/include/xpress_block_render.php'; 168 169 foreach($blocks as $block){ 170 $func_file = $block->func_file; 171 $call_theme_function_name = str_replace(".php", "", $func_file); 172 $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php'; 173 $cache_title = str_replace(".php", "", $func_file); 174 $blockID = $block->bid; 175 $options = explode("|", $block->options); 176 177 $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name); 178 require_once $block_theme_file; 179 $render = $call_theme_function_name($options); //The block name and the called function name should be assumed to be the same name. 180 $render_array['block'] = $render; 181 $render_array['block']['options'] = $block->options; 182 if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 183 $render_serialize = xpress_XML_serialize($render_array); 184 $render_md5 = md5($render_serialize); 185 186 $cache_serialize = xpress_cache_read($mydirname,$cache_title. $blockID.'.xml'); 187 $cache_md5 = md5($cache_serialize); 188 189 if ($render_md5 != $cache_md5){ 190 xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array); 191 } 192 } else { 193 xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array); 194 } 195 } 196 } 197 198 function xpress_unnecessary_block_cache_delete() 199 { 200 global $xoops_db,$xoops_config; 201 $mid = get_xpress_modid(); 202 $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid AND visible = 1"; 203 $blocks = $xoops_db->get_results($sql); 204 $mydirname = get_xpress_dir_name(); 205 require_once get_xpress_dir_path() . '/include/xpress_block_render.php'; 206 207 $pattern =''; 208 foreach($blocks as $block){ 209 $cache_file_name = $mydirname . '_'. str_replace(".php", "", $block->func_file) . $block->bid; 210 if (!empty($pattern)) $pattern .= '|'; 211 $pattern .= $cache_file_name; 212 } 213 $pattern = '(' . $pattern . ')'; 214 215 $cache_dir = $xoops_config->xoops_root_path . '/cache/'; 216 $cache_time = 0; 217 if ($dh = opendir($cache_dir)) { 218 while (($file = readdir($dh)) !== false) { 219 if (preg_match('/^' . preg_quote($mydirname) . '/', $file)) { 220 if(! preg_match('/' . $pattern . '/', $file)) { 221 unlink($cache_dir.$file); 222 } 223 } 224 } 225 closedir($dh); 226 } 227 } 228 160 229 ?> -
trunk/include/xpress_templates_make.php
r124 r135 86 86 'meta_block.html' , 87 87 'sidebar_block.html' , 88 'widget_block.html' , 88 89 'index.html', 89 90 ); -
trunk/wp-config.php
r133 r135 95 95 //When adding, and changing and deleting Post & Comment, block cache is refreshed by add_action at any time. 96 96 // This Function in xpressme plugin 97 if (!is_block_cache_normal()) block_cache_refresh(); 97 xpress_unnecessary_block_cache_delete(); 98 if (is_home()) xpress_block_cache_refresh(); 98 99 exit(); // The return to wp-blog-header.php is stolen here 99 100 } -
trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php
r133 r135 113 113 return false; 114 114 } 115 116 }117 118 119 function is_block_cache_found($block_name)120 {121 global $xoops_config;122 $mydirname = get_xpress_dir_name();123 124 if(defined('XOOPS_ROOT_PATH')){125 $cache_dir = XOOPS_ROOT_PATH . '/cache/';126 } else {127 $cache_dir = $xoops_config->xoops_root_path . '/cache/';128 }129 $xml_name = $block_name . '.xml';130 131 $filename = $cache_dir .$mydirname . '_' . $xml_name;132 $cache_time = 0;133 // if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) {134 if (file_exists($filename)) {135 return true;136 } else {137 return false;138 }139 }140 141 142 //When there is no block cash, and an optional block is different, false is returned.143 function is_block_cache_normal()144 {145 global $xoops_config;146 global $xoops_db;147 $mid = get_xpress_modid();148 $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid ";149 $blocks = $xoops_db->get_results($sql);150 $mydirname = get_xpress_dir_name();151 require_once get_xpress_dir_path() . '/include/xpress_block_render.php';152 153 foreach($blocks as $block){154 $func_file = $block->func_file;155 $call_theme_function_name = str_replace(".php", "", $func_file);156 $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';157 $cache_title = str_replace(".php", "", $func_file);158 $blockID = $block->bid;159 $options = explode("|", $block->options);160 161 if (!is_block_cache_found($cache_title . $blockID)) return false;162 $xml = xpress_block_cache_read($mydirname,$cache_title. $blockID);163 $options = '';164 $options = @$xml['block']['options'];165 if( strcmp($options,$block->options) != 0 ) return false;166 }167 return true;168 }169 170 171 function block_cache_refresh()172 {173 global $xoops_db;174 $mid = get_xpress_modid();175 $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid";176 $blocks = $xoops_db->get_results($sql);177 $mydirname = get_xpress_dir_name();178 require_once get_xpress_dir_path() . '/include/xpress_block_render.php';179 180 181 foreach($blocks as $block){182 $func_file = $block->func_file;183 $call_theme_function_name = str_replace(".php", "", $func_file);184 $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';185 $cache_title = str_replace(".php", "", $func_file);186 $blockID = $block->bid;187 $options = explode("|", $block->options);188 189 $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name);190 require_once $block_theme_file;191 $block_render = $call_theme_function_name($options); //The block name and the called function name should be assumed to be the same name.192 $xml['block'] = $block_render;193 $xml['block']['options'] = $block->options;194 xpress_block_cache_write($mydirname,$cache_title. $blockID, $xml);195 }196 115 } 197 116 -
trunk/wp-content/themes/xpress_default/blocks/block_style.css
r124 r135 323 323 324 324 } 325 /*********** widget block ***************/ 326 .xpress_widget_block { 327 328 } 329 .xpress_widget_block h2{ 330 font-size: 10pt; 331 332 }
Note: See TracChangeset
for help on using the changeset viewer.