2014-05-03 23:48:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Patch testing component for the Joomla! CMS
|
|
|
|
*
|
2017-01-21 19:54:53 +00:00
|
|
|
* @copyright Copyright (C) 2011 - 2012 Ian MacLennan, Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved.
|
2014-05-03 23:48:08 +00:00
|
|
|
* @license GNU General Public License version 2 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace PatchTester\View;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default HTML view class.
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
*/
|
|
|
|
class DefaultHtmlView extends \JViewHtml
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Load a template file -- first look in the templates folder for an override
|
|
|
|
*
|
|
|
|
* @param string $tpl The name of the template source file; automatically searches the template paths and compiles as needed.
|
|
|
|
*
|
|
|
|
* @return string The output of the the template script.
|
|
|
|
*
|
|
|
|
* @since 2.0
|
|
|
|
* @throws \RuntimeException
|
|
|
|
*/
|
|
|
|
public function loadTemplate($tpl = null)
|
|
|
|
{
|
|
|
|
// Get the path to the file
|
2015-12-05 17:43:54 +00:00
|
|
|
$file = $this->getLayout();
|
|
|
|
|
|
|
|
if (isset($tpl))
|
|
|
|
{
|
|
|
|
$file .= '_' . $tpl;
|
|
|
|
}
|
|
|
|
|
2014-05-03 23:48:08 +00:00
|
|
|
$path = $this->getPath($file);
|
|
|
|
|
2015-02-23 00:07:05 +00:00
|
|
|
if (!$path)
|
2014-05-03 23:48:08 +00:00
|
|
|
{
|
2015-02-23 00:07:05 +00:00
|
|
|
throw new \RuntimeException(\JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file), 500);
|
|
|
|
}
|
2014-05-03 23:48:08 +00:00
|
|
|
|
2015-02-23 00:07:05 +00:00
|
|
|
// Unset so as not to introduce into template scope
|
|
|
|
unset($tpl);
|
|
|
|
unset($file);
|
2014-05-03 23:48:08 +00:00
|
|
|
|
2015-02-23 00:07:05 +00:00
|
|
|
// Never allow a 'this' property
|
|
|
|
if (isset($this->this))
|
|
|
|
{
|
|
|
|
unset($this->this);
|
|
|
|
}
|
2014-05-03 23:48:08 +00:00
|
|
|
|
2015-02-23 00:07:05 +00:00
|
|
|
// Start an output buffer.
|
|
|
|
ob_start();
|
2014-05-03 23:48:08 +00:00
|
|
|
|
2015-02-23 00:07:05 +00:00
|
|
|
// Load the template.
|
|
|
|
include $path;
|
2014-05-03 23:48:08 +00:00
|
|
|
|
2015-02-23 00:07:05 +00:00
|
|
|
// Get the layout contents.
|
2016-03-11 16:36:53 +00:00
|
|
|
return ob_get_clean();
|
2014-05-03 23:48:08 +00:00
|
|
|
}
|
|
|
|
}
|