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

Documentation generated on Sat, 08 Nov 2008 14:51:32 +0100 by phpDocumentor 1.4.1