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


PHP PageType::GetByFriendlyId方法代码示例

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


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

示例1: get

 /**
  * @method POST
  */
 function get()
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         $pageTypeId = -1;
         parse_str($this->request->data, $request);
         // parse request
         if (isset($request['pageTypeId'])) {
             $pageTypeId = $request['pageTypeId'];
         }
         if (isset($request['friendlyId'])) {
             $friendlyId = $request['friendlyId'];
             $pageType = PageType::GetByFriendlyId($friendlyId, $authUser->SiteId);
             // look up id
             $pageTypeId = $pageType['PageTypeId'];
         }
         if (isset($request['pageTypeUniqId'])) {
             $pageType = PageType::GetByPageTypeUniqId($request['pageTypeUniqId']);
             // look up id
             $pageTypeId = $pageType['PageTypeId'];
         }
         // check that pageTypeId was set
         if ($pageTypeId != -1) {
             $list = Category::GetCategories($pageTypeId);
             // return a json response
             $response = new Tonic\Response(Tonic\Response::OK);
             $response->contentType = 'application/json';
             $response->body = json_encode($list);
             return $response;
         } else {
             // return an empty response (e.g. root has not categories)
             $response = new Tonic\Response(Tonic\Response::OK);
             $response->contentType = 'application/json';
             $response->body = '[]';
             return $response;
         }
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:eavesmonkey,项目名称:respond,代码行数:45,代码来源:category.php

示例2: post


//.........这里部分代码省略.........
             $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'];
                 $layout = $value['layout'];
                 $stylesheet = $value['stylesheet'];
                 $primaryMenu = $value['primaryMenu'];
                 $footerMenu = $value['footerMenu'];
                 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, 'Page', 'Pages', $layout, $stylesheet, 0, $siteId, $userId, $userId);
                     }
                     // get newly minted page type
                     $pageTypeId = $pageType['PageTypeId'];
                 } else {
                     // root, no pagetype
                     $pageFriendlyId = $url;
                     $pageTypeId = -1;
                 }
                 // create a page
                 $page = Page::Add($pageFriendlyId, $name, $description, $layout, $stylesheet, $pageTypeId, $site['SiteId'], $userId);
                 // set the page to active
                 Page::SetIsActive($page['PageUniqId'], 1);
                 // build the content file
                 $filename = '../themes/' . $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}}', 'sites/' . $site['FriendlyId'], $content);
                 }
                 // publish the fragment
                 Publish::PublishFragment($site['FriendlyId'], $page['PageUniqId'], 'publish', $content);
                 // build the primary menu
                 if ($primaryMenu == true) {
                     MenuItem::Add($name, '', 'primary', $url, $page['PageId'], $primaryMenuCount, $site['SiteId'], $userId, $userId);
                     $primaryMenuCount++;
                 }
                 // build the footer menu
                 if ($footerMenu == true) {
                     MenuItem::Add($name, '', 'footer', $url, $page['PageId'], $footerMenuCount, $site['SiteId'], $userId, $userId);
                     $footerMenuCount++;
                 }
             }
         } else {
             return new Tonic\Response(Tonic\Response::BADREQUEST);
         }
         // publishes a theme for a site
         Publish::PublishTheme($site, $theme);
         // publish the site
         Publish::PublishSite($site['SiteUniqId']);
         // send welcome email
         if (SEND_WELCOME_EMAIL == true && $email != '') {
             $to = $email;
             $from = REPLY_TO;
             $fromName = REPLY_TO_NAME;
             $subject = BRAND . ': Welcome to ' . BRAND;
             $file = 'emails/new-user.html';
             // create strings to replace
             $loginUrl = APP_URL;
             $newSiteUrl = APP_URL . '/sites/' . $site['FriendlyId'];
             $replace = array('{{brand}}' => BRAND, '{{reply-to}}' => REPLY_TO, '{{new-site-url}}' => $newSiteUrl, '{{login-url}}' => $loginUrl);
             // send email from file
             Utilities::SendEmailFromFile($to, $from, $fromName, $subject, $replace, $file);
         }
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:eavesmonkey,项目名称:respond,代码行数:101,代码来源:site.php

示例3: 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

示例4: GetByUrl

 public static function GetByUrl($url, $siteId)
 {
     if (strpos($url, '/') !== false) {
         // get by
         $arr = explode('/', $url);
         $pageTypeFriendlyId = $arr[0];
         $pageFriendlyId = $arr[1];
         $pageType = PageType::GetByFriendlyId($pageTypeFriendlyId, $siteId);
         $page = Page::GetByFriendlyId($pageFriendlyId, $pageType['PageTypeId'], $siteId);
         return $page;
     } else {
         $pageFriendlyId = $url;
         $page = Page::GetByFriendlyId($pageFriendlyId, -1, $siteId);
         return $page;
     }
 }
开发者ID:eavesmonkey,项目名称:respond,代码行数:16,代码来源:Page.php

