ENHANCEMENT #3920: Alllow searching within subfolders in Files and Images section

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@75228 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-04-27 05:15:11 +00:00
parent ef15f1a3a6
commit 89d57e89d8

View File

@ -317,7 +317,7 @@ class Folder extends File {
$this,
"Files",
"File",
array("Title" => _t('Folder.TITLE', "Title"), "LinkedURL" => _t('Folder.FILENAME', "Filename")),
array("Title" => _t('Folder.TITLE', "Title"), "Filename" => _t('Folder.FILENAME', "Filename")),
""
);
$fileList->setFolder($this);
@ -331,9 +331,6 @@ class Folder extends File {
$deleteButton = new HiddenField('deletemarked');
}
$inlineFormAction = new InlineFormAction("delete_unused_thumbnails", _t('Folder.DELETEUNUSEDTHUMBNAILS', 'Delete unused thumbnails'));
$inlineFormAction->includeDefaultJS(false) ;
$fields = new FieldSet(
new HiddenField("Title"),
new TabSet("Root",
@ -356,12 +353,7 @@ class Folder extends File {
)
),
new Tab("UnusedFiles", _t('Folder.UNUSEDFILESTAB', "Unused files"),
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
)
new Folder_UnusedAssetsField($this)
)
),
new HiddenField("ID")
@ -372,34 +364,12 @@ class Folder extends File {
return $fields;
}
/**
* Creates table for displaying unused files.
*
* @returns AssetTableField
*/
protected function getAssetList() {
$where = $this->getUsedFilesList();
$assetList = new AssetTableField(
$this,
"AssetList",
"File",
array("Title" => _t('Folder.TITLE', "Title"), "LinkedURL" => _t('Folder.FILENAME', "Filename")),
"",
$where
);
$assetList->setPopupCaption(_t('Folder.VIEWASSET', "View Asset"));
$assetList->setPermissions(array("show","delete"));
$assetList->Markable = false;
return $assetList;
}
/**
* Looks for files used in system and create where clause which contains all ID's of files.
*
* @returns String where clause which will work as filter.
*/
protected function getUsedFilesList() {
public function getUsedFilesList() {
$result = DB::query("SELECT DISTINCT FileID FROM SiteTree_ImageTracking");
$usedFiles = array();
$where = "";
@ -447,4 +417,62 @@ HTML;
}
class Folder_UnusedAssetsField extends CompositeField {
protected $folder;
public function __construct($folder) {
$this->folder = $folder;
parent::__construct(new FieldSet());
}
public function getChildren() {
if($this->children->Count() == 0) {
$inlineFormAction = new InlineFormAction("delete_unused_thumbnails", _t('Folder.DELETEUNUSEDTHUMBNAILS', 'Delete unused thumbnails'));
$inlineFormAction->includeDefaultJS(false) ;
$this->children = new FieldSet(
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;
}
public function FieldHolder() {
$output = "";
foreach($this->getChildren() as $child) {
$output .= $child->FieldHolder();
}
return $output;
}
/**
* Creates table for displaying unused files.
*
* @returns AssetTableField
*/
protected function getAssetList() {
$where = $this->folder->getUsedFilesList();
$assetList = new AssetTableField(
$this->folder,
"AssetList",
"File",
array("Title" => _t('Folder.TITLE', "Title"), "LinkedURL" => _t('Folder.FILENAME', "Filename")),
"",
$where
);
$assetList->setPopupCaption(_t('Folder.VIEWASSET', "View Asset"));
$assetList->setPermissions(array("show","delete"));
$assetList->Markable = false;
return $assetList;
}
}
?>