diff --git a/config.php b/config.php
index a7d8cdc..1fa8430 100644
--- a/config.php
+++ b/config.php
@@ -11,7 +11,7 @@ $config = array(
// File system settings
- 'show_hidden' => true,
+ 'show_hidden' => false,
// Display settings
diff --git a/exec/core.exc.php b/exec/core.exc.php
index 634c241..eebb39d 100644
--- a/exec/core.exc.php
+++ b/exec/core.exc.php
@@ -19,18 +19,11 @@ Author: Jim Myhrberg
//>STAGE> init
//==========================
-
-//>Section> define_constants
-define('DIR_URL', $dir_url);
-define('DIR_PATH', $dir_path);
-define('QUERY_STRING', $query_string);
-
-define('DLIST_URL', $config['url']);
-define('TEMPLATE', $config['template']);
-define('TPL_URL', DLIST_URL.'templates/'.TEMPLATE.'/');
+//>Section> start_timer:10
+$timer = new speedometer();
-//>Section> port_correction
+//>Section> port_correction:20
if ( stristr($_SERVER['HTTP_HOST'], ':') !== false ) {
$http_host = explode(':', $_SERVER['HTTP_HOST'], 2);
$_SERVER['SERVER_PORT'] = $http_host[1];
@@ -40,9 +33,22 @@ preg_match("/(.*)Port [0-9]{2,8}(.*)/", $_SERVER['SERVER_SIGNATURE'], $serverinf
$_SERVER['SERVER_SIGNATURE'] = $serverinfo[1].'Port '.$_SERVER['SERVER_PORT'].$serverinfo[2];
-//>Section> set_vars
+//>Section> define_constants:30
+define('DIR_URL', $dir_url);
+define('DIR_PATH', $dir_path);
+define('QUERY_STRING', $query_string);
+
+define('DLIST_URL', $config->url);
+define('TEMPLATE', $config->template);
+define('TPL_PATH', 'templates/'.TEMPLATE.'/');
+define('TPL_URL', DLIST_URL.TPL_PATH);
+
+
+//>Section> dynamic_vars
$do_readdir = true;
$do_render = true;
+$do_sort_items = true;
+$do_sort_reverse = false;
//==========================
@@ -50,21 +56,32 @@ $do_render = true;
//==========================
-//>Section> init_dList
+//>Section> readdir
if ( $do_readdir ) {
+ //>Section> readdir.start
$dlist = new dirlist();
- if ($config['show_hidden']) $dlist->show_hidden = true;
+ //>Section> readdir.options
+ if ( empty($do_sort_items) ) {
+ $dlist->sort_items = false;
+ } elseif (!empty($do_sort_reverse)) $dlist->reverse = true;
+ if ($config->show_hidden) $dlist->show_hidden = true;
+ //>Section> readdir.read
$dlist->read(DIR_PATH);
+ //>Section> readdir.end
}
-
//==========================
//>STAGE> render
//==========================
+//>Section> end_timer:10
+$timer->end();
+
+
//>Section> echo
print_r($dlist->list);
+print_r($config);
//_END;
diff --git a/libs/config.lib.php b/libs/config.lib.php
new file mode 100644
index 0000000..d9a089b
--- /dev/null
+++ b/libs/config.lib.php
@@ -0,0 +1,64 @@
+parse($input);
+ }
+
+ function parse ($input, $overwrite=true) {
+ if ( is_array($input) ) {
+ $this->parse_array($input, $overwrite);
+ } elseif ( is_string($input) ) {
+ if ( preg_match("/.php$/", $input) ) {
+ $this->parse_php_file($input, 'config', $overwrite);
+ } else {
+ $this->parse_ini_file($input);
+ }
+ }
+ }
+
+ function parse_array ($input, $overwrite=true) {
+ if ( is_array($input) ) {
+ foreach( $input as $key => $value ) {
+ if ( is_array($value) ) {
+ foreach( $value as $k => $v ) {
+ if ( ($empty = empty($this->$key)) || $overwrite ) {
+ $this->$key = ( $empty ) ? array($k=>$v) : array_merge($this->$key, array($k=>$v)) ;
+ }
+ }
+ } else {
+ if ( $overwrite || empty($this->$key) ) $this->$key = $value;
+ }
+ }
+ return true;
+ } else return false;
+ }
+
+ function parse_php_file ($file, $var='config', $overwrite=true) {
+ if ( is_readable($file) ) {
+ include($file);
+ $this->parse_array($$var, $overwrite);
+ return true;
+ } else return false;
+ }
+
+ function parse_ini_file ($file, $overwrite=true) {
+ if ( is_readable($file) ) {
+ $this->parse_array(parse_ini_file($file, true), $overwrite);
+ }
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/libs/dirlist.lib.php b/libs/dirlist.lib.php
index 0b7b533..90820b9 100644
--- a/libs/dirlist.lib.php
+++ b/libs/dirlist.lib.php
@@ -18,7 +18,7 @@ class dirlist {
// Sorting
var $sort_items = true;
- var $sort_reverse = false;
+ var $reverse = false;
// Smart date formatting
var $smartdate = '{date}, {time}';
@@ -73,7 +73,7 @@ class dirlist {
}
}
if ( $this->sort_items ) {
- ( $this->sort_reverse ) ? krsort($this->list) : ksort($this->list) ;
+ ( $this->reverse ) ? krsort($this->list) : ksort($this->list) ;
}
return true;
}else{ $this->error = true; return false; }
diff --git a/libs/exechandler.lib.php b/libs/exechandler.lib.php
index 6bde4e6..ace3748 100644
--- a/libs/exechandler.lib.php
+++ b/libs/exechandler.lib.php
@@ -122,6 +122,7 @@ class execHandler {
} elseif( is_string($input) ) {
$result = glob($input);
}
+ $result = array_filter($result);
if ( is_array($result) ) $result = array_unique($result);
$this->files_to_load = array_merge($this->files_to_load, $result);
}
diff --git a/templates/simple/render.exc.php b/templates/simple/render.exc.php
index 6aedcfa..abc1be2 100644
--- a/templates/simple/render.exc.php
+++ b/templates/simple/render.exc.php
@@ -20,6 +20,9 @@ Author: Jim Myhrberg
//==========================
+//>After> core.define_constants
+$config->parse(TPL_PATH.'settings.php');
+
//_END;
?>
\ No newline at end of file
diff --git a/templates/simple/settings.php b/templates/simple/settings.php
new file mode 100644
index 0000000..a2615c4
--- /dev/null
+++ b/templates/simple/settings.php
@@ -0,0 +1,7 @@
+ 'simple',
+ );
+
+?>
\ No newline at end of file
diff --git a/view.php b/view.php
index 022a0a2..5e410ae 100644
--- a/view.php
+++ b/view.php
@@ -12,32 +12,45 @@
require_once('config.php');
require_once('resources/init.php');
require_once('libs/speedometer.lib.php');
+require_once('libs/config.lib.php');
require_once('libs/dirlist.lib.php');
require_once('libs/exechandler.lib.php');
-$time = new speedometer();
+
+// initialize config object
+$config = new config($config);
+// initialize debug stopwatch
+if ($config->debug) $debug_time = new speedometer();
+
+
+// initialize execHandler and main scripts
$exec = new execHandler();
$exec->cache_dir = 'cache/exec/';
-if ( $config['debug'] ) {
- $exec->debug = true;
- $exec->update_frequency = 0;
-}
+
+// debug?
+if ( $config->debug ) $exec->debug = true;
+
+// paths to load
$exec->addPath(
array(
'exec/core.exc.php',
- 'templates/'.$config['template'].'/render.exc.php',
+ 'exec/*',
+ 'templates/'.$config->template.'/render.exc.php',
'plugins/*.exc.php',
)
);
$exec->cache();
include($exec->include_file);
-print_r($exec->execution_order);
-$time->end();
-if ($config['debug']) echo "
\npage generated in ".$time->time." sec.
\n";
+if ($config->debug) {
+ $debug_time->end();
+ echo "
\npage generated in ".$debug_time->time." sec.
\n";
+}
+
+
?>
\ No newline at end of file