/** * Runs the widget. */ public function run() { Yii::import("sys.models.SysModules"); $module = Yii::app()->controller->module->id; $sysModule = SysModules::model()->find(TUtil::qc('code') . "=:code", array(":code" => $module)); if ($sysModule != null && $sysModule->enable_attachment == 0) { return; } $id = $this->id . '-file'; $containerId = $this->id . '-container'; $label = '从本地选择'; if ($this->hasModel()) { $name = CHtml::activeName($this->model, $this->attribute) . '[]'; $attributes = array('name' => $name, 'id' => $id, 'hideFocus' => true); if (isset($this->htmlOptions['accept'])) { $attributes['accept'] = $this->htmlOptions['accept']; } if (isset($this->htmlOptions['maxlength'])) { $attributes['maxlength'] = $this->htmlOptions['maxlength']; } if (isset($this->htmlOptions['multiple'])) { $attributes['multiple'] = $this->htmlOptions['multiple']; } if ($this->form) { $label .= $this->form->fileField($this->model, $this->attribute, $attributes); } else { $label .= CHtml::activeFileField($this->model, $this->attribute, $attributes); } } $this->controller->widget('bootstrap.widgets.TbButton', array('type' => $this->selectorType, 'label' => $label, 'icon' => 'storage', 'encodeLabel' => false, 'htmlOptions' => $this->htmlOptions)); if ($this->enableFileFolder == true) { echo " "; $this->controller->widget('bootstrap.widgets.TbButton', array('type' => $this->selectorType, 'label' => '从文件柜选择', 'buttonType' => 'button', 'icon' => 'folder', 'id' => $id . '_btn')); } if ($this->enableInsertPicture == true) { echo " "; $this->widget('core.widgets.TPictureSelector', array('model' => $this->model, 'attribute' => $this->attribute . "_picture")); } if ($this->enableFileFolder == true) { echo "<div id='SelFileDiv'></div>"; } echo CHtml::tag('div', array('id' => $containerId), '', true); if ($this->enableFileFolder == true) { echo CHtml::hiddenField('Sel_ATTACHMENT_ID', '', array('id' => 'Sel_ATTACHMENT_ID')); echo CHtml::hiddenField('Sel_ATTACHMENT_NAME', '', array('id' => 'Sel_ATTACHMENT_NAME')); $this->registerClientScript($id); } Yii::app()->bootstrap->registerAssetCss('bootstrap-file-selector.css'); $cs = Yii::app()->getClientScript(); $cs->registerCoreScript('multifile'); $cs->registerScript(__CLASS__ . '#' . $this->id, "\n\$('#{$id}').MultiFile(" . CJavaScript::encode($this->options) . ")"); }
public function getPageSize() { return SysModules::getPageSize($this->getId()) ? SysModules::getPageSize($this->getId()) : $this->_defaultPageSize; }