Jump to content

PSL atk CustomRowCount module

From NusaATK
Revision as of 10:18, 21 October 2008 by Stevie (talk | contribs) (New page: == Description == The PSL atk_CustomRowCount modul provides dynamic ui driven row counts in recordlists. [screenshot?] == Demo == Demo link. == Download == Download link. == Influence...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Description

The PSL atk_CustomRowCount modul provides dynamic ui driven row counts in recordlists.

[screenshot?]

Demo

Demo link.

Download

Download link.

Influences

What existing or other extension modules does it influence?

Dependencies

What modules or external software is needed to run this module?

Installation manual

<? /**

  • This file is part of the Achievo ATK distribution.
  • Detailed copyright and licensing information can be found
  • in the doc/COPYRIGHT and doc/LICENSE files which should be
  • included in the distribution.
  • @package atk
  • @copyright (c)2000-2008 Ivo Jansch
  • @license http://www.achievo.org/atk/licensing ATK Open Source License
  • @subpackage PSL atk_CustomRowCount
  • @copyright (c)2008 Psycholutions Consulting & Services
  • @version $Revision: 1.0 $
  • $Id: atk_CustomRowCount,v 1.0 2008/10/21 09:52:45 stevie Exp $
  • This file contains no standalone class, instead it provides 3 tiny functions / code fragments
  • you can use to control the row counts of your nodes recordlist from within the GUI
  • /

/**

* Sets dynamically $config_recordsperpage
* @param object $handler 
* @param array $record 
* @return object $handler 
*/      

function action_admin($handler, $record="") {

   global $config_recordsperpage;
   
   $this->validRowCounts=array('3','7','15','25','35','50','100','300','500');
   
   $session = &atkSessionManager::getSession();
   $stack=atkStackID();
   $level=atkLevel();
   
   if(isset($_REQUEST['RowCount'])&&(in_array($_REQUEST['RowCount'],$this->validRowCounts))):
       $session["default"]["stack"][$stack][$level]['RowCount']=(int)$_REQUEST['RowCount'];
   else:
       $session["default"]["stack"][$stack][$level]['RowCount']=3;
   endif;
   
   $config_recordsperpage=$session["default"]["stack"][$stack][$level]['RowCount'];
   
   return $handler->action_admin(); 

}//function

/**

* Returns html content for a dynamic preselected select option
* @return string $content 
*/ 

function getValidRowCounts() {

   $session = &atkSessionManager::getSession();
   $stack=atkStackID();
   $level=atkLevel();
   foreach($this->validRowCounts as $service):
       $content.="<option ".(($session["default"]["stack"][$stack][$level]['RowCount']==$service) ? 'selected' : )." value=\"".$service."\">".$service;
   endforeach;
   return $content;

}//function

/**

* Returns html content for a recordlists adminHeader
* including the html select input to choose a row count 
* Important Notice: you may have to change the forms index (forms[0]->forms[1])
* if you have an add screen in your recordlist or other additional html forms
* @return string $view_select 
*/     

function adminHeader(){

   $view_select ="<script language='JavaScript'>
   function extend_form(){
   rowCountHidden = document.createElement('INPUT');
   rowCountHidden.type  = 'hidden';
   rowCountHidden.name  = 'RowCount';
   rowCountHidden.value = document.getElementById('RowCountType').value;
   document.forms[1].appendChild(rowCountHidden);
   document.forms[1].submit();
   return;
   }</script>";
   $view_select.=" RowCount: <select style='padding:0px;margin:0px' id='RowCountType' name='RowCountType' 
   onChange='extend_form();'>
   <option value='choose'>Choose
   ".$this->getValidRowCounts()."
   </select></form>";      
   return $view_select;     

} ?>

Changelog

What has changed in your module in different versions?

About

History of how it came into being, who develped or sponsored.

Licence