Ejemplo n.º 1
0
function xt_yiqifa_hotactivity($isSync = false)
{
    global $xt_yiqifa_hotactivities;
    if (!$isSync) {
        if (empty($xt_yiqifa_hotactivities)) {
            $xt_yiqifa_hotactivities = xt_get_option(XT_OPTION_YIQIFA_HOTACTIVITY);
        }
    }
    if ($isSync || empty($xt_yiqifa_hotactivities)) {
        $xt_yiqifa_hotactivities = array();
        $websites = xt_yiqifa_hotactivity_website();
        if (!empty($websites)) {
            foreach ($websites as $site) {
                $activities = array();
                for ($i = 1; $i < 10; $i++) {
                    $result = xt_yiqifa_api_hotactivity_list(array('webid' => $site['web_id'], 'page_no' => $i));
                    if (is_wp_error($result)) {
                        continue;
                    } else {
                        $hots = array();
                        foreach ($result['hot_list']['hot'] as $hot) {
                            parse_str($hot['hot_o_url'], $params);
                            $hot['hot_o_url'] = isset($params['t']) ? $params['t'] : $hot['hot_o_url'];
                            $hots[] = $hot;
                        }
                        $activities = array_merge($activities, $hots);
                    }
                }
                $xt_yiqifa_hotactivities[$site['web_id']] = $activities;
            }
        }
        if (!empty($xt_yiqifa_hotactivities)) {
            if (!xt_add_option(XT_OPTION_YIQIFA_HOTACTIVITY, $xt_yiqifa_hotactivities, '', 'no')) {
                xt_update_option(XT_OPTION_YIQIFA_HOTACTIVITY, $xt_yiqifa_hotactivities);
            }
        }
    }
    return $xt_yiqifa_hotactivities;
}
Ejemplo n.º 2
0
/**
 * Display dynamic page.
 */
function xt_dynamic_page($isDynamic = true)
{
    global $xt_current_page, $xt_need_cache;
    if (!$isDynamic) {
        return false;
    }
    $isCache = $xt_current_page == 'home' || is_numeric($xt_current_page) ? true : false;
    ob_start();
    $did_one = false;
    xt_dynamic_layout();
    $out = ob_get_contents();
    ob_end_clean();
    if (defined('XT_PAGE_EDIT') && XT_PAGE_EDIT) {
        // no cache
        $isCache = false;
    }
    if ($isCache && $xt_need_cache) {
        $cache = array('data' => $out, 'time' => time());
        if (!xt_add_option(XT_OPTION_PAGE_HTML_PRE . $xt_current_page, $cache, '', 'no')) {
            xt_update_option(XT_OPTION_PAGE_HTML_PRE . $xt_current_page, $cache);
        }
    }
    echo $out;
    return $did_one;
}