Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
71
core/widgets/listtable.php
Normal file
71
core/widgets/listtable.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/widgets/widget.php';
|
||||
require_once 'core/functions.php';
|
||||
|
||||
/**
|
||||
* Êëàññ äëÿ ãåíåðàöèè òàáëèöû
|
||||
*/
|
||||
class ListTable extends Widget // MenuTable
|
||||
{
|
||||
private $visible = null;
|
||||
private $menu;
|
||||
|
||||
function setUp()
|
||||
{
|
||||
$this->menu = array();
|
||||
$this->template = "table";
|
||||
}
|
||||
|
||||
/**
|
||||
* Óñòàíàâëèâàåò ôîðìàò òàáëèöû, ñòðóêòóðó $header ñì. table.js
|
||||
*/
|
||||
function setHeader($header)
|
||||
{
|
||||
$this->setData('table', $header);
|
||||
}
|
||||
|
||||
function setView($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
}
|
||||
|
||||
function setAction($action)
|
||||
{
|
||||
$this->setData('list', forceUrl($action));
|
||||
}
|
||||
|
||||
function addMenuItem($href, $name, $to = 'item')
|
||||
{
|
||||
if ($href) {
|
||||
if ($to === true) $to = 'all';
|
||||
if (! isset($this->menu[$to])) {
|
||||
$this->menu[$to] = array('group' => $to, 'all' => ($to == 'all'), 'items' => array());
|
||||
}
|
||||
$this->menu[$to]['items'][] = array('href' => $href, 'name' => $name);
|
||||
}
|
||||
}
|
||||
|
||||
function make(Controller $parent)
|
||||
{
|
||||
$view = $this->visible;
|
||||
if (is_null($view)) {
|
||||
$view = array('left' => key_values('key', $this->data['table']), 'right' => array());
|
||||
}
|
||||
|
||||
$this->setData('setup', $view);
|
||||
|
||||
foreach ($this->menu as &$menu) {
|
||||
foreach ($menu['items'] as &$item) {
|
||||
$item['href'] = forceUrl($item['href']);
|
||||
}
|
||||
}
|
||||
$this->setData('menu', array_keys($this->menu));
|
||||
|
||||
parent::make($parent);
|
||||
|
||||
$this->view->menus = $this->menu;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue