本文整理汇总了PHP中PageType::GetByPageTypeUniqId方法的典型用法代码示例。如果您正苦于以下问题:PHP PageType::GetByPageTypeUniqId方法的具体用法?PHP PageType::GetByPageTypeUniqId怎么用?PHP PageType::GetByPageTypeUniqId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageType
的用法示例。
在下文中一共展示了PageType::GetByPageTypeUniqId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
// get the page type (if applicable)
$pageTypeId = -1;
$pageTypeUniqId = $request['pageTypeUniqId'];
// get page type
// check permissions
if (Utilities::CanPerformAction($pageTypeUniqId, $authUser->CanCreate) == false) {
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
// default layout and stylesheet is content
$layout = 'content';
$stylesheet = 'content';
if ($pageTypeUniqId != '-1') {
$pageType = PageType::GetByPageTypeUniqId($pageTypeUniqId);
if ($pageType != null) {
$pageTypeId = $pageType['PageTypeId'];
$layout = $pageType['Layout'];
$stylesheet = $pageType['Stylesheet'];
}
}
$name = $request['name'];
$friendlyId = $request['friendlyId'];
$description = $request['description'];
$page = Page::Add($friendlyId, $name, $description, $layout, $stylesheet, $pageTypeId, $authUser->SiteId, $authUser->UserId);
// add categories to the page (if set)
if (isset($request['categories'])) {
$categories = $request['categories'];
$arr = explode(',', $categories);
foreach ($arr as $categoryUniqId) {
$category = Category::GetByCategoryUniqId($categoryUniqId);
if ($category != NULL) {
Page::AddCategory($page['PageId'], $category['CategoryId']);
}
}
}
// return a json response
$response = new Tonic\Response(Tonic\Response::OK);
$response->contentType = 'application/json';
$response->body = json_encode($page);
return $response;
} else {
// unauthorized access
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
}
示例2: 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);
}
}
示例3: get
/**
* @method POST
*/
function get()
{
parse_str($this->request->data, $request);
// parse request
$siteUniqId = SITE_UNIQ_ID;
$pageTypeUniqId = $request['pageTypeUniqId'];
$site = Site::GetBySiteUniqId($siteUniqId);
$pageType = PageType::GetByPageTypeUniqId($pageTypeUniqId);
// Get all pages
$total = Page::GetPagesCount($site['SiteId'], $pageType['PageTypeId'], true);
$json = '{"total":"' . $total . '"}';
header('Content-type: application/json');
// return a json response
$response = new Tonic\Response(Tonic\Response::OK);
$response->contentType = 'applicaton/json';
$response->body = $json;
return $response;
}
示例4: delete
/**
* @method DELETE
*/
function delete($pageTypeUniqId)
{
// get an authuser
$authUser = new AuthUser();
if (isset($authUser->UserUniqId)) {
// check if authorized
$pageType = PageType::GetByPageTypeUniqId($pageTypeUniqId);
$site = Site::GetBySiteId($pageType['SiteId']);
// remove pages for that pagetype in that site
$dir = '../sites/' . $site['FriendlyId'] . '/' . $pageType['FriendlyId'];
if (file_exists($dir)) {
Utilities::RemoveDirectory($dir);
}
// remove page type and pages from DB
PageType::Delete($pageType['PageTypeId']);
return new Tonic\Response(Tonic\Response::OK);
} else {
return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
}
}