예제 #1
0
 public function search($web_id)
 {
     /** @var ActiveQuery $query */
     $query = MenuRecord::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]);
     $query->andWhere(['web_id' => $web_id]);
     $query->orderBy(['main' => SORT_DESC]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Returns main menu item id for given web and language
  * @param $webId
  * @param $languageId
  * @return bool|string
  */
 public static function getMainMenuItemId($webId, $languageId)
 {
     $mainMenuId = MenuRecord::find()->select('id')->where(['web_id' => $webId, 'main' => 1])->scalar();
     if ($mainMenuId) {
         $mainMenuItemId = MenuItemRecord::find()->select('id')->where(['menu_id' => $mainMenuId, 'language_id' => $languageId, 'main' => 1])->scalar();
         if ($mainMenuItemId) {
             return $mainMenuItemId;
         }
     }
     return false;
 }
예제 #3
0
 /**
  * Checks if menu is mainmenu
  *
  * @param $menu_id
  *
  * @return bool
  */
 private static function isMainMenu($menu_id)
 {
     $menuMain = MenuRecord::find()->select('main')->where(['id' => $menu_id])->scalar();
     return $menuMain ? true : false;
 }
예제 #4
0
 /**
  * Gets menu options for dropdown
  * @param $wid integer ID of web
  * @return string
  */
 public function actionMenuListOptions($wid)
 {
     $items = MenuRecord::find()->where(['web_id' => $wid])->activeStatus()->orderBy('title')->all();
     $itemsOptions = ['arr' => false, 'prompt' => "-- " . Yii::t('back', 'Not selected') . " --"];
     return $this->renderPartial('_listOptions', compact('items', 'itemsOptions'));
 }