示例5: post

 /**
  * @method POST
  */
 function post()
 {
     parse_str($this->request->data, $request);
     // parse request
     $siteId = $request['siteId'];
     $friendlyId = $request['type'];
     // get pagetype
     $pageType = PageType::GetByFriendlyId($friendlyId, $siteId);
     // get a count
     $count = Page::GetPagesCount($siteId, $pageType['PageTypeId'], true);
     // return a json response
     $response = new Tonic\Response(Tonic\Response::OK);
     $response->contentType = 'applicaton/json';
     $response->body = '{"count":' . $count . '}';
     return $response;
     return new Tonic\Response(Tonic\Response::CREATED);
 }
开发者ID:nboss,项目名称:respond,代码行数:20,代码来源:page.php

示例6: get

 /**
  * @method GET
  */
 function get($friendlyId)
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         $siteId = $authUser->SiteId;
         $pageSize = 100;
         $orderBy = 'Created DESC';
         $page = 0;
         $pageTypeId = -1;
         $dir = '/';
         if ($friendlyId != 'root') {
             // get pagetype
             $pageType = PageType::GetByFriendlyId($friendlyId, $siteId);
             $pageTypeId = $pageType['PageTypeId'];
             $dir = strtolower($pageType['TypeS']) . '/';
         }
         // get site url
         $site = Site::GetBySiteId($authUser->SiteId);
         $dir = 'sites/' . $site['FriendlyId'] . '/files/';
         // get pages
         $list = Page::GetPages($siteId, $pageTypeId, $pageSize, $page, $orderBy);
         $pages = array();
         foreach ($list as $row) {
             $page = Page::GetByPageId($row['PageId']);
             $fullName = $row['FirstName'] . ' ' . $row['LastName'];
             $page['LastModifiedFullName'] = $fullName;
             $thumbUrl = '';
             if ($page['Image'] != '') {
                 if (strpos($page['Image'], 't-') !== false) {
                     $thumbUrl = $dir . $page['Image'];
                 } else {
                     $thumbUrl = $dir . 't-' . $page['Image'];
                 }
             }
             // set thumb
             $page['Thumb'] = $thumbUrl;
             $url = $page['FriendlyId'];
             if ($page['PageTypeId'] != -1) {
                 $pageType = PageType::GetByPageTypeId($page['PageTypeId']);
                 $url = strtolower($pageType['TypeS']) . '/' . $page['FriendlyId'];
             }
             // set url
             $page['Url'] = $url;
             // permissions are not applicable to this API call
             $page['CanEdit'] = '';
             $page['CanPublish'] = '';
             $page['CanRemove'] = '';
             $pages[$row['PageUniqId']] = $page;
         }
         // return a json response
         $response = new Tonic\Response(Tonic\Response::OK);
         $response->contentType = 'application/json';
         $response->body = json_encode($pages);
         return $response;
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
 }
开发者ID:eavesmonkey,项目名称:respond,代码行数:64,代码来源:page.php

示例7: ParseHTML


//.........这里部分代码省略.........
                         // loads the module
                         $content = ob_get_contents();
                         // holds the content
                         ob_end_clean();
                         $el->outertext = $content;
                     } else {
                         if ($name == 'analytics') {
                             ob_start();
                             $webpropertyid = $site['AnalyticsId'];
                             include $root . 'sites/common/modules/analytics.php';
                             // loads the module
                             $content = ob_get_contents();
                             // holds the content
                             ob_end_clean();
                             $el->outertext = $content;
                         } else {
                             if ($name == 'rss') {
                                 ob_start();
                                 include $root . 'sites/common/modules/rss.php';
                                 // loads the module
                                 $content = ob_get_contents();
                                 // holds the content
                                 ob_end_clean();
                                 $el->outertext = $content;
                             } else {
                                 if ($name == 'list') {
                                     $pageTypeUniqId = '';
                                     if (isset($el->type)) {
                                         $pageTypeUniqId = $el->type;
                                     }
                                     // translate a friendlyId to a pageTypeUniqId
                                     if (isset($el->pagetype)) {
                                         $friendlyId = $el->pagetype;
                                         $pageType = PageType::GetByFriendlyId($friendlyId, $site['SiteId']);
                                         $pageTypeUniqId = $pageType['PageTypeUniqId'];
                                     }
                                     if ($pageTypeUniqId != '') {
                                         $label = $el->label;
                                         $isAjax = false;
                                         $pageNo = 1;
                                         $curr = 0;
                                         $listid = $el->id;
                                         $display = $el->display;
                                         $desclength = $el->desclength;
                                         $length = $el->length;
                                         $orderby = $el->orderby;
                                         $category = $el->category;
                                         $pageresults = $el->pageresults;
                                         if ($el->display == 'blog') {
                                             $list = '';
                                             ob_start();
                                             include $root . 'sites/common/modules/list-blog.php';
                                             // loads the module
                                             $list = ob_get_contents();
                                             // get content from module
                                             ob_end_clean();
                                         } else {
                                             if ($el->display == 'list') {
                                                 $list = '';
                                                 ob_start();
                                                 include $root . 'sites/common/modules/list.php';
                                                 // loads the module
                                                 $list = ob_get_contents();
                                                 // get content from module
                                                 ob_end_clean();
                                             } else {
开发者ID:eavesmonkey,项目名称:respond,代码行数:67,代码来源:Utilities.php


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