Source for file xt_text.class.php

Documentation is available at xt_text.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. /**
  40.  * XTText Class
  41.  * 
  42.  * 
  43.  * @author SimpliciWeb
  44.  * @version $Id: xt_text.class.php 609 2007-07-23 10:24:28Z nicolas_s $
  45.  * @package Common
  46.  * @subpackage FrameWork
  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.  * Abstract class to manage unique text to save in database
  55.  *
  56.  * @author SimpliciWeb
  57.  * @version $Id: xt_text.class.php 609 2007-07-23 10:24:28Z nicolas_s $
  58.  * @package Common
  59.  * @subpackage FrameWork
  60.  */
  61.  
  62.   class XTText extends ObjectCached {
  63.   
  64.     /**
  65.      * SQL Request : Insert
  66.      *
  67.      * @var string 
  68.      */      
  69.     var $req_insert           = "";  
  70.     /**
  71.      * SQL Request : Delete
  72.      *
  73.      * @var string 
  74.      */
  75.       var $req_delete           = "";  
  76.     /**
  77.      * SQL Request : Select
  78.      *
  79.      * @var string 
  80.      */
  81.       var $req_select           = "";  
  82.  
  83.      /**
  84.      * Database Connexion object
  85.      *
  86.      * @var DbConnexion 
  87.      */
  88.       var $m_object_dbconnexion    = NULL;
  89.     /**
  90.      * SiteInformation Object
  91.      *
  92.      * @var siteInformation 
  93.      */
  94.       var $m_object_siteinformation = NULL;
  95.       
  96. /**
  97.  * Already loaded
  98.  *
  99.  * @var array 
  100.  */
  101.       var $m_array_already_loader = array();
  102.    
  103.   /**
  104.    * Constructor, init the requests and objects
  105.    *
  106.    * @return XTText 
  107.    */
  108.   function XTText ({
  109.       global $g_object_loader;
  110.       $this->m_object_siteinformation =$g_object_loader->getSiteInformation();
  111.       $this->m_object_dbconnexion =$g_object_loader->getDbConnexion();
  112.  
  113.       $this->req_insert           = "insert into t_text(tex_type, ".multilang('tex_desc'TRUE).", tex_date) values('%s','%s', NOW());";  
  114.       $this->req_delete           = "delete  from t_text where tex_type='%s';";  
  115.       $this->req_select           = "select ".multilang('tex_desc').",  DATE_FORMAT(tex_date, '%%e/%%m/%%Y'), tex_type from t_text where tex_type='%s';";  
  116.   }
  117.   
  118.   
  119.  
  120.     
  121.   /**
  122.    * Insert
  123.    *
  124.    * @access private
  125.    * @param string $p_tex_type 
  126.    * @param string $p_tex_desc 
  127.    * @param bool $p_from_html_editor 
  128.    * @param bool $p_allow_empty 
  129.    * @return bool TRUE on error
  130.    */
  131.   function xInsert($p_tex_type$p_tex_desc$p_from_html_editor=false$p_allow_empty=false{
  132.      if ((0==strlen(trim($p_tex_desc))) && (!$p_allow_empty)) {
  133.         return true;
  134.      }
  135.      
  136.      $this->xDelete($p_tex_type);
  137.         
  138.      $parameters array();
  139.      array_push($parameters$p_tex_type);
  140.      if ($p_from_html_editor)
  141.      {
  142.          array_push($parameters$this->m_object_dbconnexion->translate("FCK_TO_DB_FCK"$p_tex_desc));
  143.      else {
  144.          array_push($parameters$p_tex_desc);
  145.      }
  146.      
  147.      $this->xClearRemember($p_tex_type);
  148.  
  149.      return $this->m_object_dbconnexion->makeSqlQuery($this->req_insert$parameters$result);
  150.   }     
  151.      
  152.   /**
  153.    * Delete
  154.    *
  155.    * @access private
  156.    * @param string $p_tex_type 
  157.    * @return bool TRUE on error
  158.    */
  159.   function xDelete($p_tex_type{
  160.      
  161.      $parameters array();
  162.      $parameters[sizeof($parameters)$p_tex_type;
  163.  
  164.      $this->xClearRemember($p_tex_type);
  165.  
  166.      return $this->m_object_dbconnexion->makeSqlQuery($this->req_delete,  $parameters$result);
  167.   }       
  168.      
  169.   
  170.   /**
  171.    * Get
  172.    *
  173.    * @access private
  174.    * @param string $p_tex_type 
  175.    * @param string $r_result 
  176.    * @param string $p_from_type 
  177.    * @param string $p_database_selected 
  178.    * @return bool TRUE on error
  179.    */
  180.   function xGet($p_tex_type&$r_result$p_from_type="NONE"$p_database_selected =""{
  181.         if ($this->xIsRemembered($p_tex_type.$p_database_selected$r_rememberded_value)) {
  182.              $r_result $r_rememberded_value;
  183.              return false;
  184.          }
  185.          $r_result array();
  186.          $parameters array();
  187.          $parameters[sizeof($parameters)$p_tex_type;
  188.  
  189.          if ($this->m_object_dbconnexion->makeSqlQuery($this->req_select$parameters$result$p_database_selected))
  190.             return true;
  191.          
  192.          while $row mysql_fetch_row($result)) {
  193.              $result_sub_array array();
  194.              if ("NONE" != $p_from_type){
  195.                  $result_sub_array['tex_desc'$this->m_object_siteinformation->isAdmin()?$this->m_object_dbconnexion->translate($p_from_type$row[0]):$this->m_object_dbconnexion->translate($p_from_type$row[0]);
  196.              else {
  197.                  $result_sub_array['tex_desc'$row[0];
  198.              }
  199.              $result_sub_array['tex_date'$row[1];
  200.              $result_sub_array['tex_type'$row[2];
  201.              
  202.              $r_result[sizeof($r_result)$result_sub_array;
  203.          }
  204.          
  205.          $this->xRemember($p_tex_type.$p_database_selected$r_result);
  206.                   
  207.          return false;                
  208.   }
  209.                  
  210. }
  211.  
  212.  
  213.  
  214. ?>

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