FEATURE: Enable switch between legacy image search and new version (from r106178)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@112489 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-10-15 02:36:33 +00:00
parent 97778ba31c
commit c4b740f8c9

View File

@ -9,6 +9,15 @@
class ThumbnailStripField extends FormField {
protected $parentField;
protected $updateMethod;
protected static $use_legacy_image_search = false;
public static function set_use_legacy_image_search($enable) {
self::$use_legacy_image_search = $enable;
}
public static function get_use_legacy_image_search() {
return self::$use_legacy_image_search;
}
function __construct($name, $parentField, $updateMethod = "getimages") {
$this->parentField = $parentField;
@ -55,9 +64,13 @@ class ThumbnailStripField extends FormField {
$images = DataObject::get('Image', $whereSQL, 'Title');
} else {
$whereSQL = "\"ParentID\" = 0";
if (!self::$use_legacy_image_search) {
$whereSQL = "\"ParentID\" = 0 AND ";
} else {
$whereSQL = '';
}
if($searchText) {
$whereSQL .= " AND \"Filename\" LIKE '%$searchText%'";
$whereSQL .= " \"Filename\" LIKE '%$searchText%'";
}
$images = DataObject::get('Image', $whereSQL, 'Title');