<?php
defined('PP_PATH') or exit;
class base_control extends control{
	public $_user = array();	// 用户
	public $_uid = 0;	//UID
	public $_group = array();	// 当前组
	public $_cfg = array();	// 全站参数
	public $_block = array();	// 全站参数

	function __construct() {

		$this->_cfg = $this->runtime->xget();
		$this->_cfg['party']  = $this->kv->xget('qq_login');
		$this->assign('pp', $this->_cfg);

		$this->_uid 		= session::get('_uid');
		if($this->_uid){
			$user = &$this->user;
			$this->_user = $user->get($this->_uid);
			$user->format($this->_user);
			
			$user_group = &$this->user_group;
			$this->_group = $user_group->get($this->_user['groupid']);
			$user_group->format($this->_group);
		}
		$block = $this->runtime->xget('block');
		$block_show = array();
		foreach($block as $k=>$t){
			if(!empty($t['isjs'])){
				$block_show[$k] = '<script src="'.$this->_cfg['webdir'].'upload/js/'.$k.'.js"></script>';
			}else{
				$block_show[$k] = $t['content'] ;
			}
		}
		$this->assign('pp_block', $block_show);
		// 获取资源分类下拉框
		$topcid = $this->category->get_smallid_upid(2,10);
		$this->assign('topcid', $topcid);
		//全站导航
		$nav_arr = $this->kv->xget('navigate');
		foreach($nav_arr as &$v) {
			if($v['cid']) {
				$v['url'] = $this->category->category_url($v['cid'], $v['alias']);
			}
			if(!empty($v['son'])) {
				foreach($v['son'] as &$v2) {
					if($v2['cid']) {
						$v2['url'] = $this->category->category_url($v2['cid'], $v2['alias']);
					}
				}
			}
		}
		$this->assign('pp_nav', $nav_arr);

		$this->assign('user', $this->_user);
		$this->assign('group', $this->_group);
	}
}