phpDocumentor lodel-logic
[ class tree: lodel-logic ] [ index: lodel-logic ] [ all elements ]

Source for file class.texts.php

Documentation is available at class.texts.php

  1. <?php
  2. /**    
  3.  * Logique des textes lodel
  4.  *
  5.  * PHP versions 4 et 5
  6.  *
  7.  * LODEL - Logiciel d'Edition ELectronique.
  8.  *
  9.  * Home page: http://www.lodel.org
  10.  * E-Mail: lodel@lodel.org
  11.  *
  12.  * All Rights Reserved
  13.  *
  14.  * This program is free software; you can redistribute it and/or modify
  15.  * it under the terms of the GNU General Public License as published by
  16.  * the Free Software Foundation; either version 2 of the License, or
  17.  * (at your option) any later version.
  18.  *
  19.  * This program is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  * GNU General Public License for more details.
  23.  *
  24.  * You should have received a copy of the GNU General Public License
  25.  * along with this program; if not, write to the Free Software
  26.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  27.  *
  28.  * @package lodel/logic
  29.  * @author Ghislain Picard
  30.  * @author Jean Lamy
  31.  * @copyright 2001-2002, Ghislain Picard, Marin Dacos
  32.  * @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
  33.  * @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
  34.  * @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
  35.  * @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
  36.  * @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
  37.  * @licence http://www.gnu.org/copyleft/gpl.html
  38.  * @since Fichier ajouté depuis la version 0.8
  39.  * @version CVS:$Id: class.texts.php 4006 2007-10-05 11:53:41Z malafosse $
  40.  */
  41.  
  42.  
  43.  
  44. require_once("translationfunc.php");
  45.  
  46. /**
  47.  * Classe de logique des textes lodel
  48.  * 
  49.  * @package lodel/logic
  50.  * @author Ghislain Picard
  51.  * @author Jean Lamy
  52.  * @copyright 2001-2002, Ghislain Picard, Marin Dacos
  53.  * @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
  54.  * @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
  55.  * @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
  56.  * @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
  57.  * @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
  58.  * @licence http://www.gnu.org/copyleft/gpl.html
  59.  * @since Classe ajouté depuis la version 0.8
  60.  * @see logic.php
  61.  */
  62. class TextsLogic extends Logic 
  63. {
  64.  
  65.     /** Constructor
  66.     */
  67.     function TextsLogic(
  68.     {
  69.         $this->Logic("texts");
  70.     }
  71.  
  72.     /**
  73.         * add/edit Action
  74.         */
  75.     function editAction(&$context&$error$clean false)
  76.     {
  77.         if ($context['id']{
  78.             // normal edit
  79.             return Logic::editAction($context,$error);
  80.         }
  81.         // Sauvegarde massive
  82.         if (is_array($context['contents'])) {
  83.             $dao $this->_getMainTableDAO();
  84.             //if ($GLOBALS['lodeluser']['translationmode'] != 'site') {
  85.             if($context['textgroup'!= 'site'{
  86.                 #echo "mode interface";
  87.                 usemaindb();
  88.             }
  89.             foreach ($context['contents'as $id=>$contents{
  90.                 if (!is_numeric($id)) {
  91.                     continue;
  92.                 }
  93.                 $dao->instantiateObject($vo);
  94.                 $vo->contents preg_replace("/(\r\n\s*){2,}/""<br />"$contents);
  95.                 $vo->id       $id;
  96.                 $status intval($context['status'][$id]);
  97.                 $this->_isAuthorizedStatus($status);
  98.                 $vo->status   $status;
  99.                 if (!$vo->status{
  100.                     $vo->status=-1;
  101.                 }
  102.                 $dao->save($vo);
  103.             }
  104.             //if ($GLOBALS['lodeluser']['translationmode']!="site") {
  105.             if($context['textgroup'!= 'site'{
  106.                 #echo "mode interface";
  107.                 usecurrentdb();
  108.             }
  109.             update();
  110.         }
  111.         require_once 'cachefunc.php';
  112.         clearcache();
  113.         return '_back';
  114.     }
  115.  
  116.  
  117.     /**
  118.         * Function to create the text entry for all the languages
  119.         */
  120.     function createTexts($name$textgroup '')
  121.     {
  122.         global $db;
  123.  
  124.         if ($textgroup == '' && is_numeric($name)) {
  125.             $criteria "#_TP_texts.id='"$name"'";
  126.         else {
  127.             $criteria "name='"$name"' AND textgroup='"$textgroup"'";
  128.         }
  129.         if ($textgroup != 'site'{
  130.             usemaindb();
  131.         }
  132.  
  133.         $result $db->execute(lq("SELECT #_TP_translations.lang FROM #_TP_translations LEFT JOIN #_TP_texts ON #_TP_translations.lang=#_TP_texts.lang AND ".$criteria." WHERE #_TP_texts.lang is NULL")) or dberror();
  134.         $dao $this->_getMainTableDAO();
  135.  
  136.         while (!$result->EOF{
  137.             $dao->instantiateObject($vo);
  138.             $vo->name      $name;
  139.             $vo->textgroup $textgroup;
  140.             $vo->status    1;
  141.             $vo->lang      $result->fields['lang'];
  142.             $dao->save($vo);
  143.             $result->MoveNext();
  144.         }
  145.         if ($textgroup != 'site'{
  146.             usecurrentdb();
  147.         }
  148.     }
  149.  
  150.     /*---------------------------------------------------------------*/
  151.     //! Private or protected from this point
  152.     /**
  153.         * @private
  154.         */
  155.  
  156.     /**
  157.     * Sauve des données dans des tables liées éventuellement
  158.     *
  159.     * Appelé par editAction pour effectuer des opérations supplémentaires de sauvegarde.
  160.     *
  161.     * @param object $vo l'objet qui a été créé
  162.     * @param array $context le contexte
  163.     */
  164.     function _saveRelatedTables($vo$context)
  165.     {
  166.         if ($vo->id{
  167.             $this->createTexts($vo->id);
  168.         else {
  169.             $this->createTexts($vo->name,$vo->textgroup);
  170.         }
  171.     }
  172.  
  173.     function _deleteRelatedTables($id
  174.     {
  175.         // reinitialise le cache surement.
  176.     }
  177.  
  178.     // begin{publicfields} automatic generation  //
  179.  
  180.     /**
  181.      * Retourne la liste des champs publics
  182.      * @access private
  183.      */
  184.     function _publicfields(
  185.     {
  186.         return array('contents' => array('longtext'''),
  187.                                     'lang' => array('lang''+'),
  188.                                     'textgroup' => array('text''+'));
  189.     }
  190.     // end{publicfields} automatic generation  //
  191.  
  192.  
  193.         function _uniqueFields({  return array();  }
  194.  
  195.  
  196. // class
  197. ?>

Documentation generated on Thu, 24 Jul 2008 05:08:18 +0200 by phpDocumentor 1.4.0a2