WordPress.org

Plugin Directory

Changeset 79270 for sermon-browser/trunk


Ignore:
Timestamp:
12/12/08 02:54:13 (5 years ago)
Author:
mark8barnes
Message:
 
Location:
sermon-browser/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • sermon-browser/trunk/sb-includes/frontend.php

    r79266 r79270  
    1414 
    1515//Are we appending sermon-browser query to an existing query, or not? 
    16 function sb_query_char () { 
    17     if (strpos(sb_display_url(), '?')===FALSE) { 
     16function sb_query_char ($return_entity = true) { 
     17    if (strpos(sb_display_url(), '?')===FALSE) 
    1818        return '?'; 
    19     } else { 
    20         return '&'; 
    21     } 
     19    else 
     20        if ($return_entity) 
     21            return '&'; 
     22        else 
     23            return '&'; 
    2224} 
    2325 
     
    552554 
    553555//Prints tag cloud 
    554 function sb_print_tag_clouds() { 
     556function sb_print_tag_clouds($minfont=80, $maxfont=150) { 
    555557    global $wpdb; 
    556558    $rawtags = $wpdb->get_results("SELECT name FROM {$wpdb->prefix}sb_tags as t RIGHT JOIN {$wpdb->prefix}sb_sermons_tags as st ON t.id = st.tag_id"); 
     
    558560        $cnt[$tag->name]++; 
    559561    } 
    560     $minfont = 80; 
    561     $maxfont = 200; 
    562562    $fontrange = $maxfont - $minfont; 
    563563    $maxcnt = 0; 
     
    648648            $param="file_name"; } 
    649649        $url = URLencode($url); 
    650         echo ' <a href="'.sb_display_url().sb_query_char().'download&'.$param.'='.$url.'">Download</a>'; 
     650        echo ' <a href="'.sb_display_url().sb_query_char().'download&amp;'.$param.'='.$url.'">Download</a>'; 
    651651    } 
    652652    echo '</div>'; 
  • sermon-browser/trunk/sb-includes/podcast.php

    r79266 r79270  
    88} 
    99 
    10 //Prints first .mp3 file 
    11 function sb_first_mp3($sermon) { 
    12     $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; 
    13     $nostats = TRUE; 
    14     if (stripos($user_agent, 'itunes')===FALSE AND stripos($user_agent, 'itunes')===FALSE) 
    15         $nostats = FALSE; // Stats have to be turned off for iTunes compatibility 
    16     $stuff = sb_get_stuff($sermon, true); 
    17     foreach ((array) $stuff['Files'] as $file) { 
    18         if (strtolower(substr($file, strrpos($file, '.') + 1)) == 'mp3') { 
    19             if (substr($file,0,7) == "http://") { 
    20                 if (!$nostats) $file=sb_display_url().sb_query_char().'show&amp;url='.URLencode($file); 
    21             } else { 
    22                 if ($nostats) 
    23                     $file=sb_get_value('wordpress_url').get_option('sb_sermon_upload_dir').URLencode($file); 
    24                 else 
    25                     $file=sb_display_url().sb_query_char().'show&amp;file_name='.URLencode($file); 
    26             } 
    27             return $file; 
    28             break; 
    29         } 
    30     } 
    31 } 
    32  
    3310//Prints size of first .mp3 file 
    3411function sb_first_mp3_size($sermon) { 
    3512    $stuff = sb_get_stuff($sermon); 
    36     foreach ((array) $stuff['Files'] as $file) { 
     13    $stuff = array_merge((array)$stuff['Files'], (array)$stuff['URLs']); 
     14    foreach ((array) $stuff as $file) { 
    3715        if (strtolower(substr($file, strrpos($file, '.') + 1)) == 'mp3') { 
    3816            if (substr($file,0,7) == "http://") { 
     
    5129?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
    5230<channel> 
    53     <atom:link href="<?php echo get_option('sb_podcast') ?>" rel="self" type="application/rss+xml" /> 
     31    <atom:link href="<?php echo str_replace('&amp;&amp;', '&amp;', str_replace('&', '&amp;', get_option('sb_podcast'))) ?>" rel="self" type="application/rss+xml" /> 
    5432    <title><?php echo get_bloginfo('name')?> Podcast</title> 
    5533    <itunes:author></itunes:author> 
    5634    <description><?php echo get_bloginfo('description') ?></description> 
    57     <link><?php echo get_bloginfo('url') ?></link> 
     35    <link><?php echo str_replace('&amp;&amp;', '&amp;', str_replace('&', '&amp;', get_bloginfo('home'))) ?></link> 
    5836    <language>en-us</language> 
    5937    <copyright></copyright> 
  • sermon-browser/trunk/sb-includes/readme.txt

    r79266 r79270  
    8181If your WordPress theme supports widgets, just go to Design and choose Widgets. There you easily can add the Sermons widget to your sidebar. If your theme doesn't support widgets, you'll need to edit your theme manually. Usually, you'll be editing a file called sidebar.php, but your theme may give it a different name. Add the following code: 
    8282 
    83     <?php if (function_exists('sb_display_sermons')) sb_display_sermons(array('display_preacher' => 0, 'display_passage' => 1, 'preacher' => 0, 'service' => 0, 'series' => 0, 'limit' => 5)) ?> 
    84  
    85 Each of the numbers in that line can be changed. display\_preacher and display\_passage affect what is displayed (0 is off, 1 is on). preacher, service and series allow you to limit the output to a particular preacher, service or series. Simply change the number of the ID of the preacher/services/series you want to display. You can get the ID from the Preachers page, or the Series & Services page. 0 shows all preachers/services/series. limit is simply the maximum number of sermons you want displayed. 
     83    <?php if (function_exists('sb_display_sermons')) sb_display_sermons(array('display_preacher' => 0, 'display_passage' => 1, 'display_date' => 1, 'display_player' => 1, 'preacher' => 0, 'service' => 0, 'series' => 0, 'limit' => 5)) ?> 
     84 
     85Each of the numbers in that line can be changed. display\_preacher, display\_passage, display\_date, and display\_player affect what is displayed (0 is off, 1 is on). preacher, service and series allow you to limit the output to a particular preacher, service or series. Simply change the number of the ID of the preacher/services/series you want to display. You can get the ID from the Preachers page, or the Series & Services page. 0 shows all preachers/services/series. limit is simply the maximum number of sermons you want displayed. 
    8686 
    8787#### My host only allows me a certain amount of disk space, and I have so many sermons uploaded, I've run out of space! What can I do? 
  • sermon-browser/trunk/sb-includes/widget.php

    r79266 r79270  
    11<?php 
    22 
    3 //Fix for users of versions prior to 0.24 
    4 if (!function_exists('display_sermons')) { 
    5     function display_sermons($params) { 
    6         return sb_display_sermons($params); 
    7     } 
    8 } 
    9  
     3// Function to display sermons for users to add to their template 
    104function sb_display_sermons($options = array()) { 
    115    $default = array( 
     
    137        'display_passage' => 1, 
    148        'display_date' => 1, 
     9        'display_player' => 0, 
    1510        'preacher' => 0, 
    1611        'service' => 0, 
     
    2015    $options = array_merge($default, (array) $options); 
    2116    extract($options); 
    22     // Do stuff for this widget, drawing data from $options[$number] 
    2317    $sermons = sb_get_sermons(array( 
    2418            'preacher' => $preacher, 
     
    2822        array(), 1, $limit       
    2923    ); 
    30 ?> 
    31     <ul class="sermon-widget"> 
    32     <?php foreach ((array) $sermons as $sermon): ?> 
    33         <li><span class="sermon-title"><a href="<?php sb_print_sermon_link($sermon) ?>"><?php echo stripslashes($sermon->title) ?></a></span> 
    34             <?php   if ($display_passage): ?><span class="sermon-passage">(<?php $foo = unserialize($sermon->start); $bar = unserialize($sermon->end); echo sb_get_books($foo[0], $bar[0]) ?>)</span><?php endif;  
    35                     if ($display_preacher): ?><span class="sermon-preacher"> <?php _e('by', $sermon_domain) ?> <a href="<?php sb_print_preacher_link($sermon) ?>"><?php echo stripslashes($sermon->preacher) ?></a></span><?php endif;  
    36                     if ($display_date): ?><span class="sermon-date"><?php _e(' on ', $sermon_domain); echo sb_format_date(strtotime($sermon->date)); ?></span><?php endif ?>. 
    37         </li>        
    38     <?php endforeach ?> 
    39     </ul> 
    40 <?php 
    41 } 
    42  
    43  
     24    echo "<ul class=\"sermon-widget\">\r"; 
     25    foreach ((array) $sermons as $sermon) { 
     26        echo "\t<li>"; 
     27        echo "<span class=\"sermon-title\"><a href=\""; 
     28        sb_print_sermon_link($sermon); 
     29        echo "\">".stripslashes($sermon->title)."</a></span>"; 
     30        if ($display_passage) { 
     31            $foo = unserialize($sermon->start); 
     32            $bar = unserialize($sermon->end); 
     33            echo "<span class=\"sermon-passage\"> (".sb_get_books($foo[0], $bar[0]).")</span>"; 
     34        } 
     35        if ($display_preacher) { 
     36            echo "<span class=\"sermon-preacher\">".__('by', $sermon_domain)." <a href=\""; 
     37            sb_print_preacher_link($sermon); 
     38            echo "\">".stripslashes($sermon->preacher)."</a></span>"; 
     39        } 
     40        if ($display_date) 
     41            echo "<span class=\"sermon-date\"> ".__('on', $sermon_domain)." ".sb_format_date(strtotime($sermon->date))."</span> "; 
     42        if ($display_player) 
     43            sb_display_mini_player($sermon); 
     44        echo ".</li>\r"; 
     45    } 
     46    echo "</ul>\r"; 
     47} 
     48 
     49// Registers the Sermon Browser widget 
    4450function sb_widget_sermon_init() { 
    4551    global $sermon_domain; 
    4652    if ( !$options = get_option('sb_widget_sermon') ) 
    4753        $options = array(); 
    48  
    4954    $widget_ops = array('classname' => 'sermon', 'description' => __('Sermon', $sermon_domain)); 
    5055    $control_ops = array('width' => 400, 'height' => 350, 'id_base' => 'sermon'); 
    5156    $name = __('Sermons', $sermon_domain); 
    52  
    5357    $registered = false; 
    5458    foreach ( array_keys($options) as $o ) { 
    55         // Old widgets can have null values for some reason 
    5659        if ( !isset($options[$o]['limit']) ) 
    5760            continue; 
    58  
    59         // $id should look like {$id_base}-{$o} 
    60         $id = "sermon-$o"; // Never never never translate an id 
     61        $id = "sermon-$o"; 
    6162        $registered = true; 
    6263        wp_register_sidebar_widget( $id, $name, 'sb_widget_sermon', $widget_ops, array( 'number' => $o ) ); 
    6364        wp_register_widget_control( $id, $name, 'sb_widget_sermon_control', $control_ops, array( 'number' => $o ) ); 
    6465    } 
    65  
    66     // If there are none, we register the widget's existance with a generic template 
    6766    if ( !$registered ) { 
    6867        wp_register_sidebar_widget( 'sermon-1', $name, 'sb_widget_sermon', $widget_ops, array( 'number' => -1 ) ); 
    6968        wp_register_widget_control( 'sermon-1', $name, 'sb_widget_sermon_control', $control_ops, array( 'number' => -1 )); 
    7069    } 
    71 } 
    72  
     70    register_sidebar_widget(__('Sermon Browser tags', $sermon_domain), 'sb_widget_tag_cloud'); 
     71} 
     72 
     73// Displays the tag cloud in the sidebar 
     74function sb_widget_tag_cloud ($args) { 
     75    global $sermon_domain; 
     76    extract($args); 
     77    echo $before_widget; 
     78    echo $before_title.__('Sermon Browser tags', $sermon_domain).$after_title; 
     79    sb_print_tag_clouds(); 
     80    echo $after_widget; 
     81} 
     82 
     83// Returns the first MP3 file attached to a sermon 
     84// Stats have to be turned off for iTunes compatibility 
     85function sb_first_mp3($sermon, $stats= TRUE) { 
     86    $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; 
     87    if (stripos($user_agent, 'itunes')===TRUE | stripos($user_agent, 'FeedBurner')===TRUE) 
     88        $stats = FALSE; 
     89    $stuff = sb_get_stuff($sermon, true); 
     90    $stuff = array_merge((array)$stuff['Files'], (array)$stuff['URLs']); 
     91    foreach ((array) $stuff as $file) { 
     92        if (strtolower(substr($file, strrpos($file, '.') + 1)) == 'mp3') { 
     93            if (substr($file,0,7) == "http://") { 
     94                if ($stats) 
     95                    $file=sb_display_url().sb_query_char().'show&amp;url='.URLencode($file); 
     96            } else { 
     97                if (!$stats) 
     98                    $file=sb_get_value('wordpress_url').get_option('sb_sermon_upload_dir').URLencode($file); 
     99                else 
     100                    $file=sb_display_url().sb_query_char().'show&amp;file_name='.URLencode($file); 
     101            } 
     102            return $file; 
     103            break; 
     104        } 
     105    } 
     106} 
     107 
     108// Displays the mini flash mp3 player (only if audio player is installed) 
     109function sb_display_mini_player ($sermon, $id=1, $flashvars="") { 
     110    $filename = sb_first_mp3($sermon, FALSE); 
     111    if ($filename !="") { 
     112        $flashvars .= "&foreColor=".str_replace("0x", "#", get_option("audio_player_rightbgcolor")); 
     113        $flashvars .= "&filename=".$filename; 
     114        if (substr($flashvars, 0, 1) == "&") 
     115            $flashvars = substr($flashvars, 1); 
     116        echo "<span class=\"sermon-player\"><embed id=\"oneBitInsert_{$id}\" width=\"10\" height=\"10\""; 
     117        if (get_option('audio_player_transparentpagebgcolor')=="true") 
     118            echo " wmode=\"transparent\""; 
     119        else 
     120            echo " bgcolor=\"".get_option('audio_player_pagebgcolor')."\""; 
     121        echo " quality=\"high\""; 
     122        echo " flashvars=\"".$flashvars."\""; 
     123        echo " src=\"".sb_get_value('plugin_url')."/sb-includes/"."1bit.swf\""; 
     124        echo " type=\"application/x-shockwave-flash\"/></span>"; 
     125    } 
     126} 
     127 
     128// Displays the widget 
    73129function sb_widget_sermon( $args, $widget_args = 1 ) { 
    74130    global $sermon_domain; 
     
    78134    $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); 
    79135    extract( $widget_args, EXTR_SKIP ); 
    80  
    81     // Data should be stored as array:  array( number => data for that instance of the widget, ... ) 
    82136    $options = get_option('sb_widget_sermon'); 
    83137    if ( !isset($options[$number]) ) 
    84138        return; 
    85          
    86139    extract($options[$number]); 
    87      
    88140    echo $before_widget; 
    89141    echo $before_title . $title . $after_title; 
    90     // Do stuff for this widget, drawing data from $options[$number] 
    91142    $sermons = sb_get_sermons(array( 
    92143            'preacher' => $preacher, 
     
    96147        array(), 1, $limit       
    97148    ); 
    98 ?> 
    99     <ul class="sermon-widget"> 
    100     <?php foreach ((array) $sermons as $sermon): ?> 
    101         <li><span class="sermon-title"><a href="<?php sb_print_sermon_link($sermon) ?>"><?php echo stripslashes($sermon->title) ?></a></span> 
    102             <?php   if ($book): ?><span class="sermon-passage">(<?php $foo = unserialize($sermon->start); $bar = unserialize($sermon->end); echo sb_get_books($foo[0], $bar[0]) ?>)</span><?php endif; 
    103                     if ($preacherz): ?><span class="sermon-preacher"> <?php _e('by', $sermon_domain) ?> <a href="<?php sb_print_preacher_link($sermon) ?>"><?php echo stripslashes($sermon->preacher) ?></a></span><?php endif; 
    104                     if ($date): ?><span class="sermon-date"> <?php _e(' on ', $sermon_domain); echo sb_format_date(strtotime($sermon->date)); ?></span><?php endif ?>. 
    105         </li>        
    106     <?php endforeach ?> 
    107     </ul> 
    108 <?php echo $after_widget; ?> 
    109 <?php 
    110 } 
     149    $i=0; 
     150    echo "<ul class=\"sermon-widget\">"; 
     151    foreach ((array) $sermons as $sermon){ 
     152        $i++; 
     153        echo "<li><span class=\"sermon-title\">"; 
     154        echo "<a href=".sb_build_url(array('sermon_id' => $sermon->id), true).">".stripslashes($sermon->title)."</a></span>"; 
     155        if ($book) { 
     156            $foo = unserialize($sermon->start); 
     157            $bar = unserialize($sermon->end); 
     158            echo " <span class=\"sermon-passage\">(".sb_get_books($foo[0], $bar[0]).")</span>"; 
     159        } 
     160        if ($preacherz) { 
     161            echo " <span class=\"sermon-preacher\">".__('by', $sermon_domain)." <a href=\""; 
     162            sb_print_preacher_link($sermon); 
     163            echo "\">".stripslashes($sermon->preacher)."</a></span>"; 
     164        } 
     165        if ($date) 
     166            echo " <span class=\"sermon-date\">".__(' on ', $sermon_domain).sb_format_date(strtotime($sermon->date))."</span>"; 
     167        if ($player) { 
     168            echo " "; 
     169            sb_display_mini_player($sermon, $i); 
     170        } 
     171        echo ".</li>"; 
     172    } 
     173    echo "</ul>"; 
     174    echo $after_widget; 
     175} 
     176 
     177// Displays the widget options and handles changes 
    111178function sb_widget_sermon_control( $widget_args = 1 ) { 
    112179    global $wpdb, $sermon_domain; 
    113180    global $wp_registered_widgets; 
    114     static $updated = false; // Whether or not we have already updated the data after a POST submit 
     181    static $updated = false; 
    115182     
    116183    $dpreachers = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}sb_preachers ORDER BY id;");  
     
    123190    extract( $widget_args, EXTR_SKIP ); 
    124191 
    125     // Data should be stored as array:  array( number => data for that instance of the widget, ... ) 
    126192    $options = get_option('sb_widget_sermon'); 
    127193    if ( !is_array($options) ) 
    128194        $options = array(); 
    129          
    130  
    131     // We need to update the data 
     195 
    132196    if ( !$updated && !empty($_POST['sidebar']) ) { 
    133         // Tells us what sidebar to put the data in 
    134197        $sidebar = (string) $_POST['sidebar']; 
    135  
    136198        $sidebars_widgets = wp_get_sidebars_widgets(); 
    137199        if ( isset($sidebars_widgets[$sidebar]) ) 
     
    139201        else 
    140202            $this_sidebar = array(); 
    141  
    142203        foreach ( $this_sidebar as $_widget_id ) { 
    143             // Remove all widgets of this type from the sidebar.  We'll add the new data in a second.  This makes sure we don't get any duplicate data 
    144             // since widget ids aren't necessarily persistent across multiple updates 
    145204            if ( 'sb_widget_sermon' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) { 
    146205                $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number']; 
    147                 if ( !in_array( "sermon-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed. "many-$widget_number" is "{id_base}-{widget_number} 
     206                if ( !in_array( "sermon-$widget_number", $_POST['widget-id'] ) ) 
    148207                    unset($options[$widget_number]); 
    149208            } 
    150209        } 
    151          
    152210        foreach ( (array) $_POST['widget-sermon'] as $widget_number => $widget_sermon_instance ) { 
    153             // compile data from $widget_many_instance 
    154             if ( !isset($widget_sermon_instance['limit']) && isset($options[$widget_number]) ) // user clicked cancel 
     211            if ( !isset($widget_sermon_instance['limit']) && isset($options[$widget_number]) ) 
    155212                continue; 
    156213            $limit = wp_specialchars( $widget_sermon_instance['limit'] ); 
     
    162219            $title = strip_tags(stripslashes($widget_sermon_instance['title'])); 
    163220            $date = (int) $widget_sermon_instance['date']; 
    164             $options[$widget_number] = array( 'limit' => $limit, 'preacherz' => $preacherz, 'book' => $book, 'preacher' => $preacher, 'service' => $service, 'series' => $series, 'title' => $title, 'date' => $date);  // Even simple widgets should store stuff in array, rather than in scalar 
    165         } 
    166  
     221            $player = (int) $widget_sermon_instance['player']; 
     222            $options[$widget_number] = array( 'limit' => $limit, 'preacherz' => $preacherz, 'book' => $book, 'preacher' => $preacher, 'service' => $service, 'series' => $series, 'title' => $title, 'date' => $date, 'player' => $player); 
     223        } 
    167224        update_option('sb_widget_sermon', $options); 
    168  
    169         $updated = true; // So that we don't go through this more than once 
    170     } 
    171  
    172  
    173     // Here we echo out the form 
    174     if ( -1 == $number ) { // We echo out a template for a form which can be converted to a specific form later via JS 
     225        $updated = true; 
     226    } 
     227 
     228    // Display widget form 
     229    if ( -1 == $number ) { 
    175230        $limit = ''; 
    176231        $preacherz = 0; 
     
    182237        $title =''; 
    183238        $date = ''; 
     239        $player = ''; 
    184240    } else { 
    185241        $limit = attribute_escape($options[$number]['limit']); 
     
    191247        $title = attribute_escape($options[$number]['title']); 
    192248        $date = (int) $options[$number]['date']; 
    193     } 
    194  
    195     // The form has inputs with names like widget-many[$number][something] so that all data for that instance of 
    196     // the widget are stored in one $_POST variable: $_POST['widget-many'][$number] 
     249        $player = attribute_escape($options[$number]['player']); 
     250    } 
     251 
    197252?> 
    198253        <p><?php _e('Title:'); ?> <input class="widefat" id="widget-sermon-title" name="widget-sermon[<?php echo $number; ?>][title]" type="text" value="<?php echo $title; ?>" /></p> 
    199254        <p> 
    200             <?php _e('Number of sermons: ', $sermon_domain) ?><input class="widefat" id="widget-sermon-limit-<?php echo $number; ?>" name="widget-sermon[<?php echo $number; ?>][limit]" type="text" value="<?php echo $limit; ?>" /><br /> 
    201              
    202             <input type="checkbox" id="widget-sermon-preacherz-<?php echo $number ?>" name="widget-sermon[<?php echo $number ?>][preacherz]" <?php echo $preacherz ? 'checked=checked' : '' ?> value="1"> <?php _e('Display preacher', $sermon_domain) ?> 
    203              
     255            <?php _e('Number of sermons: ', $sermon_domain) ?><input class="widefat" id="widget-sermon-limit-<?php echo $number; ?>" name="widget-sermon[<?php echo $number; ?>][limit]" type="text" value="<?php echo $limit; ?>" /> 
     256            <hr /> 
     257            <input type="checkbox" id="widget-sermon-preacherz-<?php echo $number ?>" name="widget-sermon[<?php echo $number ?>][preacherz]" <?php echo $preacherz ? 'checked=checked' : '' ?> value="1"> <?php _e('Display preacher', $sermon_domain) ?><br /> 
    204258            <input type="checkbox" id="widget-sermon-book-<?php echo $number ?>" name="widget-sermon[<?php echo $number ?>][book]" <?php echo $book ? 'checked=checked' : '' ?> value="1"> <?php _e('Display bible passage', $sermon_domain) ?><br /> 
    205              
    206             <input type="checkbox" id="widget-sermon-date-<?php echo $number ?>" name="widget-sermon[<?php echo $number ?>][date]" <?php echo $date ? 'checked=checked' : '' ?> value="1"> <?php _e('Display the date', $sermon_domain) ?><br /> 
    207             <?php _e('Preacher: ', $sermon_domain) ?><br /> 
    208             <select name="widget-sermon[<?php echo $number; ?>][preacher]" id="widget-sermon-preacher-<?php echo $number; ?>"> 
    209                 <option value="0" <?php echo $preacher ? '' : 'selected="selected"' ?>><?php _e('[All]', $sermon_domain) ?></option> 
    210                 <?php foreach ($dpreachers as $cpreacher): ?> 
    211                 <option value="<?php echo $cpreacher->id ?>" <?php echo $preacher == $cpreacher->id ? 'selected="selected"' : '' ?>><?php echo $cpreacher->name ?></option> 
    212                 <?php endforeach ?> 
    213             </select><br /> 
    214              
    215             <?php _e('Service: ', $sermon_domain) ?><br /> 
    216             <select name="widget-sermon[<?php echo $number; ?>][service]" id="widget-sermon-service-<?php echo $number; ?>"> 
    217                 <option value="0" <?php echo $service ? '' : 'selected="selected"' ?>><?php _e('[All]', $sermon_domain) ?></option> 
    218                 <?php foreach ($dservices as $cservice): ?> 
    219                 <option value="<?php echo $cservice->id ?>" <?php echo $service == $cservice->id ? 'selected="selected"' : '' ?>><?php echo $cservice->name ?></option> 
    220                 <?php endforeach ?> 
    221             </select><br /> 
    222              
    223             <?php _e('Series: ', $sermon_domain) ?><br /> 
    224             <select name="widget-sermon[<?php echo $number; ?>][series]" id="widget-sermon-series-<?php echo $number; ?>"> 
    225                 <option value="0" <?php echo $series ? '' : 'selected="selected"' ?>><?php _e('[All]', $sermon_domain) ?></option> 
    226                 <?php foreach ($dseries as $cseries): ?> 
    227                 <option value="<?php echo $cseries->id ?>" <?php echo $series == $cseries->id ? 'selected="selected"' : '' ?>><?php echo $cseries->name ?></option> 
    228                 <?php endforeach ?> 
    229             </select> 
     259            <input type="checkbox" id="widget-sermon-date-<?php echo $number ?>" name="widget-sermon[<?php echo $number ?>][date]" <?php echo $date ? 'checked=checked' : '' ?> value="1"> <?php _e('Display date', $sermon_domain) ?><br /> 
     260            <input type="checkbox" id="widget-sermon-player-<?php echo $number ?>" name="widget-sermon[<?php echo $number ?>][player]" <?php echo $player ? 'checked=checked' : '' ?> value="1"> <?php _e('Display mini-player', $sermon_domain) ?> 
     261            <hr /> 
     262            <table> 
     263                <tr> 
     264                    <td><?php _e('Preacher: ', $sermon_domain) ?></td> 
     265                    <td> 
     266                        <select name="widget-sermon[<?php echo $number; ?>][preacher]" id="widget-sermon-preacher-<?php echo $number; ?>"> 
     267                            <option value="0" <?php echo $preacher ? '' : 'selected="selected"' ?>><?php _e('[All]', $sermon_domain) ?></option> 
     268                            <?php foreach ($dpreachers as $cpreacher): ?> 
     269                                <option value="<?php echo $cpreacher->id ?>" <?php echo $preacher == $cpreacher->id ? 'selected="selected"' : '' ?>><?php echo $cpreacher->name ?></option> 
     270                            <?php endforeach ?> 
     271                        </select> 
     272                    </td> 
     273                </tr> 
     274                <tr> 
     275                    <td><?php _e('Service: ', $sermon_domain) ?></td> 
     276                    <td> 
     277                        <select name="widget-sermon[<?php echo $number; ?>][service]" id="widget-sermon-service-<?php echo $number; ?>"> 
     278                            <option value="0" <?php echo $service ? '' : 'selected="selected"' ?>><?php _e('[All]', $sermon_domain) ?></option> 
     279                            <?php foreach ($dservices as $cservice): ?> 
     280                                <option value="<?php echo $cservice->id ?>" <?php echo $service == $cservice->id ? 'selected="selected"' : '' ?>><?php echo $cservice->name ?></option> 
     281                            <?php endforeach ?> 
     282                        </select> 
     283                    </td> 
     284                </tr> 
     285                <tr> 
     286                    <td><?php _e('Series: ', $sermon_domain) ?></td> 
     287                    <td> 
     288                        <select name="widget-sermon[<?php echo $number; ?>][series]" id="widget-sermon-series-<?php echo $number; ?>"> 
     289                            <option value="0" <?php echo $series ? '' : 'selected="selected"' ?>><?php _e('[All]', $sermon_domain) ?></option> 
     290                            <?php foreach ($dseries as $cseries): ?> 
     291                                <option value="<?php echo $cseries->id ?>" <?php echo $series == $cseries->id ? 'selected="selected"' : '' ?>><?php echo $cseries->name ?></option> 
     292                            <?php endforeach ?> 
     293                        </select> 
     294                    </td> 
     295                </tr> 
     296            </table> 
    230297            <input type="hidden" id="widget-sermon-submit-<?php echo $number; ?>" name="widget-sermon[<?php echo $number; ?>][submit]" value="1" /> 
    231298        </p> 
  • sermon-browser/trunk/sermon.php

    r79266 r79270  
    55Description: Add sermons to your Wordpress blog. Main coding by <a href="http://codeandmore.com/">Tien Do Xuan</a>. Design and additional coding 
    66Author: Mark Barnes 
    7 Version: 0.39 
     7Version: 0.40 
    88Author URI: http://www.4-14.org.uk/ 
    99 
     
    2828 ** Initialisation                    ** 
    2929 **************************************/ 
    30 //add_action('update_option_permalink_structure', 'update_podcast_url'); 
    31 register_activation_hook( __FILE__, 'sb_activate' );            // Re-saves template on activation 
     30 
     31//Set global constants 
     32define('SB_CURRENT_VERSION', '0.40'); 
     33define('SB_DATABASE_VERSION', '1.5'); 
     34 
     35  
    3236add_action('init', 'sb_sermon_init');                           // Initialise the plugin 
    3337add_action('template_redirect', 'sb_hijack');                   // Check for file download or feed output 
     
    4246add_filter('wp_title', 'sb_page_title');                        // Amend page title on sermon pages 
    4347add_action('save_post', 'update_podcast_url');                  // Add check if [sermons] moves, and update podcast URL 
     48add_action('update_option_permalink_structure', 'update_podcast_url'); 
    4449if (SAVEQUERIES) add_action('wp_footer', 'sb_footer_stats');    // Add stats to footer if required (frontend) 
    4550if (SAVEQUERIES) add_action('admin_footer', 'sb_footer_stats'); // Add stats to footer if required (admin) 
     
    5358// Initialisation 
    5459function sb_sermon_init () { 
    55     global $sermon_domain; 
    56     //Set global constants 
    57     define('SB_CURRENT_VERSION', '0.39'); 
    58     define('SB_DATABASE_VERSION', '1.5'); 
     60    // Runs the upgrade procedures (re-save templates, and ping server) 
     61    function sb_upgrade ($old_version, $new_version) { 
     62        if ($old_version != "") { 
     63            sb_ping_gallery(); 
     64            $sbmf = get_option('sb_sermon_multi_form'); 
     65            if ($sbmf) 
     66                update_option('sb_sermon_multi_output', base64_encode(strtr(stripslashes(base64_decode($sbmf)), sb_search_results_dictionary()))); 
     67            $sbsf = get_option('sb_sermon_single_form'); 
     68            if ($sbsf)  
     69                update_option('sb_sermon_single_output', base64_encode(strtr(stripslashes(base64_decode($sbsf)), sb_sermon_page_dictionary()))); 
     70            update_option('sb_sermon_version', SB_CURRENT_VERSION); 
     71        } 
     72    } 
     73     
     74    global $sermon_domain, $wpdb, $defaultMultiForm, $defaultSingleForm, $defaultStyle; 
    5975    $directories = explode(DIRECTORY_SEPARATOR,dirname(__FILE__)); 
    6076    if ($directories[count($directories)-1] == 'mu-plugins') { 
     
    90106    if (ini_get('file_uploads')<>'1') ini_set('file_uploads', '1'); 
    91107 
    92     // Only proceed with install if necessary 
     108    // Check for Sermon Browser upgrade 
     109    $sb_version = get_option('sb_sermon_version'); 
     110    if ($sb_version != SB_CURRENT_VERSION) 
     111        sb_upgrade ($sb_version, SB_CURRENT_VERSION); 
     112 
     113    // Only proceed with install/upgrade if necessary 
    93114    $db_version = get_option('sb_sermon_db_version'); 
    94115    if($db_version == SB_DATABASE_VERSION) return; 
    95     global $wpdb; 
    96     global $defaultMultiForm, $defaultSingleForm, $defaultStyle; 
    97116    require_once(ABSPATH . 'wp-includes/pluggable.php'); 
    98117    require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
     
    137156                $wpdb->query("ALTER TABLE ".$wpdb->prefix."sb_sermons ADD page_id INT(10) NOT NULL"); 
    138157                add_option('sb_display_method', 'dynamic'); 
    139                 add_option('sb_sermons_per_page', '15'); 
     158                add_option('sb_sermons_per_page', '10'); 
    140159                add_option('sb_sermon_multi_output', base64_encode(strtr(sb_get_value('multi_form'), sb_search_results_dictionary()))); 
    141160                add_option('sb_sermon_single_output', base64_encode(strtr(sb_get_value('single_form'), sb_sermon_page_dictionary()))); 
     
    309328        add_option('sb_podcast', sb_get_value('wordpress_url').'?podcast'); 
    310329        add_option('sb_display_method', 'dynamic'); 
    311         add_option('sb_sermons_per_page', '15'); 
     330        add_option('sb_sermons_per_page', '10'); 
    312331        delete_option('sb_sermon_multi_form'); 
    313332        add_option('sb_sermon_multi_form', base64_encode(sb_default_multi_template())); 
     
    349368 **************************************/ 
    350369 
    351 // Runs upon activation 
    352 function sb_activate () { 
    353     // Re-saves the template in case of changes to dictionary.php 
    354     $sbmf = get_option('sb_sermon_multi_form'); 
    355     if ($sbmf) update_option('sb_sermon_multi_output', base64_encode(strtr(stripslashes(base64_decode($sbmf)), sb_search_results_dictionary()))); 
    356     $sbsf = get_option('sb_sermon_single_form'); 
    357     if ($sbsf) { 
    358         update_option('sb_sermon_single_output', base64_encode(strtr(stripslashes(base64_decode($sbsf)), sb_sermon_page_dictionary()))); 
    359         sb_ping_gallery(); 
    360     } 
    361     wp_die("Activated"); 
    362 } 
    363  
    364370// Adds javascript and CSS where required in admin 
    365371function sb_add_admin_headers() { 
     
    384390        $dir = sb_get_default('sermon_path'); 
    385391        if (sb_display_url()=="") { 
    386             update_option('sb_podcast', sb_get_value('wordpress_url').sb_query_char().'podcast'); 
     392            update_option('sb_podcast', sb_get_value('wordpress_url').sb_query_char(false).'podcast'); 
    387393        } else { 
    388             update_option('sb_podcast', sb_display_url().sb_query_char ().'podcast'); 
     394            update_option('sb_podcast', sb_display_url().sb_query_char(false).'podcast'); 
    389395        } 
    390396        update_option('sb_sermon_upload_dir', $dir); 
    391397        update_option('sb_sermon_upload_url', sb_get_default('attachment_url')); 
    392398        update_option('sb_display_method', 'dynamic'); 
    393         update_option('sb_sermons_per_page', '15'); 
     399        update_option('sb_sermons_per_page', '10'); 
    394400        if (!is_dir(sb_get_value('wordpress_path').$dir)) { 
    395401          if (sb_mkdir(sb_get_value('wordpress_path').$dir)) { 
     
    13781384    if((ini_get('allow_url_fopen') | function_exists(curl_init)) & get_option('blog_public') == 1 & get_option('ping_sites') != "") { 
    13791385        $url = "http://ping.preachingcentral.com/?sg_ping"; 
    1380         $url = $url."&name=".URLencode(get_option('blogname')); 
    1381         $url = $url."&tagline=".URLencode(get_option('blogdescription')); 
    1382         $url = $url."&site_url=".URLencode(get_option('siteurl')); 
    1383         $url = $url."&sermon_url=".URLencode(sb_display_url()); 
    1384         $url = $url."&most_recent=".URLencode($wpdb->get_var("SELECT date FROM {$wpdb->prefix}sb_sermons ORDER BY date DESC LIMIT 1")); 
    1385         $url = $url."&num_sermons=".URLencode($wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}sb_sermons")); 
    1386         $url = $url."&ver=".SB_CURRENT_VERSION; 
     1386        $url .= "&name=".URLencode(get_option('blogname')); 
     1387        $url .= "&tagline=".URLencode(get_option('blogdescription')); 
     1388        $url .= "&site_url=".URLencode(get_option('home')); 
     1389        $url .= "&sermon_url=".URLencode(sb_display_url()); 
     1390        $url .= "&most_recent=".URLencode($wpdb->get_var("SELECT date FROM {$wpdb->prefix}sb_sermons ORDER BY date DESC LIMIT 1")); 
     1391        $url .= "&num_sermons=".URLencode($wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}sb_sermons")); 
     1392        $url .= "&ver=".constant("SB_CURRENT_VERSION"); 
    13871393        if (ini_get('allow_url_fopen')) { 
    13881394            $headers = @get_headers($url, 1); 
     
    14641470        <h2>Filter</h2> 
    14651471            <form id="searchform" name="searchform">             
    1466             <fieldset> 
     1472            <fieldset style="float:left; margin-right: 1em"> 
    14671473                <legend><?php _e('Title', $sermon_domain) ?></legend> 
    14681474                <input type="text" size="17" value="" id="search" /> 
    14691475            </fieldset>              
    1470             <fieldset> 
     1476            <fieldset style="float:left; margin-right: 1em"> 
    14711477                <legend><?php _e('Preacher', $sermon_domain) ?></legend>                 
    14721478                <select id="preacher"> 
     
    14771483                </select> 
    14781484            </fieldset>  
    1479             <fieldset> 
     1485            <fieldset style="float:left; margin-right: 1em"> 
    14801486                <legend><?php _e('Series', $sermon_domain) ?></legend> 
    14811487                <select id="series"> 
     
    14851491                    <?php endforeach ?> 
    14861492                </select> 
    1487             </fieldset>                          
     1493            </fieldset style="float:left; margin-right: 1em">                            
    14881494            <input type="submit" class="button" value="<?php _e('Filter', $sermon_domain) ?> &raquo;" style="float:left;margin:14px 0pt 1em; position:relative;top:0.35em;" onclick="javascript:fetch(0);return false;" /> 
    14891495            </form> 
     
    18741880                </tr> 
    18751881                <tr> 
    1876                     <td> 
     1882                    <td style="overflow: visible"> 
    18771883                        <strong><?php _e('Date', $sermon_domain) ?></strong> (yyyy-mm-dd) 
    18781884                        <div> 
     
    21672173        <h4 id="sidebar">How do I get recent sermons to display in my sidebar?</h4> 
    21682174        <p>If your WordPress theme supports widgets, just go to Design and choose <a href="widgets.php">Widgets</a>. There you easily can add the Sermons widget to your sidebar. If your theme doesn't support widgets, you'll need to edit your theme manually. Usually, you'll be editing a file called <b>sidebar.php</b>, but your theme may give it a different name. Add the following code:</p> 
    2169         <p style="font-family:monospace">&lt;?php if (function_exists('display_sermons')) display_sermons(array('display_preacher' => 0, 'display_passage' => 1, 'preacher' => 0, 'service' => 0, 'series' => 0, 'limit' => 5)) ?></code> 
    2170         <p>Each of the numbers in that line can be changed. <b>display_preacher</b> and <b>display_passage</b> affect what is displayed (0 is off, 1 is on). <b>preacher</b>, <b>service</b> and <b>series</b> allow you to limit the output to a particular preacher, service or series. Simply change the number of the ID of the preacher/services/series you want to display. You can get the ID from the Preachers page, or the Series & Services page. 0 shows all preachers/services/series. <b>limit</b> is simply the maximum number of sermons you want displayed.</p> 
     2175        <p style="font-family:monospace">&lt;?php if (function_exists('display_sermons')) display_sermons(array('display_preacher' => 0, 'display_passage' => 1, 'display_date' => 1, 'display_player' => 1, 'preacher' => 0, 'service' => 0, 'series' => 0, 'limit' => 5)) ?></code> 
     2176        <p>Each of the numbers in that line can be changed. <b>display_preacher</b>, <b>display_passage</b>, <b>display_date</b>, and <b>display_player</b> affect what is displayed (0 is off, 1 is on). <b>preacher</b>, <b>service</b> and <b>series</b> allow you to limit the output to a particular preacher, service or series. Simply change the number of the ID of the preacher/services/series you want to display. You can get the ID from the Preachers page, or the Series & Services page. 0 shows all preachers/services/series. <b>limit</b> is simply the maximum number of sermons you want displayed.</p> 
    21712177        <h4 id="diskspace">My host only allows me a certain amount of disk space, and I have so many sermons uploaded, I've run out of space! What can I do?</h4> 
    21722178        <p>You could, of course, change your host to someone a little more generous! I use <a href="http://www.vortechhosting.com/shared/windows.php">VortechHosting</a> for low traffic sites (5Gb of disk space for less than $10 a month), and <a href="https://www.liquidweb.com/cart/content/vps/">LiquidWeb VPS</a> for higher traffic sites (20Gb disk space for $60 a month). You should also make sure you encode your sermons at a medium to high compression. Usually, 22.05kHz, 48kbps mono is more than adequate (you could probably go down to 32kbps for even higher compression). 48kbps means every minute of recording takes up 360kb of disk space, so a thirty minute sermon will just over 10Mb. At this setting, 5Gb would be enough for over 450 sermons.</p> 
     
    22462252            <li><b>[ylttext]</b> - Displays the full text of the <a href="http://en.wikipedia.org/wiki/Young%27s_Literal_Translation">YLT</a> Bible for all passages linked to that sermon.</li> 
    22472253            <li><b>[webtext]</b> - Displays the full text of the <a href="http://ebible.org/bible/web/">WEB</a> Bible for all passages linked to that sermon.</li> 
    2248             <li><b>[webtext]</b> - Displays the full text of the <a href="http://www.angelfire.com/al4/allenkc/akjv/">AKJV</a> Bible for all passages linked to that sermon.</li> 
    2249             <li><b>[webtext]</b> - Displays the full text of the <a href="http://ebible.org/bible/hnv/">HNV</a> Bible for all passages linked to that sermon.</li> 
     2254            <li><b>[akjvtext]</b> - Displays the full text of the <a href="http://www.angelfire.com/al4/allenkc/akjv/">AKJV</a> Bible for all passages linked to that sermon.</li> 
     2255            <li><b>[hnvtext]</b> - Displays the full text of the <a href="http://ebible.org/bible/hnv/">HNV</a> Bible for all passages linked to that sermon.</li> 
     2256            <li><b>[lbrvtext]</b> - Displays the full text of the <a href="http://en.wikipedia.org/wiki/Reina-Valera">Reina Valera</a> Bible (Spanish) for all passages linked to that sermon.</li> 
    22502257            <li><b>[biblepassage]</b> - Displays the reference of the bible passages for that sermon. Useful for utilising other bible plugins (see <a href="#otherversions">FAQ</a>).</li> 
    22512258    </div> 
     
    25962603    if (substr($existing_url, 0, strlen(sb_get_value('wordpress_url'))) == sb_get_value('wordpress_url')) { 
    25972604        if (sb_display_url(TRUE)=="") { 
    2598             update_option('sb_podcast', sb_get_value('wordpress_url').sb_query_char().'podcast'); 
     2605            update_option('sb_podcast', sb_get_value('wordpress_url').sb_query_char(false).'podcast'); 
    25992606        } else { 
    2600             update_option('sb_podcast', sb_display_url().sb_query_char ().'podcast'); 
     2607            update_option('sb_podcast', sb_display_url().sb_query_char(false).'podcast'); 
    26012608        } 
    26022609    } 
Note: See TracChangeset for help on using the changeset viewer.