Exemplo n.º 1
0
 /**
  * Render
  * 
  * Renders a cell and populates
  * it's rendered value
  * 
  * @access	public
  * @param	Spark\Grid_Column_Cell	Cell
  * @return	Spark\Grid_Column_Renderer_Checkbox
  */
 public function render(\Grid_Column_Cell $cell)
 {
     // Get the value
     $value = $cell->get_original_value();
     // An array of checked items
     $checked = ($checked = $cell->get_column()->get_checked() and $checked->count()) ? $checked->get_data() : array();
     $cell->set_rendered_value(\Form::checkbox($this->get_checkbox_name($cell), $value, array(in_array($value, $checked) ? 'checked' : null)));
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Render
  * 
  * Renders a cell and populates
  * it's rendered value
  * 
  * @access	public
  * @param	Spark\Grid_Column_Cell	Cell
  * @return	Spark\Grid_Column_Renderer_Options
  */
 public function render(\Grid_Column_Cell $cell)
 {
     // Get options
     $options = $cell->get_column()->get_options();
     // Value fallback
     $value = '';
     // Override the value with an option
     if (isset($options[$cell->get_original_value()])) {
         $value = $options[$cell->get_original_value()];
     }
     $cell->set_rendered_value($value);
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Render
  * 
  * Renders a cell and populates
  * it's rendered value
  * 
  * @access	public
  * @param	Spark\Grid_Column_Cell	Cell
  * @return	Spark\Grid_Column_Renderer_Action
  */
 public function render(\Grid_Column_Cell $cell)
 {
     // Get value
     $value = $cell->get_original_value();
     if ($actions = $cell->get_actions()) {
         if ($actions->count() > 1) {
             // Convert uri to somethign that the browser will like
             $value = \Form::select(null, null, array(null => null) + $actions->get_data(), array('onchange' => 'window.location.href=this.value'));
         } else {
             $value = '';
             foreach ($actions->get_data() as $action => $action_value) {
                 if (is_object($action_value)) {
                     $value .= \Html::anchor($action, $action_value->get_data('title'), array('class' => $action_value->get_data('link_class', '')));
                 } else {
                     $value .= \Html::anchor($action, $action_value);
                 }
             }
         }
     }
     // Set rendered
     $cell->set_rendered_value($value);
     return $this;
 }
Exemplo n.º 4
0
 /**
  * Render
  * 
  * Renders a cell and populates
  * it's rendered value
  * 
  * @access	public
  * @param	Spark\Grid_Column_Cell	Cell
  * @return	Spark\Grid_Column_Renderer_Options
  */
 public function render(\Grid_Column_Cell $cell)
 {
     // Get current row from database
     $results = $cell->get_driver()->get_results()->as_array();
     $current = $results[$this->counter++];
     // Get options
     $options = $cell->get_column()->get_options();
     // Value fallback
     $value = '';
     // Override the value with an option
     if (isset($options[$cell->get_original_value()])) {
         $value = $options[$cell->get_original_value()];
         // Create date tooltip
         if ($cell->get_original_value() == 2) {
             $value .= '<a href="#" class="activeDate" id="activeDate02" title="' . date('m/d/Y', $current->active_from) . ' - ' . date('m/d/Y', $current->active_to) . '">' . \Theme::instance()->asset->img('icon-calendar.png', array('width' => 16, 'height' => 16, 'alt' => '')) . '</a>';
         }
     }
     $cell->set_rendered_value($value);
     return $this;
 }
Exemplo n.º 5
0
 /**
  * Get Rows
  * 
  * Gets the rows based
  * off the query
  * 
  * @access	public
  * @return	Spark\Grid_Driver_Database
  */
 public function build_rows()
 {
     // Counter
     $i = 0;
     // Loop through the results and add them
     // to the rows
     foreach ($this->get_results(false) as $result) {
         // Create a row
         $row = \Grid_Row::factory()->set_grid($this->get_grid());
         // Set the class of the row
         $class = '';
         if (++$i == 1) {
             $class = 'first';
         }
         $class .= $i % 2 == 0 ? ' even' : ' odd';
         if ($i == $this->get_results()->count()) {
             $class .= ' last';
         }
         $row->set_class($class);
         // Process the row action of the grid
         if ($action = $this->get_row_action()) {
             // Get dynamic parameters from the row
             // action
             preg_match('/\\{\\w+\\}/', $action, $matches);
             // Loop through the matches and
             // update the row action string
             foreach ($matches as $match) {
                 // Determine the actual property
                 // the user is after
                 $property = str_replace(array('{', '}'), null, $match);
                 // Get the value of that proprty
                 // in this result and replace it
                 // in the string
                 $value = $result->{$property};
                 $action = \Uri::create(str_replace($match, $value, $action));
             }
             // Set the action of the row
             $row->set_action($action);
         }
         // Loop through columns and add a cell
         // to the row for each column
         foreach ($this->get_columns() as $column) {
             // Create a column cell
             $cell = \Grid_Column_Cell::factory()->set_grid($this->get_grid())->set_column($column)->set_row($row)->set_original_value($result->{$column->get_index()});
             // Process cell actions
             if ($action = $column->get_action()) {
                 // Get dynamic parameters from the row
                 // action
                 preg_match('/\\{\\w+\\}/', $action, $matches);
                 // Loop through the matches and
                 // update the row action string
                 foreach ($matches as $match) {
                     // Determine the actual property
                     // the user is after
                     $property = str_replace(array('{', '}'), null, $match);
                     // Get the value of that proprty
                     // in this result and replace it
                     // in the string
                     $value = $result->{$property};
                     $action = \Uri::create(str_replace($match, $value, $action));
                 }
                 // Set the action of the cell
                 $cell->set_action($action);
             }
             // Process any actions on the column
             if ($actions = $column->get_actions() and $actions->count()) {
                 // Clone the actions object
                 $actions = clone $actions;
                 foreach ($actions as $action => $name) {
                     // New action
                     $new_action = false;
                     // Get dynamic parameters from the row
                     // uri
                     preg_match('/\\{\\w+\\}/', $action, $matches);
                     // Loop through the matches and
                     // update the row uri string
                     foreach ($matches as $match) {
                         // Determine the actual property
                         // the user is after
                         $property = str_replace(array('{', '}'), null, $match);
                         // Get the value of that proprty
                         // in this result and replace it
                         // in the string
                         $value = $result->{$property};
                         $new_action = \Uri::create(str_replace($match, $value, $action));
                         // Update the actions
                         $actions->unset_data($action)->set_data($new_action, $name);
                     }
                 }
                 // Set the actions of the cell
                 $cell->set_actions($actions);
             }
             // Add the cell to the row
             $row->add_cell($column->get_identifier(), $cell);
         }
         // We've now built our row,
         // add it to the rows object
         $this->get_rows()->add_data($row);
     }
     return $this;
 }
Exemplo n.º 6
0
 /**
  * Render
  * 
  * Renders a cell and populates
  * it's rendered value
  * 
  * @access	public
  * @param	Spark\Grid_Column_Cell	Cell
  * @return	Spark\Grid_Column_Renderer_Text
  */
 public function render(\Grid_Column_Cell $cell)
 {
     $cell->set_rendered_value($cell->get_original_value());
     return $this;
 }