ENHANCEMENT: Added manual Filesystem::sync() button to improve load time of admin/assets area.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@80783 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-07-01 22:28:06 +00:00
parent 4854dddc0d
commit 9bc3f5fe2a
5 changed files with 54 additions and 11 deletions

View File

@ -98,12 +98,6 @@ JS
);
}
function index() {
Filesystem::sync();
return array();
}
/**
* Show the content of the upload iframe. The form is specified by a template.
*/
@ -276,7 +270,7 @@ HTML;
} else {
$record = singleton("Folder");
}
if($record) {
$fields = $record->getCMSFields();
$actions = new FieldSet();
@ -437,7 +431,7 @@ JS;
public function SiteTreeAsUL() {
$obj = singleton('Folder');
$obj->setMarkingFilter('ClassName', ClassInfo::subclassesFor('Folder'));
$obj->markPartialTree();
$obj->markPartialTree(30, null, "ChildFolders");
if($p = $this->currentPage()) $obj->markToExpose($p);
@ -445,9 +439,10 @@ JS;
$siteTreeList = $obj->getChildrenAsUL(
'',
'"<li id=\"record-$child->ID\" class=\"$child->class" . $child->markingClasses() . ($extraArg->isCurrentPage($child) ? " current" : "") . "\">" . ' .
'"<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" class=\"" . ($child->hasChildren() ? " contents" : "") . "\" >" . $child->TreeTitle() . "</a>" ',
'"<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" class=\"" . ($child->hasChildFolders() ? " contents" : "") . "\" >" . $child->TreeTitle() . "</a>" ',
$this,
true
true,
"ChildFolders"
);
// Wrap the root if needs be

View File

@ -62,7 +62,7 @@ class AssetTableField extends ComplexTableField {
while($nextIDSet) {
// TO DO: In 2.4 this should be refactored to use the new data mapper.
$nextIDSet = DB::query("SELECT ID FROM `File` WHERE ParentID IN ("
$nextIDSet = DB::query("SELECT ID FROM \"File\" WHERE ParentID IN ("
. implode(", " , $nextIDSet) . ") AND ClassName IN ($folderClasses)")->column();
if($nextIDSet) $folderIDs = array_merge($folderIDs, $nextIDSet);
}

View File

@ -321,6 +321,35 @@ addfolder.prototype = {
}
}
/**
* Look for new files (FilesystemSync) action
*/
FilesystemSyncClass = Class.create();
FilesystemSyncClass.applyTo('#filesystemsync');
FilesystemSyncClass.prototype = {
initialize: function () {
this.getElementsByTagName('button')[0].onclick = returnFalse;
},
onclick : function() {
statusMessage('Looking for new files');
var options = {
method: 'get',
onSuccess: function(t) {
eval(t.responseText);
}
};
new Ajax.Request('dev/tasks/FilesystemSyncTask',{
onSuccess: function(t) {
statusMessage("I have finished looking for files", "good");
},
onFailure: function(t) {
errorMessage("There was an error looking for new files");
}
});
return false;
}
}
/**
* Delete folder action

View File

@ -0,0 +1,14 @@
<?php
class FilesystemSyncTask extends BuildTask {
protected $title = "Sync Files & Images assets";
protected $description = "The Files & Images system in SilverStripe maintains its own database
of the contents of the assets/ folder. This action will update that database, and
should be called whenever files are added to the assets/ folder from outside
SilverStripe, for example, if an author uploads files via FTP.";
function run($request) {
Filesystem::sync();
}
}

View File

@ -3,6 +3,11 @@
<ul id="TreeActions">
<li class="action" id="addpage"><button><% _t('CREATE','Create') %></button></li>
<li class="action" id="deletepage"><button><% _t('DELETE','Delete') %></button></li>
<li class="action" id="filesystemsync">
<button title="<% _t('FILESYSTEMSYNC_DESC', 'SilverStripe maintains its own database of the files &amp; 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.') %>">
<% _t('FILESYSTEMSYNC','Look for new files') %>
</button>
</li>
</ul>
<div style="clear:both;"></div>
<form class="actionparams" id="addpage_options" style="display: none" action="admin/assets/addfolder">