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

Source for file controller.php

Documentation is available at controller.php

  1. <?php
  2. /**
  3.  * <b>Class Description</b>: The Parent Class for all Controller Classes in the System. It contains methods for shaping data that is provided
  4.  * to the controller by a Model object into a format required by the Smarty Template. It also offers functionality for
  5.  * importing information contained in system configuration files.  See {@link controllersPackage.php} for a description of the rvtwo controllers class hierarchy.
  6.  * Created On: 30 March 2009
  7.  * @author Jan van der Breggen
  8.  * @package Controllers
  9.  * @subpackage ParentClasses
  10.  ***/
  11.  
  12.  
  13. class Controller extends RvTwoObject
  14. {
  15.     /**
  16.      * Array containing all data that is passed to the Smarty View
  17.      *
  18.      * @var array 
  19.      */
  20.     public $View = array();
  21.     public $viewTemplate;
  22.     public $uiElements;
  23.     protected $package;
  24.     protected $subPackage;
  25.     protected $className;
  26.  
  27.      
  28.      
  29.  
  30.     /*********************************************************************************************
  31.      * Methods for shaping data in preparation for
  32.      * passing it to the View for display
  33.      **********************************************************************************************/
  34.  
  35.    
  36.     /**
  37.      * converts a rows_array as returned by the ORM and DB classes into an associative array.
  38.      * The returned array contains a set of arrays that each
  39.      * represent a column of the original query result. These individual arrays are
  40.      * associative arrays, the key being the primary key (or other unique value)
  41.      * of the database record.  The function assumes that this is the first column in the
  42.      * query result. If this is not the case the $keyColumn argument should be provided.
  43.      *
  44.      * @param array 'rows_array' as returned by DB class $array. The rows_array must contain a value that uniquely identifies the database tupple
  45.      * @param integer Indicating the column containing the 'key' column
  46.      * @return array  as described above
  47.      */
  48.     function convertRowsArrayToColumnsArray($array$keyColumn 0)
  49.     {
  50.       
  51.          
  52.         if (!empty($array[0]))
  53.         {
  54.             $keys array_keys($array[0]);
  55.             foreach($array as $record)
  56.             {
  57.  
  58.                 foreach ($keys as $key)
  59.                 {
  60.                     $result[$key][$record[$keys[$keyColumn]]] $record[$key];
  61.                 }
  62.  
  63.  
  64.             }
  65.         }
  66.  
  67.         return $result;
  68.     }
  69.     
  70. function makeLanguageMenuArray($menuArray)
  71.     {
  72.         $result array();
  73.         foreach ($menuArray as $key => $value{
  74.             $result[$GLOBALS['lang'][trim($key)]]=$value;
  75.         }
  76.         return $result;
  77.     }
  78.     
  79.     function applyAccessRestrictionsToMenuArray($array)
  80.     {
  81.         return $array;
  82.     }
  83.     
  84.     
  85.     /**
  86.      * Converts the contents of a screen menu configuration file stored in the filesystem location specified by the PATH_CONF constant into an associative array.
  87.      * The lefthand value of each line in the config file is treated as an key value of the $GLOBALS['lang']
  88.      * array.  In other words: it is replaced with the corresponding value in the selected
  89.      * application language. This method should only be used when no access restrictions or other operations need
  90.      * to be done on the screen menu as the resulting array will have the menu item names
  91.      * replaced by the label in the system language.
  92.      *
  93.      * @param string $fileName 
  94.      * @param string $lineDelimiter - character that delimits an entry in the config file
  95.      * @param  string $valueDelimiter - character that separates name and value of an entry in the config file
  96.      * @return associative array $config representing the menu configuration file
  97.      */
  98.     function convertMenuConfigFileToArray($fileName$lineDelimiter ';',$valueDelimiter ',' )
  99.     {
  100.  
  101.         $file explode($lineDelimiterfile_get_contents(PATH_CONF "/$fileName"));
  102.         $config array();
  103.         foreach($file as $line)
  104.         {
  105.             $values explode($valueDelimiter$line);
  106.             if (count($values)==2){
  107.                 $config[$GLOBALS['lang'][trim($values[0])]] trim($values[1]);
  108.             }
  109.         }
  110.         return $config;
  111.  
  112.     }
  113.     
  114.     function setPackageInfo($subPackageName$packageName "Controllers"{
  115.         $this->className = get_class($this);
  116.         $this->package = $packageName;
  117.         $this->subPackage = $subPackageName;
  118.         $this->View['phpDoc'URL_PHP_DOC."$this->package/$this->subPackage/$this->className".'.html';
  119.     }
  120.     
  121. }
  122. ?>

Documentation generated on Mon, 18 May 2009 11:21:47 +0200 by phpDocumentor 1.4.1