diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index dbdaa479..5d987089 100644 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -112,6 +112,20 @@ abstract class ModelAdmin extends LeftAndMain { Requirements::javascript('cms/javascript/ModelAdmin.js'); } + /** + * overwrite the static page_length of the admin panel, + * should be called in the project _config file. + */ + static function set_page_length($length){ + self::$page_length = $length; + } + + /** + * Return the static page_length of the admin, default as 30 + */ + static function get_page_length(){ + return self::$page_length; + } /** * Add mappings for generic form constructors to automatically delegate to a scaffolded form object. */ @@ -363,19 +377,23 @@ class ModelAdmin_CollectionController extends Controller { * @todo push this HTML structure out into separate template */ function search($request) { + $filteredParams = $request->getVars(); + unset($filteredParams['ctf']); $model = singleton($this->modelClass); $context = $model->getDefaultSearchContext(); - $results = $context->getResults($request->getVars(), null, array('start'=>0, 'limit'=>$this->parentController->stat('page_length'))); + $length = $this->parentController->stat('page_length'); + $results = $context->getResults($request->getVars()); $summaryFields = $model->summaryFields(); - $tf = new TableListField( $this->modelClass, $this->modelClass, $summaryFields ); $tf->setCustomSourceItems($results); + $tf->setPageSize($length); + $tf->setShowPagination(true); $tf->setPermissions(array('view')); - $url = 'modelClass . '/$ID/edit\">$value'; + $url = 'Link() . '/$ID/edit\">$value'; $tf->setFieldFormatting(array_combine(array_keys($summaryFields), array_fill(0,count($summaryFields), $url))); // implemented as a form to enable further actions on the resultset @@ -389,8 +407,16 @@ class ModelAdmin_CollectionController extends Controller { ), new FieldSet() ); - - return $form->forTemplate(); + $tf->setExtraLinkParams($filteredParams); + + if(isset($_POST['paginate']) && $_POST['paginate']==1){ + $response = $tf->renderWith("TableListField"); + FormResponse::update_dom_id($tf->id(), $response); + FormResponse::set_non_ajax_content($response); + return FormResponse::respond(); + }else{ + return $form->forTemplate(); + } } ///////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index 27fc1e6c..03885cbc 100644 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -255,8 +255,9 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { } public function Link($action = null) { - if(!$action) $action = "index"; - return "admin/security/$action/" . $this->currentPageID(); + //if(!$action) $action = "index"; + //return "admin/security/$action/" . $this->currentPageID(); + return "admin/security/$action/"; } public function listmembers( $baseGroup = null ) { diff --git a/css/ModelAdmin.css b/css/ModelAdmin.css index 84df26e2..6eac36fa 100644 --- a/css/ModelAdmin.css +++ b/css/ModelAdmin.css @@ -28,6 +28,10 @@ body.ModelAdmin #SearchForm_holder { body.ModelAdmin #ResultTable_holder { overflow:auto; +} + +body.ModelAdmin #right{ + overflow:auto; } body.ModelAdmin #right table.results { diff --git a/javascript/ModelAdmin.js b/javascript/ModelAdmin.js index de2f0f9d..f2de4a4c 100644 --- a/javascript/ModelAdmin.js +++ b/javascript/ModelAdmin.js @@ -100,6 +100,9 @@ jQuery(document).ready(function() { data = formData(form); jQuery.get(form.attr('action'), data, function(result){ jQuery('#right #ModelAdminPanel').html(result); + + Behaviour.apply(); + jQuery('#right #ModelAdminPanel tbody td a').click(function(){ var el = jQuery(this); showRecord(el.attr('href')); diff --git a/javascript/TinyMCEImageEnhancement.js b/javascript/TinyMCEImageEnhancement.js index de913d4f..94b7cc25 100644 --- a/javascript/TinyMCEImageEnhancement.js +++ b/javascript/TinyMCEImageEnhancement.js @@ -143,12 +143,14 @@ TinyMCEImageEnhancement.prototype = { } if($('FolderID') != null) { + if($('SecurityID')) var securityid=$('SecurityID').value; + else var securityid=null; this.upload = new Upload( { fileTypes : '*.jpeg;*.jpg;*.jpe;*.png;*.gif;', fileTypesDescription : 'Image files', fileUploadLimit : '100', - securityID : $('SecurityID').value, + securityID : securityid, beginUploadOnQueue : true, buildUI : this.addListeners.bind(this), fileQueued : this.uploadFileQueuedCallback.bind(this), diff --git a/templates/Includes/ModelAdmin_right.ss b/templates/Includes/ModelAdmin_right.ss index a1082f4d..8a04e6fb 100755 --- a/templates/Includes/ModelAdmin_right.ss +++ b/templates/Includes/ModelAdmin_right.ss @@ -1,5 +1,5 @@ -
+
<% if EditForm %> $EditForm