themes folder outside app dir. images handled by themes-asset controller.

This commit is contained in:
Claude 2013-03-24 19:38:49 +01:00
parent 4bb5296791
commit 79328da9a8
44 changed files with 32 additions and 11 deletions

View File

@ -0,0 +1 @@
Deny from all

View File

@ -64,7 +64,8 @@ $route['iphone/view/:any'] = 'iphone/view';
$route['404_override'] = 'main/error_404';
$route['application/themes/:any'] = 'theme_assets/css';
$route['themes/:any/css/:any'] = 'theme_assets/css';
$route['themes/:any/images/:any'] = 'theme_assets/images';
/* End of file routes.php */
/* Location: ./application/config/routes.php */

View File

@ -4,6 +4,7 @@
* Function list:
* - __construct()
* - css()
* - images()
* Classes list:
* - Theme_assets extends CI_Controller
*/
@ -19,22 +20,40 @@ class Theme_assets extends CI_Controller
function css()
{
$theme = config_item('theme');
$css_file = $this->uri->segment(5);
$css_file = str_replace('.css', '', $css_file);
$css_file = $this->uri->segment(4);
//file path
$file_path = 'application/themes/' . $theme . '/css/' . $css_file . '.css';
$file_path = 'themes/' . $theme . '/css/' . $css_file;
//fallback to default css if view in theme not found
if (!file_exists($file_path))
{
$file_path = 'application/themes/default/css/' . $css_file . '.css';
$file_path = 'themes/default/css/' . $css_file;
}
//get and send
$contents = file_get_contents($file_path);
//send
header('Content-type: text/css');
echo $contents;
readfile($file_path);
}
function images()
{
$theme = config_item('theme');
$image_file = $this->uri->segment(4);
//file path
$file_path = 'themes/' . $theme . '/images/' . $image_file;
//fallback to default css if view in theme not found
if (!file_exists($file_path))
{
$file_path = 'themes/default/images/' . $image_file;
}
//send
header('Content-type: ' . mime_content_type($file_path));
readfile($file_path);
}
}

View File

@ -30,14 +30,14 @@ class MY_Loader extends CI_Loader
//fallback to default view if view in theme not found
if (!file_exists('application/' . $view_path))
if (!file_exists($view_path))
{
$view_path = 'themes/default/views/' . $view . '.php';
}
//return
return $this->_ci_load(array(
'_ci_view' => '../' . $view_path,
'_ci_view' => '../../' . $view_path,
'_ci_vars' => $this->_ci_object_to_array($vars) ,
'_ci_return' => $return
));

View File

Before

Width:  |  Height:  |  Size: 207 B

After

Width:  |  Height:  |  Size: 207 B

View File

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 282 B

View File

@ -19,7 +19,7 @@ $theme = $this->config->item('theme');
//Carabiner
$this->carabiner->config(array(
'script_dir' => 'static/js/',
'style_dir' => 'application/themes/' . $theme . '/css/',
'style_dir' => 'themes/' . $theme . '/css/',
'cache_dir' => 'static/asset/',
'base_uri' => base_url(),
'combine' => true,