Update of /cvsroot/phpvortex/phpvortex
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8538
Added Files:
SEC_List.class.php SEC_ListNavigator.class.php
Log Message:
Added the classes SEC_List and SEC_ListNavigator
--- NEW FILE: SEC_List.class.php ---
<?php
/**
* File for class SEC_List.
*
* @package Vortex
* @subpackage Page
* @author Thiago Ramon Gonçalves Montoya
* @copyright Copyright 2004, Thiago Ramon Gonçalves Montoya
* @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
*/
/** Require the base class */
require_once('SEC_Base.class.php');
/**
* Class for Table lists sections.
*
* @package Vortex
* @subpackage Page
*/
class SEC_List extends SEC_Base
{
/**
* Table to show the list from.
*
* @var TB_Base
*/
var $table = NULL;
/**
* URL to link the table items to.
*
* @var URL
*/
var $url = NULL;
/**
* Array with the navigator of the list.
*
* The navigator is an array containing the section to use as navigator of the page in the following form:
* <pre>
* array( 'class' => 'Section Class', // Usually SEC_ListNavigator or a descendant
* 'opts' => array('Section options') );
* </pre>
* It is always sent after the list.
*
* @var array
*/
var $navigator = array();
/**
* Number of records per page to display.
*
* @var int
*/
var $recspage = -1;
/**
* Array containing the data to seek as 'field' => 'value', used only in searches and the like.
*
* @var array
*/
var $data = NULL;
/**
* Constructor: Load all parameters into member variables.
*
* @param TB_Base $table Table to show the list from.
* @param array $opts Parameters for the object, as 'var' => 'value'.
*/
function SEC_List($opts = array())
{
parent::SEC_Base($opts);
if (!empty($this->navigator)) {
if (empty($this->navigator['opts']['key'])) $this->navigator['opts']['key'] = "page_{$this->table->name}";
$this->AddSection("{$table->name}_list_navigator", $this->navigator['class'], $this->navigator['opts']);
}
}
/**
* Outputs the section to the client.
*/
function Show()
{
echo "<div class='div_list_full'>\n";
if ($this->recspage > 0) $this->table->list_recspage = $this->recspage;
$this->table->ShowList($this->url, (!empty($_REQUEST["page_{$this->table->name}"])?$_REQUEST["page_{$this->table->name}"]:-1), $this->data);
if (isset($this->sections["{$this->table->name}_list_navigator"])) {
$this->sections["{$this->table->name}_list_navigator"]->page = (!empty($_REQUEST["page_{$this->table->name}"])?$_REQUEST["page_{$this->table->name}"]:-1);
$this->sections["{$this->table->name}_list_navigator"]->pages = $this->table->NumPages($this->data);
}
parent::Show();
echo "</div>";
}
}
?>
--- NEW FILE: SEC_ListNavigator.class.php ---
<?php
/**
* File for class SEC_ListNavigator.
*
* @package Vortex
* @subpackage Page
* @author Thiago Ramon Gonçalves Montoya
* @copyright Copyright 2004, Thiago Ramon Gonçalves Montoya
* @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
*/
/** Require the base class */
require_once('SEC_Base.class.php');
/**
* Class for Table lists navigators.
*
* @package Vortex
* @subpackage Page
*/
class SEC_ListNavigator extends SEC_Base
{
/**
* URL to link the page jumps to.
*
* @var URL
*/
var $url = NULL;
/**
* Key to add the page number to into the URL.
*
* @var string
*/
var $key = 'page';
/**
* Current page.
*
* @var int
*/
var $page = 0;
/**
* Number of pages.
*
* @var int
*/
var $pages = 0;
/**
* Outputs the section to the client.
*
* Outputs the HTML opening tags, then the content, then the HTML closing tags.
*/
function Show()
{
echo "<div class='div_navi'>\n";
$start = max(0, $this->page - 3);
$end = min($this->pages, $this->page + 3);
if ($this->page > 0) {
$this->url->parameters[$this->key] = 0;
echo "<a href='".$this->url->Get()."'><<</a>";
$this->url->parameters[$this->key] = $this->page - 1;
echo " <a href='".$this->url->Get()."'><</a> ";
} else {
echo '<< < ';
}
for ($i = $start; $i <= $end; $i++) {
$this->url->parameters[$this->key] = $i;
echo " <a href='".$this->url->Get()."'>$i</a>";
}
if ($this->page < $this->pages - 1) {
$this->url->parameters[$this->key] = $this->page + 1;
echo " <a href='".$this->url->Get()."'>></a>";
$this->url->parameters[$this->key] = $this->pages - 1;
echo " <a href='".$this->url->Get()."'>>></a><br>\n";
} else {
echo " > >><br>\n";
}
parent::Show();
echo "</div>";
}
}
?>
|