3 class ReportAdmin
extends LeftAndMain
{
4 static $subitem_class = "GrantObject";
6 static $template_path = null; // defaults to (project)/templates/email
8 public function init() {
11 Requirements
::javascript(MCE_ROOT
. "tiny_mce_src.js");
12 Requirements
::javascript("jsparty/tiny_mce_improvements.js");
14 Requirements
::javascript("jsparty/hover.js");
15 Requirements
::javascript("jsparty/scriptaculous/controls.js");
17 Requirements
::javascript("cms/javascript/SecurityAdmin.js");
19 Requirements
::javascript("cms/javascript/LeftAndMain_left.js");
20 Requirements
::javascript("cms/javascript/LeftAndMain_right.js");
21 Requirements
::javascript("cms/javascript/CMSMain_left.js");
24 Requirements
::javascript("cms/javascript/ReportAdmin_left.js");
25 Requirements
::javascript("cms/javascript/ReportAdmin_right.js");
27 // TODO Find a better solution to integrate optional Requirements in a specific order
28 if(Director
::fileExists("ecommerce/css/DataReportCMSMain.css")) {
29 Requirements
::css("ecommerce/css/DataReportCMSMain.css");
31 if(Director
::fileExists("ecommerce/css/DataReportCMSMain.css")) {
32 Requirements
::javascript("ecommerce/javascript/DataReport.js");
34 if(Director
::fileExists(project() . "/css/DataReportCMSMain.css")) {
35 Requirements
::css(project() . "/css/DataReportCMSMain.css");
37 if(Director
::fileExists(project() . "/css/DataReportCMSMain.css")) {
38 Requirements
::javascript(project() . "/javascript/DataReport.js");
41 // We don't want this showing up in every ajax-response, it should always be present in a CMS-environment
42 if(!Director
::is_ajax()) {
43 Requirements
::javascriptTemplate("cms/javascript/tinymce.template.js", array(
44 "ContentCSS" => project() . "/css/editor.css",
45 "BaseURL" => Director
::absoluteBaseURL(),
50 public function Link($action = null) {
51 return "admin/reports/$action";
54 public function Reports(){
55 $allReports= ClassInfo
::subclassesFor("Report");
56 foreach($allReports as $report) {
57 if($report != 'Report') $processedReports[] = new $report();
60 $reports = new DataObjectSet($processedReports);
64 public function showreport($params) {
65 return $this->showWithEditForm( $params, $this->getReportEditForm( $params['ID'] ) );
68 protected function showWithEditForm( $params, $editForm ) {
70 Session
::set('currentPage', $params['ID']);
72 if($params['OtherID']) {
73 Session
::set('currentOtherID', $params['OtherID']);
76 if($_REQUEST['ajax']) {
77 SSViewer
::setOption('rewriteHashlinks', false);
78 $result = $this->customise( array( 'EditForm' => $editForm ) )->renderWith($this->getTemplatesWithSuffix("_right"));
79 return $this->getLastFormIn($result);
85 public function EditForm() {
86 $id = $_REQUEST['ID'] ?
$_REQUEST['ID'] : Session
::get('currentPage');
88 $subclasses = ClassInfo
::subclassesFor('Report');
90 foreach($subclasses as $class){
91 if($class != 'Report') {
93 $ids[] = $obj->getOwnerID();
97 // bdc: do we have any subclasses?
99 if($id && in_array($id, $ids)) return $this->getReportEditForm($id);
107 public function getReportEditForm($id){
109 $page = DataObject
::get_by_id("SiteTree", $id);
110 if($page) $reportClass = "Report_".$page->ClassName
;
115 $obj = new $reportClass();
116 $fields = $obj->getCMSFields();
118 $fields->push($idField = new HiddenField("ID"));
119 $idField->setValue($id);
121 //$actions = new FieldSet(new FormAction('exporttocsv', 'Export to CVS'));
122 $actions = new FieldSet();
123 $form = new Form($this, "EditForm", $fields, $actions);