本文整理汇总了PHP中CMap类的典型用法代码示例。如果您正苦于以下问题:PHP CMap类的具体用法?PHP CMap怎么用?PHP CMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: relations
public function relations()
{
$map = new CMap(parent::relations());
$nrelation = array('images' => array(self::HAS_MANY, 'Image', 'model_id', 'condition' => 'images.model_name = \'Category\''));
$map->mergeWith($nrelation);
return $map;
}
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:7,代码来源:Category.php
示例2: renderInput
public function renderInput()
{
//set default settings
$this->attributes = CMap::mergeArray($this->defaultWidgetSettings, $this->attributes);
/*
* if we have more than 1 forms on page for single model,
* than at some input will be same id. we must set different id.
* but Yii generate non different id for error tag.
*/
if (!isset($this->errorOptions['inputID']) && isset($this->attributes['id'])) {
$this->errorOptions['inputID'] = $this->attributes['id'];
}
//replace sinonym on full alias
if (isset($this->widgets[$this->type])) {
$this->type = $this->widgets[$this->type];
if (strpos($this->type, '.') === false) {
$this->type = $this->widgets_path . str_repeat('.' . $this->type, 2);
}
$attributes = $this->attributes;
$attributes['model'] = $this->getParent()->getModel();
$attributes['attribute'] = $this->name;
$attributes['input_element'] = $this;
ob_start();
$this->getParent()->getOwner()->widget($this->type, $attributes);
return ob_get_clean();
}
return parent::renderInput();
}
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:28,代码来源:FormInputElement.php
示例3: renderItem
/**
*### .renderItem()
*/
protected function renderItem($options, $templateData)
{
//apply editable if not set 'editable' params or set and not false
$apply = !empty($options['name']) && (!isset($options['editable']) || $options['editable'] !== false);
if ($apply) {
//ensure $options['editable'] is array
if (!isset($options['editable'])) {
$options['editable'] = array();
}
//take common url if not defined for particular item and not related model
if (!isset($options['editable']['url']) && strpos($options['name'], '.') === false) {
$options['editable']['url'] = $this->url;
}
//take common params if not defined for particular item
if (!isset($options['editable']['params'])) {
$options['editable']['params'] = $this->params;
}
$editableOptions = CMap::mergeArray($options['editable'], array('model' => $this->data, 'attribute' => $options['name'], 'emptytext' => $this->nullDisplay === null ? Yii::t('zii', 'Not set') : strip_tags($this->nullDisplay)));
//if value in detailview options provided, set text directly (as value means text)
if (isset($options['value']) && $options['value'] !== null) {
$editableOptions['text'] = $templateData['{value}'];
$editableOptions['encode'] = false;
}
/** @var $widget TbEditableField */
$widget = $this->controller->createWidget('TbEditableField', $editableOptions);
//'apply' can be changed during init of widget (e.g. if related model and unsafe attribute)
if ($widget->apply) {
ob_start();
$widget->run();
$templateData['{value}'] = ob_get_clean();
}
}
parent::renderItem($options, $templateData);
}
开发者ID:robebeye,项目名称:isims,代码行数:37,代码来源:TbEditableDetailView.php
示例4: init
/**
* Panel initialization.
* Generate unique tag for page. Attach panels, log watcher. Register scripts for printing debug panel.
*/
public function init()
{
parent::init();
if (!$this->enabled) {
return;
}
Yii::setPathOfAlias('yii2-debug', dirname(__FILE__));
Yii::app()->setImport(array('yii2-debug.*', 'yii2-debug.panels.*'));
if ($this->logPath === null) {
$this->logPath = Yii::app()->getRuntimePath() . '/debug';
}
$panels = array();
foreach (CMap::mergeArray($this->corePanels(), $this->panels) as $id => $config) {
if (!isset($config['highlightCode'])) {
$config['highlightCode'] = $this->highlightCode;
}
$panels[$id] = Yii::createComponent($config, $this, $id);
}
$this->panels = $panels;
Yii::app()->setModules(array($this->moduleId => array('class' => 'Yii2DebugModule', 'owner' => $this)));
if ($this->internalUrls && Yii::app()->getUrlManager()->urlFormat == 'path') {
$rules = array();
foreach ($this->coreUrlRules() as $key => $value) {
$rules[$this->moduleId . '/' . $key] = $this->moduleId . '/' . $value;
}
Yii::app()->getUrlManager()->addRules($rules, false);
}
Yii::app()->attachEventHandler('onEndRequest', array($this, 'onEndRequest'));
$this->initToolbar();
}
开发者ID:Orlac,项目名称:yii2-debug,代码行数:34,代码来源:Yii2Debug.php
示例5: renderItem
/**
*### .renderItem()
*/
protected function renderItem($options, $templateData)
{
//apply editable if not set 'editable' params or set and not false
$apply = !empty($options['name']) && (!isset($options['editable']) || $options['editable'] !== false);
if ($apply) {
//ensure $options['editable'] is array
if (!isset($options['editable'])) {
$options['editable'] = array();
}
//merge options with defaults: url, params, etc.
$options['editable'] = CMap::mergeArray($this->_data, $options['editable']);
//options to be passed into EditableField (constructed from $options['editable'])
$widgetOptions = array('model' => $this->data, 'attribute' => $options['name']);
//if value in detailview options provided, set text directly (as value here means text)
if (isset($options['value']) && $options['value'] !== null) {
$widgetOptions['text'] = $templateData['{value}'];
$widgetOptions['encode'] = false;
}
$widgetOptions = CMap::mergeArray($widgetOptions, $options['editable']);
/** @var $widget TbEditableField */
$widget = $this->controller->createWidget('TbEditableField', $widgetOptions);
//'apply' maybe changed during init of widget (e.g. if related model has unsafe attribute)
if ($widget->apply) {
ob_start();
$widget->run();
$templateData['{value}'] = ob_get_clean();
}
}
parent::renderItem($options, $templateData);
}
开发者ID:yinhe,项目名称:yincart,代码行数:33,代码来源:TbEditableDetailView.php
示例6: renderItem
protected function renderItem($options, $templateData)
{
//if editable set to false --> not editable
$isEditable = array_key_exists('editable', $options) && $options['editable'] !== false;
//if name not defined or it is not safe --> not editable
$isEditable = !empty($options['name']) && $this->data->isAttributeSafe($options['name']);
if ($isEditable) {
//ensure $options['editable'] is array
if (!array_key_exists('editable', $options) || !is_array($options['editable'])) {
$options['editable'] = array();
}
//take common url
if (!array_key_exists('url', $options['editable'])) {
$options['editable']['url'] = $this->url;
}
$editableOptions = CMap::mergeArray($options['editable'], array('model' => $this->data, 'attribute' => $options['name'], 'emptytext' => $this->nullDisplay === null ? Yii::t('zii', 'Not set') : strip_tags($this->nullDisplay)));
//if value in detailview options provided, set text directly
if (array_key_exists('value', $options) && $options['value'] !== null) {
$editableOptions['text'] = $templateData['{value}'];
$editableOptions['encode'] = false;
}
$templateData['{value}'] = $this->controller->widget('EditableField', $editableOptions, true);
}
parent::renderItem($options, $templateData);
}
开发者ID:hipogea,项目名称:zega,代码行数:25,代码来源:EditableDetailView.php
示例7: setOptions
/**
*
* Sets plugin options
* @param array $options
* @throws CException
*/
public function setOptions($options)
{
if (!is_array($options)) {
throw new CException(Yii::t('EGMap', 'KeyDrEGMapKeyDragZoomagZoom options must be of type array!'));
}
$this->options = CMap::mergeArray($this->options, $options);
}
开发者ID:romeo14,项目名称:pow,代码行数:13,代码来源:EGMapKeyDragZoom.php
示例8: init
/**
* Initializes the widget.
*/
public function init()
{
if (is_null($this->theme)) {
$this->theme = 'default';
}
// check if options parameter is a json string
if (is_string($this->options)) {
if (!($this->options = CJSON::decode($this->options))) {
throw new CException('The options parameter is not valid JSON.');
}
}
// merge options with default values
$defaultOptions = array();
$this->options = CMap::mergeArray($defaultOptions, $this->options);
// merge options with Javascript events
$normalizedEvents = array();
foreach ($this->events as $name => $handler) {
$normalizedEvents[$name] = new CJavaScriptExpression($handler);
}
$this->options = CMap::mergeArray($normalizedEvents, $this->options);
// set field initial value
if (isset($this->options['formatSubmit'])) {
if (!isset($this->htmlOptions['data-value']) && $this->hasModel()) {
$this->htmlOptions['data-value'] = CHtml::resolveValue($this->model, $this->attribute);
}
}
// prepend pickadate scripts to the begining of the additional js files array
if (!empty($this->language)) {
array_unshift($this->scripts, "translations/{$this->language}");
}
array_unshift($this->scripts, 'picker.date');
array_unshift($this->scripts, $this->baseScript);
}
开发者ID:fourteenmeister,项目名称:yii-bootstrap,代码行数:36,代码来源:TbPickadateDatePicker.php
示例9: renderMenuItem
public function renderMenuItem()
{
$parentMenuItem = parent::renderMenuItem();
$itemOptions = array('itemOptions' => array('id' => get_class($this)));
$content = CMap::mergeArray($parentMenuItem, $itemOptions);
return $content;
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:7,代码来源:DropdownSupportedLinkActionElement.php
示例10: search
/**
* Retrieves a list of models based on the current search/filter conditions.
* @param array $options
* @return YdActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search($options = array())
{
$criteria = new CDbCriteria();
$criteria->compare('t.id', $this->id);
$criteria->compare('t.name', $this->name, true);
return new YdActiveDataProvider($this, CMap::mergeArray(array('criteria' => $criteria), $options));
}
开发者ID:zainengineer,项目名称:yii-dressing,代码行数:12,代码来源:YdRole.php
示例11: renderMenuRecursive
/**
* @see CMenu::renderMenuRecursive
*/
protected function renderMenuRecursive($items)
{
foreach ($items as $item) {
echo CHtml::openTag('li', isset($item['htmlOptions']) ? $item['htmlOptions'] : array());
if (isset($item['encodeLabel']) ? $item['encodeLabel'] : $this->encodeLabel) {
$item['label'] = CHtml::encode($item['label']);
}
if (isset($item['url']) && !($this->activeLinkDisable && $item['active'])) {
$menu = CHtml::link($item['label'], $item['url'], isset($item['linkOptions']) ? $item['linkOptions'] : array());
} else {
$menu = CHtml::tag('span', isset($item['linkOptions']) ? $item['linkOptions'] : array(), $item['label']);
}
if (isset($this->itemTemplate) || isset($item['template'])) {
$template = isset($item['template']) ? $item['template'] : $this->itemTemplate;
echo strtr($template, array('{menu}' => $menu));
} else {
echo $menu;
}
if (isset($item['items']) && count($item['items'])) {
echo "\n" . CHtml::openTag('ul', CMap::mergeArray($this->submenuHtmlOptions, $item['submenuHtmlOptions'] ? $item['submenuHtmlOptions'] : array())) . "\n";
$this->renderMenuRecursive($item['items']);
echo CHtml::closeTag('ul') . "\n";
}
echo CHtml::closeTag('li') . "\n";
}
}
开发者ID:sinelnikof,项目名称:yiiext,代码行数:29,代码来源:EMenuWidget.php
示例12: cmsDataTypeRelations
public function cmsDataTypeRelations($event)
{
$event->relations = CMap::mergeArray(
$event->relations,
array('gallery' => array(ImageGallery::HAS_MANY, 'ImageGallery', ImageGallery::getPkAttr()))
);
}
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:7,代码来源:ImageGalleryModule.php
示例13: configureApplication
/**
* Load the environment file and Yii config file for the application
* The Yii config file must be named as main-APP_ID where APP_ID is defined in the index.php
*
* @return array
*/
function configureApplication($appId, $resolver)
{
ensureSSL();
if ($resolver !== true) {
return array();
}
include_once WEB_ROOT . '../server/modules/Xpress/components/Application.php';
// load environment info
$envFile = checkInditionEnv();
if ($envFile) {
include $envFile;
// load application config
$appConfigFile = WEB_ROOT . '../server/config/main-' . APP_ID . '.php';
if (file_exists($appConfigFile)) {
$appConfig = (include $appConfigFile);
} else {
$appConfig = array();
}
// merge app config with base config
$base = (require WEB_ROOT . '../server/config/base.php');
$config = CMap::mergeArray($base, $appConfig);
if ($appConfig['modules'] == array()) {
$config['components']['Xpress']['RebuildModuleCache'] = true;
}
return $config;
} else {
return array();
}
}
开发者ID:hung5s,项目名称:yap,代码行数:35,代码来源:init.php
示例14: renderHeaderCell
/**
* Renders the header cell.
*/
public function renderHeaderCell()
{
if ($this->grid->json) {
$header = array('id' => $this->id);
$content = array();
if ($this->grid->enableSorting && $this->sortable && $this->name !== null) {
$sort = $this->grid->dataProvider->getSort();
$label = isset($this->header) ? $this->header : $sort->resolveLabel($this->name);
if ($sort->resolveAttribute($this->name) !== false) {
$label .= '<span class="caret"></span>';
}
$content['content'] = $sort->link($this->name, $label, array('class' => 'sort-link'));
} else {
if ($this->name !== null && $this->header === null) {
if ($this->grid->dataProvider instanceof CActiveDataProvider) {
$content['content'] = CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name));
} else {
$content['content'] = CHtml::encode($this->name);
}
} else {
$content['content'] = trim($this->header) !== '' ? $this->header : $this->grid->blankDisplay;
}
}
return CMap::mergeArray($header, $content);
}
parent::renderHeaderCell();
}
开发者ID:branJakJak,项目名称:goawtodayaldiskon,代码行数:30,代码来源:TbJsonGridColumn.php
示例15: init
/**
* initialize widget
*
*/
public function init()
{
//check needed values
/*if(!isset($this->dataUrl))
{
throw new CException("You have to define a dataUrl!",500);
}*/
//get widget id
if (isset($this->htmlOptions['id'])) {
$id = $this->htmlOptions['id'];
} else {
$this->htmlOptions['id'] = $this->getId();
}
//set additional default options that only make sense after initialization
$this->defaultOptions = CMap::mergeArray($this->defaultOptions, array('parent' => $this->id));
//merge options with default options
$this->options = CMap::mergeArray($this->defaultOptions, $this->options);
//set correct image path according to skin if not set already
if (!isset($this->options['icon_path'])) {
$this->options['icon_path'] = $this->getAssetPath() . '/codebase/imgs/' . $this->skinToImgFolderMappings[$this->options['skin']] . '/';
}
//set correct image path according to skin if not set already
if (!isset($this->options['image_path'])) {
$this->options['image_path'] = $this->getAssetPath() . '/codebase/imgs/' . $this->skinToImgFolderMappings[$this->options['skin']] . '/';
}
$this->options['items'] = array(array('id' => 'file', 'text' => 'File', 'items' => array(array('id' => 'fileopen', 'text' => 'Open File'))));
//publish assets
parent::init();
}
开发者ID:philippfrenzel,项目名称:yiidhtmlx,代码行数:33,代码来源:DHtmlxMenuWidget.php
示例16: renderDataCellContent
protected function renderDataCellContent($row, $data)
{
if (!$this->isEditable($data)) {
parent::renderDataCellContent($row, $data);
return;
}
$options = CMap::mergeArray($this->editable, array('model' => $data, 'attribute' => $this->name));
//if value defined for column --> use it as element text
if (strlen($this->value)) {
ob_start();
parent::renderDataCellContent($row, $data);
$text = ob_get_clean();
$options['text'] = $text;
$options['encode'] = false;
}
$editable = $this->grid->controller->createWidget('TbEditableField', $options);
//manually make selector non unique to match all cells in column
$selector = get_class($editable->model) . '_' . $editable->attribute;
$editable->htmlOptions['rel'] = $selector;
$editable->renderLink();
//manually render client script (one for all cells in column)
if (!$this->isScriptRendered) {
$script = $editable->registerClientScript();
Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $selector . '-event', '
$("#' . $this->grid->id . '").parent().on("ajaxUpdate.yiiGridView", "#' . $this->grid->id . '", function() {' . $script . '});
');
$this->isScriptRendered = true;
}
}
开发者ID:janym,项目名称:angular-yii,代码行数:29,代码来源:TbEditableColumn.php
示例17: init
/**
* Initializes the widget.
*/
public function init()
{
$behavior = $this->controller->asa('seo');
if ($behavior !== null && $behavior->metaDescription !== null) {
$this->_description = $behavior->metaDescription;
} else {
if ($this->defaultDescription !== null) {
$this->_description = $this->defaultDescription;
}
}
if ($behavior !== null && $behavior->metaKeywords !== null) {
$this->_keywords = $behavior->metaKeywords;
} else {
if ($this->defaultKeywords !== null) {
$this->_keywords = $this->defaultKeywords;
}
}
if ($behavior !== null) {
$this->_properties = CMap::mergeArray($behavior->metaProperties, $this->defaultProperties);
} else {
$this->_properties = $this->defaultProperties;
}
if ($behavior !== null && $behavior->canonical !== null) {
$this->_canonical = $behavior->canonical;
}
}
开发者ID:vangogogo,项目名称:justsns,代码行数:29,代码来源:SeoHead.php
示例18: registerLocale
protected function registerLocale()
{
$langFile = dirname(__FILE__) . '/locale/' . $this->lang . '.php';
if (file_exists($langFile)) {
$this->options = CMap::mergeArray($this->options, include $langFile);
}
}
开发者ID:RezaMansouri70,项目名称:jalali-fullcalendar,代码行数:7,代码来源:JFullCalendar.php
示例19: renderField
/**
* @param $attribute
* @param null $value
* @param null $name
* @param array $htmlOptions
* @return mixed|null|string
*/
public static function renderField($attribute, $value = null, $name = null, $htmlOptions = [])
{
$name = $name ?: 'Attribute[' . $attribute->id . ']';
switch ($attribute->type) {
case Attribute::TYPE_SHORT_TEXT:
return CHtml::textField($name, $value, $htmlOptions);
break;
case Attribute::TYPE_TEXT:
return Yii::app()->getController()->widget(Yii::app()->getModule('store')->getVisualEditor(), ['name' => $name, 'value' => $value], true);
break;
case Attribute::TYPE_DROPDOWN:
$data = CHtml::listData($attribute->options, 'id', 'value');
return CHtml::dropDownList($name, $value, $data, array_merge($htmlOptions, ['empty' => '---']));
break;
case Attribute::TYPE_CHECKBOX_LIST:
$data = CHtml::listData($attribute->options, 'id', 'value');
return CHtml::checkBoxList($name . '[]', $value, $data, $htmlOptions);
break;
case Attribute::TYPE_CHECKBOX:
return CHtml::checkBox($name, $value, CMap::mergeArray(['uncheckValue' => 0], $htmlOptions));
break;
case Attribute::TYPE_NUMBER:
return CHtml::numberField($name, $value, $htmlOptions);
break;
case Attribute::TYPE_FILE:
return CHtml::fileField($name . '[name]', null, $htmlOptions);
break;
}
return null;
}
开发者ID:yupe,项目名称:yupe,代码行数:37,代码来源:AttributeRender.php
示例20: createChildWidget
/**
* @param $name
* @param $attribute
* @param null $model
* @param bool $layout
* @return VisualElementBaseWidget
*/
public function createChildWidget($name, $attribute, $model = null, $layout = false, $params = array())
{
if ($model == null) {
$model = $this->model;
}
return $this->controller->createWidget($name, CMap::mergeArray(array('form' => $this->form, 'model' => $this->model, 'attributeName' => $attribute, 'layout' => $layout), $params));
}
开发者ID:kot-ezhva,项目名称:ygin,代码行数:14,代码来源:VisualElementBaseWidget.php
注:本文中的CMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论