diff --git a/application/config/constants.php b/application/config/constants.php
index ca94609a4..07121ffc7 100644
--- a/application/config/constants.php
+++ b/application/config/constants.php
@@ -93,7 +93,7 @@
// Bonfire-specific Constants
// -----------------------------------------------------------------------------
-define('BONFIRE_VERSION', 'v0.7.3');
+define('BONFIRE_VERSION', 'v0.7.4');
// -----------------------------------------------------------------------------
// The 'App Area' allows you to specify the base folder used for all of the contexts
diff --git a/application/hooks/App_hooks.php b/application/hooks/App_hooks.php
index a4430f995..3158ed08a 100644
--- a/application/hooks/App_hooks.php
+++ b/application/hooks/App_hooks.php
@@ -133,7 +133,8 @@ public function checkSiteStatus()
}
if (! $this->ci->auth->has_permission('Site.Signin.Offline')) {
- if (! in_array($this->ci->uri->ruri_string(), $this->allowOffline)) {
+ $ruriString = '/' . ltrim(str_replace($this->ci->router->directory, '', $this->ci->uri->ruri_string()), '/');
+ if (! in_array($ruriString, $this->allowOffline)) {
$offlineReason = $this->ci->settings_lib->item('site.offline_reason');
include (APPPATH . 'errors/offline.php');
die();
diff --git a/bonfire/core/BF_Router.php b/bonfire/core/BF_Router.php
index 1b5af5e68..937136d03 100644
--- a/bonfire/core/BF_Router.php
+++ b/bonfire/core/BF_Router.php
@@ -69,6 +69,20 @@ class BF_Router extends CI_Router
private $located = 0;
+ /**
+ * Class constructor runs the route mapping function in CI3.
+ *
+ * @param array $routing Optional configuration values.
+ *
+ * @return void
+ */
+ public function __construct($routing = null)
+ {
+ parent::__construct($routing);
+
+ log_message('info', 'BF_Router class initialized');
+ }
+
/**
* Get the name of the current module.
*
@@ -227,6 +241,28 @@ public function locate($segments)
$this->located = -1;
}
+ /**
+ * Set the default controller.
+ *
+ * NOTE: this method should be protected for use with CI3, but must be public
+ * for use with CI2.
+ *
+ * @return void
+ */
+ public function _set_default_controller()
+ {
+ if (empty($this->directory)) {
+ // Set the default controller module path.
+ $this->_set_module_path($this->default_controller);
+ }
+
+ parent::_set_default_controller();
+
+ if (empty($this->class)) {
+ $this->_set_404override_controller();
+ }
+ }
+
/**
* Set module path.
*
diff --git a/bonfire/docs/_toc.ini b/bonfire/docs/_toc.ini
index 04a8c6506..607227658 100644
--- a/bonfire/docs/_toc.ini
+++ b/bonfire/docs/_toc.ini
@@ -7,6 +7,8 @@ developer/tut_blog = Simple Blog Tutorial
developer/changelog = Change Log
[Upgrade Notes]
+developer/upgrade/074 = 0.7.3 to 0.7.4
+developer/upgrade/073 = 0.7.2 to 0.7.3
developer/upgrade/072 = 0.7.1 to 0.7.2
developer/upgrade/071 = 0.7.0 to 0.7.1
diff --git a/bonfire/docs/changelog.md b/bonfire/docs/changelog.md
index 85614df8a..6bc8cb17f 100644
--- a/bonfire/docs/changelog.md
+++ b/bonfire/docs/changelog.md
@@ -1,6 +1,22 @@
# Change Log
-## Under development
+## Released versions
+
+### 0.7.4
+
+#### New Features:
+
+#### Closes Issues:
+* #1119 Module Builder xss_clean error
+* #1116 Syntax error in the builder-built view (when adding a required input field), pt 2
+* #1115 Can't save settings, 'module' field not being sent to settings table
+* #1114 Differences in Routing between CI2 and CI3
+* #1113 Syntax error in the builder-built view (when adding a required input field)
+* #1112 Can't login to site when offline in CI3
+
+#### Additional Changes:
+
+#### Known Issues:
### 0.7.3
@@ -43,8 +59,6 @@
#### Known Issues:
-## Released versions
-
### 0.7.2
#### New Features:
diff --git a/bonfire/docs/layouts_and_views.md b/bonfire/docs/layouts_and_views.md
index 3ef7b6cce..145157e3e 100644
--- a/bonfire/docs/layouts_and_views.md
+++ b/bonfire/docs/layouts_and_views.md
@@ -2,25 +2,34 @@
## Overview: How the Pieces Fit Together
-This guide covers how Bonfire handles rendering views within your application. It presents the relationship between standard CodeIgniter views and how they fit into the overall Theme.
+This guide covers how Bonfire handles rendering views within your application.
+It presents the relationship between standard CodeIgniter views and how they fit into the overall Theme.
-In a straight CodeIgniter application you might be used to having a view for your header and a view for your footer. Then, in each view file, you would use `$this->load->view('header')` to keep a consistent layout across your site. This works well, and is one of the fastest options available to you. But it's not the most efficient or flexible from a developer's viewpoint.
+In a straight CodeIgniter application you might be used to having a view for your header and a view for your footer.
+Then, in each view file, you would use `$this->load->view('header')` to keep a consistent layout across your site.
+This works well, and is one of the fastest options available to you.
+But it's not the most efficient or flexible from a developer's viewpoint.
-Bonfire uses Themes, which you'll be accustomed to using in nearly any CMS out there. Each theme contains one or more layouts (one-column, two-column, blog, etc) as well as any assets (like CSS or Javascript files) that the theme might need. A single command in your controller is all that is needed to make this work.
+Bonfire uses Themes, which you'll be accustomed to using in nearly any CMS out there.
+Each theme contains one or more layouts (one-column, two-column, blog, etc) as well as any assets (like CSS or Javascript files) that the theme might need.
+A single command in your controller is all that is needed to make this work.
Views are exactly what you are accustomed to working with, but follow a simple convention that keeps things consistent among all of the developers on your team, and keeps things simple and organized.
-
## Views
-Views in Bonfire are the same views that are available within stock CodeIgniter. They are just organized to take advantage of conventions that make keeping which view belongs to which method much simpler and consistent across projects and between co-workers. Since most of the work that you will be doing will be focused within modules, all of the examples will use a `blog` module as an example. However, these same principles apply directly to the `application/views` folder itself.
+Views in Bonfire are the same views that are available within stock CodeIgniter.
+They are just organized to take advantage of conventions that make keeping which view belongs to which method much simpler and consistent across projects and between co-workers.
+Since most of the work that you will be doing will be focused within modules, all of the examples will use a `blog` module as an example.
+However, these same principles apply directly to the `application/views` folder itself.
### Using `render`
-Wherever you would have used CodeIgniter's `$this->load->view()` previously, you should use `Template::render()` instead. It displays a view, wrapped within your themed layout files, checks if it's an AJAX or mobile request, and handles it all without you having to do much. At its simplest, all you have to do to display a fully-themed page from within your controller is:
-
+Wherever you would have used CodeIgniter's `$this->load->view()` previously, you should use `Template::render()` instead.
+It displays a view, wrapped within your themed layout files, checks if it's an AJAX or mobile request, and handles it all without you having to do much.
+At its simplest, all you have to do to display a fully-themed page from within your controller is:
class Blog extends Front_Controller
{
@@ -34,51 +43,71 @@ Wherever you would have used CodeIgniter's `$this->load->view()` previously, you
### Rendering a Method's View
-Bonfire's template system favors certain conventions in order to keep your project organized and make your job easier. When you use the `render()` method it looks for a view with the same name as the active method.
-
-All public context views (those front-facing pages) will be found in your module's `/view` folder. All other contexts (content, settings, etc) should have a folder matching the context name, and the view would be inside of that folder.
+Bonfire's template system favors certain conventions in order to keep your project organized and make your job easier.
+When you use the `render()` method it looks for a view with the same name as the active method.
+All public context views (those front-facing pages) will be found in your module's `/view` folder.
+All other contexts (content, settings, etc) should have a folder matching the context name, and the view would be inside of that folder.
/**
* Public Context for Blog Module
- *
- * View would be found at:
- * module_name/
- * views/
- * index.php
*/
class Blog extends Front_Controller
{
+ /**
+ * View would be found at:
+ * /public/themes/{currentTheme}/blog/index.php
+ * OR
+ * /application/modules/blog/views/index.php
+ */
public function index()
{
Template::render();
}
- }
+ /**
+ * View would be found at:
+ * /public/themes/{currentTheme}/blog/test.php
+ * OR
+ * /application/modules/blog/views/test.php
+ */
+ public function test()
+ {
+ Template::render();
+ }
+ }
/**
- * Settings Context
- *
- * View would be found at:
- * module_name/
- * views/
- * settings/
- * index.php
+ * Settings Context for Blog Module
*/
class Settings extends Admin_Controller
{
+ /**
+ * View would be found at:
+ * /application/modules/blog/views/settings/index.php
+ */
public function index()
{
Template::render();
}
- }
+ /**
+ * View would be found at:
+ * /application/modules/blog/views/settings/test.php
+ */
+ public function test()
+ {
+ Template::render();
+ }
+ }
### Rendering an Arbitrary View
-Sometimes you will need to use a different view than what Bonfire defaults to, such as when you want to share a form between your `create` and `edit` methods. This can be handled by using the `set_view()` method of the Template library. The only parameter is the name of the view file to display. The view name is relative to the module's view folder.
-
+Sometimes you will need to use a different view than what Bonfire defaults to, such as when you want to share a form between your `create` and `edit` methods.
+This can be handled by using the `set_view()` method of the Template library.
+The only parameter is the name of the view file to display.
+The view name is relative to the module's view folder.
class Settings extends Admin_Controller
{
@@ -89,88 +118,147 @@ Sometimes you will need to use a different view than what Bonfire defaults to, s
}
}
-
### Rendering Theme Views
-Often you will want to display one of the files from your theme within one of your view files. This is most often done within one of your layouts (see below) but can be done from within any view. You would accomplish this by using the `theme_view()` helper function. You don't need to load any helpers to make this happen, it is ready for you when your Template library is loaded.
-
-The first parameter is the name of the view to display. This view is relative to your active theme's folder.
+Often you will want to display one of the files from your theme within one of your view files.
+This is most often done within one of your layouts (see below) but can be done from within any view.
+You would accomplish this by using the `themeView()` method of the Template library or the `theme_view()` helper function.
+You don't need to load a helper file to make the helper function available, it is ready when the Template library is loaded.
+The helper function is just a short-cut to the Template method, so the parameters and return values are the same.
+The first parameter is the name of the view to display.
+This view is relative to your active theme's folder.
+Using the helper function:
echo theme_view('recent_posts');
+Using the Template method directly:
-The second parameter is an optional array of data to pass to the view. This functions exactly like the second parameter of CodeIgniter's `$this->load->view()` method. Many times this won't be necessary, as any view data that is already available should be usable by any theme views also.
+ echo Template::themeView('recent_posts');
+The second parameter is an optional array of data to pass to the view.
+This functions exactly like the second parameter of CodeIgniter's `$this->load->view()` method.
+Many times this won't be necessary, as any view data that is already available should be usable by any theme views also.
- echo theme_view('recent_posts', array('posts' => $posts));
-
-
-By default, this method will check to see if the user is viewing this from a mobile device (like a smartphone or tablet). If they are, then it will first look for a view that is prefixed with `mobile_`.
+ echo Template::themeView('recent_posts', array('posts' => $posts));
+By default, this method will check to see if the user is viewing this from a mobile device (like a smartphone or tablet).
+If they are, then it will first look for a view that is prefixed with `mobile_`.
/*
- * Would look for a file called: mobile_recent_posts
- * in the active theme folder.
+ * Would look for a file called: mobile_recent_posts in the active theme directory.
*/
- echo theme_view('recent_posts');
-
-
-If you want to ignore the mobile version (like when they have said they want to view the full site anyway) you may pass `true` in as the third parameter.
+ echo Template::themeView('recent_posts');
+To ignore the mobile version (for example, when a user has chosen to view the full site anyway) you may pass `true` in as the third parameter.
/*
- * Would look for a file called: recent_posts
- * in the active theme folder, even if they
- * were viewing on a mobile device.
+ * Would look for a file called: recent_posts in the active theme folder, and
+ * will not even check whether the user is viewing on a mobile device.
*/
- echo theme_view('recent_posts', null, true);
-
+ echo Template::themeView('recent_posts', null, true);
### Parsing Views
-Bonfire assumes that you are using PHP as your template language. However, you can still use CodeIgniter's built-in `parser` library to display your views instead of letting it parse straight PHP. This can be turned on and off with the Template library's `parse_views()` method.
+Bonfire assumes that you are using PHP as your template language.
+However, you can still use CodeIgniter's built-in `Parser` library to display your views instead of letting it parse straight PHP.
+This can be turned on and off with the Template library's `parse_views()` method.
Template::parse_views(true);
-
Once this command has been called, all views from this point on would use the parser.
## Themes
-Bonfire supports a very flexible theme engine that allows for common layouts to wrap around your views, as well as more complex parent/child relationships between themes. Themes can include their own assets (CSS, Javascript and images), as well as multiple layout files. They can also providing layout switching based on the controller that's currently being ran.
+Bonfire supports a very flexible theme engine that allows for common layouts to wrap around your views, as well as more complex parent/child relationships between themes.
+Themes can include their own assets (CSS, Javascript and images), as well as multiple layout files.
+They can also providing layout switching based on the controller that's currently being ran.
+
+
+### Parent and Child Themes
+
+Parent/Child themes make it simple to make small tweaks to a theme without actually modifying any of the original theme's files.
+Instead, you create a new theme and modify only the files that you need to change.
+If a file is not found in the active theme it will use the file from the default theme in its place.
+
+Parent/child themes are perfect to use when you have a module that requires its own theme, like a forum, but you want to give the users the ability to choose different themes.
+To create these new themes you would simply create new theme folders that only changed the layouts or assets that needed to change, while defaulting to the original theme for all other assets or layouts.
+
+There are two methods that you would use to setup a parent/child theme situation.
+
+#### set_theme($theme[, $default_theme = null])
+
+The first parameter should be the name of the active (or primary) theme to use.
+This is the one that will be looked into first when trying to display any themed files.
+The second parameter is the name of the default (or parent) theme that is used as a fallback when themed files are not found in the active theme.
+Unless otherwise specified, all themes will attempt to fall back on a theme named `default`.
+
+ Template::set_theme('my_theme', 'default');
+
+#### set_default_theme($theme)
+
+There may be situations where you need to only change the default theme that is used as a fallback and not change the active theme.
+You would use the `set_default_theme()` method to handle this.
+The only parameter is the name of the theme to use as the default.
+
+ Template::set_default_theme('my_other_theme');
+
+
+### Theme Paths
+
+By default, all of your application's themes are stored within `public/themes`.
+There may be times, though, when you need to have multiple locations to store your theme files.
+This might be handy when you ship a forums module and want to provide themes specifically for your forums in their own location.
+
+You can add a new path to look for themes with the `add_theme_path()` method.
+The only parameter is the path to your theme folder.
+This must be relative to your application's web root (`FCPATH`).
+
+ Template::add_theme_path('user_themes');
+
+If you only need that path there temporarily, you can provide a slight performance increase by removing the path when you're done with it.
+
+ Template::remove_theme_path('user_themes');
+
+If you want to permanently add that path to your application, you can set this in the `application.php` config file.
+
+ $config['template.theme_paths'] = array('user_themes', 'bonfire/themes');
-### Layouts
+## Layouts
-A layout is a view file that is contains common content that you want displayed on each page. This is commonly used to create consistent headers and footers across your site.
+A layout is a view file that is contains common content that you want displayed on each page.
+This is commonly used to create consistent headers and footers across your site.
You can also have layouts for two- and three-column (or more!) formats that are ready to be used within any controller in your site.
-### Default Layouts
+### Default Layout
-When you display a view using `Template::render()` Bonfire will use a layout called `index.php`. This is the base layout that is used across your site.
+When you display a view using `Template::render()` Bonfire will use a layout called `index.php`.
+This is the base layout that is used across your site.
- themes/
- my_theme/
- index.php
+ public/
+ themes/
+ my_theme/
+ index.php
-**AJAX Calls**
+#### AJAX Calls
When your page is displaying a view in response to an AJAX call Bonfire will ignore the current view that has been set and instead use the `ajax.php` layout. You can use this file to fire any common javascript after an AJAX response.
- themes/
- my_theme/
- ajax.php
+ public/
+ themes/
+ my_theme/
+ ajax.php
### Using Arbitrary Layouts
-If a page requires a different layout than the default ones, say to display a two-column layout, you can easily choose a different layout to use with the `render()` method.
+If a page requires a different layout than the default, say to display a two-column layout, you can easily choose a different layout to use with the `render()` method.
class Blog extends Front_Controller
{
@@ -180,31 +268,28 @@ If a page requires a different layout than the default ones, say to display a tw
}
}
-You can also set a layout to be used by an entire controller by directly tapping into the Template library's class variables.
+You can also set a layout to be used by an entire controller by directly tapping into the Template library's `setLayout()` method.
class Blog extends Front_Controller
{
public function __construct()
{
- Template::layout = 'two_column';
+ Template::setLayout('two_column');
}
}
-This is best used when you want this controller to use a layout that is shared with other controllers.
+This is best used when you want this controller to use a layout that is shared with other controllers, or to set a default layout for a controller.
### Controller-Based Layouts
If you have a controller that needs its own layout all you need to do is to create a new layout in your theme folder with the same name as your controller.
-
/**
* Uses the blog layout file at:
- * themes/
- * my_theme/
- * blog.php
+ * /public/themes/my_theme/blog.php
*/
class Blog extends Front_Controller
{
@@ -214,83 +299,51 @@ If you have a controller that needs its own layout all you need to do is to crea
}
}
-
-### Parent and Child Themes
-
-Parent/Child themes make it simple to make small tweaks to a theme without actually modifying any of the original theme's files. Instead, you create a new theme and modify only the files that you need to change. If a file is not found in the active theme it will use the file from the default theme in its place.
-
-Parent/child themes are perfect to use when you have a module that requires its own theme, like a forum, but you want to give the users the ability to choose different themes. To create these new themes you would simply create new theme folders that only changed the layouts or assets that needed to change, while defaulting to the original theme for all other assets or layouts.
-
-There are two methods that you would use to setup a parent/child theme situation.
-
-**set_theme()**
-
-The first parameter should be the name of the active (or primary) theme to use. This is the one that will be looked into first when trying to display any themed files. The second parameter is the name of the default (or parent) theme that is used as a fallback when themed files are not found in the active theme. Unless otherwise specified, all themes will attempt to fall back on a theme named `default`.
-
-
- Template::set_theme('my_theme', 'default');
-
-
-**set_default_theme()**
-
-There may be situations where you need to only change the default theme that is used as a fallback and not change the active theme. You would use the `set_default_theme()` method to handle this. The only parameter is the name of the theme to use as the default.
-
-
- Template::set_default_theme('my_other_theme');
-
-
### Understanding Template Content
In your theme's layout files, you can specify where the controller's views are set to display by using the `Template::content()` method.
-
-
## Blocks
-Blocks allow you to set aside room for content within your layouts. It can be used as a placeholder for content that varies across layouts, like a sidebar. On a two-column layout you can set aside an area for the sidebar content, but then define what content is used there in each controller or method, allowing each page to be customized without needing additional layouts.
-
+Blocks allow you to set aside room for content within your layouts and views.
+It can be used as a placeholder for content that varies across layouts, like a sidebar.
+On a two-column layout you can set aside an area for the sidebar content, but then define what content is used there in each controller or method, allowing each page to be customized without needing additional layouts.
Template::block('block_name', 'default_view');
-
-The first parameter is a name that the block can be referenced by when you set the view to use in your controller. The second optional parameter is the name of a view to use as a default, in case other content has not been set.
+The first parameter is a name that the block can be referenced by when you set the view to use in your controller.
+The second optional parameter is the name of a view to use as a default, in case other content has not been set.
If you need to pass a specific set of data to the block's view, you can pass an array of key/value pairs as the third parameter.
-
Template::block('block_name', 'default_view', $data);
-Sometimes you will want to keep all of the various files that can be used in this block within your theme. In this case, you can pass `true` as the fourth parameter. Instead of looking within your module's view folder, it will look within the theme folder.
-
+Sometimes you will want to keep all of the various files that can be used in this block within your theme.
+In this case, you can pass `true` as the fourth parameter.
+Instead of looking within your module's view folder, it will look within the theme folder.
Template::block('block_name', 'default_view', $data, true);
-
-To set a different view to use in that block, you would use the `Template::set_block()` method within your controller. The first parameter is the name of the block to set the content for. The second parameter is the name of the view file to use. By default, this will look within your module's view folder.
-
+To set a different view to use in that block, you would use the `Template::set_block()` method within your controller.
+The first parameter is the name of the block to set the content for.
+The second parameter is the name of the view file to use.
+By default, this will look within your module's view folder.
Template::set_block('sidebar', 'blog_sidebar');
-
-
-
-## Helper Functions
-
-The Template library contains several other, smaller, functions and methods that change the way you might be used to using standard CodeIgniter features, as well as some to aid with building out your navigation.
-
-### View Data
-
-Instead of using a $data array to pass content to your view, or using `$this->load->vars()`, you can use `Template::set()` to make the data usable within the view. This should follow the same format that you are used to using, namely being an array of key/value pairs.
+## View Data
+Instead of using a $data array to pass content to your view, or using `$this->load->vars()`, you can use `Template::set()` to make the data usable within the view.
+This should follow the same format that you are used to using, namely being an array of key/value pairs.
// Instead of...
$data = array(
@@ -302,10 +355,8 @@ Instead of using a $data array to pass content to your view, or using `$this->lo
Template::set('title', 'Page title');
Template::render();
-
In order to make the transition from a familiar CodeIgniter practice to Bonfire simpler, you can pass an array in as the only parameter.
-
$data = array(
'title' => 'Page title'
);
@@ -314,23 +365,25 @@ In order to make the transition from a familiar CodeIgniter practice to Bonfire
Within your views, you can access the variables with a name that matches the key of the array pairs.
-### Flash Messages
+## Flash Messages
-CodeIgniter's Session library provides flash messages that allow you to set short status messages in your views. This is commonly used for small notifications when your object saved successfully. The only limitation this has is that it only is available on a page reload, which can soon become costly due to the sheer number of server hits it creates.
-
-Bonfire provides a variation on this that is available both to the current page as well as the next page load. To use it you would call the `set_message()` method within your controllers. The first parameter is the text to be displayed. The second parameter is the class name that will be given to the output string.
+CodeIgniter's Session library provides flash messages that allow you to set short status messages in your views.
+This is commonly used for small notifications when your object saved successfully.
+The only limitation this has is that it only is available on a page reload, which can soon become costly due to the sheer number of server hits it creates.
+Bonfire provides a variation on this that is available both to the current page as well as the next page load.
+To use it you would call the `set_message()` method within your controllers.
+The first parameter is the text to be displayed.
+The second parameter is the class name that will be given to the output string.
Template::set_message('Your message displayed just fine.', 'success');
-
To display the message, use the `message()` method within your view.
+ echo Template::message();
- Template::message();
-
-The code is wrapped within HTML that you can define in the `application.php` config file. It defaults to a Bootstrap compatible alert message.
-
+The code is wrapped within HTML that you can define in the `application.php` config file.
+It defaults to a Bootstrap compatible alert message.
$config['template.message_template'] =<<
@@ -339,72 +392,54 @@ The code is wrapped within HTML that you can define in the `application.php` con
EOD;
-
-### Redirect
+## Redirect
-When you are using AJAX a lot in your application, you will find times when CodeIgniter's stock `redirect()` method will not work for you, since it redirects within the AJAX call. What happens when you want to completely break out of the AJAX call and do a complete page refresh? You can use `Template::redirect('some/other/page')` instead. This returns an empty file that simply has a Javascript redirect code inserted.
+When you are using AJAX a lot in your application, you will find times when CodeIgniter's stock `redirect()` method will not work for you, since it redirects within the AJAX call.
+What happens when you want to completely break out of the AJAX call and do a complete page refresh? You can use `Template::redirect('some/other/page')` instead.
+This returns an empty file that simply has a Javascript redirect code inserted.
The only parameter is a URL (either absolute or relative) to redirect the user to.
-
Template::redirect('users/profile');
+
+## Helper Functions
-
-### Theme Paths
-
-By default, all of your application's themes are stored within `bonfire/themes`. There may be times, though, when you need to have multiple locations to store your theme files. This might be handy when you ship a forums module and want to provide themes specifically for your forums in their own location.
-
-You can add a new path to look for themes with the `add_theme_path()` method. The only parameter is the path to your theme folder. This must be relative to your application's web root (FCPATH).
-
-
- Template::add_theme_path('user_themes');
-
-If you only need that path there temporarily, you can provide a slight performance increase by removing the path when you're done with it.
-
-
- Template::remove_theme_path('user_themes');
-
-
-If you want to permanently add that path to your application, you can set this in the `application.php` config file.
-
-
- $config['template.theme_paths'] = array('user_themes', 'bonfire/themes');
-
+The Template library contains several other, smaller, functions and methods that change the way you might be used to using standard CodeIgniter features, as well as some to aid with building out your navigation.
### Working With Menus
The template library contains two functions to ease working with navigation items and setting the active link within the menu.
-**`check_class()`**
-
-The `check_class()` function checks the passed in url segments against the controller that is running. The first parameter is the name of the class to check against. If you wanted to highlight the Blog link in your main application and your controller was named 'blog' you could use:
+#### `check_class($item[, $class_only = false])`
+The `check_class()` function checks the passed in url segments against the controller that is running.
+The first parameter is the name of the class to check against.
+If you wanted to highlight the Blog link in your main application and your controller was named 'blog' you could use:
>Blog
// Outputs:
Blog
-
If you already have other classes applied to the link and just want the word `active` output, you can pass `true` as the second parameter.
-
Blog
// Outputs:
Blog
-
-**`check_method()`**
+#### `check_method($item[, $class_only = false])`
Check method works the same as `check_class()` but compares it to the active method running within your controller. The parameters are identical.
-**`check_segment()`**
+#### `check_segment($segment_num, $item[, $class_only = false])`
-Check_segment is used in much the same way as the previous two methods, but is more generic, and, often, more flexible. The first parameter is the URI segment to check. The second parameter is the value to compare the segment to.
+Check_segment is used in much the same way as the previous two methods, but is more generic, and, often, more flexible.
+The first parameter is the URI segment to check.
+The second parameter is the value to compare the segment to.
>Blog
@@ -413,8 +448,7 @@ Check_segment is used in much the same way as the previous two methods, but is m
If you already have other classes applied to the link and just want the word `active` output, you can pass `true` as the third parameter.
-
Blog
// Outputs:
- Blog
\ No newline at end of file
+ Blog
diff --git a/bonfire/docs/template.md b/bonfire/docs/template.md
index d95c671cd..eead25fb5 100644
--- a/bonfire/docs/template.md
+++ b/bonfire/docs/template.md
@@ -212,6 +212,15 @@ Returns the name of the active theme.
Returns the full URL to the currently active theme.
If `$resource` is supplied, returns the full URL to that resource within the currently active theme (does not validate the existence of the resource within the theme).
+### themeView($view[, $data = null[, $ignore_mobile = false]])
+
+Set an insertion point for a view (`$view`) within a view.
+- `$view`: The name of the view to be rendered.
+- `$data`: An array of data to be passed to the view.
+- `$ignore_mobile`:
+ - If `true`, the library will not attempt to find a version of this view named for mobile devices (prefixed with `mobile_`).
+ - If `false` (default), the library will attempt to find a version of this view named for mobile devices when it detects that the page is being accessed from a mobile device.
+
### remove_theme_path($path)
Remove a theme path (`$path`) from the list of paths to be used when searching for themed views.
@@ -251,11 +260,7 @@ If `$item` does not match, an empty string is returned.
### theme_view($view[, $data = null[, $ignore_mobile = false]])
Set an insertion point for a view (`$view`) within a view.
-- `$view`: The name of the view to be rendered.
-- `$data`: An array of data to be passed to the view.
-- `$ignore_mobile`:
- - If `true`, the library will not attempt to find a version of this view named for mobile devices (prefixed with `mobile_`).
- - If `false` (default), the library will attempt to find a version of this view named for mobile devices when it detects that the page is being accessed from a mobile device.
+A helper function for `Template::themeView()`.
## Properties
diff --git a/bonfire/docs/tut_blog.md b/bonfire/docs/tut_blog.md
index de1ccedbd..d9ed552b6 100644
--- a/bonfire/docs/tut_blog.md
+++ b/bonfire/docs/tut_blog.md
@@ -41,7 +41,6 @@ Create a new file in your new `config` folder, called `config.php`.
'version' => '1.0.1',
);
-
Not all of these settings will be used for the Blog module, but you should understand how they work.
- **name** is the human-readable name of your module.
diff --git a/bonfire/docs/upgrade/073.md b/bonfire/docs/upgrade/073.md
index 3652907a3..73f2cca92 100644
--- a/bonfire/docs/upgrade/073.md
+++ b/bonfire/docs/upgrade/073.md
@@ -4,9 +4,10 @@
1. Update/install the files in the `/bonfire` directory.
2. Update `/application/config/autoload.php` (be sure to migrate your customizations).
-3. Update `/application/hooks/App_hooks.php`.
-4. Add `\application\language\english\bf_form_validation_lang.php`
-5. The following have been deprecated:
+3. Update `/application/config/constants.php` (update BONFIRE_VERSION).
+4. Update `/application/hooks/App_hooks.php`.
+5. Add `\application\language\english\bf_form_validation_lang.php`
+6. The following have been deprecated:
@@ -21,4 +22,4 @@
-6. If you are not using the installer, add `$config['bonfire.installed'] = "1";` to `/application/config/application.php`.
+7. If you are not using the installer, add `$config['bonfire.installed'] = "1";` to `/application/config/application.php`.
diff --git a/bonfire/docs/upgrade/074.md b/bonfire/docs/upgrade/074.md
new file mode 100644
index 000000000..7bea1b0a3
--- /dev/null
+++ b/bonfire/docs/upgrade/074.md
@@ -0,0 +1,12 @@
+# Upgrading Bonfire
+
+## 0.7.3 to 0.7.4
+
+1. Update `/application/hooks/App_hooks.php`.
+2. Update `/application/config/constants.php` (update BONFIRE_VERSION).
+3. Update all files in `/bonfire/`, or:
+ - Update `/bonfire/core/BF_Router.php`.
+ - Update all files in `/bonfire/docs/`.
+ - Update `/bonfire/libraries/Template.php`.
+ - Update all files in `/bonfire/modules/builder/`.
+ - Update `/bonfire/modules/settings/libraries/Settings_lib.php`.
diff --git a/bonfire/libraries/Template.php b/bonfire/libraries/Template.php
index 4ffc76781..1b44d1b01 100644
--- a/bonfire/libraries/Template.php
+++ b/bonfire/libraries/Template.php
@@ -8,7 +8,7 @@
* @package Bonfire
* @author Bonfire Dev Team
* @copyright Copyright (c) 2011 - 2015, Bonfire Dev Team
- * @license http://opensource.org/licenses/MIT The MIT License
+ * @license http://opensource.org/licenses/MIT The MIT License
* @link http://cibonfire.com
* @since Version 1.0
* @filesource
@@ -122,9 +122,9 @@ public static function init()
}
// Store our settings
- self::$default_theme = self::$ci->config->item('template.default_theme');
+ self::$default_theme = self::$ci->config->item('template.default_theme');
self::$layout = self::$ci->config->item('template.default_layout');
- self::$parse_views = self::$ci->config->item('template.parse_views');
+ self::$parse_views = self::$ci->config->item('template.parse_views');
self::$site_path = self::$ci->config->item('template.site_path');
self::$theme_paths = self::$ci->config->item('template.theme_paths');
@@ -709,6 +709,44 @@ public static function load_view($view = null, $data = null, $override = '', $is
}
}
+ /**
+ * Load a view (from the current theme) and return the content of that view.
+ *
+ * Allows for simple mobile templates by checking for a filename prefixed with
+ * 'mobile_' when loading the view (if $ignoreMobile is false). For example,
+ * if $view is 'index', the mobile version would be 'mobile_index'. If the file
+ * is not found with the mobile prefix, it will load the regular view.
+ *
+ * @param string $view The name of the view to load.
+ * @param array $data An array of data to pass to the view.
+ * @param boolean $ignoreMobile Disable loading mobile_ prefixed views (if true).
+ *
+ * @return string The content of the loaded view.
+ */
+ public static function themeView($view = null, $data = null, $ignoreMobile = false)
+ {
+ if (empty($view)) {
+ return '';
+ }
+
+ $output = '';
+
+ // If allowed, try to load the mobile version of the file.
+ if (! $ignoreMobile) {
+ self::$ci->load->library('user_agent');
+ if (self::$ci->agent->is_mobile()) {
+ self::load_view("mobile_{$view}", $data, null, true, $output);
+ }
+ }
+
+ // If output is empty, either mobile is ignored or no mobile file was found.
+ if (empty($output)) {
+ self::load_view($view, $data, null, true, $output);
+ }
+
+ return $output;
+ }
+
//--------------------------------------------------------------------------
// !PRIVATE METHODS
//--------------------------------------------------------------------------
@@ -717,8 +755,6 @@ public static function load_view($view = null, $data = null, $override = '', $is
* Searches through the the active theme and the default theme to try to find
* a view file. If found, it returns the rendered view.
*
- * @access private
- *
* @param string $view The name of the view to find.
* @param array $data An array of key/value pairs to pass to the views.
*
@@ -845,28 +881,7 @@ protected static function debug_message($message, $force = false)
*/
function theme_view($view = null, $data = null, $ignore_mobile = false)
{
- if (empty($view)) {
- return '';
- }
-
- $output ='';
-
- // If allowed, try to load the mobile version of the file.
- if (! $ignore_mobile) {
- $ci =& get_instance();
-
- $ci->load->library('user_agent');
- if ($ci->agent->is_mobile()) {
- Template::load_view("mobile_{$view}", $data, null, true, $output);
- }
- }
-
- // If output is empty, either mobile is ignored or no mobile file was found.
- if (empty($output)) {
- Template::load_view($view, $data, null, true, $output);
- }
-
- return $output;
+ return Template::themeView($view, $data, $ignore_mobile);
}
/**
@@ -1034,4 +1049,3 @@ function breadcrumb($my_segments = null, $wrap = false, $echo = true)
return $output;
}
-/* End of file ./application/libraries/template.php */
diff --git a/bonfire/modules/builder/controllers/Developer.php b/bonfire/modules/builder/controllers/Developer.php
index 9608921ea..c2a85ccf9 100644
--- a/bonfire/modules/builder/controllers/Developer.php
+++ b/bonfire/modules/builder/controllers/Developer.php
@@ -7,8 +7,8 @@
*
* @package Bonfire
* @author Bonfire Dev Team
- * @copyright Copyright (c) 2011 - 2014, Bonfire Dev Team
- * @license http://opensource.org/licenses/MIT
+ * @copyright Copyright (c) 2011 - 2015, Bonfire Dev Team
+ * @license http://opensource.org/licenses/MIT The MIT License
* @link http://cibonfire.com
* @since Version 1.0
* @filesource
@@ -23,9 +23,9 @@
*
* This code is originally based on Ollie Rattue's http://formigniter.org/ project
*
- * @package Bonfire\Modules\Builder\Controllers\Developer
- * @author Bonfire Dev Team
- * @link http://cibonfire.com/docs/builder
+ * @package Bonfire\Modules\Builder\Controllers\Developer
+ * @author Bonfire Dev Team
+ * @link http://cibonfire.com/docs/developer/builder
*/
class Developer extends Admin_Controller
{
@@ -81,12 +81,11 @@ public function index()
foreach ($modules as $module) {
$configs[$module] = Modules::config($module);
- if ( ! isset($configs[$module]['name'])) {
+ if (! isset($configs[$module]['name'])) {
$configs[$module]['name'] = ucwords($module);
- }
- // If the name is configured, check to see if it is a lang entry and
- // if it is, pull it from the application_lang file
- elseif (strpos($configs[$module]['name'], 'lang:') === 0) {
+ } elseif (strpos($configs[$module]['name'], 'lang:') === 0) {
+ // If the name is configured, check to see if it is a lang entry
+ // and, if it is, pull it from the application_lang file.
$configs[$module]['name'] = lang(str_replace('lang:', '', $configs[$module]['name']));
}
}
@@ -108,44 +107,46 @@ public function index()
/**
* Display the form which allows the user to create a context.
*
- * @return void
+ * @return void
*/
public function create_context()
{
- // Form submittal?
- if (isset($_POST['build'])) {
- $this->form_validation->set_rules('context_name', 'lang:mb_context_name', 'required|trim|alpha_numeric|xss_clean');
-
- if ($this->form_validation->run() !== false) {
- // Validated!
- $name = $this->input->post('context_name');
- $for_roles = $this->input->post('roles');
- $migrate = $this->input->post('migrate') == 'on';
-
- // Try to save the context, using the UI/Context helper
- $this->load->library('ui/contexts');
- if (Contexts::create_context($name, $for_roles, $migrate)) {
- Template::set_message(lang('mb_context_create_success'), 'success');
- redirect(SITE_AREA . '/developer/builder');
- }
-
- // Creating the context failed
- Template::set_message(lang('mb_context_create_error') . Contexts::errors(), 'error');
- }
- }
-
- // Load roles for display in the form.
- $this->load->model('roles/role_model');
- $this->role_model->select(array(
- 'role_id',
- 'role_name',
- ))
- ->where('deleted', 0);
-
- Template::set('roles', $this->role_model->find_all());
- Template::set('toolbar_title', lang('mb_create_a_context'));
-
- Template::render();
+ // Form submittal?
+ if (isset($_POST['build'])) {
+ $this->form_validation->set_rules('context_name', 'lang:mb_context_name', 'required|trim|alpha_numeric');
+
+ if ($this->form_validation->run() !== false) {
+ // Validated!
+ $name = $this->input->post('context_name');
+ $for_roles = $this->input->post('roles');
+ $migrate = $this->input->post('migrate') == 'on';
+
+ // Try to save the context, using the UI/Context helper
+ $this->load->library('ui/contexts');
+ if (Contexts::create_context($name, $for_roles, $migrate)) {
+ Template::set_message(lang('mb_context_create_success'), 'success');
+ redirect(SITE_AREA . '/developer/builder');
+ }
+
+ // Creating the context failed
+ Template::set_message(lang('mb_context_create_error') . Contexts::errors(), 'error');
+ }
+ }
+
+ // Load roles for display in the form.
+ $this->load->model('roles/role_model');
+ $this->role_model->select(
+ array(
+ 'role_id',
+ 'role_name',
+ )
+ )
+ ->where('deleted', 0);
+
+ Template::set('roles', $this->role_model->find_all());
+ Template::set('toolbar_title', lang('mb_create_a_context'));
+
+ Template::render();
}
//--------------------------------------------------------------------
@@ -168,9 +169,11 @@ public function create_module($fields = 0)
if ($this->validate_form($this->field_total) == false) {
// Display the modulebuilder_form
$this->prepareModuleForm($this->field_total, isset($_POST['build']));
- }
- // Validation Passed, Use existing DB, need to detect the fields
- elseif ($this->input->post('module_db') == 'existing' && $this->field_total == 0) {
+ } elseif ($this->input->post('module_db') == 'existing'
+ && $this->field_total == 0
+ ) {
+ // Validation Passed, Use existing DB, need to detect the fields.
+ //
// If the table name includes the prefix, remove the prefix
$_POST['table_name'] = preg_replace("/^".$this->db->dbprefix."/", "", $this->input->post('table_name'));
@@ -183,7 +186,7 @@ public function create_module($fields = 0)
$formError = false;
// If the table wasn't found, log/set an error message
- if ( ! empty($_POST) && $num_fields == 0) {
+ if (! empty($_POST) && $num_fields == 0) {
$formError = true;
$error_message = lang('mb_module_table_not_exist');
log_message('error', "ModuleBuilder: {$error_message}");
@@ -194,9 +197,8 @@ public function create_module($fields = 0)
// Display the modulebuilder_form
$this->prepareModuleForm($fieldTotal, $formError);
- }
- // Validation passed and ready to proceed
- else {
+ } else {
+ // Validation passed and ready to proceed
$this->build_module($this->field_total);
log_activity((int) $this->current_user->id, lang('mb_act_create') . ': ' . $this->input->post('module_name') . ' : ' . $this->input->ip_address(), 'modulebuilder');
@@ -289,7 +291,7 @@ private function deleteModuleData($moduleName)
->find_all();
// Undo any permissions that exist, from the roles as well
- if ( ! empty($permissionIds)) {
+ if (! empty($permissionIds)) {
foreach ($permissionIds as $row) {
$this->permission_model->delete($row->permission_id);
}
@@ -304,7 +306,7 @@ private function deleteModuleData($moduleName)
$mtTableName = $this->mt->get_table();
// If the model has a table and it exists in the database, drop it
- if ( ! empty($mtTableName) && $this->db->table_exists($mtTableName)) {
+ if (! empty($mtTableName) && $this->db->table_exists($mtTableName)) {
$this->dbforge->drop_table($mtTableName);
}
}
@@ -335,10 +337,7 @@ private function deleteModuleData($moduleName)
private function prepareModuleForm($fieldTotal, $formError)
{
$this->load->model('roles/role_model');
- $this->role_model->select(array(
- 'role_id',
- 'role_name',
- ))
+ $this->role_model->select(array('role_id', 'role_name'))
->where('deleted', 0)
->order_by('role_name');
@@ -361,26 +360,38 @@ private function prepareModuleForm($fieldTotal, $formError)
Template::set('form_error', $formError);
Template::set('listFieldTypes', $listFieldTypes);
Template::set('roles', $this->role_model->as_array()->find_all());
- Template::set('textarea_editors', array(
- '' => 'None',
- 'ckeditor' => 'CKEditor',
- 'elrte' => 'ElRte with ElFinder',
- 'markitup' => 'MarkitUp!',
- 'tinymce' => 'TinyMCE',
- 'xinha' => 'Xinha',
- ));
+ Template::set(
+ 'textarea_editors',
+ array(
+ '' => 'None',
+ 'ckeditor' => 'CKEditor',
+ 'elrte' => 'ElRte with ElFinder',
+ 'markitup' => 'MarkitUp!',
+ 'tinymce' => 'TinyMCE',
+ 'xinha' => 'Xinha',
+ )
+ );
Template::set('textFieldTypes', $textFieldTypes);
- Template::set('truefalse', array(
- 'false' => 'False',
- 'true' => 'True',
- ));
+ Template::set(
+ 'truefalse',
+ array(
+ 'false' => 'False',
+ 'true' => 'True',
+ )
+ );
Template::set('validation_limits', $this->options['validation_limits']);
Template::set('validation_rules', $this->options['validation_rules']);
- Template::set('view_field_types', array(
- 'input' => 'INPUT', 'checkbox' => 'CHECKBOX',
- 'password' => 'PASSWORD', 'radio' => 'RADIO',
- 'select' => 'SELECT', 'textarea' => 'TEXTAREA',
- ));
+ Template::set(
+ 'view_field_types',
+ array(
+ 'input' => 'INPUT',
+ 'checkbox' => 'CHECKBOX',
+ 'password' => 'PASSWORD',
+ 'radio' => 'RADIO',
+ 'select' => 'SELECT',
+ 'textarea' => 'TEXTAREA',
+ )
+ );
Template::set_view('developer/modulebuilder_form');
}
@@ -394,40 +405,41 @@ private function prepareModuleForm($fieldTotal, $formError)
*/
private function validate_form($field_total = 0)
{
- $this->form_validation->set_rules("contexts_content",'lang:mb_contexts_content',"trim|xss_clean|is_numeric");
- $this->form_validation->set_rules("contexts_developer",'lang:mb_contexts_developer',"trim|xss_clean|is_numeric");
- $this->form_validation->set_rules("contexts_public",'lang:mb_contexts_public',"trim|xss_clean|is_numeric");
- $this->form_validation->set_rules("contexts_reports",'lang:mb_contexts_reports',"trim|xss_clean|is_numeric");
- $this->form_validation->set_rules("contexts_settings",'lang:mb_contexts_settings',"trim|xss_clean|is_numeric");
- $this->form_validation->set_rules("module_db",'lang:mb_module_db',"trim|xss_clean|alpha");
- $this->form_validation->set_rules("form_action_create",'lang:mb_form_action_create',"trim|xss_clean|is_numeric");
- $this->form_validation->set_rules("form_action_delete",'lang:mb_form_action_delete',"trim|xss_clean|is_numeric");
- $this->form_validation->set_rules("form_action_edit",'lang:mb_form_action_edit',"trim|xss_clean|is_numeric");
- $this->form_validation->set_rules("form_action_view",'lang:mb_form_action_view',"trim|xss_clean|is_numeric");
- $this->form_validation->set_rules("form_error_delimiters",'lang:mb_form_err_delims',"required|trim|xss_clean");
- $this->form_validation->set_rules("module_description",'lang:mb_form_mod_desc',"trim|required|xss_clean");
- $this->form_validation->set_rules("module_name",'lang:mb_form_mod_name',"trim|required|xss_clean|callback__modulename_check");
- $this->form_validation->set_rules("role_id",'lang:mb_form_role_id',"trim|xss_clean|is_numeric");
+ $this->form_validation->set_rules("contexts_content", 'lang:mb_contexts_content', "trim|is_numeric");
+ $this->form_validation->set_rules("contexts_developer", 'lang:mb_contexts_developer', "trim|is_numeric");
+ $this->form_validation->set_rules("contexts_public", 'lang:mb_contexts_public', "trim|is_numeric");
+ $this->form_validation->set_rules("contexts_reports", 'lang:mb_contexts_reports', "trim|is_numeric");
+ $this->form_validation->set_rules("contexts_settings", 'lang:mb_contexts_settings', "trim|is_numeric");
+ $this->form_validation->set_rules("module_db", 'lang:mb_module_db', "trim|alpha");
+ $this->form_validation->set_rules("form_action_create", 'lang:mb_form_action_create', "trim|is_numeric");
+ $this->form_validation->set_rules("form_action_delete", 'lang:mb_form_action_delete', "trim|is_numeric");
+ $this->form_validation->set_rules("form_action_edit", 'lang:mb_form_action_edit', "trim|is_numeric");
+ $this->form_validation->set_rules("form_action_view", 'lang:mb_form_action_view', "trim|is_numeric");
+ $this->form_validation->set_rules("form_error_delimiters", 'lang:mb_form_err_delims', "required|trim");
+ $this->form_validation->set_rules("module_description", 'lang:mb_form_mod_desc', "trim|required");
+ $this->form_validation->set_rules("module_name", 'lang:mb_form_mod_name', "trim|required|callback__modulename_check");
+ $this->form_validation->set_rules("role_id", 'lang:mb_form_role_id', "trim|is_numeric");
// If there's no database table, don't use the table validation
if ($this->input->post('module_db')) {
- $this->form_validation->set_rules("table_name",'lang:mb_form_table_name',"trim|required|xss_clean|alpha_dash");
+ $this->form_validation->set_rules("table_name", 'lang:mb_form_table_name', "trim|required|alpha_dash");
// If it's a new table, extra validation is required
if ($this->input->post('module_db') == 'new') {
- $this->form_validation->set_rules("primary_key_field",'lang:mb_form_primarykey',"required|trim|xss_clean|alpha_dash");
- $this->form_validation->set_rules("soft_delete_field",'lang:mb_soft_delete_field',"trim|xss_clean|alpha_dash");
- $this->form_validation->set_rules("created_field",'lang:mb_form_created_field',"trim|xss_clean|alpha_dash");
- $this->form_validation->set_rules("modified_field",'lang:mb_form_modified_field',"trim|xss_clean|alpha_dash");
- $this->form_validation->set_rules('deleted_by_field', 'lang:mb_deleted_by_field', 'trim|xss_clean|alpha_dash');
- $this->form_validation->set_rules('created_by_field', 'lang:mb_form_created_by_field', 'trim|xss_clean|alpha_dash');
- $this->form_validation->set_rules('modified_by_field', 'lang:mb_form_modified_by_field', 'trim|xss_clean|alpha_dash');
+ $this->form_validation->set_rules("primary_key_field", 'lang:mb_form_primarykey', "required|trim|alpha_dash");
+ $this->form_validation->set_rules("soft_delete_field", 'lang:mb_soft_delete_field', "trim|alpha_dash");
+ $this->form_validation->set_rules("created_field", 'lang:mb_form_created_field', "trim|alpha_dash");
+ $this->form_validation->set_rules("modified_field", 'lang:mb_form_modified_field', "trim|alpha_dash");
+ $this->form_validation->set_rules('deleted_by_field', 'lang:mb_deleted_by_field', 'trim|alpha_dash');
+ $this->form_validation->set_rules('created_by_field', 'lang:mb_form_created_by_field', 'trim|alpha_dash');
+ $this->form_validation->set_rules('modified_by_field', 'lang:mb_form_modified_by_field', 'trim|alpha_dash');
// textarea_editor seems to be gone...
- //$this->form_validation->set_rules("textarea_editor",'lang:mb_form_text_ed',"trim|xss_clean|alpha_dash");
- }
- // If it's an existing table, the primary key validation is required
- elseif ($this->input->post('module_db') == 'existing' && $field_total > 0) {
- $this->form_validation->set_rules("primary_key_field",'lang:mb_form_primarykey',"required|trim|xss_clean|alpha_dash");
+ //$this->form_validation->set_rules("textarea_editor", 'lang:mb_form_text_ed', "trim|alpha_dash");
+ } elseif ($this->input->post('module_db') == 'existing'
+ && $field_total > 0
+ ) {
+ // If it's an existing table, the primary key validation is required
+ $this->form_validation->set_rules("primary_key_field", 'lang:mb_form_primarykey', "required|trim|alpha_dash");
}
// No need to do any of the below on every iteration of the loop
@@ -459,29 +471,30 @@ private function validate_form($field_total = 0)
// Better to do it this way round as this statement will be
// fullfilled more than the one below
if ($counter != 1) {
- $this->form_validation->set_rules("view_field_label$counter", $field_details_label . lang('mb_form_label'), 'trim|xss_clean|alpha_extra');
+ $this->form_validation->set_rules("view_field_label$counter", $field_details_label . lang('mb_form_label'), 'trim|alpha_extra');
} else {
// At least one field is required in the form
- $this->form_validation->set_rules("view_field_label$counter", $field_details_label . lang('mb_form_label'),'trim|required|xss_clean|alpha_extra');
+ $this->form_validation->set_rules("view_field_label$counter", $field_details_label . lang('mb_form_label'), 'trim|required|alpha_extra');
}
$label = $this->input->post("view_field_label$counter");
$name_required = empty($label) ? '' : 'required|';
- $this->form_validation->set_rules("view_field_name$counter", $field_details_label . lang('mb_form_fieldname'), "trim|".$name_required."callback__no_match[$counter]|xss_clean");
- $this->form_validation->set_rules("view_field_type$counter", $field_details_label . lang('mb_form_type'), "trim|required|xss_clean|alpha");
- $this->form_validation->set_rules("db_field_type$counter", $field_details_label . lang('mb_form_dbtype'), "trim|xss_clean|alpha");
+ $this->form_validation->set_rules("view_field_name$counter", $field_details_label . lang('mb_form_fieldname'), "trim|{$name_required}callback__no_match[$counter]");
+ $this->form_validation->set_rules("view_field_type$counter", $field_details_label . lang('mb_form_type'), "trim|required|alpha");
+ $this->form_validation->set_rules("db_field_type$counter", $field_details_label . lang('mb_form_dbtype'), "trim|alpha");
$field_type = $this->input->post("db_field_type$counter");
$db_len_required = '';
- if ( ! empty($label) && ! in_array($field_type, $no_length)
+ if (! empty($label)
+ && ! in_array($field_type, $no_length)
&& ! in_array($field_type, $optional_length)
- ) {
- $db_len_required = 'required|';
+ ) {
+ $db_len_required = '|required';
}
- $this->form_validation->set_rules("db_field_length_value$counter", $field_details_label . lang('mb_form_length'), "trim|".$db_len_required."xss_clean");
- $this->form_validation->set_rules('validation_rules'.$counter.'[]', $field_details_label . lang('mb_form_rules'), 'trim|xss_clean');
+ $this->form_validation->set_rules("db_field_length_value$counter", $field_details_label . lang('mb_form_length'), "trim{$db_len_required}");
+ $this->form_validation->set_rules('validation_rules'.$counter.'[]', $field_details_label . lang('mb_form_rules'), 'trim');
}
}
@@ -500,7 +513,7 @@ private function table_info($table_name)
$newfields = array();
// Check whether the table exists in this database
- if ( ! $this->db->table_exists($table_name)) {
+ if (! $this->db->table_exists($table_name)) {
return false;
}
@@ -545,25 +558,25 @@ private function table_info($table_name)
return $newfields;
}
- /**
- * Handles the heavy-lifting of building a module from ther user's specs.
- *
- * @param int $field_total The number of fields to add to the table
- *
- * @return void
- */
- private function build_module($field_total = 0)
- {
- $action_names = $this->input->post('form_action');
- $contexts = $this->input->post('contexts');
- $db_required = $this->input->post('module_db');
- $form_error_delimiters = explode(',', $this->input->post('form_error_delimiters'));
- $module_description = $this->input->post('module_description');
- $module_name = $this->input->post('module_name');
- $primary_key_field = $this->input->post('primary_key_field');
- $role_id = $this->input->post('role_id');
- $table_name = strtolower(preg_replace("/[ -]/", "_", $this->input->post('table_name')));
- $table_as_field_prefix = (bool) $this->input->post('table_as_field_prefix');
+ /**
+ * Handles the heavy-lifting of building a module from ther user's specs.
+ *
+ * @param int $field_total The number of fields to add to the table
+ *
+ * @return void
+ */
+ private function build_module($field_total = 0)
+ {
+ $action_names = $this->input->post('form_action');
+ $contexts = $this->input->post('contexts');
+ $db_required = $this->input->post('module_db');
+ $form_error_delimiters = explode(',', $this->input->post('form_error_delimiters'));
+ $module_description = $this->input->post('module_description');
+ $module_name = $this->input->post('module_name');
+ $primary_key_field = $this->input->post('primary_key_field');
+ $role_id = $this->input->post('role_id');
+ $table_name = strtolower(preg_replace("/[ -]/", "_", $this->input->post('table_name')));
+ $table_as_field_prefix = (bool) $this->input->post('table_as_field_prefix');
$logUser = $this->input->post('log_user') == 1;
$useCreated = $this->input->post('use_created') == 1;
@@ -580,85 +593,90 @@ private function build_module($field_total = 0)
$textarea_editor = $this->input->post('textarea_editor');
- if ($primary_key_field == '') {
- $primary_key_field = $this->options['primary_key_field'];
- }
+ if ($primary_key_field == '') {
+ $primary_key_field = $this->options['primary_key_field'];
+ }
- if ( ! is_array($form_error_delimiters)
+ if (! is_array($form_error_delimiters)
|| count($form_error_delimiters) != 2
- ) {
- $form_error_delimiters = $this->options['$form_error_delimiters'];
- }
+ ) {
+ $form_error_delimiters = $this->options['$form_error_delimiters'];
+ }
$controller_name = preg_replace("/[ -]/", "_", $module_name);
$module_name_lower = strtolower($controller_name);
$this->load->library('modulebuilder');
- $file_data = $this->modulebuilder->buildFiles(array(
- 'action_names' => $action_names,
- 'contexts' => $contexts,
- 'controller_name' => $controller_name,
- 'created_by_field' => $created_by_field,
- 'created_field' => $created_field,
- 'db_required' => $db_required,
- 'deleted_by_field' => $deleted_by_field,
- 'field_total' => $field_total,
- 'form_error_delimiters' => $form_error_delimiters,
- 'logUser' => $logUser,
- 'modified_by_field' => $modified_by_field,
- 'modified_field' => $modified_field,
- 'module_description' => $module_description,
- 'module_name' => $module_name,
- 'module_name_lower' => $module_name_lower,
- 'primary_key_field' => $primary_key_field,
- 'role_id' => $role_id,
- 'soft_delete_field' => $soft_delete_field,
- 'table_as_field_prefix' => $table_as_field_prefix,
- 'table_name' => $table_name,
- 'textarea_editor' => $textarea_editor,
- 'useCreated' => $useCreated,
- 'useModified' => $useModified,
- 'usePagination' => $usePagination,
- 'useSoftDeletes' => $useSoftDeletes,
- ));
-
- // Make the variables available to the view file
- $data['module_name'] = $module_name;
- $data['controller_name'] = $controller_name;
- $data['module_name_lower'] = $module_name_lower;
- $data['table_name'] = empty($table_name) ? $module_name_lower : $table_name;
-
- $data = $data + $file_data;
+ $file_data = $this->modulebuilder->buildFiles(
+ array(
+ 'action_names' => $action_names,
+ 'contexts' => $contexts,
+ 'controller_name' => $controller_name,
+ 'created_by_field' => $created_by_field,
+ 'created_field' => $created_field,
+ 'db_required' => $db_required,
+ 'deleted_by_field' => $deleted_by_field,
+ 'field_total' => $field_total,
+ 'form_error_delimiters' => $form_error_delimiters,
+ 'logUser' => $logUser,
+ 'modified_by_field' => $modified_by_field,
+ 'modified_field' => $modified_field,
+ 'module_description' => $module_description,
+ 'module_name' => $module_name,
+ 'module_name_lower' => $module_name_lower,
+ 'primary_key_field' => $primary_key_field,
+ 'role_id' => $role_id,
+ 'soft_delete_field' => $soft_delete_field,
+ 'table_as_field_prefix' => $table_as_field_prefix,
+ 'table_name' => $table_name,
+ 'textarea_editor' => $textarea_editor,
+ 'useCreated' => $useCreated,
+ 'useModified' => $useModified,
+ 'usePagination' => $usePagination,
+ 'useSoftDeletes' => $useSoftDeletes,
+ )
+ );
+
+ // Make the variables available to the view file
+ $data['module_name'] = $module_name;
+ $data['controller_name'] = $controller_name;
+ $data['module_name_lower'] = $module_name_lower;
+ $data['table_name'] = empty($table_name) ? $module_name_lower : $table_name;
+
+ $data = $data + $file_data;
// @todo Need to test whether this section can be removed... Only the
// migrations library should know anything about the structure of the
// migration versions in the database.
//
- // Allow for the Old method - update the schema first to prevent errors
+ // Allow for the Old method - update the schema first to prevent errors
// in duplicate column names due to Migrations.php caching db columns
- if ( ! $this->db->field_exists('version', 'schema_version')) {
- $this->dbforge->add_column('schema_version', array(
- $data['module_name_lower'] . '_version' => array(
- 'type' => 'INT',
- 'constraint' => 4,
- 'null' => true,
- 'default' => 0,
- ),
- ));
- }
-
- // Load the migrations library
- $this->load->library('migrations/migrations');
-
- // Run the migration install routine
- if ($this->migrations->install("{$data['module_name_lower']}_")) {
- $data['mb_migration_result'] = 'mb_out_tables_success';
- } else {
- $data['mb_migration_result'] = 'mb_out_tables_error';
- }
-
- Template::set($data);
- }
+ if (! $this->db->field_exists('version', 'schema_version')) {
+ $this->dbforge->add_column(
+ 'schema_version',
+ array(
+ $data['module_name_lower'] . '_version' => array(
+ 'type' => 'INT',
+ 'constraint' => 4,
+ 'null' => true,
+ 'default' => 0,
+ ),
+ )
+ );
+ }
+
+ // Load the migrations library
+ $this->load->library('migrations/migrations');
+
+ // Run the migration install routine
+ if ($this->migrations->install("{$data['module_name_lower']}_")) {
+ $data['mb_migration_result'] = 'mb_out_tables_success';
+ } else {
+ $data['mb_migration_result'] = 'mb_out_tables_error';
+ }
+
+ Template::set($data);
+ }
/**
* Check that the Modules folder is writable
@@ -699,7 +717,7 @@ private function checkWritable()
*/
public function _modulename_check($str)
{
- if ( ! preg_match("/^([A-Za-z \-]+)$/", $str)) {
+ if (! preg_match("/^([A-Za-z \-]+)$/", $str)) {
$this->form_validation->set_message('_modulename_check', lang('mb_modulename_check'));
return false;
}
@@ -741,4 +759,3 @@ public function _no_match($str, $fieldno)
return true;
}
}
-/* End of file: /builder/controllers/developer.php */
\ No newline at end of file
diff --git a/bonfire/modules/builder/libraries/Modulebuilder.php b/bonfire/modules/builder/libraries/Modulebuilder.php
old mode 100755
new mode 100644
index bcd5470e3..daef0bebf
--- a/bonfire/modules/builder/libraries/Modulebuilder.php
+++ b/bonfire/modules/builder/libraries/Modulebuilder.php
@@ -7,8 +7,8 @@
*
* @package Bonfire
* @author Bonfire Dev Team
- * @copyright Copyright (c) 2011 - 2014, Bonfire Dev Team
- * @license http://opensource.org/licenses/MIT
+ * @copyright Copyright (c) 2011 - 2015, Bonfire Dev Team
+ * @license http://opensource.org/licenses/MIT The MIT License
* @link http://cibonfire.com
* @since Version 1.0
* @filesource
diff --git a/bonfire/modules/builder/views/files/view_default.php b/bonfire/modules/builder/views/files/view_default.php
index 5969e8fbb..e4477308f 100644
--- a/bonfire/modules/builder/views/files/view_default.php
+++ b/bonfire/modules/builder/views/files/view_default.php
@@ -29,7 +29,7 @@
if (is_array($validation_rules)) {
foreach ($validation_rules as $key => $value) {
if ($value == 'required') {
- $required = ". lang('bf_form_label_required')";
+ $required = " . lang('bf_form_label_required')";
$required_attribute = true;
}
}
@@ -40,7 +40,7 @@
case 'textarea':
$viewFields .= PHP_EOL . "