diff options
author | Volker Thiel <riker09@gmx.de> | 2013-03-06 17:29:57 +0100 |
---|---|---|
committer | Volker Thiel <riker09@gmx.de> | 2013-03-06 17:29:57 +0100 |
commit | 5153e6d529c85be719f6172d77652b8adc5d9f8d (patch) | |
tree | 68372e404b61e41cfaa1d9dcb8a540e34f9ed694 | |
parent | 5401ac6ec6da5ad70c5ca73753447cca859699a2 (diff) | |
download | PHPixie-5153e6d529c85be719f6172d77652b8adc5d9f8d.zip PHPixie-5153e6d529c85be719f6172d77652b8adc5d9f8d.tar.gz PHPixie-5153e6d529c85be719f6172d77652b8adc5d9f8d.tar.bz2 |
Applied some code guidelines
-rw-r--r-- | .htaccess | 3 | ||||
-rw-r--r-- | application/config/core.php | 16 | ||||
-rw-r--r-- | system/classes/misc.php | 103 |
3 files changed, 68 insertions, 54 deletions
@@ -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;
+ }
+}
|