From d02ac856977973ce04ce2c448329d7172864e746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Sun, 16 Aug 2015 22:26:00 +0200 Subject: [PATCH] Fix code style --- libs/Server/Server.php | 2 +- libs/Tree/Builder.php | 3 ++- libs/Tree/Directory.php | 39 +++++++++++++++++++-------------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libs/Server/Server.php b/libs/Server/Server.php index 18db9ea..1abe7c0 100644 --- a/libs/Server/Server.php +++ b/libs/Server/Server.php @@ -74,7 +74,7 @@ class Server // The path has a special treatment on windows, revert the slashes $dir = dirname($_SERVER['PHP_SELF']); - $this->base_url = $_SERVER['HTTP_HOST'] . (DIRECTORY_SEPARATOR == "\\"? str_replace($dir,"\\","/") : $dir); + $this->base_url = $_SERVER['HTTP_HOST'] . (DIRECTORY_SEPARATOR == "\\"? str_replace($dir, "\\", "/") : $dir); $t = strrpos($this->base_url, '/index.php'); if ($t != false) { diff --git a/libs/Tree/Builder.php b/libs/Tree/Builder.php index c46c1f1..7a44548 100644 --- a/libs/Tree/Builder.php +++ b/libs/Tree/Builder.php @@ -15,7 +15,8 @@ class Builder '.DS_Store', 'Thumbs.db', ]; - protected static function isIgnored(\SplFileInfo $file, $ignore) { + protected static function isIgnored(\SplFileInfo $file, $ignore) + { if (in_array($file->getFilename(), static::$IGNORED)) { return true; } diff --git a/libs/Tree/Directory.php b/libs/Tree/Directory.php index 0199210..6deac12 100644 --- a/libs/Tree/Directory.php +++ b/libs/Tree/Directory.php @@ -59,8 +59,7 @@ class Directory extends Entry /* If the inherit_index flag is set, then we seek child content */ - if ( - $this->getConfig()['mode'] == Daux::LIVE_MODE + if ($this->getConfig()['mode'] == Daux::LIVE_MODE && !empty($this->getConfig()['live']['inherit_index']) && $first_page = $this->seekFirstPage() ) { @@ -74,25 +73,25 @@ class Directory extends Entry * Seek the first available page from descendants * @return Content|null */ - public function seekFirstPage(){ - if( $this instanceof Directory ){ - $index_key = $this->getConfig()['index_key']; - if (isset($this->children[$index_key])) { - return $this->children[$index_key]; + public function seekFirstPage() + { + if ($this instanceof Directory) { + $index_key = $this->getConfig()['index_key']; + if (isset($this->children[$index_key])) { + return $this->children[$index_key]; + } + foreach ($this->children as $node_key => $node) { + if ($node instanceof Content) { + return $node; + } + if ($node instanceof Directory + && strpos($node->getUri(), '.') !== 0 + && $childNode = $node->seekFirstPage() ) { + return $childNode; + } + } } - foreach( $this->children AS $node_key => $node ){ - if( $node instanceof Content ){ - return $node; - } - if( - $node instanceof Directory - && strpos($node->getUri(), '.') !== 0 - && $childNode = $node->seekFirstPage() ){ - return $childNode; - } - } - } - return null; + return null; } /**