You've already forked joomla_test
first commit
This commit is contained in:
49
libraries/cms/layout/base.php
Normal file
49
libraries/cms/layout/base.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Libraries
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
/**
|
||||
* Base class for rendering a display layout
|
||||
*
|
||||
* @package Joomla.Libraries
|
||||
* @subpackage Layout
|
||||
* @see http://docs.joomla.org/Sharing_layouts_across_views_or_extensions_with_JLayout
|
||||
* @since 3.0
|
||||
*/
|
||||
class JLayoutBase implements JLayout
|
||||
{
|
||||
/**
|
||||
* Method to escape output.
|
||||
*
|
||||
* @param string $output The output to escape.
|
||||
*
|
||||
* @return string The escaped output.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function escape($output)
|
||||
{
|
||||
return htmlspecialchars($output, ENT_COMPAT, 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to render the layout.
|
||||
*
|
||||
* @param object $displayData Object which properties are used inside the layout file to build displayed output
|
||||
*
|
||||
* @return string The necessary HTML to display the layout
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function render($displayData)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
110
libraries/cms/layout/file.php
Normal file
110
libraries/cms/layout/file.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Libraries
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
/**
|
||||
* Base class for rendering a display layout
|
||||
* loaded from from a layout file
|
||||
*
|
||||
* @package Joomla.Libraries
|
||||
* @subpackage Layout
|
||||
* @see http://docs.joomla.org/Sharing_layouts_across_views_or_extensions_with_JLayout
|
||||
* @since 3.0
|
||||
*/
|
||||
class JLayoutFile extends JLayoutBase
|
||||
{
|
||||
/**
|
||||
* @var string Dot separated path to the layout file, relative to base path
|
||||
* @since 3.0
|
||||
*/
|
||||
protected $layoutId = '';
|
||||
|
||||
/**
|
||||
* @var string Base path to use when loading layout files
|
||||
* @since 3.0
|
||||
*/
|
||||
protected $basePath = null;
|
||||
|
||||
/**
|
||||
* @var string Full path to actual layout files, after possible template override check
|
||||
* @since 3.0.3
|
||||
*/
|
||||
protected $fullPath = null;
|
||||
|
||||
/**
|
||||
* Method to instantiate the file-based layout.
|
||||
*
|
||||
* @param string $layoutId Dot separated path to the layout file, relative to base path
|
||||
* @param string $basePath Base path to use when loading layout files
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function __construct($layoutId, $basePath = null)
|
||||
{
|
||||
$this->layoutId = $layoutId;
|
||||
$this->basePath = is_null($basePath) ? JPATH_ROOT . '/layouts' : rtrim($basePath, DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to render the layout.
|
||||
*
|
||||
* @param object $displayData Object which properties are used inside the layout file to build displayed output
|
||||
*
|
||||
* @return string The necessary HTML to display the layout
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function render($displayData)
|
||||
{
|
||||
$layoutOutput = '';
|
||||
|
||||
// Check possible overrides, and build the full path to layout file
|
||||
$path = $this->getPath();
|
||||
|
||||
// If there exists such a layout file, include it and collect its output
|
||||
if (!empty($path))
|
||||
{
|
||||
ob_start();
|
||||
include $path;
|
||||
$layoutOutput = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
return $layoutOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to finds the full real file path, checking possible overrides
|
||||
*
|
||||
* @return string The full path to the layout file
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
protected function getPath()
|
||||
{
|
||||
jimport('joomla.filesystem.path');
|
||||
|
||||
if (is_null($this->fullPath) && !empty($this->layoutId))
|
||||
{
|
||||
$rawPath = str_replace('.', '/', $this->layoutId) . '.php';
|
||||
$fileName = basename($rawPath);
|
||||
$filePath = dirname($rawPath);
|
||||
|
||||
$possiblePaths = array(
|
||||
JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/html/layouts/' . $filePath,
|
||||
$this->basePath . '/' . $filePath
|
||||
);
|
||||
|
||||
$this->fullPath = JPath::find($possiblePaths, $fileName);
|
||||
}
|
||||
|
||||
return $this->fullPath;
|
||||
}
|
||||
}
|
53
libraries/cms/layout/helper.php
Normal file
53
libraries/cms/layout/helper.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Libraries
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
/**
|
||||
* Helper to render a JLayout object, storing a base path
|
||||
*
|
||||
* @package Joomla.Libraries
|
||||
* @subpackage Layout
|
||||
* @see http://docs.joomla.org/Sharing_layouts_across_views_or_extensions_with_JLayout
|
||||
* @since 3.1
|
||||
*/
|
||||
class JLayoutHelper
|
||||
{
|
||||
/**
|
||||
* A default base path that will be used if none is provided when calling the render method.
|
||||
* Note that JLayoutFile itself will defaults to JPATH_ROOT . '/layouts' if no basePath is supplied at all
|
||||
*
|
||||
* @var string
|
||||
* @since 3.1
|
||||
*/
|
||||
public static $defaultBasePath = '';
|
||||
|
||||
/**
|
||||
* Method to render the layout.
|
||||
*
|
||||
* @param string $layoutFile Dot separated path to the layout file, relative to base path
|
||||
* @param object $displayData Object which properties are used inside the layout file to build displayed output
|
||||
* @param string $basePath Base path to use when loading layout files
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public static function render($layoutFile, $displayData = null, $basePath = '')
|
||||
{
|
||||
$basePath = empty($basePath) ? self::$defaultBasePath : $basePath;
|
||||
|
||||
// Make sure we send null to JLayoutFile if no path set
|
||||
$basePath = empty($basePath) ? null : $basePath;
|
||||
$layout = new JLayoutFile($layoutFile, $basePath);
|
||||
$renderedLayout = $layout->render($displayData);
|
||||
|
||||
return $renderedLayout;
|
||||
}
|
||||
}
|
1
libraries/cms/layout/index.html
Normal file
1
libraries/cms/layout/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
43
libraries/cms/layout/layout.php
Normal file
43
libraries/cms/layout/layout.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Libraries
|
||||
* @subpackage Layout
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('JPATH_BASE') or die;
|
||||
|
||||
/**
|
||||
* Interface to handle display layout
|
||||
*
|
||||
* @package Joomla.Libraries
|
||||
* @subpackage Layout
|
||||
* @see http://docs.joomla.org/Sharing_layouts_across_views_or_extensions_with_JLayout
|
||||
* @since 3.0
|
||||
*/
|
||||
interface JLayout
|
||||
{
|
||||
/**
|
||||
* Method to escape output.
|
||||
*
|
||||
* @param string $output The output to escape.
|
||||
*
|
||||
* @return string The escaped output.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function escape($output);
|
||||
|
||||
/**
|
||||
* Method to render the layout.
|
||||
*
|
||||
* @param object $displayData Object which properties are used inside the layout file to build displayed output
|
||||
*
|
||||
* @return string The rendered layout.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public function render($displayData);
|
||||
}
|
Reference in New Issue
Block a user