Skip to content

Commit

Permalink
Update IXT, fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
websiteduck committed Feb 16, 2013
1 parent a268260 commit b7015de
Show file tree
Hide file tree
Showing 36 changed files with 1,624 additions and 93 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Demo Project for the IgniteXT Framework
### To use:

1. Copy demo files to a fresh install of IXT Framework.
2. In config.json, change "BASEURL": "/" to whatever directory you installed the demos to. For instance, if the demos are in /var/www/ixtdemos, change the line to "BASEURL": "/ixtdemos/"
2. In config.json, change "BASE_URL": "/" to whatever directory you installed the demos to. For instance, if the demos are in /var/www/ixtdemos, change the line to "BASE_URL": "/ixtdemos/"
3. Go to URL, e.g. http://localhost/ixtdemos

### IgniteXT Demo Project utilizes the following projects:
Expand Down
15 changes: 5 additions & 10 deletions application/config/config_base.php → application/config/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@
// The application identifier will be used by system classes to prevent multiple
// applications from interfering with each other when using shared resources such
// as PHP sessions.
'APPID' => 'ignitext_demos',
'APP_ID' => 'ignitext_demos',

// Relative URL, if your index.php file is in http://example.com/ixt/ then
// BASEURL will be "/ixt/". If it's in your root folder, leave this as "/"
'BASEURL' => '/',
// BASE_URL will be "/ixt/". If it's in your root folder, leave this as "/"
'BASE_URL' => '/',

// The ASSETS URL contains your publicly accessible files such as javascript,
// css, and image files.
'ASSETS' => '/assets/',

// Locations of directories used by IgniteXT
'APPDIR' => 'application/',
'SHRDIR' => 'shared/',
'IXTDIR' => 'ignitext/',

