From e2cb2caa97b8162d7726ae9e53a03b511b11aba3 Mon Sep 17 00:00:00 2001 From: PiTiLeZarD Date: Wed, 19 Mar 2008 18:34:28 +0100 Subject: [PATCH] remove registry, css linked to layout, rewrites ok for resources, test controller and href fixes --- kernel.php | 5 ++-- lib/pimp/Href.php | 55 +++++++++++++++++++------------------ resources/apache/rewrites.conf | 2 +- resources/css/layouts/default.css | 3 ++ resources/css/pages/firsttime.css | 0 resources/css/typography.css | 1 - site/controllers/TestController.php | 12 ++++++++ site/views/Helpers/Csspack.php | 13 ++++++++- 8 files changed, 58 insertions(+), 33 deletions(-) rewrite lib/pimp/Href.php (66%) create mode 100644 resources/css/layouts/default.css create mode 100644 resources/css/pages/firsttime.css create mode 100644 site/controllers/TestController.php diff --git a/kernel.php b/kernel.php index a0ac331..97ff393 100644 --- a/kernel.php +++ b/kernel.php @@ -65,7 +65,7 @@ class Kernel { } # register infos in the view - Zend_Registry::get('view')->infos = $this->infos; + Zend_Layout::getMvcInstance()->getView()->infos = $this->infos; } private function initDomain() { @@ -77,7 +77,7 @@ class Kernel { $url = '/'; $this->locale = new Zend_Locale(Zend_Locale::BROWSER); - $defaultDomain = $this->locale->toString(); + $defaultDomain = $this->locale->getLanguage(); if (empty($this->VARS['controller']) || (false === strstr($_SERVER['REQUEST_URI'], $this->VARS['controller']))) { $url = $_SERVER['REQUEST_URI'] . $defaultDomain . '/'; @@ -143,7 +143,6 @@ class Kernel { $view->setEncoding('UTF-8'); $view->setScriptPath('./site/views/Pages/'); $view->setHelperPath('./site/views/Helpers/'); - Zend_Registry::set('view', $view); # modify the viewRenderer default behaviour $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); diff --git a/lib/pimp/Href.php b/lib/pimp/Href.php dissimilarity index 66% index 8d7ac90..c9c2858 100644 --- a/lib/pimp/Href.php +++ b/lib/pimp/Href.php @@ -1,27 +1,28 @@ -infos['httphost'] . substr($url, 1, strlen($url)); - } - - if (($url[0] == '/') || ($url[0] == ':')) { - $url = $K->infos['httphosti18n'] . substr($url, 1, strlen($url)); - } - - if (strpos($url, "http")!==0) { - $url = $K->infos['httphosti18n'] . $url; - } - - $u = Zend_Uri::factory($url); - - return $u->getUri(); - } - -} - -?> \ No newline at end of file +infos['httphost'] . $murl; + break; + case ($url[0] == '/') || ($url[0] == ':'): + $url = $K->infos['httphosti18n'] . $murl; + break; + } + + if (strpos($url, "http") !== 0) { + $url = $K->infos['httphosti18n'] . $url; + } + + return Zend_Uri::factory($url)->getUri(); + } + +} + +?> \ No newline at end of file diff --git a/resources/apache/rewrites.conf b/resources/apache/rewrites.conf index fec1937..bdf303f 100644 --- a/resources/apache/rewrites.conf +++ b/resources/apache/rewrites.conf @@ -4,7 +4,7 @@ RewriteLog /Users/PiTiLeZarD/Workspaces/www/pimpmyv/resources/apache/rewrite.log RewriteLogLevel 0 # no redirect for these -RewriteRule ^/?(resources)(/?.*)$ $1$2 [L,QSA] +RewriteRule ^/?(resources)(/?.*)$ /$1$2 [L,QSA] # robots.txt RewriteRule ^/?robots.txt$ /resources/robots.txt [L] diff --git a/resources/css/layouts/default.css b/resources/css/layouts/default.css new file mode 100644 index 0000000..9cf39c2 --- /dev/null +++ b/resources/css/layouts/default.css @@ -0,0 +1,3 @@ +html, body { + background:lightgrey; +} \ No newline at end of file diff --git a/resources/css/pages/firsttime.css b/resources/css/pages/firsttime.css new file mode 100644 index 0000000..e69de29 diff --git a/resources/css/typography.css b/resources/css/typography.css index bf67b66..e69de29 100644 --- a/resources/css/typography.css +++ b/resources/css/typography.css @@ -1 +0,0 @@ -@CHARSET "UTF-8"; \ No newline at end of file diff --git a/site/controllers/TestController.php b/site/controllers/TestController.php new file mode 100644 index 0000000..ccace3f --- /dev/null +++ b/site/controllers/TestController.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/site/views/Helpers/Csspack.php b/site/views/Helpers/Csspack.php index d189e87..77d3127 100644 --- a/site/views/Helpers/Csspack.php +++ b/site/views/Helpers/Csspack.php @@ -12,13 +12,24 @@ class Zend_View_Helper_Csspack { 'resources' => array('css/typography.css') ) ); + + $layout = Zend_Layout::getMvcInstance()->getLayout(); + $layout = 'css/layouts/' . $layout . '.css'; + if (!is_file('resources/' . $layout)) { + $layout = null; + } if (!in_array($name, array_keys($packs))) return ''; + if ($layout) { + # todo array_prepend + $packs[$name]['resources'][] = $layout; + } + $baseUrl = Zend_Controller_Front::getInstance()->getRequest()->getBaseUrl(); $ret = ''; foreach ($packs[$name]['resources'] as $resource) { - $ret .= ''; + $ret .= ''; } return $ret; } -- 2.11.4.GIT