本文整理汇总了PHP中PageType::GetByPageTypeId方法的典型用法代码示例。如果您正苦于以下问题:PHP PageType::GetByPageTypeId方法的具体用法?PHP PageType::GetByPageTypeId怎么用?PHP PageType::GetByPageTypeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageType
的用法示例。
在下文中一共展示了PageType::GetByPageTypeId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PublishPage
public static function PublishPage($pageUniqId, $preview = false, $remove_draft = false, $root = '../')
{
$page = Page::GetByPageUniqId($pageUniqId);
if ($page != null) {
$site = Site::GetBySiteId($page['SiteId']);
// test for now
$dest = $root . 'sites/' . $site['FriendlyId'] . '/';
$imageurl = $dest . 'files/';
$siteurl = 'http://' . $site['Domain'] . '/';
$friendlyId = $page['FriendlyId'];
$url = '';
$file = '';
if ($preview == true) {
$previewId = uniqid();
$file = $page['FriendlyId'] . '-' . $previewId . '-preview.php';
} else {
$file = $page['FriendlyId'] . '.php';
}
// create a nice path to store the file
if ($page['PageTypeId'] == -1) {
$url = $page['FriendlyId'] . '.php';
$path = '';
} else {
$pageType = PageType::GetByPageTypeId($page['PageTypeId']);
$path = 'uncategorized/';
if ($pageType != null) {
$path = strtolower($pageType['FriendlyId']) . '/';
}
}
// generate default
$html = Utilities::GeneratePage($site, $page, $siteurl, $imageurl, $preview, $root);
// remove any drafts associated with the page
if ($remove_draft == true) {
$draft = $root . 'sites/' . $site['FriendlyId'] . '/fragments/draft/' . $page['PageUniqId'] . '.html';
if (file_exists($draft)) {
unlink($draft);
}
}
if ($preview == true) {
$s_dest = $dest . 'preview/';
} else {
$s_dest = $dest . $path;
}
// save the content to the published file
Utilities::SaveContent($s_dest, $file, $html);
// publish a rendered fragment
Publish::PublishRender($site, $page, $root);
// build the search index for the page
Publish::BuildSearchIndex($site, $page, $root);
return $s_dest . $file;
}
}
示例2: GenerateSiteMap
public static function GenerateSiteMap($site)
{
$list = Page::GetPagesForSite($site['SiteId']);
// get offset for time zone
$timeZone = new DateTimeZone($site['TimeZone']);
$now = new DateTime("now", $timeZone);
$offset = $timeZone->getOffset($now);
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
date_default_timezone_set('America/Los_Angeles');
foreach ($list as $row) {
$u = strtotime($row['LastModifiedDate']) + $offset;
$pageType = PageType::GetByPageTypeId($row['PageTypeId']);
if ($pageType['IsSecure'] == 1) {
continue;
}
if ($row['IncludeOnly'] == 1) {
continue;
}
// set URL divider based on URL mode
$divider = '/';
// build url
if ($row['PageTypeId'] == -1) {
$xml = $xml . '<url>' . '<loc>' . $site['Domain'] . $divider . strtolower($row['FriendlyId']) . '</loc>' . '<lastmod>' . date('Y-m-d', $u) . '</lastmod>' . '<priority>1.0</priority>' . '</url>';
} else {
$xml = $xml . '<url>' . '<loc>' . $site['Domain'] . $divider . strtolower($pageType['FriendlyId']) . '/' . strtolower($row['FriendlyId']) . '</loc>' . '<lastmod>' . date('Y-m-d', $u) . '</lastmod>' . '<priority>0.5</priority>' . '</url>';
}
}
$xml = $xml . '</urlset>';
return $xml;
}
示例3: 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';
}
//.........这里部分代码省略.........
示例4: ApplyMustacheSyntax
public static function ApplyMustacheSyntax($html, $site, $page)
{
// meta data
$photo = '';
$firstName = '';
$lastName = '';
$lastModifiedDate = $page['LastModifiedDate'];
// replace last modified
if ($page['LastModifiedBy'] != NULL) {
// get user
$user = User::GetByUserId($page['LastModifiedBy']);
// set user infomration
if ($user != NULL) {
$photo = $user['PhotoUrl'];
$firstName = $user['FirstName'];
$lastName = $user['LastName'];
}
}
// set page information
$html = str_replace('{{page.PhotoUrl}}', $photo, $html);
$html = str_replace('{{page.FirstName}}', $firstName, $html);
$html = str_replace('{{page.LastName}}', $lastName, $html);
$html = str_replace('{{page.LastModifiedDate}}', $lastModifiedDate, $html);
// replace timestamp
$html = str_replace('{{timestamp}}', time(), $html);
// replace year
$html = str_replace('{{year}}', date('Y'), $html);
// set images URL
$imagesURL = $site['Domain'] . '/';
// set iconURL
$iconURL = '';
if ($site['IconUrl'] != '') {
$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);
}
// set urls
$relativeURL = $page['FriendlyId'];
if ($page['PageTypeId'] != -1) {
$pageType = PageType::GetByPageTypeId($page['PageTypeId']);
$relativeURL = strtolower($pageType['FriendlyId']) . '/' . $page['FriendlyId'];
}
$fullURL = $site['Domain'] . '/' . $relativeURL;
// replace mustaches syntax {{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('{{site.IconBg}}', $site['IconBg'], $html);
$html = str_replace('{{site.EmbeddedCodeHead}}', $site['EmbeddedCodeHead'], $html);
$html = str_replace('{{site.EmbeddedCodeBottom}}', $site['EmbeddedCodeBottom'], $html);
$html = str_replace('{{page.FullStylesheetUrl}}', 'css/' . $page['Stylesheet'] . '.css', $html);
// urls
$html = str_replace('{{page.Url}}', $relativeURL, $html);
$html = str_replace('{{page.FullUrl}}', $fullURL, $html);
return $html;
}
示例5: get
/**
* @method GET
*/
function get($friendlyId)
{
// get token
$token = Utilities::ValidateJWTToken(apache_request_headers());
// check if token is not null
if ($token != NULL) {
// get a reference to the site
$site = Site::GetBySiteId($token->SiteId);
$siteId = $token->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['FriendlyId']) . '/';
}
// 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'] != '') {
$thumbUrl = '/files/thumbs/' . $page['Image'];
}
// set thumb
$page['Thumb'] = $thumbUrl;
$url = $page['FriendlyId'];
if ($page['PageTypeId'] != -1) {
$pageType = PageType::GetByPageTypeId($page['PageTypeId']);
$url = strtolower($pageType['FriendlyId']) . '/' . $page['FriendlyId'];
}
// set url
$page['Url'] = $url;
// permissions are not applicable to this API call
$page['CanEdit'] = '';
$page['CanPublish'] = '';
$page['CanRemove'] = '';
$pages[$row['PageId']] = $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);
}
}
示例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);
}
}
示例7: BuildSearchIndex
public static function BuildSearchIndex($site, $page, $language, $isDefaultLanguage, $content, $root = '../')
{
$html = str_get_html($content, true, true, DEFAULT_TARGET_CHARSET, false, DEFAULT_BR_TEXT);
$url = $page['FriendlyId'];
$isSecure = 0;
$image = $page['Image'];
if ($page['PageTypeId'] != -1) {
$pageType = PageType::GetByPageTypeId($page['PageTypeId']);
$url = $pageType['FriendlyId'] . '/' . $page['FriendlyId'];
if ($pageType['IsSecure'] == 1) {
$isSecure = 1;
}
}
if ($isDefaultLanguage == false) {
// set language to the domain for the site
$domain = $root . 'sites/' . $site['FriendlyId'] . '/locale';
// set the language
Utilities::SetLanguage($language, $domain);
}
$name = $page['Name'];
$text = '';
$h1s = '';
$h2s = '';
$h3s = '';
$description = $page['Description'];
if ($isDefaultLanguage == false) {
$name = _($name);
// get translated version
$description = _($description);
}
if ($html == null) {
return '';
}
// setup gettext blockquote, h1, h2, h3, p, td, th, li, meta tags for multi-lingual support
foreach ($html->find('blockquote') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('h1') as $el) {
if ($isDefaultLanguage == false) {
$h1s .= _($el->innertext) . ' ';
// get translated version
} else {
$h1s .= $el->innertext . ' ';
}
}
foreach ($html->find('h2') as $el) {
if ($isDefaultLanguage == false) {
$h2s .= _($el->innertext) . ' ';
// get translated version
} else {
$h2s .= $el->innertext . ' ';
}
}
foreach ($html->find('h3') as $el) {
if ($isDefaultLanguage == false) {
$h3s .= _($el->innertext) . ' ';
// get translated version
} else {
$h3s .= $el->innertext . ' ';
}
}
foreach ($html->find('p') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('td') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('th') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('li') as $el) {
if ($isDefaultLanguage == false) {
$text .= _($el->innertext) . ' ';
// get translated version
} else {
$text .= $el->innertext . ' ';
}
}
foreach ($html->find('meta[name=description]') as $el) {
if ($isDefaultLanguage == false) {
//.........这里部分代码省略.........
示例8: 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);
// set class
$cssClass = $page['Stylesheet'];
// set show-cart, show-settings, show-languages, show-login
if ($site['ShowCart'] == 1) {
$cssClass .= ' show-cart';
}
if ($site['ShowSettings'] == 1) {
$cssClass .= ' show-settings';
}
if ($site['ShowLanguages'] == 1) {
$cssClass .= ' show-languages';
}
if ($site['ShowLogin'] == 1) {
$cssClass .= ' show-login';
}
$html = str_replace('<body ui-view></body>', '<body page="' . $page['PageId'] . '" class="' . $cssClass . '">' . $layout_html . '</body>', $html);
$html = str_replace('<body></body>', '<body page="' . $page['PageId'] . '" class="' . $cssClass . '">' . $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 mustaches syntax {{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('{{site.IconBg}}', $site['IconBg'], $html);
$html = str_replace('{{page.FullStylesheetUrl}}', 'css/' . $page['Stylesheet'] . '.css', $html);
// meta data
$photo = '';
$firstName = '';
$lastName = '';
$lastModifiedDate = $page['LastModifiedDate'];
// replace last modified
if ($page['LastModifiedBy'] != NULL) {
// get user
$user = User::GetByUserId($page['LastModifiedBy']);
// set user infomration
if ($user != NULL) {
//.........这里部分代码省略.........
示例9: post
/**
* @method POST
*/
function post()
{
// get token
$token = Utilities::ValidateJWTToken(apache_request_headers());
// check if token is not null
if ($token != NULL) {
parse_str($this->request->data, $request);
// parse request
$pageTypeId = $request['pageTypeId'];
$pageType = PageType::GetByPageTypeId($pageTypeId);
$site = Site::GetBySiteId($pageType['SiteId']);
// remove page type and pages from DB
PageType::Remove($pageType['PageTypeId'], $token->SiteId);
return new Tonic\Response(Tonic\Response::OK);
} else {
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
}