$value) { s_log("Replacing $key with $value",0,0,3); $file=str_replace($key, $value, $file); } } return $file; } function h_template_get_file_from_memory($template_file) { global $__HOPP_TEMPLATE_MEMORY_CACHE__; if(is_array($__HOPP_TEMPLATE_MEMORY_CACHE__)) { s_log("Looking for file $template_file in memory",0,0,3); if(!empty($__HOPP_TEMPLATE_MEMORY_CACHE__[$template_file])) { s_log("File $template_file found in memory",0,0,3); return $__HOPP_TEMPLATE_MEMORY_CACHE__[$template_file]; } } } function h_template_put_file_into_memory($template_file, $file) { s_log("Storing persistent template file $template_file",0,0,3); global $__HOPP_TEMPLATE_MEMORY_CACHE__; $__HOPP_TEMPLATE_MEMORY_CACHE__[$template_file]=$file; } /* 2003-02-02 Sandino Araico Sánchez - New version of template probe function * The old one was not useful enough and had many unused features which * were causing many problems and were limiting factors. */ function h_template_probe_name($name, $template_dir='', $extra_extensions='') { s_log("probing $name",0,0,3); if(empty($name)) return; if(file_exists($name)) return $name; $extensions=__HOPP_TEMPLATE_EXTENSIONS.($extra_extensions?" $extra_extensions":''); s_log("Extensions: $extensions",0,0,3); $ext_array=explode(' ',$extensions); foreach($ext_array as $ext) { s_log("Looking for estension $ext at the end of $name",0,0,3); if(eregi("\.$ext$", $name)) continue; s_log("Probing $name with estension $ext",0,0,3); $file="$name.$ext"; s_log($file,0,0,3); if(file_exists($file)) return $file; } if(($template_dir)&&(!strstr($name,$template_dir))) { $i=h_template_probe_name("$template_dir/$name",'',$extra_extensions); if($i) return $i; } if((defined('__HOPP_TEMPLATE_DIR__'))&&(!strstr($name,__HOPP_TEMPLATE_DIR__))) { $i=h_template_probe_name(__HOPP_TEMPLATE_DIR__."/$name",'',$extra_extensions); if($i) return $i; } s_log("probing $name unsuccessful",0,0,3); } /* These functions have not been used. * They will be back if someone complains at hopp@sandino.net * They will be deleted next release if nobody complains. */ #function basic_template_container_hardcoded($template, $theme="", $subtheme="") #{ # return basic_template_container_general(0,0, $template, "H", 0, $theme, $subtheme); #} # #function basic_template_container_with_variables($template, $array, $theme="", $subtheme="") #{ # return basic_template_container_general(0,0, $template, "V", $array, $theme, $subtheme); #} # #/* 2000-10-17 Sandino Araico Sánchez # * This function is ready to expand variables contained in the array $data # * in the inclusion of the template. # * It is possible to expand a functon but I don't want to mess with function names. # * Perhaps a variable-expand to function-expand template translator is possible # * but it's not the purpose of this function and should be done in a separate one. # */ #function basic_template_container_general($id, $use_id, $template_file, $expand, $data, $theme, $subtheme, $probe=1) #{ # if(empty($template_file)) # return; # s_log("Trying to include template from $template_file",0,0,3); # // If the template does not exist we should look for it # if(!file_exists($template_file)) # return ($probe?basic_template_container_general($id, $use_id, basic_template_container_probe_name($template_file, $theme, $subtheme), $expand, $data, $theme, $subtheme,0):""); # s_log("Including template from $template_file",0,0,3); # switch($expand) # { # case "F": # case "V": # /* We are using a macro here # * Care should be taken that macros are executable on include # * Notice that we use include instead of require # */ # $__HOPP_VARIABLES_ARRAY__=$data; # include "include/MACRO/extract_variables_from_array.inc"; # default: # return $template_file; # } #} #function basic_template_container_probe_name($name, $theme="", $subtheme="", $recurse=1) #{ # s_log("probing $name, theme: $theme, subtheme: $subtheme, recurse: $recurse",0,0,3); # if(empty($name)) # return; # if(file_exists($name)) # return $name; # if($theme) # { # if($subtheme) # { # $i=basic_template_container_probe_name("$theme/$subtheme/$name","","",$recurse); # if($i) # return $i; # $i=basic_template_container_probe_name("$theme/$name_$subtheme","","",$recurse); # if($i) # return $i; # $i=basic_template_container_probe_name("$theme/$name.$subtheme","","",$recurse); # if($i) # return $i; # } # $i=basic_template_container_probe_name("$theme/$name","","",$recurse); # if($i) # return $i; # */ # if(!strstr($name, __HOPP_TEMPLATE_DIR__)) # { # $i=basic_template_container_probe_name(__HOPP_TEMPLATE_DIR__."$name","","",$recurse); # if($i) # return $i; # } # if(!ereg("(\.php$)|(\.inc$)|(\.html$)", $name)) # { # $i=basic_template_container_probe_name("$name.html","","",$recurse); # if($i) # return $i; # $i=basic_template_container_probe_name("$name.inc","","",$recurse); # if($i) # return $i; # $i=basic_template_container_probe_name("$name.php","","",$recurse); # if($i) # return $i; # } # # if($recurse) # { # global $__HOPP_THEME__; # if($__HOPP_THEME__) # { # $i=basic_template_container_probe_name($name, $__HOPP_THEME__, $subtheme, 0); # if($i) # return $i; # } # // FIXME - "default" seems not to be working as expected..... # /*$i=basic_template_container_probe_name($name, "default", $subtheme, 0); # if($i) # return $i;*/ # } # if(!defined('__HOPP_TEMPLATE_DIR__')&&!ereg("^hopp/template/", $name)) # { # if(!ereg("^template/", $name)) # { # $i=basic_template_container_probe_name("template/$name","","",$recurse); # if($i) # return $i; # } # else # { # $i=basic_template_container_probe_name("hopp/$name","","",$recurse); # if($i) # return $i; # } # } # s_log("probing $name unsuccessful",0,0,3); #} #--------------------------------------------------------------------- } //__HOPP_TEMPLATE_BASIC ?>