Changeset 2299 for branches

Show
Ignore:
Timestamp:
12/13/10 22:58:40 (17 months ago)
Author:
petsagouris
Message:

[Branch 1.5] Providing class code care

Files:
1 modified

Legend:

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

    r2239 r2299  
    55 * PHP version 5 
    66 * 
    7  * LICENSE: Hotaru CMS is free software: you can redistribute it and/or  
    8  * modify it under the terms of the GNU General Public License as  
    9  * published by the Free Software Foundation, either version 3 of  
    10  * the License, or (at your option) any later version.  
     7 * LICENSE: Hotaru CMS is free software: you can redistribute it and/or 
     8 * modify it under the terms of the GNU General Public License as 
     9 * published by the Free Software Foundation, either version 3 of 
     10 * the License, or (at your option) any later version. 
    1111 * 
    12  * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT  
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or  
    14  * FITNESS FOR A PARTICULAR PURPOSE.  
     12 * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT 
     13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
     14 * FITNESS FOR A PARTICULAR PURPOSE. 
    1515 * 
    16  * You should have received a copy of the GNU General Public License along  
     16 * You should have received a copy of the GNU General Public License along 
    1717 * with Hotaru CMS. If not, see http://www.gnu.org/licenses/. 
    18  *  
     18 * 
    1919 * @category  Content Management System 
    2020 * @package   HotaruCMS 
     
    2626class Announcements 
    2727{ 
     28 
    2829        /** 
    2930         * Displays an announcement at the top of the screen 
    3031         * 
    31          * @param string $announcement - optional  
     32         * @param string $announcement - optional 
    3233         * @return array 
    3334         */ 
    34         public function checkAnnouncements($h, $announcement = '')  
     35        public function checkAnnouncements($h, $announcement = '') 
    3536        { 
    3637                $announcements = array(); 
    37                  
     38 
    3839                if (SITE_OPEN == "false") { 
    39                         array_push( 
    40                                 $announcements,  
    41                                 $h->lang['main_announcement_site_closed'] 
    42                         ); 
     40                        $announcements[] = $h->lang['main_announcement_site_closed']; 
    4341                } 
    44                  
     42 
    4543                // "All plugins are currently disabled." 
    4644                if (!$h->numActivePlugins()) { 
    47                         array_push( 
    48                                 $announcements,  
    49                                 $h->lang['main_announcement_plugins_disabled'] 
    50                         ); 
     45                        $announcements[] = $h->lang['main_announcement_plugins_disabled']; 
    5146                } 
    52                  
     47 
    5348                // if using the announcement parameter, then add to non-admin pages only: 
    5449                if ($announcement && !$h->isAdmin) { 
    55                         array_push($announcements, $announcement); 
     50                        $announcements[] = $announcement; 
    5651                } 
    57                  
     52 
    5853                // get the announcement set in the Admin Maintenance page: 
    59                 require_once(LIBS . 'Maintenance.php'); 
     54                require_once(LIBS.'Maintenance.php'); 
    6055                $maintenance = new Maintenance(); 
    6156                $maintenance->getSiteAnnouncement($h); 
    6257                if ($h->vars['admin_announcement_enabled']) { 
    63                         array_push($announcements, urldecode($h->vars['admin_announcement'])); 
     58                        $announcements[] = urldecode($h->vars['admin_announcement']); 
    6459                } 
    65                  
     60 
    6661                // Plugins can add announcements with this: 
    6762                $h->vars['hotaru_announcements'] = $announcements; 
    6863                $h->pluginHook('hotaru_announcements'); 
    6964                $announcements = $h->vars['hotaru_announcements']; 
    70                  
    71                 if (!is_array($announcements)) { 
    72                         return false; 
    73                 } else { 
    74                         return $announcements; 
     65 
     66                if (count($announcements)) { 
     67                        return $announcemens; 
    7568                } 
     69                return FALSE; 
    7670        } 
    77          
    78          
     71 
    7972        /** 
    8073         * Returns an announcement for display at the top of Admin 
     
    8578        { 
    8679                // Check if the install file has been deleted: 
    87                  
     80 
    8881                $announcements = array(); 
    8982 
    90             // Check if install file has been deleted 
    91             $filename = INSTALL . 'install.php'; 
    92             if (file_exists($filename)) { 
    93                     array_push($announcements, $h->lang['admin_announcement_delete_install']); 
    94             } 
     83                // Check if install file has been deleted 
     84                $filename = INSTALL.'install.php'; 
     85                if (file_exists($filename)) { 
     86                        $announcements[] = $h->lang['admin_announcement_delete_install']; 
     87                } 
    9588 
    96             // Check if install file has not been run 
    97             $sql = "SELECT miscdata_value FROM " . TABLE_MISCDATA . " WHERE miscdata_key = %s"; 
    98             $hotaru_version = $h->db->get_var($h->db->prepare($sql, 'hotaru_version')); 
    99             if (version_compare($h->version, $hotaru_version, '>')) { 
    100                     array_push($announcements, $h->lang['admin_announcement_run_install']); 
    101             } 
    102                  
     89                // Check if install file has not been run 
     90                $sql = "SELECT miscdata_value FROM ".TABLE_MISCDATA." WHERE miscdata_key = %s"; 
     91                $hotaru_version = $h->db->get_var($h->db->prepare($sql, 'hotaru_version')); 
     92                if (version_compare($h->version, $hotaru_version, '>')) { 
     93                        $announcements[] = $h->lang['admin_announcement_run_install']; 
     94                } 
     95 
    10396                // Site is currently undergoing maintenance 
    10497                if (SITE_OPEN == "false") { 
    105                         array_push($announcements, $h->lang['admin_announcement_site_closed']); 
     98                        $announcements[] = $h->lang['admin_announcement_site_closed']; 
    10699                } 
    107                  
     100 
    108101                // Please enter a site email address 
    109102                if (SITE_EMAIL == "email@example.com") { 
    110                         array_push($announcements, $h->lang['admin_announcement_change_site_email']);     
    111                 }  
    112                  
     103                        $announcements[] = $h->lang['admin_announcement_change_site_email']; 
     104                } 
     105 
    113106                // "Go to Plugin Management to enable some plugins" 
    114107                if (!$h->numActivePlugins()) { 
    115                         array_push($announcements, $h->lang['admin_announcement_plugins_disabled']);     
     108                        $announcements[] = $h->lang['admin_announcement_plugins_disabled']; 
    116109                } 
    117                  
     110 
    118111                // Plugins can add announcements with this: 
    119112                $h->vars['admin_announcements'] = $announcements; 
    120113                $h->pluginHook('admin_announcements'); 
    121114                $announcements = $h->vars['admin_announcements']; 
    122                  
     115 
    123116                if (!is_array($announcements)) { 
    124117                        return false; 
     
    127120                } 
    128121        } 
     122 
    129123} 
    130 ?>