本文整理汇总了PHP中CWidget类的典型用法代码示例。如果您正苦于以下问题:PHP CWidget类的具体用法?PHP CWidget怎么用?PHP CWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
Yii::import('album.AlbumModule');
Yii::import('album.actions.*');
Yii::import('album.models.*');
parent::init();
}
示例2: init
public function init()
{
if (isset($_POST)) {
$startHidden = false;
}
if ($this->startHidden) {
// register css
Yii::app()->clientScript->registerCssFile(Yii::app()->theme->getBaseUrl() . '/css/inlinequotes.css');
// register (lots of) javascript
Yii::app()->clientScript->registerScript('toggleQuotes', ($this->startHidden ? "\$(document).ready(function() { \$('#quotes-form').hide();\n\t\t\t });\n" : '') . "function toggleQuotes() {\n\t\t\t\t\n\t\t\t\tif(\$('#quotes-form').is(':hidden')) {\n\t\t\t\t\t\$('.focus-mini-module').removeClass('focus-mini-module');\n\t\t\t\t\t\$('#quotes-form').find('.wide.form').addClass('focus-mini-module');\n\t\t\t\t\t\$('html,body').animate({\n\t\t\t\t\t\tscrollTop: (\$('#action-form').offset().top - 200)\n\t\t\t\t\t}, 300);\n\t\t\t\t}\n\t\t\t\t\$('#quotes-form').toggle('blind',300,function() {\n\t\t\t\t\t\$('#quotes-form').focus();\n\t\t\t\t});\n\t\t\t}\n\t\t\t\n\t\t\t\$(function() {\n\t\t\t\t\$('#quotes-form').click(function() {\n\t\t\t\t\tif(sendingQuote) {\n\t\t\t\t\t\tsendingQuote = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif(!\$('#quotes-form').find('.wide.form').hasClass('focus-mini-module')) {\n\t\t\t\t\t\t\t\$('.focus-mini-module').removeClass('focus-mini-module');\n\t\t\t\t\t\t\t\$('#quotes-form').find('.wide.form').addClass('focus-mini-module');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t});\n\t\t\t});\n\t\t\t", CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScript('emailQuote', "\n\t\tfunction appendEmail(line) {\n\t\t\tvar email = \$('#email-message');\n\t\t\temail.val(email.val() + line + " . '""' . ");\n\t\t}\n\t\t\n\t\tvar sendingQuote = false;\n\t\tfunction sendQuoteEmail(quote) {\n\t\t\tvar notes = " . '"\\n"' . " + quote['notes']['label'] + " . '"\\n"' . " + quote['notes']['notes'] + " . '"\\n"' . ";\n\t\t\ttoggleEmailForm();\n\t\t\tteditor.e.body.innerHTML = '' + quote['name'] + quote['products'] + notes;\n\t\t\tvar value = \$('#email-template option:contains(\"Quote\")').val();\n\t\t\t\$('#email-template').val(value);\n\t\t\t\$('#InlineEmail_subject').val('Quote');\n\t\t\t\$('#email-template').change();\n\t\t sendingQuote = true; // stop quote mini-module from stealing focus away from email\n\t\t}\n\t\t", CClientScript::POS_HEAD);
$products = Product::model()->findAll(array('select' => 'id, name, price'));
$jsProductList = "\$(productList).append(\$('<option>', {value: 0}).append(''));\n";
$jsProductPrices = "var prices = [];\n";
$jsProductPrices .= "prices[0] = 0;\n";
foreach ($products as $product) {
$jsProductList .= "\$(productList).append(\$('<option>', {value: {$product->id}}).append('{$product->name}'));\n";
$jsProductPrices .= "prices[{$product->id}] = {$product->price};\n";
}
$productNames = Product::productNames();
$jsonProductList = json_encode($productNames);
$region = Yii::app()->getLocale()->getId();
Yii::app()->clientScript->registerScript('productTable', "\n\n// translate ISO 4217 currency into i18n\nvar currencyTable = {\n\t'USD': 'en-US',\n\t'EUR': 'hsb-DE',\n\t'GBP': 'en-GB',\n\t'CAD': 'en-CA',\n\t'JPY': 'ja-JP',\n\t'CNY': 'zh-CN',\n\t'CHF': 'de-CH',\n\t'INR': 'hi-IN',\n\t'BRL': 'pt-BR',\n};\n\nfunction removeProduct(object) {\n\t\$(object).closest('tr').remove();\n\tupdateProductTotal();\n}\n\nfunction updateProduct(id, price, quantity, adjustments, label, currency) {\n\tprice = parseFloat(price);\n\tquantity = parseFloat(quantity);\n\tvar total = price * quantity;\n\tvar index = adjustments.indexOf('%');\n\tif(index == -1) { // adjustment\n\t total += parseFloat(adjustments);\n\t} else { // percent adjustment\n\t adjustments = adjustments.substring(0, index);\n\t adjustments = parseFloat(adjustments) / 100;\n\t total += total * adjustments;\n\t}\n\t\$(label).html('' + total);\n\t\$(label).formatCurrency({'region': currencyTable[currency]});\n\tupdateProductTotal(id, currency);\n}\n\nfunction updateProductTotal(id, currency) {\n\tvar total = 0;\n\t\$('#product-table-' + id + ' .product-list-price').each(function () {\n\t\t\$(this).toNumber({'region': currencyTable[currency]});\n\t total += parseFloat(\$(this).html());\n\t \$(this).formatCurrency({'region': currencyTable[currency]});\n\t});\n\t\$('#product-list-total-' + id).html('' + total);\n\t\$('#product-list-total-' + id).formatCurrency({'region': currencyTable[currency]});\n}\n\n\n\nfunction addProduct(id, currency, productNames, prices) {\n\tvar row = \$('<tr></tr>');\n\t\$('#product-table-' + id + ' tbody').append(row);\n\n\tvar td = \$('<td></td>');\n\tvar tdRemove = \$('<td></td>', {\n\t\t'style': 'padding: 0;'\n\t});\n\t\n\tvar remove = \$('<a>', {\n\t\thref: 'javascript:void(0)',\n\t\t'onClick': 'removeProduct(this);'\n\t});\n\tvar removeImage = \$('<img>', {\n\t\tsrc: '" . Yii::app()->request->baseUrl . '/themes/x2engine/css/gridview/delete.png' . "',\n\t\talt: '[" . Yii::t('quotes', 'Delete Quote') . "]'\n\t});\n\t\$(row).append(tdRemove.clone().append(remove));\n\t\$(remove).append(removeImage);\n\t\n\tvar productList = \$('<select>', {\n\t\tname: 'ExistingProducts[id][]'\n\t});\n\t\$(row).append(td.clone().append(productList));\n\tfor(var i in productNames) {\n\t\t\$(productList).append(\$('<option>', {value: i}).append(productNames[i]));\n\t}\n\t\n\tvar price = \$('<input>', {\n\t\ttype: 'text',\n\t\tsize: 10,\n\t\t'onFocus': 'toggleText(this);',\n\t\t'onBlur': 'toggleText(this);',\n\t\t'style': 'color:#aaa;',\n\t\tname: 'ExistingProducts[price][]',\n\t\tvalue: 0\n\t});\n\t\$(row).append(td.clone().append(price));\n\t\n\tvar quantity = \$('<input>', {\n\t\ttype: 'text',\n\t\tsize: 10,\n\t\t'onFocus': 'toggleText(this);',\n\t\t'onBlur': 'toggleText(this);',\n\t\t'style': 'color:#aaa;',\n\t\tname: 'ExistingProducts[quantity][]',\n\t\tvalue: 0\n\t});\n\t\$(row).append(td.clone().append(quantity));\n\t\n\tvar adjustments = \$('<input>', {\n\t\ttype: 'text',\n\t\tsize: 10,\n\t\t'onFocus': 'toggleText(this);',\n\t\t'onBlur': 'toggleText(this);',\n\t\t'style': 'color:#aaa;',\n\t\tname: 'ExistingProducts[adjustment][]',\n\t\tvalue: 0\n\t});\n\t\$(row).append(td.clone().append(adjustments));\n\t\n\tvar label = \$('<label>', {\n\t\t'class': 'product-list-price',\n\t\t'style': 'width: auto;',\n\t});\n\t\$(row).append(td.clone().append(label));\n\t\$(label).append('0');\n\t\n\t\$(productList).change(function() {\n\t\t\$(price).val('' + prices[\$(this).attr('value')]);\n\t\t\$(price).css('color', 'black');\n\t\tupdateProduct(id, \$(price).val(), \$(quantity).val(), \$(adjustments).val(), label, currency);\n\t});\n\t\n\t\$('#update-quote-button-' + id).css('background', 'yellow');\n\t\n\t\$(price).change(function() {\n\t\tupdateProduct(id, \$(price).val(), \$(quantity).val(), \$(adjustments).val(), label, currency);\n\t});\n\t\n\t\$(quantity).change(function() {\n\t\tupdateProduct(id, \$(price).val(), \$(quantity).val(), \$(adjustments).val(), label, currency);\n\t});\n\t\n\t\$(adjustments).change(function() {\n\t\tupdateProduct(id, \$(price).val(), \$(quantity).val(), \$(adjustments).val(), label, currency);\n\t});\n} \n\n\nfunction addFilledProduct(id, fillId, fillPrice, fillQuantity, fillAdjustment, currency, productNames, prices) {\n\tvar row = \$('<tr></tr>');\n\t\$('#product-table-' + id + ' tbody').append(row);\n\n\tvar td = \$('<td></td>');\n\tvar tdRemove = \$('<td></td>', {\n\t\t'style': 'padding: 0;'\n\t});\n\t\n\tvar remove = \$('<a>', {\n\t\thref: 'javascript:void(0)',\n\t\t'onClick': 'removeProduct(this);'\n\t});\n\tvar removeImage = \$('<img>', {\n\t\tsrc: '" . Yii::app()->request->baseUrl . '/themes/x2engine/css/gridview/delete.png' . "',\n\t\talt: '[" . Yii::t('quotes', 'Delete Quote') . "]'\n\t});\n\t\$(row).append(tdRemove.clone().append(remove));\n\t\$(remove).append(removeImage);\n\t\n\tvar productList = \$('<select>', {\n\t\tname: 'ExistingProducts[id][]',\n\t});\n\t\$(row).append(td.clone().append(productList));\n\tfor(var i in productNames) {\n\t\t\$(productList).append(\$('<option>', {value: i}).append(productNames[i]));\n\t}\n\t\$(productList).val(fillId);\n\t\n\tvar price = \$('<input>', {\n\t\ttype: 'text',\n\t\tsize: 10,\n\t\t'onFocus': 'toggleText(this);',\n\t\t'onBlur': 'toggleText(this);',\n\t\tname: 'ExistingProducts[price][]',\n\t\tvalue: 0,\n\t\tdefaultValue: 0,\n\t});\n\t\$(row).append(td.clone().append(price));\n\t\$(price).val(fillPrice);\n\t\n\tvar quantity = \$('<input>', {\n\t\ttype: 'text',\n\t\tsize: 10,\n\t\t'onFocus': 'toggleText(this);',\n\t\t'onBlur': 'toggleText(this);',\n\t\tname: 'ExistingProducts[quantity][]',\n\t\tvalue: 0,\n\t\tdefaultValue: 0,\n\t});\n\t\$(row).append(td.clone().append(quantity));\n\t\$(quantity).val(fillQuantity);\n\t\n\tvar adjustments = \$('<input>', {\n\t\ttype: 'text',\n\t\tsize: 10,\n\t\t'onFocus': 'toggleText(this);',\n\t\t'onBlur': 'toggleText(this);',\n\t\tname: 'ExistingProducts[adjustment][]',\n\t\tvalue: 0,\n\t\tdefaultValue: 0,\n\t});\n\t\$(row).append(td.clone().append(adjustments));\n\t\$(adjustments).val(fillAdjustment);\n\t\n\tvar label = \$('<label>', {\n\t\t'class': 'product-list-price',\n\t\t'style': 'width: auto;',\n\t});\n\t\$(row).append(td.clone().append(label));\n\t\$(label).append('0');\n\t\n\tupdateProduct(id, \$(price).val(), \$(quantity).val(), \$(adjustments).val(), label, currency);\n\n\t\$(productList).change(function() {\n\t\t\$(price).val('' + prices[\$(this).attr('value')]);\n\t\t\$(price).css('color', 'black');\n\t\t\$('#update-quote-button-' + id).css('background', 'yellow');\n\t\tupdateProduct(id, \$(price).val(), \$(quantity).val(), \$(adjustments).val(), label, currency);\n\t});\n\t\n\t\$(price).change(function() {\n\t\t\$('#update-quote-button-' + id).css('background', 'yellow');\n\t\tupdateProduct(id, \$(price).val(), \$(quantity).val(), \$(adjustments).val(), label, currency);\n\t});\n\t\n\t\$(quantity).change(function() {\n\t\t\$('#update-quote-button-' + id).css('background', 'yellow');\n\t\tupdateProduct(id, \$(price).val(), \$(quantity).val(), \$(adjustments).val(), label, currency);\n\t});\n\t\n\t\$(adjustments).change(function() {\n\t\t\$('#update-quote-button-' + id).css('background', 'yellow');\n\t\tupdateProduct(id, \$(price).val(), \$(quantity).val(), \$(adjustments).val(), label, currency);\n\t});\n}\n\nfunction toggleUpdateQuote(id, locked, strict) {\n\tvar confirmBox = \$('<div></div>')\n\t\t.html('This quote is locked. Are you sure you want to update this quote?')\n\t\t.dialog({\n\t\t\ttitle: 'Locked', \n\t\t\tautoOpen: false,\n\t\t\tresizable: false,\n\t\t\tbuttons: {\n\t\t\t\t'Yes': function() {\n\t\t\t\t\t\$('#quote-detail-' + id).hide('blind', 'slow');\n\t\t\t\t\t\$('#quote-update-' + id).show('slow');\n\t\t\t\t\t\$(this).dialog('close');\n\t\t\t\t},\n\t\t\t\t'No': function() {\n\t\t\t\t\t\$(this).dialog('close');\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\tvar denyBox = \$('<div></div>')\n\t\t.html('This quote is locked.')\n\t\t.dialog({\n\t\t\ttitle: 'Locked', \n\t\t\tautoOpen: false,\n\t\t\tresizable: false,\n\t\t\tbuttons: {\n\t\t\t\t'OK': function() {\n\t\t\t\t\t\$(this).dialog('close');\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\t\n\tif(locked)\n\t\tif(strict)\n\t\t\tdenyBox.dialog('open');\n\t\telse\n\t\t\tconfirmBox.dialog('open');\n\telse {\n\t\t\$('#quote-detail-' + id).hide('blind', 'slow');\n\t\t\$('#quote-update-' + id).show('slow');\n\t}\n}\n\nfunction toggleNewQuote() {\n\t\$('#show-new-quote-button').hide('blind', 'slow');\n\t\$('#new-quote').show('slow');\n}\n\nfunction duplicateQuote(quote) {\n\t\$('#new-quote [name=\"Quote[status]\"]').val(quote['status']);\n\t\$('#new-quote [name=\"Quote[expirationDate]\"]').val(quote['expirationDate']);\n\t\n\t\$('#product-table-create tbody tr').remove();\n\tfor(var i in quote['products']) {\n\t\taddFilledProduct('create', quote['products'][i]['id'], quote['products'][i]['price'], quote['products'][i]['quantity'], '' + quote['products'][i]['adjustment'], quote['currency'], quote['productNames'], quote['prices']);\n\t}\n\t\n\t\$('#new-quote').show('slow');\n}\n\n", CClientScript::POS_HEAD);
}
parent::init();
}
示例3: init
public function init()
{
assert('($this->model instanceof CModel && $this->form instanceof ZurmoActiveForm) ||
( $this->model == null && $this->form == null)');
assert('is_bool($this->allowSorting)');
if ($this->rightSideId == null) {
$this->rightSideId = $this->form->id . '_' . $this->rightSideAttributeName;
}
if ($this->rightSideName == null) {
$this->rightSideName = $this->rightSideAttributeName;
}
if ($this->rightSideValue === null) {
$this->rightSideValue = $this->model->{$this->rightSideAttributeName};
}
if ($this->leftSideId == null) {
$this->leftSideId = $this->form->id . '_' . $this->leftSideAttributeName;
}
if ($this->leftSideName == null) {
$this->leftSideName = $this->leftSideAttributeName;
}
if ($this->leftSideValue === null) {
$this->leftSideValue = $this->model->{$this->leftSideAttributeName};
}
if ($this->formId === null) {
$this->formId = $this->form->id;
}
$this->registerCoreScripts();
parent::init();
}
示例4: init
public function init()
{
$this->initDefaultButtons();
parent::init();
$locale = Yii::app()->getLocale();
$this->defaultOptions = array('header' => array('left' => 'prev,next today', 'center' => 'title', 'right' => 'agendaDay, agendaWeek, month'), 'defaultView' => 'month', 'axisFormat' => 'HH:mm', 'timeFormat' => 'H:mm{ - H:mm}', 'slotMinutes' => 15, 'snapMinutes' => 5, 'selectable' => true, 'selectHelper' => true, 'allDaySlot' => false, 'editable' => true, 'firstHour' => 11, 'firstDay' => 1, 'uneditableOnLeft' => true, 'droppable' => true, 'monthNames' => array_values($locale->getMonthNames('wide')), 'monthNamesShort' => array_values($locale->getMonthNames('abbreviated')), 'dayNames' => $locale->getWeekDayNames('wide'), 'dayNamesShort' => $locale->getWeekDayNames('abbreviated'), 'buttonText' => array('today' => Yii::t('FullCalendar.fc', 'Today'), 'agendaDay' => Yii::t('FullCalendar.fc', 'Day'), 'agendaWeek' => Yii::t('FullCalendar.fc', 'Week'), 'month' => Yii::t('FullCalendar.fc', 'Month')), 'eventRender' => 'js:function(event, element){if (!event.editable) element.css({opacity: 0.8})}', 'indentationMultiplier' => 0.2);
}
示例5: init
/**
* @return void Make sure that the JS SDK is enabled
*/
public function init()
{
parent::init();
if (!Yii::app()->facebook->jsSdk) {
throw new CException('Facebook JS SDK not enabled.');
}
}
示例6: init
/**
*
*/
public function init()
{
$baseUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('vendor.fortawesome.font-awesome'), false, -1, YII_DEBUG);
$clientScript = Yii::app()->clientScript;
$clientScript->registerCssFile($baseUrl . '/css/font-awesome.min.css');
parent::init();
}
示例7: init
public function init()
{
$this->registerScripts();
$this->options = (require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'tooltip.options.php');
$this->initTooltip();
parent::init();
}
示例8: init
public function init()
{
$assetsPath = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
$this->htmlOptions = isset($this->htmlOptions) ? $this->htmlOptions : array();
$this->selectSepartor = isset($this->selectSepartor) ? $this->selectSepartor : '';
$this->assetsPath = Yii::app()->getAssetManager()->publish($assetsPath);
$nameList = array();
$attributeList = array();
$dropListInit = 'new PCAS(';
$attrCity = $this->attributeCity;
$attrArea = $this->attributeArea;
$attrProvince = $this->attributeProvince;
$modelName = get_class($this->model);
if (isset($this->attributeProvince)) {
$nameList[] = '"' . $modelName . '[' . $this->attributeProvince . ']' . '"';
$attributeList[] = '"' . $this->model->{$attrProvince} . '"';
}
if (isset($this->attributeCity)) {
$nameList[] = '"' . $modelName . '[' . $this->attributeCity . ']' . '"';
$attributeList[] = '"' . $this->model->{$attrCity} . '"';
}
if (isset($this->attributeArea)) {
$nameList[] = '"' . $modelName . '[' . $this->attributeArea . ']' . '"';
$attributeList[] = '"' . $this->model->{$attrArea} . '"';
}
$initArray = array_merge($nameList, $attributeList);
$dropListInit .= implode(', ', $initArray) . ');';
Yii::app()->clientScript->registerScriptFile($this->assetsPath . '/PCAS.js');
Yii::app()->clientScript->registerScript(__CLASS__ . '#' . uniQId(), $dropListInit);
parent::init();
}
示例9: init
public function init()
{
parent::init();
if (!$this->email || !(new CEmailValidator())->validateValue($this->email)) {
throw new HttpException(500, 'The email you specified is not valid.');
}
}
示例10: init
public function init()
{
$default = array('skin' => 'default', 'preview' => null, 'allowDelete' => true, 'deleteField' => $this->name . '_delete', 'fileField' => $this->name . '_file', 'url' => '', 'secureuri' => false, 'loader' => $this->id . 'Loader', 'field' => $this->id, 'result' => $this->id . 'Result', 'button' => $this->id . 'ButtonUpload', 'container' => $this->id . 'Container', 'onBeforeSerialize' => '', 'onBeforeSubmit' => '', 'onSuccess' => '', 'url' => '', 'data' => null, 'form' => $this->id . 'Form');
$this->options = array_merge($default, $this->options);
$options = CJavaScript::encode($this->options);
switch ($this->options['skin']) {
case 'ajax':
$this->assets = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.image.assets'), false, -1, true);
$cs = Yii::app()->clientScript;
$cs->registerCoreScript('jquery');
$cs->registerScriptFile($this->assets . '/ajaxfileupload.js');
$cs->registerScriptFile($this->assets . '/ajaxfunction.js');
$cs->registerScript(__CLASS__ . '#' . $this->id, "\$.ajaxFunction({$options});");
break;
case 'ajax2':
$this->assets = Yii::app()->assetManager->publish(Yii::getPathOfAlias('ext.image.assets'), false, -1, true);
$cs = Yii::app()->clientScript;
$cs->registerCoreScript('jquery');
$cs->registerScriptFile($this->assets . '/jquery.form.js');
// заплатка, не могу понять почему исчезает форма обрамляющая поле файла
$cs->registerScript(__CLASS__ . '#' . $this->id . 'WrapInner', "\$('#{$this->options['container']}').wrapInner('<form id=\\'{$this->options['form']}\\' enctype=\\'multipart/form-data\\' method=\\'post\\' action=\\'{$this->options['url']}\\'></form>');");
$cs->registerScript(__CLASS__ . '#' . $this->id, "\$('#{$this->options['form']}').ajaxForm({\n\t\t\t\t\turl: '{$this->options['url']}',\n\t\t\t\t\tdata: " . CJavaScript::encode($this->options['data']) . ",\n\t\t\t\t\tdataType: 'json',\n\t\t\t\t\tbeforeSubmit: function(arr, form, options){\n\t\t\t\t\t\t\$('#" . $this->options['loader'] . "').show();\n\t\t\t\t\t},\n\t\t\t\t\tsuccess: function(data){\n\t\t\t\t\t\t\$('#" . $this->options['loader'] . "').hide();\n\t\t\t\t\t\t\$('#" . $this->options['field'] . "').val('');\n\t\t\t\t\t\tif(typeof(data.error) != 'undefined'){\n\t\t\t\t\t\t\talert(data.error);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t" . ($this->options['onSuccess'] ? CJavaScript::encode($this->options['onSuccess']) : '') . ";\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\terror:function(data){\n\t\t\t\t\t\talert(data);\n\t\t\t\t\t}\n\t\t\t\t});");
break;
}
return parent::init();
}
示例11: init
public function init()
{
parent::init();
Yii::app()->clientScript->registerScriptFile('https://apis.google.com/js/plusone.js', CClientScript::POS_END);
Yii::app()->clientScript->registerScriptFile('http://platform.twitter.com/widgets.js', CClientScript::POS_END);
Yii::app()->clientScript->registerScriptFile('http://connect.facebook.net/en_US/all.js#appId=362597297166414&xfbml=1', CClientScript::POS_END);
}
示例12: run
/**
* Run widget.
*/
public function run()
{
parent::run();
$this->htmlOptions['id'] = $this->map->id;
echo Html::tag($this->tagName, $this->htmlOptions, '');
$this->onAfterRender(new \CEvent($this));
}
示例13: init
public function init()
{
if (empty($this->assetsUrl)) {
$this->assetsUrl = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'prettyPhoto');
}
$this->registerClientScript();
parent::init();
$id = $this->getId();
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $id;
}
echo CHtml::openTag($this->tag, $this->htmlOptions) . "\n";
if (empty($this->options['theme'])) {
$this->options['theme'] = $this->theme;
}
$options = empty($this->options) ? '' : CJavaScript::encode($this->options);
/*
Yii::app()->clientScript->registerScript(__CLASS__,"
jQuery('#$id a').attr('data-lightbox','prettyPhoto".($this->gallery?'[]':'')."');
jQuery('a[data-lightbox^=\"prettyPhoto\"]').prettyPhoto(".$options.');
',CClientScript::POS_END);
*/
// Fix multiple widgets on same page.
Yii::app()->clientScript->registerScript('prettyPhoto_' . $id, "\n jQuery('#" . $id . " a').attr('data-lightbox','prettyPhoto_" . $id . "" . ($this->gallery ? '[]' : '') . "');\n jQuery('a[data-lightbox^=\"prettyPhoto_" . $id . "\"]').prettyPhoto(" . $options . ');
', CClientScript::POS_END);
}
示例14: init
public function init($category_id = null, $current_tuid = null)
{
parent::init();
global $js_file;
$js_file['tservices/tservices_catalog'] = 'tservices/tservices_catalog.js';
if (isset($this->options['limit'])) {
$this->limit = $this->options['limit'];
}
if (isset($this->options['prof_group_id'], $this->options['prof_id']) && !$category_id) {
require_once ABS_PATH . '/classes/tservices/tservices_categories.php';
$tservices_categories = new tservices_categories();
$category_data = $tservices_categories->getCategoryByFreelancersCatalog($this->options['prof_group_id'], $this->options['prof_id']);
if ($category_data) {
$category_id = $category_data['id'];
$this->options['category_title'] = $category_data['title'];
$this->options['category_stitle'] = $category_data['link'];
}
}
$tservicesCatalogModel = new tservices_catalog();
$tservicesCatalogModel->setPage($this->limit, 1);
if (isset($this->options['user_id']) && $this->options['user_id'] > 0) {
$tservicesCatalogModel->user_id = $this->options['user_id'];
} elseif ($category_id) {
$tservicesCatalogModel->category_id = $category_id;
}
$exclude_ids = $current_tuid ? array($current_tuid) : array();
$list = $tservicesCatalogModel->cache($this->ttl_cache)->getList($exclude_ids);
$this->tservices = $list['list'];
if ($this->tservices) {
//расширение сведений о типовых услугах
$tserviceModel = new TServiceModel();
$tserviceModel->addOwnerInfo()->extend($this->tservices, 'id');
}
}
示例15: init
public function init($data = array())
{
parent::init();
if (!empty($data)) {
$this->data = $data;
}
}