Changeset 2316
- Timestamp:
- 12/19/10 10:34:57 (17 months ago)
- Location:
- branches/1.5/libs
- Files:
-
- 2 modified
-
Initialize.php (modified) (2 diffs)
-
Maintenance.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.5/libs/Initialize.php
r2313 r2316 46 46 47 47 $this->MakeCacheFolders(); 48 $this-> getFiles();48 $this->includeFiles(); 49 49 $this->initInspektCage(); 50 50 $this->initDatabase(); … … 153 153 * @return null 154 154 */ 155 private function getFiles()155 private function includeFiles() 156 156 { 157 157 require_once(FUNCTIONS.'funcs.strings.php'); -
branches/1.5/libs/Maintenance.php
r2312 r2316 31 31 * Calls the delete_files function, then displays a message. 32 32 * 33 * @todo Should be moved to the libs/Caching.php 33 34 * @param string $folder - path to the cache folder 34 35 * @param string $msg - show "cleared" message or not … … 43 44 44 45 // go delete the files 45 $success = $this->deleteFiles(CACHE.$folder);46 $success = FileSystem::deleteFiles(CACHE.$folder); 46 47 47 48 // lang_cache only: … … 50 51 $h->lang = $langObj->includeLanguagePack($h->lang, 'main'); 51 52 $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 */ 52 59 } 53 60 … … 67 74 68 75 // return boolean result 69 return $success;70 }71 72 /**73 * Remove plugin settings74 *75 * @param string $folder - plugin folder name76 * @param bool $msg - show "Removed" message or not77 */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 plugin94 *95 * @param string $setting name of the setting to remove96 * @param string $folder name of plugin folder97 */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 table109 $h->db->query("OPTIMIZE TABLE ".TABLE_PLUGINSETTINGS);110 }111 112 /**113 * Delete all files in the specified directory except placeholder.txt114 *115 * @param string $dir - path to the cache folder116 * @return bool117 */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);138 76 return $success; 139 77 } … … 173 111 // include current theme style and default style 174 112 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">'; 176 114 } 177 115 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'; 179 117 } 180 118 echo '</head><body>'; … … 196 134 /** 197 135 * Get Site Annoucement for Maintenance Page (AdminPages.php) 136 * 137 * @todo Should be moved into libs/Announcements.php 138 * @param Hotaru $h 198 139 */ 199 public function getSiteAnnouncement( $h)140 public function getSiteAnnouncement(Hotaru $h) 200 141 { 201 142 // get announcement from database … … 226 167 * Add Site Annoucement from Maintenance Page (AdminPages.php) 227 168 * 228 * @param object $announcement_exists - result from getSiteAnnouncement() 169 * @todo Should be moved into libs/Announcements.php 170 * @param Hotaru $h the Hotaru instance 229 171 */ 230 public function addSiteAnnouncement( $h)172 public function addSiteAnnouncement(Hotaru $h) 231 173 { 232 174 $allowable_tags = "<div><p><span><b><i><u><a><img><blockquote><del><br>"; … … 248 190 } 249 191 250 /**251 * Get all files in the specified directory except placeholder.txt252 *253 * @param string $dir - path to the folder254 * @param array $exclude - array of file/folder names to exclude255 * @return array256 */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 276 192 }