Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1165

Přidáno uživatelem Ondřej Fibich před asi 13 roky(ů)

Novinky:

- grid dostal pole Grouped_Action_Field pro shlukovani poli akci
- akce gridu plne podporuji pouzivani ikon
- do helperu text pridana funkce starts_with

Opravy a upravy:

- upraveny, zjednoduseny a zdokumentovany tridy majici neco do cineni s Gridem
- opravi razeni order fieldem
- pridani novych akci s ikonami pro demonstraci do par controlleru

Zobrazit rozdíly:

freenetis/branches/testing/media/css/style.css
#tabs ul li a {
font-size: 13px;
font-weight: bold;
}
/* Action icon of grid */
a.action_field_icon {
display: block;
padding: 2px;
margin-right: 2px;
text-decoration: none;
}
a.action_field_icon:hover {
background-color: #dc1f1f;
}
a.action_field_icon img {
border: none;
}
table.no_table, table.no_table tr, table.no_table td, table.no_table th {
margin: 0px;
padding: 0px;
border: none;
}
freenetis/branches/testing/application/i18n/cs_CZ/texts.php
'action logs' => 'Logy akcí',
'action logs of object' => 'Logy akcí objektu',
'action logs of user' => 'Logy akcí uživatele',
'actions' => 'Akce',
'activate' => 'Aktivovat',
'activate redirection' => 'Aktivovat přesměrování',
'activate redirection to member' => 'Aktivovat členovi přesměrování',
freenetis/branches/testing/application/helpers/text.php
return $val;
}
/**
* Check if first string starts with second
*
* @author Ondřej Fibich
* @param string $str String
* @param string $start Start
* @return bool true if first string starts with second
*/
public static function starts_with($str, $start)
{
return strncmp($str, $start, mb_strlen($start)) == 0;
}
} // End text
freenetis/branches/testing/application/models/member.php
LIMIT " . intval($limit_from) . ", " . $limit_results . "
", array
(
url_lang::lang('texts.Yes'),
url_lang::lang('texts.No'),
url_lang::lang('texts.Yes'),
url_lang::lang('texts.No'),
__('Yes'),
__('No'),
__('Yes'),
__('No'),
Config::get('lang'),
Config::get('lang'),
__('IM'),
......
GROUP BY id
", array
(
url_lang::lang('texts.Yes'),
url_lang::lang('texts.No'),
url_lang::lang('texts.Yes'),
url_lang::lang('texts.No'),
__('Yes'),
__('No'),
__('Yes'),
__('No'),
Config::get('lang'),
Config::get('lang'),
__('IM'),
freenetis/branches/testing/application/controllers/users.php
->label(__('Member'))
->callback('callback::member_field');
if ($this->acl_check_view(get_class($this),'users'))
$actions = $grid->grouped_action_field();
if ($this->acl_check_view(get_class($this), 'users'))
{
$grid->action_field('id')
->label(__('User'))
->url(url_lang::base().'users/show')
->action(__('Show'))
->class('center');
$actions->add_action('id')
->icon_action('member')
->url('users/show')
->label('Show user');
}
if ($this->acl_check_view('Devices_Controller','devices'))
if ($this->acl_check_view('Devices_Controller', 'devices'))
{
$grid->action_field('id')
->label(__('Devices'))
->url(url_lang::base().'devices/show_by_user')
->action(__('Show'))
->class('center');
$actions->add_action('id')
->icon_action('devices')
->url('devices/show_by_user')
->label('Show devices');
}
if ($this->acl_check_view('Users_Controller','work'))
if ($this->acl_check_view('Users_Controller', 'work'))
{
$grid->action_field('id')
->label(__('Works'))
->url(url_lang::base().'works/show_by_user')
->action(__('Show'))
->class('center');
$actions->add_action('id')
->icon_action('work')
->url('works/show_by_user')
->label('Show works');
}
$grid->datasource($query);
freenetis/branches/testing/application/controllers/address_points.php
->label(__('Items count'))
->callback('callback::items_count_field');
$actions = $grid->grouped_action_field();
if ($this->acl_check_view(get_class($this), 'address_point'))
{
$grid->action_field('id')
->label(__('Show'))
->url(url_lang::base().'address_points/show')
->action(__('Show'));
$actions->add_action('id')
->icon_action('show')
->url('address_points/show');
}
if ($this->acl_check_edit(get_class($this), 'address_point'))
{
$grid->action_field('id')
->label(__('Edit'))
->url(url_lang::base().'address_points/edit')
->action(__('Edit'));
$actions->add_action('id')
->icon_action('edit')
->url('address_points/edit');
}
if ($this->acl_check_delete(get_class($this), 'address_point'))
{
$grid->action_field('id')
->label(__('Delete'))
->url(url_lang::base().'address_points/delete')
->action(__('Delete'))
$actions->add_action('id')
->icon_action('delete')
->url('address_points/delete')
->class('delete_link');
}
freenetis/branches/testing/application/controllers/members.php
->label(__('Street'));
$grid->order_field('street_number')
->label(__('Street number'));
->label('Street number');
$grid->order_field('town')
->label(__('Town'));
......
->label(__('Whitelist'))
->callback('callback::whitelisted_field');
$actions = $grid->grouped_action_field();
// action fields
if ($this->acl_check_view(get_class($this), 'members'))
{
$grid->action_field('id')
->label(__('Member'))
->url(url_lang::base().'members/show')
->action(__('Show'));
$actions->add_action('id')
->icon_action('member')
->url('members/show')
->label('Show member');
}
if ($this->acl_check_edit(get_class($this), 'members'))
{
$grid->action_field('aid')
->label(__('Transfers'))
->url(url_lang::base().'transfers/show_by_account')
->action(__('Show'));
$actions->add_action('id')
->icon_action('money')
->url('transfers/show_by_account')
->label('Show transfers');
}
// load data
freenetis/branches/testing/application/controllers/membership_interrupts.php
$grid->order_field('comment')
->label(__('Comment'));
$actions = $grid->grouped_action_field();
if ($this->acl_check_edit('Members_Controller', 'membership_interrupts'))
{
$grid->action_field('id')
->label(__('Membership interrupts'))
->url(url_lang::base().'membership_interrupts/edit')
->action(__('Edit'));
$actions->add_action('id')
->icon_action('edit')
->url('membership_interrupts/edit');
}
if ($this->acl_check_delete('Members_Controller', 'membership_interrupts'))
{
$grid->action_field('id')
->label(__('Membership interrupts'))
->url(url_lang::base().'membership_interrupts/delete')
->action(__('Delete'))
$actions->add_action('id')
->icon_action('delete')
->url('membership_interrupts/delete')
->class('delete_link');
}
freenetis/branches/testing/application/libraries/Order_callback_field.php
<?php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
class Order_Callback_Field_Core extends Order_field
/**
* Order callback grid field
*
* @method Order_Callback_Field callback(mixed $callback)
*/
class Order_Callback_Field extends Order_field
{
/**
* Callback function
*
* @var mixed
*/
public $callback;
}
freenetis/branches/testing/application/libraries/Grouped_action_field.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Grouped action grid field.
* Make groups of actions fields.
*
* @author Ondřej Fibich
*/
class Grouped_Action_Field extends Field
{
/**
* Actions fields
*
* @var array[Actions_Field]
*/
public $actions_fields = array();
/**
* Contruct of grouped action field
*
* @param type $name
*/
public function __construct($name = NULL)
{
if (empty($name))
{
$name = __('Actions');
}
parent::__construct($name);
}
/**
* Adds action field
*
* @param type $name Table column
* @return Action_Field
*/
public function add_action($name)
{
$field = new Action_field($name);
$this->actions_fields[] = $field;
return $field;
}
}
freenetis/branches/testing/application/libraries/Callback_field.php
<?php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Callback grid field
*
* @method Order_Callback_Field callback(mixed $callback)
*/
class Callback_Field_Core extends Field
{
/**
* Callback function
*
* @var mixed
*/
public $callback;
}
freenetis/branches/testing/application/libraries/Form_field.php
<?php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
class Form_Field_Core extends Field
/**
* Form grid field
*
* @method Form_Field type(string $name)
* @method Form_Field input(string $input)
* @method Form_Field rules(string $rules)
* @method Form_Field options(array $options)
* @method Form_Field callback(mixed $callback)
*/
class Form_Field extends Field
{
/**
* Type of form element
*
* @var string
*/
public $type;
/**
* Input
*
* @var string
*/
public $input;
/**
* Rules
*
* @var string
*/
public $rules;
/**
* Options
*
* @var array
*/
public $options;
/**
* Callback
*
* @var mixed
*/
public $callback;
}
freenetis/branches/testing/application/libraries/Order_field.php
<?php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
//defined('SYSPATH') or die('No direct script access.');
class Order_Field_Core extends Field
/**
* Order grid field
*
* @method Order_Field direction(string $direction)
* @method Order_Field direction_label(string $direction_label)
* @method Order_Field return_link(string $return_link)
* @method Order_Field use_selector(bool $use_selector)
* @method Order_Field use_paginator(bool $direction)
*/
class Order_Field extends Field
{
/**
* Direction
*
* @var string
*/
public $direction;
/**
* Direction label
*
* @var string
*/
public $direction_label;
/**
* Return link
*
* @var string
*/
public $return_link;
/**
* Use selector
*
* @var boolean
*/
protected $use_selector = true;
/**
* Use paginator
*
* @var boolean
*/
protected $use_paginator = true;
/**
* Contruct of order field
*
* @param string $name
* @param string $new_order
* @param array $arguments
*/
public function __construct($name, $new_order, $arguments)
{
parent::__construct($name);
......
$this->use_paginator = $arguments['use_paginator'];
$this->create_order_by_link(
$new_order, $arguments['order_by'], $arguments['order_by_direction'],
$arguments['limit_results'], $arguments['url_array_ofset'],
$arguments['variables'], $arguments['query_string']
$new_order, $arguments['order_by'],
$arguments['order_by_direction'],
$arguments['limit_results'],
$arguments['url_array_ofset'],
$arguments['variables'],
$arguments['query_string']
);
}
public function create_order_by_link(
/**
* Created order by link
*
* @param string $new_order_by
* @param string $order_by
* @param string $order_by_direction
* @param mixed $record_per_page
* @param int $url_array_ofset
* @param string $variables
* @param string $query_string
*/
private function create_order_by_link(
$new_order_by = 'users.id', $order_by = 'users.id',
$order_by_direction = 'ASC', $record_per_page = NULL,
$url_array_ofset = 0, $variables = '', $query_string = '')
......
if ($new_order_by == $order_by)
{
$order_by_direction = $order_by_direction == 'ASC' ? 'DESC' : 'ASC';
$order_by_direction = strtoupper($order_by_direction) == 'ASC' ? 'DESC' : 'ASC';
}
else
{
$order_by_direction = strtoupper($order_by_direction);
}
$this->return_link = url_lang::base() . $pre_url . $new_order_by . '/' . $order_by_direction . '/';
$this->return_link .= ($this->use_paginator) ? $url_array[6 + $url_array_ofset] . '/' . $url_array[7 + $url_array_ofset] : '';
freenetis/branches/testing/application/libraries/Action_field.php
<?php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
class Action_Field_Core extends Field
{
/**
* Action grid field
*
* @method Action_Field name(string $name)
* @method Action_Field script(string $script)
*/
class Action_Field extends Field
{
/**
* Name of column
*
* @var string
*/
public $name = 'id';
/**
* URL to action
*
* @var string
*/
public $url;
/**
* Action
*
* @var string
*/
public $action = 'action';
/**
* Extra script
*
* @var string
*/
public $script = null;
/**
*
* @var string
*/
public $nextval = null;
/**
* Image
*
* @var string
*/
public $img = null;
/**
* Contruct of field, set label by its name with auto internationalization
*
* @param string $name Name of field
*/
public function __construct($name)
{
$this->name = $name;
}
/**
* Call method (sets properties)
*
* @param string $method
* @param array $args
* @return Field
*/
public function __call($method, $args)
{
$this->$method = $args[0];
return $this;
}
/**
* Sets action
*
* @param string $action
* @return Action_Field
*/
public function action($action)
{
$this->action = url_lang::lang('texts.'.$action);
$this->action = __($action);
return $this;
}
/**
* Assign URL to action field, add URL base if there is no such
*
* @param string $url
* @return Action_Field
*/
public function url($url)
{
if (!text::starts_with($url, url::base()))
{
$this->url = url_lang::base() . $url;
}
else
{
$this->url = $url;
}
return $this;
}
/**
* Adds icon action
*
* @param string $action Name of image (action)
* @return Action_Field
*/
public function icon_action($action)
{
$this->img = $action;
if (empty($this->label))
{
$this->label = ucfirst(__(str_replace('_', ' ', $action)));
}
return $this;
}
/**
* Renders field
*
* @return string
*/
public function render()
{
return '';
if (empty($this->img))
{
return $this->label;
}
else
{
return html::image(array
(
'src' => 'media/images/icons/grid_action/' . $this->img,
'alt' => $this->label,
'width' => 16,
'height' => 16
));
}
}
/**
* Renders field
*
* @return string
*/
public function __toString()
{
return html::anchor($this->url.'/'.$this->name, ucfirst($this->action), $this->script);
freenetis/branches/testing/application/libraries/Field.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* FORGE (FORm GEneration) library.
*
* $Id: Forge.php 1923 2008-02-05 14:49:08Z Shadowhand $
*
* @package Forge
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
* Grid field
*
* @method Field name(string $name)
* @method Field bool(bool $bool)
* @method Field class(string $class)
* @method Field order(bool $order)
* @method Field style(string $style)
* @method Field help(string $help)
* @method Field args(string $array)
*/
class Field
{
/**
* Label
*
* @var string
*/
public $label;
/**
* Name
*
* @var string
*/
public $name;
/**
* Bool
*
* @var bool
*/
public $bool;
/**
* Class
*
* @var string
*/
public $class;
public $order = True;
/**
* Order
*
* @var bool
*/
public $order = true;
/**
* Style
*
* @var string
*/
public $style;
/**
* Help hint
*
* @var string
*/
public $help;
/**
* Args
*
* @var array
*/
public $args;
/**
......
public function __construct($name)
{
$this->name = $name;
$this->label = url_lang::lang('texts.'.$name);
$this->label = __($name);
}
/**
......
*
* @param string $method
* @param array $args
* @return Field_Core
* @return Field
*/
public function __call($method, $args)
{
......
* Sets label of field
*
* @param string $label New label with auto internationalization
* @return Field_Core
* @return Field
*/
public function label($label)
{
......
}
else
{
$this->label = url_lang::lang('texts.'.$label);
$this->label = __($label);
}
return $this;
freenetis/branches/testing/application/libraries/Grid.php
<?php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Grid for display data
*
* @method Field Field(string $column)
* @method Action_Field action_field(string $column)
* @method Order_Field order_field(string $column)
* @method Order_callback_Field order_callback_field(string $column)
* @method Callback_Field callback_field(string $column)
* @method Grouped_Action_Field grouped_action_field(string $column)
*/
class Grid
{
protected $fields;
protected $action_fields;
protected $add_button = FALSE;
protected $back_button = FALSE;
protected $add_button = FALSE;
protected $back_button = FALSE;
protected $base_uri;
protected $template = 'grid_template';
protected $template = 'grid_template';
protected $title;
protected $label = NULL;
protected $use_paginator = true;
protected $use_selector = true;
protected $separator = '<br /><br />';
protected $show_labels = true;
protected $selector_increace = 30;
protected $selector_min = 10;
protected $selector_max_multiplier = 5;
protected $current = 10;
protected $style = 'classic';
protected $uri_segment = 3;
protected $items_per_page = 10;
protected $total_items = 0;
protected $base_url = '';
protected $label = NULL;
protected $use_paginator = true;
protected $use_selector = true;
protected $separator = '<br /><br />';
protected $show_labels = true;
protected $selector_increace = 30;
protected $selector_min = 10;
protected $selector_max_multiplier = 5;
protected $current = 10;
protected $style = 'classic';
protected $uri_segment = 3;
protected $items_per_page = 10;
protected $total_items = 0;
protected $base_url = '';
protected $order_by;
protected $a_rec_per_page;
protected $variables;
protected $order_by_direction;
protected $limit_results;
protected $record_per_page = NULL;
protected $url_array_ofset = 0;
protected $record_per_page = NULL;
protected $url_array_ofset = 0;
protected $query_string;
protected $filter = '';
protected $form = FALSE;
protected $form_submit_value = '';
protected $filter = '';
protected $form = FALSE;
protected $form_submit_value = '';
protected $form_extra_buttons = array();
protected $buttons = array();
private $first_add_button;
protected $buttons = array();
private $first_add_button;
/**
* Grid construct
*
* @param type $base_uri
* @param type $title
* @param type $config
* @param type $template
*/
public function __construct($base_uri, $title, $config = NULL, $template = FALSE)
{
if ($template) {
if ($template)
{
$this->template = $template;
}
$this->template = new View($this->template);
$this->template->base_uri = $this->base_uri = $base_uri;
$this->template->title = $title;
$this->template->label = (isset($config['total_items'])) ? url_lang::lang('texts.Total items').': '.$config['total_items'] : '';
if (is_array($config)) $this->initialize($config);
$this->template->label = (isset($config['total_items'])) ? __('Total items') . ': ' . $config['total_items'] : '';
if (is_array($config))
{
$this->initialize($config);
}
$this->first_add_button = true;
}
/**
* Initialize grid with given config
*
* @param array $config
*/
public function initialize($config = array())
{
// Assign config values to the object
......
{
$this->$key = $value;
}
}
}
if ($this->use_paginator)
$this->pagination = new Pagination(array(
'base_url' => $this->base_url,
'uri_segment' => $this->uri_segment,
'total_items' => $this->total_items,
'items_per_page' => $this->items_per_page,
'style' => $this->style
));
if ($this->use_selector)
$this->selector = new Selector(array(
'current' => $this->current,
'selector_increace' => $this->selector_increace,
'selector_min' => $this->selector_min,
'selector_max_multiplier' => $this->selector_max_multiplier
));
{
$this->pagination = new Pagination(array
(
'base_url' => $this->base_url,
'uri_segment' => $this->uri_segment,
'total_items' => $this->total_items,
'items_per_page' => $this->items_per_page,
'style' => $this->style
));
}
if ($this->use_selector)
{
$this->selector = new Selector(array
(
'current' => $this->current,
'selector_increace' => $this->selector_increace,
'selector_min' => $this->selector_min,
'selector_max_multiplier' => $this->selector_max_multiplier
));
}
$this->template->show_labels = $this->show_labels;
}
/**
* Sets values
*
* @param string $key
* @param mixed $value
*/
public function __set($key, $value)
{
$this->$key = $value;
}
/**
* Adds new button to the top of grid
*
* @param type $uri URI of button
* @param type $label Label of button
* @param type $options Options
* @param type $help Help hint
*/
public function add_new_button($uri, $label, $options = array(), $help = '')
{
$this->buttons[] = html::anchor($uri, $label, $options).(($help == '') ? '' : '&nbsp;'.$help);
$this->buttons[] = html::anchor(
$uri, $label, $options
) . (($help == '') ? '' : '&nbsp;' . $help);
}
/**
* Adds back button to the top of grid
*
* @param string $label Label of button
*/
public function add_back_button($label)
{
$this->template->back_button = "<a href=\"javascript:history.go(-1)\">".$label."</a>";
$this->template->back_button = "<a href=\"javascript:history.go(-1)\">" . $label . "</a>";
}
/**
* Magic __call method. Creates a new form element object.
*
......
// Class name
$field = ucfirst($method);
// Create the input
if ($field == 'Order_field')
if ($field == 'Order_field')
{
$arguments = array(
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
$arguments = array
(
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
);
if (!isset($args[1])) $args[1] = NULL;
$field = new $field($args[0],$args[1],$arguments);
if (!isset($args[1]))
$args[1] = NULL;
$field = new Order_field($args[0], $args[1], $arguments);
}
elseif ($field == 'Order_callback_field')
{
$arguments = array(
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
$arguments = array
(
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
);
if (!isset($args[1])) $args[1] = NULL;
$field = new $field($args[0],$args[1],$arguments);
if (!isset($args[1]))
$args[1] = NULL;
$field = new Order_callback_field($args[0], $args[1], $arguments);
}
elseif ($field == 'Order_form_field')
{
$arguments = array(
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
$arguments = array
(
'order_by' => $this->order_by,
'order_by_direction' => $this->order_by_direction,
'limit_results' => $this->limit_results,
'record_per_page' => $this->record_per_page,
'url_array_ofset' => $this->url_array_ofset,
'variables' => $this->variables,
'query_string' => $this->query_string,
'use_selector' => $this->use_selector,
'use_paginator' => $this->use_paginator
);
if (!isset($args[1])) $args[1] = NULL;
$field = new $field($args[0],$args[1],$arguments);
if (!isset($args[1]))
$args[1] = NULL;
$field = new Order_form_field($args[0], $args[1], $arguments);
}
else $field = new $field($args[0]);
else if ($field == 'Grouped_action_field')
{
$field = new Grouped_action_field(isset($args[0]) ? $args[0] : NULL);
}
else
{
$field = new $field($args[0]);
}
if ( ! ($field instanceof Field))
if (!($field instanceof Field))
{
throw new Kohana_Exception('grige.unknown_field', get_class($field));
if ($field instanceof Grid_Actionfield) {
}
if ($field instanceof Grid_Actionfield)
{
$this->action_fields[] = $field;
} else {
}
else
{
$this->fields[] = $field;
}
if ($field instanceof Form_Field || $field instanceof Order_Form_Field)
{
$this->form = TRUE;
}
return $field;
}
/**
* Load satasource
*
* @param object $items
*/
public function datasource($items)
{
$this->template->items = $items;
}
/**
* Renders grid
*
* @return string
*/
public function render()
{
$this->template->buttons = $this->buttons;
......
$this->template->fields = $this->fields;
$this->template->action_fields = $this->action_fields;
$this->template->paginator = ($this->use_paginator) ? $this->pagination->create_links('digg') : '';
$this->template->selector = ($this->use_selector) ? $this->selector->create() : '';
$this->template->separator = $this->separator ;
$this->template->selector = ($this->use_selector) ? $this->selector->create() : '';
$this->template->separator = $this->separator;
$this->template->form = $this->form;
$this->template->form_extra_buttons = $this->form_extra_buttons;
$this->template->form_submit_value = ($this->form_submit_value!='') ? $this->form_submit_value : url_lang::lang('texts.Update');
$this->template->form_submit_value = ($this->form_submit_value != '') ? $this->form_submit_value : __('Update');
return $this->template->render();
}
/**
* Renders grid
*
* @return string
*/
public function __toString()
{
return $this->render();
}
}
}
freenetis/branches/testing/application/views/main.php
return false;
})
$('.delete_link').click(function(){
$('.delete_link, .delete_link *').click(function(){
return window.confirm('<?php echo __('Do you really want to delete this record') ?>?');
})
freenetis/branches/testing/application/views/grid_template.php
</th>
<?php
}
else if ($field instanceof Grouped_Action_Field)
{
if (count($field->actions_fields))
{
?>
<th class="{sorter: false}"><?php echo $field->label?><?php if ($field->help!='') echo $field->help ?>
</th>
<?php
}
}
else
{
?>
<th class="noprint<?php echo (!$field->order) ? ' {sorter: false}' : ''?>"><?php echo $field->label?><?php if ($field->help!='') echo $field->help ?></th>
<?php
}
}
?>
<?php endforeach; ?>
</tr>
......
<?php foreach ($fields as $field) :
if ($field->class != '') $class_td = ' class="'.$field->class.'"';
else $class_td = '';
else $class_td = '';
// action field
if ($field instanceof Action_Field) :
$property = $field->name; ?>
<td class="noprint"><?php echo html::anchor($field->url.'/'.$item->$property, $field->action, array('script' => $field->script,'class'=> $field->class))?></td>
<?php elseif ($field->bool != ''): ?>
<td <?php echo $class_td?>><?php echo $field->bool[(bool)$item->$field] ?>
</td>
<?php else: ?>
<?php
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff