public function init()
 {
     parent::init();
     Requirements::css("dynamictemplate/css/DynamicTemplateAdmin.css");
     Requirements::css("dynamictemplate/thirdparty/jquery.treetable/src/stylesheets/jquery.treeTable.css");
     Requirements::javascript("dynamictemplate/thirdparty/jquery.treetable/src/javascripts/jquery.treeTable.min.js");
     Requirements::javascript("dynamictemplate/javascript/DynamicTemplateAdmin_left.js");
     Requirements::javascript("dynamictemplate/javascript/DynamicTemplateAdmin_right.js");
     Requirements::javascript("dynamictemplate/thirdparty/jquery.entwine-0.9/dist/jquery.entwine-dist.js");
     Requirements::javascript("dynamictemplate/thirdparty/editarea_0_8_2/edit_area/edit_area_full.js");
     self::$tree_class = "DynamicTemplate";
 }
 /**
  * Return the FieldSet used to edit a dynamic template in the CMS.
  */
 function getCMSFields()
 {
     $fileList = new DynamicTemplateFilesField("Files", "Files", $this);
     $titleField = $this->ID && $this->ID != "root" ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title");
     // delete files button
     if ($this->canEdit()) {
         $deleteButton = new InlineFormAction('deletemarked', _t('Folder.DELSELECTED', 'Delete selected files'), 'delete');
         $deleteButton->includeDefaultJS(false);
     } else {
         $deleteButton = new HiddenField('deletemarked');
     }
     // link file button
     if ($this->canEdit()) {
         $fileButtons = new CompositeField($linkFileButton = new InlineFormAction('linkfile', _t('DynamicTemplate.LINKFILE', 'Link file(s) from theme'), 'link'), $copyFileButton = new InlineFormAction('copyfile', _t('DynamicTemplate.COPYFILE', 'Copy file(s) from theme'), 'copy'), $newFileButton = new InlineFormAction('newfile', _t('DynamicTemplate.NEWFILE', 'New file'), 'newfile'));
         $linkFileButton->includeDefaultJS(false);
         $newFileButton->includeDefaultJS(false);
     } else {
         $fileButtons = new HiddenField('linkfile');
     }
     $propButtons = new CompositeField();
     //		$propButtons->push($exportButton = new InlineFormAction('exporttemplate', _t('DynamicTemplate.EXPORTTEMPLATE', 'Export'), 'export'));
     //		$exportButton->includeDefaultJS(false);
     //		if ($this->canEdit()) {
     //			$propButtons->push($saveButton = new InlineFormAction('savetemplate', _t('DynamicTemplate.SAVETEMPLATE', 'Save'), 'save'));
     //			$saveButton->includeDefaultJS(false);
     //		}
     if ($this->canDelete()) {
         $propButtons->push($deleteButton = new InlineFormAction('deletetemplate', _t('DynamicTemplate.DELETETEMPLATE', 'Delete'), 'delete'));
         $deleteButton->includeDefaultJS(false);
     }
     if (DynamicTemplateAdmin::tarball_available()) {
         $exportTarballButton = new InlineFormAction('exportastarball', _t('DynamicTemplate.EXPORT', 'Export as tarball'), 'exportastarball');
         $exportTarballButton->includeDefaultJS(false);
         $propButtons->push($exportTarballButton);
     }
     if (DynamicTemplateAdmin::zip_available()) {
         $exportZipButton = new InlineFormAction('exportaszip', _t('DynamicTemplate.EXPORT', 'Export as zip'), 'exportaszip');
         $exportZipButton->includeDefaultJS(false);
         $propButtons->push($exportZipButton);
     }
     $titleField = $this->ID && $this->ID != "root" ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title");
     if (!$this->canEdit()) {
         $titleField->setReadOnly(true);
     }
     $fields = new FieldSet(new HiddenField("Name"), new TabSet("Root", new Tab("Properties", _t('DynamicTemplate.PROPERTIESTAB', 'Properties'), $titleField, new ReadonlyField("URL", _t('Folder.URL', 'URL')), new ReadonlyField("Created", _t('Folder.CREATED', 'First Uploaded')), new ReadonlyField("LastEdited", _t('Folder.LASTEDITED', 'Last Updated')), $propButtons), new Tab("Files", _t('Folder.FILESTAB', "Files"), $fileList, $fileButtons, new HiddenField("FileIDs"), new HiddenField("DestFolderID")), new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"), new LabelField('UploadPrompt', _t('DynamicTemplate.UPLOADPROMPT', 'Upload files to your template. Uploads will automatically be added to the right place.')), new LiteralField("UploadIframe", $this->getUploadIframe()))), new HiddenField("ID"));
     if (!$this->canEdit()) {
         $fields->removeFieldFromTab("Root", "Upload");
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 /**
  * Return the FieldSet used to edit a dynamic template in the CMS.
  */
 function getCMSFields()
 {
     // // delete files button
     // if( $this->canEdit() ) {
     // 	$deleteButton = new InlineFormAction('deletemarked',_t('Folder.DELSELECTED','Delete selected files'), 'delete');
     // 	$deleteButton->includeDefaultJS(false);
     // } else {
     // 	$deleteButton = new HiddenField('deletemarked');
     // }
     // link file button
     if ($this->canEdit()) {
         $fileButtons = new CompositeField($linkFileButton = new InlineFormAction('linkfile', _t('DynamicTemplate.LINKFILE', 'Link file(s) from theme'), 'link'), $copyFileButton = new InlineFormAction('copyfile', _t('DynamicTemplate.COPYFILE', 'Copy file(s) from theme'), 'copy'), $newFileButton = new InlineFormAction('newfile', _t('DynamicTemplate.NEWFILE', 'New file'), 'newfile'));
         $linkFileButton->includeDefaultJS(false);
         $copyFileButton->includeDefaultJS(false);
         $newFileButton->includeDefaultJS(false);
     } else {
         $fileButtons = new HiddenField('linkfile');
     }
     $propButtons = new CompositeField();
     //		$propButtons->push($exportButton = new InlineFormAction('exporttemplate', _t('DynamicTemplate.EXPORTTEMPLATE', 'Export'), 'export'));
     //		$exportButton->includeDefaultJS(false);
     //		if ($this->canEdit()) {
     //			$propButtons->push($saveButton = new InlineFormAction('savetemplate', _t('DynamicTemplate.SAVETEMPLATE', 'Save'), 'save'));
     //			$saveButton->includeDefaultJS(false);
     //		}
     if (DynamicTemplateAdmin::tarball_available()) {
         $exportTarballButton = new InlineFormAction('exportastarball', _t('DynamicTemplate.EXPORT', 'Export as tarball'), 'exportastarball');
         $exportTarballButton->includeDefaultJS(false);
         $propButtons->push($exportTarballButton);
     }
     if (DynamicTemplateAdmin::zip_available()) {
         $exportZipButton = new InlineFormAction('exportaszip', _t('DynamicTemplate.EXPORT', 'Export as zip'), 'exportaszip');
         $exportZipButton->includeDefaultJS(false);
         $propButtons->push($exportZipButton);
     }
     //		$titleField = ($this->ID && $this->ID != "root") ? new TextField("Title", _t('Folder.TITLE', 'Title')) : new HiddenField("Title");
     $titleField = new TextField("Title", _t('Folder.TITLE', 'Title'));
     if (!$this->canEdit()) {
         $titleField->setReadOnly(true);
     }
     $nameField = new TextField("Name");
     if (!$this->canEdit()) {
         $titleField->setReadOnly(true);
     }
     $fields = new FieldList($rootTabSet = new TabSet("Root", new Tab("Properties", _t('DynamicTemplate.PROPERTIESTAB', 'Properties'), $titleField, new ReadonlyField("URL", _t('Folder.URL', 'URL')), new ReadonlyField("Created", _t('Folder.CREATED', 'First Uploaded')), new ReadonlyField("LastEdited", _t('Folder.LASTEDITED', 'Last Updated')), new HiddenField("ID"), new HiddenField("ClassName", null, "DynamicTemplate"), $propButtons), new Tab("Upload", _t('Folder.UPLOADTAB', "Upload"), new LabelField('UploadPrompt', _t('DynamicTemplate.UPLOADPROMPT', 'Upload files to your template. Uploads will automatically be added to the right place.')), $this->getUploadField())));
     // A DT can only have files if it has been saved at least once. This is also to avoid time out issue where DynamicTemplatesFileField::calc_tree
     // tries to find files from a DT with ID=0
     if ($this->ID) {
         $fileList = new DynamicTemplateFilesField("Files", "Files", $this);
         $rootTabSet->push(new Tab("Files", _t('Folder.FILESTAB', "Files"), $fileList, $fileButtons, new HiddenField("FileIDs"), new HiddenField("DestFolderID")));
     }
     if (!$this->canEdit()) {
         $fields->removeFieldFromTab("Root", "Upload");
     }
     $this->extend('updateCMSFields', $fields);
     Session::set("dynamictemplates_currentID", $this->ID);
     return $fields;
 }