Changeset 2315

Show
Ignore:
Timestamp:
12/19/10 10:31:41 (17 months ago)
Author:
petsagouris
Message:

[Branch 1.5] Adding FileSystem class for file and folder operations. Fixing the usage of the Debug class in the core.
Removing the functions/funcs.files.php since there are no more functions in there anymore.
Fixing the admin_default theme to use the FileSystem class.

Location:
branches/1.5
Files:
1 added
1 removed
7 modified

Legend:

Unmodified
Added
Removed
  • branches/1.5/Hotaru.php

    r2313 r2315  
    286286        } 
    287287 
    288  
    289 /* ************************************************************* 
    290  * 
    291  *  PAGE HANDLING FUNCTIONS 
    292  * 
    293  * *********************************************************** */ 
    294  
     288        ############################# 
     289        ## PAGE HANDLING FUNCTIONS ## 
     290        ############################# 
     291         
    295292        /** 
    296293         * Set the homepage (and set page name) 
     
    433430 
    434431 
    435 /* ************************************************************* 
    436  * 
    437  *  BREADCRUMB FUNCTIONS 
    438  * 
    439  * *********************************************************** */ 
    440  
     432        ########################## 
     433        ## BREADCRUMB FUNCTIONS ## 
     434        ########################## 
    441435 
    442436        /** 
     
    463457        } 
    464458 
    465  
    466  /* ************************************************************* 
    467  * 
    468  *  USERAUTH FUNCTIONS / USERBASE FUNCTIONS 
    469  * 
    470  * *********************************************************** */ 
    471  
     459        ################################### 
     460        ## USERAUTH / USERBASE FUNCTIONS ## 
     461        ################################### 
     462         
    472463        /* UserBase & UserAuth functions should be called directly if you want to 
    473464           retain the user object being used. E.g. 
     
    638629        } 
    639630 
    640  
    641  /* ************************************************************* 
    642  * 
    643  *  USERINFO FUNCTIONS 
    644  * 
    645  * *********************************************************** */ 
    646  
     631        ######################## 
     632        ## USERINFO FUNCTIONS ## 
     633        ######################## 
    647634 
    648635        /** 
     
    810797        } 
    811798 
    812  
    813  /* ************************************************************* 
    814  * 
    815  *  PLUGIN FUNCTIONS 
    816  * 
    817  * *********************************************************** */ 
    818  
    819  
     799        ####################### 
     800        ## PLUGIN FUNCTIONS  ## 
     801        ####################### 
     802         
    820803        /** 
    821804         * Look for and run actions at a given plugin hook 
     
    965948        } 
    966949 
    967  
    968  /* ************************************************************* 
    969  * 
    970  *  PLUGIN SETTINGS FUNCTIONS 
    971  * 
    972  * *********************************************************** */ 
    973  
     950        ############################### 
     951        ## PLUGIN SETTINGS FUNCTIONS ## 
     952        ############################### 
    974953 
    975954        /** 
     
    10271006        { 
    10281007                $pluginSettings = new PluginSettings(); 
    1029                 $this->pluginSettings = $pluginSettings->getAllPluginSettings($this); 
    1030                 return $this->pluginSettings; 
     1008                return $pluginSettings->getAllPluginSettings($this); 
    10311009        } 
    10321010 
     
    10591037        } 
    10601038 
    1061  
    1062  /* ************************************************************* 
    1063  * 
    1064  *  THEME SETTINGS FUNCTIONS 
    1065  * 
    1066  * *********************************************************** */ 
     1039        ############################## 
     1040        ## THEME SETTINGS FUNCTIONS ## 
     1041        ############################## 
    10671042 
    10681043        /** 
     
    11071082        } 
    11081083 
    1109  
    1110  /* ************************************************************* 
    1111  * 
    1112  *  INCLUDE CSS & JAVASCRIPT FUNCTIONS 
    1113  * 
    1114  * *********************************************************** */ 
    1115  
     1084        ######################################## 
     1085        ## INCLUDE CSS & JAVASCRIPT FUNCTIONS ## 
     1086        ######################################## 
    11161087 
    11171088        /** 
     
    11431114         * @param $filename - optional js file without an extension 
    11441115         */ 
    1145          public function includeJs($folder = '', $filename = '') 
    1146          { 
    1147                 $folder = (empty($folder)) ? $this->plugin->folder: $folder; 
    1148                 return $this->includes->includeFile('js', $folder, $filename,$this->isAdmin); 
    1149          } 
     1116        public function includeJs($folder = '', $filename = '') 
     1117        { 
     1118                $folder = (empty($folder)) ? $this->plugin->folder : $folder; 
     1119                return $this->includes->includeFile('js', $folder, $filename, $this->isAdmin); 
     1120        } 
    11501121 
    11511122 
     
    11561127         * @param $folder - optional pluin folder 
    11571128         */ 
    1158          public function includeOnceCss($files = array(), $folder = '') 
    1159          { 
    1160                  $folder = (empty($folder)) ? $this->plugin->folder: $folder; 
    1161                  $files = (is_array($files)) ? $files : array($files); 
    1162                  return $this->includes->includeFileOnce($files, 'css', $folder); 
    1163          } 
     1129        public function includeOnceCss($files = array(), $folder = '') 
     1130        { 
     1131                $folder = (empty($folder)) ? $this->plugin->folder : $folder; 
     1132                $files = (is_array($files)) ? $files : array($files); 
     1133                return $this->includes->includeFileOnce($files, 'css', $folder); 
     1134        } 
    11641135 
    11651136 
     
    11701141         * @param $folder - optional pluin folder 
    11711142         */ 
    1172          public function includeOnceJs($files = array(), $folder = '') 
    1173          { 
    1174                  $folder = (empty($folder)) ? $this->plugin->folder: $folder; 
    1175                  $files = (is_array($files)) ? $files : array($files); 
    1176                  return $this->includes->includeFileOnce($files, 'js', $folder); 
    1177          } 
    1178  
    1179  
    1180  /* ************************************************************* 
    1181  * 
    1182  *  MESSAGE FUNCTIONS (success/error messages) 
    1183  * 
    1184  * *********************************************************** */ 
     1143        public function includeOnceJs($files = array(), $folder = '') 
     1144        { 
     1145                $folder = (empty($folder)) ? $this->plugin->folder : $folder; 
     1146                $files = (is_array($files)) ? $files : array($files); 
     1147                return $this->includes->includeFileOnce($files, 'js', $folder); 
     1148        } 
     1149 
     1150        ################################################ 
     1151        ## MESSAGE FUNCTIONS (success/error messages) ## 
     1152        ################################################ 
    11851153 
    11861154 
     
    12071175        } 
    12081176 
    1209  
    1210  /* ************************************************************* 
    1211  * 
    1212  *  ANNOUNCEMENT FUNCTIONS 
    1213  * 
    1214  * *********************************************************** */ 
    1215  
     1177        ############################ 
     1178        ## ANNOUNCEMENT FUNCTIONS ## 
     1179        ############################ 
    12161180 
    12171181        /** 
     
    12311195        } 
    12321196 
    1233  
    1234  /* ************************************************************* 
    1235  * 
    1236  *  DEBUG FUNCTIONS 
    1237  * 
    1238  * *********************************************************** */ 
    1239  
     1197        ##################### 
     1198        ## DEBUG FUNCTIONS ## 
     1199        ##################### 
    12401200 
    12411201        /** 
    12421202         * Shows number of database queries and the time it takes for a page to load 
     1203         *  
     1204         * @todo Replace all $h->showQueriesAndTime() with Debug::showQueriesAndTime($h) in the themes before releasing 1.5 
    12431205         */ 
    12441206        public function showQueriesAndTime() 
     
    12471209        } 
    12481210 
    1249         /** 
    1250          * Log performance and errors 
    1251          * 
    1252          * @param string $type "speed", "error", etc. 
    1253          */ 
    1254         public function log($type = 'error', $string = '') 
    1255         { 
    1256                 Debug::log($type, $string); 
    1257         } 
    1258  
    1259         /** 
    1260          * Generate a system report 
    1261          * 
    1262          * @param string $type "log" or "object" 
    1263          */ 
    1264         public function generateReport($type = 'log') 
    1265         { 
    1266                 return Debug::generateReport($this, $type); 
    1267         } 
    1268  
    1269  
    1270  /* ************************************************************* 
    1271  * 
    1272  *  RSS FEED FUNCTIONS 
    1273  * 
    1274  * *********************************************************** */ 
    1275  
     1211        ######################## 
     1212        ## RSS FEED FUNCTIONS ## 
     1213        ######################## 
    12761214 
    12771215        /** 
     
    13051243        } 
    13061244 
    1307  
    1308  /* ************************************************************* 
    1309  * 
    1310  *  ADMIN FUNCTIONS 
    1311  * 
    1312  * *********************************************************** */ 
    1313  
     1245        ##################### 
     1246        ## ADMIN FUNCTIONS ## 
     1247        ##################### 
    13141248 
    13151249         /** 
     
    13441278        } 
    13451279 
    1346  
    1347  /* ************************************************************* 
    1348  * 
    1349  *  MAINTENANCE FUNCTIONS 
    1350  * 
    1351  * *********************************************************** */ 
    1352  
     1280        ########################### 
     1281        ## MAINTENANCE FUNCTIONS ## 
     1282        ########################### 
    13531283 
    13541284        /** 
     
    13591289        public function checkAccess() 
    13601290        { 
    1361                 if (SITE_OPEN == 'true') { return true; }   // site is open, go back and continue 
    1362  
    1363                 // site closed, but user has admin access so go back and continue as normal 
    1364                 if ($this->currentUser->getPermission('can_access_admin') == 'yes') { return true; } 
    1365  
    1366                 if ($this->pageName == 'admin_login') { return true; } 
     1291                // site is open, go back and continue 
     1292                if ((SITE_OPEN == 'true') 
     1293                        // site closed, but user has admin access so go back and continue as normal 
     1294                        || ($this->currentUser->getPermission('can_access_admin') == 'yes') 
     1295                        || ($this->pageName == 'admin_login') ) 
     1296                { 
     1297                        return true; 
     1298                } 
    13671299 
    13681300                $maintenance = new Maintenance(); 
     
    13841316 
    13851317        /** 
    1386          * Optimize all database tables 
    1387          */ 
    1388         public function optimizeTables() 
    1389         { 
    1390                 $maintenance = new Maintenance(); 
    1391                 $maintenance->optimizeTables($this); 
    1392         } 
    1393  
    1394  
    1395         /** 
    1396          * Empty plugin database table 
    1397          * 
    1398          * @param string $table_name - table to empty 
    1399          * @param string $msg - show "emptied" message or not 
    1400          */ 
    1401         public function emptyTable($table_name = '', $msg = true) 
    1402         { 
    1403                 $maintenance = new Maintenance(); 
    1404                 $maintenance->emptyTable($this, $table_name, $msg); 
    1405         } 
    1406  
    1407  
    1408         /** 
    1409          * Delete plugin database table 
    1410          * 
    1411          * @param string $table_name - table to drop 
    1412          * @param string $msg - show "dropped" message or not 
    1413          */ 
    1414         public function dropTable($table_name = '', $msg = true) 
    1415         { 
    1416                 $maintenance = new Maintenance(); 
    1417                 $maintenance->dropTable($this, $table_name, $msg); 
    1418         } 
    1419  
    1420  
    1421         /** 
    1422          * Remove plugin settings 
    1423          * 
    1424          * @param string $folder - plugin folder name 
    1425          * @param bool $msg - show "Removed" message or not 
    1426          */ 
    1427         public function removeSettings($folder = '', $msg = true) 
    1428         { 
    1429                 $maintenance = new Maintenance(); 
    1430                 $maintenance->removeSettings($this, $folder, $msg); 
    1431         } 
    1432  
    1433  
    1434         /** 
    1435          * Deletes rows from pluginsettings that match a given setting or plugin 
    1436          * 
    1437          * @param string $setting name of the setting to remove 
    1438          * @param string $folder name of plugin folder 
    1439          */ 
    1440         public function deleteSettings($setting = '', $folder = '') 
    1441         { 
    1442                 $maintenance = new Maintenance(); 
    1443                 $maintenance->deleteSettings($this, $setting, $folder); 
    1444         } 
    1445  
    1446  
    1447         /** 
    1448          * Delete all files in the specified directory except placeholder.txt 
    1449          * 
    1450          * @param string $dir - path to the cache folder 
    1451          * @return bool 
    1452          */ 
    1453         public function deleteFiles($dir = '') 
    1454         { 
    1455                 $maintenance = new Maintenance(); 
    1456                 return $maintenance->deleteFiles($dir); 
    1457         } 
    1458  
    1459  
    1460         /** 
    14611318         * Calls the delete_files function, then displays a message. 
    14621319         * 
     
    14701327        } 
    14711328 
    1472  
    1473         /** 
    1474          * Get all files in the specified directory except placeholder.txt 
    1475          * 
    1476          * @param string $dir - path to the folder 
    1477          * @param array $exclude - array of file/folder names to exclude 
    1478          * @return array 
    1479          */ 
    1480         public function getFiles($dir = '', $exclude = array()) 
    1481         { 
    1482                 $maintenance = new Maintenance(); 
    1483                 return $maintenance->getFiles($dir, $exclude); 
    1484         } 
    1485  
    1486  
    1487         /** 
    1488          * System Report is under Debug Functions 
    1489          */ 
    1490  
    1491  
    1492  /* ************************************************************* 
    1493  * 
    1494  *  CACHING FUNCTIONS (Note: "clearCache" is in Maintenance above) 
    1495  * 
    1496  * *********************************************************** */ 
    1497  
     1329        #################################################################### 
     1330        ## CACHING FUNCTIONS (Note: "clearCache" is in Maintenance above) ## 
     1331        #################################################################### 
    14981332 
    14991333        /** 
     
    15351369        } 
    15361370 
    1537  
    1538  /* ************************************************************* 
    1539  * 
    1540  *  BLOCKED FUNCTIONS (i.e. Admin's Blocked list) 
    1541  * 
    1542  * *********************************************************** */ 
    1543  
     1371        ################################################### 
     1372        ## BLOCKED FUNCTIONS (i.e. Admin's Blocked list) ## 
     1373        ################################################### 
     1374         
    15441375         /** 
    15451376         * Check if a value is blocked from registration and post submission) 
     
    15711402        } 
    15721403 
    1573  
    1574  /* ************************************************************* 
    1575  * 
    1576  *  LANGUAGE FUNCTIONS 
    1577  * 
    1578  * *********************************************************** */ 
    1579  
     1404        ######################## 
     1405        ## LANGUAGE FUNCTIONS ## 
     1406        ######################## 
    15801407 
    15811408        /** 
     
    16091436        } 
    16101437 
    1611  
    1612 /* ************************************************************* 
    1613  * 
    1614  *  CSRF FUNCTIONS 
    1615  * 
    1616  * *********************************************************** */ 
    1617  
     1438        #################### 
     1439        ## CSRF FUNCTIONS ## 
     1440        #################### 
    16181441 
    16191442        /** 
     
    16311454        } 
    16321455 
    1633  
    1634 /* ************************************************************* 
    1635  * 
    1636  *  POST FUNCTIONS 
    1637  * 
    1638  * *********************************************************** */ 
    1639  
    1640  
     1456        #################### 
     1457        ## POST FUNCTIONS ## 
     1458        #################### 
     1459         
    16411460        /** 
    16421461         * Get all the parameters for the current post 
     
    18161635        } 
    18171636 
    1818  
    1819 /* ************************************************************* 
    1820  * 
    1821  *  AVATAR FUNCTIONS 
    1822  * 
    1823  * *********************************************************** */ 
    1824  
     1637        ###################### 
     1638        ## AVATAR FUNCTIONS ## 
     1639        ###################### 
    18251640 
    18261641        /** 
     
    18701685        } 
    18711686 
    1872  
    1873 /* ************************************************************* 
    1874  * 
    1875  *  CATEGORY FUNCTIONS 
    1876  * 
    1877  * *********************************************************** */ 
     1687        ######################## 
     1688        ## CATEGORY FUNCTIONS ## 
     1689        ######################## 
    18781690 
    18791691        /** 
     
    20081820        } 
    20091821 
    2010  
    2011 /* ************************************************************* 
    2012  * 
    2013  *  WIDGET FUNCTIONS 
    2014  * 
    2015  * *********************************************************** */ 
     1822        ###################### 
     1823        ## WIDGET FUNCTIONS ## 
     1824        ###################### 
    20161825 
    20171826        /** 
  • branches/1.5/content/admin_themes/admin_default/admin_sidebar.php

    r2160 r2315  
    5959                <ul id="theme_settings_list"> 
    6060                <?php 
    61                         $themes = $h->getFiles(THEMES, array('404error.php')); 
     61                        $themes = FileSystem::listFiles(THEMES, array('404error.php'), FALSE); 
    6262                        if ($themes) { 
    6363                                $themes = sksort($themes, $subkey="name", $type="char", true); 
  • branches/1.5/content/admin_themes/admin_default/theme_settings.php

    r2154 r2315  
    7878                <ul id="plugin_settings_list"> 
    7979                        <?php 
    80                                 $themes = $h->getFiles(THEMES, array('404error.php')); 
     80                                $themes = FileSystem::listFiles(THEMES, array('404error.php'), FALSE); 
    8181                                if ($themes) { 
    8282                                        $themes = sksort($themes, $subkey="name", $type="char", true); 
  • branches/1.5/libs/AdminPages.php

    r2313 r2315  
    186186                        $theme = strtolower($h->cage->post->testAlnumLines('theme')."/"); 
    187187                        $this->adminSettingUpdate($h, 'THEME', $theme); 
    188                         $h->deleteFiles(CACHE.'css_js_cache'); // clear the CSS/JS cache 
     188                        FileSystem::deleteFiles(CACHE.'css_js_cache'); // clear the CSS/JS cache 
    189189                        $json_array = array('activate' => 'true', 'message' => $h->lang["admin_settings_theme_activate_success"], 'color' => 'green'); 
    190190 
     
    329329                                break; 
    330330                        case 'remove_settings': 
    331                                 $h->removeSettings($h->cage->get->testAlnumLines('settings')); 
     331                                $plugin_settings = new PluginSettings(); 
     332                                if($plugin_settings->removeSettings($h, $h->cage->get->testAlnumLines('settings'))){ 
     333                                        $h->message = $h->lang['admin_maintenance_settings_removed']; 
     334                                        $h->messageType = 'green'; 
     335                                } 
    332336                                break; 
    333337                        case 'system_report': 
    334                                 $h->generateReport(); 
     338                                Debug::generateReport($h); 
    335339                                break; 
    336340                        case 'email_report': 
    337                                 $h->generateReport('email'); 
     341                                Debug::generateReport($h, 'email'); 
    338342                                break; 
    339343                        case 'delete_debugs': 
    340344                                $h->clearCache('debug_logs'); 
    341                                 $h->vars['debug_files'] = $h->getFiles(CACHE.'debug_logs'); 
     345                                $h->vars['debug_files'] = FileSystem::listFiles(CACHE.'debug_logs'); 
    342346                                break; 
    343347                } 
    344348 
    345349                // get list of debug logs 
    346                 $h->vars['debug_files'] = $h->getFiles(CACHE.'debug_logs'); 
     350                $h->vars['debug_files'] = FileSystem::listFiles(CACHE.'debug_logs'); 
    347351        } 
    348352 
     
    354358        public function listPluginSettings($h) 
    355359        { 
    356                 $sql = "SELECT DISTINCT plugin_folder FROM ".TABLE_PLUGINSETTINGS; 
    357                 $results = $h->db->get_results($h->db->prepare($sql)); 
     360                $results = $h->db->get_results("SELECT DISTINCT plugin_folder FROM ".TABLE_PLUGINSETTINGS); 
    358361 
    359362                if (!$results) { 
     
    364367 
    365368                foreach ($results as $item) { 
    366                         array_push($plugin_settings, $item->plugin_folder); 
     369                        $plugin_settings[] = $item->plugin_folder; 
    367370                } 
    368371 
  • branches/1.5/libs/Debug.php

    r2298 r2315  
    4040                        echo $h->lang['main_hotaru_db_queries'].$h->db->num_queries." | "; 
    4141                        echo $h->lang['main_hotaru_page_load_time'].timer_stop(1).$h->lang['main_times_secs']." | "; 
    42                         echo $h->lang['main_hotaru_memory_usage'].display_filesize(memory_get_usage())." | "; 
     42                        echo $h->lang['main_hotaru_memory_usage'].FileSystem::display_filesize(memory_get_usage())." | "; 
    4343                        echo $h->lang['main_hotaru_php_version'].phpversion()." | "; 
    4444                        echo $h->lang['main_hotaru_mysql_version'].$mysql_version." | "; 
  • branches/1.5/libs/PluginSettings.php

    r1662 r2315  
    114114        public function getAllPluginSettings($h) 
    115115        { 
    116                 $sql = "SELECT plugin_folder, plugin_setting, plugin_value FROM " . TABLE_PLUGINSETTINGS; 
    117                 $results = $h->db->get_results($h->db->prepare($sql)); 
    118                 if ($results) { return $results; } else { return false; } 
     116                $results = $h->db->get_results("SELECT plugin_folder, plugin_setting, plugin_value FROM ".TABLE_PLUGINSETTINGS); 
     117                $h->pluginSettings = $results; 
     118                if ($results) { 
     119                        return $results; 
     120                } 
     121                return FALSE; 
    119122        } 
    120123         
     
    167170                $h->db->query("OPTIMIZE TABLE " . TABLE_PLUGINSETTINGS); 
    168171        } 
     172 
     173        /** 
     174         * Remove plugin settings 
     175         * 
     176         * @param string $folder - plugin folder name 
     177         * @param bool $msg - show "Removed" message or not 
     178         */ 
     179        public function removeSettings($h, $folder, $msg = true) 
     180        { 
     181                if (!$folder) { 
     182                        $folder = $h->plugin->folder; 
     183                } 
     184 
     185                $sql = "DELETE FROM ".TABLE_PLUGINSETTINGS." WHERE plugin_folder = %s"; 
     186                $h->db->get_results($h->db->prepare($sql, $folder)); 
     187                return TRUE; 
     188        } 
     189 
    169190} 
    170 ?> 
  • branches/1.5/libs/SystemInfo.php

    r2255 r2315  
    3838                        'format' => $format, 
    3939                        'method' => 'hotaru.systemFeedback.add', 
    40                         'args' => serialize($h->generateReport("object")) 
     40                        'args' => serialize(Debug::generateReport($h, "object")) 
    4141                )); 
    4242