Code Search for Developers
 
 
  

calendar.php from Group-Office groupware at Krugle


Show calendar.php syntax highlighted

<?php

/**
 *  File: calendar.php | (c) dynarch.com 2004
 *  Distributed as part of "The Coolest DHTML Calendar"
 *  under the same terms.
 *  -----------------------------------------------------------------
 *  This file implements a simple PHP wrapper for the calendar.  It
 *  allows you to easily include all the calendar files and setup the
 *  calendar by instantiating and calling a PHP object.
 */

define('NEWLINE', "\n");

class DHTML_Calendar {
    var $calendar_lib_path;

    var $calendar_file;
    var $calendar_lang_file;
    var $calendar_setup_file;
    var $calendar_theme_file;
    var $calendar_options;

    function DHTML_Calendar($calendar_lib_path = '/calendar/',
                            $lang              = 'en',
                            $theme             = 'calendar-win2k-1',
                            $stripped          = true) {
        if ($stripped) {
            $this->calendar_file = 'calendar_stripped.js';
            $this->calendar_setup_file = 'calendar-setup_stripped.js';
        } else {
            $this->calendar_file = 'calendar.js';
            $this->calendar_setup_file = 'calendar-setup.js';
        }
        $this->calendar_lang_file = 'lang/calendar-' . $lang . '.js';
        $this->calendar_theme_file = $theme.'.css';
        $this->calendar_lib_path = preg_replace('/\/+$/', '/', $calendar_lib_path);
        $this->calendar_options = array('ifFormat' => '%Y/%m/%d',
                                        'daFormat' => '%Y/%m/%d');
    }

    function set_option($name, $value) {
        $this->calendar_options[$name] = $value;
    }

    function load_files() {
        echo $this->get_load_files_code();
    }

    function get_load_files_code() {
        $code  = ( '<link rel="stylesheet" type="text/css" media="all" href="' .
                   $this->calendar_lib_path . $this->calendar_theme_file .
                   '" />' . NEWLINE );
        $code .= ( '<script type="text/javascript" src="' .
                   $this->calendar_lib_path . $this->calendar_file .
                   '"></script>' . NEWLINE );
        $code .= ( '<script type="text/javascript" src="' .
                   $this->calendar_lib_path . $this->calendar_lang_file .
                   '"></script>' . NEWLINE );
        $code .= ( '<script type="text/javascript" src="' .
                   $this->calendar_lib_path . $this->calendar_setup_file .
                   '"></script>' );
        return $code;
    }

    function _make_calendar($other_options = array()) {
        $js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options));
        $code  = ( '<script type="text/javascript">Calendar.setup({' .
                   $js_options .
                   '});</script>' );
        return $code;
    }

    function make_input_field($cal_options = array(), $field_attributes = array()) {
        $id = $this->_gen_id();
        $attrstr = $this->_make_html_attr(array_merge($field_attributes,
                                                      array('id'   => $this->_field_id($id),
                                                            'type' => 'text')));
        echo '<input ' . $attrstr .'/>';
        echo '<a href="#" id="'. $this->_trigger_id($id) . '">' .
            '<img align="middle" border="0" src="' . $this->calendar_lib_path . 'img.gif" alt="" /></a>';

        $options = array_merge($cal_options,
                               array('inputField' => $this->_field_id($id),
                                     'button'     => $this->_trigger_id($id)));
        echo $this->_make_calendar($options);
    }

    /// PRIVATE SECTION

    function _field_id($id) { return 'f-calendar-field-' . $id; }
    function _trigger_id($id) { return 'f-calendar-trigger-' . $id; }
    function _gen_id() { static $id = 0; return ++$id; }

    function _make_js_hash($array) {
        $jstr = '';
        reset($array);
        while (list($key, $val) = each($array)) {
            if (is_bool($val))
                $val = $val ? 'true' : 'false';
            else if (!is_numeric($val))
                $val = '"'.$val.'"';
            if ($jstr) $jstr .= ',';
            $jstr .= '"' . $key . '":' . $val;
        }
        return $jstr;
    }

    function _make_html_attr($array) {
        $attrstr = '';
        reset($array);
        while (list($key, $val) = each($array)) {
            $attrstr .= $key . '="' . $val . '" ';
        }
        return $attrstr;
    }
};

?>



See more files for this project here

Group-Office groupware

Group-Office is a powerfull modular Internet/Intranet application framework. It features calendaring, project management, e-mail, tasks, addressbook, file management.

Project homepage: http://sourceforge.net/projects/group-office
Programming language(s): JavaScript,Pascal,PHP
License: other

  doc/
    html/
      field-button.jpg
      reference-Z-S.css
      reference.css
      reference.html
    reference.pdf
  lang/
    b5.js
    calendar-af.js
    calendar-al.js
    calendar-bg.js
    calendar-big5-utf8.js
    calendar-big5.js
    calendar-br.js
    calendar-ca.js
    calendar-cs-utf8.js
    calendar-cs-win.js
    calendar-cs.js
    calendar-da.js
    calendar-de.js
    calendar-du.js
    calendar-el.js
    calendar-en.js
    calendar-es.js
    calendar-fi.js
    calendar-fr.js
    calendar-he-utf8.js
    calendar-hr-utf8.js
    calendar-hr.js
    calendar-hu.js
    calendar-it.js
    calendar-ja.js
    calendar-jp.js
    calendar-ko-utf8.js
    calendar-ko.js
    calendar-lang.php
    calendar-lt-utf8.js
    calendar-lt.js
    calendar-lv.js
    calendar-nl.js
    calendar-no.js
    calendar-pl-utf8.js
    calendar-pl.js
    calendar-pt-br.js
    calendar-pt.js
    calendar-ro.js
    calendar-ru.js
    calendar-ru_win_.js
    calendar-si.js
    calendar-sk.js
    calendar-sl.js
    calendar-sp.js
    calendar-sv.js
    calendar-th.js
    calendar-tr.js
    calendar-zh-tw.js
    calendar-zh.js
    cn_utf8.js
  ChangeLog
  README
  bugtest-hidden-selects.html
  calendar-blue.css
  calendar-blue2.css
  calendar-brown.css
  calendar-go.css
  calendar-green.css
  calendar-lang.php
  calendar-setup.js
  calendar-setup_stripped.js
  calendar-system.css
  calendar-tas.css
  calendar-win2k-1.css
  calendar-win2k-2.css
  calendar-win2k-cold-1.css
  calendar-win2k-cold-2.css
  calendar.js
  calendar.php
  calendar_stripped.js
  dayinfo.html
  img.gif
  index.html
  menuarrow.gif
  menuarrow2.gif
  multiple-dates.html
  release-notes.html
  simple-1.html
  simple-2.html
  simple-3.html
  simple-4.html
  test-position.html
  test.php