<?php
/**
 * 印刷用ページ
 * 
 */
require_once 'Zend/Controller/Action.php';

class PrintController extends Zend_Controller_Action
{
    public function indexAction()
    {
    }
    
    public function viewAction()
    {
        global $config, $db, $manager, $currentContent;
        
        // id/[id]
        $request = $this->getRequest();
        $id = $request->getParam('id');
        
        ob_start();
        
        $sql = "SELECT type FROM Platy_Content_Base WHERE id={$id}";
        $row = $db->fetchRow($sql);
        
        $ContentType = $row['type'];
        
        //$url = BASE_FULL_URL . substr($currentNode, 1) . $row2['name'];
        $url = '';
        $currentContent = array('type'=>$ContentType, 'id'=>$id, 'url'=>$url);
        
        require(APP_PATH . 'models/ContentType/' . $ContentType . '.php');
        $classname = 'Platy_ContentType_' . $ContentType;
        $obj = new $classname($id);
        
        // status,期間のチェック
        $startDate = $obj->startDate;
        $endDate = $obj->endDate;
        $status = $obj->status;
        if ($status == 'public' && checkPeriod($startDate, $endDate) == true) {
            $link = $serverRoot . $currentPath;
            
            $manager->raiseEvent('PreViewContent');
            
            $obj->view($link);
        }
        
        $contents = ob_get_contents();
        ob_end_clean();
        
        Zend_Loader::loadClass('Zend_View');
        $view = new Zend_View();
        $view->setScriptPath(APP_PATH . 'views');
        $view->contents = $contents;
        $view->config = $config;
        echo $view->render('print.php');
    }
    
    public function noRouteAction()
    {
        //$this->_redirect('/');
        echo "noRouteAction";
    }
}
?>