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