Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix up broken things
  • Loading branch information
goFrendiAsgard committed Mar 29, 2016
1 parent 83a462a commit 09fe0e6
Show file tree
Hide file tree
Showing 224 changed files with 191 additions and 180 deletions.
27 changes: 13 additions & 14 deletions application/core/CMS_Controller.php
Expand Up @@ -125,12 +125,6 @@ public function __construct()
}
}


if(!$this->input->is_ajax_request() && strtoupper(trim($this->cms_get_config('site_show_benchmark'))) == 'TRUE'){
$this->output->enable_profiler(TRUE);
}else{
$this->output->enable_profiler(FALSE);
}
}

public function __call($method, $args){
Expand Down Expand Up @@ -589,13 +583,6 @@ protected function view($view_url, $data = null, $navigation_name = null, $confi
$result = null;
$view_url = $this->cms_parse_keyword($view_url);

// Profiler
if(!$this->input->is_ajax_request() && strtoupper(trim($this->cms_get_config('site_show_benchmark'))) == 'TRUE'){
$this->output->enable_profiler(TRUE);
}else{
$this->output->enable_profiler(FALSE);
}

/*
* PREPARE PARAMETERS *********************************************************************************************
*/
Expand Down Expand Up @@ -965,7 +952,17 @@ protected function view($view_url, $data = null, $navigation_name = null, $confi
if ($return_as_string) {
return $result;
} else {
$this->cms_show_html($result);

// Profiler
if(!$this->input->is_ajax_request() && strtoupper(trim($this->cms_get_config('site_show_benchmark'))) == 'TRUE'){
$this->output->enable_profiler(TRUE);
}else{
$this->output->enable_profiler(FALSE);
}

echo $result;
// load view introduce rendering problem if profiler activated, thus I use echo for now
//$this->cms_show_html($result);
}
}

Expand Down Expand Up @@ -1006,6 +1003,8 @@ private function __cms_parse_widget_theme_path($html, $theme, $layout, $navigati
if (strpos($html, '{{ ') !== false && $recursive_level > 0) {
$html = $this->__cms_parse_widget_theme_path($html, $theme, $layout, $navigation_name, $recursive_level);
}

$html = $this->{$this->__cms_base_model_name}->cms_unescape_template($html);
}

return $html;
Expand Down
2 changes: 2 additions & 0 deletions application/core/CMS_Model.php
Expand Up @@ -3520,6 +3520,8 @@ public function cms_parse_keyword($value)
), $value);
}

$value = $this->cms_unescape_template($value);

return $value;
}

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions doc/tutorial.md
Expand Up @@ -18,6 +18,7 @@ For mere users and everyone
* [Installation](tutorial/user_installation.md)
* [Update & Migration](tutorial/user_update_and_migration.md)
* [Themes](tutorial/user_themes.md)
* [Layouts](tutorial/user_layout.md)
* [Setting](tutorial/user_setting.md)
* [User & Groups](tutorial/user_user_and_group.md)
* [Navigation & Pages](tutorial/user_navigation.md)
Expand Down
104 changes: 27 additions & 77 deletions doc/tutorial/designer_themes.md
Expand Up @@ -4,93 +4,43 @@ Themes
======
You can change No-CMS theme by accessing `Complete Menu | CMS Management | Change Theme` or `CMS Management | Change Theme`.

To set per-page theme, you can access `Complete Menu | Page Management` and set `Default Theme`
To set per-page theme, you can access `Complete Menu | Navigation Management` and set `Default Theme`

Themes are located at `/themes/` folder. With such a structure:
Themes are located at `/themes/` folder. With this structure:
```
/themes
|--- [your_theme]
|--- /assets
| |--- /default (consists of js, css, images etc)
| |--- /[other_layout] (optional)
|--- /assets (Contains your css, js, fonts, and other static files)
|
|--- /views
|--- /layouts
| |--- default.php (here is the main UI script)
| |--- [other_layout].php (optional)
|
|--- /partials
|--- /default
|--- /other_layout
```
In your `default.php`, you can several variables:

