public function actionDataBlocks() { $favs = Yii::$app->adminuser->identity->setting->get("blockfav", []); $groups = []; foreach (BlockGroup::find()->asArray()->all() as $group) { $blocks = []; $groupPosition = null; foreach (Block::find()->where(['group_id' => $group['id']])->all() as $block) { $obj = Block::objectId($block['id'], 0, 'admin'); if (!$obj || in_array(get_class($obj), Yii::$app->getModule('cmsadmin')->hiddenBlocks)) { continue; } if ($groupPosition == null) { $groupObject = Yii::createObject($obj->blockGroup()); $groupPosition = $groupObject->getPosition(); } $blocks[] = ['id' => $block['id'], 'name' => $obj->name(), 'full_name' => $obj->icon() === null ? $obj->name() : '<i class="material-icons">' . $obj->icon() . '</i> <span>' . $obj->name() . '</span>', 'favorized' => array_key_exists($block['id'], $favs)]; } if (empty($blocks)) { continue; } $group['is_fav'] = 0; $group['toggle_open'] = (int) Yii::$app->adminuser->identity->setting->get("togglegroup.{$group['id']}", 1); $groups[] = ['groupPosition' => $groupPosition, 'group' => $group, 'blocks' => $blocks]; } if (!empty($favs)) { $favblocks = []; foreach ($favs as $fav) { $favblocks[] = $fav; } array_unshift($groups, ['group' => ['toggle_open' => (int) Yii::$app->adminuser->identity->setting->get("togglegroup.99999", 1), 'id' => '99999', 'is_fav' => 1, 'name' => Module::t('block_group_favorites'), 'identifier' => 'favs', 'position' => 0], 'groupPosition' => 0, 'blocks' => $favblocks]); } return $groups; }
protected function ensureInputValues($event) { // sort index fixture if (!$this->isNewRecord) { $this->_olds = $this->getOldAttributes(); } // its a negative value, so its a last item, lets find the last index for current config if ($this->sort_index < 0) { $last = self::originalFind()->andWhere(['nav_item_page_id' => $this->nav_item_page_id, 'placeholder_var' => $this->placeholder_var, 'prev_id' => $this->prev_id])->orderBy('sort_index DESC')->one(); if (!$last) { $this->sort_index = 0; } else { $this->sort_index = $last->sort_index + 1; } } else { // its not a negative value, we have to find the positions after the current sort index and update to a higher level $higher = self::originalFind()->where('sort_index >= :index', ['index' => $this->sort_index])->andWhere(['nav_item_page_id' => $this->nav_item_page_id, 'placeholder_var' => $this->placeholder_var, 'prev_id' => $this->prev_id])->all(); foreach ($higher as $item) { $newSortIndex = $item->sort_index + 1; Yii::$app->db->createCommand()->update(self::tableName(), ['sort_index' => $newSortIndex], ['id' => $item->id])->execute(); } } // manipulate timestamps if ($this->isNewRecord) { $this->timestamp_create = time(); $this->timestamp_update = time(); $this->create_user_id = Module::getAuthorUserId(); } else { $this->deleteHasCache(['blockcache', (int) $this->id]); $this->is_dirty = 1; $this->update_user_id = Module::getAuthorUserId(); $this->timestamp_update = time(); } }
</p> <div class="card-panel" ng-controller="DraftsController"> <table class="striped"> <thead> <tr> <th><?php echo \luya\cms\admin\Module::t('draft_column_id'); ?> </th> <th><?php echo \luya\cms\admin\Module::t('draft_column_title'); ?> </th> <th><?php echo \luya\cms\admin\Module::t('draft_column_action'); ?> </th> </tr> </thead> <tr ng-repeat="item in menuData.drafts"> <td>{{item.id}}</td> <td>{{item.title}}</td> <td><button type="button" ng-click="go(item.id)" class="btn btn-flat"><?php echo \luya\cms\admin\Module::t('draft_edit_button'); ?> </button> </tr> </table> </div> </div> </div>
</div> </div> <!-- /PAGE__CONTENT --> </div> <!-- /PAGE --> </div> </div> </div> <div class="cms__sidebar"> <div class="blockholder" ng-controller="DroppableBlocksController"> <div class="col s12"> <div class="blockholder__group blockholder__group--clipboard" ng-show="copyStack.length > 0"> <b class="blockholder__group-title blockholder__group-title--clipboard"><i class="material-icons left">content_copy</i> <span><?php echo Module::t('view_update_blockholder_clipboard'); ?> </span></b> <div class="blockholder__block" ng-repeat="stackItem in copyStack" data-drag="true" data-copy="true" jqyoui-draggable="{placeholder: 'keep', onStart : 'onStart', onStop : 'onStop'}" ng-model="stackItem" data-jqyoui-options="{revert: false, refreshPositions : true, snapTolerance : 40, helper : 'clone', cursor:'move', cursorAt: { top: 0, left: 0 }}"> <span>{{stackItem.name}}</span> </div> <span ng-click="clearStack()" class="blockholder__clear-clipboard"><i class="material-icons">clear</i></span> </div> <div class="blockholder__search" ng-class="{'blockholder__search--active': searchQuery}" zaa-esc="searchQuery=''""> <input class="blockholder__input" type="text" ng-model="searchQuery" value="" id="blockholderSearch" /> <label class="blockholder__icon blockholder__icon--search" for="blockholderSearch"><i class="material-icons">search</i></label> <label class="blockholder__icon blockholder__icon--cancel" for="blockholderCancel"> <div ng-show="searchQuery.length > 0" ng-click="searchQuery=''"><i class="material-icons">close</i></div> </label> </div> <div class="blockholder__group" ng-repeat="item in blocksData | orderBy:'groupPosition'" ng-class="{'blockholder__group--favorite' : item.group.is_fav}">
public function getAction() { if ($this->is_insertion) { switch ($this->table_name) { case "nav_item": return Module::t('log_action_insert_cms_nav_item', ['info' => $this->rowDescriber]); case "nav": return Module::t('log_action_insert_cms_nav', ['info' => $this->rowDescriber]); case "cms_nav_item_page_block_item": return Module::t('log_action_insert_cms_nav_item_page_block_item', ['info' => $this->rowDescriber]); default: return Module::t('log_action_insert_unkown', ['info' => $this->rowDescriber]); } } if ($this->is_update) { switch ($this->table_name) { case "nav_item": return Module::t('log_action_update_cms_nav_item', ['info' => $this->rowDescriber]); case "nav": return Module::t('log_action_update_cms_nav', ['info' => $this->rowDescriber]); case "cms_nav_item_page_block_item": return Module::t('log_action_update_cms_nav_item_page_block_item', ['info' => $this->rowDescriber]); default: return Module::t('log_action_update_unkown', ['info' => $this->rowDescriber]); } } if ($this->is_deletion) { switch ($this->table_name) { case "nav_item": return Module::t('log_action_delete_cms_nav_item', ['info' => $this->rowDescriber]); case "nav": return Module::t('log_action_delete_cms_nav', ['info' => $this->rowDescriber]); case "cms_nav_item_page_block_item": return Module::t('log_action_delete_cms_nav_item_page_block_item', ['info' => $this->rowDescriber]); default: return Module::t('log_action_delete_unkown'); } } }
/** * * @param unknown $navId * @param unknown $langId * @param unknown $title * @param unknown $alias * @param unknown $layoutId * @param unknown $description * @return boolean */ public function createPageItem($navId, $langId, $title, $alias, $layoutId, $description) { $_errors = []; $navItem = new NavItem(); $navItem->parent_nav_id = self::findOne($navId)->parent_nav_id; $navItemPage = new NavItemPage(); $navItem->attributes = ['nav_id' => $navId, 'lang_id' => $langId, 'title' => $title, 'alias' => $alias, 'description' => $description, 'nav_item_type' => 1]; $navItemPage->attributes = ['nav_item_id' => 0, 'layout_id' => $layoutId, 'create_user_id' => Module::getAuthorUserId(), 'timestamp_create' => time(), 'version_alias' => Module::VERSION_INIT_LABEL]; if (!$navItem->validate()) { $_errors = ArrayHelper::merge($navItem->getErrors(), $_errors); } if (!$navItemPage->validate()) { $_errors = ArrayHelper::merge($navItemPage->getErrors(), $_errors); } if (!empty($_errors)) { return $_errors; } $navItemPage->save(); $navItem->nav_item_type_id = $navItemPage->id; $navItemId = $navItem->save(); $navItemPage->updateAttributes(['nav_item_id' => $navItem->id]); return $navItemId; }
/** * @inheritdoc */ public function attributeLabels() { return ['value' => Module::t('model_navitemredirect_value_label'), 'type' => Module::t('model_navitemredirect_type_label')]; }
public function eventBeforeUpdate() { $this->timestamp_update = time(); $this->update_user_id = Module::getAuthorUserId(); $this->slugifyAlias(); }
</span> </label> </div> <?php if (Yii::$app->adminuser->canApi('api-cms-navitempageblockitem')) { ?> <div class="sidebar__button sidebar__button--grey sidebar__button--switch switch" ng-class="{ 'sidebar__button--active': showDrag }"> <label> <input type="checkbox" ng-model="showDrag" ng-true-value="1" ng-false-value="0"> <span class="lever"></span> <div class="sidebar__icon-holder"> <i class="sidebar__icon material-icons">mouse</i> </div> <span class="sidebar__text"><?php echo \luya\cms\admin\Module::t('view_index_sidebar_move'); ?> </span> </label> </div> <?php } ?> <div class="treeview" ng-repeat="catitem in menuData.containers" ng-class="{ 'treeview--drag-active' : showDrag }"> <h5 class="sidebar__group-title sidebar__group-title--clickable" ng-click="toggleCat(catitem.id)"><i class="material-icons sidebar__group-title-icon" ng-class="{'sidebar__group-title-icon--closed': toggleIsHidden(catitem.id)}">arrow_drop_down</i> <span>{{catitem.name}}</span></h5> <div class="treeview__drop" ng-show="(menuData.items|menuparentfilter:catitem.id:0).length == 0 && !toggleIsHidden(catitem.id)" ng-controller="DropNavController" ng-model="droppedNavItem" data-itemid="{{catitem.id}}" data-drop="true" data-jqyoui-options="{greedy : true, tolerance : 'pointer', hoverClass : 'treeview__drop--hover' }" jqyoui-droppable="{onDrop: 'onEmptyDrop()', multiple : true}"></div> <ul class="treeview__list" ng-hide="toggleIsHidden(catitem.id)"> <li class="treeview__item" ng-repeat="data in menuData.items | menuparentfilter:catitem.id:0" ng-include="'reverse.html'"></li>
/** * @inheritdoc */ public function fields() { $fields = parent::fields(); $fields['contentAsArray'] = 'contentAsArray'; $fields['version_alias'] = function ($model) { return Module::t($model->version_alias); }; return $fields; }
/** * @inheritdoc */ public function attributeLabels() { return ['module_name' => Module::t('model_navitemmodule_module_name_label')]; }
<?php use luya\cms\admin\Module; ?> <div ng-controller="CmsadminCreateController"> <div class="row"> <div class="col s12"> <div class="card-panel"> <h5 style="text-align:center;"><?php echo Module::t('view_index_add_title'); ?> </h5> <create-form data="data"></create-form> </div> </div> </div> </div>