summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.htaccess3
-rw-r--r--application/config/core.php16
-rw-r--r--system/classes/misc.php103
3 files changed, 68 insertions, 54 deletions
diff --git a/.htaccess b/.htaccess
index d93c0c4..e03a30f 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,7 +1,10 @@
RewriteEngine On
+
RewriteBase /
+
RewriteCond %{DOCUMENT_ROOT}/web/%{REQUEST_URI} -f
RewriteRule ^(.*)$ /web/$1 [L,QSA]
+
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php?$0 [PT,L,QSA]
diff --git a/application/config/core.php b/application/config/core.php
index cbd0582..ce980fa 100644
--- a/application/config/core.php
+++ b/application/config/core.php
@@ -1,12 +1,12 @@
<?php
return array(
- 'routes' => array(
- array('default', '(/<controller>(/<action>(/<id>)))', array(
- 'controller' => 'home',
- 'action' => 'index'
- )
- )
- ),
- 'modules' => array('database', 'orm','cache')
+ 'routes' => array(
+ array('default', '(/<controller>(/<action>(/<id>)))', array(
+ 'controller' => 'home',
+ 'action' => 'index'
+ )
+ ),
+ ),
+ 'modules' => array('database', 'orm', 'cache'),
);
diff --git a/system/classes/misc.php b/system/classes/misc.php
index 0696861..65f2ec6 100644
--- a/system/classes/misc.php
+++ b/system/classes/misc.php
@@ -4,61 +4,72 @@
* Miscellaneous useful functions.
* @package Core
*/
-class Misc{
-
+class Misc
+{
/**
* Retrieve value from array by key, with default value support.
- *
- * @param array $array Input array
+ *
+ * @param array $array Input array
* @param string $key Key to retrieve from the array
- * @param mixed $default Default value to return if the key is not found
- * @return mixed An array value if it was found or default value if it is not
- * @access public
- * @static
+ * @param mixed $default Default value to return if the key is not found
+ * @return mixed An array value if it was found or default value if it is not
+ * @access public
+ * @static
*/
- public static function arr($array,$key,$default=null){
- if (isset($array[$key]))
- return $array[$key];
- return $default;
- }
+ public static function arr($array,$key,$default=null)
+ {
+ if (isset($array[$key]))
+ {
+ return $array[$key];
+ }
+ return $default;
+ }
/**
* Finds full path to a specified file
- * It will search in the /application folder first, then in all enabled modules
- * and then the /system folder
- *
+ * It will search in the /application folder first, then in all enabled modules
+ * and then the /system folder
+ *
* @param string $subfolder Subfolder to search in e.g. 'classes' or 'views'
* @param string $name Name of the file without extension
- * @param string $extension File extension
- * @param boolean $return_all If 'true' returns all mathced files as array,
- * otherwise returns the first file found
+ * @param string $extension File extension
+ * @param boolean $return_all If 'true' returns all mathced files as array,
+ * otherwise returns the first file found
* @return mixed Full path to the file or False if it is not found
- * @access public
- * @static
+ * @access public
+ * @static
*/
- public static function find_file($subfolder, $name, $extension = 'php', $return_all = false ) {
-
- $folders = array(APPDIR);
-
- foreach(Config::get('core.modules',array()) as $module)
- $folders[] = MODDIR.$module.'/';
- $folders[] = SYSDIR;
+ public static function find_file($subfolder, $name, $extension = 'php', $return_all = false )
+ {
+ $folders = array(APPDIR);
+
+ foreach(Config::get('core.modules', array()) as $module)
+ {
+ $folders[] = MODDIR.$module.'/';
+ }
+ $folders[] = SYSDIR;
+
+ $fname = $name.'.'.$extension;
+ $found_files = array();
+
+ foreach ($folders as $folder)
+ {
+ $file = $folder.$subfolder.'/'.$fname;
+ if (file_exists($file))
+ {
+ if (!$return_all)
+ {
+ return($file);
+ }
+ $found_files[] = $file;
+ }
+ }
+
+ if (!empty($found_files))
+ {
+ return $found_files;
+ }
- $fname=$name.'.'.$extension;
- $found_files = array();
-
- foreach($folders as $folder) {
- $file = $folder.$subfolder.'/'.$fname;
- if (file_exists($file)) {
- if(!$return_all)
- return($file);
- $found_files[]=$file;
- }
- }
-
- if(!empty($found_files))
- return $found_files;
-
- return false;
- }
-} \ No newline at end of file
+ return false;
+ }
+}