Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added theme.php view config for themes

  • Loading branch information...
commit 9a6efed4751750e00dbc350783d1ba61679e2eef 1 parent ba99f6f
tquensen authored
13 app/frontend/settings/theme.php
View
@@ -0,0 +1,13 @@
+<?php
+//this file is loaded only if a theme is used, and can be used to overwrite a themes view settings
+//this file has only access to $MiniMVC_view['css'], $MiniMVC_view['js'] and $MiniMVC_view['navi']
+//$theme holds the name of the current theme
+
+/*
+if ($theme === 'example') {
+ //unset the themes css
+ unset($MiniMVC_view['css']['theme.example.base']);
+ //add additional css for this theme
+ $MiniMVC_view['css']['theme.example.fixes'] = array('file' => 'example.fixes.css');
+}
+*/
18 lib/MiniMVC/MiniMVC/Helper/Css.php
View
@@ -95,7 +95,23 @@ public function prepareFiles()
return array_merge($cache, $this->additionalFiles);
}
- $files = $this->registry->settings->get('view/css', array());
+ if ($theme) {
+ $MiniMVC_view = $this->registry->settings->get('view', array());
+ $currentApp = $this->registry->settings->get('currentApp');
+ if (file_exists(THEMEPATH.$theme.'/theme.php')) {
+ include THEMEPATH.$theme.'/theme.php';
+ }
+ if (file_exists(DATAPATH.'settings/theme.php')) {
+ include DATAPATH.'settings/theme.php';
+ }
+ if ($currentApp && file_exists(APPPATH.$currentApp.'settings/theme.php')) {
+ include APPPATH.$currentApp.'settings/theme.php';
+ }
+ $files = isset($MiniMVC_view['css']) ? $MiniMVC_view['css'] : array();
+ } else {
+ $files = $this->registry->settings->get('view/css', array());
+ }
+
$preparedFiles = array();
foreach ($files as $file) {
$data = array();
25 lib/MiniMVC/MiniMVC/Helper/Js.php
View
@@ -158,11 +158,28 @@ public function addVar($key, $value, $literal = false)
public function prepareFiles()
{
- if (null !== ($cache = $this->registry->cache->get('jsCached'))) {
+ $theme = $this->registry->layout->getTheme();
+ if (null !== ($cache = $this->registry->cache->get('jsCached_'.$theme))) {
return $cache;
}
- $theme = $this->registry->layout->getTheme();
- $files = $this->registry->settings->get('view/js', array());
+
+ if ($theme) {
+ $MiniMVC_view = $this->registry->settings->get('view', array());
+ $currentApp = $this->registry->settings->get('currentApp');
+ if (file_exists(THEMEPATH.$theme.'/theme.php')) {
+ include THEMEPATH.$theme.'/theme.php';
+ }
+ if (file_exists(DATAPATH.'settings/theme.php')) {
+ include DATAPATH.'settings/theme.php';
+ }
+ if ($currentApp && file_exists(APPPATH.$currentApp.'settings/theme.php')) {
+ include APPPATH.$currentApp.'settings/theme.php';
+ }
+ $files = isset($MiniMVC_view['js']) ? $MiniMVC_view['js'] : array();
+ } else {
+ $files = $this->registry->settings->get('view/js', array());
+ }
+
$preparedFiles = array();
foreach ($files as $file) {
$data = array();
@@ -207,7 +224,7 @@ public function prepareFiles()
}
$combinedFiles = $this->combineFiles($preparedFiles);
- $this->registry->cache->set('jsCached', $combinedFiles);
+ $this->registry->cache->set('jsCached_'.$theme, $combinedFiles);
return $combinedFiles;
}
22 lib/MiniMVC/MiniMVC/Helper/Navi.php
View
@@ -31,14 +31,32 @@ public function getHtml($navi, $module = null, $partial = 'navi')
public function get($navi)
{
if (!isset($this->navis[$navi])) {
- $naviData = $this->buildNavi($this->registry->settings->get('view/navi/' . $navi, array()));
+ $naviData = $this->buildNavi($navi);
$this->navis[$navi] = $naviData[0];
}
return $this->navis[$navi];
}
- protected function buildNavi($navi)
+ protected function buildNavi($name)
{
+ $theme = $this->registry->layout->getTheme();
+ if ($theme) {
+ $MiniMVC_view = $this->registry->settings->get('view', array());
+ $currentApp = $this->registry->settings->get('currentApp');
+ if (file_exists(THEMEPATH.$theme.'/theme.php')) {
+ include THEMEPATH.$theme.'/theme.php';
+ }
+ if (file_exists(DATAPATH.'settings/theme.php')) {
+ include DATAPATH.'settings/theme.php';
+ }
+ if ($currentApp && file_exists(APPPATH.$currentApp.'settings/theme.php')) {
+ include APPPATH.$currentApp.'settings/theme.php';
+ }
+ $navi = isset($MiniMVC_view['navi'][$name]) ? $MiniMVC_view['navi'][$name] : array();
+ } else {
+ $navi = $this->registry->settings->get('view/navi/' . $name, array());
+ }
+
$return = array();
$active = false;
foreach ($navi as $entry) {
1  module/Dev/controller/Generate.php
View
@@ -119,6 +119,7 @@ public function appAction($params)
file_put_contents($path . '/settings/config.php', str_replace('APP', $params['app'], file_get_contents($dummy . '/config_app.php')));
file_put_contents($path . '/settings/routes.php', str_replace('APP', $params['app'], file_get_contents($dummy . '/routes_app.php')));
file_put_contents($path . '/settings/widgets.php', str_replace('APP', $params['app'], file_get_contents($dummy . '/widgets_app.php')));
+ file_put_contents($path . '/settings/theme.php', str_replace('APP', $params['app'], file_get_contents($dummy . '/theme.php')));
if ($params['w']) {
file_put_contents(WEBPATH . $params['app'] . '.php', str_replace('APP', $params['app'], file_get_contents($dummy . '/app_web.php')));
13 module/Dev/dummies/theme.php
View
@@ -0,0 +1,13 @@
+<?php
+//this file is loaded only if a theme is used, and can be used to overwrite a themes view settings
+//this file has only access to $MiniMVC_view['css'], $MiniMVC_view['js'] and $MiniMVC_view['navi']
+//$theme holds the name of the current theme
+
+/*
+if ($theme === 'example') {
+ //unset the themes css
+ unset($MiniMVC_view['css']['theme.example.base']);
+ //add additional css for this theme
+ $MiniMVC_view['css']['theme.example.fixes'] = array('file' => 'example.fixes.css');
+}
+*/
4 module/My/controller/Default.php
View
@@ -5,10 +5,10 @@ class My_Default_Controller extends MiniMVC_Controller
public function indexAction($params)
{
$this->view->setFile('static/home');
- if ('homeTitle' !== ($title = $this->view->t->get('homeTtitle'))) {
+ if ('homeTitle' !== ($title = $this->view->t->get('homeTitle'))) {
$this->registry->helper->meta->setTitle($title);
}
- if ('homeDescription' !==($description = $this->view->t->get('homeDescription'))) {
+ if ('homeDescription' !== ($description = $this->view->t->get('homeDescription'))) {
$this->registry->helper->meta->setDescription($description);
}
}
48 theme/example/theme.php
View
@@ -0,0 +1,48 @@
+<?php
+//overwrites the view config (only $MiniMVC_view['css'], $MiniMVC_view['js'] and $MiniMVC_view['navi'])
+
+//add css files (default media type is "screen")
+$MiniMVC_view['css']['theme.example.base'] = array('file' => 'base.css');
+
+//unset the apps / modules default css files
+//unset($MiniMVC_view['css']['my.screen'])
+
+//define navigation menu(s)
+/*
+$MiniMVC_view['navi']['main'] = array(
+ array(
+ 'title' => 'Home',
+ 'route' => $this->get('config/defaultRoute')
+ ),
+ array(
+ 'title' => array('naviAbout'), //set an array as title for i18n array(i18nString) or array(i18nString, Module)
+ 'route' => 'my.about',
+ 'submenu' => array(
+ array('route' => 'my.about.subpage1'), //submenuitems without title won't be shown, but
+ array('route' => 'my.about.subpage2') //the parent menu item will be marked as active if one of this routes is active
+ )
+ ),
+ array( //real world example
+ 'title' => array('NaviTitle', 'News'),
+ 'route' => 'news.defaultIndex',
+ 'submenu' => array( //"invisible" submenu items to make this menu item also active on single/edit/create pages
+ array('route' => 'news.defaultShow'),
+ array('route' => 'news.defaultCreate'),
+ array('route' => 'news.defaultEdit')
+ )
+ ),
+ array(
+ 'title' => 'Example Menu', //route or url is not required
+ 'submenu' => array(
+ array(
+ 'title' => 'Google.com',
+ 'url' => 'http://www.google.com'
+ ),
+ array(
+ 'title' => 'Example #2',
+ 'url' => 'http://www.example.com'
+ )
+ )
+ )
+);
+*/
Please sign in to comment.
Something went wrong with that request. Please try again.