public function flushCache() { if ($this->menuLinkID) { $menuLink = new MenuLink($this->menuLinkID); $menuLink->setElement('Page', $this); $menuLink->flushCache(); } }
public function actionUpdate($id) { if (Yii::app()->request->isAjaxRequest) { $this->layout = '//layouts/empty'; } else { $this->layout = '//layouts/main'; } Yii::app()->clientScript->registerCSSFile(Yii::app()->request->getBaseUrl(false) . '/js/plugins/bootstrap-switch/static/stylesheets/bootstrap-switch-metro.css'); Yii::app()->clientScript->registerScriptFile(Yii::app()->request->getBaseUrl(false) . '/js/plugins/bootstrap-switch/static/js/bootstrap-switch.min.js', CClientScript::POS_BEGIN); Yii::app()->clientScript->registerScriptFile(Yii::app()->request->getBaseUrl(false) . '/js/plugins/bootstrap-touchspin/bootstrap.touchspin.js', CClientScript::POS_END); Yii::app()->clientScript->registerScript('initTouchSpin', "FormComponents.initTouchSpin();", CClientScript::POS_END); $sections = $this->getMainSections(); $parents[0] = 'Нет родителя'; foreach ($sections as $section) { if ($section['id'] != $id) { $parents[$section['id']] = $section['title']; } } $childs = MenuLink::model()->findAll(array('conditions' => array('menu_id' => array('equals' => 7)), 'sort' => array('parent_id' => 1, 'order' => 1))); foreach ($childs as $child) { $show = false; $allowed_modules = explode(',', $child->is_visible); foreach ($allowed_modules as $am) { if (trim($am) == 1) { $show = true; } else { if (Yii::app()->params[trim($am)]) { $show = true; } } } if ($show) { $temp = array(); $temp['id'] = $child->id; $temp['title'] = $child->title; if ($child->parent_id > 0) { $filtered_childs[$child->parent_id][] = $temp; } } } $model = $this->loadModel($id); if (isset($_POST['MenuLinks'])) { $model->attributes = $_POST['MenuLinks']; // TODO поправить баг $model->controller = $_POST['MenuLinks']['controller']; $model->url = $_POST['MenuLinks']['url']; $model->icon = $_POST['MenuLinks']['icon']; if ($_POST['MenuLinks']['is_visible'] == "Да") { $model->is_visible = true; } else { if ($_POST['MenuLinks']['is_visible'] == "Нет") { $model->is_visible = false; } else { $model->is_visible = $_POST['MenuLinks']['is_visible']; } } if ($model->save()) { $this->redirect(array('index')); } } $updateSection = null; foreach ($sections as $section) { if ($section->id == $id) { $updateSection = $section; } } $this->render('update', array('model' => $model, 'sections' => $parents, 'section' => $updateSection, 'subsections' => $filtered_childs[$id])); }
public function getHiddenSections() { return MenuLink::model()->findAll(array('conditions' => array('menu_id' => array('equals' => 7), 'is_visible' => array('equals' => false)), 'sort' => array('order' => 1))); }
/** * Display the list of the menus available * * @return Response */ public function list_menus() { $l = MenuLink::all(); return View::make('admin.menu', ['links' => $l]); }
/** * Add classes to the current link and its ancestors * @param \Laasti\Navigation\MenuLink $link */ protected function activate(MenuLink $link) { $link->setAttribute('class', $link->getAttribute('class') . ' ' . $this->classes['active']); $link->setContainerAttribute('class', $link->getContainerAttribute('class') . ' ' . $this->classes['container_active']); $parent = $link->getParent(); $level = 0; while ($parent instanceof Menu || $parent instanceof MenuLink) { if ($parent instanceof Menu) { $parent = $parent->getParent(); continue; } if (!$level) { $parent->setAttribute('class', $parent->getAttribute('class') . ' ' . $this->classes['parent']); $parent->setContainerAttribute('class', $parent->getContainerAttribute('class') . ' ' . $this->classes['container_parent']); } else { $parent->setAttribute('class', $parent->getAttribute('class') . ' ' . $this->classes['ancestor']); $parent->setContainerAttribute('class', $parent->getContainerAttribute('class') . ' ' . $this->classes['container_ancestor']); } $level++; $parent = $parent->getParent(); } }
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the Closure to execute when that URI is requested. | */ if (Schema::hasTable('menu_links')) { $twig = app('twig'); $twig->addGlobal('links', MenuLink::all()); } Route::get('/', 'MainController@home'); // All user related resources Route::resource('users', 'UsersController'); Route::get('signout', 'UsersController@signout'); Route::get('search', 'MainController@lookup'); Route::get('recover-password', 'UsersController@recover_password'); Route::post('recover-password', 'UsersController@recover_password_post'); Route::post('signin', 'UsersController@signin'); Route::get('activation/{code}', 'UsersController@activation'); Route::get('p/{page}', 'MainController@page'); Route::get('news/{id}', 'MainController@news'); // Artist related routes Route::get('artist/new/', array('before' => 'auth|fresh|isArtist', 'uses' => 'ArtistsController@new_artist')); Route::post('create/album/', array('before' => 'auth|fresh|isArtist', 'uses' => 'ArtistsController@create_album')); Route::get('delete/album/{id}', array('before' => 'auth|fresh|isArtist', 'uses' => 'ArtistsController@delete_album'));
public function flushCache() { $menuLinkID = DB::query("SELECT `ID` FROM `" . MenuLink::TABLE . "` WHERE `URL`='/project'")->fetchFirstField(); $menuLink = new MenuLink($menuLinkID); $menuLink->flushCache(); }