当前位置: 首页>>代码示例>>PHP>>正文


PHP MenuItem::GetMenuItemsForType方法代码示例

本文整理汇总了PHP中MenuItem::GetMenuItemsForType方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::GetMenuItemsForType方法的具体用法?PHP MenuItem::GetMenuItemsForType怎么用?PHP MenuItem::GetMenuItemsForType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MenuItem的用法示例。


在下文中一共展示了MenuItem::GetMenuItemsForType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get

 /**
  * @method GET
  */
 function get($type)
 {
     $list = MenuItem::GetMenuItemsForType(SITE_ID, $type);
     $menu = array();
     foreach ($list as $row) {
         $scope = 'external';
         $pageUniqId = '';
         // set the scope of the link
         if ($row['PageId'] != '-1') {
             $scope = 'internal';
             $page = Page::GetByPageId($row['PageId']);
             if ($page != NULL) {
                 $pageUniqId = $page['PageUniqId'];
             }
         }
         // set the item
         $item = array('MenuItemUniqId' => $row['MenuItemUniqId'], 'Name' => $row['Name'], 'Url' => $row['Url'], 'PageUniqId' => $pageUniqId, 'Scope' => $scope);
         // push the item to the array
         array_push($menu, $item);
     }
     // return a json response
     $response = new Tonic\Response(Tonic\Response::OK);
     $response->contentType = 'application/json';
     $response->body = json_encode($menu);
     return $response;
 }
开发者ID:eavesmonkey,项目名称:respond,代码行数:29,代码来源:menu.php

示例2: get

 /**
  * @method GET
  */
 function get($type)
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         $list = MenuItem::GetMenuItemsForType($authUser->SiteId, $type);
         // 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);
     }
 }
开发者ID:eavesmonkey,项目名称:respond,代码行数:19,代码来源:menuItem.php

示例3: 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
         $type = $request['type'];
         $list = MenuItem::GetMenuItemsForType($authUser->SiteId, $type);
         // 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);
     }
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:22,代码来源:menuItem.php

