public function actionCreate()
 {
     $model = new Menu();
     $form = new Form('content.MenuForm', $model);
     if ($form->submitted() && $model->save()) {
         $section = new MenuSection();
         $section->menu_id = $model->id;
         $section->title = $model->name . '::корень';
         $section->saveNode();
         $this->redirect('/content/MenuAdmin/manage/');
     }
     $this->render('create', ['form' => $form]);
 }
 /**
  * Import the menu item Section
  * Check for existing records, ensuring no duplicates.
  *
  * @param  object &$obj   The menu item object
  * @param  string $val    The name of the Section
  * @param  array  $record The record from the CSV
  * @return void
  */
 static function importSection(&$obj, $val, $record)
 {
     // Get the Section Title from the passed in value
     $SQL_val = Convert::raw2sql($val);
     // Get a MenuSection record that matches the Title
     $oResult = DataObject::get_one('MenuSection', "Title = '{$SQL_val}'");
     // If no record with the current Title exists
     if (!$oResult) {
         // Set a new MenuSection object
         $oSection = new MenuSection();
         // Set the Title to the passed in value
         $oSection->Title = $SQL_val;
         // Set the MenuPageID from the session MenuPageID var
         $oSection->MenuPageID = Session::get('MenuPageID');
         // If there are SectionImageIDs session vars set in the load method
         if (Session::get('SectionImageIDs')) {
             // Loop through the session SectionImageIDs
             foreach (Session::get('SectionImageIDs') as $title => $imageId) {
                 // If the MenuSection object Title matches the title of the session record
                 if (strtolower($oSection->Title) == $title) {
                     // Set the image ID for the MenuSection object
                     $oSection->SectionImageID = $imageId;
                 }
             }
         }
         // Save the MenuSection record
         $iResult = $oSection->write();
         // Set the MenuSectionID ID from the insert result
         $obj->MenuSubSection()->MenuSectionID = $iResult;
     } else {
         // Set the MenuSectionID from the existing record
         $obj->MenuSubSection()->MenuSectionID = $oResult->ID;
     }
     // Return the result
     //return $oResult;
 }
Example #3
0
<?php

$this->page_title = $this->t('admin', 'Сортировка пунктов меню');
$this->tabs = [$this->t('admin', 'Управление пунктами меню') => $this->createUrl("manage", ['menu_id' => $menu_id])];
?>

<div class="sortable-list">
    <?php 
$this->widget('content.portlets.NestedSortable', ['model' => MenuSection::model(), 'sortable' => true, 'root_id' => $root_id, 'id' => 'menu_section_sorting']);
?>
</div>
 public function actionManage($menu_id)
 {
     $menu = Menu::model()->findByPk($menu_id);
     if (!$menu) {
         $this->pageNotFound();
     }
     $root = MenuSection::model()->roots()->find('menu_id = ' . $menu_id);
     if (!$root) {
         $root = new MenuSection();
         $root->menu_id = $menu->id;
         $root->title = $menu->name . '::корень';
         $root->saveNode();
     }
     $model = new MenuSection('search');
     $model->unsetAttributes();
     if (isset($_GET['MenuSection'])) {
         $model->attributes = $_GET['MenuSection'];
     }
     $this->render('manage', ['menu' => $menu, 'model' => $model, 'root' => $root]);
 }
Example #5
0
 public function getPagePath($page_id)
 {
     $section = MenuSection::model()->findByAttributes(['page_id' => $page_id, 'menu_id' => $this->id]);
     return $section->getPath();
 }