Changeset 2915
- Timestamp:
- 07/22/08 12:47:30 (1 month ago)
- Files:
-
- trunk/project/modules/devel/cms3/heading/classes/headingelementinformationservices.class.php (modified) (2 diffs)
- trunk/project/modules/devel/cms3/heading/classes/headingelementstatus.class.php (modified) (2 diffs)
- trunk/project/modules/devel/cms3/heading/classes/headingservices.class.php (modified) (1 diff)
- trunk/project/modules/devel/cms3/heading/module.xml (modified) (1 diff)
- trunk/project/modules/devel/cms3/heading/tests/heading_headingtest.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/project/modules/devel/cms3/heading/classes/headingelementinformationservices.class.php
r2911 r2915 22 22 /** 23 23 * Création d'un nouvel élément 24 * @param object $pHeadingElementInformation 24 25 * @return int public_id de l'élément nouvellement généré 25 26 */ 26 27 public function insert ($pHeadingElementInformation){ 28 $this->fillMissing ($pHeadingElementInformation); 29 _dao ('headingelementinformation')->insert ($pHeadingElementInformation); 30 $this->_updatePublicIdIfMissing ($pHeadingElementInformation); 31 return $pHeadingElementInformation->public_id_hei; 27 32 } 28 33 … … 45 50 public function deleteByPublicId ($pPublicId){ 46 51 } 52 53 /** 54 * Remplis les informations manquantes sur l'élément 55 */ 56 public function fillMissing ($pHEI){ 57 //Dates de mises à jour 58 $date = date (CopixI18N::getDateTimeFormat ()); 59 if (!isset ($pHEI->date_create_hei)){ 60 $pHEI->date_create_hei = $date; 61 } 62 if (!isset ($pHEI->date_update_hei)){ 63 $pHEI->date_update_hei = $date; 64 } 65 66 //Auteurs 67 $id = _currentUser ()->getId (); 68 $handler = _currentUser ()->getHandler (); 69 $caption = _currentUser ()->getCaption (); 70 71 //ID 72 if (!isset ($pHEI->author_id_update_hei)){ 73 $pHEI->author_id_update_hei = $id; 74 } 75 if (!isset ($pHEI->author_id_create_hei)){ 76 $pHEI->author_id_create_hei = $id; 77 } 78 //handler 79 if (!isset ($pHEI->author_handler_update_hei)){ 80 $pHEI->author_handler_update_hei = $handler; 81 } 82 if (!isset ($pHEI->author_handler_create_hei)){ 83 $pHEI->author_handler_create_hei = $handler; 84 } 85 //libellé 86 if (!isset ($pHEI->author_caption_update_hei)){ 87 $pHEI->author_caption_update_hei = $caption; 88 } 89 if (!isset ($pHEI->author_caption_create_hei)){ 90 $pHEI->author_caption_create_hei = $caption; 91 } 92 93 //SiteId 94 if (!isset ($pHEI->site_id_hei)){ 95 $pHEI->site_id_hei = CopixConfig::get ('heading|site_id'); 96 } 97 98 //Status - Si aucun donné, on considère "PUBLISHED" 99 if (!isset ($pHEI->status_hei)){ 100 _classInclude ('heading|HeadingElementStatus'); 101 $pHEI->status_hei = HeadingElementStatus::PUBLISHED; 102 } 103 104 //Version / From Version 105 if (!isset ($pHEI->version_hei)){ 106 $pHEI->version_hei = 0; 107 } 108 if (!isset ($pHEI->fromversion_hei)){ 109 $pHEI->fromversion_hei = 0; 110 } 111 112 //affichage dans le menu 113 if (!isset ($pHEI->show_in_menu_hei)){ 114 $pHEI->show_in_menu_hei = 0; 115 } 116 117 } 118 119 /** 120 * Cette fonction met à jour le publicid dans l'enregistrement si ce dernier n'est pas présent 121 * @return boolean s'il a fallu mettre l'enregistrement a jour ou non 122 */ 123 protected function _updatePublicIdIfMissing ($pHEI){ 124 if (!isset ($pHEI->public_id_hei)){ 125 $pHEI->public_id_hei = $pHEI->id_hei; 126 _dao ('heading|headingelementinformation')->update ($pHEI); 127 return true; 128 } 129 return false; 130 } 131 132 /** 133 * Donne le numéro de version "suivant" pour un contenu d'identifiant donné 134 * 135 * @param int $pPublicId l'identifiant publique de l'élément dont on souhaite connaitre le numéro de version 136 * @return int le numéro de version a venir 137 */ 138 public function getNextVersion ($pPublicId){ 139 } 47 140 } trunk/project/modules/devel/cms3/heading/classes/headingelementstatus.class.php
r2912 r2915 8 8 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 9 9 */ 10 11 /** 12 * Représentation des status possibles dans le workflow des contenus 13 */ 10 14 class HeadingElementStatus { 11 15 /** 12 16 * Constantes correspondants aux status possibles pour les éléments du CMS 13 *14 17 */ 15 18 const DRAFT = 0; … … 58 61 } 59 62 } 60 ?>trunk/project/modules/devel/cms3/heading/classes/headingservices.class.php
r2911 r2915 13 13 */ 14 14 class HeadingServices { 15 public function create ($pHeadingDescription){ 15 /** 16 * Création d'une nouvelle rubrique 17 * @param array / object $pHeadingDescription 18 */ 19 public function insert ($pHeadingDescription){ 16 20 CopixDB::begin (); 17 18 19 _dao ('heading|heading'); 21 try { 22 _dao ('heading')->insert ($record = $this->createRecordFromObject ($pHeadingDescription)); 23 $record->id_helt = $record->id_head; 24 $record->type_hei = 'heading'; 25 26 //dans $record->id_hei on a le nouvel identifiant 27 _class ('heading|headingelementinformationservices')->insert ($record); 28 29 //on met maintenant a jour l'élément $record avec les informations publiques mises à jour 30 _dao ('heading')->update ($record); 31 32 }catch (CopixException $e){ 33 CopixDB::rollback (); 34 throw $e; 35 } 20 36 CopixDB::commit (); 21 37 } 22 23 public function createRecord 38 39 public function createRecordFromObject ($pInformations){ 40 return _record ('heading')->initFromDbObject (_rPPO ($pInformations)); 41 } 24 42 } trunk/project/modules/devel/cms3/heading/module.xml
r2911 r2915 5 5 description="[CMS] Gestion des rubriques" /> 6 6 </general> 7 <parameters> 8 <parameter name="site_id" caption="Identifiant unique du site" default="principal" /> 9 </parameters> 7 10 </moduledefinition> trunk/project/modules/devel/cms3/heading/tests/heading_headingtest.class.php
r2911 r2915 14 14 class Heading_HeadingTest extends CopixTest { 15 15 public function testCreationRubrique (){ 16 //création d'une rubrique test 17 $ppo = _rPPO (); 18 $ppo->parent_id_head = 0;//rubrique parente = rubrique racine 19 $ppo->description_head = 'Rubrique testée unitairement'; 20 _class ('heading|headingservices')->insert ($ppo); 21 $this->assertFalse ($ppo->public_id_hei === null); 22 $this->assertFalse ($ppo->id_head === null); 23 24 25 $this->assertTrue (is_object ($heading = _dao ('heading')->get ($ppo->id_head))); 16 26 } 17 27
