2011-03-23 00:25:02 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2011-03-22 10:47:26 +01:00
|
|
|
* @package cms
|
2011-03-23 00:25:02 +01:00
|
|
|
* @subpackage filesystem
|
|
|
|
*/
|
|
|
|
class Folder_UnusedAssetsField extends CompositeField {
|
|
|
|
protected $folder;
|
|
|
|
|
|
|
|
public function __construct($folder) {
|
|
|
|
$this->folder = $folder;
|
2011-10-26 07:35:51 +02:00
|
|
|
parent::__construct(new FieldList());
|
2011-03-23 00:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getChildren() {
|
|
|
|
if($this->children->Count() == 0) {
|
|
|
|
$inlineFormAction = new InlineFormAction("delete_unused_thumbnails", _t('Folder.DELETEUNUSEDTHUMBNAILS', 'Delete unused thumbnails'));
|
|
|
|
$inlineFormAction->includeDefaultJS(false) ;
|
|
|
|
|
2011-10-26 07:35:51 +02:00
|
|
|
$this->children = new FieldList(
|
2011-03-23 00:25:02 +01:00
|
|
|
new LiteralField( "UnusedAssets", "<h2>"._t('Folder.UNUSEDFILESTITLE', 'Unused files')."</h2>" ),
|
|
|
|
$this->getAssetList(),
|
|
|
|
new FieldGroup(
|
|
|
|
new LiteralField( "UnusedThumbnails", "<h2>"._t('Folder.UNUSEDTHUMBNAILSTITLE', 'Unused thumbnails')."</h2>"),
|
|
|
|
$inlineFormAction
|
|
|
|
)
|
|
|
|
);
|
|
|
|
$this->children->setForm($this->form);
|
|
|
|
}
|
|
|
|
return $this->children;
|
|
|
|
}
|
|
|
|
|
2012-04-11 08:09:11 +02:00
|
|
|
public function FieldHolder($properties = array()) {
|
2011-03-23 00:25:02 +01:00
|
|
|
$output = "";
|
|
|
|
foreach($this->getChildren() as $child) {
|
|
|
|
$output .= $child->FieldHolder();
|
|
|
|
}
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates table for displaying unused files.
|
|
|
|
*
|
2012-02-14 22:03:09 +01:00
|
|
|
* @return GridField
|
2011-03-23 00:25:02 +01:00
|
|
|
*/
|
|
|
|
protected function getAssetList() {
|
|
|
|
$where = $this->folder->getUnusedFilesListFilter();
|
2012-02-14 22:03:09 +01:00
|
|
|
$files = DataList::create('File')->where($where);
|
|
|
|
$field = new GridField('AssetList', false, $files);
|
|
|
|
return $field;
|
2011-03-23 00:25:02 +01:00
|
|
|
}
|
|
|
|
}
|