Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CJuiAccordion
  • CJuiAutoComplete
  • CJuiButton
  • CJuiDatePicker
  • CJuiDialog
  • CJuiDraggable
  • CJuiDroppable
  • CJuiInputWidget
  • CJuiProgressBar
  • CJuiResizable
  • CJuiSelectable
  • CJuiSlider
  • CJuiSliderInput
  • CJuiSortable
  • CJuiTabs
  • CJuiWidget
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * CJuiDatePicker class file.
  4:  *
  5:  * @author Sebastian Thierer <sebathi@gmail.com>
  6:  * @link http://www.yiiframework.com/
  7:  * @copyright 2008-2013 Yii Software LLC
  8:  * @license http://www.yiiframework.com/license/
  9:  */
 10: 
 11: Yii::import('zii.widgets.jui.CJuiInputWidget');
 12: 
 13: /**
 14:  * CJuiDatePicker displays a datepicker.
 15:  *
 16:  * CJuiDatePicker encapsulates the {@link http://jqueryui.com/datepicker/ JUI
 17:  * datepicker} plugin.
 18:  *
 19:  * To use this widget, you may insert the following code in a view:
 20:  * <pre>
 21:  * $this->widget('zii.widgets.jui.CJuiDatePicker',array(
 22:  *     'name'=>'publishDate',
 23:  *     // additional javascript options for the date picker plugin
 24:  *     'options'=>array(
 25:  *         'showAnim'=>'fold',
 26:  *     ),
 27:  *     'htmlOptions'=>array(
 28:  *         'style'=>'height:20px;'
 29:  *     ),
 30:  * ));
 31:  * </pre>
 32:  *
 33:  * By configuring the {@link options} property, you may specify the options
 34:  * that need to be passed to the JUI datepicker plugin. Please refer to
 35:  * the {@link http://api.jqueryui.com/datepicker/ JUI DatePicker API}
 36:  * documentation for possible options (name-value pairs) and
 37:  * {@link http://jqueryui.com/datepicker/ JUI DatePicker page} for general
 38:  * description and demo.
 39:  *
 40:  * @author Sebastian Thierer <sebathi@gmail.com>
 41:  * @package zii.widgets.jui
 42:  * @since 1.1
 43:  */
 44: class CJuiDatePicker extends CJuiInputWidget
 45: {
 46:     /**
 47:      * @var string the locale ID (eg 'fr', 'de') for the language to be used by the date picker.
 48:      * If this property is not set, I18N will not be involved. That is, the date picker will show in English.
 49:      * You can force English language by setting the language attribute as '' (empty string)
 50:      */
 51:     public $language;
 52:     /**
 53:      * @var string The i18n Jquery UI script file. It uses scriptUrl property as base url.
 54:      */
 55:     public $i18nScriptFile='jquery-ui-i18n.min.js';
 56:     /**
 57:      * @var array The default options called just one time per request. This options will alter every other CJuiDatePicker instance in the page.
 58:      * It has to be set at the first call of CJuiDatePicker widget in the request.
 59:      */
 60:     public $defaultOptions;
 61:     /**
 62:      * @var boolean If true, shows the widget as an inline calendar and the input as a hidden field.
 63:      */
 64:     public $flat=false;
 65: 
 66:     public function init () {
 67:         /* x2modstart */   
 68:         // mobile app has its own datepicker styling
 69:         if (Yii::app()->params->isMobileApp) {
 70:             $this->cssFile = null;
 71:         }
 72:         /* x2modend */ 
 73:         parent::init ();
 74:     }
 75: 
 76:     /**
 77:      * Run this widget.
 78:      * This method registers necessary javascript and renders the needed HTML code.
 79:      */
 80:     public function run()
 81:     {
 82:         list($name,$id)=$this->resolveNameID();
 83: 
 84:         if(isset($this->htmlOptions['id']))
 85:             $id=$this->htmlOptions['id'];
 86:         else
 87:             $this->htmlOptions['id']=$id;
 88:         if(isset($this->htmlOptions['name']))
 89:             $name=$this->htmlOptions['name'];
 90: 
 91:         if($this->flat===false)
 92:         {
 93:             if($this->hasModel())
 94:                 echo CHtml::activeTextField($this->model,$this->attribute,$this->htmlOptions);
 95:             else
 96:                 echo CHtml::textField($name,$this->value,$this->htmlOptions);
 97:         }
 98:         else
 99:         {
100:             if($this->hasModel())
101:             {
102:                 echo CHtml::activeHiddenField($this->model,$this->attribute,$this->htmlOptions);
103:                 $attribute=$this->attribute;
104:                 $this->options['defaultDate']=$this->model->$attribute;
105:             }
106:             else
107:             {
108:                 echo CHtml::hiddenField($name,$this->value,$this->htmlOptions);
109:                 $this->options['defaultDate']=$this->value;
110:             }
111: 
112:             $this->options['altField']='#'.$id;
113: 
114:             $id=$this->htmlOptions['id']=$id.'_container';
115:             $this->htmlOptions['name']=$name.'_container';
116: 
117:             echo CHtml::tag('div',$this->htmlOptions,'');
118:         }
119: 
120:         $options=CJavaScript::encode($this->options);
121:         $js = "jQuery('#{$id}').datepicker($options);";
122: 
123:         if($this->language!='' && $this->language!='en')
124:         {
125:             $this->registerScriptFile($this->i18nScriptFile);
126:             $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false},jQuery.datepicker.regional['{$this->language}'],{$options}));";
127:         }
128: 
129:         $cs = Yii::app()->getClientScript();
130: 
131:         if(isset($this->defaultOptions))
132:         {
133:             $this->registerScriptFile($this->i18nScriptFile);
134:             $cs->registerScript(__CLASS__,$this->defaultOptions!==null?'jQuery.datepicker.setDefaults('.CJavaScript::encode($this->defaultOptions).');':'');
135:         }
136:         $cs->registerScript(__CLASS__.'#'.$id,$js);
137:     }
138: }
139: 
API documentation generated by ApiGen 2.8.0