Horde 4 CS, PHP5 for Kronolith_FreeBusy_*
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 26 Jan 2011 16:22:57 +0000 (11:22 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 26 Jan 2011 18:58:34 +0000 (13:58 -0500)
kronolith/lib/FreeBusy/View.php
kronolith/lib/FreeBusy/View/Day.php
kronolith/lib/FreeBusy/View/Month.php
kronolith/lib/FreeBusy/View/Week.php
kronolith/lib/FreeBusy/View/Workweek.php

index fc5f0da..dea3937 100644 (file)
  * @author  Jan Schneider <jan@horde.org>
  * @package Kronolith
  */
-class Kronolith_FreeBusy_View {
+class Kronolith_FreeBusy_View
+{
+    protected $_requiredMembers = array();
+    protected $_optionalMembers = array();
+    protected $_requiredResourceMembers = array();
+    protected $_optionalResourceMembers = array();
+    protected $_timeBlocks = array();
 
-    var $_requiredMembers = array();
-    var $_optionalMembers = array();
-    var $_requiredResourceMembers = array();
-    var $_optionalResourceMembers = array();
-    var $_timeBlocks = array();
+    protected $_startHour;
+    protected $_endHour;
 
-    var $_startHour;
-    var $_endHour;
+    protected $_start;
+    protected $_end;
 
-    var $_start;
-    var $_end;
-
-    function addRequiredMember($vFreebusy)
+    /**
+     * Adds a required attendee
+     *
+     * @param Kronolith_Freebusy $vFreebusy
+     */
+    public function addRequiredMember(Kronolith_Freebusy $vFreebusy)
     {
         $this->_requiredMembers[] = clone $vFreebusy;
     }
 
-    function addOptionalMember($vFreebusy)
+    /**
+     * Adds an optional attendee
+     *
+     * @param Kronolith_Freebusy $vFreebusy
+     */
+    public function addOptionalMember(Kronoolith_Freebusy $vFreebusy)
     {
         $this->_optionalMembers[] = clone $vFreebusy;
     }
 
-    function addOptionalResourceMember($vFreebusy)
+    /**
+     * Adds an optional resource
+     *
+     * @param Kronolith_Freebusy $vFreebusy
+     */
+    public function addOptionalResourceMember(Kronolith_Freebusy $vFreebusy)
     {
         $this->_optionalResourceMembers[] = clone $vFreebusy;
     }
 
-    function addRequiredResourceMember($vFreebusy)
+    /**
+     * Adds a required resource
+     *
+     * @param Kronolith_Freebusy $vFreebusy
+     */
+    public function addRequiredResourceMember(Kronolith_Freebusy $vFreebusy)
     {
         $this->_requiredResourceMembers[] = clone $vFreebusy;
     }
 
-    function render($day = null)
+    /**
+     * Renders the fb view
+     *
+     * @global Horde_Prefs $prefs
+     * @param  Horde_Date $day  The day to render
+     *
+     * @return string  The html of the rendered fb view.
+     */
+    public function render($day = null)
     {
         global $prefs;
 
@@ -140,8 +168,7 @@ class Kronolith_FreeBusy_View {
             $html .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/section.html');
         }
 
-        // Required Resources
-        //if (count($this->_requiredResourceMembers) > 0) {
+        // Resources
         if (count($this->_requiredResourceMembers) > 0 || count($this->_optionalResourceMembers) > 0) {
             $template = $GLOBALS['injector']->createInstance('Horde_Template');
             $rows = '';
@@ -170,28 +197,6 @@ class Kronolith_FreeBusy_View {
             $html .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/section.html');
         }
 
-//        // Optional Resources
-//        if (count($this->_optionalResourceMembers) > 0) {
-//            $template = $GLOBALS['injector']->createInstance('Horde_Template');
-//            $rows = '';
-//            foreach ($this->_optionalResourceMembers as $member) {
-//                $member->simplify();
-//                $blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"));
-//                $template = $GLOBALS['injector']->createInstance('Horde_Template');
-//                $template->set('blocks', $blocks);
-//                $template->set('name', $member->getName());
-//                $rows .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/row.html');
-//            }
-//            $template = $GLOBALS['injector']->createInstance('Horde_Template');
-//            $template->set('title', _("Optional Resources"));
-//            $template->set('rows', $rows);
-//            $template->set('span', count($this->_timeBlocks));
-//            $template->set('hours', $hours_html);
-//            $template->set('legend', '');
-//            $html .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/section.html');
-//        }
-
-
         // Possible meeting times.
         $optimal->setAttribute('ORGANIZER', _("All Attendees"));
         $blocks = $this->_getBlocks($optimal,
@@ -253,7 +258,7 @@ class Kronolith_FreeBusy_View {
      * @return mixed  The newly created concrete Kronolith_FreeBusy_View
      *                instance, or false on an error.
      */
-    function factory($view)
+    static public function factory($view)
     {
         $driver = basename($view);
         $class = 'Kronolith_FreeBusy_View_' . $driver;
@@ -279,7 +284,7 @@ class Kronolith_FreeBusy_View {
      * @return mixed  The created concrete Kronolith_FreeBusy_View instance, or
      *                false on an error.
      */
-    function &singleton($view)
+    static public function &singleton($view)
     {
         static $instances = array();
 
@@ -290,7 +295,17 @@ class Kronolith_FreeBusy_View {
         return $instances[$view];
     }
 
-    function _getBlocks($member, $periods, $blockfile, $label)
+    /**
+     * Render the blocks
+     *
+     * @param Horde_Icalendar_Vfreebusy $member  Member's freebusy info
+     * @param array $periods                     Free periods
+     * @param string $blockfile                  Template file to use for blocks
+     * @param string $label                      Label to use
+     *
+     * @return string  The block html
+     */
+    protected function _getBlocks($member, $periods, $blockfile, $label)
     {
         $template = $GLOBALS['injector']->createInstance('Horde_Template');
         $template->set('label', $label);
index db63728..bbd2a94 100644 (file)
  * @author  Jan Schneider <jan@horde.org>
  * @package Kronolith
  */
-class Kronolith_FreeBusy_View_Day extends Kronolith_FreeBusy_View {
+class Kronolith_FreeBusy_View_Day extends Kronolith_FreeBusy_View
+{
+    public $view = 'day';
 
-    var $view = 'day';
-
-    function _title()
+    protected function _title()
     {
         global $registry, $prefs;
 
@@ -31,7 +31,7 @@ class Kronolith_FreeBusy_View_Day extends Kronolith_FreeBusy_View {
             . '</a>';
     }
 
-    function _hours()
+    protected function _hours()
     {
         global $prefs;
 
@@ -49,7 +49,7 @@ class Kronolith_FreeBusy_View_Day extends Kronolith_FreeBusy_View {
         return $hours_html;
     }
 
-    function _render($day = null)
+    protected function _render($day = null)
     {
         $this->_start = new Horde_Date($day);
         $this->_start->hour = $this->_startHour;
index 7038891..4759a75 100644 (file)
  * @author  Jan Schneider <jan@horde.org>
  * @package Kronolith
  */
-class Kronolith_FreeBusy_View_Month extends Kronolith_FreeBusy_View {
+class Kronolith_FreeBusy_View_Month extends Kronolith_FreeBusy_View
+{
+    /**
+     * This view type
+     *
+     * @var string
+     */
+    public $view = 'month';
 
-    var $view = 'month';
-    var $_days = 30;
+    /**
+     * Number of days
+     *
+     * @var integer
+     */
+    protected $_days = 30;
 
-    function _title()
+
+    protected function _title()
     {
         $end = new Horde_Date($this->_start);
         $end->mday += $this->_days - 1;
@@ -32,7 +44,7 @@ class Kronolith_FreeBusy_View_Month extends Kronolith_FreeBusy_View {
             . '</a>';
     }
 
-    function _hours()
+    protected function _hours()
     {
         global $prefs;
 
@@ -81,7 +93,7 @@ class Kronolith_FreeBusy_View_Month extends Kronolith_FreeBusy_View {
         return $hours_html;
     }
 
-    function _render($day = null)
+    protected function _render($day = null)
     {
         $this->_start = new Horde_Date($day);
         $this->_start->mday = 1;
index 1db9f64..4c7e429 100644 (file)
  * @author  Jan Schneider <jan@horde.org>
  * @package Kronolith
  */
-class Kronolith_FreeBusy_View_Week extends Kronolith_FreeBusy_View {
+class Kronolith_FreeBusy_View_Week extends Kronolith_FreeBusy_View
+{
+    /**
+     * This view type
+     *
+     * @var string
+     */
+    public $view = 'week';
 
-    var $view = 'week';
-    var $_days = 7;
+    /**
+     * Number of days
+     *
+     * @var integer
+     */
+    protected $_days = 7;
 
-    function _title()
+    protected function _title()
     {
         global $prefs;
 
@@ -35,7 +46,7 @@ class Kronolith_FreeBusy_View_Week extends Kronolith_FreeBusy_View {
             . '</a>';
     }
 
-    function _hours()
+    protected function _hours()
     {
         global $prefs;
 
@@ -77,7 +88,7 @@ class Kronolith_FreeBusy_View_Week extends Kronolith_FreeBusy_View {
         return $hours_html;
     }
 
-    function _render($day = null)
+    protected function _render($day = null)
     {
         $this->_start = new Horde_Date(Date_Calc::beginOfWeek($day->mday, $day->month, $day->year, '%Y%m%d000000'));
         $this->_end = new Horde_Date($this->_start);
index e776a96..9625649 100644 (file)
  * @author  Jan Schneider <jan@horde.org>
  * @package Kronolith
  */
-class Kronolith_FreeBusy_View_Workweek extends Kronolith_FreeBusy_View_Week {
-
+class Kronolith_FreeBusy_View_Workweek extends Kronolith_FreeBusy_View_Week
+{
+   /**
+     * This view type
+     *
+     * @var string
+     */
     var $view = 'workweek';
+
+    /**
+     * Number of days
+     *
+     * @var integer
+     */
     var $_days = 5;
 
 }