Skip to content

Commit

Permalink
Lot of changes. v0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gintsmurans committed Oct 21, 2015
1 parent baa5dd9 commit 64e4b7a
Show file tree
Hide file tree
Showing 49 changed files with 1,596 additions and 375 deletions.
13 changes: 6 additions & 7 deletions .gitignore
@@ -1,10 +1,9 @@
CHANGELOG.md
/tmp/
/vendor/
/application/cache/*/
/application/public/assets/vendor/
/composer.lock
/application/public/docs/
/Vendor/
/Application/Cache/
/Application/Public/assets/vendor/
/Application/Public/uploads/
/Application/Public/xhprof/
/Application/Public/docs/


# OS generated files #
Expand Down
35 changes: 18 additions & 17 deletions application/config/config.php → Application/Config/Config.php
Expand Up @@ -18,26 +18,27 @@

$config['base_url'] = null; // NULL for auto detect


/*
|--------------------------------------------------------------------------
| Debug
|--------------------------------------------------------------------------
*/

// Set environment
$config['environment'] = ((empty($_SERVER['app_env']) || $_SERVER['app_env'] !== 'dev') && php_sapi_name() != 'cli-server' ? 'live' : 'dev');

// Set debug
$config['debug'] = ($config['environment'] !== 'dev' ? false : true);

// List of ip addresses where debug will be turned on by default
$config['debug_ips'] = ['::1', '127.0.0.1'];
$config['env'] = (
(empty($_SERVER['app_env']) || $_SERVER['app_env'] !== 'dev') &&
php_sapi_name() != 'cli-server' ? 'live' : 'dev'
);
$config['debug'] = ($config['env'] !== 'dev' ? false : true);
$config['debug_ips'] = ['::1', '127.0.0.1'];

/*
| Send errors to this email address.
|
| * Core will only send error emails when debug is turned off.
| * Emails are sent using php's mail function, if you intend to use this feature, make sure your system is configured to be able to send emails.
| * Emails are sent using php's mail function, if you intend to use this feature,
| make sure your system is configured to be able to send emails.
*/
$config['debug_email'] = null;

Expand All @@ -50,17 +51,17 @@
|--------------------------------------------------------------------------
*/

$config['request_uri'] = & $_SERVER['REQUEST_URI'];
$config['request_uri'] = & $_SERVER['REQUEST_URI'];
$config['query_string'] = & $_SERVER['QUERY_STRING'];
$config['script_name'] = & $_SERVER['SCRIPT_NAME'];
$config['client_ip'] = & $_SERVER['REMOTE_ADDR'];
$config['script_name'] = & $_SERVER['SCRIPT_NAME'];
$config['client_ip'] = & $_SERVER['REMOTE_ADDR'];

/*
|--------------------------------------------------------------------------
| Uris
|
| URL prefixes can be useful when for example identifying ajax requests,
| they will be stored in config variable and can be checked with router::hasPrefix('ajax') === true
| they will be stored in config variable and can be checked with Router::hasPrefix('ajax') === true
| they must be in correct sequence. For example, if url is /ajax/test/en/open/29, where ajax and test is prefixes,
| then array should look something like this - ['ajax', 'test']. In this case /test/en/open/29 will also work.
|--------------------------------------------------------------------------
Expand All @@ -72,20 +73,20 @@
| Autoload
|
| Place filenames without ".php" extension here to autoload various files and classes
| To auto-load files from other projects as well from system, use ['db' => 'system']
| Possible formats: Application/Module/Filename, Module/Filename, Filename (only to load global config)
|--------------------------------------------------------------------------
*/

$config['autoload_configs'] = [];
$config['autoload_models'] = [];
$config['autoload_helpers'] = ['system'];
$config['autoload_helpers'] = ['Defaults/Bootstrap'];

/*
|--------------------------------------------------------------------------
| Hooks
|
| Currently only "before controller" hook is supported and will be called right before including controller file.
| It passes three parametrs as references - $file, $class and $mehthod, meaning callback can override current controller.
| Currently only "before controller" hook is supported and will be called right
| before including controller file. It passes three parametrs as references - $file,
| $class and $method, meaning callback can override current controller.
|--------------------------------------------------------------------------
*/

