Changeset 2936
- Timestamp:
- 07/23/08 15:36:10 (1 month ago)
- Files:
-
- trunk/project/modules/devel/cms3/heading/classes/headingelementinformationservices.class.php (modified) (3 diffs)
- trunk/project/modules/devel/cms3/heading/classes/headingservices.class.php (modified) (1 diff)
- trunk/project/modules/devel/cms3/heading/install/scripts/install.pdo_mysql.sql (modified) (1 diff)
- trunk/project/modules/devel/cms3/heading/tests/heading_headingelementinformationtest.class.php (modified) (1 diff)
- trunk/project/modules/devel/cms3/heading/tests/heading_headingportletsxmlparse.class.php (added)
- trunk/project/modules/devel/cms3/heading/tests/heading_headingservicestest.class.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/project/modules/devel/cms3/heading/classes/headingelementinformationservices.class.php
r2922 r2936 136 136 * @return int le numéro de version a venir 137 137 */ 138 public function getNextVersion ($pPublicId){ 138 public function getNextVersion ($pPublicId) { 139 $parameters = _daoSp ()->addCondition ('public_id_hei', '=', $pPublicId) 140 ->orderby(array('version_hei', 'DESC')) 141 ->setLimit (0, 1); 142 $results = _dao('headingelementinformation')->findBy ($parameters); 143 144 return $results[0]->version_hei+1; 145 139 146 } 140 147 … … 145 152 */ 146 153 public function getHeadingPathFromId ($pId){ 154 CopixClassesFactory::fileInclude('heading|headingelementinformation'); 155 $parameters = _daoSp ()->addCondition ('id_helt', '=', $pId); 156 if (_dao('headingelementinformation')->findBy ($parameters) !== false) { 157 return HeadingServices::getPathFromId($pId); 158 } 147 159 } 148 160 … … 153 165 */ 154 166 public function getHeadingPathFromPublicId ($pId){ 167 CopixClassesFactory::fileInclude('heading|headingelementinformation'); 168 $parameters = _daoSp ()->addCondition ('public_id_hei', '=', $pId); 169 if (_dao('headingelementinformation')->findBy ($parameters) !== false) { 170 return HeadingServices::getPathFromPublicId($pId); 171 } 155 172 } 156 173 } trunk/project/modules/devel/cms3/heading/classes/headingservices.class.php
r2922 r2936 41 41 } 42 42 43 /** 44 * Retourne le chemin des parents à partir d'un identifiant public 45 * 46 * @param int $pPublicId : identifiant public 47 * @return array () : Identifiants des parents 48 */ 43 49 public function getPathFromPublicId ($pPublicId){ 50 if (!is_integer($pPublicId)) { 51 throw new CopixException ('ID must be an integer'); 52 } 53 $path = array (); 54 $public_id = $pPublicId; 55 for (;;) { 56 $parameters = _daoSp ()->addCondition ('public_id_hei', '=', $public_id) 57 ->setLimit (0, 1); 58 $results = _dao('heading')->findBy ($parameters); 59 if ($results[0]->parent_id_head !== null) { 60 $record = _dao('heading')->get ($results[0]->parent_id_head); 61 $path[] = $record->public_id_hei; 62 $public_id = $record->public_id_hei; 63 } else { 64 break; 65 } 66 } 67 return $path; 44 68 } 45 46 public function getPathFromId ($pId){ 69 70 /** 71 * Retourne le chemin des parents à partir d'un identifiant 72 * 73 * @param int $pId : identifiant 74 * @return array () : Identifiants des parents 75 */ 76 public function getPathFromId ($pId) { 77 if (!is_integer($pId)) { 78 throw new CopixException ('ID must be an integer'); 79 } 80 $path = array (); 81 $id_head = $pId; 82 for (;;) { 83 $results = _dao('heading')->get ($id_head); 84 if ($results->parent_id_head !== null) { 85 $path[] = $results->parent_id_head; 86 $id_head = $results->parent_id_head; 87 } else { 88 break; 89 } 90 } 91 return $path; 47 92 } 48 93 } trunk/project/modules/devel/cms3/heading/install/scripts/install.pdo_mysql.sql
r2923 r2936 37 37 PRIMARY KEY (`id_hei`) 38 38 ) AUTO_INCREMENT=1 ; 39 40 -- Données pour les tests unitaires -- 41 42 INSERT INTO `heading` (`id_head`, `public_id_hei`, `parent_id_head`, `description_head`) VALUES 43 (1, 4, NULL, NULL), 44 (2, 4, NULL, NULL), 45 (5, 16, 2, NULL), 46 (6, 16, 2, NULL), 47 (8, 85, 6, NULL), 48 (9, 85, 6, NULL); 49 50 INSERT INTO `headingelementinformation` (`id_hei`, `id_helt`, `type_hei`, `public_id_hei`, `site_id_hei`, `public_id_heading_hei`, `author_id_create_hei`, `author_handler_create_hei`, `author_caption_create_hei`, `date_create_hei`, `author_id_update_hei`, `author_handler_udpate_hei`, `author_caption_update_hei`, `date_update_hei`, `comment_hei`, `caption_hei`, `published_date_hei`, `end_published_date_hei`, `status_hei`, `version_hei`, `from_version_hei`, `show_in_menu_hei`, `base_url_hei`, `url_id_hei`, `public_id_root_menu_hei`, `public_id_contextual_menu_hei`, `theme_id_hei`) VALUES 51 (1, 0, '', 1, '', 0, '', '', '', '0000-00-00 00:00:00', '', '', '', '0000-00-00 00:00:00', NULL, '', NULL, NULL, '', 1, 0, 0, NULL, NULL, NULL, NULL, NULL), 52 (2, 0, '', 1, '', 0, '', '', '', '0000-00-00 00:00:00', '', '', '', '0000-00-00 00:00:00', NULL, '', NULL, NULL, '', 2, 1, 0, NULL, NULL, NULL, NULL, NULL), 53 (3, 0, '', 1, '', 0, '', '', '', '0000-00-00 00:00:00', '', '', '', '0000-00-00 00:00:00', NULL, '', NULL, NULL, '', 3, 2, 0, NULL, NULL, NULL, NULL, NULL); trunk/project/modules/devel/cms3/heading/tests/heading_headingelementinformationtest.class.php
r2911 r2936 22 22 public function testSupressionHeadingElementInformation (){ 23 23 } 24 25 public function testgetNextVersion () { 26 CopixClassesFactory::fileInclude('heading|headingelementinformationservices'); 27 $this->assertTrue(HeadingElementInformationServices::getNextVersion(1) == 4); 28 } 29 24 30 }
