Xataface HTML Reports Module 0.2
HTML Reports Module for Xataface
|
00001 <?php 00002 /* 00003 * Xataface HTML Reports Module 00004 * Copyright (C) 2011 Steve Hannah <steve@weblite.ca> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Library General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Library General Public 00017 * License along with this library; if not, write to the 00018 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 * 00021 */ 00022 00073 class actions_htmlreports_validate_template { 00074 function handle($params){ 00075 00076 try { 00077 00078 if ( !@$_POST['--template'] ){ 00079 throw new Exception("No template content provided"); 00080 } 00081 00082 if ( !@$_POST['-table'] ){ 00083 throw new Exception("No table specified for template."); 00084 } 00085 00086 require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'XfHtmlReportBuilder.class.php'); 00087 00088 $table = Dataface_Table::loadTable($_POST['-table']); 00089 $perms = $table->getPermissions(array()); 00090 if ( !@$perms['validate report template'] ){ 00091 throw new Exception("You don't have permission to validate this template. Template validation requires the 'validate report template' permission."); 00092 00093 } 00094 $res = XfHtmlReportBuilder::validateTemplate($table, $_POST['--template']); 00095 00096 00097 //$results = XfHtmlReportBuilder::fillReportTable($records, $report->val('template_html')); 00098 00099 $this->out(array( 00100 'code'=>200, 00101 'message'=> 'Template validation was successful. No errors found.' 00102 )); 00103 exit; 00104 00105 } catch (Exception $ex){ 00106 $this->out(array( 00107 'code'=> $ex->getCode(), 00108 'message'=> $ex->getMessage() 00109 )); 00110 exit; 00111 00112 00113 } 00114 } 00115 00116 function out($params){ 00117 header('Content-type: text/json; charset="'.Dataface_Application::getInstance()->_conf['oe'].'"'); 00118 echo json_encode($params); 00119 } 00120 }