Changeset 2936

Show
Ignore:
Timestamp:
07/23/08 15:36:10 (1 month ago)
Author:
alexandrej
Message:

Mise à jour Heading

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/project/modules/devel/cms3/heading/classes/headingelementinformationservices.class.php

    r2922 r2936  
    136136     * @return int  le numéro de version a venir  
    137137     */ 
    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             
    139146    } 
    140147     
     
    145152     */ 
    146153    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        } 
    147159    }    
    148160 
     
    153165     */ 
    154166    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        } 
    155172    }    
    156173} 
  • trunk/project/modules/devel/cms3/heading/classes/headingservices.class.php

    r2922 r2936  
    4141    } 
    4242 
     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     */ 
    4349    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; 
    4468    } 
    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; 
    4792    } 
    4893} 
  • trunk/project/modules/devel/cms3/heading/install/scripts/install.pdo_mysql.sql

    r2923 r2936  
    3737  PRIMARY KEY  (`id_hei`) 
    3838) AUTO_INCREMENT=1 ; 
     39 
     40-- Données pour les tests unitaires -- 
     41 
     42INSERT 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 
     50INSERT 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  
    2222    public function testSupressionHeadingElementInformation (){ 
    2323    } 
     24     
     25    public function testgetNextVersion () { 
     26        CopixClassesFactory::fileInclude('heading|headingelementinformationservices'); 
     27        $this->assertTrue(HeadingElementInformationServices::getNextVersion(1) == 4); 
     28    } 
     29     
    2430}