/** * @method GET */ function get() { // get an authuser $token = Utilities::ValidateJWTToken(apache_request_headers()); // check if token is not null if ($token != NULL) { parse_str($this->request->data, $request); // parse request $list = MenuItem::GetMenuItems($token->SiteId); // return a json response $response = new Tonic\Response(Tonic\Response::OK); $response->contentType = 'application/json'; $response->body = json_encode($list); return $response; } else { return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }
public static function PublishMenu($siteUniqId, $root = '../') { $site = Site::GetBySiteUniqId($siteUniqId); $list = MenuItem::GetMenuItems($site['SiteId']); $menu = array(); $count = 0; foreach ($list as $row) { if ($row['PageId'] != -1) { $page = Page::GetByPageId($row['PageId']); if ($page != null) { $pageUniqId = $page['PageUniqId']; } else { $pageUniqId = -1; } } else { $pageUniqId = -1; } $item = array('MenuItemUniqId' => $row['MenuItemUniqId'], 'Name' => $row['Name'], 'CssClass' => $row['CssClass'], 'Type' => $row['Type'], 'Url' => $row['Url'], 'PageUniqId' => $pageUniqId); $menu[$count] = $item; $count = $count + 1; } // encode to json $encoded = json_encode($menu); $dest = $root . 'sites/' . $site['FriendlyId'] . '/data/'; Utilities::SaveContent($dest, 'menu.json', $encoded); }