Airship\Cabin\Bridge\Landing\PageManager::deleteDir PHP Method

deleteDir() public method

Delete a directory in the custom page system
public deleteDir ( string $cabin = '' )
$cabin string
    public function deleteDir(string $cabin = '')
    {
        $path = $this->determinePath($cabin);
        if (!\is1DArray($_GET)) {
            \Airship\redirect($this->airship_cabin_prefix . '/pages/' . \trim($cabin, '/'));
        }
        $cabins = $this->getCabinNamespaces();
        if (!\in_array($cabin, $cabins)) {
            \Airship\redirect($this->airship_cabin_prefix);
        }
        $this->setTemplateExtraData($cabin);
        if (!$this->can('delete')) {
            \Airship\redirect($this->airship_cabin_prefix);
        }
        // Split this up
        $pieces = \explode('/', $path);
        $dir = \array_shift($pieces);
        $path = \implode('/', $pieces);
        try {
            $dirInfo = $this->pg->getDirInfo($cabin, $path, $dir);
        } catch (CustomPageNotFoundException $ex) {
            \Airship\redirect($this->airship_cabin_prefix . '/pages/' . \trim($cabin, '/'));
            return;
        }
        $secretKey = $this->config('recaptcha.secret-key');
        if (empty($secretKey)) {
            $this->lens('pages/bad_config');
        }
        $post = $this->post(new DeleteDirFilter());
        if (!empty($post)) {
            if (isset($post['g-recaptcha-response'])) {
                $rc = \Airship\getReCaptcha($secretKey, $this->config('recaptcha.curl-opts') ?? []);
                $resp = $rc->verify($post['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
                if ($resp->isSuccess()) {
                    // CAPTCHA verification and CSRF token both passed
                    if ($this->processDeleteDir((int) $dirInfo['directoryid'], $post, $cabin, $cabins)) {
                        // Return to the parent directory.
                        \Airship\redirect($this->airship_cabin_prefix . '/pages/' . \trim($cabin, '/'), ['dir' => $path]);
                    }
                }
            }
        }
        $this->lens('pages/dir_delete', ['cabins' => $cabins, 'custom_dir_tree' => $this->pg->getCustomDirTree($cabins, 0, (int) $dirInfo['directoryid']), 'dirinfo' => $dirInfo, 'config' => $this->config(), 'parent' => $path, 'dir' => $dir, 'cabin' => $cabin, 'pathinfo' => \Airship\chunk($path)]);
    }