root/trunk/midcom/midcom.helper.schemaapi/schema.php

Revision 14084, 2.4 kB (checked in by flack, 10 months ago)

The PHPdoc Massacre, Part 1

Line 
1 <?php
2 /**
3  * @package midcom.helper.schemaapi
4  * @author The Midgard Project, http://www.midgard-project.org
5  * @copyright The Midgard Project, http://www.midgard-project.org
6  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7  */
8
9 /** @ignore */
10 require_once 'field.php';
11 require_once 'supertype.php';
12
13 /**
14  * @package midcom.helper.schemaapi
15  */
16 class midcom_helper_schemaapi_schema
17 {
18
19     protected $name = 'default';
20     protected $description = "Autogenerated schema for ";
21     protected $fields = array(  );
22
23     public function __construct(  )
24     {
25
26     }
27
28     public function asString (  )
29     {
30         $out = array(  );
31         $out[$this->name] = array (
32                 'description' => $this->description,
33                 'fields' => $this->fields,
34                 );
35
36         ob_start(  );
37         var_export( $out );
38         $ret = ob_get_contents(  );
39         ob_end_clean(  );
40         return $ret;
41     }
42     public function set_name( $name ) {
43
44         $this->name  = $name;
45     }
46
47     public function set_description( $desc )
48     {
49         $this->description = $desc;
50     }
51
52     public function get_description(  )
53     {
54         return $this->description;
55     }
56     /**
57      * adds a field to the fieldarray
58      * @param midcom_helper_schemaapi_field
59      */
60     public function add_field( $field )
61     {
62         $this->fields = array_merge$this->fields ,$field->asArray(  ));
63     }
64
65
66     public static function load_widget( $widget ) {
67         if ( !file_exists( dirname( __FILE__ ) . "/widget/$widget.php" ) )
68         {
69
70             $class =<<<EOF
71 <?php
72 class midcom_helper_schemaapi_widget_$widget extends midcom_helper_schemaapi_supertype
73 {
74
75     public function __construct (  ) {
76         parent::__construct( "$widget" );
77
78     }
79
80 }
81 ?>
82 EOF;
83
84             file_put_contents( dirname( __FILE__ ) . "/widget/$widget.php", $class );
85         }
86         require_once "widget/$widget.php";
87     }
88     public static function load_type( $type ) {
89         if ( !file_exists( dirname( __FILE__ ) . "/type/$type.php" ) )
90         {
91             $class =<<<EOF
92 <?php
93 class midcom_helper_schemaapi_type_$type extends midcom_helper_schemaapi_supertype
94 {
95
96
97     public function __construct ( ) {
98         parent::__construct( "$type" );
99     }
100
101 }
102 ?>
103 EOF;
104
105             file_put_contents( dirname( __FILE__ ) . "/type/$type.php", $class );
106         }
107         require_once "type/$type.php";
108     }
109
110
111 }
112
Note: See TracBrowser for help on using the browser.