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.   protected $dispatcher = null;
  40.  
  41.   public function __construct()
  42.   {
  43.     $this->dispatcher = $GLOBALS['dispatcher'];
  44.   }
  45.  
  46.   public function __call($method$arguments)
  47.   {
  48.     $event $this->dispatcher->notifyUntil(new sfEvent($this'contents.extensible_function'array(
  49.       'method'    => $method,
  50.       'arguments' => $arguments
  51.     )));
  52.     if (!$event->isProcessed())
  53.     {
  54.       throw new Exception(sprintf('Call to undefined method %s::%s.'get_class($this)$method));
  55.     }
  56.  
  57.     return $event->getReturnValue();
  58.   }
  59.   /**
  60.    * contents::CheckDataIntegrity()
  61.    * vérifie l'integrité d'un partie avant Insertion
  62.    *
  63.    * @access public
  64.    * @param array $table contient les composants d'une partie
  65.    * @param string $type 'P', 'W'
  66.    * @param string $type_test 'LIGHT', 'ROCK'
  67.    * @return boolean true
  68.    *  si verifié, sinon string 'message d'erreur'
  69.    */
  70.   function CheckDataIntegrity($table$type$type_test 'LIGHT')
  71.   {
  72.     if (strlen($table[0]2return _t('contents','no_title');
  73.     if (strlen($table[1]10return _t('contents','no_body');
  74.     if ($type == 'P' && $type_test == 'ROCK'{
  75.       if ($table[2!= && $table[3== '')return _t('contents','no_visu1');
  76.     }
  77.  
  78.     return true;
  79.   }
  80.  
  81.   /**
  82.    * contents::GetTemplateName()
  83.    * Retourne la forme textuelle du template
  84.    *
  85.    * @access public
  86.    * @param integrer $num 
  87.    * @return void 
  88.    */
  89.   function GetTemplateName($num)
  90.   {
  91.     if ($num == 1return _t('contents','template_1');
  92.     if ($num == 2return _t('contents','template_2');
  93.     if ($num == 3return _t('contents','template_3');
  94.   }
  95.  
  96.   /**
  97.    * contents::_wichType()
  98.    * initialisation des tables SQL
  99.    *
  100.    * @access private
  101.    * @param string $type : type du CONTENU 'WORKSHOP' ou 'PUBLICATION'
  102.    * @return string -void
  103.    */
  104.   function _wichType($type)
  105.   {
  106.     switch ($type{
  107.       case 'WORKSHOP':
  108.         $this->ACTIVE_TABLE = $this->WR_TABLE;
  109.         $this->ACTIVE_TYPE = 'W';
  110.         break;
  111.       case 'PUBLICATION':
  112.         $this->ACTIVE_TABLE = $this->P_TABLE;
  113.         $this->ACTIVE_TYPE = 'P';
  114.         break;
  115.       default:
  116.         return "error";
  117.     }
  118.   }
  119.  
  120.   /**
  121.    * contents::AddContents()
  122.    * ajout d'une partie de contenu
  123.    *
  124.    * @access public
  125.    * @param integer $ID identifiant du père (rattachement)
  126.    * @param array $contents_table tableau contenant les infos ressources
  127.    * @param string $type 'WORKSHOP' ou 'PUBLICATION'
  128.    * @param object 
  129.    * @return integer $last_id
  130.    */
  131.   function AddContents($ID$contents_table$type$sql_object)
  132.   {
  133.     $contents_table=$sql_object->DBescape($contents_table);
  134.     if ($this->_wichType($type== "error"exit;
  135.     $requete "INSERT INTO " $this->ACTIVE_TABLE ;
  136.     if ($type == "WORKSHOP"{
  137.       $this->WR_TITLE = strip_input($contents_table[0]);
  138.       $this->WR_BODY = strip_input($contents_table[1]true);
  139.       $requete.= " (workrepcon_title, workrepcon_body, workrepcon_date_crea, workrepcon_last_modify, workrepcon_validity)";
  140.       $requete .= " VALUES('" $this->WR_TITLE . "', '" $this->WR_BODY . "', NOW(),NOW(), 'Y');";
  141.     }
  142.     if ($type == "PUBLICATION"{
  143.       $this->P_TITLE = strip_input($contents_table[0]);
  144.       $this->P_BODY = strip_input($contents_table[1]true);
  145.       $this->P_TEMPLATE = $contents_table[2];
  146.       $this->P_PHOTOS_URI = strip_input($contents_table[3]);
  147.       $requete.= " (publicon_title, publicon_body, publicon_template, publicon_photos_uri, publicon_date_crea, publicon_last_modify, publicon_validity)";
  148.       $requete .= " VALUES('" $this->P_TITLE . "', '" $this->P_BODY . "', " $this->P_TEMPLATE . ", '" $this->P_PHOTOS_URI . "', NOW(),NOW(), 'Y');";
  149.     }
  150.     $last_id $sql_object->DBInsert ($requete1);
  151.  
  152.     if (is_numeric($last_id)) {
  153.       $requete "INSERT INTO " $this->TDB_LIAISON . " VALUES(" $ID "," $last_id ", '" $this->ACTIVE_TYPE . "');";
  154.       $result $sql_object->DBInsert ($requete);
  155.     }
  156.     return $result;
  157.   }
  158.  
  159.   /**
  160.    * contents::ModifyContents()
  161.    * modification d'une partie de contenu
  162.    *
  163.    * @access public
  164.    * @param integer $ID : identifiant de la partie à modifier
  165.    * @param array $contents_table : tableau contenant les infos ressources
  166.    * @param string $type 'WORKSHOP' ou 'PUBLICATION'
  167.    * @param object $sql_object 
  168.    * @return boolean $result
  169.    */
  170.   function ModifyContents($ID$contents_table$type$sql_object)
  171.   {
  172.     $contents_table=$sql_object->DBescape($contents_table);
  173.     if ($this->_wichType($type== "error"exit;
  174.     if (!is_numeric($ID)) return false;
  175.     if ($type == "WORKSHOP"$this->WR_ID = $ID;
  176.     if ($type == "PUBLICATION"$this->P_ID = $ID;
  177.  
  178.     $requete "UPDATE " $this->ACTIVE_TABLE . " SET ";
  179.     if ($type == "WORKSHOP"{
  180.       $this->WR_TITLE = strip_input($contents_table[0]);
  181.       $this->WR_BODY = strip_input($contents_table[1]true);
  182.       $requete .= "workrepcon_title='" $this->WR_TITLE . "', workrepcon_body='" $this->WR_BODY . "', workrepcon_last_modify=NOW() WHERE workrepcon_id='" $this->WR_ID . "';";
  183.     }
  184.     if ($type == "PUBLICATION"{
  185.       $this->P_TITLE = strip_input($contents_table[0]);
  186.       $this->P_BODY = strip_input($contents_table[1]true);
  187.       $this->P_TEMPLATE = strip_input($contents_table[2]);
  188.       $this->P_PHOTOS_URI = strip_input($contents_table[3]);
  189.       $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 . "';";
  190.     }
  191.     $result $sql_object->DBQuery($requete);
  192.  
  193.     return $result;
  194.   }
  195.  
  196.   /**
  197.    * contents::DeleteContents()
  198.    * suppression d'une partie
  199.    *
  200.    * @access public
  201.    * @param integer $ID : identifiant du contents a supprimer
  202.    * @param string $type :  'WORKSHOP' ou 'PUBLICATION'
  203.    * @param object $sql_object 
  204.    * @return boolean $result
  205.    */
  206.   function DeleteContents($ID$type$sql_object)
  207.   {
  208.     if (is_numeric($ID)) {
  209.       if ($type == "WORKSHOP"{
  210.         $champ1 "workrepcon_id";
  211.         $champ2 "jwp_contents_id";
  212.         $champ3 "workrepcon_validity";
  213.         $champ4 "workrepcon_last_modify";
  214.       }
  215.       if ($type == "PUBLICATION"{
  216.         $champ1 "publicon_id";
  217.         $champ2 "jpp_contents_id";
  218.         $champ3 "publicon_validity";
  219.         $champ4 "publicon_last_modify";
  220.       }
  221.     else return false;
  222.     if ($this->_wichType($type== "error"return false;
  223.     $requete "UPDATE " $this->ACTIVE_TABLE . " SET " $champ3 "='N', ".$champ4."=NOW()  WHERE " $champ1 "='" $ID "';";
  224.     $result $sql_object->DBQuery($requete);
  225.  
  226.     return $result;
  227.   }
  228. }
  229.  
  230. ?>

Documentation generated on Fri, 01 Apr 2011 09:28:31 +0200 by phpDocumentor 1.4.1