Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
simple_report.inc
1 <?php
17 require_once SQ_INCLUDE_PATH.'/asset.inc';
18 
33 class Simple_Report extends Asset
34 {
35 
36 
43  function __construct($assetid=0)
44  {
45  parent::__construct($assetid);
46 
47  }//end constructor
48 
49 
60  public static function paintReport(Backend_Outputter &$o, $type_code)
61  {
62 
63  }//end paintReport()
64 
65 
76  public static function processReport(Backend_Outputter &$o, $type_code)
77  {
78  return TRUE;
79 
80  }//end processReport()
81 
82 
93  protected static function saveReport($type_code, $report_data)
94  {
95  $fd = FALSE;
96 
97  // Final check before using supplied type code
98  $am = $GLOBALS['SQ_SYSTEM']->am;
99  if ($am->installed($type_code)) {
100  $fd = fopen(SQ_CACHE_PATH.'/'.$type_code.'.dat', 'w');
101  if ($fd) {
102  fwrite($fd, serialize($report_data));
103  fclose($fd);
104  }
105  }
106 
107  return $fd;
108 
109  }//end saveReport()
110 
111 
121  protected static function loadReport($type_code)
122  {
123  $report_data = Array();
124 
125  // Final check before using supplied type code
126  $am = $GLOBALS['SQ_SYSTEM']->am;
127  if ($am->installed($type_code)) {
128  $filename = SQ_CACHE_PATH.'/'.$type_code.'.dat';
129  if (file_exists($filename)) {
130  $fd = fopen($filename, 'r');
131  if ($fd) {
132  $report_data = fread($fd, filesize($filename));
133  $report_data = unserialize($report_data);
134  if (!is_array($report_data)) $report_data = Array();
135  fclose($fd);
136  }
137  }
138  }
139 
140  return $report_data;
141 
142  }//end loadReport()
143 
144 
154  protected static function paintReportNotGenerated($type_code)
155  {
156  $generate_link = '<a href="#'.$type_code.'" onclick="regen(\''.$type_code.'\');">'.translate('generate_report').'</a>';
157 
158  $table_format = '<table class="sq-backend-table">
159  <tr>
160  <th class="sq-backend-table-header" width="35%%">'.translate('last_generated').'</th>
161  <td class="sq-backend-table-cell" id="'.$type_code.'_regen" align="right">%s &nbsp;&nbsp;( %s )</td>
162  </tr>
163  </table>';
164 
165  $table = sprintf($table_format, translate('report_not_generated'), $generate_link);
166  echo $table;
167 
168  }//end paintReportNotGenerated()
169 
170 
181  protected static function paintLastGeneratedDate($type_code, $date)
182  {
183  $regenerate_link = '<a href="#'.$type_code.'" onclick="regen(\''.$type_code.'\');">'.translate('regenerate_report').'</a>';
184 
185  $table_format = '<table class="sq-backend-table">
186  <tr>
187  <th class="sq-backend-table-header" width="35%%">'.translate('last_generated').'</th>
188  <td class="sq-backend-table-cell" id="'.$type_code.'_regen" align="right">%s &nbsp;&nbsp;( %s )</td>
189  </tr>
190  </table>';
191 
192  $table = sprintf($table_format, $date, $regenerate_link);
193  echo $table;
194 
195  }//end paintLastGeneratedDate()
196 
197 
209  protected static function paintRecommendedTasks(Backend_Outputter &$o, $type_code, $report_type_codes)
210  {
211  $table_format = '<table class="sq-backend-table">
212  <tr>
213  <th class="sq-backend-table-header" width="35%%">'.translate('recommended_maintenance_tasks').'</th>
214  <td class="sq-backend-table-cell" align="right">%s</td>
215  </tr>
216  </table>';
217 
218  // Get report name and description and sort reports by name
219  $report_list = Array();
220  foreach ($report_type_codes as $report_type_code) {
221  $report_info = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($report_type_code);
222  $report_name = $report_info['name'];
223  $report_list[$report_name] = Array(
224  'type_code' => $report_type_code,
225  'description' => $report_info['description'],
226  );
227  }
228 
229  ksort($report_list);
230  reset($report_list);
231 
232  $row_string = '';
233 
234  // Link to the relevant tools
235  foreach ($report_list as $report_name => $report) {
236  $row_string .= '<img src="'.sq_web_path('lib').'/web/images/icons/asset_map/myspace.png"> <a href="./?SQ_BACKEND_PAGE=main&backend_section=tools&tool_type_code='.$report['type_code'].'&redirect_to_sys_maintenance=1">'.$report_name.'</a>';
237  }
238 
239  $table = sprintf($table_format, $row_string);
240  echo $table;
241 
242  }//end paintRecommendedTasks()
243 
244 
245 }//end class
246 
247 
248 ?>