unclecheese / kickassets Goto Github PK
View Code? Open in Web Editor NEWThe KickAssets module for SilverStripe is an alternative to AssetAdmin
Home Page: http://www.leftandmain.com
The KickAssets module for SilverStripe is an alternative to AssetAdmin
Home Page: http://www.leftandmain.com
If there is a FileAttachmentField in ModelAdmin the detach method won't work as expected. You will need to click detach & save twice as in "Detach => ID=0 => Save => Image reappears=> Detach => Save => Image detached".
This seems to be only the case in ModelAdmin.
I've traced the problem to FileAttachmentField->setValue().
https://github.com/unclecheese/KickAssets/blob/master/code/FileAttachmentField.php#L35
// if button detach clicked then ID = 0, so this condition fails if($id = Controller::curr()->getRequest()->requestVar($this->Name()."ID")) { $value = $id; } // in ModelAdmin: the old DataObject will overwrite the currently detached file elseif(!$value && $data && $data instanceof DataObject && $data->hasMethod($this->name)) { $funcName = $this->name; if($obj = $data->$funcName()) { if($obj instanceof File) { $value = $obj->ID; } } }
My fix is to check requestVars with isset():
$requests = Controller::curr()->getRequest()->requestVars(); if( isset($requests[$this->Name()."ID"])) { $value = $requests[$this->Name()."ID"]; } elseif(!$value && $data && $data instanceof DataObject && $data->hasMethod($this->name)) { $funcName = $this->name; if($obj = $data->$funcName()) { if($obj instanceof File) { $value = $obj->ID; } } }
When I set a folder for an upload field then everything works a treat, EXCEPT, if I browse to another folder to select a file then it does not work (it seems it is attached, but on saving the attachment is disconnected).
there are several HTMLEditorField alternatives included in DOM to work with the popup.
unfortunately all of them break once you add a FileAttachmentField to the popup.
More a feature request than a bug:
For the same image it is not possible the have individual titles (or ALT text) on each page. Especially for translations this would be important (accessibility and SEO).
long folder titles are unworkable because they end up with ... in the middle, making them unreadable
A double click on a file slides in the right sidebar to edit a file.
I believe the Edit button should do the same.
I tested on Win7, and from the following browsers only in IE the Edit button worked.
IE 9
IE 8
IE 7
Chrome 13.0.782.220
Firefox 6.0.2
Safari 5.1
Opera 11.51
The normal behavior of SS is to upload files to assets/Uploads. However kickassets seems to upload directly to assets if a default folder has not been set. And I cannot even see the Uploads folder in the interface. Is this intentional or a bug?
Note: Never mind, I found the new "Look for new files" button and that fixed it all up nice. Thanks.
I use setDefaultFolder on two FileAttachmentFields in the same DataObject. I pass the same folder path to each one. I expected that if the folder did not exists the 1st one would create the folder and the second one would use the folder created by the 1st one. However I find that each FileAttachmentField creates a new folder. KickAssetField uses Folder::findormake($folder); Which I have found to be very unsatisfactory in that it often will create duplicates of folders even when they exist already.
I have written my own version of FindOrMake that has a lot more logic and is much more robust. This class does make use of Folder::findormake($folder); but first does a lot more checking for an existing valid folder so it does not fail where the other function does.
Here is my utility class. Maybe it can be incorporated into Kickassets.
Title); else $Title = SiteTree::generateURLSegment($Title); $folderTitle = $Title; if ($AppendID) $folderTitle .= '_ID' . $CallerObject->ID; if (!$RootFolder) $RootFolder = 'assets'; if ($CallerObject->$FolderRef > 0) { $supposedFolder = DataObject::get_by_id("Folder", $CallerObject->$FolderRef); // If the ID exists, find if there is a folder in the database of that ID if ($supposedFolder && file_exists($_SERVER{'DOCUMENT_ROOT'} . "/" . $supposedFolder->Filename)) // Make sure the Folder exists in the file system. { $supposedFolder->Title = $folderTitle; $supposedFolder->setName($folderTitle); // If all is good so far make sure the Folder has the right name. $supposedFolder->write(); } else { // If the ID exists and the database knows about the Folder but for some reason it was deleted from the filesystem, // make a new folder and set the new ID $galleries = Folder::findOrMake($RootFolder); $galleries->Title = $RootFolder; $galleries->write(); $folder = Folder::findOrMake($RootFolder. "/" . $folderTitle); $folder->Title = $folderTitle; $folder->setName($folderTitle); $folder->write(); $CallerObject->$FolderRef = $folder->ID; $CallerObject->write(); } } else if( !$CallerObject->$FolderRef || $CallerObject->$FolderRef == 0) // If there is no folder anywhere then go ahead and make the dang thing. { $galleries = Folder::findOrMake($RootFolder); $galleries->Title = $RootFolder; $galleries->write(); $folder = Folder::findOrMake($RootFolder. "/" . $folderTitle); $folder->Title = $folderTitle; $folder->setName($folderTitle); $folder->write(); $CallerObject->$FolderRef = $folder->ID; $CallerObject->write(); } } ``` } ?>Uncle Cheese,
Do you have plans to add sortability to this field. I often want to attache a lot of images to an object or page and then need to sort them in the CMS to either select the 1st one as a primary image or to just set the order they display very specifically.
I can see how this might be difficult since I am trying to avoid special data objects to hold my images. But in this case there is a table in the database to manage the relationships so maybe it could just be code added to the onBefore Write of the Page or Object that the images are attached to? I might be able to figure out how to modify the form with jquery sortable and then just write some manual queries to put sort values into a sort column of the relationship table.
I have two or three installs now of kickassets(which is great) but:
When adding new folders and naming them the names dont appear in the drop down field for entering(and choosing) images to insert in the WYSYWYG area. The new folders just have a name of "new folder" in that drop down. But in the kick assests pop up and via FTP the folders show theier proper name.
I have already tried:
But none of the above solutions help. Any Ideas?
THanks in advance
KickAssets is not completely working on Internet Explorers. At least IE9 support would be great.
I'm currently using kick assets on a DataObject related to a page and the field itself works great. However trying to open the kick assets admin from there ends up looking really messy since the original popup window is already pretty small and kick assets admin needs to fit in the popup.
I'm not sure if there's a nice way around this but I just wanted to report it in. Everything else works great in the popup and I'm loving the drag&drop experience.
Umm I just downloaded the latest version and there's still an ampersand in there. The code looks like this:
if(version_compare(PHP_VERSION, '5.3')) {
$file->updateCMSFields(&$fields);
}
else {
$file->updateCMSFields($fields);
}
I'm running version 5.2.11 but I'm still getting an error related to this.
It's on line 600 in KickAssetAdmin.php.
I have read your comment on leftandmain.com and the prev issue on here about IE, but I still wish to bring up this topic again.
I think drag & drop support for IE is out of question, but with some quick changes we could show the IE users a normal uploadify field or even just a normal html form browse button.
Telling a user he has to use another browser is normally fine to me.
but sometimes you have clients that have no other choice then using IE, in that case you can at least tell them that it works in IE, but works way better in a proper browser.
first thing is that in IE if you open a folder, you get a error.
[Notice] Trying to get property of non-object
Problem is, the url is "admin/files/admin/files/browse/1" and not "admin/files/browse/1" as it should be.
simple fix: kickassets.js, Line 388
replace "window.location.href = $t.data('link');" with "window.location.href = '/'.$t.data('link');"
With that simple fix, a IE user can at least browse the files.
For the "upload some files" field I do the following:
seen on Chrome 13.0.782.220 / OSX Lion
I noticed that renaming a file or folder in KickAssetsAdmin changes the Name in the database but not the Title. This is a problem in the CMS when selecting a folder to insert an image from since the TinyMCE dropdown for selecting the image uses Title instead of Name. All the folders I created are listed as New-Folder still. I have fixed this by editing KickAssetAdmin.php.
public function updatefilename(SS_HTTPRequest $r) {
if($file = DataObject::get_by_id("File", (int) $r->requestVar('fileid'))) {
$file->setName($r->requestVar('new'));
$file->Title = $r->requestVar('new'); // This is the new line so that Title gets updated as well.
$file->write();
$template = $file instanceof Folder ? "Folder" : "File";
return $this->customise($this->getFields($file))->renderWith($template);
}
}
$file->setDefaultFolder('test');
this will create 'test', and store my files in test, but it also creates a folder named 'folder'.
If you use the search filter box to filter down the visible files based on filename, select them all and then delete them, all the files in the folder get deleted. This happens consistently in our testing and is too dangerous of a gotcha for general release to the CMS users.
A nice general feature to add would be some sort of spinner, or other notification that a async operation is in progress. Dragging and dropping large files doesn't seem to do anything because there is no acknowledgement that any action is being taken - it might be useful to have some area that shows actions happening in the background.
Thanks,
Steve
Having manually sorted the order of files appearing in the MultipleFileAttachmentField, adding a new file reverts the order back to alphabetical.
for some reason the file attachment field is uploading several times the same files. its seems that the drag behavior is triggering several times the upload action.
My install doesn't seem too happy with $file->updateCMSFields(&$fields);
Warning: Call-time pass-by-reference has been deprecated in /srv/www/htdocs/intranet/kickassets/code/KickAssetAdmin.php on line 567
Seems to popup everywhere
After creating the ManyManySort field manually everything seems to work as should.
[26-Feb-2012 05:37:33] Error at sapphire/core/model/MySQLDatabase.php line 525: Couldn't run query:
INSERT INTO "SomePage_MyFiles" ("SomePageID","FileID" , "ManyManySort") VALUES (16, 169 , '1')
Unknown column 'ManyManySort' in 'field list' (http://localhost:8888/ss/admin/EditForm)
[26-Feb-2012 05:39:06] Error at sapphire/core/model/MySQLDatabase.php line 525: Couldn't run query:
INSERT INTO "SomePage_MyFiles" ("SomePageID","FileID" , "ManyManySort") VALUES (16, 169 , '1')
Unknown column 'ManyManySort' in 'field list' (http://localhost:8888/ss/admin/EditForm)
Fix is to to change line 518 of BreadCrumbs() function in KickAssetAdmin.php to
$list = array_reverse($breadcrumbs, true);
passing true as the second argument causes the array keys to be preserved.
When you start silverstripe from a page that doesn't have any KickAssets fields included and then go to edit another page that does have a MultipleFileAttachmentField with the ManyManySortable extension enabled I get a javascript error; "Livequery is not a object". This is because the script manymanysortable.js is loading before livequery is loaded.
I'll submit a pull request shortly with a fix.
in the normal silverstripe Files & Images tab you can find 3 buttons, "Create", "Delete" and "Look for new files"Look for new files"
"SilverStripe maintains its own database of the files & images stored in your assets/ folder. Click this button to update that database, if files are added to the assets/ folder from outside SilverStripe, for example, if you have uploaded files via FTP."
for users uploading files via ftp this feature is required.
Hi,
If we have a file attachement field with a userdefinedform (eg. if you have added a FileAttachmentField to your Page.php..) the UserDefinedForm javascript is broken : can't open field options, can' add any new fields, etc.
Seems the problem is in the javascript for the dragndrop in the file_attachement_field.js file. it works If I remove the
$('.file_drop').livequery(dnd.ready());
It is almost impossible to delete folders, even if they are empty.
Latest master branch version. Steps to reproduce:
In the CMS, klick "Browse files...", choose any file and click "Delete".
The following error shows up in the JS console:
apprise is not defined (kickassets.js, line 413)
Steps to reproduce the bug:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.