Combining two functionaity into one

hey all, i am working on a project in which i got two separate folders doing two different things and i wanna combine 1st with 2nd so with every rss feed i get the social networking widget. i m unable to do it. is it possible? if so how… here is the code

<?php
class modSlickDetailedRSSHelper
{
    function getFeed(&$params)
    {
        //global $mainframe;
        $slick_detailed_rss = array(); //init feed array
        if(!class_exists('SimplePie')){
            //include Simple Pie processor class
            require_once (JPATH_SITE.DS.'libraries'.DS.'simplepie'.DS.'simplepie.php');
        }
        // check if cache directory exists and is writeable
        $cacheDir =  JPATH_BASE.DS.'cache';    
        if ( !is_writable( $cacheDir ) ) {    
            $slick_detailed_rss['error'][] = 'Cache folder is unwriteable. Solution: chmod 777 '.$cacheDir;
            $cache_exists = false;
        }else{
            $cache_exists = true;
        }
        //get local module parameters from xml file module config settings
        $rssurl         = $params->get( 'rssurl', NULL );
        $rssitems         = $params->get( 'rssitems', 5 );
        $rssdesc         = $params->get( 'rssdesc', 1 );
        $rssimage         = $params->get( 'rssimage', 1 );
        $rssitemtitle_words     = $params->get( 'rssitemtitle_words', 0 );
        $rssitemdesc        = $params->get( 'rssitemdesc', 0 );
        $rssitemdesc_images    = $params->get( 'rssitemdesc_images', 1 );
        $rssitemdesc_words    = $params->get( 'rssitemdesc_words', 0 );
        $rsstitle        = $params->get( 'rsstitle', 1 );
        $rsscache        = $params->get( 'rsscache', 3600 );
        $link_target        = $params->get( 'link_target', 1 );
        $no_follow        = $params->get( 'no_follow', 0 );    
        $enable_tooltip         = $params->get( 'enable_tooltip','yes' );
        $tooltip_desc_words    = $params->get( 't_word_count_desc', 25 );
        $tooltip_desc_images    = $params->get( 'tooltip_desc_images', 1 );
        $tooltip_title_words    = $params->get( 't_word_count_title', 25 );

        
        
        if(!$rssurl){
            $slick_detailed_rss['error'][] = 'Invalid feed url. Please enter a valid url in the module settings.';
            return $slick_detailed_rss; //halt if no valid feed url supplied
        }
        
        switch($link_target){ //open links in current or new window
            case 1:
                $link_target='_blank';
                break;
            case 0:
                $link_target='_self';
                break;
            default:
                $link_target='_blank';
                break;
        }
        $slick_detailed_rss['target'] = $link_target;
        if($no_follow){
            $slick_detailed_rss['nofollow'] = 'rel="nofollow"';
        }
        
        //Load and build the feed array
        $feed = new SimplePie();
        $feed->set_feed_url($rssurl);
        
        //check and set caching
        if($cache_exists) {
            $feed->set_cache_location($cacheDir);
            $feed->enable_cache();
            $cache_time = (intval($rsscache));
            $feed->set_cache_duration($cache_time);
        }
        else {
            $feed->enable_cache('false');
        }

        $feed->init(); //process the loaded feed
        $feed->handle_content_type();
        //store any error message
        if (isset($feed->error)) {
            $slick_detailed_rss['error'][] = $feed->error;
        }
            
        //start building the feed meta-info (title, desc and image)
        // feed title            
        if ( $feed->get_title() && $rsstitle ) {
            $slick_detailed_rss['title']['link'] = $feed->get_link();
            $slick_detailed_rss['title']['title'] = $feed->get_title();
        }    
        // feed description
        if ( $rssdesc ) {
            $slick_detailed_rss['description'] = $feed->get_description();
        }    
        // feed image
        if ( $rssimage && $feed->get_image_url() ) {
            $slick_detailed_rss['image']['url'] = $feed->get_image_url();
            $slick_detailed_rss['image']['title'] = $feed->get_image_title();
        }        
        //end feed meta-info
        
        //start processing feed items
        //if there are items in the feed
        if($feed->get_item_quantity()){    
        //start looping through the feed items
        $slick_rss_item = 0; //item counter for array indexing in the loop
        foreach ($feed->get_items(0, $rssitems) as $currItem) {
            
            // item title                            
            $item_title = trim($currItem->get_title());
            // item title word limit check
            if ( $rssitemtitle_words ) {
                $item_titles = explode( ' ', $item_title );
                $count = count( $item_titles );
                if ( $count > $rssitemtitle_words ) {
                    $item_title = '';
                    for( $i=0; $i < $rssitemtitle_words; $i++ ) {
                        $item_title .= ' '. $item_titles[$i];
                    }
                    $item_title .= '...';
                }
            }
            $slick_detailed_rss['items'][$slick_rss_item]['title'] = $item_title; // Item Title
            $slick_detailed_rss['items'][$slick_rss_item]['link'] = $currItem->get_permalink();
            
            // item description
            if($rssitemdesc){
                $desc = trim($currItem->get_description());
                if(!$rssitemdesc_images){
                    $desc = preg_replace("/<img[^>]+\\>/i", "", $desc); //strip image tags
                }    
                
                //item description word limit check
                if ( $rssitemdesc_words ) {
                    $texts = explode( ' ', $desc );
                    $count = count( $texts );
                    if ( $count > $rssitemdesc_words ) {
                        $desc = '';
                        for( $i=0; $i < $rssitemdesc_words; $i++ ) {
                            $desc .= ' '. $texts[$i]; //build words
                        }
                        $desc .= '...';
                    }
                }
                $slick_detailed_rss['items'][$slick_rss_item]['description'] = $desc; //Item Description
            }
            
            // tooltip text
            if ( $enable_tooltip == 'yes' ) {
                
                //tooltip item title
                $t_item_title = trim($currItem->get_title());
                
                // tooltip title word limit check
                if ( $tooltip_title_words ) {
                    $t_item_titles = explode( ' ', $t_item_title );
                    $count = count( $t_item_titles );
                    if ( $count > $tooltip_title_words ) {
                        $tooltip_title = '';
                        for( $i=0; $i < $tooltip_title_words; $i++ ) {
                            $tooltip_title .= ' '. $t_item_titles[$i];
                        }
                        $tooltip_title .= '...';                        
                    }else{
                        $tooltip_title = $t_item_title;    
                    }
                }else{
                    $tooltip_title = $t_item_title;    
                }
                
                $tooltip_title = preg_replace("/(\\r\
|\
|\\r)/", " ", $tooltip_title); //replace new line characters in tooltip title, important!
                $tooltip_title = htmlspecialchars(html_entity_decode($tooltip_title), ENT_QUOTES); //format text for tooltip
                $slick_detailed_rss['items'][$slick_rss_item]['tooltip']['title'] = $tooltip_title; //Tooltip Title
                
                //tooltip item description
                $text = trim($currItem->get_description());
                if(!$tooltip_desc_images){
                    $text = preg_replace("/<img[^>]+\\>/i", "", $text);
                }
                
                // tooltip desc word limit check
                if ( $tooltip_desc_words ) {
                    $texts = explode( ' ', $text );
                    $count = count( $texts );
                    if ( $count > $tooltip_desc_words ) {
                        $text = '';
                        for( $i=0; $i < $tooltip_desc_words; $i++ ) {
                            $text .= ' '. $texts[$i];
                        }
                        $text .= '...';
                    }
                }
                $text = preg_replace("/(\\r\
|\
|\\r)/", " ", $text); //replace new line characters in tooltip, important!
                $text = htmlspecialchars(html_entity_decode($text), ENT_QUOTES); //format text for tooltip
                $slick_detailed_rss['items'][$slick_rss_item]['tooltip']['description'] = $text; //Tooltip Body
            }else{ 
                $slick_detailed_rss['items'][$slick_rss_item]['tooltip'] = array(); //blank
            }                                    
            
            $slick_rss_item++; //increment item counter
        }                
        
        } //end item quantity check if statement
            
        //return the feed data structure for the template    
        return $slick_detailed_rss;
    }
}


