public function getListView(&$criteria, $return = false) { $dp = new EActiveDataProvider(get_class($this->model), array( 'criteria' => $criteria, //'pagination' => $this->settings['pagination'], )); //default params $params = array( 'dataProvider'=>$dp, 'pager'=>array( 'id'=>$this->widgetModel->pk.'Pager', 'class'=>'LinkPager', 'htmlOptions'=>array('class'=>'pager'), 'cssFile'=>Yii::app()->baseUrl.'/css/pager.css' ), 'ajaxUpdate'=>true, 'template'=>$this->render('listTemplate', array(), true), 'afterAjaxUpdate' => ModelFactory::getAfterAjaxUpdateFunction($this->category->type), 'beforeAjaxUpdate' => ModelFactory::getBeforeAjaxUpdateFunction($this->category->type), 'category' => $this->category, 'contextWidget' => $this ); try { $res = Y::controller()->widget('ListView', $params, true); } catch (CException $e) { Y::dump($e->__toString()); } if ($return) return $res; else echo $res; }
public static function curBaseUrl() { $baseUrl = '/'; if (Y::module()) { $baseUrl .= Y::module()->id . '/'; } $baseUrl .= Y::controller()->id; return $baseUrl; }
public function activeCaptcha() { $code = Y::controller()->createAction('captcha')->getVerifyCode(); if ($code != $this->verifyCode) { $this->addError('verifyCode', 'Неправильный код проверки.'); } if(!isset($_POST['ajax'])) { Y::controller()->createAction('captcha')->getVerifyCode(true); } }
private function renderWidget($widget, $category) { $settings = CMap::mergeArray($widget->settings, array( 'category' => $category, 'blockModel' => $this, 'widgetModel' => $widget, 'block' => $this, 'model' => isset(Y::controller()->model) ? Y::controller()->model : null )); return Y::controller()->widget($widget->class.'Widget', $settings, true); }
protected function renderContent() { $alias = $this->alias; if (($menuRoot = Category::model()->menuRoot($alias)) == null) { Y::end("Параметр alias для menu не верен. Шаблон $alias"); } if ($this->expand) { echo $menuRoot->makeTreeHtml($this->category, true); } else { $params = array( 'items' => $menuRoot->makeMenu($this->category) ); Y::controller()->widget('CMenu', $params); } }
public function get($alias) { if (($menuRoot = Category::model()->menuRoot($alias)) == null) { $this->error("Параметр tag для menu не верен. Шаблон $this->tmplAlias"); $res = $this->command; } $params = new CMap(); if ($params->remove('expand')) { $res = $menuRoot->makeTreeHtml(Y::controller()->category, true); } else { $params['items'] = $menuRoot->makeMenu(Y::controller()->category); $res = Y::controller()->widget('Menu', $params, true); } return $res; }
public function init() { parent::init(); $this->uiDateFormat = $this->uiDateFormat ? $this->uiDateFormat : "yy-mm-dd"; $this->attribute = $this->attribute ? $this->attribute : $this->name; $this->filter = Y::controller()->widget('ext.jui.FJuiDatePicker', array( 'model'=>$this->model, 'attribute'=>$this->attribute, 'language'=>'ru', 'options'=>array( 'dateFormat'=>$this->uiDateFormat ) ), true ); }
/** * Registers necessary client scripts. */ public function registerClientScript() { parent::registerClientScript(); $cs=Yii::app()->getClientScript(); $cs->registerScriptFile($this->baseTreeTableUrl.'/javascripts/jquery.treeTable.js',CClientScript::POS_END); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.core.min.js',CClientScript::POS_END); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.widget.min.js',CClientScript::POS_END); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.mouse.min.js',CClientScript::POS_END); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.droppable.min.js',CClientScript::POS_END); $cs->registerScriptFile($this->baseJuiUrl.'/jquery.ui.draggable.min.js',CClientScript::POS_END); $cs->registerCssFile($this->baseTreeTableUrl.'/stylesheets/jquery.treeTable.css'); $cs->registerScript('treeTable', ' $(document).ready(function() { $("#'.$this->getId().' .items").treeTable(); }); '); $baseUrl = '/'; if(Y::module()) $baseUrl.=Y::module()->id.'/'; $baseUrl .= Y::controller()->id.'/'; $cs->registerScript('draganddrop', ' $(document).ready(function() { $("#'.$this->getId().' .items tr.initialized").draggable({ helper: "clone", opacity: .75, refreshPositions: true, // Performance? revert: "invalid", revertDuration: 300, scroll: true }); $("#'.$this->getId().' .items tr.initialized, #'.$this->getId().' .items tr.before, #'.$this->getId().' .items tr.after").droppable({ accept: ".initialized", drop: function(e, ui) { // Call jQuery treeTable plugin to move the branch //$(ui.draggable).appendBranchTo(this); if($(this).hasClass("initialized")) { window.location.href = "'.$baseUrl.'moveNode/action/child/to/"+$(this).attr("id")+"/id/"+$(ui.draggable).attr("id"); } if($(this).hasClass("before")) { window.location.href = "'.$baseUrl.'moveNode/action/before/to/"+$(this).attr("id").replace("before-", "")+"/id/"+$(ui.draggable).attr("id"); } if($(this).hasClass("after")) { window.location.href = "'.$baseUrl.'moveNode/action/before/to/"+$(this).attr("id").replace("after-", "")+"/id/"+$(ui.draggable).attr("id"); } }, hoverClass: "accept", over: function(e, ui) { // Make the droppable branch expand when a draggable node is moved over it. if(this.id != $(ui.draggable.parents("tr")[0]).id && !$(this).is(".expanded")) { $(this).expand(); } }, activate: function(e, ui) { $(".after").css("display", "table-row"); $(".before").css("display", "table-row"); }, deactivate: function(e, ui) { $(".after").css("display", "none"); $(".before").css("display", "none"); }, }); }); '); }
public function getTabs($id = null, $return = false) { $submitButton = Y::controller()->widget('AjaxSubmitButton', array( 'name'=>'saveButton', 'id'=>$id.'_save_button', 'htmlOptions'=>array('class'=>'submit-button','value'=>'Save',), 'options'=>array( 'success'=>'js:function(){$("#submit-form-result").fadeIn(400).delay(2000).fadeOut(400)}' ) ), true); $tabs = self::controller()->widget( 'ExtTabs', array( 'tabs'=>self::$tabs, 'options'=>array( 'collapsible'=>false, ), 'id' => $id, 'htmlOptions' => array('class'=>'widget_settings_tabs', 'style'=>'height:495px'), //add buttons to widget header 'buttons' => array ($submitButton), 'extHeaderHtml' => '<div id="submit-form-result">Сохранено</div>' ), true ); //clear self::$tabs = array(); self::$curTabName = ''; //return if ($return) return $tabs; else echo $tabs; }
public function widget($widgetName, $event, $additionParams = array()) { $params = CMap::mergeArray($event->params, $additionParams); Y::controller()->widget($widgetName, $params); }
public static function makeDateFields($form, $model, $attributes, $dateFormat = 'yy.mm.dd', $phpDateFormat = 'd.m.Y') { foreach ((array)$attributes as $attr) { echo '<div class="row"> <div class="left">'.$form->labelEx($model,$attr).'</div> <div class="right">'; $name = get_class($model).'['.$attr.']'; if ($model->isNewRecord) { $model->{$attr} = date('d.m.Y'); } $time = date($phpDateFormat,strtotime($model->{$attr})); Y::controller()->widget('zii.widgets.jui.CJuiDatePicker', array( 'attribute'=>$attr, // 'scriptFile'=>'/js/jquery-ui.min.js', 'model'=>$model, 'language'=>Yii::app()->language, 'options'=>array( 'changeYear'=>true, 'yearRange'=>'-50:-15', 'dateFormat'=>'dd.mm.yy', ), 'htmlOptions'=>array('size'=>30,'class'=>'date') )); echo '</div> </div>'; } }