Example #1
0
 /**
  * Construct
  * 
  * Called when the class is constructed
  * 
  * @access	public
  * @param	mixed
  * @return	Spark\Grid_Column
  */
 public function __construct($identifier = null, array $attributes = array())
 {
     // Validate the identifier
     if (!$identifier) {
         throw new Exception(\Str::f('An identifier must be provided when initialising a grid column'));
     }
     $this->set_identifier($identifier)->set_data($attributes);
 }
Example #2
0
 /**
  * Get Grid
  * 
  * Gets the grid this component
  * is part of
  * 
  * @access	public
  * @return	Spark\Grid
  */
 public final function get_grid()
 {
     // Make sure the grid has been set for this component
     if (!$this->_grid instanceof \Grid) {
         throw new \Exception(\Str::f('Cannot retrieve grid instance for %s', get_class($this)));
     }
     return $this->_grid;
 }
Example #3
0
 * web-based systems easier and quicker.
 * 
 * @package    Fuel
 * @subpackage Spark
 * @version    1.0
 * @author     Ben Corlett (http://www.bencorlett.com)
 * @license    MIT License
 * @copyright  (c) 2011 Ben Corlett
 * @link       http://spark.bencorlett.com
 */
namespace Spark;

?>
<div class="range">
	<div class="line min">
		<?php 
echo \Form::label('From', \Str::f('grid-%s-filter-%s-min', $filter->get_grid()->get_identifier(), $filter->get_column()->get_identifier()));
?>
		<?php 
echo \Form::input($filter->get_column()->get_identifier() . '[min]', $filter->get_user_value() ? $filter->get_user_value()->get_min() : null, array('class' => 'filter', 'id' => \Str::f('grid-%s-filter-%s-min', $filter->get_grid()->get_identifier(), $filter->get_column()->get_identifier())));
?>
	</div>
	<div class="line max">
		<?php 
echo \Form::label('To', \Str::f('grid-%s-filter-%s-max', $filter->get_grid()->get_identifier(), $filter->get_column()->get_identifier()));
?>
		<?php 
echo \Form::input($filter->get_column()->get_identifier() . '[max]', $filter->get_user_value() ? $filter->get_user_value()->get_max() : null, array('class' => 'filter', 'id' => \Str::f('grid-%s-filter-%s-max', $filter->get_grid()->get_identifier(), $filter->get_column()->get_identifier())));
?>
	</div>
</div><?php 
Example #4
0
 /**
  * Get Column
  * 
  * Gets the column
  * property that this
  * cell belongs to
  * 
  * @access	public
  * @return	Spark\Grid_Column_Filter
  */
 public function get_column()
 {
     if (!$this->_column instanceof \Grid_Column) {
         throw new \Exception(\Str::f('Cannot retrieve grid column instance for %s', get_class($this)));
     }
     return $this->_column;
 }
Example #5
0
 /**
  * Get Driver
  * 
  * Gets the driver for the
  * grid, based off the query
  * 
  * @access	public
  * @return	Spark\Grid_Driver_Abstract
  */
 public function get_driver()
 {
     // Lazy load the driver
     if (!$this->_driver) {
         // Loop through drivers and determine the driver based off
         // the class the query has
         foreach ($this->get_drivers() as $query_class => $driver_class) {
             // We can either deal with a class or a subclass
             if (get_class($this->get_query()) === $query_class or is_subclass_of(get_class($this->get_query()), $query_class)) {
                 $this->_driver = $driver_class::factory()->set_grid($this);
                 // Make sure the driver is valid
                 if (!$this->_driver instanceof \Grid_Driver_Abstract) {
                     throw new Exception('Grid drivers must extend Spark\\Grid_Driver_Abstract');
                 }
                 break;
             }
         }
         // If we still haven't found a driver
         // throw an exception
         if (!$this->_driver) {
             throw new Exception(Str::f('There is no driver for the a query which is an instance of %s', get_class($this->get_query())));
         }
     }
     return $this->_driver;
 }
Example #6
0
 /**
  * Get Row
  * 
  * Gets the row property
  * this cell belongs to
  * 
  * @access	public
  * @return	Spark\Grid_Row	Row
  */
 public function get_row()
 {
     if (!$this->_row instanceof \Grid_Row) {
         throw new \Exception(\Str::f('Cannot retrieve row instance for %s', get_class($this)));
     }
     return $this->_row;
 }
Example #7
0
 /**
  * Call Static
  * 
  * Magic method used to create
  * an instance of the object
  * 
  * @access	public
  * @param	string	Method
  * @param	array	Arguments
  * @return	mixed
  */
 public static function __callStatic($method, array $arguments)
 {
     if (substr($method, 0, 11) === 'create_from') {
         switch (substr($method, 12)) {
             case 'post':
                 return static::factory($_POST)->make_recursive();
             case 'get':
                 return static::factory($_GET)->make_recursive();
         }
     }
     throw new Exception(\Str::f('Call to undefined method %s::%s()', __CLASS__, $method));
 }