Skip to content

Commit

Permalink
Merge pull request #5119 from bembelimen/patch-23
Browse files Browse the repository at this point in the history
Allow "external" JDocument classes
  • Loading branch information
infograf768 committed Nov 20, 2014
2 parents 68b58f3 + 9acb354 commit 1b7bb4a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions libraries/joomla/document/document.php
Expand Up @@ -277,27 +277,28 @@ public static function getInstance($type = 'html', $attributes = array())
{
$type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type);
$path = __DIR__ . '/' . $type . '/' . $type . '.php';
$rawpath = __DIR__ . '/raw/raw.php';
$ntype = null;

// Check if the document type exists
if (!file_exists($path))
{
// Default to the raw format
$ntype = $type;
$type = 'raw';
}

// Determine the path and class
$class = 'JDocument' . $type;

if (!class_exists($class))
{
$path = __DIR__ . '/' . $type . '/' . $type . '.php';

if (file_exists($path))
{
require_once $path;
}
// Default to the raw format
elseif (file_exists($rawpath))
{
$ntype = $type;
$type = 'raw';

$class = 'JDocument' . $type;

require_once $rawpath;
}
else
{
// @codeCoverageIgnoreStart
Expand Down

0 comments on commit 1b7bb4a

Please sign in to comment.