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


PHP MenuItem::Add方法代码示例

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


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

示例1: add

 /**
  * @method POST
  */
 function add()
 {
     // 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
         $name = $request['name'];
         $cssClass = $request['cssClass'];
         $type = $request['type'];
         $url = $request['url'];
         $pageId = $request['pageId'];
         $priority = $request['priority'];
         $siteId = $token->SiteId;
         $lastModifiedBy = $token->UserId;
         $menuItem = MenuItem::Add($name, $cssClass, $type, $url, $pageId, $priority, $siteId, $lastModifiedBy);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($menuItem);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:sanderdrummer,项目名称:Homepages,代码行数:30,代码来源:menuItem.php

示例2: add

 /**
  * @method POST
  */
 function add()
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         parse_str($this->request->data, $request);
         // parse request
         $name = $request['name'];
         $cssClass = $request['cssClass'];
         $type = $request['type'];
         $url = $request['url'];
         $pageId = $request['pageId'];
         $priority = $request['priority'];
         $siteId = $authUser->SiteId;
         $createdBy = $authUser->UserId;
         $lastModifiedBy = $authUser->UserId;
         $menuItem = MenuItem::Add($name, $cssClass, $type, $url, $pageId, $priority, $siteId, $createdBy, $lastModifiedBy);
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($menuItem);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:eavesmonkey,项目名称:respond,代码行数:31,代码来源:menuItem.php

示例3: post

 /**
  * @method POST
  */
 function post()
 {
     parse_str($this->request->data, $request);
     // parse request
     $friendlyId = $request['friendlyId'];
     $name = $request['name'];
     $s_passcode = $request['passcode'];
     $timeZone = $request['timeZone'];
     $email = '';
     $password = '';
     $language = 'en-us';
     // language for the app
     $userId = -1;
     $theme = DEFAULT_THEME;
     // set theme
     if (isset($request['theme'])) {
         $theme = $request['theme'];
     }
     // set language if set
     if (isset($request['language'])) {
         $language = $request['language'];
     }
     // check for email and password
     if (isset($request['email'])) {
         $userLanguage = 'en-us';
         if (isset($request['userLanguage'])) {
             $userLanguage = $request['userLanguage'];
         }
         $email = $request['email'];
         $password = $request['password'];
     } else {
         // get an authuser
         $authUser = new AuthUser();
         if ($authUser->UserUniqId && $authUser->IsSuperAdmin == true) {
             // check if authorized
             $userId = $authUser->UserId;
         } else {
             return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
         }
     }
     // defaults
     $firstName = 'New';
     $lastName = 'User';
     $domain = APP_URL . '/sites/' . $friendlyId;
     $domain = str_replace('http://', '', $domain);
     $logoUrl = 'sample-logo.png';
     if ($s_passcode == PASSCODE) {
         // check for uniqueness of email
         if ($email != '') {
             $isUserUnique = User::IsLoginUnique($email);
             if ($isUserUnique == false) {
                 return new Tonic\Response(Tonic\Response::CONFLICT);
             }
         }
         $isFriendlyIdUnique = Site::IsFriendlyIdUnique($friendlyId);
         if ($isFriendlyIdUnique == false) {
             return new Tonic\Response(Tonic\Response::CONFLICT);
         }
         // add the site
         $site = Site::Add($domain, $name, $friendlyId, $logoUrl, $theme, $email, $timeZone, $language);
         // add the site
         // add the admin
         if ($email != '') {
             $isActive = 1;
             // admins by default are active
             $user = User::Add($email, $password, $firstName, $lastName, 'Admin', $userLanguage, $isActive, $site['SiteId']);
             $userId = $user['UserId'];
         }
         // set the stripe plan, customer id, status
         if (DEFAULT_STRIPE_PLAN != '') {
             Stripe::setApiKey(STRIPE_API_KEY);
             $customer = Stripe_Customer::create(array("plan" => DEFAULT_STRIPE_PLAN, "email" => $email));
             $customerId = $customer->id;
             Site::EditCustomer($site['SiteUniqId'], $customerId);
         }
         // read the defaults file
         $default_json_file = '../themes/' . $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;
             // walk through defaults array
             foreach ($json as &$value) {
                 // get values from array
                 $url = $value['url'];
                 $source = $value['source'];
                 $name = $value['name'];
                 $description = $value['description'];
//.........这里部分代码省略.........
开发者ID:eavesmonkey,项目名称:respond,代码行数:101,代码来源:site.php

示例4: 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++;
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:bladep911,项目名称:respond,代码行数:101,代码来源:Publish.php


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