Changeset 2324

Show
Ignore:
Timestamp:
12/21/10 16:14:40 (17 months ago)
Author:
petsagouris
Message:

[Branch 1.5] Removing Feeds::adminNews() -- too much function for nothing. Replaced with jquery.
todo: Style the output properly.

Location:
branches/1.5
Files:
2 added
4 modified

Legend:

Unmodified
Added
Removed
  • branches/1.5/content/admin_themes/admin_default/admin_header.php

    r2290 r2324  
    4141                <link rel="stylesheet" href="<?php echo ADMIN_THEME_URL ?>css/style.css" type="text/css"> 
    4242                <!-- <link rel="shortcut icon" href="<?php echo SITEURL; ?>favicon.ico"> --> 
     43                <?php if($h->pageName == 'admin_home') { ?> 
     44                <link rel="stylesheet" href="<?php echo ADMIN_THEME_URL ?>css/zrssfeed.css" type="text/css" /> 
     45                <script type="text/javascript" src="<?php echo ADMIN_THEME_URL?>javascript/jquery.zrssfeed.min.js"></script> 
     46                <script type="text/javascript"> 
     47                        $(document).ready(function () { 
     48                                $("#admin_news").rssfeed('http://feeds2.feedburner.com/hotarucms', { 
     49                                        showerror: false, 
     50                                        header: false, 
     51                                        limit: 5 
     52                                }); 
     53                        }); 
     54                </script> 
     55                <?php } ?> 
    4356                <?php $h->pluginHook('admin_header_include_raw'); ?> 
    4457        </head> 
  • branches/1.5/content/admin_themes/admin_default/admin_home.php

    r2307 r2324  
    3636                        <h3><?php echo $h->lang["admin_theme_main_help"]; ?></h3> 
    3737                        <!-- Feed items, number to show content for, max characters for content --> 
    38                         <?php  
    39                                 $feeds = new Feeds(); 
    40                                 $feeds->adminNews($h->lang, 10, 3, 300); //lang, max_items, items_with_content, max_chars 
    41                         ?> 
     38                        <div id="admin_news"></div> 
    4239                        <br/> 
    4340                        <h2><?php echo $h->lang["admin_theme_main_join_us"]; ?></h2> 
  • branches/1.5/content/themes/default/settings.php

    r2274 r2324  
    3333?> 
    3434<form name="theme_settings_form" action="<?php echo BASEURL; ?>admin_index.php?page=theme_settings&amp;theme=<?php echo $theme_name; ?>" method="post"> 
    35         <label>Tagline: <input type="text" size="70" name="tagline" value="<?php echo htmlentities($theme_settings['tagline'], ENT_QUOTES, 'UTF-8'); ?>"></label> 
     35        <label>Tagline: <input type="text" size="70" name="tagline" value="<?php echo htmlspecialchars($theme_settings['tagline'], ENT_QUOTES, 'UTF-8',FALSE); ?>"></label> 
    3636        <input type="submit" value="<?php echo $h->lang['main_form_save']; ?>" /> 
    3737        <input type="hidden" name="submitted" value="true" /><input type="hidden" name="csrf" value="<?php echo $h->csrfToken; ?>" /> 
  • branches/1.5/libs/Feeds.php

    r2323 r2324  
    2525 * @link      http://www.hotarucms.org/ 
    2626 */ 
    27 class Feeds { 
     27class Feeds 
     28{ 
    2829 
    29          /** 
     30        /** 
    3031         * Create an RSS Feed 
    3132         * 
     
    3637         * @param string $content_type e.g. 'application/xml' or 'text/plain' 
    3738         */ 
    38         public function rss($h, $title = '', $link = '', $description = '', $items = array(), $content_type = 'application/xml') { 
    39                 require_once(LIBS.'RSS.php'); 
    40                  
    41                 $feed = new RSS($h->url(array('page'=>'rss'))); 
     39        public function rss($h, $title = '', $link = '', $description = '', $items = array(), $content_type = 'application/xml') 
     40        { 
     41                $feed = new RSS($h->url(array('page' => 'rss'))); 
    4242                $feed->title = htmlspecialchars_decode($title, ENT_QUOTES); 
    4343                $feed->link = htmlspecialchars_decode($link, ENT_QUOTES); 
    4444                $feed->description = $description; 
    45                  
     45 
    4646                if ($items) { 
    4747                        $feed->addItem($items); 
    4848                } 
    4949 
    50                 $r = $feed->out($content_type); 
    51                 echo $r; 
     50                echo $feed->out($content_type); 
    5251        } 
    53  
    54                                  
    55         /** 
    56          * Includes the SimplePie RSS file and sets the cache 
    57          * 
    58          * @param string $feed 
    59          * @param bool $cache 
    60          * @param int $cache_duration 
    61          * 
    62          * @return object|false $sp 
    63          */ 
    64         public function newSimplePie($feed='', $cache=RSS_CACHE, $cache_duration=RSS_CACHE_DURATION) { 
    65                 if ($feed != '') { 
    66                         $sp = new SimplePie(); 
    67                         $sp->set_feed_url($feed); 
    68                         $sp->set_cache_location(CACHE."rss_cache/"); 
    69                         $sp->set_cache_duration($cache_duration); 
    70                         $sp->enable_cache(($cache === 'true')); 
    71                         $sp->handle_content_type(); 
    72                         return $sp; 
    73                 } 
    74                 return FALSE; 
    75         } 
    76          
    77          /** 
    78          * Display Hotaru forums feed on Admin front page 
    79          * 
    80          * @param int $max_items 
    81          * @param int $items_with_content 
    82          * @param int $max_chars 
    83          */ 
    84         public function adminNews($lang, $max_items = 10, $items_with_content = 3, $max_chars = 300) { 
    85                 $feedurl = 'http://feeds2.feedburner.com/hotarucms'; 
    86                 $feed = $this->newSimplePie($feedurl); 
    87                 $feed->init(); 
    88                  
    89                 $output = ""; 
    90                 $item_count = 0; 
    91                  
    92                 if ($feed->data) {  
    93                         foreach ($feed->get_items() as $item) { 
    94                                 $output .= "<div class='admin_news'>"; 
    95                                  
    96                                 // Title 
    97                                 $output .= "<a href='".$item->get_permalink()."'>".sanitize($item->get_title(), 'tags')."</a><br />"; 
    98                                  
    99                                 if ($item_count < $items_with_content) { 
    100                                         // Posted by 
    101                                         $output .= "<small>".$lang["admin_news_posted_by"]." "; 
    102                                          
    103                                         foreach ($item->get_authors() as $author) { 
    104                                             $output .= $author->get_name();  
    105                                         } 
    106                                          
    107                                         // Date 
    108                                         $output .= " ".$lang["admin_news_on"]." ".$item->get_date('j F Y')."</small><br />"; 
    109                                          
    110                                         // Content 
    111                                         $output .= truncate(sanitize($item->get_content(), 'tags'), $max_chars, TRUE); 
    112                                          
    113                                         // Read more 
    114                                         $output .= "<small><a href='".$item->get_permalink()."' title='".sanitize($item->get_title(), 'tags')."'>[".$lang["admin_news_read_more"]."]</a></small>"; 
    115                                 } 
    116                                  
    117                                 $output .= "</div>"; 
    118                                 if ($item_count < $items_with_content) { 
    119                                         $output .="<br />"; 
    120                                 } 
    121                                  
    122                                 if ($item_count == ($items_with_content - 1)) { 
    123                                         $output .= "<h3>".$lang["admin_news_more_threads"]."</h3>"; 
    124                                 } 
    125  
    126                                 $item_count++; 
    127                                 if ($item_count >= $max_items) { 
    128                                         break; 
    129                         } 
    130                 } 
    131                 } 
    132                  
    133                 echo $output; 
    134         } 
    135  
    13652}