本文整理汇总了PHP中CMap::mergeArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CMap::mergeArray方法的具体用法?PHP CMap::mergeArray怎么用?PHP CMap::mergeArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMap
的用法示例。
在下文中一共展示了CMap::mergeArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAdd
/**
* Action добавления комментария
*
*
**/
public function actionAdd()
{
if (!Yii::app()->getRequest()->getIsPostRequest() || !Yii::app()->getRequest()->getPost('Comment')) {
throw new CHttpException(404);
}
$module = Yii::app()->getModule('comment');
if (!$module->allowGuestComment && !Yii::app()->user->isAuthenticated()) {
throw new CHttpException(404);
}
if (Yii::app()->commentManager->isSpam(Yii::app()->user)) {
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
Yii::app()->ajax->failure(array('message' => Yii::t('CommentModule.comment', 'Spam protection, try to create comment after {few} seconds!', array('{few}' => $module->antispamInterval))));
}
throw new CHttpException(404, Yii::t('CommentModule.comment', 'Spam protection, try to create comment after {few} seconds!', array('{few}' => $module->antispamInterval)));
}
$params = Yii::app()->getRequest()->getPost('Comment');
if (Yii::app()->user->isAuthenticated()) {
$params = CMap::mergeArray($params, array('user_id' => Yii::app()->user->getId(), 'name' => Yii::app()->user->getState('nick_name'), 'email' => Yii::app()->user->getState('email')));
}
$redirect = Yii::app()->getRequest()->getPost('redirectTo', Yii::app()->user->returnUrl);
if ($comment = Yii::app()->commentManager->create($params, $module, Yii::app()->user)) {
$commentContent = $comment->status == Comment::STATUS_APPROVED ? $this->_renderComment($comment) : '';
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
Yii::app()->ajax->success(array('message' => Yii::t('CommentModule.comment', 'You record was created. Thanks.'), 'comment' => array('parent_id' => $comment->parent_id), 'commentContent' => $commentContent));
}
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('CommentModule.comment', 'You record was created. Thanks.'));
$this->redirect($redirect);
} else {
if (Yii::app()->getRequest()->getIsAjaxRequest()) {
Yii::app()->ajax->failure(array('message' => Yii::t('CommentModule.comment', 'Record was not added! Fill form correct!')));
}
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('CommentModule.comment', 'Record was not added! Fill form correct!'));
$this->redirect($redirect);
}
}
示例2: 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();
}
示例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);
}
示例4: 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;
}
}
示例5: registerClientScript
/**
* Register required script files
* @param $id
*/
public function registerClientScript($id)
{
Yii::app()->bootstrap->registerAssetCss('redactor.css');
Yii::app()->bootstrap->registerAssetJs('redactor.min.js');
$options = CJSON::encode(CMap::mergeArray($this->editorOptions, array('lang' => $this->lang)));
Yii::app()->bootstrap->registerRedactor('#' . $id, $options);
}
示例6: init
public function init()
{
$this->defaultOptions = CMap::mergeArray($this->defaultOptions, array('delegate' => $this->delegate));
$this->target = '#' . $this->id;
echo CHtml::openTag($this->tagName, array('id' => $this->id), $this->htmlOptions);
parent::init();
}
示例7: 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();
}
示例8: 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";
}
}
示例9: 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));
}
示例10: 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();
}
}
示例11: cmsDataTypeRelations
public function cmsDataTypeRelations($event)
{
$event->relations = CMap::mergeArray(
$event->relations,
array('gallery' => array(ImageGallery::HAS_MANY, 'ImageGallery', ImageGallery::getPkAttr()))
);
}
示例12: 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();
}
示例13: execute
public function execute($url, $options = array(), $postData = array())
{
$ch = curl_init();
$options = CMap::mergeArray(self::$defaultOptions, $options);
$options[CURLOPT_URL] = $url;
if (!empty($postData)) {
$options[CURLOPT_POST] = true;
$options[CURLOPT_POSTFIELDS] = $postData;
}
foreach ($options as $key => $value) {
curl_setopt($ch, $key, $value);
}
$start = microtime(true);
// загрузка страницы и выдача её браузеру
$this->content = curl_exec($ch);
$this->totalTime = microtime(true) - $start;
$this->errorCode = curl_errno($ch);
if ($this->errorCode) {
$this->errorMessage = curl_error($ch);
}
$this->httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// завершение сеанса и освобождение ресурсов
curl_close($ch);
if ($this->errorCode) {
return false;
} else {
if (!$this->isHttpOK()) {
$this->errorMessage = $this->content;
return false;
} else {
return true;
}
}
}
示例14: renderMeta
public function renderMeta()
{
if (empty($this->metaTitle)) {
$this->metaTitle = Yii::app()->params['htmlMetadata']['title'];
}
if (empty($this->metaDescription)) {
$this->metaDescription = Yii::app()->params['htmlMetadata']['description'];
}
if (empty($this->metaKeyword)) {
$this->metaKeyword = Yii::app()->params['htmlMetadata']['keywords'];
}
if (empty($this->canonical)) {
$this->canonical = Yii::app()->request->getHostInfo() . Yii::app()->request->url;
}
echo CHtml::tag('link', array('rel' => 'canonical', 'href' => $this->canonical));
$metaKeywords = CMap::mergeArray(array('title' => $this->metaTitle, 'description' => $this->metaDescription, 'keywords' => $this->metaKeyword), $this->metaKeyOthers);
foreach ($metaKeywords as $name => $content) {
echo CHtml::metaTag($content, $name) . PHP_EOL;
}
if (!empty($this->metaProperties)) {
foreach ($this->metaProperties as $key => $content) {
echo '<meta property="' . $content['name'] . '" content="' . $content['value'] . '" />' . PHP_EOL;
}
// we can't use Yii's method for this.
}
}
示例15: run
/**
*/
public function run()
{
/**
* @var CClientScript $cs
*/
$cs = Yii::app()->getClientScript();
// Javascript var
if (empty($this->jsVarName)) {
$this->jsVarName = $this->getId() . 'Layout';
}
// Container ID
if (!isset($this->htmlOptions['id'])) {
$this->htmlOptions['id'] = $this->getId();
}
$id = $this->htmlOptions['id'];
echo CHtml::openTag('div', $this->htmlOptions);
$layoutsOptions = $this->renderLayouts();
echo '</div>';
// Prepare options
$options = CMap::mergeArray($this->options, $layoutsOptions);
$options = empty($options) ? '' : CJavaScript::encode($options);
// Register global JS var
$cs->registerScript(__CLASS__ . '#jsVar#' . $this->getId(), 'var ' . $this->jsVarName . ';', CClientScript::POS_HEAD);
// Register Layouts init script
$cs->registerScript(__CLASS__ . '#init#' . $this->getId(), $this->jsVarName . ' = $("#' . $id . '").layout(' . $options . ');', CClientScript::POS_READY);
}