Changeset 2316

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

[Branch 1.5] Complementary changes to last commit (r2315)

Location:
branches/1.5/libs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/1.5/libs/Initialize.php

    r2313 r2316  
    4646 
    4747                $this->MakeCacheFolders(); 
    48                 $this->getFiles(); 
     48                $this->includeFiles(); 
    4949                $this->initInspektCage(); 
    5050                $this->initDatabase(); 
     
    153153         * @return null 
    154154         */ 
    155         private function getFiles() 
     155        private function includeFiles() 
    156156        { 
    157157                require_once(FUNCTIONS.'funcs.strings.php'); 
  • branches/1.5/libs/Maintenance.php

    r2312 r2316  
    3131         * Calls the delete_files function, then displays a message. 
    3232         * 
     33         * @todo Should be moved to the libs/Caching.php 
    3334         * @param string $folder - path to the cache folder 
    3435         * @param string $msg - show "cleared" message or not 
     
    4344 
    4445                // go delete the files 
    45                 $success = $this->deleteFiles(CACHE.$folder); 
     46                $success = FileSystem::deleteFiles(CACHE.$folder); 
    4647 
    4748                // lang_cache only: 
     
    5051                        $h->lang = $langObj->includeLanguagePack($h->lang, 'main'); 
    5152                        $h->lang = $langObj->includeLanguagePack($h->lang, 'admin'); 
     53                        /* @todo        This doesn't load the language files from plugins that are 
     54                         *                      using Admin Area/Maintenance hooks (messaging comes to mind) we 
     55                         *                      should implement a hook in here for plugins that want the language 
     56                         *                      to be included when the language cache is created or just make 
     57                         *                      the language cache be more smart... 
     58                         */ 
    5259                } 
    5360 
     
    6774 
    6875                // return boolean result 
    69                 return $success; 
    70         } 
    71  
    72         /** 
    73          * Remove plugin settings 
    74          * 
    75          * @param string $folder - plugin folder name 
    76          * @param bool $msg - show "Removed" message or not 
    77          */ 
    78         public function removeSettings($h, $folder, $msg = true) 
    79         { 
    80                 if (!$folder) { 
    81                         $folder = $h->plugin->folder; 
    82                 } 
    83                 $sql = "DELETE FROM ".TABLE_PLUGINSETTINGS."pluginsettings WHERE plugin_folder = %s"; 
    84                 $h->db->get_results($h->db->prepare($sql, $folder)); 
    85  
    86                 if ($msg) { 
    87                         $h->message = $h->lang['admin_maintenance_settings_removed']; 
    88                         $h->messageType = 'green'; 
    89                 } 
    90         } 
    91  
    92         /** 
    93          * Deletes rows from pluginsettings that match a given setting or plugin 
    94          * 
    95          * @param string $setting name of the setting to remove 
    96          * @param string $folder name of plugin folder 
    97          */ 
    98         public function deleteSettings($h, $setting = '', $folder = '') 
    99         { 
    100                 if ($setting) { 
    101                         $sql = "DELETE FROM ".TABLE_PLUGINSETTINGS." WHERE plugin_setting = %s"; 
    102                         $h->db->query($h->db->prepare($sql, $setting)); 
    103                 } elseif ($folder) { 
    104                         $sql = "DELETE FROM ".TABLE_PLUGINSETTINGS." WHERE plugin_folder = %s"; 
    105                         $h->db->query($h->db->prepare($sql, $folder)); 
    106                 } 
    107  
    108                 // optimize the table 
    109                 $h->db->query("OPTIMIZE TABLE ".TABLE_PLUGINSETTINGS); 
    110         } 
    111  
    112         /** 
    113          * Delete all files in the specified directory except placeholder.txt 
    114          * 
    115          * @param string $dir - path to the cache folder 
    116          * @return bool 
    117          */ 
    118         public function deleteFiles($dir) 
    119         { 
    120                 $handle = opendir($dir); 
    121  
    122                 $success = false; 
    123                 while (($file = readdir($handle)) !== false) { 
    124                         if (is_file($dir.'/'.$file)) { 
    125                                 if ($file != 'placeholder.txt') { 
    126                                         if (@unlink($dir.'/'.$file)) { 
    127                                                 // ignore setting $success for the JavascriptConstants file which is ALWAYS present (even gets regenerated after deletion) 
    128                                                 if ($file != 'JavascriptConstants.js') { 
    129                                                         $success = true; 
    130                                                 } 
    131                                         } else { 
    132                                                 $success = false; 
    133                                         } 
    134                                 } 
    135                         } 
    136                 } 
    137                 closedir($handle); 
    13876                return $success; 
    13977        } 
     
    173111                // include current theme style and default style 
    174112                if (file_exists(BASE.'content/themes/'.$h->pageHandling->default.'css/style.css')) { 
    175                         echo '<link rel="stylesheet" href="'.SITEURL.'content/themes/'.$h->pageHandling->default.'css/style.css" type="text/css">'; 
     113                        echo '<link rel="stylesheet" href="'.SITEURL.'content/themes/default/css/style.css" type="text/css">'; 
    176114                } 
    177115                if (file_exists(BASE.'content/themes/'.THEME.'css/style.css')) { 
    178                         echo '<link rel="stylesheet" href="'.SITEURL.'content/themes/'.THEME.'css/style.css" type="text/css">\n'; 
     116                        echo '<link rel="stylesheet" href="'.THEME_URL.'css/style.css" type="text/css">\n'; 
    179117                } 
    180118                echo '</head><body>'; 
     
    196134        /** 
    197135         * Get Site Annoucement for Maintenance Page (AdminPages.php) 
     136         * 
     137         * @todo Should be moved into libs/Announcements.php 
     138         * @param Hotaru $h 
    198139         */ 
    199         public function getSiteAnnouncement($h) 
     140        public function getSiteAnnouncement(Hotaru $h) 
    200141        { 
    201142                // get announcement from database 
     
    226167         * Add Site Annoucement from Maintenance Page (AdminPages.php) 
    227168         * 
    228          * @param object $announcement_exists - result from getSiteAnnouncement() 
     169         * @todo Should be moved into libs/Announcements.php 
     170         * @param Hotaru $h the Hotaru instance 
    229171         */ 
    230         public function addSiteAnnouncement($h) 
     172        public function addSiteAnnouncement(Hotaru $h) 
    231173        { 
    232174                $allowable_tags = "<div><p><span><b><i><u><a><img><blockquote><del><br>"; 
     
    248190        } 
    249191 
    250         /** 
    251          * Get all files in the specified directory except placeholder.txt 
    252          * 
    253          * @param string $dir - path to the folder 
    254          * @param array $exclude - array of file/folder names to exclude 
    255          * @return array 
    256          */ 
    257         public function getFiles($dir, $exclude = array()) 
    258         { 
    259                 $files = array(); 
    260                 $exceptions = array_merge(array('.svn', '.', '..', 'placeholder.txt'), $exclude); 
    261  
    262                 foreach (new DirectoryIterator($dir) as $file) { 
    263                         if ($file->isDot() || in_array($file->getFilename(), $exceptions)) { 
    264                                 continue; 
    265                         } 
    266                         $files[] = $file; 
    267                 } 
    268  
    269                 if ($files) { 
    270                         return $files; 
    271                 } 
    272  
    273                 return FALSE; 
    274         } 
    275  
    276192}