mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 04:40:44 +02:00
If cache is activated, the already parsed batch shortcode files are now written to cache
This commit is contained in:
@@ -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,43 +159,68 @@ 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')
|
||||||
{
|
{
|
||||||
$sc_batch = file($fname);
|
$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);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$cur_shortcodes = $eArrayStorage->ReadArray($sc_cache);
|
||||||
|
$sc_batch = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sc_batch = $fname;
|
$sc_batch = $fname;
|
||||||
}
|
}
|
||||||
$cur_sc = '';
|
|
||||||
foreach($sc_batch as $line) {
|
if($sc_batch)
|
||||||
if (trim($line) == 'SC_END') {
|
{
|
||||||
$cur_sc = '';
|
foreach($sc_batch as $line)
|
||||||
|
{
|
||||||
|
if (trim($line) == 'SC_END')
|
||||||
|
{
|
||||||
|
$cur_sc = '';
|
||||||
|
}
|
||||||
|
if ($cur_sc)
|
||||||
|
{
|
||||||
|
$cur_shortcodes[$cur_sc] .= $line;
|
||||||
|
}
|
||||||
|
if (preg_match("#^SC_BEGIN (\w*).*#", $line, $matches))
|
||||||
|
{
|
||||||
|
$cur_sc = $matches[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($cur_sc && !$override) {
|
if($type == 'file')
|
||||||
$ret[$cur_sc] .= $line;
|
{
|
||||||
|
$sc_cache = $eArrayStorage->WriteArray($cur_shortcodes, false);
|
||||||
|
$e107cache->set($batch_cachefile, $sc_cache);
|
||||||
}
|
}
|
||||||
if (preg_match("#^SC_BEGIN (\w*).*#", $line, $matches)) {
|
}
|
||||||
$cur_sc = $matches[1];
|
|
||||||
$ret[$cur_sc]='';
|
foreach(array_keys($cur_shortcodes) as $cur_sc)
|
||||||
if (is_array($this -> registered_codes) && array_key_exists($cur_sc, $this -> registered_codes)) {
|
{
|
||||||
if ($this -> registered_codes[$cur_sc]['type'] == 'plugin') {
|
if (is_array($this -> registered_codes) && array_key_exists($cur_sc, $this -> registered_codes)) {
|
||||||
$scFile = e_PLUGIN.strtolower($this -> registered_codes[$cur_sc]['path']).'/'.strtolower($cur_sc).'.sc';
|
if ($this -> registered_codes[$cur_sc]['type'] == 'plugin') {
|
||||||
} else {
|
$scFile = e_PLUGIN.strtolower($this -> registered_codes[$cur_sc]['path']).'/'.strtolower($cur_sc).'.sc';
|
||||||
$scFile = THEME.strtolower($cur_sc).'.sc';
|
|
||||||
}
|
|
||||||
if (is_readable($scFile)) {
|
|
||||||
$ret[$cur_sc] = file_get_contents($scFile);
|
|
||||||
}
|
|
||||||
$override = TRUE;
|
|
||||||
} else {
|
} else {
|
||||||
$override = FALSE;
|
$scFile = THEME.strtolower($cur_sc).'.sc';
|
||||||
|
}
|
||||||
|
if (is_readable($scFile)) {
|
||||||
|
$cur_shortcodes[$cur_sc] = file_get_contents($scFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $cur_shortcodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user