Source for file cell.php

Documentation is available at cell.php

  1. <?php
  2. /**
  3. * Booking cell object for display in a table
  4. *
  5. @author    Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage Bookings
  11. */
  12.  
  13. /** Load ancillary functions */
  14. require_once 'inc/typeinfo.php';
  15.  
  16. /** cell is in the middle of a booking */
  17. define('MIDDLE_BOOKING',    1);
  18. /** cell is at the start of a booking */
  19. define('START_BOOKING',     2);
  20. /** cell is at the start of a day's calendar display */
  21. define('START_BOOKING_DAY'4);
  22.  
  23. /**
  24. * Booking cell object for display in a table
  25. *
  26. @package    Bumblebee
  27. @subpackage Bookings
  28. */
  29. class BookingCell {
  30.   /** @var TimeSlot   Vacancy or Booking object for this cell    */
  31.   var $booking;
  32.   /** @var boolean    Cell is at start of booking   */
  33.   var $isStart;
  34.   /** @var boolean    Cell is at start of day  */
  35.   var $isStartDay;
  36.   /** @var integer    Number of rows in cell  */
  37.   var $rows;
  38.   /** @var array      list of class names to use for cells */
  39.   var $rotaClass;
  40.   /** @var string     data on which to rotate through classes */
  41.   var $roton;
  42.   /** @var string     class name to use if the cell is today  */
  43.   var $todayClass;
  44.  
  45.   /**
  46.   *  Create a new display cell
  47.   *
  48.   * @param TimeSlot $booking  the timeslot (Booking or Vacancy object) to be represented
  49.   * @param integer  $start    type of cell (START_BOOKING, START_BOOKING_DAY, MIDDLE_BOOKING)
  50.   * @param integer  $rows     number of rows this cell should occupy
  51.   */
  52.   function BookingCell(&$book$start=START_BOOKING$rows=1{
  53.     $this->booking = $book;
  54.     $this->isStart    = $start START_BOOKING;
  55.     $this->isStartDay = $start START_BOOKING_DAY;
  56.     $this->rows    = $rows;
  57.   }
  58.  
  59.   /**
  60.   * use a number of different html/css classes for displaying cells
  61.   *
  62.   * (unused?)
  63.   *
  64.   * @param array  $arr       list of class names
  65.   * @param string $roton     data on which to rotate through classes
  66.   */
  67.   function addRotateClass($arr$roton{
  68.     $this->rotaClass   = $arr;
  69.     $this->roton = $roton;
  70.   }
  71.  
  72.   /**
  73.   * html/css class to use if this day is today
  74.   *
  75.   * @param string  $c   class name
  76.   */
  77.   function addTodayClass($c{
  78.     $this->todayClass   = $c;
  79.   }
  80.  
  81.   /**
  82.   * prepare html representation of the cell
  83.   *
  84.   * @param string  $class   class name to use for the cell
  85.   * @param string  $href    base href to be used for making links to book/edit
  86.   * @param boolean $popup   provide a popup layer with extra details of the booking
  87.   * @param boolean $isadmin provide an admin view of the data
  88.   */
  89.   function display($class$href$popup=false$isadmin=0{
  90.     $this->_makePopupScript();
  91.     $t '';
  92.     if ($this->isStart || $this->isStartDay{
  93.       $class .= ' '.$this->booking->baseclass;
  94.       $popupControl='';
  95.       if ($popup{
  96.         $message '<b>'.$this->booking->generateBookingTitle().'</b><br />'
  97.                   .$this->booking->generateLongDescription();
  98.         $message rawurlencode($message);
  99.         $popupControl 'onMouseOver="showCalendarPopup(\''.$message.'\');" '
  100.                        .'onMouseOut="hideCalendarPopup();" ';;
  101.       }
  102.       $t .= '<td rowspan="'.$this->rows.'" class="'.$class.'" '
  103.            .$popupControl
  104.            .'title="'.$this->booking->generateBookingTitle().'">';
  105.       $this->booking->href = $href;
  106.       $t .= $this->booking->displayInCell($isadmin);
  107.       $t .= '</td>';
  108.     else {
  109.       $t .= '<!-- c:'.xssqw($this->booking->id).'-->';
  110.     }
  111.     return $t;
  112.   }
  113.  
  114.   function _makePopupScript({
  115.     static $onceOnly false;
  116.  
  117.     if ($onceOnlyreturn;
  118.     $onceOnly true;
  119.  
  120.     $width 500;
  121.     $offsety 50;
  122.     echo "
  123.       <script type='text/javascript'>
  124.       function showCalendarPopup(message{
  125.         showPopup(message$width$offsety);
  126.       }
  127.       function hideCalendarPopup() {
  128.         return hidePopup();
  129.       }
  130.       </script>
  131.     ";
  132.   }
  133.  
  134.  
  135. //class BookingCell
  136. ?>

Documentation generated on Tue, 06 Mar 2007 10:01:01 +0000 by phpDocumentor 1.3.0