Documentation is available at timeinfo.php
- <?php
- /**
- * Class helpDeskTimeInfo
- * @package helpdesk
- * Copyright OSI 2005. All rights reserved.
- * It is expected that version 1.0 will be GPLed, but this interim work
- * is kept closed until 1.0 is ready.
- */
- // echo "<p>Start of " . __FILE__ . "</p>" ;
- $_timeinfo_saved_er = error_reporting (E_ALL | E_STRICT) ;
- /**
- * import ancillary functions
- */
- require_once("misc.php") ;
- /**
- * import HD core
- */
- require_once("core.php");
- /**
- * VIEW: Time value, drupal style
- * @subpackage helpdesk_time
- */
- class helpdeskTimeValue
- {
- /**
- * POSIX timestamp
- * @var integer
- */
- public $ts ;
- /**
- * is it to be displayed in views/forms
- * @var boolean
- */
- public $isShown ;
- /**
- * is it to be enabled in forms
- * @var boolean
- */
- public $isEnabled;
- /**
- * HTML render size in forms
- * @var integer
- */
- public $size;
- /**
- * HTML max length in forms
- * @var integer
- */
- public $maxLength;
- /**
- * format code for drupal's format_date
- * @var string
- * @see http://drupaldocs.org/api/4.6/function/format_date API
- */
- public $format;
- /**
- * HTML name attribute in forms
- * @var string
- */
- public $name ;
- /**
- * Init default value: beware, they are mutually dependent
- * @return void
- */
- function __construct()
- {
- $this->size = 16 ;
- $this->maxLength = 16 ;
- $this->format = 'small' ; // do not localize
- }
- /**
- * formats a time value for the use of a form
- * 0 or empty displayed as empty
- * @return string HTML for form field
- */
- function form_field ()
- {
- $disabled = array ('disabled' => 'disabled') ; // Do not localize !
- if (isset($this->ts) && ($this->ts > 0))
- $ret = format_date($this->ts, $this->format) ;
- else
- $ret = '' ;
- $ret = form_textfield(
- '',
- $this->name,
- $ret,
- $this->size,
- $this->maxLength,
- NULL,
- ($this->isEnabled ? NULL : $disabled),
- TRUE) ;
- return $ret;
- }
- }
- //===========================================================================================
- /**
- * TimeInfo class implementing S.A.M.E. properties
- * @subpackage helpdesk_time
- */
- class helpdeskTimeInfo extends helpdeskObject
- {
- /**
- * Indexed array of S.A.M.E. helpdeskTimeValues
- * @var array
- */
- public $values ;
- /**
- * Title when TI is displayed in a form
- * @var string plain text
- */
- public $title ;
- /**
- * description for forms
- * @var string
- */
- public $description;
- /**
- * Enumerate S.A.M.E. properties.
- * Defining the array as a global doesn't work (why?) so
- * I return this from a method. It belongs in the class anyway
- * @return array
- */
- function enumKeys ()
- {
- return array('S', 'A', 'M', 'E') ;
- }
- /**
- * Enumerate the titles of the S.A.M.E. properties
- * @return array
- */
- function enumKeyTitles ()
- {
- return array('S' => t('Start'), 'A' => t('Access'), 'M' => t('Modify'), 'E' => t('End'));
- }
- /**
- * constructor MUST run to initialize SAME array
- * @return void
- */
- function __construct()
- {
- $this->values = array();
- foreach ($this->enumKeys() as $key)
- $this->values[$key] = new helpdeskTimeValue();
- }
- /**
- * initialize fields in existing timeinfo from param array
- * @param array $ar S.A.M.E. timestamps. Cheating: it should be an object
- * @param boolean $fromDB
- * @return void
- */
- function init($ar, $fromDB)
- {
- foreach ($this->enumKeys() as $key)
- {
- $this->values[$key]->ts = $ar[ $key ];
- $this->values[$key]->isShown = $ar[ "show$key"];
- $this->values[$key]->isEnabled = $ar["enabled$key"];
- }
- }
- /**
- * Builds the form representation of a helpdesk_timeinfo
- * @param boolean $enabledS If function show the S column, is it enabled ?
- * @return string HTML form code
- */
- function form()
- {
- $ret = '' ;
- $header = array () ;
- $row = array () ;
- foreach ($this->enumKeyTitles() as $key => $value)
- {
- if ($this->values[$key]->isShown)
- {
- array_push ($header, $value) ;
- array_push ($row, $this->values[$key]->form_field()) ;
- }
- }
- $items = theme_table ($header, array ($row));
- $ret .= form_group
- (
- $this->title,
- $items,
- $this->description,
- NULL) ;
- unset ($items) ;
- return $ret ;
- }
- /**
- * display a timeinfo, typically for hook_view
- * @return string HTML
- */
- function view()
- {
- $header = array();
- foreach ($this->enumKeys() as $key)
- {
- if ($this->values[$key]->isShown)
- { $header[] = $this->values[$key] ; }
- }
- $output = theme_table($header, NULL);
- return $output;
- }
- }
- error_reporting($_timeinfo_saved_er) ;
- unset ($_timeinfo_saved_er) ;
- // echo "<p>End of " . __FILE__ . "</p>" ;
- ?>
Documentation generated on Tue, 01 Nov 2005 23:15:03 +0100 by phpDocumentor 1.3.0RC3