public static function PublishAllPages($siteUniqId, $root = '../') { $site = Site::GetBySiteUniqId($siteUniqId); // Get all pages $list = Page::GetPagesForSite($site['SiteId']); foreach ($list as $row) { Publish::PublishPage($row['PageUniqId'], false, false, $root); } }
public static function PublishAllPages($site) { // Get all pages $list = Page::GetPagesForSite($site['SiteId']); foreach ($list as $row) { Publish::PublishPage($row['PageId'], false, false); } }
/** * @method POST */ function post() { // get token $token = Utilities::ValidateJWTToken(apache_request_headers()); // check if token is not null if ($token != NULL) { // get user $user = User::GetByUserId($token->UserId); $site = Site::GetBySiteId($token->SiteId); // creates an access object $access = Utilities::SetAccess($user); parse_str($this->request->data, $request); // parse request $pageId = $request['pageId']; // get page type $content = $request['content']; // get page type $status = 'draft'; // get page and site $page = Page::GetByPageId($pageId); // make sure the user is part of the site (or is a superadmin) if ($user['SiteId'] != $page['SiteId']) { return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } // default is root $pageTypeId = -1; $pageType = NULL; // determine if file is in sub-direcotry if ($page['PageTypeId'] != -1) { $pageType = PageType::GetByPageTypeId($page['PageTypeId']); // set page type $pageTypeId = $pageType['PageTypeId']; } // get permissions $canEdit = Utilities::CanPerformAction($pageTypeId, $access['CanEdit']); $canPublish = Utilities::CanPerformAction($pageTypeId, $access['CanPublish']); // check permissions to save a draft if ($canEdit == true || $canPublish == true) { // create a preview $url = Publish::PublishPage($page['PageId'], true); } // strip leading '../' from string $url = str_replace('../', '', $url); $response = new Tonic\Response(Tonic\Response::OK); $response->contentType = 'text/html'; $response->body = $url; return $response; } else { // unauthorized access return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }
/** * @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 $configurations = $request['configurations']; $site = Site::GetBySiteId($token->SiteId); // get configuration $configure_file = SITES_LOCATION . '/' . $site['FriendlyId'] . '/themes/' . $site['Theme'] . '/configure.json'; // put contents file_put_contents($configure_file, $configurations); // republish css Publish::PublishAllCSS($site); // get index $page = Page::GetByFriendlyId('index', '-1', $token->SiteId); // republish home page Publish::PublishPage($page['PageId']); // return a json response $response = new Tonic\Response(Tonic\Response::OK); return $response; } else { // return an unauthorized exception (401) return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }
/** * @method POST */ function publish($pageUniqId) { // get an authuser $authUser = new AuthUser(); if (isset($authUser->UserUniqId)) { // check if authorized // get page $page = Page::GetByPageUniqId($pageUniqId); // make sure the user is part of the site (or is a superadmin) if ($authUser->IsSuperAdmin == false && $authUser->SiteId != $page['SiteId']) { return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } // default is root $pageTypeUniqId = -1; // determine if file is in sub-direcotry if ($page['PageTypeId'] != -1) { $pageType = PageType::GetByPageTypeId($page['PageTypeId']); // set page type $pageTypeUniqId = $pageType['PageTypeUniqId']; } // check permissions if (Utilities::CanPerformAction($pageTypeUniqId, $authUser->CanPublish) == false) { return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } // set the page to active Page::SetIsActive($pageUniqId, 1); // publish the page Publish::PublishPage($pageUniqId); // return a json response $response = new Tonic\Response(Tonic\Response::OK); } else { // unauthorized access return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }