Permalink
Browse files

Remove constant SEP.

  • Loading branch information...
1 parent f8f2297 commit 6b82d0fa7951202ebbed35074097143322ba33ad @Seza Seza committed Mar 20, 2012
View
@@ -36,13 +36,12 @@
// Step 2. A little of constant creation
-defined('VERSION') or define('VERSION', '0.0.1', true);
-defined('SEP') or define('SEP', DIRECTORY_SEPARATOR, true);
-defined('ROOT_PATH') or define('ROOT_PATH', dirname(__DIR__), true);
-defined('APP_PATH') or define('APP_PATH', ROOT_PATH . SEP . 'app', true);
-defined('CORE_PATH') or define('CORE_PATH', APP_PATH . SEP . 'core', true);
-defined('PLUG_PATH') or define('PLUG_PATH', APP_PATH . SEP . 'plugins', true);
-defined('PRIV_PATH') or define('PRIV_PATH', ROOT_PATH . SEP . 'private', true);
+defined('VERSION') or define('VERSION', '0.0.1', true);
+defined('ROOT_PATH') or define('ROOT_PATH', dirname(__DIR__), true);
+defined('APP_PATH') or define('APP_PATH', ROOT_PATH . '/app', true);
+defined('CORE_PATH') or define('CORE_PATH', APP_PATH . '/core', true);
+defined('PLUG_PATH') or define('PLUG_PATH', APP_PATH . '/plugins', true);
+defined('PRIV_PATH') or define('PRIV_PATH', ROOT_PATH . '/private', true);
// Step 3. A little of error handling
set_error_handler(function ($errno, $errstr, $errfile, $errline)
@@ -87,15 +86,15 @@
if (substr($class, 0, $len) != $ns) return false;
// remove the main namespace of the class name and apply psr-0
- $file = APP_PATH . str_replace('\\', SEP, substr($class, $len)) . '.php';
+ $file = APP_PATH . str_replace('\\', '/', substr($class, $len)) . '.php';
is_file($file) and require_once $file;
return class_exists($name);
});
// Step 5. We need to parse the config file and set properly the environnement
-$conf = Config::load(PRIV_PATH . SEP . 'config.json');
+$conf = Config::load(PRIV_PATH . '/config.json');
// Debug can also be switched on by setting the Apache envrionment
// variable `APPLICATION_ENV` to `development` in .htaccess
@@ -112,7 +111,7 @@
// Step 6. Check auto update if needed
if (Filter::compare_version($conf->version, VERSION))
{
- require_once APP_PATH . SEP . 'update.php';
+ require_once APP_PATH . '/update.php';
}
// Step 7. Registers activated plugins
View
@@ -33,7 +33,7 @@ class Db extends SQLite3
{
if (!is_null(static::$_instance)) throw Error::create(10);
- $this->open(static::$_database ?: PRIV_PATH . SEP . 'sqlite3.db');
+ $this->open(static::$_database ?: PRIV_PATH . '/sqlite3.db');
static::$_instance = $this;
}
View
@@ -115,7 +115,7 @@ public static function get_file($plugin)
{
Filter::is_string($plugin);
- return PLUG_PATH . SEP . $plugin . SEP . static::PLUG_FILE;
+ return PLUG_PATH . '/' . $plugin . '/' . static::PLUG_FILE;
}
/**
@@ -195,7 +195,7 @@ public static function detect()
while (false !== $file = readdir($rd))
{
- $f = PLUG_PATH . SEP . $file;
+ $f = PLUG_PATH . '/' . $file;
if (!is_dir($f) || $file == '.' || $file == '..') continue;
@@ -232,7 +232,7 @@ public static function clean($plugin)
$conf->save();
- $path = PLUG_PATH . SEP . $plugin;
+ $path = PLUG_PATH . '/' . $plugin;
foreach(new RII(new RDI($path), RII::CHILD_FIRST) as $file)
{
View
@@ -42,8 +42,8 @@ class Template
public static function create()
{
$tpl = new static;
- $tpl->set_template_path(PLUG_PATH . SEP);
- $tpl->set_template_cache_path(PRIV_PATH . SEP . 'cache' . SEP);
+ $tpl->set_template_path(PLUG_PATH);
+ $tpl->set_template_cache_path(PRIV_PATH . '/cache');
return $tpl;
}
@@ -71,7 +71,7 @@ public function set_template_path($path)
{
Filter::assume_string($var);
- $this->_tplPath = $path . ((substr($path, -1) == SEP) ? '' : SEP);
+ $this->_tplPath = $path;
return $this;
}
@@ -85,7 +85,7 @@ public function set_template_cache_path($path)
{
Filter::assume_string($var);
- $this->_tplCache = $path . ((substr($path, -1) == SEP) ? '' : SEP);
+ $this->_tplCache = $path;
return $this;
}
@@ -425,10 +425,8 @@ public function render($templateFile)
try
{
- $templateFile = str_replace('/', SEP, $templateFile);
-
- $tpl = $this->_tplPath . $templateFile;
- $cache = $this->_tplCache . $templateFile;
+ $tpl = $this->_tplPath . '/' . $templateFile;
+ $cache = $this->_tplCache . '/' . $templateFile;
if (!file_exists($tpl)) throw new Error(16, array($tpl));
@@ -491,11 +491,11 @@ public function make_extends()
if (is_null($filename)) return;
- $filename = str_replace('/', SEP, trim($filename));
+ $filename = trim($filename);
if ($filename == '') throw Error::create(20);
- $file = $this->path . $filename;
+ $file = $this->path . '/' . $filename;
if (!file_exists($file)) throw Error::create(21, array($file));
@@ -529,11 +529,11 @@ public function make_include()
foreach($includes as $id => $include)
{
- $filename = str_replace('/', SEP, trim($include));
+ $filename = trim($include);
if ($filename == '') throw Error::create(22);
- $file = $this->path . $filename;
+ $file = $this->path . '/' . $filename;
if (!file_exists($file)) throw Error::create(23, array($file));
View
@@ -14,22 +14,19 @@
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300)
{
// use dirname(__FILE__) here because __DIR__ exists since PHP 5.3.0
- include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup'
- . DIRECTORY_SEPARATOR . 'tpl'
- . DIRECTORY_SEPARATOR . 'step0-fail.tpl';
-
+ include dirname(__FILE__) . 'setup/tpl/step0-fail.tpl';
exit();
}
try
{
- require_once __DIR__ . DIRECTORY_SEPARATOR . 'bootstrap.php';
+ require_once __DIR__ . '/bootstrap.php';
}
-// we can't use pixelpost\core\Error here because we consider we can be in PHP < 5.3
-// so namespace can't be used.
catch(Exception $e)
{
- // use get_class instead of is_a() or instanceof because is_a() throw
+ // we can't use pixelpost\core\Error here because we consider we can be in PHP < 5.3
+ // so namespace can't be used.
+ // use get_class() instead of is_a() or instanceof because is_a() throw
// a E_STRICT between PHP5.0.0 and PHP 5.3.0 and instanceof exists since
// PHP 5.0.0 (and instanceof can call __autoload() before PHP 5.1.0)
if (get_class($e) == 'pixelpost\core\Error' && $e->getCode() == 3) $isConfFileExists = false;
@@ -43,10 +40,6 @@
switch($step)
{
- case 1:
- require __DIR__ . SEP . 'setup' . SEP . 'step1.php';
- break;
- case 2:
- require __DIR__ . SEP . 'setup' . SEP . 'step2.php';
- break;
+ case 1: require __DIR__ . '/setup/step1.php'; break;
+ case 2: require __DIR__ . '/setup/step2.php'; break;
}
@@ -10,17 +10,17 @@ class Page
{
public static function page_index(Event $event)
{
- require __DIR__ . SEP . 'page' . SEP . 'home.php';
+ require __DIR__ . '/page/home.php';
}
public static function page_404(Event $event)
{
- require __DIR__ . SEP . 'page' . SEP . '404.php';
+ require __DIR__ . '/page/404.php';
}
public static function page_api_test(Event $event)
{
- require __DIR__ . SEP . 'page' . SEP . 'api_test.php';
+ require __DIR__ . '/page/api_test.php';
}
public static function template_nav_phpinfo(Event $event)
@@ -44,6 +44,6 @@ public static function page_api_bridge(Event $event)
public static function page_account(Event $event)
{
- require __DIR__ . SEP . 'admin' . SEP . 'account.php';
+ require __DIR__ . '/admin/account.php';
}
}
@@ -133,126 +133,126 @@ public static function auth_version(Event $event)
public static function auth_request(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_request.php';
+ require __DIR__ . '/api/auth_request.php';
}
public static function auth_token(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_token.php';
+ require __DIR__ . '/api/auth_token.php';
}
public static function auth_refresh(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_refresh.php';
+ require __DIR__ . '/api/auth_refresh.php';
}
public static function auth_destroy(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_destroy.php';
+ require __DIR__ . '/api/auth_destroy.php';
}
public static function auth_config_get(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_config_get.php';
+ require __DIR__ . '/api/auth_config_get.php';
}
public static function auth_config_set(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_config_set.php';
+ require __DIR__ . '/api/auth_config_set.php';
}
public static function auth_user_add(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_user_add.php';
+ require __DIR__ . '/api/auth_user_add.php';
}
public static function auth_user_set(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_user_set.php';
+ require __DIR__ . '/api/auth_user_set.php';
}
public static function auth_user_get(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_user_get.php';
+ require __DIR__ . '/api/auth_user_get.php';
}
public static function auth_user_del(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_user_del.php';
+ require __DIR__ . '/api/auth_user_del.php';
}
public static function auth_user_list(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_user_list.php';
+ require __DIR__ . '/api/auth_user_list.php';
}
public static function auth_user_grant_add(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_user_grant_add.php';
+ require __DIR__ . '/api/auth_user_grant_add.php';
}
public static function auth_user_grant_del(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_user_grant_del.php';
+ require __DIR__ . '/api/auth_user_grant_del.php';
}
public static function auth_entity_add(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_entity_add.php';
+ require __DIR__ . '/api/auth_entity_add.php';
}
public static function auth_entity_set(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_entity_set.php';
+ require __DIR__ . '/api/auth_entity_set.php';
}
public static function auth_entity_get(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_entity_get.php';
+ require __DIR__ . '/api/auth_entity_get.php';
}
public static function auth_entity_del(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_entity_del.php';
+ require __DIR__ . '/api/auth_entity_del.php';
}
public static function auth_entity_list(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_entity_list.php';
+ require __DIR__ . '/api/auth_entity_list.php';
}
public static function auth_entity_grant_add(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_entity_grant_add.php';
+ require __DIR__ . '/api/auth_entity_grant_add.php';
}
public static function auth_entity_grant_del(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_entity_grant_del.php';
+ require __DIR__ . '/api/auth_entity_grant_del.php';
}
public static function auth_grant_add(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_grant_add.php';
+ require __DIR__ . '/api/auth_grant_add.php';
}
public static function auth_grant_set(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_grant_set.php';
+ require __DIR__ . '/api/auth_grant_set.php';
}
public static function auth_grant_get(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_grant_get.php';
+ require __DIR__ . '/api/auth_grant_get.php';
}
public static function auth_grant_del(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_grant_del.php';
+ require __DIR__ . '/api/auth_grant_del.php';
}
public static function auth_grant_list(Event $event)
{
- require __DIR__ . SEP . 'api' . SEP . 'auth_grant_list.php';
+ require __DIR__ . '/api/auth_grant_list.php';
}
}
@@ -49,8 +49,8 @@ public static function error_new(Event $event)
{
$error = $event->exception;
- if (DEBUG) include __DIR__ . SEP . 'tpl' . SEP . 'error_debug.php';
- else include __DIR__ . SEP . 'tpl' . SEP . 'error.php';
+ if (DEBUG) include __DIR__ . '/tpl/error_debug.php';
+ else include __DIR__ . '/tpl/error.php';
// we need to stop the script, if not, PHP understand that the exception
// was not caugth. And raise an error:
@@ -31,6 +31,6 @@ public static function template_widget(Event $event)
public static function page_index(Event $event)
{
- require __DIR__ . SEP . 'admin' . SEP . 'home.php';
+ require __DIR__ . '/admin/home.php';
}
}
Oops, something went wrong.

2 comments on commit 6b82d0f

@jaywilliams
Member

That cleans up the quite quite a lot, and makes it easier to read. It's a win-win for sure!

@Seza
Member
Seza commented on 6b82d0f Mar 20, 2012

Thank you Jay, I’m totally agree with you. After doing the change all seems lighter, more readable and understandable.

Please sign in to comment.