Changeset 1781

Show
Ignore:
Timestamp:
02/03/08 15:01:38 (10 months ago)
Author:
cfriesen
Message:

add config option in rssview to set the number of output items

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/plugins/rssview.php

    r1732 r1781  
    3131/// Description: Adds a RSS link to the header and the footer of each page 
    3232/// Version: 0.7 
     33/// Configuration: __rss_view_config 
    3334 
    3435/** 
     
    3839 * 0.6 - Don't put a link in admin and other locations 
    3940 * 0.7 - Show ATOM link as well. 
     41 * 0.8 - Add configurable output count. 
    4042 */ 
     43 
     44define ('RSSVIEW_CONFIG_OUTPUTCOUNT', 'rssview.outputcount'); 
     45define ('RSSVIEW_DEFAULT_COUNT', 10); 
     46 
     47function __rss_view_config () { 
     48    $cnt = rss_plugins_get_option(RSSVIEW_CONFIG_OUTPUTCOUNT); 
     49     
     50    if(empty($cnt)) { 
     51        $cnt = RSSVIEW_DEFAULT_COUNT; 
     52    } 
     53     
     54  if(rss_plugins_is_submit()) { 
     55    if(!empty($_REQUEST['rv_oc'])) { 
     56        $cnt = $_REQUEST['rv_oc']; 
     57        } 
     58         
     59    rss_plugins_add_option(RSSVIEW_CONFIG_OUTPUTCOUNT, $cnt, 'num'); 
     60    return; 
     61    } 
     62 
     63    print ("<fieldset>\n"); 
     64    print ("  <legend>" . __('Output Count') . "</legend>\n"); 
     65    print ("   <p><label for='rv_oc'>" . __('Count') . "</label></br>"); 
     66    print ("   <input id='rv_oc' type='text' value='" . $cnt . "' name='rv_oc'></p>\n"); 
     67    print ("</fieldset>\n"); 
     68} 
    4169 
    4270function __rss_view_url($type = "rss") { 
     
    4472    $url .= $_SERVER["REQUEST_URI"]; 
    4573 
     74        $cnt = rss_plugins_get_option(RSSVIEW_CONFIG_OUTPUTCOUNT); 
     75         
     76        if(empty($cnt)) { 
     77            $cnt = RSSVIEW_DEFAULT_COUNT; 
     78        } 
     79         
    4680    if (strstr($_SERVER['REQUEST_URI'],"?") !== FALSE) { 
    47         $url .= "&amp;media=$type"; 
     81        $url .= "&amp;media=$type&amp;count=$cnt"; 
    4882    } else { 
    49         $url .= "?media=$type"; 
     83        $url .= "?media=$type&amp;count=$cnt"; 
    5084    } 
    5185    $url .= __rss_view_post2get();