예제 #1
0
function capi_mkfeedtitle($feed)
{
    global $_SGLOBAL, $_SN, $_SCONFIG;
    $feed['title_data'] = empty($feed['title_data']) ? array() : unserialize($feed['title_data']);
    if (!is_array($feed['title_data'])) {
        $feed['title_data'] = array();
    }
    //title
    $searchs = $replaces = array();
    if ($feed['title_data'] && is_array($feed['title_data'])) {
        foreach (array_keys($feed['title_data']) as $key) {
            if ($key === "touser") {
                $dom = new DomDocument();
                @$dom->loadHTML($feed["title_data"]["touser"]);
                $urls = $dom->getElementsByTagName('a');
                $url = $urls->item(0);
                $value["title_data"]["touser"] = capi_fhtml($value["title_data"]["touser"]);
            }
            $searchs[] = '{' . $key . '}';
            $replaces[] = $feed['title_data'][$key];
        }
    }
    $searchs[] = '{actor}';
    $replaces[] = empty($actors) ? $_SN[$feed['uid']] : implode(lang('dot'), $actors);
    $feed['title_template'] = mktarget(str_replace($searchs, $replaces, $feed['title_template']));
    return $feed;
}
예제 #2
0
function mkfeed($feed, $actors = array())
{
    global $_SGLOBAL, $_SN, $_SCONFIG;
    $feed['title_data'] = empty($feed['title_data']) ? array() : unserialize($feed['title_data']);
    if (!is_array($feed['title_data'])) {
        $feed['title_data'] = array();
    }
    $feed['body_data'] = empty($feed['body_data']) ? array() : unserialize($feed['body_data']);
    if (!is_array($feed['body_data'])) {
        $feed['body_data'] = array();
    }
    //title
    $searchs = $replaces = array();
    if ($feed['title_data'] && is_array($feed['title_data'])) {
        foreach (array_keys($feed['title_data']) as $key) {
            $searchs[] = '{' . $key . '}';
            $replaces[] = $feed['title_data'][$key];
        }
    }
    $searchs[] = '{actor}';
    $replaces[] = empty($actors) ? "<a href=\"space.php?uid={$feed['uid']}\">" . $_SN[$feed['uid']] . "</a>" : implode(lang('dot'), $actors);
    $searchs[] = '{app}';
    if (empty($_SGLOBAL['app'][$feed['appid']])) {
        $replaces[] = '';
    } else {
        $app = $_SGLOBAL['app'][$feed['appid']];
        $replaces[] = "<a href=\"{$app['url']}\">{$app['name']}</a>";
    }
    $feed['title_template'] = mktarget(str_replace($searchs, $replaces, $feed['title_template']));
    //body
    $searchs = $replaces = array();
    if ($feed['body_data'] && is_array($feed['body_data'])) {
        foreach (array_keys($feed['body_data']) as $key) {
            $searchs[] = '{' . $key . '}';
            $replaces[] = $feed['body_data'][$key];
        }
    }
    $feed['magic_class'] = '';
    if ($feed['appid']) {
        if (!empty($feed['body_data']['magic_color'])) {
            $feed['magic_class'] = 'magiccolor' . $feed['body_data']['magic_color'];
        }
        if (!empty($feed['body_data']['magic_thunder'])) {
            $feed['magic_class'] = 'magicthunder';
        }
    }
    $searchs[] = '{actor}';
    $replaces[] = "<a href=\"space.php?uid={$feed['uid']}\">{$feed['username']}</a>";
    $feed['body_template'] = mktarget(str_replace($searchs, $replaces, $feed['body_template']));
    $feed['body_general'] = mktarget($feed['body_general']);
    //icon
    if ($feed['appid']) {
        $feed['icon_image'] = "image/icon/{$feed['icon']}.gif";
    } else {
        $feed['icon_image'] = "http://appicon.manyou.com/icons/{$feed['icon']}";
    }
    //阅读
    $feed['style'] = $feed['target'] = '';
    if ($_SCONFIG['feedread'] && empty($feed['id'])) {
        $read_feed_ids = empty($_COOKIE['read_feed_ids']) ? array() : explode(',', $_COOKIE['read_feed_ids']);
        if ($read_feed_ids && in_array($feed['feedid'], $read_feed_ids)) {
            $feed['style'] = " class=\"feedread\"";
        } else {
            $feed['style'] = " onclick=\"readfeed(this, {$feed['feedid']});\"";
        }
    }
    if ($_SCONFIG['feedtargetblank']) {
        $feed['target'] = ' target="_blank"';
    }
    //管理
    if (in_array($feed['idtype'], array('blogid', 'picid', 'sid', 'pid', 'eventid', 'bwztid'))) {
        $feed['showmanage'] = 1;
    }
    //是否自身应用
    $feed['thisapp'] = 0;
    if ($feed['appid'] == UC_APPID) {
        $feed['thisapp'] = 1;
    }
    return $feed;
}