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

Documentation generated on Thu, 20 Mar 2014 16:46:57 +0100 by phpDocumentor 1.4.1