From 454fabf53452dcc664fd45314ee8f2c5c548c055 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 13 Nov 2008 05:18:06 +0000 Subject: [PATCH] Merged in image search capabilities from trunk version - r65820, r65823 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@65824 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/ThumbnailStripField.php | 68 +++++++++++++++++++-------- javascript/LeftAndMain.js | 4 +- javascript/ThumbnailStripField.js | 31 +++++++++--- javascript/TinyMCEImageEnhancement.js | 23 ++++----- lang/bg_BG.php | 2 +- lang/da_DK.php | 2 +- lang/de_DE.php | 2 +- lang/en_US.php | 2 +- lang/es_ES.php | 2 +- lang/fi_FI.php | 2 +- lang/fr_FR.php | 2 +- lang/it_IT.php | 2 +- lang/nl_NL.php | 2 +- lang/pl_PL.php | 2 +- lang/pt_PT.php | 2 +- lang/ru_RU.php | 2 +- lang/tr_TR.php | 2 +- templates/ThumbnailStripField.ss | 2 +- 18 files changed, 98 insertions(+), 56 deletions(-) diff --git a/code/ThumbnailStripField.php b/code/ThumbnailStripField.php index deefd09b..5a7b619f 100755 --- a/code/ThumbnailStripField.php +++ b/code/ThumbnailStripField.php @@ -26,10 +26,6 @@ class ThumbnailStripField extends FormField { return $this->renderWith('ThumbnailStripField'); } - function Images() { - //return DataObject::get("Image", "Paretn); - } - function UpdateMethod() { return $this->updateMethod; } @@ -40,14 +36,29 @@ class ThumbnailStripField extends FormField { */ function getimages() { $result = ''; - $folder = DataObject::get_by_id('Folder', (int) $_GET['folderID']); + $images = null; + $whereSQL = ''; + $folderID = isset($_GET['folderID']) ? (int) $_GET['folderID'] : 0; + $searchText = (isset($_GET['searchText']) && $_GET['searchText'] != 'undefined' && $_GET['searchText'] != 'null') ? Convert::raw2sql($_GET['searchText']) : ''; - if(!$folder) return _t('ThumbnailStripField.NOTAFOLDER', 'This is not a folder'); + $folder = DataObject::get_by_id('Folder', (int) $_GET['folderID']); - $folderList = $folder->getDescendantIDList("Folder"); - array_unshift($folderList, $folder->ID); + if($folder) { + $folderList = $folder->getDescendantIDList('Folder'); + array_unshift($folderList, $folder->ID); + + $whereSQL = 'ParentID IN (' . implode(', ', $folderList) . ')'; + if($searchText) $whereSQL .= " AND Filename LIKE '%$searchText%'"; - $images = DataObject::get('Image', 'ParentID IN (' . implode(', ', $folderList) . ')', 'Title'); + $images = DataObject::get('Image', $whereSQL, 'Title'); + + } else { + if($searchText) { + $whereSQL = "Filename LIKE '%$searchText%'"; + + $images = DataObject::get('Image', $whereSQL, 'Title'); + } + } if($images) { $result .= ''; } else { - $result = '

' . _t('ThumbnailStripField.NOIMAGESFOUND', 'No images found in') . ' ' . $folder->Title . '

'; + if($folder) { + $result = '

' . _t('ThumbnailStripField.NOFOLDERIMAGESFOUND', 'No images found in') . ' ' . $folder->Title . '

'; + } else { + $result = '

' . _t('ThumbnailStripField.NOIMAGESFOUND', 'No images found') . '

'; + } } return $result; } function getflash() { - $folder = DataObject::get_by_id("Folder", (int) $_GET['folderID']); - - if(!$folder) return _t('ThumbnailStripField.NOTAFOLDER', 'This is not a folder'); - - $folderList = $folder->getDescendantIDList('Folder'); - array_unshift($folderList, $folder->ID); + $flashObjects = null; + $result = ''; + $whereSQL = ''; + $folderID = isset($_GET['folderID']) ? (int) $_GET['folderID'] : 0; + $searchText = (isset($_GET['searchText']) && $_GET['searchText'] != 'undefined' && $_GET['searchText'] != 'null') ? Convert::raw2sql($_GET['searchText']) : ''; $width = Image::$strip_thumbnail_width - 10; $height = Image::$strip_thumbnail_height - 10; - $flashObjects = DataObject::get("File", "ParentID IN (" . implode(', ', $folderList) . ") AND Filename LIKE '%.swf'"); - $result = ''; + $folder = DataObject::get_by_id("Folder", (int) $_GET['folderID']); + + if($folder) { + $folderList = $folder->getDescendantIDList('Folder'); + array_unshift($folderList, $folder->ID); + + $whereSQL = "ParentID IN (" . implode(', ', $folderList) . ") AND Filename LIKE '%.swf'"; + if($searchText) $whereSQL .= " AND Filename LIKE '%$searchText%'"; + + $flashObjects = DataObject::get('File', $whereSQL); + } else { + if($searchText) { + $flashObjects = DataObject::get('File', "Filename LIKE '%$searchText%'"); + } + } + if($flashObjects) { $result .= '