and i want this file to return with every loop of first one

    # add the css style to the head
    $doc = &JFactory::getDocument();
    $doc->addStyleSheet('modules/mod_social_widgets/css/main.css');

    # get module params
    $twitter_login = $params->get('twitter_login', '');
    $twitter_widget = $params->get('twitter_widget', '');

    $small_twitter = $params->get('small_twitter', '');
    $small_facebook = $params->get('small_facebook', '');
    
    $big_twitter = $params->get('big_twitter', '');
    $big_facebook = $params->get('big_facebook', '');
    $big_share_facebook = $params->get('big_share_facebook', '');

    $facebook = $params->get('facebook', '');
    $twitter = $params->get('twitter', '');
    $myspace = $params->get('myspace', '');
    $stumbleupon = $params->get('stumbleupon', '');
    $reddit = $params->get('reddit', '');
    $delicious = $params->get('delicious', '');
    $google = $params->get('google', '');
    $mail = $params->get('mail', '');
    $print = $params->get('print', '');

    $number_of_tweets = $params->get('number_of_tweets', '');
    $show_avatars = $params->get('show_avatars', '');
    $show_timestamps = $params->get('show_timestamps', '');
    $show_hashtags = $params->get('show_hashtags', '');
    
    $shell_background = $params->get('shell_background', '');
    $shell_color = $params->get('shell_color', '');
    $tweets_background = $params->get('tweets_background', '');
    $tweets_color = $params->get('tweets_color', '');
    $tweets_links = $params->get('tweets_links', '');
    
    $icons_size = $params->get('icons_size', '');

    $social_url = JURI::current();

