primo commit
This commit is contained in:
		
							
								
								
									
										69
									
								
								libraries/f0f/layout/file.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								libraries/f0f/layout/file.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,69 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package     FrameworkOnFramework | ||||
|  * @subpackage  layout | ||||
|  * @copyright   Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved. | ||||
|  * @license     GNU General Public License version 2 or later; see LICENSE.txt | ||||
|  */ | ||||
| // Protect from unauthorized access | ||||
| defined('F0F_INCLUDED') or die; | ||||
|  | ||||
| /** | ||||
|  * Base class for rendering a display layout | ||||
|  * loaded from from a layout file | ||||
|  * | ||||
|  * This class searches for Joomla! version override Layouts. For example, | ||||
|  * if you have run this under Joomla! 3.0 and you try to load | ||||
|  * mylayout.default it will automatically search for the | ||||
|  * layout files default.j30.php, default.j3.php and default.php, in this | ||||
|  * order. | ||||
|  * | ||||
|  * @package  FrameworkOnFramework | ||||
|  * @since    1.0 | ||||
|  */ | ||||
| class F0FLayoutFile extends JLayoutFile | ||||
| { | ||||
| 	/** | ||||
| 	 * Method to finds the full real file path, checking possible overrides | ||||
| 	 * | ||||
| 	 * @return  string  The full path to the layout file | ||||
| 	 */ | ||||
| 	protected function getPath() | ||||
| 	{ | ||||
| 		$filesystem = F0FPlatform::getInstance()->getIntegrationObject('filesystem'); | ||||
|  | ||||
| 		if (is_null($this->fullPath) && !empty($this->layoutId)) | ||||
| 		{ | ||||
| 			$parts = explode('.', $this->layoutId); | ||||
| 			$file  = array_pop($parts); | ||||
|  | ||||
| 			$filePath = implode('/', $parts); | ||||
| 			$suffixes = F0FPlatform::getInstance()->getTemplateSuffixes(); | ||||
|  | ||||
| 			foreach ($suffixes as $suffix) | ||||
| 			{ | ||||
| 				$files[] = $file . $suffix . '.php'; | ||||
| 			} | ||||
|  | ||||
| 			$files[] = $file . '.php'; | ||||
|  | ||||
|             $platformDirs = F0FPlatform::getInstance()->getPlatformBaseDirs(); | ||||
|             $prefix       = F0FPlatform::getInstance()->isBackend() ? $platformDirs['admin'] : $platformDirs['root']; | ||||
|  | ||||
| 			$possiblePaths = array( | ||||
| 				$prefix . '/templates/' . JFactory::getApplication()->getTemplate() . '/html/layouts/' . $filePath, | ||||
| 				$this->basePath . '/' . $filePath | ||||
| 			); | ||||
|  | ||||
| 			reset($files); | ||||
|  | ||||
| 			while ((list(, $fileName) = each($files)) && is_null($this->fullPath)) | ||||
| 			{ | ||||
| 				$r = $filesystem->pathFind($possiblePaths, $fileName); | ||||
| 				$this->fullPath = $r === false ? null : $r; | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return $this->fullPath; | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										39
									
								
								libraries/f0f/layout/helper.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								libraries/f0f/layout/helper.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| <?php | ||||
| /** | ||||
|  * @package     FrameworkOnFramework | ||||
|  * @subpackage  layout | ||||
|  * @copyright   Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved. | ||||
|  * @license     GNU General Public License version 2 or later; see LICENSE.txt | ||||
|  */ | ||||
| // Protect from unauthorized access | ||||
| defined('F0F_INCLUDED') or die; | ||||
|  | ||||
| /** | ||||
|  * Helper to render a F0FLayout object, storing a base path | ||||
|  * | ||||
|  * @package  FrameworkOnFramework | ||||
|  * @since    x.y | ||||
|  */ | ||||
| class F0FLayoutHelper extends JLayoutHelper | ||||
| { | ||||
| 	/** | ||||
| 	 * 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 | ||||
| 	 */ | ||||
| 	public static function render($layoutFile, $displayData = null, $basePath = '') | ||||
| 	{ | ||||
| 		$basePath = empty($basePath) ? self::$defaultBasePath : $basePath; | ||||
|  | ||||
| 		// Make sure we send null to F0FLayoutFile if no path set | ||||
| 		$basePath = empty($basePath) ? null : $basePath; | ||||
| 		$layout = new F0FLayoutFile($layoutFile, $basePath); | ||||
| 		$renderedLayout = $layout->render($displayData); | ||||
|  | ||||
| 		return $renderedLayout; | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user