Skip to content

Commit

Permalink
Merge pull request #6 from carlino1994/master
Browse files Browse the repository at this point in the history
Some fixes and controller system
  • Loading branch information
carlo94it committed Jun 21, 2011
2 parents ae97ed6 + 41e1ede commit 73e8a8b
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 599 deletions.
96 changes: 30 additions & 66 deletions Bokeh-Platform/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
if (defined('DISPLAY_RAM') && DISPLAY_RAM)
{
$base_memory_usage = 0;

if (function_exists('memory_get_usage'))
{
$base_memory_usage = memory_get_usage();
Expand All @@ -43,33 +43,26 @@
define('SMARTY_DIR', $root_path . 'includes/smarty/');
define('STRIP', (get_magic_quotes_gpc()) ? true : false);

# Start session
session_start();
# Session disabled for now (21.06.2011, 1.0.0-dev)
#session_start();

# Setting some arrays
$config = $user = array();

# Check config file
if (!file_exists($root_path . 'config.' . $phpEx))
{
die("<p>The config.$phpEx file could not be found.</p>");
die("<p>The config.{$phpEx} file could not be found.</p>");
}

require($root_path . 'config.' . $phpEx);

date_default_timezone_set($config['timezone']);

$config['site_root'] = $config['server_protocol'] . '://' . $config['server_name'] . ($config['server_port'] != 80 ? ":{$config['server_port']}" : '') . $config['server_path'] . '/';
$config['page_url'] = $config['server_protocol'] . '://' . $config['server_name'] . ($config['server_port'] != 80 ? ":{$config['server_port']}" : '') . $_SERVER['SCRIPT_NAME'];
$config['page_arg'] = $_SERVER['QUERY_STRING'];

# Set some default $config vars if they are not set in database
$config['site_name'] = 'My Bokeh Platform site';
$config['site_description'] = 'This is a Bokeh Platform powered site';
$config['meta_keywords'] = 'bokeh, platform, php';
$config['meta_description'] = 'This is a Bokeh Platform powered site';
$config['template'] = 'default';
$config['date_format'] = 'j | Y';
$config['hour_format'] = 'H:i';
$config['page_info'] = ((isset($_SERVER['PATH_INFO']) && !empty($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : '');

# Setting default timezone
ini_set('date.timezone', $config['timezone']);
Expand All @@ -93,10 +86,13 @@
require($root_path . 'languages/en.' . $phpEx);
}

$user = array('lang' => $lang);
# Initialize database class
if ($config['database_enabled'])
{
$db = new $__database_class__();
}

# Initialize some basic classes
$db = new $__database_class__();
# Initialize Smarty
$smarty = new Smarty();

# Smarty settings
Expand Down Expand Up @@ -131,7 +127,7 @@

# Set template default vars
$smarty->assign(array(
'root_path' => $root_path,
'root_path' => $config['site_root'],
'bokeh_site' => $bokeh_domain,
'bokeh_version' => $bokeh_version,
'page_url' => ($config['page_url'] . (($config['page_arg'] == '') ? '' : ('?' . $config['page_arg']))),
Expand All @@ -155,65 +151,33 @@
$request_vars = retrive_requests_vars($_REQUEST);

# Connect to DB
$db->sql_connect($dbhost, $dbport, $dbuser, $dbpass, $dbname);
if ($config['database_enabled'])
{
$db->sql_connect($dbhost, $dbport, $dbuser, $dbpass, $dbname);
}

# We do not need this any longer, unset for safety purposes
unset($dbpass);

# Check if install.php exist, else if is not in install.php page, redirect to error_box()
if (file_exists($root_path . 'install.php'))
{
if (!defined('BOKEH_INSTALL') && !defined('BOKEH_UPDATE'))
{
error_box("The file install.php exist. If you have installed Bokeh, please delete it, else go to install.php page.");
}
}

# Check if update.php exist, else if is not in update.php page, redirect to error_box()
if (file_exists($root_path . 'update.php'))
{
if (!defined('BOKEH_INSTALL') && !defined('BOKEH_UPDATE'))
{
error_box("The file update.php exist. If you have updated Bokeh, please delete it, else go to update.php page.");
}
}
# Check if template dir exist and set it
check_template($config['template']);

# Execute some code only if Bokeh Platform is installed, and we are not in install.php page
if (!defined('BOKEH_INSTALL') && !defined('BOKEH_UPDATE'))
# Now activate plugins with a include() of $root_path/plugins/(plugin_name)/(plugin_name).(phpEx)
# After including, add a new object $plugin_(plugin_name) for the class plugin_(plugin_name)
if (defined('ENABLE_PLUGINS') && ENABLE_PLUGINS)
{
# Get $config array from database, only if we are not in install.php page
generate_config_data();

# Decode some JSON config data
$tmp_config_json_decode = array('plugins_active');

foreach($tmp_config_json_decode as $config_key)
{
$config[$config_key] = json_decode($config[$config_key]);
}

unset($tmp_config_json_decode);

# Check if template dir exist and set it
check_template($config['template']);

# Now activate plugins with a include() of $root_path/plugins/(plugin_name)/(plugin_name).php
# After including, add a new object $plugin_(plugin_name) for the class plugin_(plugin_name)
if (defined('ENABLE_PLUGINS') && ENABLE_PLUGINS)
if (count($config['plugins_active']))
{
if (isset($config['plugins_active']) && count($config['plugins_active']))
foreach($config['plugins_active'] as $plugin_name)
{
foreach($config['plugins_active'] as $plugin_name)
if (file_exists($root_path . 'plugins/' . $plugin_name . '/' . $plugin_name . '.' . $phpEx))
{
if (file_exists($root_path . 'plugins/' . $plugin_name . '/' . $plugin_name . '.' . $phpEx))
include($root_path . 'plugins/' . $plugin_name . '/' . $plugin_name . '.' . $phpEx);
$plugin_class_name = 'plugin_' . $plugin_name;

if (class_exists($plugin_class_name))
{
include($root_path . 'plugins/' . $plugin_name . '/' . $plugin_name . '.' . $phpEx);
$plugin_class_name = 'plugin_' . $plugin_name;

if (class_exists($plugin_class_name))
{
$plugin_class_name = new $plugin_class_name();
}
$plugin_class_name = new $plugin_class_name();
}
}
}
Expand Down
21 changes: 16 additions & 5 deletions Bokeh-Platform/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,22 @@
* Advanced system configuration is to be set via Admin panel
*/
$config = array(
'server_protocol' => 'http',
'server_name' => 'www.mysite.com',
'server_port' => 80,
'server_path' => '/bokeh',
'timezone' => 'Europe/Rome'
'database_enabled' => false,
'server_protocol' => 'http',
'server_name' => 'www.mysite.com',
'server_port' => 80,
'server_path' => '/bokeh',
'default_controller' => 'default',
'site_name' => 'My Bokeh Platform site',
'site_description' => 'This is a Bokeh Platform powered site',
'meta_keywords' => 'bokeh, platform, php',
'meta_description' => 'This is a Bokeh Platform powered site',
'site_email' => 'info@mysite.com',
'template' => 'default',
'date_format' => 'j | Y',
'hour_format' => 'H:i',
'timezone' => 'Europe/Rome',
'plugins_active' => array(),
);

/**
Expand Down
4 changes: 4 additions & 0 deletions Bokeh-Platform/controllers/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Files *>
Order Allow,Deny
Deny from All
</Files>
40 changes: 40 additions & 0 deletions Bokeh-Platform/controllers/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
*
* @package Bokeh Platform
* @version $Id$
* @copyright (c) 2011 Bokeh Platform
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_BOKEH'))
{
exit;
}

class controller_default
{
function controller_default()
{
# here you can put some code for init our controller
}

function index()
{
global $lang;

# this is index page
# this page have two links:
# > http://www.mysite.com/bokeh/index.php/default/
# > http://www.mysite.com/bokeh/index.php/default/index

page_header($lang['HOME']);
_template('home_body');
page_footer();
}
}
?>
Empty file.

0 comments on commit 73e8a8b

Please sign in to comment.