Changeset 2956

Show
Ignore:
Timestamp:
07/24/08 17:28:14 (4 weeks ago)
Author:
gcroes
Message:

Fonctionne maintenant correctement avec plusieurs modules (c'était le but)
Ajout d'un élément image
Lance une exception si on demande le libellé d'un type qui n'existe pas
Changement du nom du cache
La classe gère elle même le décodage du XML (c'est aussi le but)

Files:

Legend:

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

    r2949 r2956  
    11<?php 
    22/** 
    3  * @package    standard 
     3 * @package    cms 
    44 * @subpackage heading 
    55 * @author     Gérald CROËS, Alexandre JULIEN 
     
    88 * @license    http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 
    99 */ 
     10 
     11/** 
     12 * Opérations sur les types d'éléments 
     13 * @package cms 
     14 * @subpackage heading 
     15 */ 
    1016class HeadingElementType { 
    1117     
     
    1319        CopixClassesFactory::fileInclude ('heading|headingparameterservices'); 
    1420        $xml = CopixModule::getParsedModuleInformation ( 
    15                             "headingList_ParameterGroups", 
     21                            "heading_ElementTypes", 
    1622                            "/moduledefinition/registry/entry[@id='HeadingElement']/*", 
    17                             array ('HeadingParameterServices', 'getTypesFromXML')); 
     23                            array ($this, 'getTypesFromXML')); 
    1824        return $xml; 
    1925    } 
     
    2531     * @return string libellé 
    2632     */ 
    27     public function getCaption ($id) { 
    28         $arData = self::getList($id); 
    29         return $arData[$id]; 
     33    public function getCaption ($pId) { 
     34        $arData = self::getList (); 
     35        if (!array_key_exists ($pId, $arData)){ 
     36            throw new CopixException ('Element de type '.$pId.' non trouvé'); 
     37        } 
     38        return $arData[$id]['caption']; 
    3039    } 
    3140     
     41    /** 
     42     *  
     43     */ 
     44    public function getTypesFromXml ($moduleNode){ 
     45        $arData = array (); 
     46        foreach ($moduleNode as $moduleName=>$moduleNodes) { 
     47            foreach ($moduleNodes as $node){ 
     48                if ($node->getName () === 'type') { 
     49                    $id = _toString ($node['id']); 
     50     
     51                    if (_toString ($node['caption']) !== '') { 
     52                        $arData[$id]['caption'] = _toString ($node['caption']); 
     53                    } elseif (_toString ($node['captioni18n']) !== '') { 
     54                        $arData[$id]['caption'] = _i18n (_toString($node['captioni18n'])); 
     55                    } 
     56                     
     57                    if (_toString ($node['image']) !== ''){ 
     58                        $arData[$id]['image'] = _toString ($node['image']); 
     59                    }else{ 
     60                        $arData[$id]['image'] = null; 
     61                    } 
     62                } 
     63            } 
     64        } 
     65        return $arData; 
     66    }  
    3267} 
    3368?>