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


PHP CHtml::resolveName方法代码示例

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


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

示例1: login

 /**
  * Displays the login page
  * @param object $formModel
  * @param bool $isMobile Whether this was called from mobile site controller
  */
 public function login(LoginForm $model, $isMobile = false)
 {
     $model->attributes = $_POST['LoginForm'];
     // get user input data
     Session::cleanUpSessions();
     $ip = $this->owner->getRealIp();
     $userModel = $model->getUser();
     $isRealUser = $userModel instanceof User;
     $effectiveUsername = $isRealUser ? $userModel->username : $model->username;
     $isActiveUser = $isRealUser && $userModel->status == User::STATUS_ACTIVE;
     /* increment count on every session with this user/IP, to prevent brute force attacks 
        using session_id spoofing or whatever */
     Yii::app()->db->createCommand('UPDATE x2_sessions SET status=status-1,lastUpdated=:time WHERE user=:name AND 
         CAST(IP AS CHAR)=:ip AND status BETWEEN -2 AND 0')->bindValues(array(':time' => time(), ':name' => $effectiveUsername, ':ip' => $ip))->execute();
     $activeUser = Yii::app()->db->createCommand()->select('username')->from('x2_users')->where('username=:name AND status=1', array(':name' => $model->username))->limit(1)->queryScalar();
     // get the correctly capitalized username
     if (isset($_SESSION['sessionId'])) {
         $sessionId = $_SESSION['sessionId'];
     } else {
         $sessionId = $_SESSION['sessionId'] = session_id();
     }
     $session = X2Model::model('Session')->findByPk($sessionId);
     /* get the number of failed login attempts from this IP within timeout interval. If the 
        number of login attempts exceeds maximum, display captcha */
     $badAttemptsRefreshTimeout = 900;
     $maxFailedLoginAttemptsPerIP = 100;
     $maxLoginsBeforeCaptcha = 5;
     $this->pruneTimedOutBans($badAttemptsRefreshTimeout);
     $failedLoginRecord = FailedLogins::model()->findActiveByIp($ip);
     $badAttemptsWithThisIp = $failedLoginRecord ? $failedLoginRecord->attempts : 0;
     if ($badAttemptsWithThisIp >= $maxFailedLoginAttemptsPerIP) {
         $this->recordFailedLogin($ip);
         throw new CHttpException(403, Yii::t('app', 'You are not authorized to use this application'));
     }
     // if this client has already tried to log in, increment their attempt count
     if ($session === null) {
         $session = new Session();
         $session->id = $sessionId;
         $session->user = $model->getSessionUserName();
         $session->lastUpdated = time();
         $session->status = 0;
         $session->IP = $ip;
     } else {
         $session->lastUpdated = time();
         $session->user = $model->getSessionUserName();
     }
     if ($isActiveUser === false) {
         $model->verifyCode = '';
         // clear captcha code
         $model->validate();
         // validate captcha if it's being used
         $this->recordFailedLogin($ip);
         $session->save();
         if ($badAttemptsWithThisIp + 1 >= $maxFailedLoginAttemptsPerIP) {
             throw new CHttpException(403, Yii::t('app', 'You are not authorized to use this application'));
         } else {
             if ($badAttemptsWithThisIp >= $maxLoginsBeforeCaptcha - 1) {
                 $model->useCaptcha = true;
                 $model->setScenario('loginWithCaptcha');
                 $session->status = -2;
             }
         }
     } else {
         if ($model->validate() && $model->login()) {
             // user successfully logged in
             if ($model->rememberMe) {
                 foreach (array('username', 'rememberMe') as $attr) {
                     // Expires in 30 days
                     AuxLib::setCookie(CHtml::resolveName($model, $attr), $model->{$attr}, 2592000);
                 }
             } else {
                 foreach (array('username', 'rememberMe') as $attr) {
                     // Remove the cookie if they unchecked the box
                     AuxLib::clearCookie(CHtml::resolveName($model, $attr));
                 }
             }
             // We're not using the isAdmin parameter of the application
             // here because isAdmin in this context hasn't been set yet.
             $isAdmin = Yii::app()->user->checkAccess('AdminIndex');
             if ($isAdmin && !$isMobile) {
                 $this->owner->attachBehavior('updaterBehavior', new UpdaterBehavior());
                 $this->owner->checkUpdates();
                 // check for updates if admin
             } else {
                 Yii::app()->session['versionCheck'] = true;
             }
             // ...or don't
             $session->status = 1;
             $session->save();
             SessionLog::logSession($model->username, $sessionId, 'login');
             $_SESSION['playLoginSound'] = true;
             if (YII_UNIT_TESTING && defined('X2_DEBUG_EMAIL') && X2_DEBUG_EMAIL) {
                 Yii::app()->session['debugEmailWarning'] = 1;
             }
             // if ( isset($_POST['themeName']) ) {
//.........这里部分代码省略.........
开发者ID:dsyman2,项目名称:X2CRM,代码行数:101,代码来源:CommonSiteControllerBehavior.php

示例2: hasError

 /**
  * Checks if model attribute has error, returns true or false
  *
  * @param CActiveRecord $model Model attribute belongs to
  * @param string $attribute Name of attribute
  * @return bool True if attribute has error, otherwise false
  */
 public function hasError($model, $attribute)
 {
     CHtml::resolveName($model, $attribute);
     // turn [a][b]attr into attr
     $error = $model->getError($attribute);
     return $error != '';
 }
开发者ID:elephanthead,项目名称:itr,代码行数:14,代码来源:BetterCActiveForm.php

示例3: getElementName

 public function getElementName()
 {
     // Имя элемента
     // Menu[name]
     $attr = $this->attributeName;
     if ($attr != null) {
         return CHtml::resolveName($this->model, $attr);
     }
     $elementName = "ve_";
     $elementName .= $this->objectParameter->getIdParameter();
     return $elementName;
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:12,代码来源:VisualElementWidget.php

示例4: run

    public function run()
    {
        $cs = Yii::app()->getClientScript();
        $textAreaOptions = $this->gettextareaOptions();
        $textAreaOptions['name'] = CHtml::resolveName($this->model, $this->name);
        $this->id = $textAreaOptions['id'] = CHtml::getIdByName($textAreaOptions['name']);
        echo CHtml::activeTextArea($this->model, $this->name, $textAreaOptions);
        $properties_string = CJavaScript::encode($this->getKeProperties());
        $js = <<<EOF
KindEditor.ready(function(K) {
\tvar editor_{$this->id} = K.create('#{$this->id}', 
{$properties_string}
\t);
});
EOF;
        $cs->registerScript('KE' . $this->name, $js, CClientScript::POS_HEAD);
    }
开发者ID:diandianxiyu,项目名称:Yii1.x-admin,代码行数:17,代码来源:KEditor.php

示例5: getInstances

 /**
  * Returns all uploaded files for the given model attribute.
  * @param CModel $model the model instance
  * @param string $attribute the attribute name. For tabular file uploading, this can be in the format of "[$i]attributeName", where $i stands for an integer index.
  * @return array array of TUploadedFile objects.
  * Empty array is returned if no available file was found for the given attribute.
  */
 public static function getInstances($model, $attribute)
 {
     self::$_files = array();
     if (!isset($_FILES) || !is_array($_FILES)) {
         return [];
     }
     foreach ($_FILES as $class => $info) {
         self::collectFilesRecursive($class, $info['name'], $info['tmp_name'], $info['type'], $info['size'], $info['error']);
     }
     $name = CHtml::resolveName($model, $attribute);
     $len = strlen($name);
     $results = array();
     //Yii::log(var_export(self::$_files, true), CLogger::LEVEL_INFO);
     foreach (array_keys(self::$_files) as $key) {
         //兼容移动客户端上传的附件uploadedfile_x的格式
         if ((0 === strncmp($key, $name, $len) || 1 === preg_match('/^uploadedfile_\\d+$/i', $key)) && self::$_files[$key]->getError() != UPLOAD_ERR_NO_FILE) {
             $results[] = self::$_files[$key];
         }
     }
     return $results;
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:28,代码来源:TUploadedFile.php

示例6: renderElement

 /**
  * Only one line is changed from CForm to render a valid class when
  * using tabular inputs. The line is marked.
  */
 public function renderElement($element)
 {
     if (is_string($element)) {
         if (($e = $this[$element]) === null && ($e = $this->getButtons()->itemAt($element)) === null) {
             return $element;
         } else {
             $element = $e;
         }
     }
     if ($element->getVisible() || $this->getModel()->isAttributeSafe(substr($element->name, 3))) {
         if ($element instanceof CFormInputElement) {
             //print_r($element->name); die;
             if ($element->type === 'hidden') {
                 return "<div style=\"visibility:hidden\">\n" . $element->render() . "</div>\n";
             } else {
                 //print_r($element); die;
                 $elementName = $element->name;
                 return '<div class="row field_' . strtolower(preg_replace('/(\\[\\w*\\])?\\[(\\w*)\\]/', '_$2', CHtml::resolveName($element->getParent()->getModel(), $elementName))) . "\">\n" . $element->render() . "</div>\n";
                 // This line is the change
             }
         } elseif ($element instanceof CFormButtonElement) {
             return $element->render() . "\n";
         } else {
             return $element->render();
         }
     }
     return '';
 }
开发者ID:schrapps,项目名称:risksur,代码行数:32,代码来源:CFormTabular.php

示例7: renderStars

 /**
  * Renders the stars.
  * @param string $id the ID of the container
  * @param string $name the name of the input
  */
 protected function renderStars($id, $name)
 {
     $inputCount = (int) (($this->maxRating - $this->minRating) / $this->ratingStepSize + 1);
     $starSplit = (int) ($inputCount / $this->starCount);
     if ($this->hasModel()) {
         $attr = $this->attribute;
         CHtml::resolveName($this->model, $attr);
         $selection = $this->model->{$attr};
     } else {
         $selection = $this->value;
     }
     $options = $starSplit > 1 ? array('class' => "{split:{$starSplit}}") : array();
     for ($value = $this->minRating, $i = 0; $i < $inputCount; ++$i, $value += $this->ratingStepSize) {
         $options['id'] = $id . '_' . $i;
         $options['value'] = $value;
         if (isset($this->titles[$value])) {
             $options['title'] = $this->titles[$value];
         } else {
             unset($options['title']);
         }
         echo CHtml::radioButton($name, !strcmp($value, $selection), $options) . "\n";
     }
 }
开发者ID:romeo14,项目名称:wallfeet,代码行数:28,代码来源:CStarRating.php

示例8: checkboxGroup

 /**
  * Generates a checkbox group for a model attribute.
  *
  * This method is a wrapper for {@link CActiveForm::checkbox} and {@link customFieldGroup}.
  * Please check {@link CActiveForm::checkbox} for detailed information about $htmlOptions argument.
  * About $options argument parameters see {@link TbActiveForm} documentation.
  *
  * @param CModel $model The data model.
  * @param string $attribute The attribute.
  * @param array $htmlOptions Additional HTML attributes.
  * @param array $options Group attributes.
  * @return string The generated checkbox group.
  * @see CActiveForm::checkbox
  * @see customFieldGroup
  */
 public function checkboxGroup($model, $attribute, $options = array())
 {
     $this->initOptions($options);
     if ($this->type == self::TYPE_INLINE) {
         self::addCssClass($options['labelOptions'], 'inline');
     }
     $field = $this->checkbox($model, $attribute, $options['widgetOptions']['htmlOptions']);
     if ((!array_key_exists('uncheckValue', $options['widgetOptions']) || isset($options['widgetOptions']['uncheckValue'])) && preg_match('/\\<input.*?type="hidden".*?\\>/', $field, $matches)) {
         $hiddenField = $matches[0];
         $field = str_replace($hiddenField, '', $field);
     }
     $realAttribute = $attribute;
     CHtml::resolveName($model, $realAttribute);
     ob_start();
     echo '<div class="checkbox">';
     if (isset($hiddenField)) {
         echo $hiddenField;
     }
     echo CHtml::tag('label', $options['labelOptions'], false, false);
     echo $field;
     if (isset($options['label'])) {
         if ($options['label']) {
             echo $options['label'];
         }
     } else {
         echo ' ' . $model->getAttributeLabel($realAttribute);
     }
     echo CHtml::closeTag('label');
     echo '</div>';
     $fieldData = ob_get_clean();
     $options['label'] = '';
     return $this->customFieldGroupInternal($fieldData, $model, $attribute, $options);
 }
开发者ID:ardhimaarik,项目名称:dapus-generator,代码行数:48,代码来源:TbActiveForm.php

示例9: renderError

 /**
  * Creates the HTML code wrapping the error text for given model attribute.
  *
  * @param CModel $model the data model
  * @param string $attribute the attribute name
  * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
  * @return string the error display. Empty if no errors are found.
  *
  * @see CModel::getErrors
  * @see errorMessageCss
  */
 protected static function renderError($model, $attribute, $htmlOptions = array())
 {
     /* Using side effects of `resolveName`: 
        `$attribute` will be modified: `[a][b]attr` will be turned into `attr` */
     CHtml::resolveName($model, $attribute);
     $error = $model->getError($attribute);
     return $error != '' ? CHtml::tag('span', $htmlOptions, $error) : '';
 }
开发者ID:robebeye,项目名称:isims,代码行数:19,代码来源:TbActiveForm.php

示例10: error

 /**
  * Displays the first validation error for a model attribute.
  * @param CModel $model the data model
  * @param string $attribute the attribute name
  * @param array $htmlOptions additional HTML attributes to be rendered in the container tag.
  * @return string the error display. Empty if no errors are found.
  * @see CModel::getErrors
  * @see errorMessageCss
  * @see $errorContainerTag
  */
 public static function error($model, $attribute, $htmlOptions = array())
 {
     CHtml::resolveName($model, $attribute);
     // turn [a][b]attr into attr
     $error = $model->getError($attribute);
     return $error != '' ? CHtml::tag('span', self::defaultOption('class', self::$errorMessageCss, $htmlOptions), $error) : '';
 }
开发者ID:yii-twbs,项目名称:yiistrap,代码行数:17,代码来源:TbHtml.php

示例11: getAttributeId

 /**
  * Returns the id that should be used for the specified attribute
  * @param string $attribute the attribute
  * @return string the id 
  */
 protected function getAttributeId($attribute)
 {
     return isset($this->htmlOptions['id']) ? $this->htmlOptions['id'] : CHtml::getIdByName(CHtml::resolveName($this->model, $attribute));
 }
开发者ID:niranjan2m,项目名称:Voyanga,代码行数:9,代码来源:BootInput.php

示例12: checkBoxRow

 /**
  * Generates a checkbox row for a model attribute.
  *
  * This method is a wrapper for {@link \CActiveForm::checkBox} and {@link customFieldRow}.
  * Please check {@link \CActiveForm::checkBox} for detailed information about $htmlOptions argument.
  * About $rowOptions argument parameters see {@link ActiveForm} documentation.
  *
  * @param \CModel $model The data model.
  * @param string $attribute The attribute.
  * @param array $htmlOptions Additional HTML attributes.
  * @param array $rowOptions Row attributes.
  * @return string The generated checkbox row.
  * @see \CActiveForm::checkBox
  * @see customFieldRow
  */
 public function checkBoxRow($model, $attribute, $htmlOptions = [], $rowOptions = [])
 {
     $this->initRowOptions($rowOptions);
     Html::addCssClass($rowOptions['labelOptions'], 'checkbox');
     if ($this->type == self::TYPE_INLINE) {
         Html::addCssClass($rowOptions['labelOptions'], 'inline');
     }
     $field = $this->checkBox($model, $attribute, $htmlOptions);
     if ((!array_key_exists('uncheckValue', $htmlOptions) || isset($htmlOptions['uncheckValue'])) && preg_match('/\\<input.*?type="hidden".*?\\>/', $field, $matches)) {
         $hiddenField = $matches[0];
         $field = str_replace($hiddenField, '', $field);
     }
     $realAttribute = $attribute;
     \CHtml::resolveName($model, $realAttribute);
     ob_start();
     if (isset($hiddenField)) {
         echo $hiddenField;
     }
     echo \CHtml::tag('label', $rowOptions['labelOptions'], false, false);
     echo $field;
     if (isset($rowOptions['label'])) {
         if ($rowOptions['label']) {
             echo $rowOptions['label'];
         }
     } else {
         echo $model->getAttributeLabel($realAttribute);
     }
     echo \CHtml::closeTag('label');
     $fieldData = ob_get_clean();
     $rowOptions['label'] = '';
     return $this->customFieldRowInternal($fieldData, $model, $attribute, $rowOptions);
 }
开发者ID:intersvyaz,项目名称:yii-bootstrap,代码行数:47,代码来源:ActiveForm.php

示例13: resolveName

 /**
  * Generate form input name for an attribute so that the urlencoded post data
  * comes in a form that can be properly interpreted by setAttributes in the
  * container model
  * {@link JSONEmbeddedModelFieldsBehavior}
  * @param string $attribute
  */
 public function resolveName($attribute)
 {
     if (!isset($this->exoFormName)) {
         $this->exoFormName = CHtml::resolveName($this->exoModel, $this->exoAttr);
     }
     return $this->exoFormName . strtr(CHtml::resolveName($this, $attribute), array(get_class($this) => ''));
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:14,代码来源:JSONEmbeddedModel.php

示例14: error

 /**
  * Displays the first validation error for a model attribute.
  * This is similar to {@link CHtml::error} except that it registers the model attribute
  * so that if its value is changed by users, an AJAX validation may be triggered.
  * @param CModel $model the data model
  * @param string $attribute the attribute name
  * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
  * Besides all those options available in {@link CHtml::error}, the following options are recognized in addition:
  * <ul>
  * <li>validationDelay</li>
  * <li>validateOnChange</li>
  * <li>validateOnType</li>
  * <li>hideErrorMessage</li>
  * <li>inputContainer</li>
  * <li>errorCssClass</li>
  * <li>successCssClass</li>
  * <li>validatingCssClass</li>
  * <li>beforeValidateAttribute</li>
  * <li>afterValidateAttribute</li>
  * </ul>
  * These options override the corresponding options as declared in {@link options} for this
  * particular model attribute. For more details about these options, please refer to {@link clientOptions}.
  * Note that these options are only used when {@link enableAjaxValidation} or {@link enableClientValidation}
  * is set true.
  *
  * When client-side validation is enabled, an option named "clientValidation" is also recognized.
  * This option should take a piece of JavaScript code to perform client-side validation. In the code,
  * the variables are predefined:
  * <ul>
  * <li>value: the current input value associated with this attribute.</li>
  * <li>messages: an array that may be appended with new error messages for the attribute.</li>
  * <li>attribute: a data structure keeping all client-side options for the attribute</li>
  * </ul>
  * @param boolean $enableAjaxValidation whether to enable AJAX validation for the specified attribute.
  * Note that in order to enable AJAX validation, both {@link enableAjaxValidation} and this parameter
  * must be true.
  * @param boolean $enableClientValidation whether to enable client-side validation for the specified attribute.
  * Note that in order to enable client-side validation, both {@link enableClientValidation} and this parameter
  * must be true. This parameter has been available since version 1.1.7.
  * @return string the validation result (error display or success message).
  * @see CHtml::error
  */
 public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true)
 {
     if (!$this->enableAjaxValidation) {
         $enableAjaxValidation = false;
     }
     if (!$this->enableClientValidation) {
         $enableClientValidation = false;
     }
     if (!isset($htmlOptions['class'])) {
         $htmlOptions['class'] = $this->errorMessageCssClass;
     }
     if (!$enableAjaxValidation && !$enableClientValidation) {
         return CHtml::error($model, $attribute, $htmlOptions);
     }
     $id = CHtml::activeId($model, $attribute);
     $inputID = isset($htmlOptions['inputID']) ? $htmlOptions['inputID'] : $id;
     unset($htmlOptions['inputID']);
     if (!isset($htmlOptions['id'])) {
         $htmlOptions['id'] = $inputID . '_em_';
     }
     $option = array('id' => $id, 'inputID' => $inputID, 'errorID' => $htmlOptions['id'], 'model' => get_class($model), 'name' => CHtml::resolveName($model, $attribute), 'enableAjaxValidation' => $enableAjaxValidation);
     $optionNames = array('validationDelay', 'validateOnChange', 'validateOnType', 'hideErrorMessage', 'inputContainer', 'errorCssClass', 'successCssClass', 'validatingCssClass', 'beforeValidateAttribute', 'afterValidateAttribute');
     foreach ($optionNames as $name) {
         if (isset($htmlOptions[$name])) {
             $option[$name] = $htmlOptions[$name];
             unset($htmlOptions[$name]);
         }
     }
     if ($model instanceof CActiveRecord && !$model->isNewRecord) {
         $option['status'] = 1;
     }
     if ($enableClientValidation) {
         $validators = isset($htmlOptions['clientValidation']) ? array($htmlOptions['clientValidation']) : array();
         foreach ($model->getValidators($attribute) as $validator) {
             if ($enableClientValidation && $validator->enableClientValidation) {
                 if (($js = $validator->clientValidateAttribute($model, $attribute)) != '') {
                     $validators[] = $js;
                 }
             }
         }
         if ($validators !== array()) {
             $option['clientValidation'] = "js:function(value, messages, attribute) {\n" . implode("\n", $validators) . "\n}";
         }
     }
     $html = CHtml::error($model, $attribute, $htmlOptions);
     if ($html === '') {
         if (isset($htmlOptions['style'])) {
             $htmlOptions['style'] = rtrim($htmlOptions['style'], ';') . ';display:none';
         } else {
             $htmlOptions['style'] = 'display:none';
         }
         $html = CHtml::tag('div', $htmlOptions, '');
     }
     $this->attributes[$inputID] = $option;
     return $html;
 }
开发者ID:israelCanul,项目名称:Bonanza_V2,代码行数:98,代码来源:CActiveForm.php

示例15: renderBoolean

 public function renderBoolean($field, array $htmlOptions = array())
 {
     $fieldName = $field->fieldName;
     $inputName = CHtml::resolveName($this->owner, $fieldName);
     $for = CHtml::getIdByName($inputName);
     return CHtml::label('', $for) . CHtml::activeCheckBox($this->owner, $field->fieldName, array_merge(array('unchecked' => 0, 'title' => $field->attributeLabel), $htmlOptions));
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:7,代码来源:MobileFieldInputRenderer.php


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