Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
get_design_area_setable_attrs.php
1 <?php
24 error_reporting(E_ALL);
25 $SYSTEM_ROOT = '';
26 // from cmd line
27 if ((php_sapi_name() == 'cli')) {
28  if (isset($_SERVER['argv'][1])) $SYSTEM_ROOT = $_SERVER['argv'][1];
29  $err_msg = "You need to supply the path to the System Root as the first argument\n";
30 
31 } else {
32  if (isset($_GET['SYSTEM_ROOT'])) $SYSTEM_ROOT = $_GET['SYSTEM_ROOT'];
33  $err_msg = '
34  <div style="background-color: red; color: white; font-weight: bold;">
35  You need to supply the path to the System Root as a query string variable called SYSTEM_ROOT
36  </div>
37  ';
38 }
39 
40 if (empty($SYSTEM_ROOT)) {
41  echo $err_msg;
42  exit();
43 }
44 
45 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.'/core/include/init.inc')) {
46  echo "ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
47  exit();
48 }
49 
50 require_once $SYSTEM_ROOT.'/core/include/init.inc';
51 
52 $am = &$GLOBALS['SQ_SYSTEM']->am;
53 
54 $design_area_types = $am->getTypeDescendants('design_area');
55 $design_types = $am->getTypeDescendants('design');
56 $design_types[] = 'design';
57 
58 // remove the 'design' asset type and any decendants
59 $all_design_area_types = array_diff($design_area_types, $design_types);
60 
61 $design_areas = Array();
62 // now remove all design areas that are not instantiable
63 foreach ($all_design_area_types as $type_code) {
64  #pre_echo($type_code.' : '.$am->getTypeInfo($type_code, 'instantiable'));
65  if ($am->getTypeInfo($type_code, 'instantiable')) $design_areas[] = $type_code;
66 }
67 
68 sort($design_areas);
69 
70 
71 if (!SQ_PHP_CLI) {
72  ?>
73  <html>
74  <title>Settable Attributes for Instantiable Design Areas</title>
75  <style type="text/css">
76  body, table, td, th {
77  font-family: verdana, arial, sans-serif;
78  font-size: 9pt;
79  background-color: #ffffff;
80  }
81 
82  table {
83  width: 100%;
84  border: 1px solid;
85  }
86  th, td {
87  vertical-align: top;
88  text-align: left;
89  }
90  th.type-code {
91  color: #ffffff;
92  background-color: #000000;
93  padding: 10px;
94  }
95 
96  </style>
97  <body>
98  <?php
99 }
100 
101 foreach ($design_areas as $type_code) {
102 
103  $am->includeAsset($type_code);
104  $da = new $type_code();
105 
106  $setable_vars = $da->vars;
107  $protected_vars = $da->getProtectedAttrs();
108 
109  if (SQ_PHP_CLI) {
110  echo $type_code, " ", str_repeat('-', 80 - (strlen($type_code) + 1)), "\n";
111  } else {
112  ?>
113  <table>
114  <tr>
115  <th class="type-code" colspan="3"><?php echo $type_code; ?></th>
116  </tr>
117  <tr>
118  <th width="20%">Var Name</th>
119  <th width="10%">Type</th>
120  <th width="70%">Description</th>
121  </tr>
122  <?php
123  }
124 
125  ksort($setable_vars);
126 
127  foreach ($setable_vars as $var_name => $info) {
128  if (in_array($var_name, $protected_vars) || $info['type']=='serialise') continue;
129  $attr = $da->getAttribute($var_name);
130  $desc = $attr->description;
131 
132  if ($info['type'] == 'selection') {
133  if (!SQ_PHP_CLI) $desc .= '<pre>';
134  else $desc .= "\n";
135  $desc .= "\t\tOptions : \n";
136  foreach ($attr->_params['options'] as $value => $text) {
137  $desc .= "\t\t\t".$value.' => '.$text."\n";
138  }
139  if (!SQ_PHP_CLI) $desc .= '</pre>';
140  }
141 
142  if (SQ_PHP_CLI) {
143  echo "\t-> ", $var_name, "\t" , $info['type'], "\t", $desc, "\n";
144  } else {
145  ?>
146  <tr>
147  <td><?php echo $var_name; ?></th>
148  <td><?php echo $info['type']; ?></th>
149  <td><?php echo $desc; ?></th>
150  </tr>
151  <?php
152  }
153 
154  }//end foreach
155 
156  if (SQ_PHP_CLI) {
157  echo str_repeat('-', 80), "\n\n";
158  } else {
159  ?>
160  </table>
161  <br>
162  <?php
163  }
164 
165  unset($edit_fns);
166  unset($da);
167 
168 }//end foreach
169 
170 if (!SQ_PHP_CLI) {
171  ?>
172  </body>
173  </html>
174  <?php
175 }
176 
177 ?>