当前位置: 首页>>代码示例>>PHP>>正文


PHP CHtml类代码示例

本文整理汇总了PHP中CHtml的典型用法代码示例。如果您正苦于以下问题:PHP CHtml类的具体用法?PHP CHtml怎么用?PHP CHtml使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CHtml类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 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);
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:30,代码来源:VoteAction.php

示例2: getRightsReturnUrl

 /**
  * 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);
 }
开发者ID:fobihz,项目名称:cndiesel,代码行数:15,代码来源:RWebUser.php

示例3: renderContent

 /**
  * (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();
 }
开发者ID:jackycgq,项目名称:advanced,代码行数:11,代码来源:EThemePicker.php

示例4: renderButton

 /**
  * 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);
         }
     }
 }
开发者ID:bafio89,项目名称:qea-u,代码行数:32,代码来源:BsButtonColumn.php

示例5: actionCreate

 /**
  * 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>&quot;{$model->name}&quot;</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));
             }
         }
     }
 }
开发者ID:rodespsan,项目名称:LMEC,代码行数:38,代码来源:ModeloController.php

示例6: renderButton

 /**
  * 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);
         }
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:35,代码来源:ButtonColumn.php

示例7: reject

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"));
}
开发者ID:acuba001,项目名称:Collaborative-Platform,代码行数:7,代码来源:index.php

示例8: actionLogin

 /**
  * 会员登录
  */
 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));
 }
开发者ID:zywh,项目名称:maplecity,代码行数:31,代码来源:PublicController.php

示例9: textField

 public function textField($model, $attribute, $htmlOptions = array())
 {
     if (empty($htmlOptions['class'])) {
         $htmlOptions['class'] = 't_input';
     }
     return CHtml::activeTextField($model, $attribute, $htmlOptions);
 }
开发者ID:vangogogo,项目名称:justsns,代码行数:7,代码来源:YiicmsActiveForm.php

示例10: run

 /**
  * 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);
 }
开发者ID:BGCX261,项目名称:zii-svn-to-git,代码行数:32,代码来源:CJuiDatePicker.php

示例11: renderValue

 /**
  * @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;
 }
开发者ID:yupe,项目名称:yupe,代码行数:38,代码来源:AttributeRender.php

示例12: run

 /**
  * 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});");
 }
开发者ID:nisarg709,项目名称:yii-bootstrap,代码行数:10,代码来源:BootTypeahead.php

示例13: etiquetaExtranjero

 /**
  * @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);
 }
开发者ID:EurekaSolutions,项目名称:sistemanc,代码行数:10,代码来源:Proveedores.php

示例14: actionLogin

 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));
     }
 }
开发者ID:hit-shappens,项目名称:testapp,代码行数:26,代码来源:DefaultController.php

示例15: renderDataCellContent

 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'));
         }
     }
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:28,代码来源:CommentsViewLinkColumn.php


注:本文中的CHtml类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。