[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 3 if ( !class_exists( 'NestedTestContentClass' ) ) 4 { 5 class NestedTestContentClass 6 { 7 function NestedTestContentClass( $id, $identifier, $name, $attributes ) 8 { 9 $this->ID = $id; 10 $this->Identifier = $identifier; 11 $this->Name = $name; 12 $this->Attributes = $attributes; 13 } 14 15 function attributes() 16 { 17 return array( 'id', 'name', 'attributes', 'identifier' 18 ); 19 } 20 21 function hasAttribute( $name ) 22 { 23 return in_array( $name, array( 'id', 'name', 'attributes', 'identifier' 24 ) ); 25 } 26 27 function &attribute( $name ) 28 { 29 if ( $name == 'name' ) 30 return $this->Name; 31 else if ( $name == 'attributes' ) 32 return $this->Attributes; 33 else if ( $name == 'identifier' ) 34 return $this->Identifier; 35 else if ( $name == 'id' ) 36 return $this->ID; 37 $retValue = null; 38 return $retValue; 39 } 40 } 41 } 42 43 if ( !class_exists( 'NestedTestContentObject' ) ) 44 { 45 class NestedTestContentObject 46 { 47 function NestedTestContentObject( $id, $name, $section, $attributes, &$class, $list = array() ) 48 { 49 $this->ID = $id; 50 $this->Name = $name; 51 $this->Section = $section; 52 $this->Class =& $class; 53 $this->Attributes = $attributes; 54 $this->List = $list; 55 } 56 57 function attributes() 58 { 59 return array( 'id', 'name', 'attributes', 60 'list', 61 'section_id', 'contentclass_id', 'class_identifier' 62 ); 63 } 64 65 function hasAttribute( $name ) 66 { 67 return in_array( $name, array( 'id', 'name', 'attributes', 68 'list', 69 'section_id', 'contentclass_id', 'class_identifier' 70 ) ); 71 } 72 73 function &attribute( $name ) 74 { 75 if ( $name == 'name' ) 76 return $this->Name; 77 else if ( $name == 'attributes' ) 78 return $this->Attributes; 79 else if ( $name == 'section_id' ) 80 return $this->Section; 81 else if ( $name == 'list' ) 82 return $this->List; 83 else if ( $name == 'contentclass_id' ) 84 return $this->Class->ID; 85 else if ( $name == 'class_identifier' ) 86 return $this->Class->Identifier; 87 else if ( $name == 'id' ) 88 return $this->ID; 89 $retValue = null; 90 return $retValue; 91 } 92 } 93 } 94 95 if ( !class_exists( 'NestedTestContentObjectTreeNode' ) ) 96 { 97 class NestedTestContentObjectTreeNode 98 { 99 function NestedTestContentObjectTreeNode( $id, $name, &$object ) 100 { 101 $this->ID = $id; 102 $this->Name = $name; 103 $this->Object =& $object; 104 $this->Children = array(); 105 $object->Node =& $this; 106 } 107 108 function attributes() 109 { 110 return array( 'node_id', 'name', 'object', 'children', 'contentobject_id' ); 111 } 112 113 function hasAttribute( $name ) 114 { 115 return in_array( $name, array( 'node_id', 'name', 'object', 'children', 'contentobject_id' ) ); 116 } 117 118 function &attribute( $name ) 119 { 120 if ( $name == 'name' ) 121 return $this->Name; 122 else if ( $name == 'object' ) 123 return $this->Object; 124 else if ( $name == 'children' ) 125 return $this->Children; 126 else if ( $name == 'contentobject_id' ) 127 { 128 return $this->Object->ID; 129 } 130 else if ( $name == 'node_id' ) 131 return $this->ID; 132 $retValue = null; 133 return $retValue; 134 } 135 136 function addChild( &$node ) 137 { 138 $this->Children[] =& $node; 139 } 140 } 141 } 142 143 if ( !class_exists( 'NestedTestContentObjectAttribute' ) ) 144 { 145 class NestedTestContentObjectAttribute 146 { 147 function NestedTestContentObjectAttribute( $id, $dataText = false, $dataInt = false ) 148 { 149 $this->ID = $id; 150 // $this->DataTypeString = $dataTypeString; 151 // $this->Name = $name; 152 $this->DataText = $dataText; 153 $this->DataInt = $dataInt; 154 $this->ClassAttribute = false; 155 } 156 157 function attributes() 158 { 159 return array( 'edit_template', 'view_template', 160 'name', 'contentclass_attribute', 161 'data_type_string', 162 'id', 'data_text', 'data_int' ); 163 } 164 165 function hasAttribute( $name ) 166 { 167 return in_array( $name, array( 'edit_template', 'view_template', 168 'name', 'contentclass_attribute', 169 'data_type_string', 170 'section_id', 'contentclass_id', 'class_identifier', 171 'id', 'data_text', 'data_int' ) ); 172 } 173 174 function &attribute( $name ) 175 { 176 if ( $name == 'edit_template' ) 177 return $this->ClassAttribute->attribute( 'data_type_string' ); 178 else if ( $name == 'view_template' ) 179 return $this->ClassAttribute->attribute( 'data_type_string' ); 180 else if ( $name == 'name' ) 181 return $this->ClassAttribute->attribute( 'name' ); 182 else if ( $name == 'contentclass_attribute' ) 183 return $this->ClassAttribute; 184 else if ( $name == 'id' ) 185 return $this->ID; 186 else if ( $name == 'data_text' ) 187 return $this->DataText; 188 else if ( $name == 'data_int' ) 189 return $this->DataInt; 190 $retValue = null; 191 return $retValue; 192 } 193 } 194 } 195 196 if ( !class_exists( 'NestedTestContentClassAttribute' ) ) 197 { 198 class NestedTestContentClassAttribute 199 { 200 function NestedTestContentClassAttribute( $id, $dataTypeString, $name, $isInformationCollector ) 201 { 202 $this->ID = $id; 203 $this->DataTypeString = $dataTypeString; 204 $this->Name = $name; 205 $this->IsInformationCollector = $isInformationCollector; 206 // $this->DataText = $dataText; 207 // $this->DataInt = $dataInt; 208 } 209 210 function attributes() 211 { 212 return array( 'edit_template', 'view_template', 213 'data_type_string', 214 'id', 'name', 'is_information_collector' ); 215 } 216 217 function hasAttribute( $name ) 218 { 219 return in_array( $name, array( 'edit_template', 'view_template', 220 'data_type_string', 221 'id', 'name', 'is_information_collector' ) ); 222 } 223 224 function &attribute( $name ) 225 { 226 if ( $name == 'edit_template' ) 227 return $this->DataTypeString; 228 else if ( $name == 'view_template' ) 229 return $this->DataTypeString; 230 else if ( $name == 'data_type_string' ) 231 return $this->DataTypeString; 232 else if ( $name == 'name' ) 233 return $this->Name; 234 else if ( $name == 'id' ) 235 return $this->ID; 236 else if ( $name == 'is_information_collector' ) 237 return $this->IsInformationCollector; 238 // else if ( $name == 'data_text' ) 239 // return $this->DataText; 240 // else if ( $name == 'data_int' ) 241 // return $this->DataInt; 242 $retValue = null; 243 return null; 244 } 245 } 246 } 247 248 $cattribute1 = new NestedTestContentClassAttribute( 2, 'ezstring', 'Title', false ); 249 $cattribute2 = new NestedTestContentClassAttribute( 3, 'eztext', 'Message', true ); 250 $cattribute3 = new NestedTestContentClassAttribute( 4, 'ezstring', 'Author', true ); 251 $cattribute4 = new NestedTestContentClassAttribute( 5, 'ezstring', 'Author2', false ); 252 $cattribute5 = new NestedTestContentClassAttribute( 6, 'ezfile', 'File', false ); 253 254 $cattributes1 = array( $cattribute1, $cattribute2, $cattribute3, $cattribute4, $cattribute5 ); 255 $class1 = new NestedTestContentClass( 1, 'article', 'Article', $cattributes1 ); 256 257 $cattribute2_1 = new NestedTestContentClassAttribute( 12, 'ezstring', 'Title', false ); 258 $cattribute2_2 = new NestedTestContentClassAttribute( 13, 'eztext', 'Body', false ); 259 260 $cattributes2 = array( $cattribute2_1, $cattribute2_2 ); 261 $class2 = new NestedTestContentClass( 2, 'folder', 'Folder', $cattributes2 ); 262 263 $attribute1 = new NestedTestContentObjectAttribute( 5, 'New article' ); 264 $attribute1->ClassAttribute = $cattribute1; 265 $attribute2 = new NestedTestContentObjectAttribute( 6, 'Cool site' ); 266 $attribute2->ClassAttribute = $cattribute2; 267 $attribute3 = new NestedTestContentObjectAttribute( 7, 'John Doe' ); 268 $attribute3->ClassAttribute = $cattribute3; 269 $attribute4 = new NestedTestContentObjectAttribute( 8, 'Arne' ); 270 $attribute4->ClassAttribute = $cattribute4; 271 $attribute5 = new NestedTestContentObjectAttribute( 9, 'info.pdf' ); 272 $attribute5->ClassAttribute = $cattribute5; 273 274 $attribute2_1 = new NestedTestContentObjectAttribute( 15, 'New article' ); 275 $attribute2_1->ClassAttribute = $cattribute1; 276 $attribute2_2 = new NestedTestContentObjectAttribute( 16, 'Cool site' ); 277 $attribute2_2->ClassAttribute = $cattribute2; 278 $attribute2_3 = new NestedTestContentObjectAttribute( 17, 'John Doe' ); 279 $attribute2_3->ClassAttribute = $cattribute3; 280 $attribute2_4 = new NestedTestContentObjectAttribute( 18, 'Arne' ); 281 $attribute2_4->ClassAttribute = $cattribute4; 282 $attribute2_5 = new NestedTestContentObjectAttribute( 19, 'test.pdf' ); 283 $attribute2_5->ClassAttribute = $cattribute5; 284 285 $attribute3_1 = new NestedTestContentObjectAttribute( 25, 'New article' ); 286 $attribute3_1->ClassAttribute = $cattribute1; 287 $attribute3_2 = new NestedTestContentObjectAttribute( 26, 'Cool site' ); 288 $attribute3_2->ClassAttribute = $cattribute2; 289 $attribute3_3 = new NestedTestContentObjectAttribute( 27, 'John Doe' ); 290 $attribute3_3->ClassAttribute = $cattribute3; 291 $attribute3_4 = new NestedTestContentObjectAttribute( 28, 'Arne' ); 292 $attribute3_4->ClassAttribute = $cattribute4; 293 $attribute3_5 = new NestedTestContentObjectAttribute( 29, 'document.pdf' ); 294 $attribute3_5->ClassAttribute = $cattribute5; 295 296 $attributes1 = array( $attribute1, $attribute2, $attribute3, $attribute4, $attribute5 ); 297 $object1 = new NestedTestContentObject( 2, 'New article', 1, $attributes1, $class1 ); 298 $attributes2 = array( $attribute2_1, $attribute2_2, $attribute2_3, $attribute2_4, $attribute2_5 ); 299 $object2 = new NestedTestContentObject( 3, 'Sub article', 1, $attributes2, $class1, array( 1, 5, 10 ) ); 300 $attributes3 = array( $attribute3_1, $attribute3_2, $attribute3_3, $attribute3_4, $attribute3_5 ); 301 $object3 = new NestedTestContentObject( 4, 'Sub folder', 1, $attributes3, $class2, array( 2, 4, 12 ) ); 302 $object4 = null; 303 304 $node1 = new NestedTestContentObjectTreeNode( 2, 'New article', $object1 ); 305 $node2 = new NestedTestContentObjectTreeNode( 3, 'Sub article', $object2 ); 306 $node1->addChild( $node2 ); 307 $node3 = new NestedTestContentObjectTreeNode( 4, 'Sub folder', $object3 ); 308 $node1->addChild( $node3 ); 309 $top = new NestedTestContentObjectTreeNode( 5, 'Top folder', $object4 ); 310 $top->addChild( $node1 ); 311 312 $tpl->setVariable( 'object', $object1 ); 313 $tpl->setVariable( 'top', $top ); 314 315 include_once ( 'kernel/common/eztemplatedesignresource.php' ); 316 $designResource =& eZTemplateDesignResource::instance(); 317 $designResource->setKeys( array( array( 'object' => $object1->attribute( 'id' ) ), 318 array( 'section', $object1->attribute( 'section_id' ) ), 319 array( 'node' , $node1->attribute( 'node_id' ) ) ) ); 320 321 322 ?>
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 |