linea21-core
[ class tree: linea21-core ] [ index: linea21-core ] [ all elements ]

Source for file class.theme.php

Documentation is available at class.theme.php

  1. <?php
  2. /**
  3.  * @package linea21.core
  4.  * @subpackage theme
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  Theme Management
  10.  */
  11.  
  12. class theme {
  13.   /* @param
  14.    * */
  15.   var $TDB_THEME = T_THEME// nom de la table.
  16.   var $TDB_SDTHEME = T_SD_THEME// nom de la table.
  17.   var $ID;
  18.   var $NAME;
  19.   var $VISUAL_URI;
  20.   var $ROOT;
  21.   var $SD_THEME;
  22.   var $DESC_PROJECT;
  23.   var $DESC_DASHBOARD;
  24.   var $DESC_NEWS;
  25.   var $DESC_WORKSHOP;
  26.   var $RANGE_PROJECT;
  27.   var $RANGE_NEWS;
  28.   var $RANGE_WORKSHOP;
  29.   var $DATE_CREA;
  30.   var $STATUT;
  31.   var $LAST_MODIFY;
  32.  
  33.   /**
  34.    * theme::CheckDataIntegrity()
  35.    * Vérification des données d'un thème
  36.    *
  37.    * @access public
  38.    * @param array $table_theme : contient les composants d'un thème
  39.    * @return boolean si vrai renvoie true sinon message d'erreurs (string)
  40.    */
  41.   function CheckDataIntegrity($table_theme)
  42.   {
  43.     if (strlen($table_theme[0]2return _t('theme','object_notdenomination');
  44.  
  45.     if(!$this->isRoot()) {
  46.       if (!is_numeric($table_theme[2]|| $table_theme[2== -1return _t('theme','object_notSDtheme');
  47.  
  48.       if (defined('MOD_PROJECT'&& strlen($table_theme[3]2return _t('theme','object_notdesc_completed');
  49.       if (defined('MOD_SDI'&& strlen($table_theme[4]2return _t('theme','object_notdesc_completed');
  50.       if (defined('MOD_PUBLICATION'&& strlen($table_theme[5]2return _t('theme','object_notdesc_completed');
  51.       if (defined('MOD_NEWS'&& strlen($table_theme[6]2return _t('theme','object_notdesc_completed');
  52.       if (defined('MOD_WORKSHOP'&& strlen($table_theme[7]2return _t('theme','object_notdesc_completed');
  53.  
  54.     }
  55.     return true;
  56.   }
  57.  
  58.   /**
  59.    * theme::AddTheme()
  60.    * Ajout d'un nouveau theme
  61.    *
  62.    * @access public
  63.    * @param array $table_theme : contient les composants d'un theme
  64.    * @param object $sql_object 
  65.    * @return integer $last_id
  66.    */
  67.   function AddTheme($table_theme$sql_object)
  68.   {
  69.     $table_theme=$sql_object->DBescape($table_theme);
  70.     if ($table_theme[14== 1$this->SetRoot();
  71.  
  72.     if ($table_theme[0!= ''{
  73.       $this->NAME = strip_input(trim($table_theme[0]));
  74.     }
  75.     if ($table_theme[1!= ''{
  76.       $this->VISUAL_URI = strip_input(trim($table_theme[1]));
  77.     }
  78.     if (is_numeric($table_theme[2])) {
  79.       $this->SD_THEME = $table_theme[2];
  80.     }
  81.     $this->DESC_PROJECT = strip_input(trim($table_theme[3])true);
  82.     $this->DESC_DASHBOARD = strip_input(trim($table_theme[4])true);
  83.     $this->DESC_PUBLICATION = strip_input(trim($table_theme[5])true);
  84.     $this->DESC_NEWS = strip_input(trim($table_theme[6])true);
  85.     $this->DESC_WORKSHOP = strip_input(trim($table_theme[7])true);
  86.  
  87.     if (is_numeric($table_theme[8])) {
  88.       $this->RANGE_PROJECT = $table_theme[8];
  89.     }
  90.     if (is_numeric($table_theme[9])) {
  91.       $this->RANGE_DASHBOARD = $table_theme[9];
  92.     }
  93.     if (is_numeric($table_theme[10])) {
  94.       $this->RANGE_PUBLICATION = $table_theme[10];
  95.     }
  96.     if (is_numeric($table_theme[11])) {
  97.       $this->RANGE_NEWS = $table_theme[11];
  98.     }
  99.     if (is_numeric($table_theme[12])) {
  100.       $this->RANGE_WORKSHOP = $table_theme[12];
  101.     }
  102.  
  103.     if ($table_theme[13!= ''{
  104.       strtoupper($table_theme[13]);
  105.       switch ($table_theme[13]{
  106.         case 'P':
  107.           $this->STATUT = $table_theme[13];
  108.           break;
  109.         case 'D':
  110.           $this->STATUT = $table_theme[13];
  111.           break;
  112.         default:
  113.           $this->STATUT = 'P';
  114.           break;
  115.       }
  116.     else $this->STATUT = 'P';
  117.  
  118.     if($this->isRoot()) {
  119.       $query =     "INSERT INTO " $this->TDB_SDTHEME .
  120.                 " (sdtheme_name, sdtheme_description, sdtheme_date_crea) " .
  121.                 "VALUES('".$this->NAME."','".$this->DESC_PROJECT . "', NOW());";
  122.     else {
  123.       $query "INSERT INTO " $this->TDB_THEME .
  124.              " (theme_name, theme_visual_uri, theme_sd_theme, theme_desc_project, theme_desc_dashboard, " 
  125.              "theme_desc_publication, theme_desc_news, theme_desc_workshop, theme_range_project, "
  126.              "theme_range_dashboard, theme_range_publication, theme_range_news, theme_range_workshop, " .
  127.              "theme_statut, theme_date_crea) " 
  128.              "VALUES('" $this->NAME . "', '" $this->VISUAL_URI . "', " $this->SD_THEME . 
  129.              ", '" $this->DESC_PROJECT ."', '" $this->DESC_DASHBOARD . 
  130.              "', '" $this->DESC_PUBLICATION . "', '" $this->DESC_NEWS . 
  131.              "', '" $this->DESC_WORKSHOP . "', " $this->RANGE_PROJECT . 
  132.              ", " $this->RANGE_DASHBOARD . ", " $this->RANGE_PUBLICATION . 
  133.              ", " $this->RANGE_NEWS . ", " $this->RANGE_WORKSHOP . ", '" $this->STATUT . "', NOW());";
  134.     }
  135.     $last_id $sql_object->DBInsert ($query1);
  136.     return $last_id;
  137.   }
  138.  
  139.   /**
  140.    * theme::ModifyTheme()
  141.    * modification d'un theme
  142.    *
  143.    * @access public
  144.    * @param int $ID : identifiant du theme
  145.    * @param array $table_theme : contient les composants d'un theme
  146.    * @param object $sql_object 
  147.    * @return bool $result
  148.    */
  149.   function ModifyTheme($ID$table_theme$sql_object)
  150.   {
  151.     $table_theme=$sql_object->DBescape($table_theme);
  152.  
  153.     if ($table_theme[9== 1$this->SetRoot();
  154.     if (is_numeric($ID)) {
  155.       $this->ID = $ID;
  156.     }
  157.     if ($table_theme[0!= ''{
  158.       $this->NAME = strip_input(trim($table_theme[0]));
  159.     }
  160.     if ($table_theme[1!= ''{
  161.       $this->VISUAL_URI = strip_input(trim($table_theme[1]));
  162.     }
  163.     if (is_numeric($table_theme[2])) {
  164.       $this->SD_THEME = $table_theme[2];
  165.     }
  166.     $this->DESC_PROJECT = strip_input(trim($table_theme[3])true);
  167.     $this->DESC_DASHBOARD = strip_input(trim($table_theme[4])true);
  168.     $this->DESC_PUBLICATION = strip_input(trim($table_theme[5])true);
  169.     $this->DESC_NEWS = strip_input(trim($table_theme[6])true);
  170.     $this->DESC_WORKSHOP = strip_input(trim($table_theme[7])true);
  171.     if ($table_theme[8!= ''{
  172.       strtoupper($table_theme[8]);
  173.       switch ($table_theme[8]{
  174.         case 'P':
  175.           $this->STATUT = $table_theme[8];
  176.           break;
  177.         case 'D':
  178.           $this->STATUT = $table_theme[8];
  179.           break;
  180.         default:
  181.           $this->STATUT = 'P';
  182.           break;
  183.       }
  184.     else $this->STATUT = 'P';
  185.  
  186.     if($this->isRoot()) {
  187.       $query "UPDATE  " $this->TDB_SDTHEME . " set sdtheme_name='" $this->NAME . "', sdtheme_description='" $this->DESC_PROJECT . "', sdtheme_last_modify=NOW() WHERE sdtheme_id='" $this->ID . "';";
  188.  
  189.     else {
  190.       $query "UPDATE  " $this->TDB_THEME . " set theme_name='" $this->NAME . "', theme_visual_uri='" $this->VISUAL_URI . "' , theme_sd_theme='" $this->SD_THEME . "', theme_desc_project='" $this->DESC_PROJECT . "', theme_desc_dashboard='" $this->DESC_DASHBOARD . "',theme_desc_publication= '" $this->DESC_PUBLICATION . "', theme_desc_news='" $this->DESC_NEWS . "' , theme_desc_workshop='" $this->DESC_WORKSHOP . "' , theme_statut='" $this->STATUT . "', theme_last_modify=NOW() WHERE theme_id='" $this->ID . "';";
  191.     }
  192.  
  193.     $result $sql_object->DBQuery($query);
  194.     return $result;
  195.   }
  196.  
  197.   /**
  198.    * theme::StateTheme()
  199.    * modification du statut d'un theme
  200.    *     -- NE PREND PAS EN CHARGE l'EFFACEMENT --
  201.    *
  202.    * @access public
  203.    * @param int $ID identifiant de l'entreprise
  204.    * @param string $state (facultatif) 'P' Public/'D' Draft
  205.    * @param object $sql_object 
  206.    * @return bool $result
  207.    */
  208.   function StateTheme($ID$state$sql_object)
  209.   {
  210.     if (is_numeric($ID)) {
  211.       $this->ID = $ID;
  212.     }
  213.     if ($state != ''{
  214.       strtoupper($state);
  215.       switch ($state{
  216.         case 'P':
  217.           $this->STATUT = $state;
  218.           break;
  219.         case 'D':
  220.           $this->STATUT = $state;
  221.           break;
  222.         default:
  223.           $this->STATUT = $state;
  224.           break;
  225.       }
  226.     else $this->STATUT = 'P';
  227.     $query "UPDATE  " $this->TDB_THEME . " set theme_statut='" $this->STATUT . "', theme_last_modify=NOW() WHERE theme_id=" $this->ID . ";";
  228.     $result $sql_object->DBQuery($query);
  229.     return $result;
  230.   }
  231.  
  232.   /**
  233.    * theme::DeleteTheme()
  234.    * suppression d'un theme
  235.    *
  236.    * @access public
  237.    * @param int $ID identifiant du theme
  238.    * @param string $type 'MASS_DELETE' toutes les ressources associées aus themes sont rendues inactives
  239.    *  'MASS_MODIFY' remplacement de l'ancien theme par $ID_new
  240.    * @param int $id_new nouvel id de rattachement
  241.    * @param object $sql_object 
  242.    * @return bool $result
  243.    */
  244.   function DeleteTheme($ID$sql_object$type$ID_new = -1)
  245.   {
  246.     $affected 0;
  247.     if (is_numeric($ID)) {
  248.       $this->ID = $ID;
  249.     }
  250.     if($this->isRoot()) {
  251.       $query "UPDATE  " $this->TDB_THEME . " set theme_sd_theme=" $ID_new " WHERE  theme_sd_theme=" $this->ID . ";";
  252.       $result $sql_object->DBQuery($query);
  253.       $affected += $sql_object->DBaffectedRow();
  254.       $query "DELETE FROM  " $this->TDB_SDTHEME . " where sdtheme_id='".$this->ID ."';";
  255.       $result $sql_object->DBQuery($query);
  256.     }
  257.     if($this->isRoot(== false{
  258.       if ($type == 'MASS_MODIFY'{
  259.         if ($ID_new != -&& is_numeric($ID_new)) {
  260.           $query "UPDATE  " $this->TDB_THEME . " set theme_statut='E', theme_last_modify=NOW() WHERE theme_id=" $this->ID . ";";
  261.           $result $sql_object->DBQuery($query);
  262.           if ($result == true{
  263.             $query_news "UPDATE  " T_NEWS " set news_theme=" $ID_new " WHERE  news_theme=" $this->ID . ";";
  264.             $result $sql_object->DBQuery($query_news);
  265.             $affected += $sql_object->DBaffectedRow();
  266.             $query_publication "UPDATE  " T_PUBLI " set publi_theme=" $ID_new " WHERE  publi_theme=" $this->ID . ";";
  267.             $result $sql_object->DBQuery($query_publication);
  268.             $affected += $sql_object->DBaffectedRow();
  269.             $query_workshop "UPDATE  " T_WORK " set workshop_theme=" $ID_new " WHERE  workshop_theme=" $this->ID . ";";
  270.             $result $sql_object->DBQuery($query_workshop);
  271.             $affected += $sql_object->DBaffectedRow();
  272.             $query_sdiinfo "UPDATE  " T_SDI_INFO " set sdii_theme=" $ID_new " WHERE  sdii_theme=" $this->ID . ";";
  273.             $result $sql_object->DBQuery($query_workshop);
  274.             $affected += $sql_object->DBaffectedRow();
  275.             $query_yellowpages "UPDATE  " T_YELLOWPAGES " set yellowp_theme=" $ID_new " WHERE  yellowp_theme=" $this->ID . ";";
  276.             $result $sql_object->DBQuery($query_yellowpages);
  277.             $affected += $sql_object->DBaffectedRow();
  278.           }
  279.         }
  280.       }
  281.       if ($type == 'MASS_DELETE'{
  282.         $query "UPDATE  " $this->TDB_THEME . " SET theme_statut='E', theme_last_modify=NOW() WHERE theme_id=" $this->ID . ";";
  283.         $result $sql_object->DBQuery($query);
  284.         if ($result == true{
  285.           $query_news "UPDATE  " T_NEWS " SET news_statut='E' WHERE  news_theme=" $this->ID . ";";
  286.           $result $sql_object->DBQuery($query_news);
  287.           $affected += $sql_object->DBaffectedRow();
  288.           $query_publication "UPDATE  " T_PUBLI " SET publi_statut='E' WHERE  publi_theme=" $this->ID . ";";
  289.           $result $sql_object->DBQuery($query_publication);
  290.           $affected += $sql_object->DBaffectedRow();
  291.           $query_workshop "UPDATE  " T_WORK " SET workshop_statut='E' WHERE  workshop_theme=" $this->ID . ";";
  292.           $result $sql_object->DBQuery($query_workshop);
  293.           $affected += $sql_object->DBaffectedRow();
  294.           $query_sdiinfo "UPDATE " T_SDI_INFO " SET sdii_statut='E' WHERE  sdii_theme=" $this->ID . ";";
  295.           $result $sql_object->DBQuery($query_sdiinfo);
  296.           $affected += $sql_object->DBaffectedRow();
  297.           $query_sdivalue "UPDATE " T_SDI_VALUE " SET sdiv_statut='E' WHERE sdiv_sdi_info="$this->ID . ";";
  298.           $result $sql_object->DBQuery($query_sdivalue);
  299.           $affected += $sql_object->DBaffectedRow();
  300.           $query_yellowpages "UPDATE  " T_YELLOWPAGES " SET yellowp_statut='AA' WHERE  yellowp_theme=" $this->ID . ";";
  301.           $result $sql_object->DBQuery($query_yellowpages);
  302.           $affected += $sql_object->DBaffectedRow();
  303.         }
  304.       }
  305.     }
  306.     return $affected;
  307.   }
  308.  
  309.   /**
  310.    * theme::SetRoot()
  311.    * Set the ROOT attribute to 1
  312.    *
  313.    * @access public
  314.    * @return void 
  315.    */
  316.   function SetRoot()
  317.   {
  318.     $this->ROOT = 1;
  319.   }
  320.  
  321.   /**
  322.    * theme::isRoot()
  323.    * Is the current theme root?
  324.    *
  325.    * @access public
  326.    * @return bool 
  327.    */
  328.   function isRoot()
  329.   {
  330.     if($this->ROOT == 1{
  331.       return true;
  332.     else{
  333.       return false;
  334.     }
  335.   }
  336.  
  337.   /**
  338.    * theme::SetThemeRange()
  339.    * modification des RANGE des themes
  340.    *   --- NON IMPLEMENTE/NON TESTE ---
  341.    *
  342.    * @access public
  343.    * @param string $module spécifie le module concernée : valeur 'DASHBOARD', 'PUBLICATION', 'NEWS', 'WORKSHOP', 'ALL'
  344.    * @param array $table_range tableau contenant les id des themes
  345.    * @param object $sql_object 
  346.    * @return bool $result
  347.    */
  348.   /**
  349.    * function SetThemeRange($table_range, $sql_object, $module)
  350.    * {
  351.    * $result = false;
  352.    * if (count($table_range) > 0) {
  353.    * if (strlen($module) > 2) {
  354.    * if ($module != 'ALL') {
  355.    * $champ = 'theme_range_';
  356.    * if ($module == 'DASHBOARD') $champ .= 'dashboard';
  357.    * if ($module == 'PUBLICATION') $champ .= 'publication';
  358.    * if ($module == 'NEWS') $champ .= 'news';
  359.    * if ($module == 'WORKSHOP') $champ .= 'workshop';
  360.    * for($i = 0; $i < count($table_range); $i++) {
  361.    * $range = $i + 1;
  362.    * $query = "UPDATE  " . $this->TDB_THEME . " SET " . $champ . "=" . $range . " WHERE theme_id='" . $table_range[$i] . "';";
  363.    * $result = $sql_object->DBQuery($query);
  364.    * echo $query . "<br>";
  365.    * }
  366.    * } elseif ($module == 'ALL') {
  367.    * for($i = 0; $i < count($table_range); $i++) {
  368.    * $range = $i + 1;
  369.    * $to_update = "theme_range_dashboard=" . $range . ", theme_range_publication=" . $range . ", theme_range_news=" . $range . ", theme_range_workshop=" . $range;
  370.    * $query = "UPDATE  " . $this->TDB_THEME . " SET " . $to_update . " WHERE theme_id=" . $table_range[$i] . ";";
  371.    * $result = $sql_object->DBQuery($query);
  372.    * echo $query . "<br>";
  373.    * }
  374.    * }
  375.    * }
  376.    * }
  377.    *
  378.    * return $result;
  379.    * }
  380.    */
  381. }
  382.  
  383. ?>

Documentation generated on Fri, 16 Oct 2009 09:30:28 +0200 by phpDocumentor 1.4.1