示例4: GenerateRenderAtPublish

 public static function GenerateRenderAtPublish($html, $site, $page)
 {
     // set images URL
     $imagesURL = $site['Domain'] . '/';
     // build out the menus where render is set to publish
     foreach ($html->find('respond-menu[render=publish]') as $el) {
         // get the type
         if ($el->type) {
             $type = $el->type;
             // init menu
             $menu = '<ul';
             // set class if applicable
             if (isset($el->class)) {
                 $menu .= ' class="' . $el->class . '">';
             } else {
                 $menu .= '>';
             }
             // get items for type
             $menuItems = MenuItem::GetMenuItemsForType($site['SiteId'], $type);
             $i = 0;
             $parent_flag = false;
             $new_parent = true;
             // walk through items
             foreach ($menuItems as $menuItem) {
                 $url = $menuItem['Url'];
                 $name = $menuItem['Name'];
                 $css = '';
                 $cssClass = '';
                 $active = '';
                 if ($page['PageId'] == $menuItem['PageId']) {
                     $css = 'active';
                 }
                 $css .= ' ' . $menuItem['CssClass'];
                 if (trim($css) != '') {
                     $cssClass = ' class="' . $css . '"';
                 }
                 // check for new parent
                 if (isset($menuItems[$i + 1])) {
                     if ($menuItems[$i + 1]['IsNested'] == 1 && $new_parent == true) {
                         $parent_flag = true;
                     }
                 }
                 $menu_root = '/';
                 // check for external links
                 if (strpos($url, 'http') !== false) {
                     $menu_root = '';
                 }
                 if ($new_parent == true && $parent_flag == true) {
                     $menu .= '<li class="dropdown">';
                     $menu .= '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' . $menuItem['Name'] . ' <span class="caret"></span></a>';
                     $menu .= '<ul class="dropdown-menu">';
                     $new_parent = false;
                 } else {
                     $menu .= '<li' . $cssClass . '>';
                     $menu .= '<a href="' . $url . '">' . $menuItem['Name'] . '</a>';
                     $menu .= '</li>';
                 }
                 // end parent
                 if (isset($menuItems[$i + 1])) {
                     if ($menuItems[$i + 1]['IsNested'] == 0 && $parent_flag == true) {
                         $menu .= '</ul></li>';
                         // end parent if next item is not nested
                         $parent_flag = false;
                         $new_parent = true;
                     }
                 } else {
                     if ($parent_flag == true) {
                         $menu .= '</ul></li>';
                         // end parent if next menu item is null
                         $parent_flag = false;
                         $new_parent = true;
                     }
                 }
                 $i = $i + 1;
             }
             $menu .= '</ul>';
             $el->outertext = $menu;
         }
         /* isset */
     }
     /* foreach */
     // replace content where render is set to publish
     foreach ($html->find('respond-content[render=publish]') as $el) {
         // get the url
         if (isset($el->url)) {
             $url = $el->url;
             // replace the / with a period
             $url = str_replace('/', '.', $url);
             $url .= '.html';
             $content_html = '';
             // get the content from the site
             $content_dest = SITES_LOCATION . '/' . $site['FriendlyId'] . '/templates/page/' . $url;
             if (file_exists($content_dest)) {
                 $content_html = file_get_contents($content_dest);
             }
             // update images url
             $content_html = str_replace('{{site.ImagesUrl}}', $imagesURL, $content_html);
             $content_html = str_replace('{{site.ImagesURL}}', $imagesURL, $content_html);
             // set outer text
             if ($content_html != '') {
//.........这里部分代码省略.........
开发者ID:bladep911,项目名称:respond,代码行数:101,代码来源:Publish.php

示例5: PublishStaticPage

 public static function PublishStaticPage($page, $site, $preview = false, $remove_draft = false)
 {
     $dest = SITES_LOCATION . '/' . $site['FriendlyId'] . '/';
     $imageurl = $dest . 'files/';
     $siteurl = $site['Domain'] . '/';
     $friendlyId = $page['FriendlyId'];
     $url = '';
     $file = '';
     // created ctrl
     $ctrl = ucfirst($page['FriendlyId']);
     $ctrl = str_replace('-', '', $ctrl);
     // set base
     $base = '';
     // create a static location for the page
     if ($page['PageTypeId'] == -1) {
         $url = $page['FriendlyId'] . '.html';
         $dest = SITES_LOCATION . '/' . $site['FriendlyId'] . '/';
     } else {
         $pageType = PageType::GetByPageTypeId($page['PageTypeId']);
         $dest = SITES_LOCATION . '/' . $site['FriendlyId'] . '/uncategorized/';
         if ($pageType != null) {
             $dest = SITES_LOCATION . '/' . $site['FriendlyId'] . '/' . $pageType['FriendlyId'] . '/';
             // created ctrl
             $ctrl = ucfirst($pageType['FriendlyId']) . $ctrl;
             $ctrl = str_replace('-', '', $ctrl);
         }
         // set $base to the root of the director
         $base = '../';
     }
     // create directory if it does not exist
     if (!file_exists($dest)) {
         mkdir($dest, 0755, true);
     }
     // generate default
     $html = '';
     $content = '';
     // get index and layout (file_get_contents)
     $index = SITES_LOCATION . '/' . $site['FriendlyId'] . '/themes/' . $site['Theme'] . '/layouts/index.html';
     $layout = SITES_LOCATION . '/' . $site['FriendlyId'] . '/themes/' . $site['Theme'] . '/layouts/' . $page['Layout'] . '.html';
     // get index html
     if (file_exists($index)) {
         $html = file_get_contents($index);
     }
     // get layout html
     if (file_exists($layout)) {
         $layout_html = file_get_contents($layout);
         $html = str_replace('<body ui-view></body>', '<body ng-controller="PageCtrl" page="' . $page['PageId'] . '" class="' . $page['Stylesheet'] . '">' . $layout_html . '</body>', $html);
     }
     // get draft/content
     if ($preview == true) {
         $file = $page['FriendlyId'] . '.preview.html';
         $content = $page['Draft'];
     } else {
         $file = $page['FriendlyId'] . '.html';
         $content = $page['Content'];
     }
     // replace respond-content for layout with content
     $html = str_replace('<respond-content id="main-content" url="{{page.Url}}"></respond-content>', $content, $html);
     // remove any drafts associated with the page
     if ($remove_draft == true) {
         // remove a draft from the page
         Page::RemoveDraft($page['PageId']);
     }
     // replace common Angular calls for SEO, e.g. {{page.Name}} {{page.Description}} {{site.Name}}
     $html = str_replace('{{page.Name}}', $page['Name'], $html);
     $html = str_replace('{{page.Description}}', $page['Description'], $html);
     $html = str_replace('{{page.Keywords}}', $page['Keywords'], $html);
     $html = str_replace('{{page.Callout}}', $page['Callout'], $html);
     $html = str_replace('{{site.Name}}', $site['Name'], $html);
     $html = str_replace('{{site.Language}}', $site['Language'], $html);
     $html = str_replace('{{site.Direction}}', $site['Direction'], $html);
     $html = str_replace('{{page.FullStylesheetUrl}}', 'css/' . $page['Stylesheet'] . '.css', $html);
     // update base
     $html = str_replace('<base href="/">', '<base href="' . $base . '">', $html);
     // add menu links for SEO (<respond-menu type="primary"></respond-menu>)
     $delimiter = '#';
     $startTag = '<respond-menu type="';
     $endTag = '"></respond-menu>';
     $regex = $delimiter . preg_quote($startTag, $delimiter) . '(.*?)' . preg_quote($endTag, $delimiter) . $delimiter . 's';
     // match against html
     preg_match_all($regex, $html, $matches);
     // crawl matches
     foreach ($matches[1] as &$value) {
         // init menu
         $menu = '';
         // get items for type
         $menuItems = MenuItem::GetMenuItemsForType($site['SiteId'], $value);
         $i = 0;
         $parent_flag = false;
         $new_parent = true;
         // walk through items
         foreach ($menuItems as $menuItem) {
             $url = $menuItem['Url'];
             $name = $menuItem['Name'];
             $css = '';
             $cssClass = '';
             $active = '';
             if ($page['PageId'] == $menuItem['PageId']) {
                 $css = 'active';
             }
//.........这里部分代码省略.........
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:101,代码来源:Publish.php

示例6: GeneratePage


//.........这里部分代码省略.........
     $content = str_replace('{{language}}', '<?php print $language; ?>', $content);
     $local = new DateTimeZone($site['TimeZone']);
     // create a friendly date
     $date = DateTime::createFromFormat('Y-m-d H:i:s', $page['LastModifiedDate']);
     $date->setTimezone($local);
     $readable = $date->format('D, M d y h:i a');
     $content = str_replace('{{date}}', $readable, $content);
     // create a friendly event date
     $eventBeginDate = DateTime::createFromFormat('Y-m-d H:i:s', $page['BeginDate']);
     if ($eventBeginDate != null) {
         $eventBeginDate->setTimezone($local);
         $readable = $eventBeginDate->format('D, M d y h:i a');
         $content = str_replace('{{event-begin-date}}', $readable, $content);
     }
     // get the author
     $user = User::GetByUserId($page['LastModifiedBy']);
     $author = '';
     $photo = '';
     if ($user != null) {
         $author = $user['FirstName'] . ' ' . $user['LastName'];
         if ($user['PhotoUrl'] != NULL && $user['PhotoUrl'] != '') {
             $photo = '<span class="photo" style="background-image: url(' . $rootloc . 'files/' . $user['PhotoUrl'] . ')"></span>';
         }
     }
     $content = str_replace('{{author}}', $author, $content);
     $content = str_replace('{{photo}}', $photo, $content);
     // menus
     $delimiter = '#';
     $startTag = '{{menu-';
     $endTag = '}}';
     $regex = $delimiter . preg_quote($startTag, $delimiter) . '(.*?)' . preg_quote($endTag, $delimiter) . $delimiter . 's';
     preg_match_all($regex, $content, $matches);
     foreach ($matches[1] as &$value) {
         $menuItems = MenuItem::GetMenuItemsForType($site['SiteId'], $value);
         $menu = '';
         $i = 0;
         $parent_flag = false;
         $new_parent = true;
         foreach ($menuItems as $menuItem) {
             $url = $menuItem['Url'];
             $name = $menuItem['Name'];
             $css = '';
             $cssClass = '';
             $active = '';
             if ($page['PageId'] == $menuItem['PageId']) {
                 $css = 'active';
             }
             $css .= ' ' . $menuItem['CssClass'];
             if (trim($css) != '') {
                 $cssClass = ' class="' . $css . '"';
             }
             // check for new parent
             if (isset($menuItems[$i + 1])) {
                 if ($menuItems[$i + 1]['IsNested'] == 1 && $new_parent == true) {
                     $parent_flag = true;
                 }
             }
             $menu_root = $rootloc;
             // check for external links
             if (strpos($url, 'http') !== false) {
                 $menu_root = '';
             }
             if ($new_parent == true && $parent_flag == true) {
                 $menu .= '<li class="dropdown">';
                 $menu .= '<a href="' . $menu_root . $url . '" class="dropdown-toggle" data-toggle="dropdown">' . $menuItem['Name'] . ' <b class="caret"></b></a>';
                 $menu .= '<ul class="dropdown-menu">';
开发者ID:eavesmonkey,项目名称:respond,代码行数:67,代码来源:Utilities.php

示例7: PublishStaticPage


//.........这里部分代码省略.........
         $iconURL = $imagesURL . 'files/' . $site['IconUrl'];
     }
     // replace
     $html = str_replace('ng-src', 'src', $html);
     $html = str_replace('{{site.ImagesUrl}}', $imagesURL, $html);
     $html = str_replace('{{site.ImagesURL}}', $imagesURL, $html);
     $html = str_replace('{{site.IconUrl}}', $iconURL, $html);
     // set fullLogo
     $html = str_replace('{{fullLogoUrl}}', $imagesURL . 'files/' . $site['LogoUrl'], $html);
     // set altLogo (defaults to full logo if not available)
     if ($site['AltLogoUrl'] != '' && $site['AltLogoUrl'] != NULL) {
         $html = str_replace('{{fullAltLogoUrl}}', $imagesURL . 'files/' . $site['AltLogoUrl'], $html);
     } else {
         $html = str_replace('{{fullAltLogoUrl}}', $imagesURL . 'files/' . $site['LogoUrl'], $html);
     }
     // update base
     $html = str_replace('<base href="/">', '<base href="' . $base . '">', $html);
     // parse the html for menus
     $html = str_get_html($html, true, true, DEFAULT_TARGET_CHARSET, false, DEFAULT_BR_TEXT);
     // build out the menus where render is set to publish
     foreach ($html->find('respond-menu[render=publish]') as $el) {
         // get the type
         if ($el->type) {
             $type = $el->type;
             // init menu
             $menu = '<ul';
             // set class if applicable
             if (isset($el->class)) {
                 $menu .= ' class="' . $el->class . '">';
             } else {
                 $menu .= '>';
             }
             // get items for type
             $menuItems = MenuItem::GetMenuItemsForType($site['SiteId'], $type);
             $i = 0;
             $parent_flag = false;
             $new_parent = true;
             // walk through items
             foreach ($menuItems as $menuItem) {
                 $url = $menuItem['Url'];
                 $name = $menuItem['Name'];
                 $css = '';
                 $cssClass = '';
                 $active = '';
                 if ($page['PageId'] == $menuItem['PageId']) {
                     $css = 'active';
                 }
                 $css .= ' ' . $menuItem['CssClass'];
                 if (trim($css) != '') {
                     $cssClass = ' class="' . $css . '"';
                 }
                 // check for new parent
                 if (isset($menuItems[$i + 1])) {
                     if ($menuItems[$i + 1]['IsNested'] == 1 && $new_parent == true) {
                         $parent_flag = true;
                     }
                 }
                 $menu_root = '/';
                 // check for external links
                 if (strpos($url, 'http') !== false) {
                     $menu_root = '';
                 }
                 if ($new_parent == true && $parent_flag == true) {
                     $menu .= '<li class="dropdown">';
                     $menu .= '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">' . $menuItem['Name'] . ' <span class="caret"></span></a>';
                     $menu .= '<ul class="dropdown-menu">';
开发者ID:nboss,项目名称:respond,代码行数:67,代码来源:Publish.php


注:本文中的MenuItem::GetMenuItemsForType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。