本文整理汇总了PHP中MenuItem::GetMenuItems方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::GetMenuItems方法的具体用法?PHP MenuItem::GetMenuItems怎么用?PHP MenuItem::GetMenuItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::GetMenuItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* @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);
}
}
示例2: PublishMenu
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);
}