Source for file xt_page.class.php

Documentation is available at xt_page.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.  * XTPage Class
  41.  * 
  42.  * 
  43.  * @author SimpliciWeb
  44.  * @version $Id: xt_page.class.php 738 2007-12-05 15:16:46Z nicolas_s $
  45.  * @package Common
  46.  * @subpackage FrameWork
  47.  */    
  48. /**
  49.  * Include the ocject cache class
  50.  */
  51. require_once('internal_components/common/cache_class/object_cached.class.php');
  52.  
  53.  
  54. /**
  55.  * Command part for managing the web page of the front office web site
  56.  *
  57.  * @author SimpliciWeb
  58.  * @version $Id: xt_page.class.php 738 2007-12-05 15:16:46Z nicolas_s $
  59.  * @package Common
  60.  * @subpackage FrameWork
  61.  */
  62. class XTPage extends ObjectCached {
  63.  
  64.     
  65.     
  66.     // member object
  67.     /**
  68.      * Format Object
  69.      *
  70.      * @var Format 
  71.      */
  72.     var $m_object_format             = NULL;
  73.     /**
  74.      * db page level
  75.      *
  76.      * @var array 
  77.      */
  78.     var $m_db_page_level            = array();
  79.     /**
  80.      * page id
  81.      *
  82.      * @var array 
  83.      */
  84.     var $m_db_page_id                = array();
  85.     /**
  86.      * @var array 
  87.      */
  88.     var $m_product                    = array();
  89.     /**
  90.      * @var array 
  91.      */
  92.     var $m_r_product                = array();
  93.     /**
  94.      * @var array 
  95.      */
  96.     var $m_cached                    = array();
  97.     /**
  98.      * @var array 
  99.      */
  100.     var $m_r_cached                    = array();
  101.     /**
  102.      * @var array 
  103.      */
  104.     var $m_visibility                = array();
  105.     /**
  106.      * @var array 
  107.      */
  108.     var $m_r_visibility                = array();
  109.     /**
  110.      * @var array 
  111.      */
  112.     var $m_type                        = array();
  113.     /**
  114.      * @var array 
  115.      */
  116.     var $m_r_type                    = array();
  117.     /**
  118.      * @var array 
  119.      */
  120.     var $m_access                    = array();
  121.     /**
  122.      * @var array 
  123.      */
  124.     var $m_r_access                    = array();
  125.     /**
  126.      * @var array 
  127.      */
  128.     var $m_robot                    = array();
  129.     /**
  130.      * @var array 
  131.      */
  132.     var $m_r_robot                    = array();
  133.     /**
  134.      * @var array 
  135.      */
  136.     var $m_distribution                = array();
  137.     /**
  138.      * @var array 
  139.      */
  140.     var $m_r_distribution            = array();
  141.     /**
  142.      * Set array for translate all plici_page_id in page_id
  143.      * 
  144.      * @var array 
  145.      */
  146.     var $m_plici_page_id_translate_array    = array();
  147.  
  148.     /**
  149.      * List separator for stock array in database
  150.      *
  151.      * Is not private. This symbol is used in request
  152.      * @var string 
  153.      */
  154.     var $m_dbc_dbname_list_separator"|";
  155.  
  156.     /**
  157.      * SQL Request : Get all plici page id not null with page id.
  158.      *                 Usefull to build translate array
  159.      * 
  160.      * @var string 
  161.      */
  162.     var $req_get_plici_page_id        =
  163. "SELECT page_id, plici_page_id
  164. FROM t_page
  165. WHERE plici_page_id IS NOT NULL;";
  166.     
  167.  
  168.  
  169.     /**
  170.      * Constructor, init the requests and objects
  171.      *
  172.      * @return XTPage 
  173.      */
  174.     function XTPage({
  175.         global $g_object_loader;
  176.         $this->m_object_format =$g_object_loader->getFormat();
  177.  
  178.  
  179.         // Structure
  180.         $this->m_db_page_id["SITE"1;
  181.         $this->m_db_page_id["ADVANCE"2;
  182.         $this->m_db_page_id["NORMAL"3;
  183.         $this->m_db_page_id["PARTICULAR"4;
  184.         $this->m_db_page_id["INTERNAL"5;
  185.         $this->m_db_page_id["TOP"6;
  186.         $this->m_db_page_id["BOTTOM"7;
  187.         $this->m_db_page_id["LEFT"8;
  188.         $this->m_db_page_id["RIGHT"9;
  189.         $this->m_db_page_id["TRASH"70;
  190.  
  191.         // Special Page
  192.         $this->m_db_page_id["INDEX"10;
  193.         $this->m_db_page_id["NOEXIST"11;
  194.         $this->m_db_page_id["NOVISIBLE"12;
  195.         $this->m_db_page_id["NOACCESS"13;
  196.         $this->m_db_page_id["AUTHENTIFICATION"14;
  197.         $this->m_db_page_id["NOPRODUCT"28;
  198.         $this->m_db_page_id["SHOPPING_CART"30;
  199.         $this->m_r_db_page_id array_flip($this->m_db_page_id);
  200.  
  201.         $this->m_db_page_level["MIN_MENU"1;
  202.         $this->m_db_page_level["MAX_MENU"2;
  203.         $this->m_db_page_level["CONTAINER"$this->m_db_page_level["MAX_MENU"]+1;
  204.         $this->m_db_page_level["PAGE"$this->m_db_page_level["CONTAINER"]+1;
  205.  
  206.  
  207.         $this->m_product["YES""Y";
  208.         $this->m_product["NO""N";
  209.         $this->m_r_product = array_flip($this->m_product);
  210.  
  211.         $this->m_cached["YES""YES";
  212.         $this->m_cached["NO""NO";
  213.         $this->m_r_cached = array_flip($this->m_cached);
  214.  
  215.         $this->m_visibility["VISIBLE""VI";
  216.         $this->m_visibility["HIDDEN""HI";
  217.         $this->m_r_visibility = array_flip($this->m_visibility);
  218.  
  219.         $this->m_type["SYSTEM"]     "SY";
  220.         $this->m_type["C1"]         "C1";
  221.         $this->m_type["INTERNAL"]     "IN"//C2=IN
  222.         $this->m_type["UNIT"]         "UN"//C3=UN
  223.  
  224.         $this->m_type["CONTAINER"]     "CO";
  225.         $this->m_type["SPECIAL"]     "SP"//C4=SP
  226.         $this->m_type["USER"]         "US";
  227.         $this->m_type["NO_DELETE"]    "ND";
  228.         $this->m_type["MODULE"]        "MO";
  229.         $this->m_type["INDEX"]        "IX"//INDEX
  230.         $this->m_r_type = array_flip($this->m_type);
  231.  
  232.         $this->m_access["ALWAYS"]"AL";
  233.         $this->m_access["NEVER"]"NE";
  234.         $this->m_access["LOGIN_PASS"]"LP";
  235.         $this->m_r_access = array_flip($this->m_access);
  236.  
  237.         $this->m_robot[""]="";
  238.         $this->m_robot["INDEX, FOLLOW"]="IF";
  239.         $this->m_robot["INDEX, FOLLOW, ALL"]="IFA";
  240.         $this->m_robot["INDEX, NOFOLLOW"]="IN";
  241.         $this->m_robot["INDEX, NOFOLLOW, ALL"]="INA";
  242.         $this->m_robot["NOINDEX, FOLLOW"]="NF";
  243.         $this->m_robot["NOINDEX, FOLLOW, ALL"]="NFA";
  244.         $this->m_robot["NOINDEX, NOFOLLOW"]="NN";
  245.         $this->m_robot["NOINDEX, NOFOLLOW, ALL"]="NNA";
  246.         $this->m_r_robot = array_flip($this->m_robot);
  247.         
  248.         $this->m_distribution["GLOBAL""GLOBAL";
  249.         $this->m_distribution["LOCAL""LOCAL";
  250.         $this->m_r_distribution = array_flip($this->m_distribution);
  251.     
  252.     
  253.     //  xIsNotValid
  254.     //  **********
  255.     /**
  256.      * Parameter Integrity checker
  257.      *
  258.      * @access private
  259.      * @param string $p_value 
  260.      * @return  bool TRUE if not valid
  261.      */
  262.     function isNotValidPageId($p_value{
  263.         return $this->m_object_format->isNotUnsignedInteger($p_value8);
  264.     }
  265.     /**
  266.      * Parameter Integrity checker
  267.      *
  268.      * @access private
  269.      * @param string $p_value 
  270.      * @return  bool TRUE if not valid
  271.      */
  272.     function isNotValidPliciPageId($p_value{
  273.         return $this->m_object_format->isNotVarchar($p_value32);
  274.     }
  275.     /**
  276.      * Parameter Integrity checker
  277.      *
  278.      * @access private
  279.      * @param string $p_value 
  280.      * @return  bool TRUE if not valid
  281.      */
  282.     function xIsNotValidPageBorder($p_value{
  283.         return $this->m_object_format->isNotUnsignedInteger($p_value5);
  284.     
  285.     /**
  286.      * Parameter Integrity checker
  287.      *
  288.      * @access private
  289.      * @param string $p_value 
  290.      * @return  bool TRUE if not valid
  291.      */
  292.     function xIsNotValidPageLevel($p_value{
  293.         return $this->m_object_format->isNotUnsignedInteger($p_value3);
  294.     
  295.     /**
  296.      * Parameter Integrity checker
  297.      *
  298.      * @access private
  299.      * @param string $p_value 
  300.      * @return  bool TRUE if not valid
  301.      */
  302.     function xIsNotValidPageLogin($p_value{
  303.         return $this->m_object_format->isNotVarchar($p_value16);
  304.     
  305.     /**
  306.      * Parameter Integrity checker
  307.      *
  308.      * @access private
  309.      * @param string $p_value 
  310.      * @return  bool TRUE if not valid
  311.      */
  312.     function xIsNotValidPagePass($p_value{
  313.         return $this->m_object_format->isNotVarchar($p_value45);
  314.     
  315.  
  316.  
  317.     /**
  318.      * Return the template name for a link
  319.      *
  320.      * @param string $p_name 
  321.      * @return string 
  322.      */
  323.     function convertLinkDisplayName($p_name{
  324.         if ((isset($p_name)) && (null != $p_name))
  325.         {
  326.             //Suppression de répertoire detail du chemin des scripts
  327.             $tmp strstr($p_name"detail/");
  328.             $tmp FALSE === $tmp?$p_name:substr($tmpstrlen("detail/"));
  329.             $temp explode("."$tmp);
  330.             $tmp str_replace("/","-",$temp[0]);
  331.         else {
  332.             $tmp null;
  333.         }
  334.         return $tmp;
  335.     }
  336.  
  337.     /**
  338.      * Translate PLICI_PAGE_ID in page_id
  339.      * Return page id for one page identified by plici page id
  340.      *
  341.      * @param string $p_plici_page_id 
  342.      * @param array $r_result 
  343.      * @return bool TRUE on error
  344.      */
  345.     function translatePliciPageId($p_plici_page_id&$r_result)
  346.     {
  347.         $r_result = -1;
  348.  
  349.         global $g_object_loader;
  350.         $g_object_message =$g_object_loader->getMessage();
  351.  
  352.         // Valid input
  353.         onErrorThrow($this->isNotValidPliciPageId($p_plici_page_id)plici_lang("lang_error_internal"));
  354.         if ($g_object_message->thereIsAnError()) {
  355.             return true;    
  356.         }
  357.  
  358.         if ((0==count($this->m_plici_page_id_translate_array)) 
  359.             || (!isset($this->m_plici_page_id_translate_array[$p_plici_page_id])))
  360.         {
  361.             // Translate table is empty or page is not found
  362.             //    Reload translate table
  363.  
  364.             $this->xFillPliciPageIdTranslateArray();
  365.         }
  366.  
  367.         if (isset($this->m_plici_page_id_translate_array[$p_plici_page_id]))
  368.         {
  369.             $r_result $this->m_plici_page_id_translate_array[$p_plici_page_id];
  370.         else {
  371.             trigger_error("This PLICI page id :".$p_plici_page_id." is unknow");
  372.         }
  373.  
  374.         // Return no error code
  375.         return false;
  376.     }
  377.  
  378.     /**
  379.      * Translate page_id in PLICI_PAGE_ID
  380.      * Return plici page id for one page identified by page id
  381.      *
  382.      * @param integer $p_page_id 
  383.      * @param array $r_result 
  384.      * @return bool TRUE on error
  385.      */
  386.     function translatePageId($p_page_id&$r_result)
  387.     {
  388.         $r_result = -1;
  389.  
  390.         global $g_object_loader;
  391.         $g_object_message =$g_object_loader->getMessage();
  392.  
  393.         // Valid input
  394.         onErrorThrow($this->isNotValidPageId($p_page_id)plici_lang("lang_error_internal"));
  395.         if ($g_object_message->thereIsAnError()) {
  396.             return true;    
  397.         }
  398.  
  399.         $translate_array array_flip($this->m_plici_page_id_translate_array);
  400.  
  401.         if ((0==count($translate_array))
  402.             || (!isset($translate_array[$p_page_id])))
  403.         {
  404.             // Translate table is empty or page is not found
  405.             //    Reload translate table
  406.  
  407.             $this->xFillPliciPageIdTranslateArray();
  408.         }
  409.  
  410.         $translate_array array_flip($this->m_plici_page_id_translate_array);
  411.  
  412.         if (isset($translate_array[$p_page_id]))
  413.         {
  414.             $r_result $translate_array[$p_page_id];
  415.         else {
  416.             trigger_error("This page id :".$p_page_id." is unknow");
  417.         }
  418.  
  419.         // Return no error code
  420.         return false;
  421.     }
  422.  
  423.     /**
  424.      * Fill plici page id translate array
  425.      *
  426.      * @access private
  427.      * @return bool TRUE on error
  428.      */
  429.     function xFillPliciPageIdTranslateArray()
  430.     {
  431.         // Erase old value
  432.         $this->m_plici_page_id_translate_array = array();
  433.  
  434.         // Set request parameter
  435.         $parameters array();
  436.  
  437.         // Declare database request result
  438.         $result "";
  439.  
  440.         // Execute request
  441.         if ($this->m_object_dbconnexion->makeSqlQuery($this->req_get_plici_page_id$parameters$result)) {
  442.             return onErrorThrow(true'sqlGetPliciPageId'plici_lang("lang_error_internal"));
  443.         }
  444.  
  445.         // Arrange result
  446.         while ($row mysql_fetch_row($result)) {
  447.             $this->m_plici_page_id_translate_array[$row[1]] $row[0];
  448.         }
  449.  
  450.         // Return no error code
  451.         return false;
  452.     }
  453.  
  454.  
  455.     /**
  456.      * Transform array in string
  457.      *
  458.      * @param array $r_result 
  459.      * @param array $p_page_dbc_dbname_list 
  460.      * @return bool TRUE on error
  461.      */
  462.     function xTransformPageDbcDbnameListForBD(&$r_result$p_page_dbc_dbname_list)
  463.     {
  464.         $r_result $this->m_dbc_dbname_list_separator."".implode($this->m_dbc_dbname_list_separator$p_page_dbc_dbname_list);
  465.  
  466.         // Return no error code
  467.         return false;
  468.     }
  469.  
  470.     /**
  471.      * Return parameters
  472.      *
  473.      * @param array $r_result 
  474.      * @return bool TRUE on error
  475.      */
  476.     function getCurrentPageDbcDbNameListParameterForSearch(&$r_result)
  477.     {
  478.         $r_result "";
  479.         global $g_object_siteinformation;
  480.  
  481.         if  ($this->xTransformPageDbcDbnameListForBD($r_resultarray($g_object_siteinformation->getDatabaseSiteName())))
  482.             return true;
  483.         return false;
  484.     }
  485. }
  486. ?>

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