Structures_DataGrid_Renderer_Smarty
[ class tree: Structures_DataGrid_Renderer_Smarty ] [ index: Structures_DataGrid_Renderer_Smarty ] [ all elements ]

Class: Structures_DataGrid_Renderer_Smarty

Source Location: /Structures_DataGrid_Renderer_Smarty-0.1.5/Structures/DataGrid/Renderer/Smarty.php

Class Overview

Structures_DataGrid_Renderer
   |
   --Structures_DataGrid_Renderer_Smarty

Smarty Rendering Driver


Author(s):

Version:

  • $Revision: 259488 $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 148]
Smarty Rendering Driver

SUPPORTED OPTIONS:

  • selfPath: (string) The complete path for sorting and paging links. (default: $_SERVER['PHP_SELF'])
  • sortingResetsPaging: (bool) Whether sorting HTTP queries reset paging.
  • convertEntities: (bool) Whether or not to convert html entities. This calls htmlspecialchars().
  • varPrefix: (string) Prefix for smarty variables and functions assigned by this driver. Can be used in conjunction with Structure_DataGrid::setRequestPrefix() for displaying several grids on a single page.
  • associative: (bool) By default the column set and the records are numerically indexed arrays. By setting this option to true the keys will be field names instead.
SUPPORTED OPERATION MODES:

  • Container Support: yes
  • Output Buffering: yes
  • Direct Rendering: no
  • Streaming: no
  • Object Preserving: yes
GENERAL NOTES:

To use this driver you need the Smarty template engine from http://smarty.php.net

This driver does not support the render() method, it is only able to:

Either fill() a Smarty object by assigning variables and registering the {getPaging} smarty function. It's up to you to call Smarty::display() after the Smarty object has been filled.

Or return all variables as a PHP array from getOutput(), for maximum flexibility, so that you can assign them the way you like to your Smarty instance.

This driver assigns the following Smarty variables:

  1.  - $columnSet:       array of columns specifications
  2.                      structure:
  3.                           array (
  4.                               0 => array (
  5.                                   'name'       => field name,
  6.                                   'label'      => column label,
  7.                                   'link'       => sorting link,
  8.                                   'attributes' => attributes string,
  9.                                   'direction'  => 'ASC''DESC' or '',
  10.                                   'onclick'    => onMove call
  11.                               ),
  12.                               ...
  13.                           )
  14.  - $recordSet:       array of records values
  15.  - $currentPage:     current page (starting from 1)
  16.  - $nextPage:        next page
  17.  - $previousPage:    previous page
  18.  - $recordLimit:     number of rows per page
  19.  - $pagesNum:        number of pages
  20.  - $columnsNum:      number of columns
  21.  - $recordsNum:      number of records in the current page
  22.  - $totalRecordsNum: total number of records
  23.  - $firstRecord:     first record number (starting from 1)
  24.  - $lastRecord:      last record number (starting from 1)
  25.  - $currentSort:     array with column names and the directions used for sorting
  26.  - $datagrid:        a reference that you can pass to {getPaging}

This driver registers a Smarty custom function named getPaging that can be called from Smarty templates with {getPaging} in order to print paging links. This function accepts the same parameters as the pagerOptions option of Structures_DataGrid_Renderer_Pager.

{getPaging} accepts an optional "datagrid" parameter which you can pass the $datagrid variable, to display paging for an arbitrary datagrid (useful with multiple dynamic datagrids on a single page).

Object Records : this drivers preserves object records if provided. This means that if your datasource provides objects instead of associative arrays as records, you can access their properties and methods in your smarty template, with something like: {$recordSet[col]->getSomeInformation()}.



[ Top ]


Method Detail

Structures_DataGrid_Renderer_Smarty (Constructor)   [line 167]

Structures_DataGrid_Renderer_Smarty Structures_DataGrid_Renderer_Smarty( )

Constructor
  • Access: public

[ Top ]

buildBody   [line 314]

void buildBody( )

Handles building the body of the table
  • Access: protected

[ Top ]

buildHeader   [line 252]

void buildHeader( &$columns, array $columns)

Build the header
  • Access: protected

Parameters:

array   $columns   —  Columns' fields names and labels
   &$columns   — 

[ Top ]

defaultCellFormatter   [line 450]

string defaultCellFormatter( string $value)

Default formatter for all cells
  • Return: Formatted cell value
  • Access: protected

Parameters:

string   $value   —  Cell value

[ Top ]

finalize   [line 343]

void finalize( )

Assign the computed variables to the Smarty container, if any
  • Access: protected

[ Top ]

flatten   [line 367]

array flatten( )

Return the computed variables
  • Return: Array with smarty variable names as keys
  • Access: protected

[ Top ]

getContainer   [line 217]

object Smarty &getContainer( )

Return the currently used Smarty object
  • Return: or PEAR_Error object

[ Top ]

init   [line 227]

void init( )

Initialize the Smarty container
  • Access: protected

[ Top ]

render   [line 381]

void render( )

Discard the unsupported render() method

This Smarty driver does not support the render() method. It is required to use the setContainer() (or Structures_DataGrid::fill()) method in order to do anything with this driver.


[ Top ]

setContainer   [line 194]

mixed setContainer( &$smarty, object $smarty)

Attach an already instantiated Smarty object
  • Return: True or PEAR_Error

Parameters:

object   $smarty   —  Smarty container
   &$smarty   — 

[ Top ]

setSmarty   [line 207]

void setSmarty( object Smarty &$smarty)

Attach a Smarty instance
  • Deprecated: Use setContainer() instead
  • Access: public

Parameters:

object Smarty   &$smarty   —  instance

[ Top ]

smartyGetPaging   [line 399]

string smartyGetPaging( array $params, &$smarty, object $smarty)

Smarty custom function "getPaging"

This is only meant to be called from a smarty template, using the expression: {getPaging <options>}

<options> are any Pager::factory() options

  • Return: Paging HTML links
  • Access: public

Parameters:

array   $params   —  Options passed from the Smarty template
object   $smarty   —  Smarty object
   &$smarty   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:40:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.