Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
system_maintenance.inc
1 <?php
31 {
40  public function paintBackend(&$backend)
41  {
42  $o =& $backend->out;
43 
44  if (isset($_GET['report_type_code'])) {
45  $report = $_GET['report_type_code'];
46 
47  $this->_processReport($o, $report);
48  $this->_paintReport($o, $report);
49  exit;
50  }
51 
52  $o->setHeading(translate('system_maintenance'), sq_get_icon($o->filesPath('/images/icons/header/system_maintenance.png'), 20, 20, translate('system_maintenance')));
53  $o->setPageTitle(translate('system_maintenance'));
54 
55  $o->openSection(translate('reports_and_maintenance_tasks'));
56  $o->openField('');
57  $reports = $GLOBALS['SQ_SYSTEM']->am->getTypeDescendants('simple_report');
58 
59  if (count($reports) > 0) {
60  $backend_url = $backend->getBackendUrl('main');
61 
62  ?>
63  <script type="text/javascript" src="<?php echo sq_web_path('lib'); ?>/js/JsHttpConnector.js"></script>
64  <script type="text/javascript">
65  var selectedReport = '';
66 
67  function toggleDiv(id)
68  {
69  var d = document.getElementById(id);
70  var disp = "none";
71 
72  if (d.style.display == "none") {
73  disp = "block";
74  }
75 
76  d.style.display = disp;
77  }
78 
79 
80  function regenCallback(responseText)
81  {
82  document.getElementById(selectedReport).innerHTML = responseText;
83  bg = document.getElementById(selectedReport+"_regen").style.background;
84  document.getElementById(selectedReport+"_regen").style.background = "#e8ddeb";
85  window.setTimeout('document.getElementById(selectedReport+"_regen").style.background = bg;', 1500);
86  }
87 
88 
89  function regen(report)
90  {
91  selectedReport = report;
92  var regenElement = document.getElementById(report+"_regen");
93  var reportElement = document.getElementById(report+"_report");
94  reportElement.style.opacity = "0.4";
95  reportElement.style.filter = "alpha(opacity=40)";
96  regenElement.innerHTML = "Regenerating...";
97  JsHttpConnector.submitRequest('<?php echo $backend_url; ?>&backend_section=sys_maintenance&report_type_code='+report, regenCallback);
98  }
99  </script>
100 
101  <table class="sq-backend-table">
102  <tr>
103  <th><?php echo translate('name'); ?></th>
104  <th><?php echo translate('description'); ?></th>
105  </tr>
106  <?php
107 
108  // Get report name and description and sort reports by name
109  $report_list = Array();
110  foreach ($reports as $report_type_code) {
111  $report_info = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($report_type_code);
112  $report_name = $report_info['name'];
113  $report_list[$report_name] = Array(
114  'type_code' => $report_type_code,
115  'description' => $report_info['description'],
116  );
117  }
118 
119  ksort($report_list);
120  reset($report_list);
121 
122  $expand_reports = '';
123  if (isset($_REQUEST['expand'])) $expand_reports = $_REQUEST['expand'];
124 
125  foreach ($report_list as $report_name => $report_info) {
126  ?>
127  <tr>
128  <td class="sq-backend-table-cell" style="background: white;"><a href="#<?php echo $report_info['type_code']; ?>" onclick="toggleDiv('<?php echo $report_info['type_code']; ?>');"><?php echo $report_name; ?></a></td>
129  <td class="sq-backend-table-cell" style="background: white;"><?php echo $report_info['description']; ?>
130  <div id="<?php echo $report_info['type_code']; ?>" style="display: <?php echo (($report_info['type_code'] == 'report_'.$expand_reports)?'block':'none'); ?>">
131  <?php
132 
133  $this->_paintReport($o, $report_info['type_code']);
134 
135  ?>
136  </div>
137  </td>
138  </tr>
139  <?php
140  }
141  ?>
142  </table>
143  <?php
144  } else {
145  echo translate('general_reports_not_installed');
146  }
147  $o->closeField();
148  $o->closeSection();
149 
150  }//end paintBackend()
151 
152 
162  private function _paintReport(&$o, $report_type_code)
163  {
164  $am =& $GLOBALS['SQ_SYSTEM']->am;
165 
166  if ($am->installed($report_type_code)) {
167  $am->includeAsset($report_type_code);
168  ?>
169  <br>
170  <div id="<?php echo $report_type_code; ?>_report">
171  <?php
172  call_user_func_array(Array($report_type_code, 'paintReport'), Array($o, $report_type_code));
173  ?>
174  </div>
175  <br><br>
176  <?php
177  }
178 
179  }//end _paintReport()
180 
181 
191  private function _processReport(&$o, $report_type_code)
192  {
193  $am =& $GLOBALS['SQ_SYSTEM']->am;
194 
195  if ($am->installed($report_type_code)) {
196  $am->includeAsset($report_type_code);
197  call_user_func_array(Array($report_type_code, 'processReport'), Array($o, $report_type_code));
198  }
199 
200  }//end _processReport()
201 
202 
203 }//end class
204 
205 ?>