Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-14-2008, 04:57 PM
reotto reotto is offline
 
Join Date: Oct 2007
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Coollege Football Scheduler Wordpress to vB conversion needed

All,

I found a good piece of code from a Wordpress programmer. I was curious as to if anyone knew how to translate this to work in vB. I have some XML files to use to get the results, but it is not going to help if I can't get it to work in vB.

PHP Code:
<?php
/*
Plugin Name: fanWidget  
Description: College Football Schedule for your WP Blog/Site
Author: Alvin Kreitman 
Version: 1.0
Plugin URI: http://www.techkismet.com/fanwidget_ncaa_football_for_wp
Author URI: http://techkismet.com
License: MIT License - http://www.opensource.org/licenses/mit-license.php
Warranties: See Licensing Information
Last Modified: 09/07/2007
*/

// Add the widget to plugin loading
function widget_fanwidget_init() {

        
// Check for the sidebar widget functions
    
if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
            return;
    
    
// This var is the URL to link to promote this wordpress widget
        
$home_url "http://techkismet.com/fanwidget_ncaa_football_for_wp";

    
// configuration form  
    
function widget_fanwidget_control() {
        
$options $newoptions get_option('widget_fanwidget');
        if (
$_POST['fanwidget-submit']) {
            
$newoptions['team_key'] = $_POST['fanwidget-team'];
            
$newoptions['fanwidget-title'] = $_POST['fanwidget-title'];
        }

        if (
$options != $newoptions) {
            
$options $newoptions;
            
update_option('widget_fanwidget'$options);
        }

        
// These XML files are for the use of this widget only.  If you want access to the data, please contact me.
        
$xmlstr file_get_contents("http://fanwidgets.com/wp-widgets/ncaafb_teams_xml.php");
        
$xml = new SimpleXMLElement($xmlstr);
    
        
# Build select dropdown
        
$s "<select name='fanwidget-team'>";
        foreach(
$xml->teams->entity as $e) {
            
$s .= '<option value="' $e->md5key '"' . ($e->md5key == $options['team_key'] ? ' selected' '') . '>' $e->DisplayName '</option>';
        }
        
$s .= "</select>";

        
?>
            <p style="text-align:left;"><label>Title: &nbsp; <input type="text" name="fanwidget-title" value = "<?= $options['fanwidget-title'?>"></label> </p>
            <p style="text-align:left;"><label>Team: &nbsp;
            <?= $s ?></label></p>
            <input type="hidden" id="fanwidget-submit" name="fanwidget-submit" value="1">
        <?php
    
        
}

    function 
widget_load_stylesheet() {
        echo 
'<link href="http://fanwidgets.com/wp-widgets/css/widget_style.css" rel="stylesheet" type="text/css" />';
    }

        
// This shows the widget on the sidebar
        
function widget_fanwidget($args) {
                
extract($args);
        
$options get_option('widget_fanwidget');
        
$title $options['fanwidget-title']; 

        
// These XML files are for the use of this widget only.  If you want access to the data, please contact me.
            // Page used as a parameter in XML requests.
            
$p get_bloginfo('url') . $_SERVER['REQUEST_URI'];

        
$xmlstr file_get_contents("http://fanwidgets.com/wp-widgets/ncaafb_schedule_xml.php?id={$options['team_key']}&p={$p}");
        
$xml = new SimpleXMLElement($xmlstr);

        
?>    
        <?php echo $before_widget?>
                    <?php print($before_title $title $after_title)  ?>

<div id="fanwidgets">
<h2><?= $xml->team_name ?> 
    <?php 
    $rank 
= (int) $xml->national_rank;
    if(
$rank 0) { 
        
?> 
        <span>(<?= $rank ?>)</span>
        <?php
    

    
?>
    </h2>
    <div class="rec">Record <?= $xml->overall_record ?> (Con:<?= $xml->conference_record ?>)</div>


<ul id="schedule">
    <?php
        
foreach ($xml->game as $g) { 
            
$team short_text($g->opponent_name19"..")
            
?>
            <li><div class="date"><?= $g->game_date ?></div>
            <div class="team"><?= ($g->home_away == "away" "at " "") . $team ?></div>
            <?php
                
if ($g->result == "0") {
                    
?>
                    <div class="result"><?= $g->game_time ?></div>
                    <?php
                
} else {
                    
?>
                    <div class="result <?= ($g->result == "W" " win" " loss"?>">
                    <?= $g->result " " $g->score ?></div>
                    <?php
                
}
            
?>
            <div class="clear"></div>
            </li>
        <?php
        
}
    
?>
</ul>

<p class="time">* All times are ET</p> 

<!-- to support this widget, please leave this link in here -->
<a href="<?= $home_url ?>"><img src="http://fanwidgets.com/wp-widgets/images/plus.gif" class="plus" border="0" /></a>
<div class="clear"></div>

</div>
<!-- please do not remove this comment or code  ||widget_key==b248e38421ff3cd18b6b2bb7174a87f2|| -->

            <?php echo $after_widget?>
        <?php
    
}

        
// Tell the sidebar about the Twitter widget and its control
        
register_sidebar_widget('fanWidget''widget_fanwidget');
        
register_widget_control('fanWidget''widget_fanwidget_control');
    
add_action('wp_head''widget_load_stylesheet');

    function 
short_text($text,$num,$trail) {

             
$chars $num;

            if (
strlen($text) > $chars) {
       
                    
$text $text." ";
                 
$text substr($text,0,$chars);
                 
#$text = substr($text,0,strrpos($text,' '));
                 
$text $text."$trail";
            }

             return 
$text;
    }

}

add_action('widgets_init''widget_fanwidget_init');

?>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:49 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04892 seconds
  • Memory Usage 2,214KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete