Airship\Cabin\Bridge\Blueprint\CustomPages::getDirInfo PHP Method

getDirInfo() public method

Get information about only this directory
public getDirInfo ( string $cabin, string $parent = '', string $name = '' ) : array
$cabin string
$parent string
$name string
return array
    public function getDirInfo(string $cabin, string $parent = '', string $name = '') : array
    {
        if ($parent === '') {
            $info = $this->db->row('SELECT * FROM airship_custom_dir WHERE parent IS NULL AND cabin = ? AND url = ?', $cabin, $name);
        } else {
            $parentID = $this->getParentDirFromStr($parent, $cabin);
            $info = $this->db->row('SELECT * FROM airship_custom_dir WHERE parent = ? AND url = ?', $parentID, $name);
        }
        if (empty($info)) {
            throw new CustomPageNotFoundException(\__('No directory was found at this given path.'));
        }
        return $info;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * We're going to move/rename a directory
  *
  * @param string $cabin
  * @route pages/{string}/renameDir
  */
 public function renameDir(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;
     }
     $post = $this->post(new RenameFilter());
     if (!empty($post)) {
         // CAPTCHA verification and CSRF token both passed
         if ($this->processMoveDir($dirInfo, $post, $cabin, $cabins)) {
             // Return to the parent directory.
             \Airship\redirect($this->airship_cabin_prefix . '/pages/' . \trim($cabin, '/'), ['dir' => $path]);
         }
     }
     $this->lens('pages/dir_move', ['cabins' => $cabins, 'custom_dir_tree' => $this->pg->getCustomDirTree($cabins, $dirInfo['parent'] ?? 0, (int) $dirInfo['directoryid']), 'dirinfo' => $dirInfo, 'config' => $this->config(), 'parent' => $path, 'dir' => $dir, 'cabin' => $cabin, 'pathinfo' => \Airship\chunk($path)]);
 }