Horde_Core_Ui_JsCalendar::init PHP Method

init() public static method

Output the necessary javascript code to allow display of the calendar widget.
public static init ( array $params = [] )
$params array Configuration parameters for the widget:
'click_month' - (boolean) If true, the month is clickable.
                DEFAULT: false
'click_week' - (boolean) If true, will display a clickable week.
               DEFAULT: false
'click_year' - (boolean) If true, the year is clickable.
               DEFAULT: false
'full_weekdays' - (boolean) Add full weekday localized list to
                  javascript object.
                  DEFAULT: false
'short_weekdays' - (boolean) Display only the first letter of
                   weekdays?
                   DEFAULT: false
    public static function init(array $params = array())
    {
        if (self::$_initRun) {
            return;
        }
        self::$_initRun = true;
        $params = array_merge(array('click_month' => false, 'click_week' => false, 'click_year' => false, 'full_weekdays' => false, 'short_weekdays' => false), $params);
        $weekdays = self::weekdays();
        if ($params['short_weekdays']) {
            foreach ($weekdays as &$day) {
                $day = Horde_String::substr($day, 0, 1);
            }
        }
        $js = array('-Horde_Calendar.click_month' => intval($params['click_month']), '-Horde_Calendar.click_week' => intval($params['click_week']), '-Horde_Calendar.click_year' => intval($params['click_year']), '-Horde_Calendar.firstDayOfWeek' => intval($GLOBALS['prefs']->getValue('first_week_day')), 'Horde_Calendar.months' => self::months(), 'Horde_Calendar.weekdays' => $weekdays);
        if ($params['full_weekdays']) {
            $js['Horde_Calendar.fullweekdays'] = self::fullWeekdays();
        }
        $page_output = $GLOBALS['injector']->getInstance('Horde_PageOutput');
        $page_output->addScriptFile('calendar.js', 'horde');
        $page_output->addInlineJsVars($js);
    }

Usage Example

Esempio n. 1
0
 /**
  */
 public function init()
 {
     global $page_output;
     $page_output->addScriptFile('dragdrop2.js');
     $page_output->addScriptFile('redbox.js', 'horde');
     $page_output->addScriptFile('tooltips.js', 'horde');
     $page_output->addScriptFile('colorpicker.js', 'horde');
     $page_output->addScriptPackage('Horde_Core_Script_Package_Datejs');
     $page_output->addScriptFile('kronolith.js');
     Horde_Core_Ui_JsCalendar::init(array('short_weekdays' => true));
     $page_output->addInlineJsVars(array('var Kronolith' => $this->_addBaseVars()), array('top' => true));
     $page_output->header(array('body_class' => 'horde-ajax', 'growler_log' => true));
 }
All Usage Examples Of Horde_Core_Ui_JsCalendar::init