dtjo51649 2016-01-27 14:33
浏览 34

用于Wordpress社交板插件修改的XML提要

At work, I've been tasked with modifying the Wordpress Social Board plugin by duplicating their RSS feed functionality to display an XML feed specific to our calendaring system.

For example, this is what our XML feed outputs:

<?xml version="1.0"?>
<events>
<event>
<eventid>1449080815796</eventid>
<sponsorid>14</sponsorid>
<inputsponsor>Administration</inputsponsor>
<displayedsponsor>Lesbian, Gay, Bisexual, and Transgender (LGBT) Resource Center, The Division of Student Affairs</displayedsponsor>
<displayedsponsorurl></displayedsponsorurl>
<date>2016-01-25</date>
<timebegin>18:00</timebegin>
<timeend>20:00</timeend>
<repeat_vcaldef></repeat_vcaldef>
<repeat_startdate></repeat_startdate>
<repeat_enddate></repeat_enddate>
<categoryid>119</categoryid>
<category>Diversity</category>
<title>New 2 &apos;Quse Discussion Group</title>
<description>New 2 &apos;Quse is a discussion group for students who are new to SU/ESF and the lesbian, gay, bisexual, transgender, queer, asexual, and ally (LGBTQA) campus communities.</description>
<location>LGBT Resource Center (750 Ostrom)</location>
<price></price>
<contact_name>Abby Fite</contact_name>
<contact_phone>443-3983</contact_phone>
<contact_email>alfite@syr.edu</contact_email>
<url>http://lgbt.syr.edu</url>
<recordchangedtime>2015-12-02 13:26:55</recordchangedtime>
<recordchangeduser>dsalgbt2</recordchangeduser>
</event>
</events>

There is one place in the code that actually formats their RSS feed:

elseif ( $feed_class == 'rss' ) {
                $rss_output = (@$this->sboption['section_rss']['rss_output']) ? $this->sboption['section_rss']['rss_output'] : array('title' => true, 'thumb' => true, 'text' => true, 'user' => true, 'tags' => false, 'share' => true, 'info' => true);
                $iframe = @$this->sboption['section_rss']['rss_iframe'];
                $fcount = 0;
                if ( $channel = @$feed->channel ) { // rss
                    if (@$channel->item)
                    foreach($channel->item as $item) {
                        $link = @$item->link;
                        if ( $this->make_remove($link) ) {
                        $fcount++;

                        $thumb = $url = '';
                        foreach($item->children('media', true)->thumbnail as $thumbnail) {
                            $thumb = $thumbnail->attributes()->url;
                        }
                        if ( ! $thumb) {
                            foreach($item->children('media', true)->content as $content) {
                                $thumb = $content->children('media', true)->thumbnail->attributes()->url;
                                if (@$content->attributes()->type == 'image/jpeg')
                                    $url = @$content->attributes()->url;
                            }
                        }
                        if ( ! $thumb) {
                            if (@$item->enclosure->attributes()->type == 'image/jpeg')
                                $thumb = @$item->enclosure->attributes()->url;
                        }

                        if (@$item->category && @$rss_output['tags'])
                        foreach($item->category as $category) {
                            $cats[] = (string) $category;
                        }

                        // set Snippet or Full Text
                        $text = $description = '';
                        if (@$this->sboption['section_rss']['rss_text'])
                            $description = $item->description;
                        else
                            $description = (@$item->children("content", true)->encoded) ? $item->children("content", true)->encoded : $item->description;

                        if (@$description) {
                            $description = preg_replace("/<script.*?\/script>/s", "", $description);
                            if (@$attr['words']) {
                                if ( ! $thumb) {
                                    $thumb = sb_getsrc($description);
                                }
                                $text = $this->word_limiter($description, $link);
                            } else {
                                $text = $description;
                            }
                        }
                        if ($iframe) {
                            if ( ! $url)
                                $url = (@$thumb) ? $thumb : '';
                        }

                        $sbi = $this->make_timestr($item->pubDate, $link);
                        $itemdata = array(
                        'thumb' => (@$thumb) ? $thumb : '',
                        'thumburl' => $url,
                        'title' => '<a href="' . $link . '"'.$target.'>' . (@$attr['titles'] ? $this->title_limiter($item->title) : $item->title) . '</a>',
                        'text' => $text,
                        'tags' => @implode(', ', $cats),
                        'url' => $link,
                        'iframe' => $iframe ? 'icbox' : '',
                        'date' => $item->pubDate,
                        'user' => array(
                            'name' => $channel->title,
                            'url' => $channel->link,
                            'image' => @$channel->image->url
                            ),
                        'type' => 'pencil',
                        'icon' => array(@$themeoption['social_icons'][12], @$themeoption['type_icons'][0])
                        );
                        $final[$sbi] = $layoutobj->sb_create_item($feed_class, $itemdata, $attr, $rss_output, $sbi);
                        if ( isset($slideshow) ) {
                            $itemdata['text'] = @$this->format_text($description);
                            if ($url)
                                $itemdata['thumb'] = $url;
                            $finalslide[$sbi] = $slidelayoutobj->sb_create_slideitem($feed_class, $itemdata, $attr, $rss_output, $sbi);
                        }

                        if ( $fcount >= $results ) break;
                        }
                    }
                } elseif ( $entry = @$feed->entry ) { // atom
                    // get feed link
                    foreach($feed->link as $link) {
                        if ($link->attributes()->rel == 'alternate')
                            $user_url = $link->attributes()->href;
                    }
                    foreach($feed->entry as $item) {
                        $link = @$item->link[0]->attributes()->href;
                        if ( $this->make_remove($link) ) {
                        $fcount++;

                        $title = (string) $item->title;
                        $thumb = $url = '';
                        foreach($item->media as $thumbnail) {
                            $thumb = $thumbnail->attributes()->url;
                        }
                        if ( ! $thumb) {
                            foreach($item->link as $linkitem) {
                                if (@$linkitem->attributes()->rel == 'enclosure') {
                                    if (@$linkitem->attributes()->type == 'image/jpeg')
                                        $thumb = @$content->attributes()->url;
                                }
                            }
                        }

                        $cats = '';
                        if (@$item->category && @$rss_output['tags']) {
                            foreach($item->category as $category) {
                                $cats .= $category->attributes()->term.', ';
                            }
                            $cats = rtrim($cats, ", ");
                        }

                        // set Snippet or Full Text
                        $text = $description = '';
                        if (@$this->sboption['section_rss']['rss_text']) {
                            $description = (string) $item->summary;
                        } else {
                            $content = (string) @$item->content;
                            $description = ($content) ? $content : (string) $item->summary;
                        }

                        if (@$description) {
                            if (@$attr['words']) {
                                if ( ! $thumb) {
                                    $thumb = sb_getsrc($description);
                                }
                                $text = $this->word_limiter($description, $link);
                            }
                            else {
                                $text = $description;
                            }
                        }
                        if ($iframe)
                            $url = (@$thumb) ? $thumb : '';

                        $sbi = $this->make_timestr($item->published, $link);
                        $itemdata = array(
                        'thumb' => @$thumb,
                        'thumburl' => $url,
                        'title' => '<a href="' . $link . '"'.$target.'>' . (@$attr['titles'] ? $this->title_limiter($title) : $title) . '</a>',
                        'text' => @$text,
                        'tags' => @$cats,
                        'url' => $link,
                        'iframe' => $iframe ? 'icbox' : '',
                        'date' => $item->published,
                        'user' => array(
                            'name' => $feed->title,
                            'url' => @$user_url,
                            'image' => @$feed->logo
                            ),
                        'type' => 'pencil',
                        'icon' => array(@$themeoption['social_icons'][12], @$themeoption['type_icons'][0])
                        );
                        $final[$sbi] = $layoutobj->sb_create_item($feed_class, $itemdata, $attr, $rss_output, $sbi);
                        if ( isset($slideshow) ) {
                            $itemdata['text'] = @$this->format_text($description);
                            if ($url)
                                $itemdata['thumb'] = $url;
                            $finalslide[$sbi] = $slidelayoutobj->sb_create_slideitem($feed_class, $itemdata, $attr, $rss_output, $sbi);
                        }

                        if ( $fcount >= $results ) break;
                        }
                    }
                }
            }

