From 934c47ffbf9e863fbdaa420b3968a712c2d11e70 Mon Sep 17 00:00:00 2001 From: Awilum Date: Tue, 13 Mar 2018 01:22:01 +0300 Subject: [PATCH] Code cleanup and refactoring #5 --- rawilum/Cache.php | 12 ++++++++---- rawilum/Pages.php | 24 ++++++++++++------------ rawilum/Plugins.php | 3 ++- rawilum/Rawilum.php | 2 +- rawilum/Themes.php | 1 - 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/rawilum/Cache.php b/rawilum/Cache.php index 029834b1..c7b6c11d 100755 --- a/rawilum/Cache.php +++ b/rawilum/Cache.php @@ -104,15 +104,19 @@ class Cache break; case 'memcache': $memcache = new \Memcache(); - $memcache->connect($this->rawilum['config']->get('site.cache.memcache.server', 'localhost'), - $this->rawilum['config']->get('site.cache.memcache.port', 11211)); + $memcache->connect( + $this->rawilum['config']->get('site.cache.memcache.server', 'localhost'), + $this->rawilum['config']->get('site.cache.memcache.port', 11211) + ); $driver = new \Doctrine\Common\Cache\MemcacheCache(); $driver->setMemcache($memcache); break; case 'redis': $redis = new \Redis(); - $redis->connect($this->rawilum['config']->get('site.cache.redis.server', 'localhost'), - $this->rawilum['config']->get('site.cache.redis.port', 6379)); + $redis->connect( + $this->rawilum['config']->get('site.cache.redis.server', 'localhost'), + $this->rawilum['config']->get('site.cache.redis.port', 6379) + ); $driver = new \Doctrine\Common\Cache\RedisCache(); $driver->setRedis($redis); break; diff --git a/rawilum/Pages.php b/rawilum/Pages.php index 577af1e4..4c6d2545 100755 --- a/rawilum/Pages.php +++ b/rawilum/Pages.php @@ -46,17 +46,17 @@ class Pages // If url is empty that its a homepage if ($url_abs) { - if ($url) { - $file = $url; - } else { - $file = PAGES_PATH . '/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md'; - } + if ($url) { + $file = $url; + } else { + $file = PAGES_PATH . '/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md'; + } } else { - if ($url) { - $file = PAGES_PATH . '/' . $url . '/index.md'; - } else { - $file = PAGES_PATH . '/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md'; - } + if ($url) { + $file = PAGES_PATH . '/' . $url . '/index.md'; + } else { + $file = PAGES_PATH . '/' . $this->rawilum['config']->get('site.pages.main') . '/' . 'index.md'; + } } // Get 404 page if file not exists @@ -83,7 +83,8 @@ class Pages $template_path = THEMES_PATH . '/' . $site_theme . '/' . $template_name . $template_ext; if ($this->rawilum['filesystem']->exists($template_path)) { - include $template_path; + $this->rawilum['themes']->renderPage($page); + //include $template_path; } else { throw new RuntimeException("Template {$template_name} does not exist."); } @@ -123,7 +124,6 @@ class Pages */ public function getPage($url = '', $raw = false, $url_abs = false) { - $file = $this->finder($url, $url_abs); if ($raw) { diff --git a/rawilum/Plugins.php b/rawilum/Plugins.php index f74c51e9..3ce776d8 100755 --- a/rawilum/Plugins.php +++ b/rawilum/Plugins.php @@ -32,7 +32,8 @@ class Plugins * @access public * @return mixed */ - public function init() { + public function init() + { // Plugin manifest $plugin_manifest = []; diff --git a/rawilum/Rawilum.php b/rawilum/Rawilum.php index 606f05d9..8d1acb3e 100755 --- a/rawilum/Rawilum.php +++ b/rawilum/Rawilum.php @@ -84,7 +84,7 @@ class Rawilum extends Container }; $container['pages'] = function ($c) { - return new Pages($c); + return new Pages($c); }; $container['themes'] = function ($c) { diff --git a/rawilum/Themes.php b/rawilum/Themes.php index 294e910b..af54d2df 100644 --- a/rawilum/Themes.php +++ b/rawilum/Themes.php @@ -46,5 +46,4 @@ class Themes throw new RuntimeException("Template {$template_name} does not exist."); } } - }