mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
6bfb0ba64a
API CHANGE Deprecated menu manipulation through Object::addStaticVars(), changed internal representation of menu_item array to always use associative arrays ENHANCEMENT Added LeftAndMain::add_menu_item(), LeftAndMain::replace_menu_item(), LeftAndMain::remove_menu_item() ENHANCEMENT Moved default menu items from LeftAndMain->MainMenu() to cms/_config.php ENHANCEMENT Added ReportAdmin::has_reports() ENHANCEMENT Object::addStaticVars() can replace the whole array optionally ENHANCEMENT Object::stat() optionally returns uncached results ENHANCEMENT Moved Object::useCustomClass('SSDateTime') from Object.php to sapphire/_config.php ENHANCEMENT Misc documentation and formatting in LeftAndMain and Object classes git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@52171 467b73ca-7a2a-4603-9d3b-597d59a354a9
155 lines
4.3 KiB
PHP
Executable File
155 lines
4.3 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* @package cms
|
|
* @subpackage reports
|
|
*/
|
|
|
|
/**
|
|
* Reports section of the CMS
|
|
* @package cms
|
|
* @subpackage reports
|
|
*/
|
|
class ReportAdmin extends LeftAndMain {
|
|
static $subitem_class = "GrantObject";
|
|
|
|
static $template_path = null; // defaults to (project)/templates/email
|
|
|
|
public function init() {
|
|
parent::init();
|
|
|
|
Requirements::javascript(MCE_ROOT . "tiny_mce_src.js");
|
|
Requirements::javascript("jsparty/tiny_mce_improvements.js");
|
|
|
|
Requirements::javascript("jsparty/hover.js");
|
|
Requirements::javascript("jsparty/scriptaculous/controls.js");
|
|
|
|
Requirements::javascript("cms/javascript/SecurityAdmin.js");
|
|
|
|
Requirements::javascript("cms/javascript/LeftAndMain_left.js");
|
|
Requirements::javascript("cms/javascript/LeftAndMain_right.js");
|
|
Requirements::javascript("cms/javascript/CMSMain_left.js");
|
|
|
|
|
|
Requirements::javascript("cms/javascript/ReportAdmin_left.js");
|
|
Requirements::javascript("cms/javascript/ReportAdmin_right.js");
|
|
|
|
Requirements::css("cms/css/ReportAdmin.css");
|
|
|
|
// TODO Find a better solution to integrate optional Requirements in a specific order
|
|
if(Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
|
|
Requirements::css("ecommerce/css/DataReportCMSMain.css");
|
|
}
|
|
if(Director::fileExists("ecommerce/css/DataReportCMSMain.css")) {
|
|
Requirements::javascript("ecommerce/javascript/DataReport.js");
|
|
}
|
|
if(Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
|
|
Requirements::css(project() . "/css/DataReportCMSMain.css");
|
|
}
|
|
if(Director::fileExists(project() . "/css/DataReportCMSMain.css")) {
|
|
Requirements::javascript(project() . "/javascript/DataReport.js");
|
|
}
|
|
|
|
// We don't want this showing up in every ajax-response, it should always be present in a CMS-environment
|
|
if(!Director::is_ajax()) {
|
|
Requirements::javascriptTemplate("cms/javascript/tinymce.template.js", array(
|
|
"ContentCSS" => project() . "/css/editor.css",
|
|
"BaseURL" => Director::absoluteBaseURL(),
|
|
"Lang" => i18n::get_tinymce_lang()
|
|
));
|
|
}
|
|
}
|
|
|
|
public function Link($action = null) {
|
|
return "admin/reports/$action";
|
|
}
|
|
|
|
public function Reports(){
|
|
$allReports= ClassInfo::subclassesFor("Report");
|
|
foreach($allReports as $report) {
|
|
if($report != 'Report') $processedReports[] = new $report();
|
|
}
|
|
|
|
$reports = new DataObjectSet($processedReports);
|
|
return $reports;
|
|
}
|
|
|
|
public function showreport($params) {
|
|
return $this->showWithEditForm( $params, $this->getReportEditForm( $params['ID'] ) );
|
|
}
|
|
|
|
protected function showWithEditForm( $params, $editForm ) {
|
|
if(isset($params['ID'])) {
|
|
Session::set('currentPage', $params['ID']);
|
|
}
|
|
if(isset($params['OtherID'])) {
|
|
Session::set('currentOtherID', $params['OtherID']);
|
|
}
|
|
|
|
if(Director::is_ajax()) {
|
|
SSViewer::setOption('rewriteHashlinks', false);
|
|
$result = $this->customise( array( 'EditForm' => $editForm ) )->renderWith($this->getTemplatesWithSuffix("_right"));
|
|
return $this->getLastFormIn($result);
|
|
} else {
|
|
return array();
|
|
}
|
|
}
|
|
|
|
public function EditForm() {
|
|
$id = (isset($_REQUEST['ID'])) ? $_REQUEST['ID'] : Session::get('currentPage');
|
|
|
|
$subclasses = ClassInfo::subclassesFor('Report');
|
|
|
|
foreach($subclasses as $class){
|
|
if($class != 'Report') {
|
|
$obj = new $class();
|
|
$ids[] = $obj->getOwnerID();
|
|
}
|
|
}
|
|
|
|
// bdc: do we have any subclasses?
|
|
if(sizeof($ids) > 0){
|
|
if($id && in_array($id, $ids)) return $this->getReportEditForm($id);
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
public function getReportEditForm($id){
|
|
if(is_numeric($id))
|
|
$page = DataObject::get_by_id("SiteTree", $id);
|
|
$reportClass = (isset($page)) ? "Report_".$page->ClassName : $id;
|
|
|
|
$obj = new $reportClass();
|
|
$fields = $obj->getCMSFields();
|
|
|
|
$fields->push($idField = new HiddenField("ID"));
|
|
$idField->setValue($id);
|
|
|
|
//$actions = new FieldSet(new FormAction('exporttocsv', 'Export to CVS'));
|
|
$actions = new FieldSet();
|
|
$form = new Form($this, "EditForm", $fields, $actions);
|
|
|
|
return $form;
|
|
}
|
|
|
|
/**
|
|
* Determine if we have reports and need to display the Reports main menu item
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public static function has_reports() {
|
|
$subclasses = ClassInfo::subclassesFor('Report');
|
|
foreach($subclasses as $class){
|
|
if($class != 'Report') {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
?>
|