1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 05:07:27 +02:00

If cache is activated, the already parsed batch shortcode files are now written to cache

This commit is contained in:
mcfly
2006-12-03 07:03:22 +00:00
parent 6f98fa6a54
commit c51e07466e

View File

@@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $
| $Revision: 1.1.1.1 $ | $Revision: 1.2 $
| $Date: 2006-12-02 04:33:57 $ | $Date: 2006-12-03 07:03:22 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -159,27 +159,56 @@ class e_shortcode {
return $ret; return $ret;
} }
function parse_scbatch($fname, $type = 'file') { function parse_scbatch($fname, $type = 'file')
$ret = array(); {
global $e107cache, $eArrayStorage;
$cur_shortcoces = array();
if($type == 'file') if($type == 'file')
{
$batch_cachefile = "nomd5_".md5($fname);
// $cache_filename = $e107cache->cache_fname("nomd5_{$batchfile_md5}");
$sc_cache = $e107cache->retrieve($batch_cachefile);
if(!$sc_cache)
{ {
$sc_batch = file($fname); $sc_batch = file($fname);
} }
else else
{
$cur_shortcodes = $eArrayStorage->ReadArray($sc_cache);
$sc_batch = "";
}
}
else
{ {
$sc_batch = $fname; $sc_batch = $fname;
} }
$cur_sc = '';
foreach($sc_batch as $line) { if($sc_batch)
if (trim($line) == 'SC_END') { {
foreach($sc_batch as $line)
{
if (trim($line) == 'SC_END')
{
$cur_sc = ''; $cur_sc = '';
} }
if ($cur_sc && !$override) { if ($cur_sc)
$ret[$cur_sc] .= $line; {
$cur_shortcodes[$cur_sc] .= $line;
} }
if (preg_match("#^SC_BEGIN (\w*).*#", $line, $matches)) { if (preg_match("#^SC_BEGIN (\w*).*#", $line, $matches))
{
$cur_sc = $matches[1]; $cur_sc = $matches[1];
$ret[$cur_sc]=''; }
}
if($type == 'file')
{
$sc_cache = $eArrayStorage->WriteArray($cur_shortcodes, false);
$e107cache->set($batch_cachefile, $sc_cache);
}
}
foreach(array_keys($cur_shortcodes) as $cur_sc)
{
if (is_array($this -> registered_codes) && array_key_exists($cur_sc, $this -> registered_codes)) { if (is_array($this -> registered_codes) && array_key_exists($cur_sc, $this -> registered_codes)) {
if ($this -> registered_codes[$cur_sc]['type'] == 'plugin') { if ($this -> registered_codes[$cur_sc]['type'] == 'plugin') {
$scFile = e_PLUGIN.strtolower($this -> registered_codes[$cur_sc]['path']).'/'.strtolower($cur_sc).'.sc'; $scFile = e_PLUGIN.strtolower($this -> registered_codes[$cur_sc]['path']).'/'.strtolower($cur_sc).'.sc';
@@ -187,15 +216,11 @@ class e_shortcode {
$scFile = THEME.strtolower($cur_sc).'.sc'; $scFile = THEME.strtolower($cur_sc).'.sc';
} }
if (is_readable($scFile)) { if (is_readable($scFile)) {
$ret[$cur_sc] = file_get_contents($scFile); $cur_shortcodes[$cur_sc] = file_get_contents($scFile);
}
$override = TRUE;
} else {
$override = FALSE;
} }
} }
} }
return $ret; return $cur_shortcodes;
} }
} }