public function getPathByPageId(int $pageId, string $cabin = '') : array { $page = $this->db->row('SELECT url, directory FROM airship_custom_page WHERE pageid = ?', $pageId); if (empty($page)) { throw new CustomPageNotFoundException(\trk('errors.pages.page_does_not_exist')); } if (empty($page['directory'])) { return []; } try { $path = \implode('/', $this->getPathFromDirectoryId((int) $page['directory'], $cabin)); return [$cabin, \trim($path, '/'), $page['url']]; } catch (CustomPageNotFoundException $ex) { $this->log('Custom directory not found', LogLevel::ALERT, ['pageid' => $pageId, 'url' => $page['url'], 'directory' => $page['directory'], 'cabin' => $cabin, 'exception' => \Airship\throwableToArray($ex)]); throw $ex; } }
/** * Confirm deletion * * @param int $pageId * @param array $post * @param string $cabin * @param string $dir * @return mixed */ protected function processDeletePage(int $pageId, array $post = [], string $cabin = '', string $dir = '') : bool { $this->log('Attempting to delete a page', LogLevel::ALERT, ['pageId' => $pageId, 'cabin' => $cabin, 'dir' => $dir]); list($oldCabin, $oldPath, $oldURL) = $this->pg->getPathByPageId((int) $pageId, $cabin); if ($this->pg->deletePage($pageId)) { if (!empty($post['create_redirect']) && !empty($post['redirect_to'])) { $this->pg->createSameCabinRedirect($oldPath . '/' . $oldURL, $post['redirect_to'], $oldCabin); } \Airship\redirect($this->airship_cabin_prefix . '/pages/' . $cabin, ['dir' => $dir]); } return false; }