Source for file config_smarty.inc

Documentation is available at config_smarty.inc

  1. <?php  
  2.  
  3.  
  4. /**
  5.  * Smarty: the PHP compiling template engine
  6.  * Smarty is a powerfull template engine
  7.  * 
  8.  * 
  9.  * @author SimpliciWeb
  10.  * @version $Id: config_smarty.inc 922 2008-03-22 09:35:03Z stephanet $
  11.  * @package Common
  12.  * @subpackage Start
  13.  */
  14.  
  15. $id_config_smarty_inc $g_object_time_elapser->beginningInclude("config_smarty.inc");
  16.  
  17.  
  18. /**
  19.  * Include the smarty library
  20.  * @ignore
  21.  */
  22. require('external_components/smarty/Smarty.class.php');
  23.  
  24. /**
  25.  * Include the php functions
  26.  */
  27. include_once('internal_components/common/globals/php_functions.inc.php');
  28.  
  29.  
  30.  
  31. /**
  32.  * The Smarty class modified for PLICI
  33.  * Smarty is a powerfull template engine
  34.  *
  35.  * @author SimpliciWeb
  36.  * @version $Id: config_smarty.inc 922 2008-03-22 09:35:03Z stephanet $
  37.  * @package Common
  38.  * @subpackage Start
  39.  */
  40. class Smarty_custom extends Smarty {
  41.  
  42.     /**
  43.      * The MD5 cache id generated by PLICI for using the Smarty cache
  44.      *
  45.      * @var string 
  46.      */
  47.     var $id_of_cache = "";
  48.     /**
  49.      * PLICI var to set if this page must use cache or not
  50.      *
  51.      * @var bool 
  52.      */
  53.     var $m_cannotbecached = false;
  54.     
  55.     /**
  56.      * Template required by PLICI
  57.      *
  58.      * @var string 
  59.      */
  60.     var $template_asked = "";
  61.  
  62.     /**
  63.      * Current page name from Url
  64.      *
  65.      * @var string 
  66.      */
  67.     var $page_name    = NULL;
  68.     /**
  69.      * ¨PLICI current page id
  70.      *
  71.      * @var integer 
  72.      */
  73.     var $page_id    = 0;
  74.     /**
  75.      * 
  76.      *
  77.      * @var string 
  78.      * @deprecated Seems to be not used
  79.      */
  80.     var    $page_tpl    = NULL;
  81.     
  82.     
  83.     /**
  84.      * The PLICI main {@link TPageFo} class
  85.      *      *
  86.      * @var TPageFo 
  87.      */
  88.     var $m_object_t_page = null;
  89.     
  90.     /**
  91.      * The PLICI main {@link siteInformation} class
  92.      *
  93.      * @var siteInformation 
  94.      */
  95.     var $m_object_siteinformation = null;
  96.     
  97.  
  98.     /**
  99.      * The PLICI var containing variable for all the web page (in any template)
  100.      *
  101.      * @var array 
  102.      */
  103.     var $m_tpl_var_for_all = array();
  104.  
  105.     /**
  106.      * Deprecated
  107.      *
  108.      * @var string 
  109.      * @deprecated Seems to ben not used
  110.      */
  111.     var $m_memory_id_of_cache = "";
  112.  
  113.     /**
  114.      * The file that contains the compiler class. This can a full
  115.      * pathname, or relative to the php_include path.
  116.      *
  117.      * @var string 
  118.      */
  119.     var $compiler_file        =    "";
  120.  
  121.     /**
  122.      * The class used for compiling templates.
  123.      *
  124.      * @var string 
  125.      */
  126.     var $compiler_class        =   'Smarty_Compiler_custom';    
  127.  
  128.     
  129.     /**
  130.      * The class constructor.
  131.      * PLICI load and configure the Smarty Object
  132.      *
  133.      * @param string $template_asked 
  134.      * @return Smarty_custom 
  135.      */
  136.     function Smarty_custom($template_asked ""{
  137.         
  138.         
  139.         $this->compiler_file        =    dirname(__FILE__).'/config_smarty_compiler.class.php';
  140.         
  141.         // Constructeur de la classe. Appelé automatiquement
  142.         // à l'instanciation de la classe.
  143.  
  144.         
  145.         /*global $g_object_loader;
  146.         $g_object_siteinformation =& $g_object_loader->getSiteInformation();
  147.         */
  148.         global $g_object_siteinformation;
  149.         $this->m_object_siteinformation =$g_object_siteinformation;
  150.           
  151.         
  152.  
  153.         $this->cache_modified_check 2400;
  154.         
  155.         $this->template_asked = $template_asked;
  156.         
  157.         $this->template_dir "";
  158.         $this->compile_dir $g_object_siteinformation->getTemplateCompiledFilePath();
  159.         $this->config_dir $g_object_siteinformation->getTemplateConfigFilePath();
  160.         $this->cache_dir $g_object_siteinformation->getTemplateCacheFilePath();
  161.  
  162.         
  163.         // verify alls temps directory :
  164.         $array_path_to_create array($this->compile_dir$this->config_dir$this->cache_dir);
  165.         foreach($array_path_to_create as $current_dir{
  166.         if (!file_exists($current_dir))
  167.             if (!@net_mkdirs($current_dir)) 
  168.             {
  169.                 echo "<h1 style='color:red;'>Error creating compile directory. </h1>";
  170.                 trigger_error("[".date("D M d G:i:s Y")."] "."Error creating cache directory :".$current_dir);
  171.                 flush;die();
  172.             }
  173.         }        
  174.  
  175.  
  176.         // partie d'activation du Cache seulement pour le FrontOffice
  177.         $this->caching false;
  178.         $this->compile_check true;
  179.         $post_no_session     $_POST;
  180.         $get_no_session     $_GET;
  181.         //$request_no_session = $_REQUEST;
  182.         
  183.         //print_r($post_no_session);
  184.         //print_r($get_no_session);
  185.         //print_r($request_no_session);
  186.     
  187.         // set if the page can be cached
  188.         $this->setCannotBeCached($g_object_siteinformation->isAdmin());
  189.         // permet de desactiver le cache pour les gens n'ayant pas les cookies
  190.         // actif, car sinon l'id de session se perdrait en tombant sur des pages
  191.         // cachées et sans id de session dans les liens
  192.         if (isset($post_no_session[$g_object_siteinformation->getSessionBoIdName()]
  193.             || isset($get_no_session[$g_object_siteinformation->getSessionBoIdName()])
  194.             //|| isset($request_no_session[$g_object_siteinformation->getSessionBoIdName()])
  195.             
  196.             || isset($post_no_session[$g_object_siteinformation->getSessionFoIdName()])
  197.             || isset($get_no_session[$g_object_siteinformation->getSessionFoIdName()])
  198.             //|| isset($request_no_session[$g_object_siteinformation->getSessionFoIdName()])
  199.         {
  200. //            echo_net("not cached because SESSIONID");
  201.             $this->setCannotBeCached(true);
  202.         }
  203.  
  204.         //$this->setCannotBeCached(true);
  205.  
  206.         // permet de forcer le cache si il s'agit d'un JS ou CSS même en Back Office
  207.         if ($this->canNotBeCached())
  208.             $this->setCannotBeCached(!$g_object_siteinformation->isJssOrCss());
  209.  
  210.         if (DBG_FORCE_NO_USING_CACHE{
  211. //            echo_net("not cached because localhost access");
  212.             $this->setCannotBeCached(true);
  213.         }
  214.             //$this->setCannotBeCached(true);
  215.         
  216.         // quand un utilisateur est logué, il faut activer un cache spécifique pour lui
  217.         // car il peut avoir des infos qui lui sont propres
  218.         
  219.         if (!$g_object_siteinformation->isAdmin()) {
  220.             global $g_object_loader;
  221.             if (!isset($g_object_loader)) {
  222.             /**
  223.              * Include 'internal_components/common/loader/object_loader.class.php'
  224.              */
  225.             require_once('internal_components/common/loader/object_loader.class.php');
  226. // not needed, now the require instanciante the objectloader:              $g_object_loader = new ObjectLoader();
  227.               }
  228.  
  229.             $object_tcustomerfo =$g_object_loader->getTCustomerFo();
  230.             $r_email=""$r_cus_id="";
  231.             $object_tcustomerfo->getCustomerAuthentQuick($r_email$r_cus_id);
  232.             if ($r_email != "" && $r_cus_id != ""{
  233.                     $post_no_session['internal_spw_user_email'$r_email
  234.                     $post_no_session['internal_spw_user_cus_id'$r_cus_id
  235.             }
  236.         }
  237.         
  238.             $this->left_delimiter '{';
  239.             $this->right_delimiter '}';            
  240.  
  241.         $this->id_of_cache = md5(serialize($post_no_session).serialize($get_no_session));
  242.         
  243.         if (!$this->canNotBeCached()) {
  244.             $this->caching true;
  245.             $this->cache_lifetime 86400;
  246.         }
  247.  
  248.  
  249.         // a therme il faudrait pouvoir mettre TRUE a la valeur de security
  250.         //        ca permet ensuite dans $this->secure_dir de mettre les repertoires
  251.         //        qui sont autorisés et forcèment ca bloque pas mal :)
  252.         $this->security true;
  253.  
  254.         $this->security_settings["PHP_HANDLING"false
  255.         $this->security_settings["INCLUDE_ANY"true;
  256.         $this->security_settings["PHP_TAGS"false;
  257.         $this->security_settings["IF_FUNCS"]
  258.             [sizeof($this->security_settings["IF_FUNCS"])"TRUE";
  259.         $this->security_settings["IF_FUNCS"]
  260.             [sizeof($this->security_settings["IF_FUNCS"])"FALSE";
  261.         $this->security_settings["MODIFIER_FUNCS"]
  262.             [sizeof($this->security_settings["MODIFIER_FUNCS"])"urlencode";
  263.         $this->security_settings["MODIFIER_FUNCS"]
  264.             [sizeof($this->security_settings["MODIFIER_FUNCS"])"default";
  265.  
  266.  
  267.  
  268.  
  269.         // Détermination page courante
  270.         $this->page_name = $g_object_siteinformation->getUriForIniSection();
  271.         if (strlen($this->page_name)) {
  272.             if ('p' == $this->page_name[0]{
  273.                 $array_path explode("/"$this->page_name);
  274.                 $this->page_id =substr(array_shift($array_path),1);
  275.                 $this->page_name = implode('/',$array_path);
  276.             }
  277.         }
  278.         
  279.         // enregistre le filtre de sortie
  280.         $this->register_outputfilter("protect_email");
  281.         
  282.         if (!$g_object_siteinformation->isAdmin()) 
  283.             $this->register_outputfilter("smarty_outputfilter_parseplicitag");
  284.         
  285.         $this->register_block('not_cached''smarty_bloc_dynamique'falsearray("design_id""page_id"));
  286.  
  287.         // plicitag
  288.         $this->register_block('plicitag''smarty_plicitag'falsearray("charged_dynamicly_by_compiler_from_every_tag"));
  289.         $this->register_block('parse_plicitag''smarty_parse_plicitag'falsearray("charged_dynamicly_by_compiler_from_every_tag"));
  290.         
  291.         $this->load_filter('pre''plici')
  292.         
  293.         
  294.         //just for testing if demo web site became better : $this->load_filter('output', 'neternel');
  295.  
  296.         // on configure smarty en fonction du repertoire de template qui dépend
  297.         $this->setTemplateDirAndSecureDir($template_asked);
  298.  
  299.         
  300.  
  301.         parent::Smarty();
  302.  
  303.     }
  304.  
  305.     /**
  306.      * Used for closing the debug printing when acceding to a page with www.sample.com/?plici_debug=true
  307.      * 
  308.      * @access private
  309.      * @return string 
  310.      */
  311.     function xxCloseDebugDiv({
  312.         return '</div>';
  313.     }
  314.     
  315.     /**
  316.      * Used for closing the debug printing when acceding to a page with www.sample.com/?plici_debug=true
  317.      * 
  318.      * @access private
  319.      *
  320.      */
  321.     function xCloseDebugDiv({
  322.         echo($this->xxCloseDebugDiv());
  323.     }
  324.     
  325.     /**
  326.      * Used for openning the debug printing when acceding to a page with www.sample.com/?plici_debug=true
  327.      *
  328.      * @param string $p_type 
  329.      * @param string $p_include_name 
  330.      * @return string 
  331.      */
  332.     function xxOpenDebugDiv($p_type$p_include_name{
  333.         
  334.         
  335.         $bgcolor array(    'block_auto_container'     => '#FFAAAA',
  336.                             'block_auto_link'         => '#AAFFAA',
  337.                             'plicitag'                => '#AAFFAA',
  338.                             'block_auto_sublink'     => '#AAAAFF',
  339.                             'middle_template'        => 'white',
  340.                             'include'                => 'black',
  341.         );
  342.         $color array(            'block_auto_container'     => 'black',
  343.                                 'block_auto_link'         => 'black',
  344.                                 'plicitag'                 => 'black',
  345.                                 'block_auto_sublink'     => 'black',
  346.                                 'middle_template'        => 'red',    
  347.                                 'include'                => 'white',
  348.         );
  349.         
  350.         $short_type array(    'block_auto_container'     => 'ctn',
  351.                                 'block_auto_link'         => 'lnk',
  352.                                 'plicitag'                 => 'tag',
  353.                                 'block_auto_sublink'     => 'slnk',
  354.                                 'middle_template'        => 'Template used',    
  355.                                 'include'                => '>'
  356.         );
  357.         if (isset($color[$p_type]&& isset($color[$p_type]&& isset($short_type[$p_type]))
  358.             if ($p_type == "middle_template"{
  359.                 $result (sprintf("<div style='text-align:center;'><span style='background-color: %s;color: %s;'>[%s]%s</span>"
  360.                             $bgcolor[$p_type]$color[$p_type]$short_type[$p_type]$p_include_name));
  361.                 else {
  362.                 $result (sprintf("<div style='border: thin solid %s;'><span style='background-color: %s;color: %s;'>[%s]%s</span>"
  363.                             $bgcolor[$p_type]$bgcolor[$p_type]$color[$p_type]$short_type[$p_type]$p_include_name));
  364.             }        
  365.         
  366.         return $result;
  367.     }
  368.     /**
  369.      * Used for openning the debug printing when acceding to a page with www.sample.com/?plici_debug=true
  370.      * 
  371.      * @access private
  372.      * @param string $p_type 
  373.      * @param string $p_include_name 
  374.      * @return bool 
  375.      */
  376.     function xOpenDebugDiv($p_type$p_include_name{
  377.         
  378.         
  379.         echo($this->xxOpenDebugDiv($p_type$p_include_name));    
  380.             
  381.         return true;
  382.     }
  383.     
  384.     /**
  385.      * called for included templates
  386.      * PLICI manage this blocs here : <!--{include file="block_auto_container"}-->
  387.      *
  388.      * @param array $params 
  389.      * @return string 
  390.      */
  391.     function  _smarty_include($params){    
  392.         global $g_object_siteinformation;
  393.         global $g_object_loader;
  394.         
  395.         // print_r($params);
  396.         
  397.         //<!--{include file="block_auto_container"}-->
  398.         //<!--{include file="`$container.des_template_detail`" list_page=$container.list_page}-->
  399.  
  400.         //<!--{include file="block_auto_link"}-->
  401.         $old_tpl_vars "";
  402.         $we_have_to_close_div false;
  403.         if (isset($params['smarty_include_tpl_file']))
  404.             if ($params['smarty_include_tpl_file'== "block_auto_container" {
  405.                 $object_tpage =$g_object_loader->getTPageFo();
  406.  
  407.                 $container $object_tpage->getMyBlockValue();
  408.                 $params['smarty_include_tpl_file'$container['des_template_detail'];
  409.  
  410.                 if (DBG_SMARTY_VIEW_CONTAINER && !$g_object_siteinformation->isAdmin())
  411.                     $we_have_to_close_div $this->xOpenDebugDiv('block_auto_container'$params['smarty_include_tpl_file']);
  412.                 $object_tpage->setCurrentPageList($container['list_page']);
  413.                 //$params['smarty_include_vars']['list_page'] = $container['list_page'];
  414.                     
  415.             else if ($params['smarty_include_tpl_file'== "block_auto_link" {
  416.                 $object_tpage =$g_object_loader->getTPageFo();
  417.                 $page $object_tpage->getMyBlockValue();
  418.  
  419.                 
  420.                 
  421.                 $params['smarty_include_tpl_file']                    $page['des_template_link'];
  422.                 
  423.                 if (DBG_SMARTY_VIEW_LINKS && !$g_object_siteinformation->isAdmin())
  424.                     $we_have_to_close_div $this->xOpenDebugDiv('block_auto_link'$params['smarty_include_tpl_file']);
  425.  
  426.                 $object_tpage->setCurrentPageId($page['page_id']);
  427.                 
  428.                 $params['smarty_include_vars']['design_id']         $page['page_link_design'];
  429.                 $params['smarty_include_vars']['id']                 $page['page_id'];
  430.                 $params['smarty_include_vars']['title']             $page['page_title'];
  431.                 $params['smarty_include_vars']['template_detail']     $page['des_template_detail'];
  432.                 $params['smarty_include_vars']['plici_page_mod_id'$page['page_mod_id'];
  433.                 $params['smarty_include_vars']['plici_page_mod_index'$page['page_mod_index'];
  434.                 $params['smarty_include_vars']['page_picture'$page['page_picture'];
  435.                 
  436.                 // here plicitag
  437.                 $params['smarty_include_vars']['plici_page_link_plicitag'$page['page_link_plicitag'];
  438.                 
  439.                 
  440.                 // on ne transmet à cette include que ses propres variables
  441.                 $old_tpl_vars $this->_tpl_vars;
  442.                 
  443.                 
  444.                 if ((!isset($object_tpage->m_array_link_data[$page['page_id']])) || (!is_array($object_tpage->m_array_link_data[$page['page_id']]))){
  445.                     $this->_tpl_vars $this->m_tpl_var_for_all;
  446.                 else if (!is_array($this->m_tpl_var_for_all)) {
  447.                     $this->_tpl_vars $object_tpage->m_array_link_data[$page['page_id']];
  448.                 else {
  449.                 $this->_tpl_vars array_merge($object_tpage->m_array_link_data[$page['page_id']]
  450.                                     $this->m_tpl_var_for_all);
  451.                 }
  452.                 
  453.             else if ($params['smarty_include_tpl_file'== "block_auto_sublink" {
  454.                 $object_tpage =$g_object_loader->getTPageFo();
  455.                 $sub_link $object_tpage->getMyBlockValue();
  456.                 //print_r_net($sub_link);
  457.                 $params['smarty_include_tpl_file']                    $sub_link['des_template_link'];
  458.  
  459.                 if (DBG_SMARTY_VIEW_SUB_LINKS  && !$g_object_siteinformation->isAdmin())
  460.                     $we_have_to_close_div $this->xOpenDebugDiv('block_auto_sublink'$params['smarty_include_tpl_file']);
  461.  
  462.  
  463.                 $params['smarty_include_vars']['id']                 $sub_link['page_id'];
  464.                 $params['smarty_include_vars']['design_id']         $sub_link['page_link_des_id'];
  465.  
  466.                 // on ne transmet à cette include que ses propres variables
  467.                 $old_tpl_vars $this->_tpl_vars;
  468.                 //$this->_tpl_vars = array_merge($sub_link['page_data'], $this->m_tpl_var_for_all);
  469.  
  470.  
  471.                 if (!is_array($sub_link['page_data']))
  472.                     $this->_tpl_vars $this->m_tpl_var_for_all;
  473.                 else if (!is_array($this->m_tpl_var_for_all))
  474.                     $this->_tpl_vars $sub_link['page_data'];
  475.                 else
  476.                     $this->_tpl_vars array_merge($sub_link['page_data']$this->m_tpl_var_for_all);
  477.  
  478.                     
  479.  
  480.                 //$params['smarty_include_vars']['data']                 = $sub_link['page_data'];
  481.                 $params['smarty_include_vars']['title']             $sub_link['page_title'];
  482.                 $params['smarty_include_vars']['template_detail']     $sub_link['des_template_detail'];
  483.                 $params['smarty_include_vars']['plici_page_mod_id'$sub_link['page_mod_id'];
  484.                 $params['smarty_include_vars']['plici_page_mod_index'$sub_link['page_mod_index'];
  485.                 
  486.                 // here plicitag
  487.                 $params['smarty_include_vars']['plici_page_link_plicitag'$sub_link['page_link_plicitag'];
  488.                 
  489.                 
  490.             else if (substr($params['smarty_include_tpl_file'],0,6== "PLICI:"{
  491.                 /**
  492.                  * This is a hack 
  493.                  * In template when using "include file=" in not a container loop, var cant register
  494.                  * Now, when use include file in template we must set link with mark as
  495.                  * include file="PLICI:link/little_shopping_cart.tpl"
  496.                  */
  497.  
  498.                 if (DBG_SMARTY_VIEW_INCLUDES_NAME  && !$g_object_siteinformation->isAdmin())
  499.                     $we_have_to_close_div $this->xOpenDebugDiv('include'$params['smarty_include_tpl_file']);
  500.                 
  501.                 
  502.                 $params['smarty_include_tpl_file'substr($params['smarty_include_tpl_file'],6);
  503.                 //echo_net($params['smarty_include_tpl_file']);
  504.                 $object_tpage =$g_object_loader->getTPageFo();
  505.                 //echo_net($object_tpage->m_array_links);
  506.                 $sub_link "";
  507.                 foreach ($object_tpage->m_array_links as $array_link1
  508.                 foreach ($array_link1 as $array_link{
  509.                     if (isset($array_link['list_page'])) {
  510.                         foreach($array_link['list_page'as $pages{
  511.                             if ($pages['des_template_link'== $params['smarty_include_tpl_file']{
  512.                                 $link_data $this->m_object_t_page->m_array_link_data[$pages['page_id']];
  513.                                 //echo_net($link_data);
  514.                                 $sub_link $pages;
  515.                                 $sub_link['page_data'$link_data;
  516.                                 break 3;
  517.                             }
  518.                         }
  519.                     }
  520.                     
  521.                 }
  522.                 
  523.                 $params['smarty_include_vars']['id']                 $sub_link['page_id'];
  524.                 $params['smarty_include_vars']['design_id']         $sub_link['page_link_des_id'];
  525.  
  526.                 // on ne transmet à cette include que ses propres variables
  527.                 $old_tpl_vars $this->_tpl_vars;
  528.                 //$this->_tpl_vars = array_merge($sub_link['page_data'], $this->m_tpl_var_for_all);
  529.  
  530.  
  531.                 if (!is_array($sub_link['page_data']))
  532.                     $this->_tpl_vars $this->m_tpl_var_for_all;
  533.                 else if (!is_array($this->m_tpl_var_for_all))
  534.                     $this->_tpl_vars $sub_link['page_data'];
  535.                 else
  536.                     $this->_tpl_vars array_merge($sub_link['page_data']$this->m_tpl_var_for_all);
  537.  
  538.                     
  539.  
  540.                 //$params['smarty_include_vars']['data']                 = $sub_link['page_data'];
  541.                 $params['smarty_include_vars']['title']             $sub_link['page_title'];
  542.                 $params['smarty_include_vars']['template_detail']     $sub_link['des_template_detail'];
  543.                 $params['smarty_include_vars']['plici_page_mod_id'$sub_link['page_mod_id'];
  544.                 $params['smarty_include_vars']['plici_page_mod_index'$sub_link['page_mod_index'];
  545.                 
  546.                 // here plicitag
  547.                 $params['smarty_include_vars']['plici_page_link_plicitag'$sub_link['page_link_plicitag'];
  548.                                 
  549.                 
  550.                 //echo_net($this->_tpl_vars);
  551.                 
  552.             else {
  553.                 if (DBG_SMARTY_VIEW_INCLUDES_NAME  && !$g_object_siteinformation->isAdmin())
  554.                     $we_have_to_close_div $this->xOpenDebugDiv('include'$params['smarty_include_tpl_file']);
  555.             }
  556.         
  557.         // @SIMPLICIWEB@ : permet d'utiliser le template dont le theme herite si il n'en a pas un propre
  558.         $template_not_compiled_path "";
  559.         $template_not_compiled_path_old "";
  560.         
  561.         
  562.         if ($g_object_siteinformation->isAdmin()) {
  563.                 // on est dans du Bakc Office, la logique est différente car il n'y a pas de thème, juste le changement
  564.                 // de my en for_plici
  565. //                trigger_error("Ask template : ".$params['smarty_include_tpl_file']);
  566.                 if (!file_exists($this->template_dir.'/'.$params['smarty_include_tpl_file'])) {
  567.                     
  568. //                    trigger_error("Old template_dir :".$this->template_dir);
  569.                     
  570.                     $template_not_compiled_path_old $this->template_dir;
  571.                     $this->template_dir $g_object_siteinformation->getTemplateNotCompiledFilePath();
  572. //                    trigger_error("New template_dir : ".$this->template_dir);
  573.                 }
  574.         else // on est dans dans du front, donc on fait l'héritage tout simple
  575.             if ($g_object_siteinformation->getExistTemplateNotCompiledFilePath(
  576.                 $params['smarty_include_tpl_file']
  577.                 $template_not_compiled_path)) {
  578.                 $template_not_compiled_path_old $this->template_dir;
  579.                 $this->template_dir $template_not_compiled_path;
  580.         }
  581.         
  582.         $to_return =  parent::_smarty_include($params);
  583.  
  584.         if ($we_have_to_close_div)
  585.             $this->xCloseDebugDiv();
  586.         
  587.     
  588.         if ($template_not_compiled_path_old != ""{
  589.             $this->template_dir $template_not_compiled_path_old;
  590. //            trigger_error("Restore the include path to ".$this->template_dir);
  591.         }
  592.         
  593.         
  594.         if (isset($params['smarty_include_tpl_file']))
  595.             if ($params['smarty_include_tpl_file'== "block_auto_container" {
  596.                 $object_tpage =$g_object_loader->getTPageFo();
  597.                 $object_tpage->setCurrentPageList(array());
  598.                                 
  599.             else if ($params['smarty_include_tpl_file'== "block_auto_link" {
  600.                 $this->_tpl_vars $old_tpl_vars;
  601.                 
  602.             else if ($params['smarty_include_tpl_file'== "block_auto_sublink" {
  603.                 $this->_tpl_vars $old_tpl_vars;
  604.  
  605.             }
  606.                 
  607.         return $to_return;    
  608.     }
  609.  
  610.     /**
  611.      * PLICI force this page to not be cached
  612.      *
  613.      * @param bool $p_not_be_cached 
  614.      */
  615.     function setCannotBeCached($p_not_be_cached)
  616.     {
  617.         if ($p_not_be_cached)
  618.         {
  619.             $this->m_cannotbecached = true;
  620.             $this->caching false;
  621.             $this->cache_lifetime 0;
  622.         else {
  623.             $this->m_cannotbecached = false;
  624.             $this->caching true;
  625.             $this->cache_lifetime 86400;
  626.         }
  627.     }
  628.  
  629.     /**
  630.      * Accessor for m_cannotbecached
  631.      *
  632.      * @return bool 
  633.      */
  634.     function canNotBeCached({
  635.         return $this->m_cannotbecached;
  636.     }
  637.     
  638.     // permet d'introduire completement le système de cache par ID dans
  639.  
  640.     /**
  641.      * test to see if valid cache exists for this template
  642.      * PLICI can bypass this function to force template to not be cached
  643.      *
  644.      * @param string $p_tpl_name name of template file
  645.      * @return string|falseresults of {@link _read_cache_file()}
  646.      */    
  647.     function is_cached($p_tpl_name{
  648.         
  649.         if ($this->canNotBeCached()) {
  650. //            echo_net("canNotBeCached");
  651.             return false;
  652.         else {
  653. //            echo_net("is_cached $p_tpl_name, {$this->id_of_cache}");
  654.             return    parent::is_cached($p_tpl_name$this->id_of_cache);
  655.         }
  656.     }
  657.     
  658.  
  659.     /**
  660.      * Assign to Smarty a var $p_name wich contain the htmleditor code to print
  661.      *
  662.      * @param string $p_name       The smarty var name
  663.      * @param string $p_value      Value into the input
  664.      * @param array $p_template    Template list
  665.      * @param array $p_bbcode      BBcode list
  666.      * @param string $p_skin       Skin name
  667.      * @param string $p_lang       The default language code
  668.      */
  669.     function setHtmlEditor($p_name$p_value=NULL$p_template=NULL$p_bbcode=NULL$p_skin=NULL$p_lang=NULL{
  670.         global $g_object_loader;
  671.         $object_html_editor =$g_object_loader->getHtmlEditor();
  672.         $html_editor_frame "";
  673.         $object_html_editor->getHtmlEditorCode($p_name$html_editor_framestr_replace("\r""",str_replace("\n"""$p_value))strtoupper($p_template)$p_bbcode$p_skin$p_lang);
  674.         $this->assign($p_name$html_editor_frame);
  675.     }
  676.  
  677.     /**
  678.      * PLICI save the tab index
  679.      *
  680.      */
  681.     function saveTabIndex({
  682.         $a_tab_selected getFromArray('f_tab_selected'$_REQUESTNULL);
  683. //echo "\n<br /><DEBUG> === Sauvegarde des index === ";
  684. //print_r_net($a_tab_selected);
  685.         if (NULL != $a_tab_selected{
  686.             // Enregistrement dans la session
  687.             foreach ($a_tab_selected as $key => $val{
  688.                 $_SESSION['tab'][$this->page_id][$key$val;
  689.             }
  690.         }
  691.     }
  692.     
  693.     /**
  694.      * PLICI load the tab index
  695.      *
  696.      * @param integer $r_tab_selected 
  697.      */
  698.     function loadTabIndex(&$r_tab_selected{
  699.         $r_tab_selected = isset($_SESSION['tab'][$this->page_id])?$_SESSION['tab'][$this->page_id]:NULL;
  700.     }
  701.  
  702.  
  703.     
  704.  
  705.     /**
  706.      * executes & displays the template results
  707.      * PLICI make many tratement to print the correct html code
  708.      *
  709.      * @param string $template 
  710.      * @param bool $notFromMessage  Set to false if is from the {@link Message} class only
  711.      * @param bool $is_using_cache  Define if cache is used, then make different treatement
  712.      * @param bool $notFromTBoUser  Set to false if is from the {@link TBoUser} class only
  713.      * @return none 
  714.      */
  715.     function display($template$notFromMessage true$is_using_cache false$notFromTBoUser true{
  716.         
  717.         global $plici_current_father_path$g_object_siteinformation,$_PLICI_CFG;
  718.  
  719.         if (DBG_SMARTY_VIEW_INCLUDES_NAME && !$g_object_siteinformation->isAdmin()) {
  720.             $this->xOpenDebugDiv("middle_template"$template);
  721.             $this->xCloseDebugDiv();
  722.         }
  723.         
  724.  
  725.  
  726.         
  727.         
  728.         if ($g_object_siteinformation->isAdmin(|| $g_object_siteinformation->isJssOrCss())
  729.         {
  730.             return $this->xDisplayInternal($template$notFromMessage $is_using_cache$notFromTBoUser );
  731.         else {
  732.             if (!$g_object_siteinformation->getExistTemplateNotCompiledFilePath($template$r_unused))
  733.             {
  734.                 echo "<h1 style='color:red;'>Error design file</h1>".$template;
  735.                 die();
  736.             }
  737.         }
  738.     
  739.         global $g_object_loader;
  740.         // on regardes si on doit envoyer un mail
  741.         if (!isset($g_object_loader)) {
  742.             // on declare le $g_object_loader car il peut ne pas exister
  743.             // si on est sur une page de cache
  744. /**
  745.  * Include 'internal_components/common/loader/object_loader.class.php'
  746.  */
  747. require_once('internal_components/common/loader/object_loader.class.php');
  748.             global $g_object_loader;
  749. // not needed, now the require instanciante the objectloader:            $g_object_loader = new ObjectLoader();
  750.         }        
  751.         $object_pagemail =$g_object_loader->getPageMail();
  752.  
  753.         if ($object_pagemail->getMustSendMail()) {
  754.             ob_start();
  755.             $this->xDisplayInternal($template$notFromMessage $is_using_cache );
  756.             $content_html ob_get_contents();
  757.             ob_end_clean();
  758.  
  759.             $object_pagemail->send($content_html);            
  760.         
  761.             echo($content_html);
  762.             
  763.         else {
  764.             $this->xDisplayInternal($template$notFromMessage $is_using_cache );
  765.         }
  766.         
  767.     
  768.     
  769.     /**
  770.      * Template memory
  771.      *
  772.      * @var string 
  773.      */
  774.     var $memori_of_template_name = "";
  775.  
  776.     /**
  777.      * From a short template path, find and set the good template and secure directory for Smarty.
  778.      *
  779.      * @param string $p_template_name Template path
  780.      */
  781.     function setTemplateDirAndSecureDir($p_template_name{
  782.         if ($this->memori_of_template_name == $p_template_name)
  783.             return;
  784.         // on configure smarty en fonction du repertoire de template qui dépend
  785.         $template_not_compiled_path "";
  786.         global $g_object_siteinformation;
  787.         $g_object_siteinformation->getExistTemplateNotCompiledFilePath($p_template_name$template_not_compiled_path);
  788.  
  789.         $this->template_dir $template_not_compiled_path;
  790. //        echo_net("====> this->template_dir = ".$template_not_compiled_path);
  791.         $this->secure_dir array($template_not_compiled_path);
  792.         
  793.         $this->memori_of_template_name = $p_template_name;
  794.     }
  795.     
  796.     
  797.     
  798.     /**
  799.      * Display the template
  800.      *
  801.      * @access private
  802.      * 
  803.      * @param string $template 
  804.      * @param bool $notFromMessage 
  805.      * @param bool $is_using_cache 
  806.      * @param bool $notFromTBoUser 
  807.      */
  808.     function xDisplayInternal($template$notFromMessage true$is_using_cache false$notFromTBoUser true{
  809.         global $g_object_time_elapser;
  810.         global $g_object_loader;
  811.         $id_template_time $g_object_time_elapser->beginningTemplate($template);
  812.  
  813.         global $g_object_siteinformation;
  814.             
  815.         $smarty =$this;
  816.  
  817.         $tab_index "";
  818.         // On sauvegarde les onglets
  819.         $this->saveTabIndex();
  820.         // On charge les onglets
  821.         $this->loadTabIndex($tab_index);
  822.         if (!= count($tab_index))
  823.             $this->assign_by_ref("array_tab_selected"$tab_index);
  824.  
  825. //        
  826. //        *** STEF *** ce cas ne devrait plus exister on doit utiliser des
  827. //                    redirectoanddie        
  828. //                    ex :$object_siteinformation->redirectToAndDie("pE_MAILS/buying/deleted_account.html");
  829. //
  830. //
  831. //        if ($this->template_asked != $template) {
  832. //            // nous sommes dans le cas ou le tempate annoncé en debut d'entrees
  833. //            // n'est pas le même que celui demandé au final
  834. //            // les premier includes de init.inc ont pu ne pas être loadé
  835. //            // il faut les loader si le cache n'existe pas
  836. //            if (!Smarty::is_cached($template, $this->id_of_cache)) {
  837. //require_once('internal_components/common/globals/not_included_if_cached.inc');
  838. //            }
  839. //            
  840. //        }
  841. //        
  842.  
  843.         global $plici_current_father_path$g_object_siteinformation,$_PLICI_CFG;
  844.         $last_item = isset($plici_current_father_path)?count($plici_current_father_path)-1:0;
  845.         // si c'est un module et qu'on demande une page d'admin, on va chercher le patron dans view/sites/my/admin_sites
  846.         if ($plici_current_father_path[$last_item]['bo_menu_place'== "MODULE" && $g_object_siteinformation->isAdmin()) {
  847.                 $module_template_directory $_PLICI_CFG['racine_web'].'/'.
  848.                                             PLICI_VIEW_SITES_MY_ADMIN_SITES_DIRECTORY.'/'.
  849.                                             PLICI_MOD_USER_DIRECTORY."/".
  850.                                             $plici_current_father_path[1]['id'];
  851.                 // on définit proprement l'environnement du module
  852.                 //echo_net($module_template_directory);
  853.                 $this->template_dir $module_template_directory;
  854.                 $this->secure_dir array($module_template_directory);                
  855.                 
  856.         else {
  857.  
  858.             // on configure smarty en fonction du repertoire de template qui dépend
  859.             $this->setTemplateDirAndSecureDir($template);
  860.         }
  861.         
  862.  
  863.         // ces asign_for_all on en a besoin même dans les fichiers qui n'ont pas la chance
  864.         // de pouvoir être cachées, il faut les laisserà disposition
  865.  
  866.         $picture_http_path_spe $g_object_siteinformation->getPictureHttpPath();
  867.         //$picture_http_path_not_spe = $g_object_siteinformation->getPictureHttpPathNotSpe();
  868.         
  869.         /*doit pointer vers son propre repertoire*/
  870.         $this->assign_for_all('picture_path_special',  $picture_http_path_spe);
  871.         /*forcement pointer vers le repertoir du thème si il est saisi dans la BD*/ 
  872.         /*doit pointer vers le thème si il existe sinon son propre repertoire*/
  873.         $this->assign_for_all('picture_path',  $picture_http_path_spe);//$picture_http_path_not_spe);
  874.         $this->assign_for_all('root_http_current'$g_object_siteinformation->getBaseHttp());
  875.  
  876.         
  877.         if ($is_using_cache == false
  878.         {
  879.     
  880.  
  881.         // partie devant etre traité que si le cache n'est pas utilisé
  882.     
  883.             
  884.             if ($notFromMessage /*&& $g_object_siteinformation->isAdmin()*/{
  885.                 $g_object_message =$g_object_loader->getMessage();
  886.  
  887.                 $r_message array();
  888.                 $g_object_message->getMessagesToAssign($r_message);
  889.                 $smarty->assign_by_ref('error_msg'$r_message);
  890.                 
  891.             }
  892.     
  893.     
  894.             global $_PLICI_CFG;
  895.             if ($g_object_siteinformation->isAdmin()) {
  896.  
  897.                 $this->assign('picture_path_bo'$g_object_siteinformation->getPictureHttpPathBO());
  898.                 $this->assign('full_root_url_fo_without_language'$g_object_siteinformation->getBaseFullHttpFoWithoutLanguage());
  899.                 $this->assign('js_dialog_http_path',  $g_object_siteinformation->getHttpPathJsDialog());
  900.                 $this->assign('dbg_admin_show_btn_modift_help'DBG_ADMIN_SHOW_BTN_MODIFY_HELP);
  901.                 
  902.                 if (isset($_PLICI_CFG['masteruser_name']))
  903.                     $this->assign('master_user_from_cfg'$_PLICI_CFG['masteruser_name']);
  904.                 else
  905.                     $this->assign('master_user_from_cfg'"");
  906.                 
  907.                 if (isset($_PLICI_CFG['uid']))
  908.                     $this->assign('uid_from_cfg'$_PLICI_CFG['uid']);
  909.                 else
  910.                     $this->assign('uid_from_cfg'"");
  911.                                         
  912.                 if ($notFromTBoUser == true && !$g_object_siteinformation->isJssOrCss()) {
  913.                     $o_bo_users =$g_object_loader->getTBoUsers();
  914.                     $this->assign('g_admin_login'$o_bo_users->GetNick());
  915.                 }
  916.                 
  917.                  
  918.                 
  919.             }
  920.  
  921.             $this->assign('plici_version'(isset($_PLICI_CFG['version'])?$_PLICI_CFG['version']:"n/c"));
  922.             
  923.             
  924.             if (isset($_PLICI_CFG['uid']))
  925.                 $this->assign('uid_from_cfg'$_PLICI_CFG['uid']);
  926.             else
  927.                 $this->assign('uid_from_cfg'"");
  928.         
  929.             global $g_object_loader;
  930.             $object_db_connexion =&    $g_object_loader->getDbConnexion();
  931.             $this->assign_for_all('is_ecommerce_web_site'$object_db_connexion->getIsEcommerceWebSite());
  932.             
  933.             
  934.             
  935.             // besoin pour les stats de phpmyvisite (avant c t que dans admin)
  936.             $this->assign('full_root_url_fo'$g_object_siteinformation->getBaseFullHttpFo());
  937.             
  938.             $this->assign('root_http_current_ref'$g_object_siteinformation->getBaseHttpReferencing());
  939.             $this->assign('is_not_local_host'$g_object_siteinformation->isNotLocalhost());
  940.             $this->assign('http_css_file'$g_object_siteinformation->getHttpCssFile());
  941.             $this->assign('http_css_file_fo'$g_object_siteinformation->getHttpCssFileFo());
  942.             $this->assign('http_js_file',  $g_object_siteinformation->getHttpJsFile());
  943.             $this->assign('site_name',  $g_object_siteinformation->getSiteName());
  944.  
  945.     
  946.         }    
  947.         
  948.         
  949.         
  950.         
  951.         
  952.         
  953.         // disable the notice only for Smarty
  954. //        global $plici_error_handling_disable_e_notice;
  955. //        onErrorThrow(true, "----------------------PLOP START!!!! ".$template); 
  956. //        $plici_error_handling_disable_e_notice = true;
  957.         parent::display($template$this->id_of_cache);
  958. //        $plici_error_handling_disable_e_notice = false; 
  959. //        onErrorThrow(true, "----------------------PLOP END!!!! ".$template); 
  960.         
  961.         
  962.         
  963.         
  964.         
  965.         
  966.         
  967.         $g_object_time_elapser->endingTemplate($id_template_time);
  968.         
  969.     }
  970.  
  971.     /**
  972.      * Accessor for $this->template_asked
  973.      *
  974.      * @return string 
  975.      */
  976.     function getTemplateAsked({return $this->template_asked;}
  977.  
  978.  
  979.     /**
  980.      * assigns values to template variables
  981.      * PLICI set this template var for all the tempaltes (details and links)
  982.      *
  983.      * @param string $tpl_var the template variable name
  984.      * @param mixed $value the referenced value to assign
  985.      * @return none 
  986.      */
  987.     function assign_for_all($tpl_var$value null){
  988.         $this->m_tpl_var_for_all[$tpl_var=   $value;
  989.         return $this->assign($tpl_var$value);
  990.     }
  991.     
  992.     /**
  993.      * assigns values to template variables by reference
  994.      * PLICI set this template var for all the template for the web page
  995.      *
  996.      * @param string $tpl_var the template variable name
  997.      * @param mixed $value the referenced value to assign
  998.      * @return none 
  999.      */
  1000.     function assign_by_ref_for_all($tpl_var&$value){
  1001.         $this->m_tpl_var_for_all[$tpl_var=   &$value;
  1002.         return $this->assign_by_ref($tpl_var$value);
  1003.     }
  1004.  
  1005.     /**
  1006.      * assigns values to template variables
  1007.      * PLICI set this template var only for the page template (only for details, not for links)
  1008.      *
  1009.      * @param string $tpl_var the template variable name
  1010.      * @param mixed $value the referenced value to assign
  1011.      * @return none 
  1012.      */
  1013.     function assign_to_page($tpl_var$value null){
  1014.         return parent::assign($tpl_var$value);
  1015.     }
  1016.     
  1017.     /**
  1018.      * assigns values to template variables by reference
  1019.      * PLICI set this template var only for the page template (only for details, not for links)
  1020.      *
  1021.      * @param string $tpl_var the template variable name
  1022.      * @param mixed $value the referenced value to assign
  1023.      * @return none 
  1024.      */
  1025.     function assign_by_ref_to_page($tpl_var&$value){
  1026.         return parent::assign_by_ref($tpl_var$value);
  1027.     }
  1028.     
  1029.     /**
  1030.      * assigns values to template variables
  1031.      * PLICI play with the vars to set it only for the needed template
  1032.      *
  1033.      * @param array|string$tpl_var the template variable name(s)
  1034.      * @param mixed $value the value to assign
  1035.      * @return none 
  1036.      */
  1037.     function assign($tpl_var$value null)
  1038.     {
  1039.         // si c'est un cas normal on ne cherche pas à comrpendre c'est la même fonction
  1040.         // mais si c'est un include, on stock les infos dans le tableau qui va bien
  1041.         if (!$this->m_object_siteinformation->isAdmin() ) {
  1042.             if (is_null($this->m_object_t_page)) {
  1043.                 global $g_object_loader
  1044.                 if (isset($g_object_loader))
  1045.                     $this->m_object_t_page =$g_object_loader->getTPageFo();
  1046.             
  1047.         
  1048.         if ($this->m_object_t_page != null)
  1049.             if ($this->m_object_t_page->m_current_in_php_include_page_id != -1{
  1050.                 $this->m_object_t_page->m_array_link_data[$this->m_object_t_page->m_current_in_php_include_page_id][$tpl_var$value;
  1051.                 return ;
  1052.             else {
  1053.                 return parent::assign($tpl_var$value);
  1054.             }
  1055.         }
  1056.         return parent::assign($tpl_var$value);
  1057.     }
  1058.     
  1059.     /**
  1060.      * assigns values to template variables by reference
  1061.      * PLICI play with the vars to set it only for the needed template
  1062.      *
  1063.      * @param string $tpl_var the template variable name
  1064.      * @param mixed $value the referenced value to assign
  1065.      * @return none 
  1066.      */
  1067.     function assign_by_ref($tpl_var&$value)
  1068.     {
  1069.         // si c'est un cas normal on ne cherche pas à compendre c'est la même fonction
  1070.         // mais si c'est un include, on stock les infos dans le tableau qui va bien
  1071.  
  1072.         if (!$this->m_object_siteinformation->isAdmin() ) {
  1073.             if (is_null($this->m_object_t_page)) {
  1074.                 global $g_object_loader
  1075.                 if (isset($g_object_loader))
  1076.                     $this->m_object_t_page =$g_object_loader->getTPageFo();
  1077.             
  1078.             if ($this->m_object_t_page != null)
  1079.                 if ($this->m_object_t_page->m_current_in_php_include_page_id != -1{
  1080.                     $this->m_object_t_page->m_array_link_data[$this->m_object_t_page->m_current_in_php_include_page_id][$tpl_var&$value;
  1081.                     return ;
  1082.                 else {
  1083.                     return parent::assign_by_ref($tpl_var$value);
  1084.                 }
  1085.         }
  1086.         return parent::assign_by_ref($tpl_var$value);
  1087.         
  1088.     }    
  1089.  
  1090. }
  1091.  
  1092.  
  1093.  
  1094.  
  1095. $g_object_time_elapser->endingInclude($id_config_smarty_inc);
  1096. ?>

Documentation generated on Tue, 25 Mar 2008 15:32:57 +0100 by phpDocumentor 1.3.2