<?php
/*
	Copyright(c) 2010 Shift Tech Inc. All Rights Reserved.
 	http://www.shift-tech.jp/

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

require_once (LIB_PATH.'/common/sectionIdxDB.php');
require_once (LIB_PATH.'/common/categoryDB.php');
require_once (LIB_PATH.'/common/pagecontainerDB.php');
require_once (LIB_PATH.'/common/unitDB.php');
require_once (LIB_PATH.'/common/pageunitDB.php');
require_once (LIB_PATH.'/common/pageView.php');
class Admin_admin_contents_page_Unitlist extends Model
{
	var $db=null;
	var $_container = array();
	var $_unit = array();
	
	function Admin_admin_contents_page_Unitlist()
	{
		$this->__construct();
	}
	function __construct()
	{
		Model::__construct();
		$this->db = new DataBase();
	}
	
	function prepare($view)
	{
		$this->_mprev = $this->getRequest('mprev') ? true : false;
		$view->assign("mprev",$this->_mprev);
		$this->_sidx_code = $this->getRequest('sidx_code') ? $this->getRequest('sidx_code') : "";
		$this->_cat_code = $this->getRequest('cat_code') ? $this->getRequest('cat_code') : "";
		$this->_pidx_code = $this->getRequest('pidx_code') ? $this->getRequest('pidx_code') : "";
		if(is_numeric($this->_sidx_code)) {
			$this->_sidx_data = sectionIdxDB::getData($this->_sidx_code,$this->_mprev);
		}
		if(is_numeric($this->_cat_code)) {
			$this->_cat_data = categoryDB::getData($this->_cat_code,$this->_mprev);
		}
		if(is_numeric($this->_pidx_code)) {
			$this->_pidx_data = pageIdxDB::getTmpData($this->_pidx_code);
		}
		
		return null;
	}

	function perform($view)
	{
		$view->assign('sidx_data',$this->_sidx_data);
		$view->assign('cat_data',$this->_cat_data);
		$view->assign('pidx_code',$this->_pidx_code);
		$view->assign('pidx_data',$this->_pidx_data);
		$view->assign('sidx_code',$this->_sidx_code);
		$view->assign('cat_code',$this->_cat_code);
		//url変換
		$url = pageView::getSiteURL($d=$this->_sidx_data["sidx_dir"],$c=$this->_cat_data["cat_dir"],$p=$this->_pidx_data["pidx_url"],$this->_sidx_data["sidx_ssl"],$prev=true,$this->_mprev);
		$view->assign('previewurl',$url);
		
        return 'contents/page/unitlist.tpl';
	}
}
?>
