HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
TbPassfield.php
Go to the documentation of this file.
1 <?php
16 class TbPassfield extends CInputWidget
17 {
23  public $form;
24 
28  public $options = array();
29 
33  public $events = array();
34 
40  public function init()
41  {
42  $this->htmlOptions['type'] = 'text';
43  $this->htmlOptions['autocomplete'] = 'off';
44 
45  if (!isset($this->options['language'])) {
46  $this->options['locale'] = substr(Yii::app()->getLanguage(), 0, 2);
47  } else {
48  $this->options['locale'] = $this->options['language'];
49  }
50 
51  }
52 
58  public function run()
59  {
60  list($name, $id) = $this->resolveNameID();
61 
62  if ($this->hasModel()) {
63  if ($this->form) {
64  echo $this->form->passwordField($this->model, $this->attribute, $this->htmlOptions);
65  } else {
66  echo CHtml::activePasswordField($this->model, $this->attribute, $this->htmlOptions);
67  }
68 
69  } else {
70  echo CHtml::passwordField($name, $this->value, $this->htmlOptions);
71  }
72 
73  $this->registerClientScript();
74  $options = !empty($this->options) ? CJavaScript::encode($this->options) : '';
75 
76  ob_start();
77  echo "jQuery('#{$id}').passField({$options})";
78  foreach ($this->events as $event => $handler) {
79  echo ".on('{$event}', " . CJavaScript::encode($handler) . ")";
80  }
81 
82  Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $this->getId(), ob_get_clean() . ';');
83 
84  }
85 
92  public function registerClientScript()
93  {
94  Booster::getBooster()->registerPackage('passfield');
95  }
96 
97 }