2012-01-09 17:32:27 +01:00
|
|
|
<?php
|
|
|
|
class CMSFileAddController extends AssetAdmin {
|
|
|
|
|
|
|
|
static $url_segment = 'assets/add';
|
|
|
|
static $url_priority = 60;
|
2012-03-05 16:07:53 +01:00
|
|
|
static $required_permission_codes = 'CMS_ACCESS_AssetAdmin';
|
2012-01-09 17:32:27 +01:00
|
|
|
|
2012-02-03 00:11:11 +01:00
|
|
|
// public function upload($request) {
|
|
|
|
// $formHtml = $this->renderWith(array('AssetAdmin_UploadContent'));
|
|
|
|
// if($this->isAjax()) {
|
|
|
|
// return $formHtml;
|
|
|
|
// } else {
|
|
|
|
// return $this->customise(array(
|
|
|
|
// 'Content' => $formHtml
|
|
|
|
// ))->renderWith(array('AssetAdmin', 'LeftAndMain'));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Form
|
|
|
|
* @todo what template is used here? AssetAdmin_UploadContent.ss doesn't seem to be used anymore
|
|
|
|
*/
|
2012-02-10 23:15:41 +01:00
|
|
|
public function getEditForm($id = null, $fields = null) {
|
2012-02-03 00:11:11 +01:00
|
|
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/AssetUploadField.js');
|
|
|
|
Requirements::css(SAPPHIRE_DIR . '/css/AssetUploadField.css');
|
|
|
|
|
2012-02-21 21:17:56 +01:00
|
|
|
$folder = $this->currentPage();
|
|
|
|
|
2012-02-03 00:11:11 +01:00
|
|
|
$uploadField = Object::create('UploadField', 'AssetUploadField', '');
|
|
|
|
$uploadField->setConfig('previewMaxWidth', 40);
|
|
|
|
$uploadField->setConfig('previewMaxHeight', 30);
|
|
|
|
$uploadField->addExtraClass('ss-assetuploadfield');
|
|
|
|
$uploadField->removeExtraClass('ss-uploadfield');
|
|
|
|
$uploadField->setTemplate('AssetUploadField');
|
2012-02-21 21:17:56 +01:00
|
|
|
if ($folder->exists() && $folder->getFilename()) {
|
2012-03-02 15:43:22 +01:00
|
|
|
// The Upload class expects a folder relative *within* assets/
|
|
|
|
$path = preg_replace('/^' . ASSETS_DIR . '\//', '', $folder->getFilename());
|
|
|
|
$uploadField->setFolderName($path);
|
2012-02-03 00:11:11 +01:00
|
|
|
}
|
|
|
|
|
2012-03-02 15:43:22 +01:00
|
|
|
$form = new Form(
|
|
|
|
$this,
|
|
|
|
'getEditForm',
|
|
|
|
new FieldList($uploadField, new HiddenField('ID')),
|
|
|
|
new FieldList()
|
|
|
|
);
|
2012-02-15 19:35:11 +01:00
|
|
|
$form->addExtraClass('center cms-edit-form ' . $this->BaseCSSClasses());
|
2012-01-09 17:32:27 +01:00
|
|
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
2012-02-21 21:17:56 +01:00
|
|
|
$form->Fields()->push(
|
|
|
|
new LiteralField(
|
|
|
|
'BackLink',
|
|
|
|
sprintf(
|
|
|
|
'<a href="%s" class="backlink ss-ui-button cms-panel-link" data-icon="back">%s</a>',
|
|
|
|
Controller::join_links(singleton('AssetAdmin')->Link('show'), $folder ? $folder->ID : 0),
|
|
|
|
_t('AssetAdmin.BackToFolder', 'Back to folder')
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2012-03-02 15:43:22 +01:00
|
|
|
$form->loadDataFrom($folder);
|
2012-02-21 21:17:56 +01:00
|
|
|
|
2012-01-09 17:32:27 +01:00
|
|
|
return $form;
|
|
|
|
}
|
|
|
|
|
2012-02-15 19:35:11 +01:00
|
|
|
function Tools() {
|
|
|
|
return false;
|
|
|
|
}
|
2012-01-09 17:32:27 +01:00
|
|
|
|
|
|
|
}
|