ENHANCEMENT Added possibility of search for images and flash before inserting into the content editor in CMS

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@65820 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2008-11-13 04:55:23 +00:00
parent 5b80a0c1d1
commit c5241fa487
18 changed files with 98 additions and 56 deletions

View File

@ -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 .= '<ul>';
@ -59,11 +70,11 @@ class ThumbnailStripField extends FormField {
$width = $image->Width;
$height = $image->Height;
if($width > 600) {
$height *= (600/$width);
$height *= (600 / $width);
$width = 600;
}
if($height > 600) {
$width *= (600/$height);
$width *= (600 / $height);
$height = 600;
}
@ -76,25 +87,42 @@ class ThumbnailStripField extends FormField {
}
$result .= '</ul>';
} else {
$result = '<h2>' . _t('ThumbnailStripField.NOIMAGESFOUND', 'No images found in') . ' ' . $folder->Title . '</h2>';
if($folder) {
$result = '<h2>' . _t('ThumbnailStripField.NOFOLDERIMAGESFOUND', 'No images found in') . ' ' . $folder->Title . '</h2>';
} else {
$result = '<h2>' . _t('ThumbnailStripField.NOIMAGESFOUND', 'No images found') . '</h2>';
}
}
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 .= '<ul>';
foreach($flashObjects as $flashObject) {

View File

@ -187,7 +187,7 @@ window.onresize = function(init) {
if(navigator.appName == "Microsoft Internet Explorer") {
fitToParent('Image');
} else {
fitToParent('Image', 170);
fitToParent('Image', 190);
}
}
if($('Form_EditorToolbarFlashForm') && $('Form_EditorToolbarFlashForm').style.display == "block") {
@ -196,7 +196,7 @@ window.onresize = function(init) {
if(navigator.appName == "Microsoft Internet Explorer") {
fitToParent('Flash');
} else {
fitToParent('Flash', 80);
fitToParent('Flash', 100);
}
}

View File

@ -11,7 +11,7 @@ ThumbnailStripField.prototype = {
* in the PHP-constructor of ThumbnailStripField and is passed to the client
* as a fake css-class.
*/
updateMethod: "getimages",
updateMethod: 'getimages',
initialize: function() {
try {
@ -24,13 +24,30 @@ ThumbnailStripField.prototype = {
if(parentField) {
parentField.observeMethod('Change', this.ajaxGetFiles.bind(this));
}
var searchField = $$('#' + this.updateMethod + 'Search input')[0];
var timeout = undefined;
if(searchField) {
Event.observe(searchField, 'keypress', function(event) {
if(timeout != undefined) clearTimeout(timeout);
timeout = setTimeout(function() {
var searchText = searchField.value;
$('Image').ajaxGetFiles(null, searchText);
}, 500);
});
}
}
},
ajaxGetFiles: function(folderID,callback) {
ajaxGetFiles: function(folderID, searchText, callback) {
if(!callback) callback = this.reapplyBehaviour.bind(this);
this.innerHTML = '<span style="float: left">Loading...</span>'
var ajaxURL = this.helperURLBase() + '&methodName='+this.updateMethod+'&folderID=' + folderID + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '') + '&cacheKillerDate=' + parseInt((new Date()).getTime()) + '&cacheKillerRand=' + parseInt(10000*Math.random());
var securityID = ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
this.innerHTML = '<h2>Loading...</h2>';
var ajaxURL = this.helperURLBase() + '&methodName=' + this.updateMethod + '&folderID=' + folderID + '&searchText=' + searchText + securityID + '&cacheKillerDate=' + parseInt((new Date()).getTime()) + '&cacheKillerRand=' + parseInt(10000 * Math.random());
new Ajax.Updater(this, ajaxURL, {
method : 'get',
onComplete : callback,
@ -43,9 +60,11 @@ ThumbnailStripField.prototype = {
},
helperURLBase: function() {
var fieldName = this.id; //this.id.replace(this.ownerForm().name + '_','');
var fieldName = this.id;
var ownerForm = this.ownerForm();
var securityID = ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
return this.ownerForm().action + '&action_callfieldmethod=1&fieldName=' + fieldName + '&ajax=1' + ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
return ownerForm.action + '?action_callfieldmethod=1&fieldName=' + fieldName + '&ajax=1' + securityID;
},
ownerForm: function() {

View File

@ -140,9 +140,9 @@ TinyMCEImageEnhancement.prototype = {
if(navigator.appVersion.indexOf("Mac") != -1 || navigator.appVersion.indexOf("X11") != -1 || navigator.appVersion.indexOf("Linux") != -1) {
pv = getFlashPlayerVersion();
if(pv.major < 9 || (pv.major == 9 && pv.minor == 0 && pv.rev < 64)) {
if($('AddFolderGroup')) $('AddFolderGroup').style.display = 'none';
if($('PipeSeparator')) $('PipeSeparator').style.display = 'none';
if($('UploadGroup')) $('UploadGroup').style.display = 'none';
if($('AddFolderGroup')) $('AddFolderGroup').style.display = 'none';
if($('PipeSeparator')) $('PipeSeparator').style.display = 'none';
if($('UploadGroup')) $('UploadGroup').style.display = 'none';
return;
}
}
@ -183,7 +183,7 @@ TinyMCEImageEnhancement.prototype = {
$('UploadFiles').innerHTML = "upload";
statusMessage('Uploaded ' + this.upload.getFilesUploaded() + ' files','good');
if(this.getParentID() != 'root') {
$('Image').ajaxGetFiles(this.getParentID(),this.insertImages.bind(this));
$('Image').ajaxGetFiles(this.getParentID(), null, this.insertImages.bind(this));
}
},
@ -192,24 +192,19 @@ TinyMCEImageEnhancement.prototype = {
*
* @param transport object
*/
insertImages: function(transport) {
//HACK FOR STRANGE ERROR OCCURING UNDER SAFARI
if(transport.responseText == '') {
$('Image').ajaxGetFiles(this.getParentID(),this.insertImages.bind(this));
$('Image').ajaxGetFiles(this.getParentID(), null, this.insertImages.bind(this));
return;
}
//END OF HACK
$('Image').reapplyBehaviour();
this.addToTinyMCE = this.addToTinyMCE.bind(this);
/* Don't insert images for now - this inserts the wrong image as images are now sorted by filename rather than date uploaded.
var childNodes = $('Image').childNodes[0].childNodes;
var newImages = $A(childNodes).slice(childNodes.length - this.filesUploaded);
newImages.each(function(item) {
tinyMCEImageEnhancement.addToTinyMCE(item.childNodes[0]);
});
*/
this.processInProgress = false;
this.processInProgress = false;
},
/**

View File

@ -353,7 +353,7 @@ $lang['bg_BG']['StaticExporter']['FOLDEREXPORT'] = 'Папка към която
$lang['bg_BG']['StaticExporter']['NAME'] = 'Статичен експортър';
$lang['bg_BG']['StaticExporter']['ONETHATEXISTS'] = 'Моля укажете съществуваща папка';
$lang['bg_BG']['TaskList.ss']['BY'] = 'от';
$lang['bg_BG']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Не са намерени никакви изображения';
$lang['bg_BG']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Не са намерени никакви изображения';
$lang['bg_BG']['ThumbnailStripField']['NOTAFOLDER'] = 'Това не е папка';
$lang['bg_BG']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Избери папка по-горе)';
$lang['bg_BG']['ViewArchivedEmail.ss']['CANACCESS'] = 'Можете да влезнете в архивирания сайт чрез тази препратка:';

View File

@ -348,7 +348,7 @@ $lang['da_DK']['StaticExporter']['FOLDEREXPORT'] = 'Mappe der skal eksporteres t
$lang['da_DK']['StaticExporter']['NAME'] = 'Statisk eksporter';
$lang['da_DK']['StaticExporter']['ONETHATEXISTS'] = 'Specificer en mappe der findes';
$lang['da_DK']['TaskList.ss']['BY'] = 'af';
$lang['da_DK']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Ingen billeder fundet i';
$lang['da_DK']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Ingen billeder fundet i';
$lang['da_DK']['ThumbnailStripField']['NOTAFOLDER'] = 'Dette er ikke en mappe';
$lang['da_DK']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = 'Vælg en mappe ovenover';
$lang['da_DK']['ViewArchivedEmail.ss']['CANACCESS'] = 'Du kan tilgå¨den arkiverede side på dette link:';

View File

@ -380,7 +380,7 @@ $lang['de_DE']['StaticExporter']['FOLDEREXPORT'] = 'Ordner zum exportieren';
$lang['de_DE']['StaticExporter']['NAME'] = 'statischer Exporter';
$lang['de_DE']['StaticExporter']['ONETHATEXISTS'] = 'Bitte geben Sie einen vorhandenen Ordner an';
$lang['de_DE']['TaskList.ss']['BY'] = 'von';
$lang['de_DE']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Keine Bilder gefunden in';
$lang['de_DE']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Keine Bilder gefunden in';
$lang['de_DE']['ThumbnailStripField']['NOTAFOLDER'] = 'Dies ist kein Ordner';
$lang['de_DE']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(wählen Sie eine der obigen Ordner)';
$lang['de_DE']['ViewArchivedEmail.ss']['CANACCESS'] = 'Sie können unter folgendem Verweis auf die archivierte Seite zugreifen:';

View File

@ -496,7 +496,7 @@ $lang['en_US']['TableListField_PageControls.ss']['VIEWLAST'] = 'View last';
$lang['en_US']['TableListField_PageControls.ss']['VIEWNEXT'] = 'View next';
$lang['en_US']['TableListField_PageControls.ss']['VIEWPREVIOUS'] = 'View previous';
$lang['en_US']['TaskList.ss']['BY'] = 'by';
$lang['en_US']['ThumbnailStripField']['NOIMAGESFOUND'] = 'No images found in';
$lang['en_US']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'No images found in';
$lang['en_US']['ThumbnailStripField']['NOTAFOLDER'] = 'This is not a folder';
$lang['en_US']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Choose a folder above)';
$lang['en_US']['ViewArchivedEmail.ss']['CANACCESS'] = 'You can access the archived site at this link:';

View File

@ -353,7 +353,7 @@ $lang['es_ES']['StaticExporter']['FOLDEREXPORT'] = 'Carpeta a exportar';
$lang['es_ES']['StaticExporter']['NAME'] = 'Exportador estático';
$lang['es_ES']['StaticExporter']['ONETHATEXISTS'] = 'Por favor especifique una carpeta que exista';
$lang['es_ES']['TaskList.ss']['BY'] = 'por';
$lang['es_ES']['ThumbnailStripField']['NOIMAGESFOUND'] = 'No se han encontrado imágenes';
$lang['es_ES']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'No se han encontrado imágenes';
$lang['es_ES']['ThumbnailStripField']['NOTAFOLDER'] = 'Esto no es una carpeta';
$lang['es_ES']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Elija una carpeta a continuación)';
$lang['es_ES']['ViewArchivedEmail.ss']['CANACCESS'] = 'Puede acceder al sitio archivado con este enlace:';

View File

@ -341,7 +341,7 @@ $lang['fi_FI']['StaticExporter']['FOLDEREXPORT'] = 'Kansio, jonne viedään:';
$lang['fi_FI']['StaticExporter']['NAME'] = 'Staattinen viejä';
$lang['fi_FI']['StaticExporter']['ONETHATEXISTS'] = 'Anna olemassaoleva kansio';
$lang['fi_FI']['TaskList.ss']['BY'] = 'henkilöltä';
$lang['fi_FI']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Kuvia ei löytynyt kohteesta ';
$lang['fi_FI']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Kuvia ei löytynyt kohteesta ';
$lang['fi_FI']['ThumbnailStripField']['NOTAFOLDER'] = 'Tämä ei ole kansio';
$lang['fi_FI']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Valitse yllä kansio)';
$lang['fi_FI']['ViewArchivedEmail.ss']['CANACCESS'] = 'Pääset arkistoidulle sivulle tällä linkillä:';

View File

@ -353,7 +353,7 @@ $lang['fr_FR']['StaticExporter']['FOLDEREXPORT'] = 'Dossier à exporter vers';
$lang['fr_FR']['StaticExporter']['NAME'] = 'Exportation Statique';
$lang['fr_FR']['StaticExporter']['ONETHATEXISTS'] = 'Spécifier un dossier qui existe s\'il vous plaît';
$lang['fr_FR']['TaskList.ss']['BY'] = 'par';
$lang['fr_FR']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Aucune image trouvée dans';
$lang['fr_FR']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Aucune image trouvée dans';
$lang['fr_FR']['ThumbnailStripField']['NOTAFOLDER'] = 'Ce n\'est pas un dossier';
$lang['fr_FR']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Choisir un dossier ci-dessus)';
$lang['fr_FR']['ViewArchivedEmail.ss']['CANACCESS'] = 'Vous pouvez accéder le site archivé par ce lien :';

View File

@ -321,7 +321,7 @@ $lang['it_IT']['StaticExporter']['FOLDEREXPORT'] = 'Cartella dove esportare';
$lang['it_IT']['StaticExporter']['NAME'] = 'Sistema di esportazione statico';
$lang['it_IT']['StaticExporter']['ONETHATEXISTS'] = 'Per favore specifica una cartella esistente';
$lang['it_IT']['TaskList.ss']['BY'] = 'da';
$lang['it_IT']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Nessuna immagine trovata in';
$lang['it_IT']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Nessuna immagine trovata in';
$lang['it_IT']['ThumbnailStripField']['NOTAFOLDER'] = 'Questa non è una cartella';
$lang['it_IT']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Scegli una cartella qui sopra)';
$lang['it_IT']['ViewArchivedEmail.ss']['CANACCESS'] = 'Puoi accedere al sito archiviato da questo indirizzo:';

View File

@ -353,7 +353,7 @@ $lang['nl_NL']['StaticExporter']['FOLDEREXPORT'] = 'Map waarnaar geexporteerd di
$lang['nl_NL']['StaticExporter']['NAME'] = 'Statische export';
$lang['nl_NL']['StaticExporter']['ONETHATEXISTS'] = 'Geef een map op die bestaat';
$lang['nl_NL']['TaskList.ss']['BY'] = 'door';
$lang['nl_NL']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Geen afbeeldingen gevonden in';
$lang['nl_NL']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Geen afbeeldingen gevonden in';
$lang['nl_NL']['ThumbnailStripField']['NOTAFOLDER'] = 'Dit is geen map';
$lang['nl_NL']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Kies een map hierboven)';
$lang['nl_NL']['ViewArchivedEmail.ss']['CANACCESS'] = 'U kunt de gearchiveerde site bekijken via deze link:';

View File

@ -353,7 +353,7 @@ $lang['pl_PL']['StaticExporter']['FOLDEREXPORT'] = 'Folder przeniesiony do';
$lang['pl_PL']['StaticExporter']['NAME'] = 'Statyczny eksport';
$lang['pl_PL']['StaticExporter']['ONETHATEXISTS'] = 'Proszę wybierz dostępny folder';
$lang['pl_PL']['TaskList.ss']['BY'] = 'przez';
$lang['pl_PL']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Nie znaleziono obrazków w';
$lang['pl_PL']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Nie znaleziono obrazków w';
$lang['pl_PL']['ThumbnailStripField']['NOTAFOLDER'] = 'To nie jest folder';
$lang['pl_PL']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Wybierz powyższy folder)
';

View File

@ -321,7 +321,7 @@ $lang['pt_PT']['StaticExporter']['FOLDEREXPORT'] = 'Pasta para onde exportar';
$lang['pt_PT']['StaticExporter']['NAME'] = 'Exportador estático';
$lang['pt_PT']['StaticExporter']['ONETHATEXISTS'] = 'Por favor, especifique uma pasta existente';
$lang['pt_PT']['TaskList.ss']['BY'] = 'por';
$lang['pt_PT']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Imagens não encontradas em';
$lang['pt_PT']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Imagens não encontradas em';
$lang['pt_PT']['ThumbnailStripField']['NOTAFOLDER'] = 'Não é uma pasta';
$lang['pt_PT']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Escolha uma pasta acima)';
$lang['pt_PT']['ViewArchivedEmail.ss']['CANACCESS'] = 'Pode aceder ao site arquivado através deste link:';

View File

@ -353,7 +353,7 @@ $lang['ru_RU']['StaticExporter']['FOLDEREXPORT'] = 'Папка для экспо
$lang['ru_RU']['StaticExporter']['NAME'] = 'Статический экспорт';
$lang['ru_RU']['StaticExporter']['ONETHATEXISTS'] = 'Пожалуйста, укажите существующую папку';
$lang['ru_RU']['TaskList.ss']['BY'] = '-';
$lang['ru_RU']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Не найдено изображений в';
$lang['ru_RU']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Не найдено изображений в';
$lang['ru_RU']['ThumbnailStripField']['NOTAFOLDER'] = 'Это не папка';
$lang['ru_RU']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Выберите выше папку)';
$lang['ru_RU']['ViewArchivedEmail.ss']['CANACCESS'] = 'Вы можете посмотреть архивную версию сайта по этой ссылке:';

View File

@ -370,7 +370,7 @@ $lang['tr_TR']['StaticExporter']['FOLDEREXPORT'] = 'Kaydedilecek klasör';
$lang['tr_TR']['StaticExporter']['NAME'] = 'Statik Dosya Olarak Dışa Aktarma';
$lang['tr_TR']['StaticExporter']['ONETHATEXISTS'] = 'Lütfen geçerli bir klasör belirtiniz';
$lang['tr_TR']['TaskList.ss']['BY'] = 'tarafından';
$lang['tr_TR']['ThumbnailStripField']['NOIMAGESFOUND'] = 'Resim bulunamadı:';
$lang['tr_TR']['ThumbnailStripField']['NOFOLDERIMAGESFOUND'] = 'Resim bulunamadı:';
$lang['tr_TR']['ThumbnailStripField']['NOTAFOLDER'] = 'Bu klasör geçerli değil';
$lang['tr_TR']['ThumbnailStripField.ss']['CHOOSEFOLDER'] = '(Yukarıdan bir klasör seçiniz)';
$lang['tr_TR']['ViewArchivedEmail.ss']['CANACCESS'] = 'Arşivdeki siteye şu bağlantıdan erişebilirsiniz:';

View File

@ -1,3 +1,3 @@
<div id="$Name" class="thumbnailstrip parent=$ParentField updatemethod=$updateMethod">
<span style="float: left"><% _t('CHOOSEFOLDER','(Choose a folder above)') %></span>
<h2><% _t('CHOOSEFOLDER','(Choose a folder or search above)') %></h2>
</div>