public function run() { $voting = null; if (is_numeric(HU::post('id_voting'))) { $voting = Voting::model()->onlyActive()->with('answer')->findByPk(HU::post('id_voting')); } if ($voting == null) { //echo CHtml::encode($this->controller->widget('vote.widgets.VoteWidget', null, true)); return; } if (Yii::app()->vote->check($voting->id_voting)) { $answers = $_POST['VotingAnswer']['name']; $cr = new CDbCriteria(); $cr->addColumnCondition(array('id_voting' => $voting->id_voting)); if (is_array($answers)) { $cr->addInCondition('id_voting_answer', $answers); } else { if (is_numeric($answers)) { $cr->addColumnCondition(array('id_voting_answer' => $answers)); } } VotingAnswer::model()->updateCounters(array('count' => 1), $cr); VisitSite::saveCurrentVisit(Voting::ID_OBJECT, $voting->id_voting); Yii::app()->user->setState('vote_' . $voting->id_voting, time()); // перегружаем голосовалку, чтоб обновились показатели счетчиков $voting = Voting::model()->onlyActive()->with('answer')->findByPk($voting->id_voting); } $voteCount = $voting->getSumVote(); echo CHtml::encode($this->controller->renderPartial("vote.widgets.views.statistic", array('voting' => $voting, 'voteCount' => $voteCount)), null, true); }
/** * Returns the URL that the user should be redirected to * after updating an authorization item. * @param string $defaultUrl the default return URL in case it was not set previously. If this is null, * the application entry URL will be considered as the default return URL. * @return string the URL that the user should be redirected to * after updating an authorization item. */ public function getRightsReturnUrl($defaultUrl = null) { if (($returnUrl = $this->getState('Rights_returnUrl')) !== null) { $this->returnUrl = null; } return $returnUrl !== null ? CHtml::normalizeUrl($returnUrl) : CHtml::normalizeUrl($defaultUrl); }
/** * (non-PHPdoc) * @see CPortlet::renderContent() */ protected function renderContent() { $themesList = array_combine(Yii::app()->themeManager->themeNames, Yii::app()->themeManager->themeNames); echo CHtml::form('', 'post', array()); echo CHtml::dropDownList('themeSelector', Yii::app()->theme->name, $themesList, $this->dropDownOptions); echo CHtml::endForm(); }
/** * Renders a link button. * @param string $id the ID of the button * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements. * @param integer $row the row number (zero-based) * @param mixed $data the data object associated with the row */ protected function renderButton($id, $button, $row, $data) { if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) { return; } $url = \bootstrap\helpers\BSArray::popValue('url', $button, '#'); if (strcmp($url, '#') !== 0) { $url = $this->evaluateExpression($url, array('data' => $data, 'row' => $row)); } $imageUrl = \bootstrap\helpers\BSArray::popValue('imageUrl', $button, false); $label = \bootstrap\helpers\BSArray::popValue('label', $button, $id); $options = \bootstrap\helpers\BSArray::popValue('options', $button, array()); \bootstrap\helpers\BSArray::defaultValue('data-title', $label, $options); \bootstrap\helpers\BSArray::defaultValue('title', $label, $options); \bootstrap\helpers\BSArray::defaultValue('data-toggle', 'tooltip', $options); if ($icon = \bootstrap\helpers\BSArray::popValue('icon', $button, false)) { echo CHtml::link(BSHtml::icon($icon), $url, $options); } else { if ($imageUrl && is_string($imageUrl)) { echo CHtml::link(CHtml::image($imageUrl, $label), $url, $options); } else { echo CHtml::link($label, $url, $options); } } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Modelo(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Modelo'])) { $model->attributes = $_POST['Modelo']; if ($model->save()) { if (!empty($_POST['yt1'])) { Yii::app()->user->setFlash('modelo-created', "¡El modelo <b><i>"{$model->name}"</i></b> fue creado exitosamente!"); //$this->redirect(array('create')); $modelSaved = $model; $model = new Modelo(); $model->equipment_type_id = $modelSaved->equipment_type_id; $model->brand_id = $modelSaved->brand_id; } else { $this->redirect(array('view', 'id' => $model->id)); } } } if (EquipmentType::model()->count('active = 1') == 0 && Brand::model()->count('active = 1') == 0) { throw new CHttpException('', 'Primero debe ' . CHtml::link('crear un Tipo de Equipo', array('equipmentType/create')) . ' y ' . CHtml::link('crear una Marca', array('brand/create')) . '.'); } else { if (EquipmentType::model()->count('active = 1') == 0) { throw new CHttpException('', 'Primero debe ' . CHtml::link('crear un Tipo de Equipo', array('equipmentType/create')) . '.'); } else { if (Brand::model()->count('active = 1') == 0) { throw new CHttpException('', 'Primero debe ' . CHtml::link('crear una Marca', array('brand/create')) . '.'); } else { $this->render('create', array('model' => $model)); } } } }
/** * Render the link or ajax link * @param string $id the ID of the button * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements. * See {@link buttons} for more details. * @param integer $row the row number (zero-based) * @param mixed $data the data object associated with the row */ protected function renderButton($id, $button, $row, $data) { if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) { return; } $label = isset($button['label']) ? $button['label'] : $id; if (isset($button['url'])) { $url = $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row)); // Not Coding Standard } else { $url = '#'; } $options = isset($button['options']) ? $button['options'] : array(); if (!isset($options['title'])) { $options['title'] = $label; } if (isset($button['ajaxOptions'])) { unset($options['ajaxOptions']); echo ZurmoHtml::ajaxLink($label, $url, $button['ajaxOptions'], $options); } else { if (isset($button['imageUrl']) && is_string($button['imageUrl'])) { echo ZurmoHtml::link(CHtml::image($button['imageUrl'], $label), $url, $options); } else { echo ZurmoHtml::link($label, $url, $options); } } }
function reject($vcid) { return CHtml::ajaxLink('Reject', Yii::app()->createAbsoluteUrl('videoConference/reject/' . $vcid), array('type' => 'get', 'data' => array('id' => $vcid, 'type' => 'get'), 'update' => 'message', 'success' => 'function(response) { $(".message").html(response); location.reload(); }'), array('confirm' => 'Are you sure you want to reject this invitation?', 'role' => "button", "class" => "btn btn-danger")); }
/** * 会员登录 */ public function actionLogin() { $model = new Admin('login'); if (XUtils::method() == 'POST') { $model->attributes = $_POST['Admin']; if ($model->validate()) { $data = $model->find('username=:username', array('username' => $model->username)); if ($data === null) { $model->addError('username', '用户不存在'); AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,用户不存在:' . CHtml::encode($model->username), 'user_id' => 0)); } elseif (!$model->validatePassword($data->password)) { $model->addError('password', '密码不正确'); AdminLogger::_create(array('catalog' => 'login', 'intro' => '登录失败,密码不正确:' . CHtml::encode($model->username) . ',使用密码:' . CHtml::encode($model->password), 'user_id' => 0)); } elseif ($data->group_id == 2) { $model->addError('username', '用户被锁定,请联系网站管理'); } else { parent::_stateWrite(array('userId' => $data->id, 'userName' => $data->username, 'groupId' => $data->group_id, 'super' => $data->group_id == 1 ? 1 : 0), array('prefix' => '_admini')); $data->last_login_ip = XUtils::getClientIP(); $data->last_login_time = time(); $data->login_count = $data->login_count + 1; $data->save(); AdminLogger::_create(array('catalog' => 'login', 'intro' => '用户登录成功:' . CHtml::encode($model->username))); $this->redirect(array('default/index')); } } } $this->render('login', array('model' => $model)); }
public function textField($model, $attribute, $htmlOptions = array()) { if (empty($htmlOptions['class'])) { $htmlOptions['class'] = 't_input'; } return CHtml::activeTextField($model, $attribute, $htmlOptions); }
/** * Run this widget. * This method registers necessary javascript and renders the needed HTML code. */ public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } else { $this->htmlOptions['name'] = $name; } if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').datepicker({$options});"; if (isset($this->language)) { $this->registerScriptFile($this->i18nScriptFile); $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));"; } $cs = Yii::app()->getClientScript(); $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : ''); $cs->registerScript(__CLASS__ . '#' . $id, $js); }
/** * @param $attribute * @param $value * @return string */ public static function renderValue(Attribute $attribute, $value, $template = '<p>{item}</p>') { $unit = $attribute->unit ? ' ' . $attribute->unit : ''; $res = null; switch ($attribute->type) { case Attribute::TYPE_TEXT: case Attribute::TYPE_SHORT_TEXT: case Attribute::TYPE_NUMBER: $res = $value; break; case Attribute::TYPE_DROPDOWN: $data = CHtml::listData($attribute->options, 'id', 'value'); if (is_array($value)) { $value = array_shift($value); } if (isset($data[$value])) { $res .= $data[$value]; } break; case Attribute::TYPE_CHECKBOX_LIST: $data = CHtml::listData($attribute->options, 'id', 'value'); if (is_array($value)) { foreach (array_intersect(array_keys($data), $value) as $val) { $res .= strtr($template, ['{item}' => $data[$val]]); } } break; case Attribute::TYPE_CHECKBOX: $res = $value ? Yii::t("StoreModule.store", "Yes") : Yii::t("StoreModule.store", "No"); break; } return $res . $unit; }
/** * Runs the widget. */ public function run() { $id = $this->id; echo CHtml::tag('input', $this->htmlOptions); $options = !empty($this->options) ? CJavaScript::encode($this->options) : ''; Yii::app()->clientScript->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').typeahead({$options});"); }
/** * @return html nombre de partida compuesto con el nombre */ public function etiquetaExtranjero() { //echo count($this->id); //die; $extranjero = ProveedoresExtranjeros::model()->findByAttributes(array('proveedor_id' => $this->id)); return CHtml::encode($this->rif . ' - ' . $this->razon_social . ' - ' . $extranjero->num_identificacion . ' - ' . $extranjero->pais->nombre); }
public function actionLogin() { if (isset($_POST['token'])) { $this->networkLogin(); } $this->layout = null; $this->breadCrumbs = array('Управление сайтом' => array('/users/default/siteManagment')); $form = new LoginForm(); if (isset($_POST['LoginForm'])) { $form->attributes = $_POST['LoginForm']; if ($form->validate()) { $backUrl = $form->getBackUrl(); if (Yii::app()->getRequest()->getIsAjaxRequest()) { echo CHtml::script("document.location='" . $backUrl . "'"); return; } else { $this->redirect($backUrl); } } } if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('form/login', array('form' => $form, 'backUrl' => $backurl)); } else { $this->render('login', array('user' => $form, 'backUrl' => $backurl)); } }
protected function renderDataCellContent($row, $data) { if (!$data instanceof CommentYii) { return; } $key = $data->id_object . '_' . $data->id_instance; $owner = null; if (isset($this->cache[$key])) { $owner = $this->cache[$key]; } if ($owner || !$owner && ($owner = $data->getOwnerModel())) { $this->cache[$key] = $owner; $method = ''; if (method_exists($owner, 'getCommentsUrl')) { $method = 'getCommentsUrl'; } elseif (method_exists($owner, 'getUrl')) { $method = 'getUrl'; } elseif (method_exists($owner, 'getViewUrl')) { $method = 'getViewUrl'; } if ($method) { Yii::app()->urlManager->frontendMode = true; $link = Yii::app()->createUrl($owner->{$method}()); Yii::app()->urlManager->frontendMode = false; echo CHtml::link('<i class=" glyphicon glyphicon-share"></i> просмотреть на сайте', $link, array('target' => '_blank')); } } }
public function init() { if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $id = $this->htmlOptions['id'] = $this->getId(); } if ($this->url !== null) { $this->url = CHtml::normalizeUrl($this->url); } $cs = Yii::app()->getClientScript(); //$cs->registerCoreScript('treeview'); $baseUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('ext.yii-jqTree.source')); $cs->registerScriptFile($baseUrl . '/tree.jquery.js'); $options = $this->getClientOptions(); $options = $options === array() ? '{}' : CJavaScript::encode($options); $cs->registerScript('Yii.JQTree#0' . $id, "if (jQuery.jqTree == undefined) {jQuery.jqTree = new Array;}"); $cs->registerScript('Yii.JQTree#' . $id, "jQuery.jqTree[\"{$id}\"] = jQuery(\"#{$id}\").tree({$options});"); if ($this->cssFile === null) { $cs->registerCssFile($baseUrl . '/jqtree.css'); } else { if ($this->cssFile !== false) { $cs->registerCssFile($this->cssFile); } } echo CHtml::tag('ul', $this->htmlOptions, false, false) . "\n"; }
public function hiddenField($model, $attribute, $htmlOptions = array(), $value = null) { if ($value !== null) { $model->{$attribute} = $value; } return CHtml::activeHiddenInput($model, $attribute, $htmlOptions); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['EvaAttributesMatrix'])) { $model->attributes = $_POST['EvaAttributesMatrix']; if ($model->save()) { $this->redirect(['index']); } } $dropDownData = []; $survObjCriteria = new CDbCriteria(); $survObjCriteria->with = ['options']; $survObjCriteria->select = 'inputName'; $survObjCriteria->condition = "inputName='survObj' AND options.frameworkFieldId=t.id"; $rsSurveillanceObjective = FrameworkFields::model()->find($survObjCriteria); $dropDownData['objectives'] = CHtml::listData($rsSurveillanceObjective->options, 'optionId', 'label'); $rsQuestionGrp = EvaQuestionGroups::model()->find(['select' => 'questions']); $questionsArray = array_keys((array) json_decode($rsQuestionGrp->questions)); $dropDownData['groups'] = array_combine($questionsArray, range(1, count($questionsArray))); //print_r($dropDownData['groups']); die; $dropDownData['attributes'] = CHtml::listData(EvaAttributes::model()->findAll(), 'attributeId', 'name'); $this->menu = [['label' => 'Add Attribute Relevance', 'url' => $this->createUrl('create')], ['label' => 'List Attribute Relevance', 'url' => $this->createUrl('index')]]; $this->render('update', ['model' => $model, 'dropDownData' => $dropDownData]); }
public function actionSetSorters() { $sql = 'SELECT id, name_' . Yii::app()->language . ' AS name FROM {{location_country}} ORDER BY name_' . Yii::app()->language . ' ASC'; $res = Yii::app()->db->createCommand($sql)->queryAll(); $countries = CHtml::listData($res, 'id', 'name'); $co = 1; foreach ($countries as $coid => $coname) { $sql = 'UPDATE {{location_country}} SET sorter="' . $co . '" WHERE id = ' . $coid . ' LIMIT 1'; Yii::app()->db->createCommand($sql)->execute(); $sql = 'SELECT id, name_' . Yii::app()->language . ' AS name FROM {{location_region}} WHERE country_id = :country ORDER BY name_' . Yii::app()->language . ' ASC'; $res = Yii::app()->db->createCommand($sql)->queryAll(true, array(':country' => $coid)); $regions = CHtml::listData($res, 'id', 'name'); $r = 1; foreach ($regions as $rid => $rname) { $sql = 'UPDATE {{location_region}} SET sorter="' . $r . '" WHERE id = ' . $rid . ' LIMIT 1'; Yii::app()->db->createCommand($sql)->execute(); $sql = 'SELECT id, name_' . Yii::app()->language . ' AS name FROM {{location_city}} WHERE region_id = :region ORDER BY name_' . Yii::app()->language . ' ASC'; $res = Yii::app()->db->createCommand($sql)->queryAll(true, array(':region' => $rid)); $cities = CHtml::listData($res, 'id', 'name'); $c = 1; foreach ($cities as $cid => $cname) { $sql = 'UPDATE {{location_city}} SET sorter="' . $c . '" WHERE id = ' . $cid . ' LIMIT 1'; Yii::app()->db->createCommand($sql)->execute(); $c++; } $r++; } $co++; } echo 'ok'; }
/** * Run widget. */ public function run() { if($this->hasModel()) echo CHtml::activeTextArea($this->model,$this->attribute,$this->htmlOptions); else echo CHtml::textArea($this->name,$this->value,$this->htmlOptions); }
public function renderPagerList() { if (!$this->enablePagination) { return; } if (isset($this->pagerlist['all'])) { $t = $this->pagerlist; $this->pagerlist = array(); foreach ($t as $k => $v) { if ($k == 'all') { $this->pagerlist[$this->dataProvider->getTotalItemCount()] = Yii::t('zii', $v); } else { $this->pagerlist[$k] = $v; } } } $controller = $this->getController(); $route = $controller->route; $parameters = $_GET; unset($parameters['pageSize']); $parameters['page'] = $this->dataProvider->getPagination()->getCurrentPage() + 1; $parameters['pageSize'] = ''; $url = $controller->createUrl($route, $parameters); $id = parent::getId(); echo '<div class="' . $this->pagerlistCssClass . '">'; echo CHtml::dropDownList($id . '_pagerlist', $this->dataProvider->pagination->pageSize, $this->pagerlist, array('onchange' => $id . "_changePageSize(\"{$id}\",\"{$url}\")")); echo '<span>' . Yii::t('zii', $this->textItemsPerPage) . '</span>'; echo '</div>'; }
public function init() { $this->filtered_options = $this->options; if (empty($_POST)) { if ($this->element && $this->element->{$this->relation}) { foreach ($this->element->{$this->relation} as $item) { $this->selected_ids[] = $item->{$this->relation_id_field}; unset($this->filtered_options[$item->{$this->relation_id_field}]); } } elseif (!$this->element || !$this->element->id) { if (is_array($this->default_options)) { $this->selected_ids = $this->default_options; foreach ($this->default_options as $id) { unset($this->filtered_options[$id]); } } } } else { if (isset($_POST[$this->field]) && is_array($_POST[$this->field])) { foreach ($_POST[$this->field] as $id) { $this->selected_ids[] = $id; unset($this->filtered_options[$id]); } } elseif (isset($_POST[CHtml::modelName($this->element)][$this->relation])) { foreach ($_POST[CHtml::modelName($this->element)][$this->relation] as $id) { $this->selected_ids[] = $id; unset($this->filtered_options[$id]); } } } //NOTE: don't call parent init as the field behaviour doesn't work for the relations attribute with models }
/** * Run this widget. * This method registers necessary javascript and renders the needed HTML code. */ public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } if ($this->sourceUrl !== null) { $this->options['source'] = CHtml::normalizeUrl($this->sourceUrl); } else { $this->options['source'] = $this->source; } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').autocomplete({$options}){$this->methodChain};"; $cs = Yii::app()->getClientScript(); $cs->registerScript(__CLASS__ . '#' . $id, $js); }
/** * Renders a link button. * @param string $id the ID of the button * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements. * @param integer $row the row number (zero-based) * @param mixed $data the data object associated with the row */ protected function renderButton($id, $button, $row, $data) { if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) { return; } $label = isset($button['label']) ? $button['label'] : $id; $url = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row)) : '#'; $options = isset($button['options']) ? $button['options'] : array(); if (!isset($options['title'])) { $options['title'] = $label; } //Forsing btn class if (!isset($options['class'])) { $options['class'] = 'btn'; } else { if (!preg_match('/[^A-z\\-]btn[^A-z\\-]/', $options['class'])) { $options['class'] = 'btn ' . $options['class']; } } if (isset($button['icon'])) { if (strpos($button['icon'], 'icon') === false) { $button['icon'] = 'icon-' . implode(' icon-', explode(' ', $button['icon'])); } echo CHtml::link('<i class="' . $button['icon'] . '"></i>', $url, $options); } else { echo CHtml::link($label, $url, $options); } }
public function getDetails($cate) { $model = $this->findAllByAttributes(array('opt_category' => $cate)); $result = CHtml::listData($model, 'id', 'details'); $value = array_values($result); return array_combine($value, $value); }
public function actionShareAccount($id) { $model = $this->loadModel($id); $body = "\n\n\n\n" . Yii::t('accounts', '{module} Record Details', array('{module}' => Modules::displayName(false))) . " <br />\n<br />" . Yii::t('accounts', 'Name') . ": {$model->name}\n<br />" . Yii::t('accounts', 'Description') . ": {$model->description}\n<br />" . Yii::t('accounts', 'Revenue') . ": {$model->annualRevenue}\n<br />" . Yii::t('accounts', 'Phone') . ": {$model->phone}\n<br />" . Yii::t('accounts', 'Website') . ": {$model->website}\n<br />" . Yii::t('accounts', 'Type') . ": {$model->type}\n<br />" . Yii::t('app', 'Link') . ": " . CHtml::link($model->name, array('/accounts/accounts/view', 'id' => $model->id)); $body = trim($body); $errors = array(); $status = array(); $email = array(); if (isset($_POST['email'], $_POST['body'])) { $subject = Yii::t('accounts', "Account Record") . ": {$model->name}"; $email['to'] = $this->parseEmailTo($this->decodeQuotes($_POST['email'])); $body = $_POST['body']; // if(empty($email) || !preg_match("/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/",$email)) if ($email['to'] === false) { $errors[] = 'email'; } if (empty($body)) { $errors[] = 'body'; } if (empty($errors)) { $status = $this->sendUserEmail($email, $subject, $body); } if (array_search('200', $status)) { $this->redirect(array('view', 'id' => $model->id)); return; } if ($email['to'] === false) { $email = $_POST['email']; } else { $email = $this->mailingListToString($email['to']); } } $this->render('shareAccount', array('model' => $model, 'body' => $body, 'email' => $email, 'status' => $status, 'errors' => $errors)); }
/** * Renders a link button. * @param string $id the ID of the button * @param array $button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements. * @param integer $row the row number (zero-based) * @param mixed $data the data object associated with the row */ protected function renderButton($id, $button, $row, $data) { if (isset($button['visible']) && !$this->evaluateExpression($button['visible'], array('row' => $row, 'data' => $data))) { return; } $label = isset($button['label']) ? $button['label'] : $id; $url = isset($button['url']) ? $this->evaluateExpression($button['url'], array('data' => $data, 'row' => $row)) : '#'; $options = isset($button['options']) ? $button['options'] : array(); if (!isset($options['title'])) { $options['title'] = $label; } if (!isset($options['rel'])) { $options['rel'] = 'tooltip'; } if (isset($button['icon'])) { if (strpos($button['icon'], 'icon') === false) { $button['icon'] = 'icon-' . implode(' icon-', explode(' ', $button['icon'])); } echo CHtml::link('<i class="' . $button['icon'] . '"></i>', $url, $options); } else { if (isset($button['imageUrl']) && is_string($button['imageUrl'])) { echo CHtml::link(CHtml::image($button['imageUrl'], $label), $url, $options); } else { echo CHtml::link($label, $url, $options); } } }
/** * Class object initialization */ public function init() { $this->title = CHtml::image(Yii::app()->request->baseUrl . '/images/portlets/bug.png') . " " . Yii::t('portlet', 'TasksToDoTitle'); $this->decorationCssClass = "portlet-header"; $this->titleCssClass = "portlet-title"; parent::init(); }
/** * Display editor */ public function run() { // Resolve name and id list($name, $id) = $this->resolveNameID(); // Get assets dir $baseDir = dirname(__FILE__); $assets = Yii::app()->getAssetManager()->publish($baseDir . DIRECTORY_SEPARATOR . 'ueditor1_2_5'); // Publish required assets $cs = Yii::app()->getClientScript(); $jsFile = $this->debug ? 'editor_all.js' : 'editor_all_min.js'; $cs->registerScriptFile($assets . '/' . $jsFile); $cs->registerScriptFile($assets . '/editor_config.js'); $this->htmlOptions['id'] = $id; if (!array_key_exists('style', $this->htmlOptions)) { $this->htmlOptions['style'] = "width:{$this->width};"; } if ($this->toolbars) { $this->editorOptions['toolbars'][] = $this->toolbars; } $options = CJSON::encode(array_merge(array('theme' => $this->theme, 'lang' => $this->language, 'UEDITOR_HOME_URL' => "{$assets}/", 'initialFrameWidth' => $this->width, 'initialFrameHeight' => $this->height), $this->editorOptions)); $js = <<<EOP UE.getEditor('{$id}',{$options}); EOP; // Register js code $cs->registerScript('Yii.' . get_class($this) . '#' . $id, $js, CClientScript::POS_READY); // Do we have a model if ($this->hasModel()) { $html = CHtml::activeTextArea($this->model, $this->attribute, $this->htmlOptions); } else { $html = CHtml::textArea($name, $this->value, $this->htmlOptions); } echo $html; }
public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } else { $this->htmlOptions['name'] = $name; } if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').{$this->mode}picker({$options});"; if (isset($this->language)) { $this->registerScriptFile($this->i18nScriptFile); $js = "jQuery('#{$id}').{$this->mode}picker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));"; } $cs = Yii::app()->getClientScript(); $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'); $cs->registerCssFile($assets . self::ASSETS_NAME . '.css'); $cs->registerScriptFile($assets . self::ASSETS_NAME . '.js', CClientScript::POS_END); $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.{$this->mode}picker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : ''); $cs->registerScript(__CLASS__ . '#' . $id, $js); }