[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZMatrixDefinition class 4 // 5 // Created on: <03-Jun-2003 18:30:44 sp> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezmatrixdefinition.php 30 */ 31 32 /*! 33 \class eZMatrixDefinition ezmatrixdefinition.php 34 \ingroup eZDatatype 35 \brief The class eZMatrixDefinition does 36 37 */ 38 include_once ( "lib/ezxml/classes/ezxml.php" ); 39 40 class eZMatrixDefinition 41 { 42 /*! 43 Constructor 44 */ 45 function eZMatrixDefinition() 46 { 47 $this->ColumnNames = array(); 48 } 49 50 51 function decodeClassAttribute( $xmlString ) 52 { 53 $xml = new eZXML(); 54 $dom =& $xml->domTree( $xmlString ); 55 if ( strlen ( $xmlString ) != 0 ) 56 { 57 $columns = $dom->elementsByName( "column-name" ); 58 $columnList = array(); 59 foreach ( $columns as $columnElement ) 60 { 61 $columnList[] = array( 'name' => $columnElement->textContent(), 62 'identifier' => $columnElement->attributeValue( 'id' ), 63 'index' => $columnElement->attributeValue( 'idx' ) ); 64 } 65 $this->ColumnNames =& $columnList; 66 } 67 else 68 { 69 $this->addColumn( ); 70 $this->addColumn( ); 71 } 72 73 } 74 75 function attributes() 76 { 77 return array( 'columns' ); 78 } 79 80 function hasAttribute( $attr ) 81 { 82 return in_array( $attr, $this->attributes() ); 83 } 84 85 function &attribute( $attr ) 86 { 87 if ( $attr == 'columns' ) 88 { 89 return $this->ColumnNames; 90 } 91 else 92 { 93 eZDebug::writeError( "Attribute '$attr' does not exist", 'eZMatrixDefinition::attribute' ); 94 $retValue = null; 95 return $retValue; 96 } 97 } 98 99 function &xmlString( ) 100 { 101 $doc = new eZDOMDocument( "Matrix" ); 102 $root = $doc->createElementNode( "ezmatrix" ); 103 $doc->setRoot( $root ); 104 105 foreach ( $this->ColumnNames as $columnName ) 106 { 107 $columnNameNode = $doc->createElementNode( 'column-name' ); 108 $columnNameNode->appendAttribute( $doc->createAttributeNode( 'id', $columnName['identifier'] ) ); 109 $columnNameNode->appendAttribute( $doc->createAttributeNode( 'idx', $columnName['index'] ) ); 110 $columnNameNode->appendChild( $doc->createTextNode( $columnName['name'] ) ); 111 $root->appendChild( $columnNameNode ); 112 unset( $columnNameNode ); 113 } 114 115 $xml = $doc->toString(); 116 117 return $xml; 118 } 119 120 function addColumn( $name = false , $id = false ) 121 { 122 if ( $name == false ) 123 { 124 $name = 'Col_' . ( count( $this->ColumnNames ) ); 125 } 126 127 if ( $id == false ) 128 { 129 // Initialize transformation system 130 include_once ( 'lib/ezi18n/classes/ezchartransform.php' ); 131 $trans =& eZCharTransform::instance(); 132 $id = $trans->transformByGroup( $name, 'identifier' ); 133 } 134 135 $this->ColumnNames[] = array( 'name' => $name, 136 'identifier' => $id, 137 'index' => count( $this->ColumnNames ) ); 138 } 139 140 function removeColumn( $index ) 141 { 142 if ( $index == 0 && count( $this->ColumnNames ) == 1 ) 143 { 144 $this->ColumnNames = array(); 145 } 146 else 147 { 148 unset( $this->ColumnNames[$index] ); 149 } 150 } 151 152 var $ColumnNames; 153 154 } 155 156 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |