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

Source for file class.contents.php

Documentation is available at class.contents.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage content
  5.  * @see workshop, publication
  6.  * @author linea21 <info@linea21.com>
  7.  * @version $id SVN
  8.  * @access public
  9.  * @license http://opensource.org/licenses/gpl-3.0.html
  10.  *  Content Management
  11.  */
  12.  
  13. class contents {
  14.   /* @param
  15.    * */
  16.   var $TDB_LIAISON = J_PARTS;
  17.   var $ACTIVE_TABLE;
  18.   var $ACTIVE_TYPE// valeur 'P' || 'W'
  19.   var $WR_ID;
  20.   var $WR_TITLE;
  21.   var $WR_BODY;
  22.   var $WR_DATE_CREA;
  23.   var $WR_LAST_MODIFY;
  24.   var $WR_TABLE = T_WORK_REP_CONT;
  25.  
  26.   var $P_ID;
  27.   var $P_TITLE;
  28.   var $P_BODY;
  29.   var $P_TEMPLATE;
  30.   var $P_PHOTOS_URI;
  31.   var $P_DATE_CREA;
  32.   var $P_LAST_MODIFY;
  33.   var $P_TABLE = T_PUBLI_CONT;
  34.   var $P_MAX_PHOTO_MAX_WIDTH = MAX_PHOTO_MAX_WIDTH;
  35.   var $P_MAX_PHOTO_MIN_WIDTH = MAX_PHOTO_MIN_WIDTH;
  36.   var $P_UPLOAD_MAX_MO = UPLOAD_MAX_MO// taille maximale d'upload des fichiers en octets
  37.   var $P_URI_INPUT = "publication/contents/"// dossier racine de stockage des elements multimedias
  38.   var $P_URI_OUTPUT = "publication/contents/"// dossier racine de diffusion des elements multimedias
  39.   /**
  40.   * contents::CheckDataIntegrity()
  41.   * vérifie l'integrité d'un partie avant Insertion
  42.   *
  43.   * @access public
  44.   * @param array $table contient les composants d'une partie
  45.   * @param string $type 'P', 'W'
  46.   * @param string $type_test 'LIGHT', 'ROCK'
  47.   * @return boolean true
  48.   *  si verifié, sinon string 'message d'erreur'
  49.   */
  50.   function CheckDataIntegrity($table$type$type_test 'LIGHT')
  51.   {
  52.     if (strlen($table[0]2return _t('contents','no_title');
  53.     if (strlen($table[1]10return _t('contents','no_body');
  54.     if ($type == 'P' && $type_test == 'ROCK'{
  55.       if ($table[2!= && $table[3== '')return _t('contents','no_visu1');
  56.     }
  57.  
  58.     return true;
  59.   }
  60.  
  61.   /**
  62.    * contents::GetTemplateName()
  63.    * Retourne la forme textuelle du template
  64.    *
  65.    * @access public
  66.    * @param integrer $num 
  67.    * @return void 
  68.    */
  69.   function GetTemplateName($num)
  70.   {
  71.     if ($num == 1return _t('contents','template_1');
  72.     if ($num == 2return _t('contents','template_2');
  73.     if ($num == 3return _t('contents','template_3');
  74.   }
  75.  
  76.   /**
  77.    * contents::_wichType()
  78.    * initialisation des tables SQL
  79.    *
  80.    * @access private
  81.    * @param string $type : type du CONTENU 'WORKSHOP' ou 'PUBLICATION'
  82.    * @return string -void
  83.    */
  84.   function _wichType($type)
  85.   {
  86.     switch ($type{
  87.       case 'WORKSHOP':
  88.         $this->ACTIVE_TABLE = $this->WR_TABLE;
  89.         $this->ACTIVE_TYPE = 'W';
  90.         break;
  91.       case 'PUBLICATION':
  92.         $this->ACTIVE_TABLE = $this->P_TABLE;
  93.         $this->ACTIVE_TYPE = 'P';
  94.         break;
  95.       default:
  96.         return "error";
  97.     }
  98.   }
  99.  
  100.   /**
  101.    * contents::AddContents()
  102.    * ajout d'une partie de contenu
  103.    *
  104.    * @access public
  105.    * @param integer $ID identifiant du père (rattachement)
  106.    * @param array $contents_table tableau contenant les infos ressources
  107.    * @param string $type 'WORKSHOP' ou 'PUBLICATION'
  108.    * @param object 
  109.    * @return integer $last_id
  110.    */
  111.   function AddContents($ID$contents_table$type$sql_object)
  112.   {
  113.     $contents_table=$sql_object->DBescape($contents_table);
  114.     if ($this->_wichType($type== "error"exit;
  115.     $requete "INSERT INTO " $this->ACTIVE_TABLE ;
  116.     if ($type == "WORKSHOP"{
  117.       $this->WR_TITLE = strip_input($contents_table[0]);
  118.       $this->WR_BODY = strip_input($contents_table[1]true);
  119.       $requete.= " (workrepcon_title, workrepcon_body, workrepcon_date_crea, workrepcon_last_modify, workrepcon_validity)";
  120.       $requete .= " VALUES('" $this->WR_TITLE . "', '" $this->WR_BODY . "', NOW(),NOW(), 'Y');";
  121.     }
  122.     if ($type == "PUBLICATION"{
  123.       $this->P_TITLE = strip_input($contents_table[0]);
  124.       $this->P_BODY = strip_input($contents_table[1]true);
  125.       $this->P_TEMPLATE = $contents_table[2];
  126.       $this->P_PHOTOS_URI = strip_input($contents_table[3]);
  127.       $requete.= " (publicon_title, publicon_body, publicon_template, publicon_photos_uri, publicon_date_crea, publicon_last_modify, publicon_validity)";
  128.       $requete .= " VALUES('" $this->P_TITLE . "', '" $this->P_BODY . "', " $this->P_TEMPLATE . ", '" $this->P_PHOTOS_URI . "', NOW(),NOW(), 'Y');";
  129.     }
  130.     $last_id $sql_object->DBInsert ($requete1);
  131.  
  132.     if (is_numeric($last_id)) {
  133.       $requete "INSERT INTO " $this->TDB_LIAISON . " VALUES(" $ID "," $last_id ", '" $this->ACTIVE_TYPE . "');";
  134.       $result $sql_object->DBInsert ($requete);
  135.     }
  136.     return $result;
  137.   }
  138.  
  139.   /**
  140.    * contents::ModifyContents()
  141.    * modification d'une partie de contenu
  142.    *
  143.    * @access public
  144.    * @param integer $ID : identifiant de la partie à modifier
  145.    * @param array $contents_table : tableau contenant les infos ressources
  146.    * @param string $type 'WORKSHOP' ou 'PUBLICATION'
  147.    * @param object $sql_object 
  148.    * @return boolean $result
  149.    */
  150.   function ModifyContents($ID$contents_table$type$sql_object)
  151.   {
  152.     $contents_table=$sql_object->DBescape($contents_table);
  153.     if ($this->_wichType($type== "error"exit;
  154.     if (!is_numeric($ID)) return false;
  155.     if ($type == "WORKSHOP"$this->WR_ID = $ID;
  156.     if ($type == "PUBLICATION"$this->P_ID = $ID;
  157.  
  158.     $requete "UPDATE " $this->ACTIVE_TABLE . " SET ";
  159.     if ($type == "WORKSHOP"{
  160.       $this->WR_TITLE = strip_input($contents_table[0]);
  161.       $this->WR_BODY = strip_input($contents_table[1]true);
  162.       $requete .= "workrepcon_title='" $this->WR_TITLE . "', workrepcon_body='" $this->WR_BODY . "'workrepcon_last_modify=NOW() WHERE workrepcon_id='" $this->WR_ID . "';";
  163.     }
  164.     if ($type == "PUBLICATION"{
  165.       $this->P_TITLE = strip_input($contents_table[0]);
  166.       $this->P_BODY = strip_input($contents_table[1]true);
  167.       $this->P_TEMPLATE = strip_input($contents_table[2]);
  168.       $this->P_PHOTOS_URI = strip_input($contents_table[3]);
  169.       $requete .= "publicon_title='" $this->P_TITLE . "', publicon_body='" $this->P_BODY . "', publicon_template='" $this->P_TEMPLATE . "',  publicon_photos_uri='" $this->P_PHOTOS_URI . "', publicon_last_modify=NOW() WHERE publicon_id='" $this->P_ID . "';";
  170.     }
  171.     $result $sql_object->DBQuery($requete);
  172.  
  173.     return $result;
  174.   }
  175.  
  176.   /**
  177.    * contents::DeleteContents()
  178.    * suppression d'une partie
  179.    *
  180.    * @access public
  181.    * @param integer $ID : identifiant du contents a supprimer
  182.    * @param string $type :  'WORKSHOP' ou 'PUBLICATION'
  183.    * @param object $sql_object 
  184.    * @return boolean $result
  185.    */
  186.   function DeleteContents($ID$type$sql_object)
  187.   {
  188.     if (is_numeric($ID)) {
  189.       if ($type == "WORKSHOP"{
  190.         $champ1 "workrepcon_id";
  191.         $champ2 "jwp_contents_id";
  192.         $champ3 "workrepcon_validity";
  193.         $champ4 "workrepcon_last_modify";
  194.       }
  195.       if ($type == "PUBLICATION"{
  196.         $champ1 "publicon_id";
  197.         $champ2 "jpp_contents_id";
  198.         $champ3 "publicon_validity";
  199.         $champ4 "publicon_last_modify";
  200.       }
  201.     else return false;
  202.     if ($this->_wichType($type== "error"return false;
  203.     $requete "UPDATE " $this->ACTIVE_TABLE . " SET " $champ3 "='N', ".$champ4."=NOW()  WHERE " $champ1 "='" $ID "';";
  204.     $result $sql_object->DBQuery($requete);
  205.  
  206.     return $result;
  207.   }
  208. }
  209.  
  210. ?>

Documentation generated on Fri, 16 Oct 2009 09:29:14 +0200 by phpDocumentor 1.4.1