本文整理汇总了PHP中CHtml::button方法的典型用法代码示例。如果您正苦于以下问题:PHP CHtml::button方法的具体用法?PHP CHtml::button怎么用?PHP CHtml::button使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHtml
的用法示例。
在下文中一共展示了CHtml::button方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerClientScript
public function registerClientScript()
{
$cs = Yii::app()->clientScript;
$id = $this->imageOptions['id'];
$url = $this->getController()->createUrl($this->captchaAction, array(CCaptchaAction::REFRESH_GET_VAR => true));
$js = "";
if ($this->showRefreshButton) {
// reserve a place in the registered script so that any enclosing button js code appears after the captcha js
// $cs->registerScript('Yii.CCaptcha#' . $id, '// dummy');
echo CHtml::script('// dummy');
$label = $this->buttonLabel === null ? Yii::t('yii', 'Get a new code') : $this->buttonLabel;
$options = $this->buttonOptions;
if (isset($options['id'])) {
$buttonID = $options['id'];
} else {
$buttonID = $options['id'] = $id . '_button';
}
if ($this->buttonType === 'button') {
$html = CHtml::button($label, $options);
} else {
$html = CHtml::link($label, $url, $options);
}
$js = "jQuery('#{$id}').after(" . CJSON::encode($html) . ");";
$selector = "#{$buttonID}";
}
if ($this->clickableImage) {
$selector = isset($selector) ? "{$selector}, #{$id}" : "#{$id}";
}
if (!isset($selector)) {
return;
}
$js .= "\njQuery(document).on('click', '{$selector}', function(){\n\tjQuery.ajax({\n\t\turl: " . CJSON::encode($url) . ",\n\t\tdataType: 'json',\n\t\tcache: false,\n\t\tsuccess: function(data) {\n var url = data['url'].split('?v=');\n var newCode = url[url.length - 1];\n var imgSrc = jQuery('#{$id}').attr('src').split('/');\n var oldCode = imgSrc[imgSrc.length - 1];\n var newUrl = jQuery('#{$id}').attr('src').replace(oldCode, newCode);\n \n\t\t\tjQuery('#{$id}').attr('src', newUrl);\n\t\t\tjQuery('body').data('{$this->captchaAction}.hash', [data['hash1'], data['hash2']]);\n\t\t}\n\t});\n\treturn false;\n});\n";
// $cs->registerScript('Yii.CCaptcha#' . $id, $js);
echo CHtml::script($js);
}
示例2: init
public function init()
{
$assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/assets');
if (!isset($this->htmlOptions['id'])) {
$this->htmlOptions['id'] = $this->getId();
}
$this->id = $id = $this->htmlOptions['id'];
echo CHtml::image($this->url, $this->alt, $this->htmlOptions);
if (!empty($this->buttons)) {
echo '<div class="jcrop-buttons">' . CHtml::button($this->buttons['start']['label'], $this->getHtmlOptions('start', 'inline'));
echo CHtml::button($this->buttons['crop']['label'], $this->getHtmlOptions('crop'));
echo CHtml::button($this->buttons['cancel']['label'], $this->getHtmlOptions('cancel')) . '</div>';
}
echo CHtml::hiddenField($id . '_x', 0, array('class' => 'coords'));
echo CHtml::hiddenField($id . '_y', 0, array('class' => 'coords'));
echo CHtml::hiddenField($id . '_w', 0, array('class' => 'coords'));
echo CHtml::hiddenField($id . '_h', 0, array('class' => 'coords'));
echo CHtml::hiddenField($id . '_x2', 0, array('class' => 'coords'));
echo CHtml::hiddenField($id . '_y2', 0, array('class' => 'coords'));
$cls = Yii::app()->getClientScript();
$cls->registerScriptFile($assets . '/js/jquery.Jcrop.min.js');
$cls->registerScriptFile($assets . '/js/ejcrop.js', CClientScript::POS_HEAD);
$cls->registerCssFile($assets . '/css/jquery.Jcrop.css');
$this->options['onChange'] = "js:function(c) {ejcrop_getCoords(c,'{$id}'); ejcrop_showThumb(c,'{$id}');}";
$this->options['ajaxUrl'] = $this->ajaxUrl;
$this->options['ajaxParams'] = $this->ajaxParams;
$options = CJavaScript::encode($this->options);
if (!empty($this->buttons)) {
$js = "ejcrop_initWithButtons('{$id}', {$options});";
} else {
$js = "jQuery('#{$id}').Jcrop({$options});";
}
$cls->registerScript(__CLASS__ . '#' . $id, $js, CClientScript::POS_READY);
}
示例3: actiongetPreNextId
public function actiongetPreNextId()
{
$preId = '';
$nextId = '';
$preDisabled = '';
$nextDisabled = '';
$needToConfirmStr = '$needToConfirm = false;';
$id = (int) $_GET['id'];
$infoType = $_GET['type'];
$productId = (int) $_GET['product_id'];
$preNextSql = Yii::app()->user->getState($productId . '_' . $infoType . '_prenextsql');
if (isset($id) && isset($preNextSql)) {
$idSearchResult = Yii::app()->db->createCommand($preNextSql)->queryAll();
list($preId, $nextId) = InfoService::getPreNextValue($idSearchResult, $id);
}
if ('' == $preId) {
$preDisabled = 'disabled';
}
if ('' == $nextId) {
$nextDisabled = 'disabled';
}
$listStr = CHtml::button(Yii::t('Common', 'Previous') . '(P)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'id' => $preId)) . '"', 'class' => 'btn', 'disabled' => $preDisabled, 'accesskey' => 'P'));
$listStr .= CHtml::button(Yii::t('Common', 'Next') . '(N)', array('onclick' => $needToConfirmStr . 'location.href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'id' => $nextId)) . '"', 'class' => 'btn', 'disabled' => $nextDisabled, 'accesskey' => 'N'));
echo $listStr;
}
示例4: run
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;
}
$contHtmlOptions = $this->htmlOptions;
$contHtmlOptions['id'] = $id . 'container';
echo CHtml::openTag('div', $contHtmlOptions);
$inputOptions = array('id' => $id);
if ($this->hasModel()) {
echo CHtml::activeHiddenField($this->model, $this->attribute, $inputOptions);
$imgPath = $this->model->{$this->attribute};
} else {
echo CHtml::hiddenField($name, $this->value, $inputOptions);
$imgPath = $this->value;
}
if (!@getimagesize($imgPath)) {
$imgPath = $this->assetsDir . '/images/no-photo.gif';
}
echo CHtml::image($imgPath, 'preview', array('id' => 'image-preview-' . $id, 'style' => 'max-width: 120px; max-height: 120px; display: block; margin-bottom: 10px;'));
echo CHtml::button('Browse', array('id' => $id . 'browse', 'class' => 'btn'));
echo CHtml::closeTag('div');
$settings = array_merge(array('places' => "", 'rememberLastDir' => false), $this->settings);
$settings['dialog'] = array('zIndex' => 400001, 'width' => 900, 'modal' => true, 'title' => "Files");
$settings['editorCallback'] = 'js:function(url) {
$(\'#\'+aFieldId).attr(\'value\',url);
$(\'#image-preview-\'+aFieldId).attr(\'src\',url);
}';
$settings['closeOnEditorCallback'] = true;
$connectorUrl = CJavaScript::encode($this->settings['url']);
$settings = CJavaScript::encode($settings);
$script = <<<EOD
window.elfinderBrowse = function(field_id, connector) {
var aFieldId = field_id, aWin = this;
if(\$("#elFinderBrowser").length == 0) {
\$("body").append(\$("<div/>").attr("id", "elFinderBrowser"));
var settings = {$settings};
settings["url"] = connector;
\$("#elFinderBrowser").elfinder(settings);
}
else {
\$("#elFinderBrowser").elfinder("open", connector);
}
}
EOD;
$cs = Yii::app()->getClientScript();
$cs->registerScript('ServerFileInput#global', $script);
$js = '$("#' . $id . 'browse").click(function(){window.elfinderBrowse("' . $id . '", ' . $connectorUrl . ')});';
$cs->registerScript('ServerFileInput#' . $id, $js);
}
示例5: ajaxSubmitButton
public static function ajaxSubmitButton($label, $url, $ajaxOptions = array(), $htmlOptions = array())
{
if (self::getJValidateInstance()->isEnabled()) {
list($label, $htmlOptions) = self::getJValidateInstance()->ajaxSubmitButton($label, $url, $ajaxOptions, $htmlOptions);
return parent::button($label, $htmlOptions);
} else {
return parent::ajaxSubmitButton($label, $url, $ajaxOptions, $htmlOptions);
}
}
示例6: init
public function init()
{
if (Yii::app()->user->isGuest) {
return;
}
Yii::app()->clientScript->registerScriptFile('/scripts/feed.js');
$isFollowing = $this->feed->isFollowing(Yii::app()->user->id);
echo CHtml::button(Yii::t('app', 'Follow'), array('class' => 'follow', 'onclick' => new CJavaScriptExpression('app.feed.follow.call(this, ' . $this->feed->id . ')'), 'style' => $isFollowing ? 'display: none;' : ''));
echo CHtml::button(Yii::t('app', 'Unfollow'), array('class' => 'unfollow', 'onclick' => new CJavaScriptExpression('app.feed.unfollow.call(this, ' . $this->feed->id . ')'), 'style' => $isFollowing ? '' : 'display: none;'));
}
示例7: run
/**
* Execute the widget
* This method registers necessary javascript and renders the needed HTML code.
*/
public function run()
{
$this->registerClientScripts();
if ($this->_calButton == false) {
echo CHtml::activeTextField($this->_model, $this->_attribute, array('id' => $this->_inputField, 'onclick' => 'displayCalendar(' . $this->_inputField . ',"' . $this->_daFormat . '",this,false)'));
} else {
echo CHtml::activeTextField($this->_model, $this->_attribute, array('id' => $this->_inputField, 'readonly' => 'readonly'));
echo CHtml::button('Calendar', array('onclick' => 'displayCalendar(' . $this->_inputField . ',"' . $this->_daFormat . '",this,false)'));
}
}
示例8: run
public function run()
{
$cmd = CHtml::button($this->cmdLable, array('id' => 'export-button', 'class' => 'span-3 button', 'title' => $this->girdId, 'onclick' => 'CsvExporter.export(this)'));
$ddl = '';
if (!empty($this->ddlOptions)) {
$ddlOptions = array('name' => 'exportType', 'select' => '', 'data' => array(), 'htmlOptions' => array('for' => 'exportType'));
$ddlOptions = CMap::mergeArray($ddlOptions, $this->ddlOptions);
$ddl = CHtml::dropDownList($ddlOptions['name'], $ddlOptions['select'], $ddlOptions['data'], $ddlOptions['htmlOptions']);
}
echo strtr($this->template, array('{cmd}' => $cmd, '{ddl}' => $ddl));
$cs = Yii::app()->getClientScript();
$cs->registerScript(__CLASS__, $this->jsCode(), CClientScript::POS_END);
}
示例9: run
public function run()
{
list($name, $id) = $this->resolveNameID();
if (!isset($this->htmlOptions['name'])) {
$this->htmlOptions['name'] = $name;
}
if (!isset($this->htmlOptions['id'])) {
$this->htmlOptions['id'] = $id;
}
switch ($this->buttonType) {
case 'submit':
echo CHtml::submitButton($this->caption, $this->htmlOptions);
break;
case 'button':
echo CHtml::button($this->caption, $this->htmlOptions);
break;
case 'link':
echo CHtml::link($this->caption, $this->url, $this->htmlOptions);
break;
case 'radio':
if ($this->hasModel()) {
echo CHtml::activeRadioButton($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::radioButton($name, $this->value, $this->htmlOptions);
}
break;
case 'checkbox':
if ($this->hasModel()) {
echo CHtml::activeCheckbox($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::checkbox($name, $this->value, $this->htmlOptions);
}
break;
default:
throw new CException(Yii::t('zii', 'The button type "{type}" is not supported.', array('{type}' => $this->buttonType)));
}
$cs = Yii::app()->getClientScript();
$options = empty($this->options) ? '' : CJavaScript::encode($this->options);
if (isset($this->onclick)) {
if (strpos($this->onclick, 'js:') !== 0) {
$this->onclick = 'js:' . $this->onclick;
}
$click = CJavaScript::encode($this->onclick);
$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').button({$options}).click({$click});");
} else {
$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').button({$options});");
}
}
示例10: approve_buttons
function approve_buttons($data)
{
$html = '';
if ($data->approve == Payment::FREE) {
$html .= CHtml::button(Yii::t('site', 'Confirm'), array('class' => 'btn btn-primary btn-xs approve_payment', 'href' => $data->id, 'onclick' => 'setApprove($(this).attr("href"),$("#paymentType_"+$(this).attr("href")).val(),$("#payDetailNumber_"+$(this).attr("href")).val());return false;'));
}
if ($data->approve == Payment::FREE) {
$html .= CHtml::button(Yii::t('site', 'Reject'), array('class' => 'btn btn-primary btn-xs reject_payment', 'href' => $data->id, 'onclick' => 'setReject($(this).attr("href"));return false;'));
}
if ($data->approve == Payment::APPROVED) {
$html .= Yii::t('site', 'Confirmed');
}
if ($data->approve == Payment::REJECTED) {
$html .= Yii::t('site', 'Rejected');
}
return $html;
}
示例11: genContentTab
private function genContentTab($field, $lang)
{
$isCKEditor = $this->type == 'text-editor' ? 1 : 0;
$fieldId = 'id_' . $this->modelName . $this->field . '_' . $lang;
$html = '';
if ($this->useTranslate) {
$html .= '<div class="translate_button" >';
$html .= '<span class="t_loader_' . $this->modelName . $this->field . '" style="display: none;"><img src="' . Yii::app()->theme->baseUrl . '/images/ajax-loader.gif" alt="Переводим"></span>';
$html .= CHtml::button(tc('Translate'), array('onClick' => "translateField('{$this->field}', '{$lang}', '{$isCKEditor}', '" . $this->modelName . "')"));
$html .= '</div>';
}
if ($this->useCopyButton) {
$html .= '<div class="copylang_button">';
$html .= CHtml::button(tc('Copy to all languages'), array('onClick' => "copyField('{$this->field}', '{$lang}', '{$isCKEditor}', '" . $this->modelName . "')"));
$html .= '</div>';
}
$html .= '<div class="rowold">';
$html .= CHtml::activeLabel($this->model, $this->field, array('required' => $this->model->isLangAttributeRequired($this->field)));
$html .= Apartment::getTip($this->field);
if ($this->note) {
$html .= CHtml::tag('p', array('class' => 'note'), $this->note);
}
switch ($this->type) {
case 'string':
$html .= CHtml::activeTextField($this->model, $field, array('class' => 'width500', 'maxlength' => 255, 'id' => $fieldId));
break;
case 'text':
$html .= CHtml::activeTextArea($this->model, $field, array('class' => 'width500 height200', 'id' => $fieldId));
break;
case 'text-editor':
$html .= '<div class="clear"></div>';
$filebrowserImageUploadUrl = '';
$allowedContent = false;
if (Yii::app()->user->checkAccess('upload_from_wysiwyg')) {
// if admin - enable upload image
$filebrowserImageUploadUrl = Yii::app()->createAbsoluteUrl('/site/uploadimage', array('type' => 'imageUpload', Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken));
$allowedContent = true;
}
$html .= $this->widget('application.extensions.editMe.widgets.ExtEditMe', array('model' => $this->model, 'attribute' => $field, 'toolbar' => array(array('Source', '-', 'Bold', 'Italic', 'Underline', 'Strike'), array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'), array('NumberedList', 'BulletedList', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'), array('Styles', 'Format', 'Font', 'FontSize', 'TextColor', 'BGColor'), array('Image', 'Link', 'Unlink', 'SpecialChar')), 'allowedContent' => $allowedContent, 'filebrowserImageUploadUrl' => $filebrowserImageUploadUrl, 'htmlOptions' => array('id' => $fieldId)), true);
break;
}
$html .= CHtml::error($this->model, $field);
$html .= '</div>';
$this->fieldIdArr[$lang] = $fieldId;
return $html;
}
示例12: run
public function run()
{
Yii::app()->clientScript->registerCoreScript('jquery');
echo CHtml::button($this->uncheckedTitle, array('id' => 'button-' . $this->id, 'class' => 'check-all-btn', 'onclick' => '
switch($(this).val())
{
case "' . $this->checkedTitle . '":
$(this).val("' . $this->uncheckedTitle . '");
$("input[type=checkbox]").attr("checked", false);
break;
case "' . $this->uncheckedTitle . '":
$(this).val("' . $this->checkedTitle . '");
$("input[type=checkbox]").attr("checked", true);
break;
}
'));
}
示例13: init
public function init()
{
//gridId is required
if (empty($this->ecolumns['gridId'])) {
throw new CException('You must provide gridId');
}
if ($this->getId(false) === null) {
$this->setId($this->ecolumns['gridId'] . '-ecolumns-dlg');
}
//prepare EColumns params
if (!isset($this->ecolumns['buttonCancel'])) {
$this->ecolumns['buttonCancel'] = CHtml::button('Close', array('type' => 'button', 'onclick' => '$("#' . $this->getId() . '").dialog("close"); return false;', 'style' => 'float: right'));
}
if (!isset($this->ecolumns['buttonApply'])) {
$this->ecolumns['buttonApply'] = CHtml::button('Apply', array('type' => 'submit', 'onclick' => '$("#' . $this->getId() . '").dialog("close")', 'style' => 'float: left'));
}
//create EColumns object
$this->_ecolumns = $this->owner->createWidget('ext.ecolumns.EColumns', $this->ecolumns);
parent::init();
$this->_ecolumns->run();
//handler for click on link
yii::app()->clientScript->registerScript($this->getLinkId(), "\r\n jQuery('#{$this->getLinkId()}').live('click', function() { jQuery('#{$this->getId()}').dialog('open'); return false; })\r\n ", CClientScript::POS_READY);
}
示例14: run
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->size !== null) {
$this->htmlOptions['size'] = $this->size;
}
$this->registerClientScript();
print "<ul><li>" . Yii::t('cms', 'URL') . " ";
if ($this->hasModel()) {
echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
} else {
echo CHtml::textField($name, $this->value, $this->htmlOptions);
}
if ($this->showFileManagerButton) {
echo "</li><li>" . Yii::t('cms', 'or') . " ";
echo CHtml::button(Yii::t('cms', 'Browse uploaded'), array('id' => $this->htmlOptions['id'] . '_button', 'class' => 'cms-button'));
}
if ($this->showUploadButton) {
echo "</li><li>" . Yii::t('cms', 'or') . " <div id='" . $this->htmlOptions['id'] . "_file'></div>";
}
if ($this->showPageSelectButton) {
echo "</li><li>" . Yii::t('cms', 'or') . " " . Yii::t('cms', 'Select page') . "<br />";
$this->widget('PageSelect', array('textLinkId' => $this->htmlOptions['id'], 'name' => 'PageSelect', 'id' => $this->htmlOptions['id'] . '_PageSelect'));
}
echo "</li></ul>";
}
示例15: formInput
public function formInput(&$controller, $tagOptions=array())
{
if(!Yii::app()->clientScript->isScriptFileRegistered(AutoAdmin::$assetPath.'/js/text-editor.js'))
Yii::app()->clientScript->registerScriptFile(AutoAdmin::$assetPath.'/js/text-editor.js');
ob_start();
$inputName = $this->formInputName();
$inputID = "i_{$inputName}";
echo CHtml::label($this->label, $inputID);
echo CHtml::tag('br');
$value = str_replace('<br/>', "\n", $this->value);
$value = AAHelperForm::prepareTextForForm($value);
$value = str_replace("<p>", "", $value);
$value = str_replace("</p>", "", $value);
$tagOptions['id'] = $inputID;
if($this->isReadonly)
$tagOptions['disabled'] = true;
else
{
echo CHtml::button('STRONG');
echo CHtml::button('EM');
echo CHtml::button('H3');
echo CHtml::button('H4');
echo CHtml::button('UL');
echo CHtml::button('OL');
echo CHtml::button('Link');
echo CHtml::button('MailTo');
echo CHtml::button('Img');
echo CHtml::button('<..>');
}
echo CHtml::textArea($inputName, $value, $tagOptions);
return ob_get_clean();
}