Expand Down
Expand Up @@ -4,7 +4,7 @@
|--------------------------------------------------------------------------
| Routing
|
| Each next item overrides current one
| Each next item overrides last one
| Format: 'regular expression'[without starting slash] => 'new URL'
| Leave '' for default controller
|--------------------------------------------------------------------------
Expand All @@ -13,7 +13,7 @@
$config['routing'] = [

// Default Controller and Method names
'' => 'home/index',
'' => 'Defaults/Welcome/index',

// Rest of the routing
# '^([0-9]+)$' => 'orders/details/$1' # Example rewrite: http://example.com/1234 -> http://example.com/orders/details/1234
Expand Down
File renamed without changes.
@@ -1,8 +1,8 @@
<?php

namespace controllers\test;
namespace Defaults\Controllers\Test;

class test1
class Test1
{
public static function index()
{
Expand Down
16 changes: 16 additions & 0 deletions Application/Modules/Defaults/Controllers/Test/TestSecond.php
@@ -0,0 +1,16 @@
<?php

namespace Defaults\Controllers\Test;

class TestSecond
{
public static function index()
{
echo 'TestSecond::index: YES';
}

public static function testMe()
{
echo 'TestSecond::testMe: YES';
}
}
@@ -1,14 +1,15 @@
<?php

namespace controllers;
namespace Defaults\Controllers;

use \core\load;
use \Core\Controllers\Controller;
use \Core\Models\Load;

/**
* StaticPHP's base controller.
* Welcome page controller.
*/

class home
class Welcome extends Controller
{
/**
* A method to be called on every call, regardless of current request handler method.
Expand All @@ -22,8 +23,11 @@ class home
* @param string & $method
* @return void
*/
public static function construct(& $class, & $method)
public static function construct(& $class = null, & $method = null)
{
// (Optionally) Call parent construct for view rendering and
// access to self::$controller_url and self::$controller_url variables
parent::construct($class, $method);
}

/**
Expand All @@ -43,11 +47,13 @@ public static function construct(& $class, & $method)
public static function index($param1 = null, $param2 = null)
{
// Do something heavy and add timer mark
load::markTime('Before views');
Load::markTime('Before views');

// Load view
// Pass [key => value] as second parameter, to get variables available in your view
load::view('home/index.html');
self::render('index.html');

// Or call Load::view('Defaults/Views/index.html');
}

/**
Expand All @@ -59,6 +65,6 @@ public static function index($param1 = null, $param2 = null)
*/
public static function help()
{
load::view('home/help.html');
Load::view('Defaults/Views/help.html');
}
}
38 changes: 38 additions & 0 deletions Application/Modules/Defaults/Helpers/Bootstrap.php
@@ -0,0 +1,38 @@
<?php

// This is the right place to set headers, start a session, etc.

use \Core\Models\Load;

// Send content type and charset header
header('Content-type: text/html; charset=utf-8');


// CLI Access
if (!empty($GLOBALS['argv'][1])) {
Load::$config['request_uri'] =& $GLOBALS['argv'][1];
}


// Set locales
// setlocale(LC_TIME, 'lv_LV.utf8', 'lv_LV.UTF-8');
// setlocale(LC_NUMERIC, 'lv_LV.utf8', 'lv_LV.UTF-8');
// setlocale(LC_CTYPE, 'lv_LV.utf8', 'lv_LV.UTF-8');
// date_default_timezone_set('Europe/Riga');


// Init db - Before uncommenting add at the use secion: "use \Core\Models\Db;"
// Db::init();


// Start session
/*
session_set_cookie_params(0);
session_name('MY_SESSION_NAME');
session_start();
*/


// Load js and css versions. These can be loaded from database or some cache.
load::$config['view_data']['css_version'] = 1;
load::$config['view_data']['js_version'] = 1;
@@ -1,4 +1,4 @@
{% extends "layout.html" %}
{% extends "Defaults/Views/layout.html" %}

{% block content %}
<div class="content">
Expand Down
@@ -1,11 +1,12 @@
{% extends "layout.html" %}
{% extends "Defaults/Views/layout.html" %}

{% block content %}
<h1>Welcome!</h1>

This is your first page.<br /><br />

<a href="{{ 'home/help'|siteUrl }}">Help page</a><br />
<a href="{{ base_url }}defaults/welcome/help">Help page</a><br />

{% if config.debug %}
<em>* Turning off debug mode will hide help navigation item.</em>
{% endif %}
Expand Down
Expand Up @@ -9,8 +9,13 @@

<title>StaticPHP Framework</title>

<link href="{{ base_url }}assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="{{ base_url }}assets/home/style.css" rel="stylesheet" type="text/css" />
{% if config.debug %}
<link href="{{ base_url }}assets/vendor/bootstrap/css/bootstrap.css?{{ css_version }}" rel="stylesheet" type="text/css" />
<link href="{{ base_url }}assets/base/css/style.css?{{ css_version }}" rel="stylesheet" type="text/css" />
{% else %}
<link href="{{ base_url }}assets/vendor/bootstrap/css/bootstrap.min.css?{{ css_version }}" rel="stylesheet" type="text/css" />
<link href="{{ base_url }}assets/min/css/style.min.css?{{ css_version }}" rel="stylesheet" type="text/css" />
{% endif %}

{% block headers %}{% endblock %}
</head>
Expand All @@ -24,9 +29,9 @@
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li{{ method == 'index' ? ' class="active"' }}><a href="{{ base_url }}home">Start page</a></li>
<li{{ method == 'index' ? ' class="active"' }}><a href="{{ base_url }}">Start page</a></li>
{% if config['debug'] == true %}
<li{{ method == 'help' ? ' class="active"' }}><a href="{{ base_url }}home/help">Help</a></li>
<li{{ method == 'help' ? ' class="active"' }}><a href="{{ base_url }}defaults/welcome/help">Help</a></li>
{% endif %}
</ul>
</div><!--/.nav-collapse -->
Expand All @@ -37,8 +42,12 @@
{% block content %}{% endblock%}
</div>

<script src="{{ base_url }}assets/vendor/jquery/jquery.min.js"></script>
<script src="{{ base_url }}assets/vendor/bootstrap/js/bootstrap.min.js"></script>
{% if config.debug %}
<script src="{{ base_url }}assets/vendor/jquery/jquery.js?{{ js_version }}"></script>
<script src="{{ base_url }}assets/vendor/bootstrap/js/bootstrap.js?{{ js_version }}"></script>
{% else %}
<script src="{{ base_url }}assets/min/js/main.min.js?{{ js_version }}"></script>
{% endif %}

{% block scripts %}{% endblock%}

Expand Down
Expand Up @@ -7,7 +7,7 @@

## Avoid opening config
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^config/.*$ index.php/$1 [L]
RewriteRule ^Config/.*$ index.php/$1 [L]

# RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions Application/Public/assets/min/css/style.min.css
@@ -0,0 +1 @@
footer.page-footer{background:#F1F1F1;padding:20px 25px;margin-top:100px}
8 changes: 8 additions & 0 deletions Application/Public/assets/min/js/main.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Application/Public/assets/min/js/main.min.js.map

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions Application/Public/index.php
@@ -0,0 +1,12 @@
<?php

// Define paths
define('PUBLIC_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
define('APP_PATH', dirname(PUBLIC_PATH).DIRECTORY_SEPARATOR);
define('APP_MODULES_PATH', APP_PATH.'Modules'.DIRECTORY_SEPARATOR);
define('BASE_PATH', dirname(APP_PATH).DIRECTORY_SEPARATOR);
define('SYS_PATH', BASE_PATH.'System'.DIRECTORY_SEPARATOR);
define('SYS_MODULES_PATH', SYS_PATH.'Modules'.DIRECTORY_SEPARATOR);

// Load core class
require SYS_PATH.'Modules/Core/Helpers/Bootstrap.php'; // Load

0 comments on commit 64e4b7a

Please sign in to comment.