2016-04-09 13:44:37 +02:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2016-10-28 21:43:18 +02:00
|
|
|
|
* Questlab
|
2016-04-09 13:44:37 +02:00
|
|
|
|
*
|
|
|
|
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
2016-10-28 21:43:18 +02:00
|
|
|
|
* @copyright 2014 – 2016 Heinrich-Heine-Universität Düsseldorf
|
2016-04-09 13:44:37 +02:00
|
|
|
|
* @license http://www.gnu.org/licenses/gpl.html
|
2016-10-28 21:43:18 +02:00
|
|
|
|
* @link https://github.com/coderkun/questlab
|
2016-04-09 13:44:37 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace hhu\z\views;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Abstract class for implementing a QuesttypeView.
|
|
|
|
|
*
|
|
|
|
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
|
|
|
|
*/
|
|
|
|
|
class QuesttypeView extends \nre\core\View
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Load and instantiate the QuesttypeView of a QuesttypeAgent.
|
|
|
|
|
*
|
|
|
|
|
* @throws \nre\exceptions\ViewNotFoundException
|
|
|
|
|
* @param string $layoutName Name of Layout in use
|
|
|
|
|
* @param string $agentName Name of the Agent
|
|
|
|
|
* @param string $action Current Action
|
|
|
|
|
* @param bool $isToplevel Agent is a ToplevelAgent
|
|
|
|
|
*/
|
|
|
|
|
public static function loadAndFactory($layoutName, $agentName=null, $action=null, $isToplevel=false)
|
|
|
|
|
{
|
|
|
|
|
return new QuesttypeView($layoutName, $agentName, $action, $isToplevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Construct a new QuesttypeView.
|
|
|
|
|
*
|
|
|
|
|
* @throws \nre\exceptions\ViewNotFoundException
|
|
|
|
|
* @param string $layoutName Name of Layout in use
|
|
|
|
|
* @param string $agentName Name of the Agent
|
|
|
|
|
* @param string $action Current Action
|
|
|
|
|
* @param bool $isToplevel Agent is a ToplevelAgent
|
|
|
|
|
*/
|
|
|
|
|
protected function __construct($layoutName, $agentName=null, $action=null, $isToplevel=false)
|
|
|
|
|
{
|
|
|
|
|
// Create template filename
|
|
|
|
|
// LayoutName
|
|
|
|
|
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($agentName).DS.strtolower($layoutName).DS;
|
|
|
|
|
|
|
|
|
|
// Action
|
|
|
|
|
$fileName .= strtolower($action);
|
|
|
|
|
|
|
|
|
|
// File extension
|
|
|
|
|
$fileName .= \nre\configs\CoreConfig::getFileExt('views');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check template file
|
|
|
|
|
if(!file_exists($fileName)) {
|
|
|
|
|
throw new \nre\exceptions\ViewNotFoundException($fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Save filename
|
|
|
|
|
$this->templateFilename = $fileName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|