* `$template['body']` : This variable contains your page content.
* `$template['title']` : This variable contains your page title
* `$template['metadata']` : This variable contains everything including JQuery, meta keyword, and language information
* `$template['partials']['header']` : Including `/views/partials/default/header.php`.
| |--- css.php (how the css used in your theme)
| |
| |--- js.php (how the js used in your theme)
|
|--- description.txt (theme's description)
|
|--- preview.png
You can also use several tags such as:
* `{{ site_logo }}` : Your logo path
* `{{ site_slogan }}` : Slogan
* `{{ site_footer }}` : Your footer
* `{{ widget_name:top_navigation }}` : A widget contains bootstrap styled top navigation
* `{{ widget_name:left_navigation }}` : A widget contains bootstrap styled top navigation
* And many others, see [designer tag's guide](designer_tags.md) for more information
css.php
=======
Example of css.php:
Here is a very simple example of `default.php`:
```php
<!DOCTYPE html>
<html>
<head>
<title><?php echo $template['title']; ?></title>
<?php echo $template['metadata']; ?>
</head>
<body>
<h1><img src=”{{ site_logo }}” /><?php echo $template['title']; ?></h1>
<div class="nav-collapse in collapse" id="main-menu" style="height: auto; ">
{{ widget_name:top_navigation }}
</div>
<?php echo $template['body']; ?>
</body>
<footer>{{ site_footer }}</footer>
</html>
<?php
$asset = new Cms_asset();
$asset->add_themes_css('css/bootstrap.min.css', '{{ used_theme }}');
$asset->add_themes_css('css/style.css', '{{ used_theme }}');
echo $asset->compile_css();
```

Partials
========
For modularity sake, you might want to separate your layout into several part (e.g: header, footer, etc). Phil Sturgeon's template library (which is used in No-CMS) already support this. You can make as many partials as you need, and access it by using `$template['partials']['your_partial_name']` variable. Partial files should be located at /themes/your_theme_name/views/partials/default/. The previous example layout can be separated into several partials:

Content of `/themes/your_theme_name/views/layouts/default.php`:

```html
<!DOCTYPE html>
<html>
<head>
<title><?php echo $template['title']; ?></title>
<?php echo $template['metadata']; ?>
</head>
<body>
<?php echo $template['partials']['header']; ?>
<?php echo $template['body']; ?>
<?php echo $template['partials']['footer']; ?>
</body>
</html>
```
js.php
=======
Example of js.php:

Content of `/themes/your_theme_name/views/partials/default/header.php`:

```html
<h1><img src=”{{ site_logo }}” /><?php echo $template['title']; ?></h1>
<div class="nav-collapse in collapse" id="main-menu" style="height: auto; ">
{{ navigation_top_quicklink }}
</div>
```

Content of `/themes/your_theme_name/views/partials/default/footer.php`:

```html
<footer>{{ site_footer }}</footer>
```php
<?php
$asset = new Cms_asset();
$asset->add_cms_js('bootstrap/js/bootstrap.min.js');
$asset->add_themes_js('js/script.js', '{{ used_theme }}');
echo $asset->compile_js();
```

__PS:__ The above example is a very minimalistic example to explain the concept. Please take a look at `/themes` folder to see the real `themes` example.
90 changes: 90 additions & 0 deletions doc/tutorial/user_layout.md
@@ -0,0 +1,90 @@
Layouts
=======

You can manage your layouts by accessing `CMS Management | Layout Management`. Layout define how your pages looked. To modify a layout you need to know some basic HTML.

There are some special tags you can use in layouts:
* `{{ layout:title }}` This tag will be rendered and replaced by page title
* `{{ layout:metadata }}` This tag will be rendered and replaced by default metadata
* `{{ layout:js }}` This tag will be rendered and replaced by No-CMS and theme's predefined javascript (See `js.php` in your `themes/your-theme/views`)
* `{{ layout:css }}` This tag will be rendered and replaced by No-CMS and theme's predefined css (See `css.php` in your `themes/your-theme/views`)
* `{{ layout:body }}` This tag will be rendered and replaced by current page's content. You should ensure your layout contains this tag.

Example
=======

Here is the default layout provided by No-CMS:

```html
<!DOCTYPE html>
<html lang="{{ language:language_alias }}">
<head>
<meta charset="utf-8">
<title>{{ layout:title }}</title>
{{ layout:metadata }}
<link rel="icon" href="{{ site_favicon }}">
<!-- Le styles -->
{{ layout:css }}
<style type="text/css">{{ widget_name:section_custom_style }}</style>
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="{{ site_favicon }}">
</head>
<body>
{{ layout:js }}
<script type="text/javascript">{{ widget_name:section_custom_script }}</script>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="{{ BASE_URL }}assets/no_cms/js/html5.js"></script>
<script src="{{ BASE_URL }}assets/no_cms/js/respond.min.js"></script>
<![endif]-->

{{ widget_name:section_top_fix }}
<div class="container">
<div class="row-fluid">
<div id="__section-banner">{{ widget_name:section_banner }}</div>
<div>
<div id="__section-left-and-content" class="col-md-9">
<div>{{ navigation_path }}</div><hr />
<div>
<div id="__section-left" class="hidden">
{{ widget_name:section_left }}
</div>
<div id="__section-content" class="col-md-12">
{{ layout:body }}
</div>
</div>
</div><!--/#layout-content-->
<div id="__section-right" class="col-md-3">
{{ widget_name:section_right }}
</div><!--/#layout-widget-->
</div>
</div><!--/row-->
<hr>
</div><!--/.fluid-container-->
<footer>{{ widget_name:section_bottom }}</footer>
<script type="text/javascript">
$(document).ready(function(){
// if section-left is empty, remove it
if($.trim($('#__section-left').html()) == ''){
$('#__section-left').remove();
}else{
$('#__section-content').removeClass('col-md-12');
$('#__section-content').addClass('col-md-9');
$('#__section-left').removeClass('hidden');
$('#__section-left').addClass('col-md-3');
}
// if section-right is empty, remove it
if($.trim($('#__section-right').html()) == ''){
$('#__section-right').remove();
$('#__section-left-and-content').removeClass('col-md-9');
$('#__section-left-and-content').addClass('col-md-12');
}
// if section-banner is empty, remove it
if($.trim($('__section-banner').html()) == ''){
$('__section-banner').remove();
}
});
</script>
</body>
</html>
```
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion modules/main/controllers/Manage_user.php
Expand Up @@ -280,7 +280,7 @@ public function _callback_field_group_user($value, $primary_key){
$value = array();
}
$query = $this->db->select('group_id, group_name')
->from($this->cms_user_table_name())
->from($this->t('main_group'))
->limit(20)
->get();
$html = '<select id="field-group_user" name="group_user[]" multiple="multiple" size="8" class="form-control" data-placeholder="Select users">';
Expand Down
11 changes: 1 addition & 10 deletions modules/main/views/main_change_theme.php
@@ -1,14 +1,5 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>
<style>
li.change-theme-container>a{
width: 100%;
height: 100%;
display: block;
}
li.change-theme-container img{
max-width: 128px;
height: auto;
}
#message:empty{
display:none;
}
Expand All @@ -34,7 +25,7 @@
}
$image_path = base_url('themes/'.$theme['path'].'/preview.png');
if(@file_get_contents($image_path,0,NULL,0,1)){
echo '<img style="border:1px solid" src="'.$image_path.'" />';
echo '<img class="col-md-12" src="'.$image_path.'" />';
}else{
echo '{{ language:No Preview }}';
}
Expand Down
50 changes: 12 additions & 38 deletions modules/teldrassil/controllers/Teldrassil.php
Expand Up @@ -104,14 +104,11 @@ public function index(){
$this->directory_copy(FCPATH.'modules/'.$module_path.'/assets/theme_template', FCPATH.'themes/'.$theme_name);
// copy images
$preview_name = FCPATH.'themes/'.$theme_name.'/preview.png';
$background_name = FCPATH.'themes/'.$theme_name.'/assets/default/images/background.png';
copy($file_name, $preview_name);
copy($file_name, $background_name);
$this->load->library('image_moo');
$this->image_moo->load($background_name)->save($background_name, TRUE);
$this->image_moo->load($preview_name)->resize(769,395, TRUE)->save($preview_name, TRUE);
file_put_contents(FCPATH.'themes/'.$theme_name.'/assets/css/bootstrap.min.css',
$this->get_css($font, $colors,'images/background.png'));
$this->get_css($font, $colors));
// create subsite_auth
$subsite_auth = '<?php defined(\'BASEPATH\') OR exit(\'No direct script access allowed\');'.PHP_EOL.
'// GENERATED AUTOMATICALLY, DO NOT EDIT THIS FILE !!!'.PHP_EOL.
Expand Down Expand Up @@ -183,51 +180,28 @@ private function directory_copy($srcdir, $dstdir){

}

private function get_css($font, $colors, $background_image = NULL){
private function get_css($font, $colors){
$module_path = $this->cms_module_path();
if($background_image !== NULL){
$background_image = '#__background-image{'.PHP_EOL.
' background-image: url(\''.$background_image.'\');'.PHP_EOL.
' background-size:cover;'.PHP_EOL.
' filter: blur(10px);'.PHP_EOL.
' -webkit-filter: blur(10px);'.PHP_EOL.
' z-index: -99999;'.PHP_EOL.
' width: 100%;'.PHP_EOL.
' height: 100%;'.PHP_EOL.
' position: fixed;'.PHP_EOL.
' top: 0px;'.PHP_EOL.
'}';
$background_color = '#__background-color{'.PHP_EOL.
' background-color: #'.$colors[0].';'.PHP_EOL.
' opacity: 0.6;'.PHP_EOL.
' z-index: -99998;'.PHP_EOL.
' width: 100%;'.PHP_EOL.
' height: 100%;'.PHP_EOL.
' position: fixed;'.PHP_EOL.
' top:0px;'.PHP_EOL.
'}';
}else{
$background_color = '#__background-color{'.PHP_EOL.
' background-color: #'.$colors[0].';'.PHP_EOL.
' z-index: -99998;'.PHP_EOL.
' width: 100%;'.PHP_EOL.
' height: 100%;'.PHP_EOL.
' position: fixed;'.PHP_EOL.
' top:0px;'.PHP_EOL.
'}';
}
$background_color = '#__background-color{'.PHP_EOL.
' background-color: #'.$colors[0].';'.PHP_EOL.
' z-index: -99998;'.PHP_EOL.
' width: 100%;'.PHP_EOL.
' height: 100%;'.PHP_EOL.
' position: fixed;'.PHP_EOL.
' top:0px;'.PHP_EOL.
'}';

$css = file_get_contents(FCPATH.'modules/'.$module_path.'/assets/theme_template.css');
$css = str_replace(
array(
'{{ FONT }}', '{{ COLOR_1 }}', '{{ COLOR_2 }}', '{{ COLOR_3 }}',
'{{ COLOR_4 }}', '{{ COLOR_5 }}', '{{ COLOR_6 }}', '{{ COLOR_7 }}', '{{ FONT+ }}',
'{{ BACKGROUND_IMAGE }}', '{{ BACKGROUND_COLOR }}'
'{{ BACKGROUND_COLOR }}'
),
array(
$font, '#'.$colors[0], '#'.$colors[1], '#'.$colors[2], '#'.$colors[3],
'#'.$colors[4], '#'.$colors[5], '#'.$colors[6], implode('+', explode(' ', $font)),
$background_image, $background_color,
$background_color,
),
$css
);
Expand Down

0 comments on commit 09fe0e6

Please sign in to comment.