Sitellite Application Framework
Class Tree         Index         All Elements

Class: DataGrid

Source Location: Program_Root/GUI/DataGrid.php

Class Overview


Generates tables of data with automatic next/previous paging, sorting by column headers, and add/edit/delete capabilities (via linking to specified URLs. Also handles the retrieval of the data from the specified table automatically.


Author(s)

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 42]
Generates tables of data with automatic next/previous paging, sorting by column headers, and add/edit/delete capabilities (via linking to specified URLs. Also handles the retrieval of the data from the specified table automatically.


1 <?php
2
3 loader_import ('saf.GUI.DataGrid');
4
5 $dg = new DataGrid (
6 'sitellite_user',
7 array (
8 'username' => 'User ID',
9 'lastname' => 'Last Name',
10 'firstname' => 'First Name',
11 'company' => 'Company',
12 'email' => 'Email Address',
13 )
14 );
15
16 page_title ('Member List');
17
18 $dg->setEditUrl ('/index/user-edit-action');
19 $dg->setDeleteUrl ('/index/user-delete-action');
20 $dg->setAddUrl ('/index/user-add-action');
21
22 echo $dg->draw ();
23
24 ? >




Tags:

access:  public


[ Top ]


Class Variables

$addUrl =  false

[line 55]


Type:   mixed


[ Top ]

$collection =

[line 44]


Type:   mixed


[ Top ]

$deleteUrl =  false

[line 56]


Type:   mixed


[ Top ]

$editUrl =  false

[line 54]


Type:   mixed


[ Top ]

$error =

[line 59]


Type:   mixed


[ Top ]

$fields =

[line 46]


Type:   mixed


[ Top ]

$footer =  ''

[line 52]


Type:   mixed


[ Top ]

$header =  ''

[line 51]


Type:   mixed


[ Top ]

$limit =

[line 45]


Type:   mixed


[ Top ]

$list =  false

[line 48]


Type:   mixed


[ Top ]

$remember = array ()

[line 49]


Type:   mixed


[ Top ]

$skipHeaders = array ()

[line 50]


Type:   mixed


[ Top ]

$template =  '

{if obj.addUrl}
   <p><a href="{addUrl}?collection={collection}">{intl Add Item}</a></p>
{end if}

{alt #eee #fff}

{if obj.deleteUrl}
<script language="javascript" type="text/javascript">

var datagrid_select_switch = false;

function datagrid_select_all (f) {
   if (datagrid_select_switch == false) {
      for (i = 0; i < f.elements.length; i++) {
         f.elements[i].checked = true;
         datagrid_select_switch = true;
      }
   } else {
      for (i = 0; i < f.elements.length; i++) {
         f.elements[i].checked = false;
         datagrid_select_switch = false;
      }
   }
   return false;
}

function datagrid_confirm_delete () {
   return confirm (\'{intl Are you sure you want to delete the selected items?}\');
}

</script>

<form method="post" action="{deleteUrl}">
<input type="hidden" name="collection" value="{collection}" />
{filter none}
{rememberHiddenValues}
{end filter}
{end if}

{filter none}{header}{end filter}

<table border="0" cellpadding="3" width="100%">
   <tr>
      <td>{spt PAGER_TEMPLATE_FROM_TO}</td>
      <td align="right">{if pager.total}{spt PAGER_TEMPLATE_PREV_PAGE_LIST_NEXT}{end if}</td>
   </tr>
</table>

<table border="0" cellpadding="2" cellspacing="1" width="100%">
   <tr style="background-color: {alt/next}">
      {if obj.deleteUrl}
         <th width="52" valign="bottom">
            <input type="image" src="{site/prefix}/inc/app/cms/pix/icons/select-all.gif" alt="{intl Select All}" title="{intl Select All}" border="0" onclick="return datagrid_select_all (this.form)" />&nbsp;
            <input type="image" src="{site/prefix}/inc/app/cms/pix/icons/delete.gif" alt="{intl Delete Selected}" title="{intl Delete Selected}" border="0" onclick="return datagrid_confirm_delete ()" />
         </th>
      {end if}
      {loop obj.headers}
         {if in_array (loop.name, obj.skipHeaders)}
            <th>{loop/fullname}</th>
         {end if}
         {if else}
            <th><a href="{site/current}?offset={cgi/offset}&orderBy={loop/name}&sort={loop/getSort}{rememberParams}">{loop/fullname}</a>
            {if loop.isCurrent ()}
               <img src="{site/prefix}/inc/app/cms/pix/arrow.{cgi/sort}.gif" alt="{cgi/sort}" border="0" />
            {end if}
            </th>
         {end if}
      {end loop}
   </tr>
   {loop obj.list}
      <tr style="background-color: {alt/next}">
         {if obj.deleteUrl}
            <td align="center"><input type="checkbox" name="items[]" value="{loop/_key}" /></td>
         {end if}
         {loop loop._properties}
            {if in_array (loop._key, array_keys (obj.headers)) or in_array (loop[_key], array_keys (obj.headers))}
            {if obj.editUrl and loop._key eq obj.first_field}
               <td>
                  <a href="{editUrl}?collection={collection}&item={parent/_key}{rememberParams}">{filter datagrid_filter}{loop/_value}{end filter}</a>
               </td>
            {end if}
            {if else}
               <td>
                  {filter datagrid_filter}{loop/_value}{end filter}
               </td>
            {end if}
            {end if}
         {end loop}
      </tr>
   {end loop}
</table>

{filter none}{footer}{end filter}

{if obj.deleteUrl}
</form>
{end if}

   '

[line 58]


Type:   mixed


[ Top ]

$total =  0

[line 47]


Type:   mixed


[ Top ]

$type =  'db'

[line 43]


Type:   mixed


[ Top ]



Class Methods


constructor DataGrid [line 61]

DataGrid DataGrid( mixed $collection, mixed $fields, [mixed $limit = false])



[ Top ]

method draw [line 179]

void draw( )



[ Top ]

method filter [line 135]

void filter( mixed $name, [mixed $func = false])



[ Top ]

method getList [line 144]

void getList( )



[ Top ]

method primaryKey [line 73]

void primaryKey( mixed $field)



[ Top ]

method rememberValue [line 97]

void rememberValue( mixed $name, [mixed $value = false])



[ Top ]

method setAddUrl [line 81]

void setAddUrl( mixed $url)



[ Top ]

method setDeleteUrl [line 85]

void setDeleteUrl( mixed $url)



[ Top ]

method setEditUrl [line 77]

void setEditUrl( mixed $url)



[ Top ]

method skipHeader [line 89]

void skipHeader( mixed $name)



[ Top ]


Copyright © 2007, SIMIAN systems Inc.
All rights reserved. Privacy policy
Documentation generated on Tue, 13 Feb 2007 17:17:14 -0600 by Sitellite AppDoc and phpDocumentor 1.2.2