Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
hipo_backend_outputter.inc
1 <?php
17 require_once SQ_SYSTEM_ROOT.'/core/include/backend_outputter.inc';
18 
19 
33 {
34 
39  var $_form_data = Array();
40 
41 
50  {
51  $this->Backend_Outputter();
52 
53  }//end constructor
54 
55 
65  function setFormData($form_name, $url)
66  {
67  $this->_form_data = Array('form_name' => $form_name, 'url' => $url);
68 
69  }//end setFormData()
70 
71 
78  function _paintHeader()
79  {
80  if (!headers_sent()) {
81  if ($this->_charset) {
82  header("Content-type: text/html; charset=$this->_charset");
83  } else {
84  header('Content-type: text/html; charset='.SQ_CONF_DEFAULT_CHARACTER_SET);
85  }
86  }
87  ?>
88  <html>
89  <head>
90  <title><?php echo translate('hipo_processing'); ?></title>
91  <?php
92 
93  $this->addCssInclude($this->filesPath('css/edit.css'));
94  $this->addCssInclude($this->filesPath('css/hipo.css'));
95  foreach ($this->_css_includes as $file) {
96  $this->_paintCssInclude($file);
97  }
98 
99  // add JS translation files
100  foreach ($GLOBALS['SQ_SYSTEM']->lm->getJavascriptIncludes() as $js_include) {
101  $this->addJsInclude($js_include);
102  }
103 
104  // add general Js includes
105  $this->addJsInclude(sq_web_path('lib').'/html_form/html_form.js');
106  $this->addJsInclude(sq_web_path('lib').'/js/general.js');
107  $this->addJsInclude(sq_web_path('lib').'/js/debug.js');
108  $this->addJsInclude(sq_web_path('lib').'/js/edit.js');
109 
110  // print them all out
111  foreach ($this->_js_includes as $file) {
112  $this->_paintJsInclude($file);
113  }
114  ?>
115  <script type="text/javascript">
116  <!--
117  var ON_LOAD_TIME_OUT = null;
118  function page_on_load() {
119  <?php
120  foreach ($this->_on_load_calls as $call) {
121  echo "\n".$call;
122  }
123  ?>
124  }// end page_on_load()
125 
126  // -->
127  </script>
128  </head>
129  <body bgcolor="#FFFFFF" onLoad="javascript: page_on_load();">
130  <table border="0" cellspacing="0" cellpadding="0" width="100%">
131  <tr>
132  <td><img src="<?php echo $this->filesPath('images/blank.gif');?>" width="1" height="20" /></td>
133  </tr>
134  <tr>
135  <td align="center">
136  <form name="<?php echo $this->_form_data['form_name']; ?>" method="post" action="<?php echo $this->_form_data['url']; ?>" enctype="multipart/form-data">
137  <?php
138  foreach ($this->_hidden_fields as $name => $value) {
139  hidden_field($name, $value);
140  }
141 
142  }//end _paintHeader()
143 
144 
151  function _paintFooter()
152  {
153  ?>
154  </form>
155  </td>
156  </tr>
157  </table>
158  </body>
159  </html>
160  <?php
161 
162  }//end _paintFooter()
163 
164 
174  function _paintSection($section, $depth=0)
175  {
176  if ($section['type'] == 'raw') {
177  echo $section['contents'];
178  } else {
179 
180  ?>
181  <a name="section_<?php echo $section['section_count']; ?>"></a>
182  <table width="100%" cellpadding="0" cellspacing="0" border="0">
183  <?php
184  if ($section['heading']) {
185  if ($depth > 0) {
186  // printing a nested section - needs to look a little different
187  ?>
188  <tr>
189  <td class="sq-backend-section-subheading" colspan="3"><?php echo $section['heading'];?></td>
190  </tr>
191  <?php
192  } else {
193  // printing a top level section
194  ?>
195  <tr class="sq-backend-section-heading-container">
196  <td colspan="3">
197  <table border="0" cellspacing="0" cellpadding="0">
198  <tr>
199  <td class="sq-backend-section-heading"><?php echo $section['heading'];?></td>
200  <td><img src="<?php echo $this->filesPath('images/section_icon.gif');?>" width="27" height="21" /></td>
201  </tr>
202  </table>
203  </td>
204  </tr>
205  <?php
206  }
207  }//end if
208 
209  // print the section seperator
210  ?>
211  <tr>
212  <td colspan="2"><img src="<?php echo $this->filesPath('images/blank.gif');?>" width="1" height="10" /></td>
213  </tr>
214  <tr>
215  <td><img src="<?php echo $this->filesPath('images/blank.gif');?>" width="10" height="1" /></td>
216  <td width="100%">
217  <table cellspacing="0" cellpadding="0" border="0" width="100%">
218  <?php
219 
220  for ($j = 0; $j < count($section['areas']); $j++) {
221  switch ($section['areas'][$j]['area_type']) {
222  case 'section' :
223  ?>
224  <tr>
225  <td width="100%" valign="top" colspan="2">
226  <?php
227  $this->_paintSection($section['areas'][$j], $depth + 1);
228  ?>
229  </td>
230  </tr>
231  <?php
232  break;
233 
234  case 'field' :
235  $field =& $section['areas'][$j];
236  switch ($field['format']) {
237  case 'new_line' :
238  $style = $id = '';
239  if ($field['hidden']) {
240  $style = 'style="display: none"';
241  }
242  if ($field['id_name']) {
243  $id = 'id="'.$field['id_name'].'"';
244  }
245  ?>
246  <tr <?php echo $style; ?> <?php echo $id; ?>>
247  <td class="sq-backend-field sq-backend-field-newline" colspan="2">
248  <a name="field_<?php echo $field['field_count']; ?>"></a>
249  <?php echo $field['name'];?>
250  </td>
251  </tr>
252  <tr>
253  <td class="sq-backend-data sq-backend-data-newline" colspan="2">
254  <?php
255  echo $field['contents'];
256  if ($field['note']) $this->note($field['note']);
257  ?>
258  </td>
259  </tr>
260  <?php
261  break;
262 
263  case 'commit' :
264  ?>
265  <tr>
266  <td class="sq-backend-data" style="text-align: right;" colspan="2">
267  <?php
268  echo $field['contents'];
269  if ($field['note']) $this->note($field['note']);
270  ?>
271  </td>
272  </tr>
273  <?php
274  break;
275 
276  case 'blank' :
277  // a blank field to be used just for formatting
278  break;
279 
280  default :
281  $style = $id = '';
282  if ($field['hidden']) {
283  $style = 'style="display: none"';
284  }
285  if ($field['id_name']) {
286  $id = 'id="'.$field['id_name'].'"';
287  }
288  ?>
289  <tr <?php echo $style; ?> <?php echo $id; ?>>
290  <td class="sq-backend-field">
291  <a name="field_<?php echo $field['field_count']; ?>"></a>
292  <?php echo $field['name'];?>
293  </td>
294  <td class="sq-backend-data">
295  <?php
296  echo $field['contents'];
297  if ($field['note']) $this->note($field['note']);
298  ?>
299  </td>
300  </tr>
301  <?php
302  }//end switch
303  break;
304 
305  default :
306  trigger_localised_error('HIPO0059', E_USER_ERROR, $section['areas'][$j]['area_type']);
307 
308  }//end switch area type
309 
310  }//end for
311 
312  ?>
313  </table>
314  </td>
315  <td><img src="<?php echo $this->filesPath('images/blank.gif');?>" width="10" height="1" /></td>
316  </tr>
317  </table>
318  <table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td width="100%"><img src="<?php echo $this->filesPath('images/blank.gif');?>" width="1" height="10" /></td></tr></table>
319  <?php
320 
321  }//end else section type == raw
322 
323  }//end _paintSection()
324 
325 
326 }//end class
327 
328 ?>