本文整理汇总了PHP中MenuItem::RemoveForType方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::RemoveForType方法的具体用法?PHP MenuItem::RemoveForType怎么用?PHP MenuItem::RemoveForType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::RemoveForType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
/**
* @method POST
*/
function post()
{
// get token
$token = Utilities::ValidateJWTToken();
// check if token is not null
if ($token != NULL) {
parse_str($this->request->data, $request);
// parse request
$menuTypeId = $request['menuTypeId'];
$menuType = MenuType::GetByMenuTypeId($menuTypeId);
// remove items for type
MenuItem::RemoveForType($menuType['FriendlyId'], $token->SiteId);
// remove type
MenuType::Remove($menuTypeId);
return new Tonic\Response(Tonic\Response::OK);
} else {
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
}
示例2: PublishDefaultContent
public static function PublishDefaultContent($site, $theme, $userId)
{
// read the defaults file
$default_json_file = APP_LOCATION . THEMES_FOLDER . '/' . $theme . '/default.json';
// set $siteId
$siteId = $site['SiteId'];
// check to make sure the defaults.json exists
if (file_exists($default_json_file)) {
// get json from the file
$json_text = file_get_contents($default_json_file);
// decode json
$json = json_decode($json_text, true);
// pagetypes
$pagetypes = array();
// menu counts
$primaryMenuCount = 0;
$footerMenuCount = 0;
// clear default types
MenuItem::RemoveForType('primary', $siteId);
MenuItem::RemoveForType('footer', $siteId);
// walk through defaults array
foreach ($json as &$value) {
// get values from array
$url = $value['url'];
$source = $value['source'];
$name = $value['name'];
$description = $value['description'];
$layout = $value['layout'];
$stylesheet = $value['stylesheet'];
$primaryMenu = $value['primaryMenu'];
$footerMenu = $value['footerMenu'];
$includeOnly = 0;
// set includeOnly (if specified in default)
if (isset($value['includeOnly'])) {
if ($value['includeOnly'] == true) {
$includeOnly = 1;
}
}
// initialize PT
$pageType = NULL;
if (strpos($url, '/') !== false) {
// the url has a pagetype
$arr = explode('/', $url);
// get friendly ids from $url
$pageTypeFriendlyId = $arr[0];
$pageFriendlyId = $arr[1];
$pageTypeId = -1;
$pageType = PageType::GetByFriendlyId($pageTypeFriendlyId, $siteId);
// create a new pagetype
if ($pageType == NULL) {
$pageType = PageType::Add($pageTypeFriendlyId, $layout, $stylesheet, 0, $siteId, $userId);
}
// get newly minted page type
$pageTypeId = $pageType['PageTypeId'];
} else {
// root, no pagetype
$pageFriendlyId = $url;
$pageTypeId = -1;
}
// determine if page is unique
$isUnique = Page::IsFriendlyIdUnique($pageFriendlyId, $pageTypeId, $site['SiteId']);
// initialize page
$page = NULL;
// if page has not been created, create a page
if ($isUnique == true) {
// create a page
$page = Page::Add($pageFriendlyId, $name, $description, $layout, $stylesheet, $pageTypeId, $site['SiteId'], $userId);
} else {
// get the page
$page = Page::GetByFriendlyId($pageFriendlyId, $pageTypeId, $site['SiteId']);
}
// quick check
if ($page != NULL) {
// set the page to active
Page::SetIsActive($page['PageId'], 1);
// set include only
Page::SetIncludeOnly($page['PageId'], $includeOnly);
// build the content file
$filename = APP_LOCATION . THEMES_FOLDER . '/' . $theme . '/' . $source;
$content = '';
// get the content for the page
if (file_exists($filename)) {
$content = file_get_contents($filename);
// fix images
$content = str_replace('{{site-dir}}', $site['Domain'], $content);
}
// edit the page content
Page::EditContent($page['PageId'], $content, $userId);
// build the primary menu
if ($primaryMenu == true) {
MenuItem::Add($name, '', 'primary', $url, $page['PageId'], $primaryMenuCount, $site['SiteId'], $userId);
$primaryMenuCount++;
}
// build the footer menu
if ($footerMenu == true) {
MenuItem::Add($name, '', 'footer', $url, $page['PageId'], $footerMenuCount, $site['SiteId'], $userId);
$footerMenuCount++;
}
}
}
//.........这里部分代码省略.........