<?php

/**
 *--------------------------------------
 * single page
 *--------------------------------------
 * @project		: loga
 * @author		: cblee
 * @created		: 2016-07-10
 * @copyright	: (c)2016 AsThis
 *--------------------------------------
 */
defined('PFA_PATH') or exit('Access Denied');

class SinglePageCtrlr extends IndexCtrlr {
	public function show_single_page() {
		$singlePageId = intval(ARequest::get('single_page_id'));

		$pageSign = md5('SP|'.LANG_NAME.'|'.$singlePageId);
		$_SPI = S('_SPI'.$pageSign);
		if(empty($_SPI)) {
			$_SPI = M('SinglePage')->get_singlePageInfo($singlePageId);
			if(empty($_SPI)) {
				halt('', true, true);
			}
			S('_SPI'.$pageSign, $_SPI);
		}
		$this->assign('_V', $_SPI);

		/* html not support dynamic view */
		if(1 == $_SPI['sp_is_html'] and !is_nopc()) {
			$url = M('SinglePage')->build_url($singlePageId);
			redirect($url['sp_url']);
		}

		/* define current group */
		$this->assign('GROUP', $_SPI['sp_group']);
		$this->assign('SP_ID', $_SPI['single_page_id']);

		/* current position */
		if(is_nopc()) {
			$this->assign('_CP', $_SPI['sp_position_o']);
		}
		else {
			$this->assign('_CP', $_SPI['sp_position']);
		}

		$_SPI['sp_tpl'] = $_SPI['sp_tpl'] ? $_SPI['sp_tpl'] : 'show_single_page';

		if(IS_AJAX) {
			$this->display('home/ajax/'.$_SPI['sp_tpl']);
		}
		else {
			$this->display('home/'.$_SPI['sp_tpl']);
		}
	}
}

?>