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

Source for file function.querytable.php

Documentation is available at function.querytable.php

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7.  
  8. /**
  9.  * Experimental work not finished yet
  10.  * An attempt to componentize all tables showing query results
  11.  
  12.  * Usage:
  13.  * {querytable
  14.  *    table =""   (Table or tables, example wiki_pages,users)
  15.  *    template = "" (Template to be used for table rows, put them in templates/tables)
  16.  *
  17.  *    where = "" (Where condition for the query)
  18.  *    columns="col1,col2,col3" (Columns to be selected from the query, default = *)
  19.  *    colalign="left,center,right" (Alignement for columns you can also use the template for this)
  20.  *    sort_column = "col2" (Column to sort the data initially)
  21.  *    sort_order = "desc" (Sort order)
  22.  *    max_rows = "10" (Max number of rows to display per page)
  23.  *    height = "" (Height for the table area)
  24.  *    directpagination = "0" (Use directlinks to pages)
  25.  *    combopagination = "0" (Use a combo to directly jump to a page)
  26.  *    tableclass = "normal" (CSS class name for the table)
  27.  *    columnheadingclass = "normal" (CSS class name for the columnheadings)
  28.  *    oddrowclass = "odd"
  29.  *    evenrowclass = "even"
  30.  * }
  31.  */
  32.  
  33.  
  34. //SECURITY HERE!
  35.  
  36. function smarty_function_querytable($params&$gBitSmarty{
  37.     global $gBitSystem;
  38.     extract($params);
  39.     //Security here
  40.     $arguments Array('table','template','tableclass','where',
  41.                        'columns','height',
  42.                        'sort_column','sort_order','colalign','columnheadingclass',
  43.                        'max_rows','offset','total','directpagination',
  44.                        'combopagination');
  45.     
  46.     if(!isset($table)) {return "Table is a mandatory argument to querytable plugin!";}
  47.     if(!isset($template)) {return "Template is a mandatory argument to querytable plugin!";}
  48.     if(!isset($tableclass)) $tableclass='normal';
  49.     if(!isset($oddrowclass)) $oddrowclass="odd";
  50.     if(!isset($where)) $where="";
  51.     if(!isset($evenrowclass)) $evenrowclass="even";
  52.     if(!isset($columns)) $columns='*';
  53.     if(!isset($height)) $height=400;
  54.     if(!isset($directpagination)) $directpagination=0;
  55.     if(!isset($combopagination)) $combopagination=0;
  56.     if(!isset($max_rows)) $max_rows 20;
  57.     if(!isset($offset)) $offset 0;
  58.     if(!isset($total)) $total 0;
  59.     if(!isset($sort_column)) $sort_column='';
  60.     if(!isset($sort_order)) $sort_order='';
  61.     if(!isset($colalign)) $colalign='left';
  62.     if(!isset($columnheadingclass)) $columnheadingclass='heading';
  63.     $columns urlencode($columns);
  64.     $output "<iframe marginwidth='4px' marginheight='4px' width='100%' height='$height' frameborder='0' scrolling='auto' src='querytable.php?f=1";
  65.     foreach($arguments as $arg{
  66.         $val = $$arg;
  67.         $output.="&amp;$arg=$val";
  68.     }
  69.     $output.="'></iframe>";
  70.     
  71.     return $output;
  72.  
  73. }
  74.  
  75.  
  76.  
  77. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:39 +0000 by phpDocumentor 1.5.0-lsces