'class_callbacks' => array(
'\\Services\\System\\Profiler' => function($profiler) {
'\\IgniteXT\\Profiler' => function($profiler) {
$profiler->log_everything = false;
},
'\\Services\\System\\Database' => function($database) {
'\\IgniteXT\\Database' => function($database) {
$database->connect_dsn('sqlite:ixt_demo.sqlite');
}
)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion application/source/base/controllers/index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Controllers;

class index extends \Services\System\Controller
class index extends \IgniteXT\Controller
{
function index()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
namespace Controllers\Libraries;

class form_validation extends \Services\System\Controller
class form_validation extends \IgniteXT\Controller
{
function index()
{
$form_validation = \Get::a('\Entities\IXT\Form_Validation');
$form_validation = \Get::a('\IgniteXT\Form_Validation');

if ($_SERVER['REQUEST_METHOD']=='POST')
{
Expand Down
4 changes: 2 additions & 2 deletions application/source/base/controllers/libraries/stopwatch.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
namespace Controllers\Libraries;

class stopwatch extends \Services\System\Controller
class stopwatch extends \IgniteXT\Controller
{
function index()
{
$actions[] = 'Create IXT_Stopwatch';
$stopwatch = \Get::a('\Entities\IXT\Stopwatch');
$stopwatch = \Get::a('\IgniteXT\Stopwatch');

$actions[] = 'Create mark "one"';
$stopwatch->mark('one');
Expand Down
6 changes: 3 additions & 3 deletions application/source/base/views/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
?>
<h2>Libraries</h2>
<ul>
<li><a href="<?=BASEURL?>libraries/form_validation">\Libraries\IXT_Form_Validation</a></li>
<li><a href="<?=BASEURL?>libraries/stopwatch">\Libraries\IXT_Stopwatch</a></li>
<li><a href="<?=BASE_URL?>libraries/form_validation">\Libraries\IXT_Form_Validation</a></li>
<li><a href="<?=BASE_URL?>libraries/stopwatch">\Libraries\IXT_Stopwatch</a></li>
</ul>

<h2>Demo Apps</h2>
<ul>
<li><a href="<?=BASEURL?>user_manager/">User Manager</a></li>
<li><a href="<?=BASE_URL?>user_manager/">User Manager</a></li>
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="control-group <?php if ($form_validation->field_error($key)) echo 'error'; ?>">
<label class="control-label"><?php echo $title ?></label>
<div class="controls">
<input type="text" name="<?php echo $key ?>" value="<?php echo $this->input->form_value($key, $default) ?>" />
<input type="text" name="<?php echo $key ?>" value="<?php echo $form_validation->form_value($key, $default) ?>" />
<?php echo $instructions ?>
<span class="help-inline"><?php echo $form_validation->get_error($key) ?></span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions application/source/user_manager/controllers/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
namespace Controllers\User_Manager;

class index extends \Services\System\Controller
class index extends \IgniteXT\Controller
{
function index()
{
header('location:'.BASEURL.'user_manager/users');
header('location:'.BASE_URL.'user_manager/users');
}
}
14 changes: 5 additions & 9 deletions application/source/user_manager/controllers/users.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
<?php
namespace Controllers\User_Manager;

class users extends \Services\System\Controller
class users extends \IgniteXT\Controller
{
public function __construct() {
parent::__construct();
$this->db = \Get::the('\Services\System\Database');
}

function index()
{
header('location:' . BASEURL . 'user_manager/users/list'); die();
header('location:' . BASE_URL . 'user_manager/users/list'); die();
}

function m_list()
Expand All @@ -24,9 +20,9 @@ function create()
{
if ($_SERVER['REQUEST_METHOD']=='POST')
{
$id = $this->db->insert("INSERT INTO users (username) VALUES (?)", $_POST['username']);
$id = $this->db->insert_id("INSERT INTO users (username) VALUES (?)", $_POST['username']);
$_SESSION['success_messages'][] = 'User [' . $id . '] ' . $_POST['username'] . ' created.';
header('location:' . BASEURL . 'user_manager/users/list'); die();
header('location:' . BASE_URL . 'user_manager/users/list'); die();
}
$this->display->template('user_manager/users.create', $data);
}
Expand All @@ -37,6 +33,6 @@ function delete()
$username = $this->db->field("SELECT username FROM users WHERE id = ?", $id);
$this->db->query("DELETE FROM users WHERE id = ?", $id);
$_SESSION['success_messages'][] = 'User [' . $id . '] ' . $username . ' deleted.';
header('location:' . BASEURL . 'user_manager/users/list'); die();
header('location:' . BASE_URL . 'user_manager/users/list'); die();
}
}
4 changes: 2 additions & 2 deletions application/source/user_manager/views/menu.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

<div class="well">
<a href="<?php echo BASEURL ?>user_manager/users/list" class="btn btn-primary">
<a href="<?php echo BASE_URL ?>user_manager/users/list" class="btn btn-primary">
<img src="<?php echo ASSETS ?>img/icons/users.png" alt="" class="icon" /> List Users</a>
<a href="<?php echo BASEURL ?>user_manager/users/create" class="btn btn-primary">
<a href="<?php echo BASE_URL ?>user_manager/users/create" class="btn btn-primary">
<img src="<?php echo ASSETS ?>img/icons/user--plus.png" alt="" class="icon" /> Create User</a>
</div>

Expand Down
2 changes: 1 addition & 1 deletion application/source/user_manager/views/users.create.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?
$tpl->title = 'Create User - User Manager';
\Services\System\Display::view('user_manager/menu', $data);
$this->view('user_manager/menu', $data);

$tpl->breadcrumbs = array(
array('Demo Apps', ''),
Expand Down
4 changes: 2 additions & 2 deletions application/source/user_manager/views/users.list.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?
$tpl->title = 'List Users - User Manager';
\Services\System\Display::view('user_manager/menu', $data);
$this->view('user_manager/menu', $data);

$tpl->breadcrumbs = array(
array('Demo Apps', ''),
Expand All @@ -25,7 +25,7 @@
<th style="font-weight: bold;"><?=$user->id?></th>
<td><?=$user->username?></td>
<td>
<a href="<?php echo BASEURL ?>user_manager/users/delete?id=<?=$user->id?>">
<a href="<?php echo BASE_URL ?>user_manager/users/delete?id=<?=$user->id?>">
<img src="<?php echo ASSETS ?>img/icons/cross-button.png" alt="Delete" />
</a>
</td>
Expand Down
10 changes: 5 additions & 5 deletions application/templates/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
</a>
<ul class="dropdown-menu">
<li><h3>&nbsp; Libraries</h3></li>
<li><a href="<?php echo BASEURL ?>libraries/form_validation">IXT_Form_Validation</a></li>
<li><a href="<?php echo BASEURL ?>libraries/stopwatch">IXT_Stopwatch</a></li>
<li><a href="<?php echo BASE_URL ?>libraries/form_validation">IXT_Form_Validation</a></li>
<li><a href="<?php echo BASE_URL ?>libraries/stopwatch">IXT_Stopwatch</a></li>
<li class="divider"></li>
<li><h3>&nbsp; Demo Apps</h3></li>
<li><a href="<?php echo BASEURL ?>user_manager/">User Manager</a></li>
<li><a href="<?php echo BASE_URL ?>user_manager/">User Manager</a></li>
</ul>
</div>
</li>
Expand All @@ -42,11 +42,11 @@
</div>

<ul id="breadcrumbs" class="breadcrumb">
<li><a href="<?php echo BASEURL ?>">Home</a> <span class="divider">/</span></li>
<li><a href="<?php echo BASE_URL ?>">Home</a> <span class="divider">/</span></li>
<?php foreach ($tpl->breadcrumbs as $breadcrumb): ?>
<?php list($title, $url) = $breadcrumb; ?>
<?php if (!empty($url)): ?>
<li><a href="<?php echo BASEURL . $url ?>"><?php echo $title ?></a> <span class="divider">/</span></li>
<li><a href="<?php echo BASE_URL . $url ?>"><?php echo $title ?></a> <span class="divider">/</span></li>
<?php else: ?>
<li><?php echo $title ?> <span class="divider">/</span></li>
<?php endif; ?>
Expand Down
4 changes: 3 additions & 1 deletion config_selector.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
define('CONFDIR', 'application/config/');
define('APP_DIR', 'application/');
define('SHR_DIR', 'shared/');
define('IXT_DIR', 'ignitext/');

return 'development';
24 changes: 18 additions & 6 deletions ignitext/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace Services\System;
namespace IgniteXT;

function autoload_source($class)
{
Expand All @@ -25,9 +25,9 @@ function autoload_source($class)
$filename = array_pop($parts);

$check_dirs = array(
APPDIR . 'source/',
SHRDIR . 'source/',
IXTDIR . 'source/'
APP_DIR . 'source/',
SHR_DIR . 'source/',
IXT_DIR . 'source/'
);

foreach ($check_dirs as $dir)
Expand All @@ -44,11 +44,23 @@ function autoload_source($class)
$location .= $filename . '.php';
if (file_exists($location))
{
include $location;
require $location;
return;
}
}
}
}

spl_autoload_register('\Services\System\autoload_source');
function autoload_ignitext($class)
{
$class = strtolower($class);
$parts = explode('\\', $class);

$filename = array_pop($parts);

$location = implode($parts, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $filename . '.php';
if (file_exists($location)) require $location;
}

spl_autoload_register('\IgniteXT\autoload_source');
spl_autoload_register('\IgniteXT\autoload_ignitext');
23 changes: 11 additions & 12 deletions config_loader.php → ignitext/config_loader.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

foreach (glob(CONFDIR . 'config_*.php') as $config_file) {
$mode = substr(basename($config_file), 7, -4);
$all_config[$mode] = require $config_file;
}
$all_config = array();
$all_config[$config_select] = require(APP_DIR . 'config/' . $config_select . '.php');

$maximum_inheritance = 20;
$current_inheritance = 0;
$pending_config = true;
$processed_config = array();

while (count($processed_config) < count($all_config) && $current_inheritance < $maximum_inheritance) {
while ($pending_config && $current_inheritance < $maximum_inheritance) {
$pending_config = false;
foreach ($all_config as $config_mode => $config_obj) {
if (in_array($config_mode, $processed_config)) continue;

Expand All @@ -18,24 +18,23 @@
$pending_inherits = array();
$inherit_arr = explode(',', $config_obj['inherits']);
foreach ($inherit_arr as $inherit) {
if (!isset($all_config[$inherit])) $all_config[$inherit] = require(APP_DIR . 'config/' . $inherit . '.php');

//If the inherit still has inherits of its own, wait until later to merge it in
if (!in_array($inherit, $processed_config)) $pending_inherits[] = $inherit;
else {
$all_config[$config_mode] = array_replace_recursive($all_config[$inherit], $all_config[$config_mode]);
}
else $all_config[$config_mode] = array_replace_recursive($all_config[$inherit], $all_config[$config_mode]);
}
$config_obj['inherits'] = implode(',', $pending_inherits);
}

//All the inherits have been processed
if (empty($config_obj['inherits'])) {
$processed_config[] = $config_mode;
}
if (empty($config_obj['inherits'])) $processed_config[] = $config_mode;
else $pending_config = true;
}
$current_inheritance++;
}

if (count($processed_config) != count($all_config)) throw new \Exception('Maximum config inheritance level reached.');
if ($pending_config) throw new \Exception('Maximum config inheritance level reached.');

if (empty($all_config)) return false;
return $all_config[$config_select];
47 changes: 47 additions & 0 deletions ignitext/controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Controller
*
* The base class for a controller.
*
* @copyright Copyright 2011-2012, Website Duck LLC (http://www.websiteduck.com)
* @link http://www.ignitext.com IgniteXT PHP Framework
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace IgniteXT;

abstract class Controller extends Service
{
public function __construct()
{
$this->db = \Get::the('\IgniteXT\Database');
$this->display = \Get::the('\IgniteXT\Display');
$this->router = \Get::the('\IgniteXT\Router');
$this->session_class = \Get::the('\IgniteXT\Session');
$this->session = &$this->session_class->reference();
$this->input = \Get::the('\IgniteXT\Input');
}

public function post_handler($action) { return $this->handler("POST", $action); }
public function get_handler($action) { return $this->handler("GET", $action); }
public function put_handler($action) { return $this->handler("PUT", $action); }
public function delete_handler($action) { return $this->handler("DELETE", $action); }

/**
* Run an action for a certain request method.
*
* @param string $request_method
* @param string $action
* @return boolean $action_was_ran
*/
private function handler($request_method, $action)
{
$request_method = strtolower($request_method);
if ($request_method == strtolower($_SERVER['REQUEST_METHOD'])) {
$this->$action();
return true;
}
return false;
}
}
Loading

0 comments on commit b7015de

Please sign in to comment.