Exemplo n.º 1
0
function nvweb_list_get_from_twitter($username, $cache_time = 3600, $offset, $items = 10, $permission, $order)
{
    $url = 'https://api.twitter.com/1/statuses/user_timeline.rss?include_rts=true&contributor_details=false&screen_name=' . $username . '&count=' . $items;
    $feed = new feed_parser();
    $feed->set_cache($cache_time);
    $feed->load($url);
    list($channel, $articles) = $feed->parse('items', $offset, $order);
    $items = item::convert_from_rss($articles);
    return array($items, count($items));
}
Exemplo n.º 2
0
function run()
{
    global $user;
    switch (@$_REQUEST['act']) {
        case 'json':
            switch ($_REQUEST['oper']) {
                case 'settings_panels':
                    // save dashboard panels state
                    $dashboard_panels = $_REQUEST['dashboard_panels'];
                    $user->setting('dashboard-panels', json_encode($dashboard_panels));
                    echo json_encode(true);
                    core_terminate();
                    break;
                case 'feed':
                    $feed = new feed_parser();
                    $feed->set_cache(4 * 3600);
                    // once update each 4 hours
                    $feed->load($_REQUEST['url']);
                    list($channel, $articles, $count) = $feed->parse(0, $_REQUEST['limit'], 'newest');
                    $items = item::convert_from_rss($articles);
                    $display_language = $_REQUEST['language'];
                    if (!empty($items)) {
                        $feed_html = '';
                        for ($c = 0; $c < count($items); $c++) {
                            if (empty($items[$c])) {
                                break;
                            }
                            if (!isset($items[$c]->dictionary[$display_language])) {
                                // requested language not available, get the first available in the feed
                                $feed_languages = array_keys($items[$c]->dictionary);
                                $display_language = $feed_languages[0];
                            }
                            $tmp = array('<div class="navigate-panel-body-title ui-corner-all">' . '<a href="' . $items[$c]->paths[$display_language] . '" target="_blank">' . core_ts2date($items[$c]->date_to_display, true) . ' ' . '<strong>' . $items[$c]->dictionary[$display_language]['title'] . '</strong>' . '</a>' . '</div>', '<div id="navigatecms-feed-item-' . $items[$c]->id . '" class="navigate-panel-recent-feed-element">' . $items[$c]->dictionary[$display_language]['section-main'] . '</div>');
                            $feed_html .= implode("\n", $tmp);
                        }
                    }
                    echo $feed_html;
                    core_terminate();
                    break;
                default:
                    // list or search
            }
            break;
        case 'recent_items':
            $ri = users_log::recent_items(value_or_default($_REQUEST['limit']), 10);
            if (!is_array($ri)) {
                $ri = array();
            }
            for ($i = 0; $i < count($ri); $i++) {
                $action = $ri[$i];
                $ri[$i]->_url = '?fid=' . $action->function . '&wid=' . $action->website . '&act=load&id=' . $action->item;
                $ri[$i]->_link = '<a href="' . $ri[$i]->_url . '" title="' . htmlspecialchars($action->item_title) . ' | ' . htmlspecialchars(t($action->function_title, $action->function_title)) . '"><img src="' . $action->function_icon . '" align="absmiddle" /> ' . core_string_cut($action->item_title, 33) . '</a>';
            }
            echo json_encode($ri);
            core_terminate();
            break;
        default:
            $out = dashboard_create();
    }
    return $out;
}