From b1eaa506b228030cf8d90381144a4aa6ece8879e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ste=CC=81phane=20Goetz?= Date: Sun, 2 Aug 2015 15:42:23 +0200 Subject: [PATCH] Code Style --- libs/Console/Generate.php | 3 ++- libs/Format/Confluence/Api.php | 11 +++++++++-- libs/Format/Confluence/Generator.php | 4 +++- libs/Format/HTML/ContentPage.php | 4 +++- libs/Tree/Builder.php | 4 +++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libs/Console/Generate.php b/libs/Console/Generate.php index c25038c..7960d45 100644 --- a/libs/Console/Generate.php +++ b/libs/Console/Generate.php @@ -39,7 +39,8 @@ class Generate extends SymfonyCommand $daux->getGenerator()->generateAll($input, $output, $width); } - protected function prepareDaux(InputInterface $input) { + protected function prepareDaux(InputInterface $input) + { $daux = new Daux(Daux::STATIC_MODE); // Set the format if requested diff --git a/libs/Format/Confluence/Api.php b/libs/Format/Confluence/Api.php index af498c4..260c6be 100644 --- a/libs/Format/Confluence/Api.php +++ b/libs/Format/Confluence/Api.php @@ -193,14 +193,21 @@ class Api */ public function uploadAttachment($id, $attachment) { - //get if attachment is uploaded + // Check if an attachment with + // this name is uploaded try { $result = $this->getClient()->get("content/$id/child/attachment?filename=$attachment[filename]")->json(); } catch (BadResponseException $e) { throw $this->handleError($e); } - $url = "content/$id/child/attachment" . (count($result['results']) ? "/{$result['results'][0]['id']}/data" : ""); + $url = "content/$id/child/attachment"; + + // If the attachment is already uploaded, + // the update URL is different + if (count($result['results'])) { + $url .= "/{$result['results'][0]['id']}/data"; + } try { $this->getClient()->post( diff --git a/libs/Format/Confluence/Generator.php b/libs/Format/Confluence/Generator.php index e079f7f..ddfb155 100644 --- a/libs/Format/Confluence/Generator.php +++ b/libs/Format/Confluence/Generator.php @@ -85,10 +85,12 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator } elseif ($node instanceof Content) { $params['request'] = $node->getUrl(); + $contentType = $this->daux->getContentTypeHandler()->getType($node); + $data = [ 'title' => $this->prefix . $node->getTitle(), 'file' => $node, - 'page' => ContentPage::fromFile($node, $params, $this->daux->getContentTypeHandler()->getType($node)), + 'page' => ContentPage::fromFile($node, $params, $contentType), ]; // As the page is lazily generated diff --git a/libs/Format/HTML/ContentPage.php b/libs/Format/HTML/ContentPage.php index e849b21..c2e8db7 100644 --- a/libs/Format/HTML/ContentPage.php +++ b/libs/Format/HTML/ContentPage.php @@ -82,7 +82,9 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage $page['breadcrumb_separator'] = $params['html']['breadcrumb_separator']; } + $context = ['page' => $page, 'params' => $params]; + $template = new Template($params['templates'], $params['theme']['templates']); - return $template->render($this->homepage ? 'theme::home' : 'theme::content', ['page' => $page, 'params' => $params]); + return $template->render($this->homepage ? 'theme::home' : 'theme::content', $context); } } diff --git a/libs/Tree/Builder.php b/libs/Tree/Builder.php index 3b5f3e3..bc7c528 100644 --- a/libs/Tree/Builder.php +++ b/libs/Tree/Builder.php @@ -61,7 +61,9 @@ class Builder $config = $parent->getConfig(); if (!in_array(pathinfo($path, PATHINFO_EXTENSION), $config['valid_content_extensions'])) { - $entry = new Raw($parent, static::removeSortingInformations(static::getFilename($path)), $path, filemtime($path)); + $uri = static::removeSortingInformations(static::getFilename($path)); + + $entry = new Raw($parent, $uri, $path, filemtime($path)); $entry->setTitle(static::removeSortingInformations($name, ' ')); $entry->setName($name);