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

Source for file RunningClock.class.php

Documentation is available at RunningClock.class.php

  1. <?php
  2. /**
  3.  * @package    html
  4.  * @subpackage components
  5.  */
  6.  
  7. ifdefined"LANG" ) )
  8.   /**
  9.    * Including language specific messages.
  10.    */
  11.   includeCLASSPATH."core/lang_spec_values/".LANG.".inc.php" );
  12. else
  13. {
  14.   echo "<h3>You have to define the constant LANG!</h3>\r\n";
  15.   echo "Example for german: define( 'LANG', 'de' );\r\n";
  16.   exit();
  17. }
  18.  
  19. if!defined"CLASSPATH" ) )
  20. {
  21.   echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
  22.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
  23.   exit();
  24. }
  25.  
  26. /**
  27.  * Including the layer-class for the clock.
  28.  */
  29. require_onceCLASSPATH."html/HTMLLayer.class.php" );
  30. /**
  31.  * Including the javascript-class.
  32.  */
  33. require_onceCLASSPATH."html/JavaScript.class.php" );
  34.  
  35. /**
  36.  * A class to generate a clock that refreshes every Second.
  37.  *
  38.  * @package    html
  39.  * @subpackage components
  40.  * @version    1.2
  41.  * @author     Daniel Pl&uuml;cken <daniel@debakel.net>
  42.  * @license    http://www.gnu.org/copyleft/lesser.html
  43.  *              GNU Lesser General Public License
  44.  * @copyright  Copyright (c) 2004 Daniel Pluecken <daniel@debakel.net>
  45.  *
  46.  *  This library is free software; you can redistribute it and/or
  47.  *  modify it under the terms of the GNU Lesser General Public
  48.  *  License as published by the Free Software Foundation; either
  49.  *  version 2.1 of the License.
  50.  *
  51.  *  This library is distributed in the hope that it will be useful,
  52.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  53.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  54.  *  GNU Lesser General Public License for more details.
  55.  *
  56.  *  You should have received a copy of the GNU Lesser General
  57.  *  Public License along with this library; if not, write to the
  58.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  59.  *  Boston, MA 02111-1307 USA
  60.  */
  61. class RunningClock extends HTMLLayer
  62. {
  63.    /**
  64.     * @var    JavaScript  $js 
  65.     * @access private
  66.     */
  67.    var $js;
  68.  
  69.  
  70.  
  71.    /**
  72.     * Constructor.
  73.     *
  74.     * @version 1.1
  75.     * @since   1.0
  76.     * @author  Daniel Pl&uuml;cken <daniel@debakel.net>
  77.     * @access  public
  78.     * @param   $name The value of the name- and id-attribute of this layer.
  79.     * @return  void 
  80.     */
  81.    function RunningClock$name "clock" )
  82.    {
  83.      parent :: HTMLLayer$name );
  84.      parent :: setBody"[init]" );
  85.      $this->visible = "show";
  86.      
  87.      $this->js = new JavaScript();
  88.      $this->js->setLeadingZeros();
  89.      $this->js->add(
  90.                "  function getformattedMonth( month )\r\n"
  91.               ."  {\r\n"
  92.               ."     var monthArr = new Array(\r\n"
  93.               ."                               'Januar',\r\n"
  94.               ."                               'Februar',\r\n"
  95.               ."                               'M%E4rz',\r\n"
  96.               ."                               'April',\r\n"
  97.               ."                               'Mai',\r\n"
  98.               ."                               'Juni',\r\n"
  99.               ."                               'Juli',\r\n"
  100.               ."                               'August',\r\n"
  101.               ."                               'September',\r\n"
  102.               ."                               'Oktober',\r\n"
  103.               ."                               'November',\r\n"
  104.               ."                               'Dezember'\r\n"
  105.               ."                             );\r\n"
  106.               ."     return monthArr[month];\r\n"
  107.               ."  }\r\n\r\n"
  108.                    );
  109.      $this->js->add(
  110.                "  function getFormattedDate( dateobj )\r\n"
  111.               ."  {\r\n"
  112.               ."    return '' + leadingZeros( dateobj.getDate(), 2 )\r\n"
  113.               ."         + '. ' + unescape( getformattedMonth( "
  114.                                                 ."dateobj.getMonth() ) )\r\n"
  115.               ."         + ' ' + dateobj.getFullYear()\r\n"
  116.               ."         + ' - ' + leadingZeros( dateobj.getHours(), 2 )\r\n"
  117.               ."         + ':' + leadingZeros( dateobj.getMinutes(), 2 )\r\n"
  118.               ."         + ':' + leadingZeros( dateobj.getSeconds(), 2 )\r\n"
  119.               ."         + ' Uhr';\r\n"
  120.               ."  }\r\n\r\n"
  121.                    );
  122.      $this->js->add(
  123.                "  function showDate( container )\r\n"
  124.               ."  {\r\n"
  125.               ."     var now = new Date();\r\n\r\n"
  126.               ."     document.getElementById( container )\r\n"
  127.               ."     .firstChild.nodeValue = '' + getFormattedDate( now );\r\n"
  128.               ."  }\r\n\r\n"
  129.               ."  showDate( '".$this -> name."' );\r\n"
  130.               ."  window.setInterval( \"showDate( '"
  131.                                        .$this -> name."' );\", 1000 );\r\n\r\n"
  132.                    );
  133.    }
  134.  
  135.  
  136.  
  137.    /**
  138.     * Returns a generated string based on the attributes of this HTML-Object.
  139.     *
  140.     * @version 1.4
  141.     * @since   1.0
  142.     * @author  Daniel Pl&uuml;cken <daniel@debakel.net>
  143.     * @access  public
  144.     * @return  string 
  145.     */
  146.    function get()
  147.    return parent::get()."\r\n".$this->js->get()}
  148. // END of class RunningClock
  149. ?>

Documentation generated on Thu, 05 Jun 2008 19:14:55 +0200 by phpDocumentor 1.4.1