I've duplicated the code into another feed class and modified, but it is not pulling any values it seems:

    elseif ( $feed_class == 'dsa' ) {
                $rss_output = (@$this->sboption['section_dsa']['dsa_output']) ? $this->sboption['section_dsa']['dsa_output'] : array('title' => true, 'thumb' => true, 'text' => true, 'user' => true, 'tags' => false, 'share' => true, 'info' => true);
                $iframe = @$this->sboption['section_dsa']['dsa_iframe'];
                $fcount = 0;
                if ( $channel = @$feed->events ) { // rss
                    if (@$channel->event)
                    foreach($channel->event as $item) {
                        $link = @$item->displayedsponsorurl;
                        if ( $this->make_remove($link) ) {
                        $fcount++;

                        $thumb = $url = '';
                        foreach($item->children('media', true)->thumbnail as $thumbnail) {
                            $thumb = $thumbnail->attributes()->url;
                        }
                        if ( ! $thumb) {
                            foreach($item->children('media', true)->content as $content) {
                                $thumb = $content->children('media', true)->thumbnail->attributes()->url;
                                if (@$content->attributes()->type == 'image/jpeg')
                                    $url = @$content->attributes()->url;
                            }
                        }
                        if ( ! $thumb) {
                            if (@$item->enclosure->attributes()->type == 'image/jpeg')
                                $thumb = @$item->enclosure->attributes()->url;
                        }

                        if (@$item->category && @$rss_output['tags'])
                        foreach($item->category as $category) {
                            $cats[] = (string) $category;
                        }

                        // set Snippet or Full Text
                        $text = $description = '';
                        if (@$this->sboption['section_dsa']['dsa_text'])
                            $description = $item->description;
                        else
                            $description = (@$item->children("content", true)->encoded) ? $item->children("content", true)->encoded : $item->description;

                        if (@$description) {
                            $description = preg_replace("/<script.*?\/script>/s", "", $description);
                            if (@$attr['words']) {
                                if ( ! $thumb) {
                                    $thumb = sb_getsrc($description);
                                }
                                $text = $this->word_limiter($description, $link);
                            } else {
                                $text = $description;
                            }
                        }
                        if ($iframe) {
                            if ( ! $url)
                                $url = (@$thumb) ? $thumb : '';
                        }

                        $sbi = $this->make_timestr($item->pubDate, $link);
                        $itemdata = array(
                        'thumb' => (@$thumb) ? $thumb : '',
                        'thumburl' => $url,
                        'title' => '<a href="' . $link . '"'.$target.'>' . (@$attr['titles'] ? $this->title_limiter($item->title) : $item->title) . '</a>',
                        'text' => $text,
                        'tags' => @implode(', ', $cats),
                        'url' => $link,
                        'iframe' => $iframe ? 'icbox' : '',
                        'date' => $item->date,
                        'user' => array(
                            'name' => $channel->title,
                            'url' => $channel->link,
                            'image' => @$channel->image->url
                            ),
                        'type' => 'pencil',
                        'icon' => array(@$themeoption['social_icons'][12], @$themeoption['type_icons'][0])
                        );
                        $final[$sbi] = $layoutobj->sb_create_item($feed_class, $itemdata, $attr, $rss_output, $sbi);
                        if ( isset($slideshow) ) {
                            $itemdata['text'] = @$this->format_text($description);
                            if ($url)
                                $itemdata['thumb'] = $url;
                            $finalslide[$sbi] = $slidelayoutobj->sb_create_slideitem($feed_class, $itemdata, $attr, $rss_output, $sbi);
                        }

                        if ( $fcount >= $results ) break;
                        }
                    }
                } elseif ( $entry = @$feed->entry ) { // atom
                    // get feed link
                    foreach($feed->link as $link) {
                        if ($link->attributes()->rel == 'alternate')
                            $user_url = $link->attributes()->href;
                    }
                    foreach($feed->entry as $item) {
                        $link = @$item->link[0]->attributes()->href;
                        if ( $this->make_remove($link) ) {
                        $fcount++;

                        $title = (string) $item->title;
                        $thumb = $url = '';
                        foreach($item->media as $thumbnail) {
                            $thumb = $thumbnail->attributes()->url;
                        }
                        if ( ! $thumb) {
                            foreach($item->link as $linkitem) {
                                if (@$linkitem->attributes()->rel == 'enclosure') {
                                    if (@$linkitem->attributes()->type == 'image/jpeg')
                                        $thumb = @$content->attributes()->url;
                                }
                            }
                        }

                        $cats = '';
                        if (@$item->category && @$rss_output['tags']) {
                            foreach($item->category as $category) {
                                $cats .= $category->attributes()->term.', ';
                            }
                            $cats = rtrim($cats, ", ");
                        }

                        // set Snippet or Full Text
                        $text = $description = '';
                        if (@$this->sboption['section_dsa']['dsa_text']) {
                            $description = (string) $item->summary;
                        } else {
                            $content = (string) @$item->content;
                            $description = ($content) ? $content : (string) $item->summary;
                        }

                        if (@$description) {
                            if (@$attr['words']) {
                                if ( ! $thumb) {
                                    $thumb = sb_getsrc($description);
                                }
                                $text = $this->word_limiter($description, $link);
                            }
                            else {
                                $text = $description;
                            }
                        }
                        if ($iframe)
                            $url = (@$thumb) ? $thumb : '';

                        $sbi = $this->make_timestr($item->published, $link);
                        $itemdata = array(
                        'thumb' => @$thumb,
                        'thumburl' => $url,
                        'title' => '<a href="' . $link . '"'.$target.'>' . (@$attr['titles'] ? $this->title_limiter($title) : $title) . '</a>',
                        'text' => @$text,
                        'tags' => @$cats,
                        'url' => $link,
                        'iframe' => $iframe ? 'icbox' : '',
                        'date' => $item->published,
                        'user' => array(
                            'name' => $feed->title,
                            'url' => @$user_url,
                            'image' => @$feed->logo
                            ),
                        'type' => 'pencil',
                        'icon' => array(@$themeoption['social_icons'][12], @$themeoption['type_icons'][0])
                        );
                        $final[$sbi] = $layoutobj->sb_create_item($feed_class, $itemdata, $attr, $rss_output, $sbi);
                        if ( isset($slideshow) ) {
                            $itemdata['text'] = @$this->format_text($description);
                            if ($url)
                                $itemdata['thumb'] = $url;
                            $finalslide[$sbi] = $slidelayoutobj->sb_create_slideitem($feed_class, $itemdata, $attr, $rss_output, $sbi);
                        }

                        if ( $fcount >= $results ) break;
                        }
                    }
                }
            }

I apologize for this being a highly specific question. I am inexperienced with PHP, especially for Wordpress plugins and have been tasked to get this working ASAP...

Am I just missing something with the operators not pulling in the values? I haven't set all the values yet, I'm just modifying the ones that already exist before moving onto adding anything.

There are no direct errors my logs pulled, so I believe it's just not pulling in the right values, but I'm not sure how to fix that.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)