Beispiel #1
0
 /**
  * Lists all menus and items
  *
  * @param {string} $siteId
  * @return {array}
  */
 public static function listExtended($siteId)
 {
     $menus = Menu::listAll($siteId);
     $i = 0;
     foreach ($menus as $menu) {
         $menus[$i]['items'] = MenuItem::listAll($menu['id'], $siteId);
         $i++;
     }
     return $menus;
 }
 /**
  * Adds the menu item
  *
  * @return Response
  */
 public function add(Request $request)
 {
     // get request data
     $email = $request->input('auth-email');
     $siteId = $request->input('auth-id');
     // menu
     $menuId = $request->json()->get('id');
     // item
     $html = $request->json()->get('html');
     $cssClass = $request->json()->get('cssClass');
     $isNested = $request->json()->get('isNested');
     $url = $request->json()->get('url');
     // add a menu
     $item = MenuItem::add($html, $cssClass, $isNested, $url, $menuId, $siteId);
     // get site and user
     $site = Site::getById($siteId);
     $user = User::getByEmail($email, $siteId);
     // re-publish plugins
     Publish::publishPlugins($user, $site);
     if ($item !== NULL) {
         return response('OK, menu item added', 200);
     }
     return response('Error', 400);
 }