<?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/pageunitDB.php');
require_once (LIB_PATH.'/common/templateDB.php');
class Admin_admin_template_Editin extends templateDB
{
	function prepare($view)
	{
		$this->_tpl_code = $this->getrequest("tpl_code");
		$this->_sidx_code = 1;

		if(is_numeric($this->_sidx_code)) {
			$this->_sidx_data = sectionIdxDB::getData($this->_sidx_code);
		}
		
		return null;
	}

	function perform($view)
	{
        
        //一般ページの情報セット
		require_once (LIB_PATH.'/common/pageView.php');
		$pageView = new pageView();
		$pageView->_prev = 1;
		$pageView->_tpl_editting = true;
		if(!$pageView->initPage(&$view)) {
			return BASE_PATH.'/app/view/404.tpl';
		}
		$view->assign('tpl_code',$this->_tpl_code);
		$view->assign('preview', ($this->_prev) ? 1 : 0);
		$view->assign('header',$pageView->_header);
		$view->assign('footer',$pageView->_footer);
		$view->assign('m_menu',$pageView->_gmenu);
		$view->assign('sub_menu',$pageView->_smenu);
		$view->assign('SIDE',$pageView->_sidebar);
		
		$view->assign('sidx_data',$pageView->_sidx_data);
		$view->assign('sidx_code',$this->_sidx_code);
		$view->assign('PAGEU_IMGPATH',str_replace(DOCUMENT_ROOT_PATH,"",UNITS_PATH));//サムネイル画像取得用
		
		$view->assign('WWW', WWW);
		$view->assign('WWW_SSL', WWW_SSL);
		$view->assign('SITENAME', SITENAME);
		$view->assign('ADMIN_MAIL', ADMIN_MAIL);
		//管理画面ではカウントさせない
		$view->assign('ANALYTICS', '');
		
		$view->assign('SIDEBARAREA', $pageView->_skinsetting["SIDEBARAREA"]);
		
		//パンくず
		if(isset($pageView->_template_data["tpl_pagenavi"])&&$pageView->_template_data["tpl_pagenavi"]==1) {
			$view->assign("PAGENAVI",array('<a href="#noscript">ナビ1（サンプル）</a>','<a href="#noscript">ナビ2</a>','ナビ3'));
		} else {
			$view->assign("PAGENAVI",' ');
		}
		$htmldata = $view->fetch("template/edit-in.tpl")."\n";//管理画面用パーツHTMLを生成
		$htmldata  .= $view->fetch("template/body.tpl")."\n";
		//登録済みコンテナ＆ユニット情報
		$view->assign('items',$htmldata);
		
		if($pageView->_skin_data["skin_path"]!=null) {
			$view->assign("CSS",$pageView->_skincss_path);
		}

        return $pageView->_sidx_data["skin_path"];
	}
}
?>