echo '<div class="social_module">';

if ($facebook != "hide" or $twitter != "hide" or $myspace != "hide" or $stumbleupon != "hide" or $reddit != "hide" or $delicious != "hide" or $google != "hide" or $mail != "hide" or $print != "hide") {
    echo <<<EOT

<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
<div class="addthis_toolbox">
   <div class="custom_images">
EOT;
    if ($facebook == "show") { 
        echo '<a class="addthis_button_facebook"><img src="modules/mod_social_widgets/images/'.$icons_size.'/facebook.png" alt="Share to Facebook" /></a>&nbsp;'; 
    }
    if ($twitter == "show") {
        echo '<a class="addthis_button_twitter"><img src="modules/mod_social_widgets/images/'.$icons_size.'/twitter.png" alt="Share to Twitter" /></a>&nbsp;';
    }
    if ($myspace == "show") {
        echo '<a class="addthis_button_myspace"><img src="modules/mod_social_widgets/images/'.$icons_size.'/myspace.png" alt="Share to MySpace" /></a>&nbsp;';
    }
    if ($stumbleupon == "show") {
        echo '<a class="addthis_button_stumbleupon"><img src="modules/mod_social_widgets/images/'.$icons_size.'/stumbleupon.png" alt="Stumble It" /></a>&nbsp;';
    }
    if ($reddit == "show") {
        echo '<a class="addthis_button_reddit"><img src="modules/mod_social_widgets/images/'.$icons_size.'/reddit.png" alt="Share to Reddit" /></a>&nbsp;';
    }
    if ($delicious == "show") {
        echo '<a class="addthis_button_delicious"><img src="modules/mod_social_widgets/images/'.$icons_size.'/delicious.png" alt="Share to Delicious" /></a>&nbsp;';
    }
    if ($google == "show") {
        echo '<a class="addthis_button_google"><img src="modules/mod_social_widgets/images/'.$icons_size.'/google.png" alt="Share to Google Buzz" /></a>&nbsp;';
    }
    if ($mail == "show") {
        echo '<a class="addthis_button_email"><img src="modules/mod_social_widgets/images/'.$icons_size.'/email.png" alt="Email a Friend" /></a>&nbsp;';
    }
    if ($print == "show") {
        echo '<a class="addthis_button_print"><img src="modules/mod_social_widgets/images/'.$icons_size.'/print.png" alt="Print" /></a>&nbsp;';
    }
    echo <<<EOT
   </div>
</div>
EOT;
}

if ($small_twitter != "hide" or $small_facebook != "hide") {
    echo <<<EOT
<br/>
<div class="addthis_toolbox">
EOT;
    if ($small_facebook == "show"){
        echo '<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>';
    }
    if ($small_twitter == "show"){
        echo '<a class="addthis_button_tweet"></a>';
    }
    echo <<<EOT
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
<br/>     
EOT;
}

if ($twitter_widget == "show") {

    if (empty($show_avatars)) {
        $show_avatars="false";
    }
    if (empty($show_timestamps)) {
        $show_timestamps="false";
    }
    if (empty($show_hashtags)) {
        $show_hashtags="false";
    }

    echo <<<EOT
<script src="http://widgets.twimg.com/j/2/widget.js" type="text/javascript"></script>
<script type="text/javascript">
new TWTR.Widget({
    version: 2,
    type: 'profile',
    rpp: $number_of_tweets,
    interval: 6000,
    width: 'auto',
    height: 250,
    theme: {
        shell: {
            background: '$shell_background',
            color: '$shell_color'
        },
        tweets: {
            background: '$tweets_background',
            color: '$tweets_color',
            links: '$tweets_links'
        }
    },
    features: {
        scrollbar: false,
        loop: false,
        live: false,
        hashtags: $show_hashtags,
        timestamp: $show_timestamps,
        avatars: $show_avatars,
        behavior: 'all'
    }
}).render().setUser('$twitter_login').start();
</script>
EOT;
}

if ($big_twitter == "show") {
    echo <<<EOT
<a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<br/><br/>
EOT;
}

if ($big_facebook == "show") {
    echo <<<EOT
<iframe src="http://www.facebook.com/plugins/like.php?href=$social_url&amp;layout=standard&amp;show_faces=true&amp;width=150&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:80px;" allowTransparency="true"></iframe>
EOT;
}

if ($big_share_facebook == "show") {
    echo <<<EOT
<a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
<br/><br/>
EOT;
}

?>