當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。