Пример #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;
}
Пример #2
0
function xt_init_page($page = 'home', $page_name = '首页', $cache = false)
{
    global $xt_registered_widgets, $xt_page_widgets_setting, $xt_page_layouts, $xt_page_widgets, $xt_current_page, $xt_widget_factory, $xt_need_cache;
    $xt_current_page = $page;
    $isEdit = defined('XT_PAGE_EDIT') && XT_PAGE_EDIT;
    if (!$isEdit && $cache && ($xt_current_page == 'home' || is_numeric($xt_current_page))) {
        $cache = xt_get_option(XT_OPTION_PAGE_HTML_PRE . $page);
        if (!empty($cache)) {
            if (time() < $cache['time'] + 3600 && !empty($cache['data'])) {
                $cache = xt_cache_covert($cache);
                $time = gmdate('Y-m-d H:i:s', $cache['time'] + xt_get_option('gmt_offset') * 3600);
                echo '<!--CACHE[' . $time . '] START-->' . $cache['data'] . '<!--CACHE[' . $time . '] END-->';
                return false;
            }
        }
    }
    xt_register_page(array('name' => $page_name, 'id' => $page, 'description' => '', 'class' => ''));
    $xt_registered_widgets = array();
    $xt_widget_factory = new XT_Widget_Factory();
    $widgetsAndLayouts = xt_get_option_page($page);
    $xt_page_widgets_setting = $widgetsAndLayouts['widgets'];
    $xt_page_layouts = xt_layout_convert($widgetsAndLayouts['layouts']);
    $xt_page_layouts = $xt_page_layouts['layouts'];
    $xt_need_cache = true;
    if (!$isEdit && empty($xt_page_layouts)) {
        if (!xt_is_headerOrfooter($xt_current_page)) {
            $isInstalled = get_option(XT_OPTION_INSTALLED);
            $xt_need_cache = false;
            $xt_page_layouts = array(array('name' => 'row-12', 'delete' => 0, 'layout' => array('span12' => array('text-2' => array('edit' => 0, 'delete' => 0)))));
            $text = '<div class="well xt-unvalid"><h1>尚未装修该页面</h1><p>登录<a href="http://plugin.xintaonet.com/" target="_blank">新淘客平台</a>-页面管理-设计!</p></div>';
            if (!$isInstalled) {
                $text = '<div class="well xt-unvalid"><h1>尚未初始化站点</h1><p>注册,登录<a href="http://plugin.xintaonet.com/" target="_blank">新淘客平台</a>添加验证自己的网站即可初始化!</p></div>';
            }
            $xt_page_widgets_setting = array('text-2' => array('title' => '', 'text' => $text, 'filter' => 0, 'widefat' => 0, 'widget' => 1, 'widget_id' => 'text-2', 'widget_name' => 'text'));
        }
    }
    $_widgets = xt_widgets();
    foreach ($_widgets as $_widget) {
        xt_register_widget($_widget);
    }
    do_action('xt_widgets_init');
    return true;
}