Skip to content

Commit

Permalink
Merge pull request #47 from chillu/gridfield-assetadmin
Browse files Browse the repository at this point in the history
Gridfield assetadmin
  • Loading branch information
sminnee committed Jan 9, 2012
2 parents e34f56d + 60129f6 commit d4e5e23
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
4 changes: 3 additions & 1 deletion _config.php
Expand Up @@ -9,6 +9,7 @@
'' => 'RootURLController', '' => 'RootURLController',
'admin/bulkload//$Action/$ID/$OtherID' => 'BulkLoaderAdmin', 'admin/bulkload//$Action/$ID/$OtherID' => 'BulkLoaderAdmin',
'admin/cms//$Action/$ID/$OtherID' => 'CMSMain', 'admin/cms//$Action/$ID/$OtherID' => 'CMSMain',
'admin/asset//$Action/$ID/$OtherID' => 'AssetAdmin',
'dev/buildcache/$Action' => 'RebuildStaticCacheTask', 'dev/buildcache/$Action' => 'RebuildStaticCacheTask',
)); ));


Expand All @@ -35,4 +36,5 @@
CMSMenu::remove_menu_item('CMSPageSettingsController'); CMSMenu::remove_menu_item('CMSPageSettingsController');
CMSMenu::remove_menu_item('CMSPageHistoryController'); CMSMenu::remove_menu_item('CMSPageHistoryController');
CMSMenu::remove_menu_item('CMSPageReportsController'); CMSMenu::remove_menu_item('CMSPageReportsController');
CMSMenu::remove_menu_item('CMSPageAddController'); CMSMenu::remove_menu_item('CMSPageAddController');
CMSMenu::remove_menu_item('CMSFileAddController');
35 changes: 35 additions & 0 deletions code/controllers/CMSFileAddController.php
@@ -0,0 +1,35 @@
<?php
class CMSFileAddController extends AssetAdmin {

static $url_segment = 'assets/add';

static $url_priority = 60;

function getEditForm() {
$form = new Form(
$this,
'Form',
new FieldList(
// TODO Replace with UploadField
new LiteralField("UploadIframe",$this->getUploadIframe())
),
new FieldList(
)
);
$form->addExtraClass('cms-content center cms-edit-form ' . $this->BaseCSSClasses());
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
return $form;
}


/**
* Display the upload form. Returns an iframe tag that will show admin/assets/uploadiframe.
*/
function getUploadIframe() {
return <<<HTML
<iframe name="AssetAdmin_upload" src="admin/assets/uploadiframe/{$this->ID}" id="AssetAdmin_upload" border="0" style="border-style none !important; width: 97%; min-height: 300px; height: 100%; height: expression(document.body.clientHeight) !important;">
</iframe>
HTML;
}

}
37 changes: 37 additions & 0 deletions templates/Includes/CMSFileAddController_Content.ss
@@ -0,0 +1,37 @@
<% with EditForm %>
<form $FormAttributes data-layout="{type: 'border'}">

<div class="cms-content-header north">
<div>
<h2><% _t('CMSAddPageController.Title','Add pages') %></h2>
</div>
</div>

<div class="cms-content-fields center cms-panel-content cms-panel-padded">

<% if Message %>
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
<% else %>
<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
<% end_if %>

<fieldset>
<% if Legend %><legend>$Legend</legend><% end_if %>
<% control Fields %>
$FieldHolder
<% end_control %>
</fieldset>
</div>

<div class="cms-content-actions south">
<% if Actions %>
<div class="Actions">
<% control Actions %>
$Field
<% end_control %>
</div>
<% end_if %>
</div>

</form>
<% end_with %>

0 comments on commit d4e5e23

Please sign in to comment.