Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezmatrixdefinition.php
Go to the documentation of this file.
1 <?php
18 class eZMatrixDefinition
19 {
23 public function __construct()
24 {
25 $this->ColumnNames = array();
26 }
27
28
29 function decodeClassAttribute( $xmlString )
30 {
31 $dom = new DOMDocument( '1.0', 'utf-8' );
32 if ( strlen ( $xmlString ) != 0 )
33 {
34 $success = $dom->loadXML( $xmlString );
35 $columns = $dom->getElementsByTagName( "column-name" );
36 $columnList = array();
37 foreach ( $columns as $columnElement )
38 {
39 $columnList[] = array( 'name' => $columnElement->textContent,
40 'identifier' => $columnElement->getAttribute( 'id' ),
41 'index' => $columnElement->getAttribute( 'idx' ) );
42 }
43 $this->ColumnNames = $columnList;
44 }
45 else
46 {
47 $this->addColumn( );
48 $this->addColumn( );
49 }
50
51 }
52
53 function attributes()
54 {
55 return array( 'columns' );
56 }
57
58 function hasAttribute( $attr )
59 {
60 return in_array( $attr, $this->attributes() );
61 }
62
63 function attribute( $attr )
64 {
65 if ( $attr == 'columns' )
66 {
67 return $this->ColumnNames;
68 }
69
70 eZDebug::writeError( "Attribute '$attr' does not exist", __METHOD__ );
71 return null;
72 }
73
74 function xmlString( )
75 {
76 $doc = new DOMDocument( '1.0', 'utf-8' );
77 $root = $doc->createElement( "ezmatrix" );
78 $doc->appendChild( $root );
79
80 foreach ( $this->ColumnNames as $columnName )
81 {
82 $columnNameNode = $doc->createElement( 'column-name' );
83 $columnNameNode->appendChild( $doc->createTextNode( $columnName['name'] ) );
84 $columnNameNode->setAttribute( 'id', $columnName['identifier'] );
85 $columnNameNode->setAttribute( 'idx', $columnName['index'] );
86 $root->appendChild( $columnNameNode );
87 unset( $columnNameNode );
88 unset( $textNode );
89 }
90
91 $xml = $doc->saveXML();
92
93 return $xml;
94 }
95
96 function addColumn( $name = false , $id = false )
97 {
98 if ( $name == false )
99 {
100 $name = 'Col_' . ( count( $this->ColumnNames ) );
101 }
102
103 if ( $id == false )
104 {
105 // Initialize transformation system
106 $trans = eZCharTransform::instance();
107 $id = $trans->transformByGroup( $name, 'identifier' );
108 }
109
110 $this->ColumnNames[] = array( 'name' => $name,
111 'identifier' => $id,
112 'index' => count( $this->ColumnNames ) );
113 }
114
115 function removeColumn( $index )
116 {
117 if ( $index == 0 && count( $this->ColumnNames ) == 1 )
118 {
119 $this->ColumnNames = array();
120 }
121 else
122 {
123 unset( $this->ColumnNames[$index] );
124 }
125 }
126
127 public $ColumnNames;
128
129 }
130
131 ?>
eZCharTransform\instance
static instance()
Definition: ezchartransform.php:434
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZMatrixDefinition
The class eZMatrixDefinition does.
Definition: ezmatrixdefinition.php:19
eZMatrixDefinition\xmlString
xmlString()
Definition: ezmatrixdefinition.php:74
eZMatrixDefinition\$ColumnNames
$ColumnNames
Definition: ezmatrixdefinition.php:127
eZMatrixDefinition\decodeClassAttribute
decodeClassAttribute( $xmlString)
Definition: ezmatrixdefinition.php:29
eZMatrixDefinition\__construct
__construct()
Definition: ezmatrixdefinition.php:23
eZMatrixDefinition\attribute
attribute( $attr)
Definition: ezmatrixdefinition.php:63
eZMatrixDefinition\removeColumn
removeColumn( $index)
Definition: ezmatrixdefinition.php:115
eZMatrixDefinition\addColumn
addColumn( $name=false, $id=false)
Definition: ezmatrixdefinition.php:96
eZMatrixDefinition\hasAttribute
hasAttribute( $attr)
Definition: ezmatrixdefinition.php:58
eZMatrixDefinition\attributes
attributes()
Definition: ezmatrixdefinition.php:53
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.