<?php

// +----------------------------------------------------------------------

// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]

// +----------------------------------------------------------------------

// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.

// +----------------------------------------------------------------------

// | Author: Dean <zxxjjforever@163.com>

// +----------------------------------------------------------------------

namespace Phonegame\Controller;

use Common\Controller\PhonegameController;

class PageController extends PhonegameController{

	public function index() {

		$id=$_GET['id'];

		$content=sp_sql_page($id);

		

		if(empty($content)){

		    header('HTTP/1.1 404 Not Found');

		    header('Status:404 Not Found');

		    if(sp_template_file_exists(MODULE_NAME."/404")){

		        $this->display(":404");

		    }

		     

		    return ;

		}

		

		$this->assign($content);

		$smeta=json_decode($content['smeta'],true);

		$tplname=isset($smeta['template'])?$smeta['template']:"";

		

		$tplname=sp_get_apphome_tpl($tplname, "page");

		

		$this->display($this->template.'/template1'.'/Index'.'/page');

	}

	

	public function nav_index(){

		$navcatname="页面";

		$datas=sp_sql_pages("field:id,post_title;");

		$navrule=array(

				"action"=>"Page/index",

				"param"=>array(

						"id"=>"id"

				),

				"label"=>"post_title");

		exit( sp_get_nav4admin($navcatname,$datas,$navrule) );

	}

}