<?php
/**
 * CodeIgniter report view
 *
 * @category CodeIgniter
 * @license /_licenses/untermStrich/agb_normal.pdf
 * @author Christian Koller
 * @copyright 2009 untermStrich
 * @package views
 * @version $Id$
*/

if (!defined('BASEPATH')) { exit('No direct script access allowed'); }

require_once APPPATH.'us_libraries/US_report_view_result.php';

/**
 * A view for xslt
 */
class View_xslt extends US_report_view_result
{
    
    /**
     * Process the report based on the view mode
     *
     * @param   integer $mode   One of the US_report_view_result::M_... modes
     * @return  mixed   Either void or the filename
     *
     * @see US_report_view_result::M_DIRECT
     * @see US_report_view_result::M_FILE
     */
    protected function process($mode)
    {
        $processor = $this->_factory_processor($mode);

        $file_name_xsl = Report_config::xsl_from_name($this->viewinfo->xslt->xslfile, true);

        return $processor->process($mode, $this->viewinfo, $this->file_name, $file_name_xsl, $this->rephead, $this->designinfo);
    }

    /**
     * Loads an appropriate xslt processer
     *
     * @param   integer $mode   One of the My_controller::m_... modes
     * @return  View_xslt_processor
     */
    private function _factory_processor($mode)
    {

        require_once APPPATH.'views/Reports/xslt/Builtin.php';
        return new Xslt_builtin();
    }

} // END class View_xslt
