Source for file xt_globalscope.class.php

Documentation is available at xt_globalscope.class.php

  1. <?php   /*
  2.    *@=@=@=@ START LICENSE @=@=@=@*
  3.    Copyright or © or Copr. Stéphane TRICHET and Nicolas SOTRON
  4.    
  5.    stephane.t@simpliciweb.net and nicolas.s@simpliciweb.net
  6.    
  7.    This software is a computer program whose purpose is to make a
  8.    web hosting platform
  9.    
  10.    This software is governed by the CeCILL  license under French law and
  11.    abiding by the rules of distribution of free software.  You can  use, 
  12.    modify and/ or redistribute the software under the terms of the CeCILL
  13.    license as circulated by CEA, CNRS and INRIA at the following URL
  14.    "http://www.cecill.info". 
  15.    
  16.    As a counterpart to the access to the source code and  rights to copy,
  17.    modify and redistribute granted by the license, users are provided only
  18.    with a limited warranty  and the software's author,  the holder of the
  19.    economic rights,  and the successive licensors  have only  limited
  20.    liability. 
  21.    
  22.    In this respect, the user's attention is drawn to the risks associated
  23.    with loading,  using,  modifying and/or developing or reproducing the
  24.    software by the user in light of its specific status of free software,
  25.    that may mean  that it is complicated to manipulate,  and  that  also
  26.    therefore means  that it is reserved for developers  and  experienced
  27.    professionals having in-depth computer knowledge. Users are therefore
  28.    encouraged to load and test the software's suitability as regards their
  29.    requirements in conditions enabling the security of their systems and/or 
  30.    data to be ensured and,  more generally, to use and operate it in the 
  31.    same conditions as regards security. 
  32.    
  33.    The fact that you are presently reading this means that you have had
  34.    knowledge of the CeCILL license and that you accept its terms.
  35.    *@=@=@=@ END   LICENSE @=@=@=@*
  36.  
  37. */?><?php  
  38. /**
  39.  * XTGlobalScope Class
  40.  * 
  41.  * 
  42.  * @author SimpliciWeb
  43.  * @version $Id: xt_globalscope.class.php 606 2007-07-19 10:14:30Z stephanet $
  44.  * @package Common
  45.  * @subpackage FrameWork
  46.  */    
  47.  
  48.  
  49. /**
  50.  * Include 'internal_components/common/cache_class/object_cached.class.php'
  51.  */
  52. require_once('internal_components/common/cache_class/object_cached.class.php');
  53.  
  54. /**
  55.  * Manage special scopes
  56.  *
  57.  * @author SimpliciWeb
  58.  * @version $Id: xt_globalscope.class.php 606 2007-07-19 10:14:30Z stephanet $
  59.  * @package Common
  60.  * @subpackage FrameWork
  61.  */
  62. class XTGlobalScope extends ObjectCached{
  63.  
  64.     /**
  65.      * SQL Request : Delete
  66.      *
  67.      * @var string 
  68.      */
  69.       var $req_delete           = "delete from t_globalscope where gsc_type='%s';";  
  70.     /**
  71.      * SQL Request : Select
  72.      *
  73.      * @var string 
  74.      */
  75.       var $req_select           = "select gsc_object from t_globalscope where gsc_type='%s';";  
  76.     /**
  77.      * SQL Request : Insert
  78.      *
  79.      * @var string 
  80.      */
  81.       var $req_insert           = "insert into t_globalscope (gsc_type, gsc_object) values('%s','%s');";  
  82.     /**
  83.      * Database Connexion object
  84.      *
  85.      * @var DbConnexion 
  86.      */
  87.       var $m_object_dbconnexion    = NULL;
  88.      /**
  89.       * Supported types
  90.       *
  91.       * @var array 
  92.       */
  93.       var $m_types = array();
  94.     /**
  95.      * Already loaded informations
  96.      *
  97.      * @var array 
  98.      */
  99.       var $m_array_already_loader = array();
  100.       
  101.     /**
  102.      * Constructor, init the requests and objects
  103.      *
  104.      * @return XTGlobalScope 
  105.      */
  106.     function XTGlobalScope(){
  107.       global $g_object_loader;
  108.       $this->m_object_dbconnexion =$g_object_loader->getDbConnexion();
  109.       
  110.       $this->m_types['array_import_errors']         "a_i_e";
  111.       $this->m_types['array_import_default']         "a_i_d";
  112.       $this->m_types['array_weight_format']         "a_w_f";
  113.       $this->m_types['array_price_format']             "a_p_f";
  114.       $this->m_types['array_date_format']             "a_d_f";
  115.       $this->m_types['msg_no_deliverycosts_find']     "m_ndf";
  116.       $this->m_types['array_mail_settings']         "a_m_s";
  117.       $this->m_types['default_lang_id']             "d_l_i";
  118.       $this->m_types['number_product_pagefo']         "n_p_p";
  119.       $this->m_types['array_html_editor_format']    "a_h_f";
  120.       $this->m_types['rss_updated_page_suffix']        "u_p_s";
  121.       $this->m_types['array_web_site_width_informationprice_format']        
  122.                                                       = "swif_";
  123.       
  124.     }
  125.     
  126.     /**
  127.      * Is not valid type
  128.      *
  129.      * @param string $p_gsc_type 
  130.      * @return bool TRUE on error
  131.      */
  132.     function xIsNotValidType($p_gsc_type{
  133.         return !isset($this->m_types[$p_gsc_type]);
  134.     
  135.     }
  136.     
  137.     /**
  138.      * New
  139.      *
  140.      * @param string $p_gsc_type 
  141.      * @param mixed $p_gsc_object 
  142.      * @return bool TRUE on error
  143.      */
  144.     function xNewGlobal($p_gsc_type$p_gsc_object{
  145.         
  146.         $p_gsc_object serialize($p_gsc_object);
  147.         
  148.             
  149.         $there_is_an_error $this->xDelete($p_gsc_type);
  150.         if ($there_is_an_error{
  151.            return onErrorThrow(true,plici_lang("lang_error_deleteglobal"));
  152.         }
  153.         $there_is_an_error $this->xInsert($p_gsc_type$p_gsc_object);
  154.         if ($there_is_an_error{
  155.            return onErrorThrow(true,plici_lang("lang_error_insertglobal"));
  156.         }
  157.         
  158.         $this->xClearRemember($p_gsc_type);
  159.  
  160.         return false;
  161.     
  162.     }
  163.     
  164.     
  165.   /**
  166.    * Insert
  167.    *
  168.    * @param string $p_gsc_type 
  169.    * @param mixed $p_gsc_object 
  170.    * @return bool TRUE on error
  171.    */
  172.   function xInsert($p_gsc_type$p_gsc_object{
  173.     if ($this->xIsNotValidType($p_gsc_type)) {
  174.             return onErrorThrow(true,plici_lang("lang_error_field"));
  175.     }
  176.     $p_gsc_type $this->m_types[$p_gsc_type];
  177.     $parameters array();
  178.     $parameters[sizeof($parameters)$p_gsc_type;
  179.     $parameters[sizeof($parameters)$p_gsc_object;
  180.  
  181.     $this->xClearRemember($p_gsc_type);
  182.  
  183.     return $this->m_object_dbconnexion->makeSqlQuery($this->req_insert,  $parameters$result);
  184.   }   
  185.  
  186.   /**
  187.    * Delete
  188.    *
  189.    * @param string $p_gsc_type 
  190.    * @return bool TRUE on error
  191.    */
  192.   function xDelete($p_gsc_type{
  193.     if ($this->xIsNotValidType($p_gsc_type)) {
  194.             return onErrorThrow(true,plici_lang("lang_error_field"));
  195.     }
  196.     $p_gsc_type $this->m_types[$p_gsc_type];
  197.     $parameters array();
  198.     $parameters[sizeof($parameters)$p_gsc_type;
  199.  
  200.     $this->xClearRemember($p_gsc_type);
  201.     
  202.     return $this->m_object_dbconnexion->makeSqlQuery($this->req_delete,  $parameters$result);
  203.   }   
  204.   
  205.   /**
  206.    * Get
  207.    *
  208.    * @param string $p_gsc_type 
  209.    * @param mixed $r_gsc_object 
  210.    * @param string $p_database_selected 
  211.    * @return bool TRUE on error
  212.    */
  213.   function xGet($p_gsc_type&$r_gsc_object$p_database_selected=""{
  214.       $r_gsc_object "";
  215.     
  216.     
  217.     if ($this->xIsNotValidType($p_gsc_type)) {
  218.             return onErrorThrow(true,plici_lang("lang_error_field"));
  219.     }
  220.     $p_gsc_type $this->m_types[$p_gsc_type];
  221.     
  222.     if ($this->xIsRemembered($p_gsc_type.$p_database_selected$r_remembered_object)) {
  223.         $r_gsc_object $r_remembered_object;
  224.         return false;
  225.     }
  226.  
  227.     $parameters array();
  228.     $parameters[sizeof($parameters)$p_gsc_type;
  229.  
  230.     $this->m_object_dbconnexion->makeSqlQuery($this->req_select,  $parameters$result$p_database_selected);
  231.  
  232.     
  233.     if (!$result{
  234.         return onErrorThrow(true,plici_lang("lang_error_getglobalscope"));
  235.     }
  236.       
  237.     $is_filled false;
  238.     while($row mysql_fetch_row($result)){
  239.             $r_gsc_object $row[0];
  240.             $r_gsc_object unserialize($r_gsc_object);
  241.              $is_filled true;
  242.     }
  243.     
  244.     $this->xRemember($p_gsc_type.$p_database_selected$r_gsc_object);
  245.     
  246.     
  247.     return !$is_filled;
  248.     
  249.   
  250.   }
  251.   
  252.   /**
  253.    * Set array errors from import
  254.    *
  255.    * @param array $p_array_errors 
  256.    * @return bool TRUE on error
  257.    */
  258.   function setArrayErrorsFromImport($p_array_errors{
  259.       return $this->xNewGlobal('array_import_errors'$p_object);
  260.   }
  261.  
  262.   /**
  263.    * Destroy array erros from import
  264.    *
  265.    * @return bool TRUE on error
  266.    */
  267.   function destroyArrayErrorsFromImport({
  268.       return $this->xDelete('array_import_errors');
  269.   }
  270.  
  271.   /**
  272.    * Get from array errors from import
  273.    *
  274.    * @param array $r_array_errors 
  275.    * @return bool TRUE on error
  276.    */
  277.   function getArrayErrorsFromImport(&$r_array_errors{
  278.       return $this->xGet('array_import_errors'$r_array_errors);
  279.   }
  280.   
  281. }
  282.  
  283.  
  284.  
  285. ?>

Documentation generated on Tue, 25 Mar 2008 15:37:34 +0100 by phpDocumentor 1.3.2