joomla-platform / libraries / joomla / html / parameter / element / componentlayouts.php

hg 86a5e4a 

Louis Landry 9bb3b27 


Louis Landry 532db96 

hg 86a5e4a 

Louis Landry 532db96 
hg 86a5e4a 





hg 3da98f7 
hg 86a5e4a 




























































<?php
/**
 * @package     Joomla.Platform
 * @subpackage  HTML
 *
 * @copyright   Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE
 */

defined('JPATH_PLATFORM') or die;

require_once dirname(__FILE__).DS.'list.php';

/**
 * Parameter to display a list of the layouts for a component view from the extension or default template overrides.
 *
 * @package     Joomla.Platform
 * @subpackage  Parameter
 */
class JElementComponentLayouts extends JElementList
{
    /**
     * @var     string
     */
    protected $_name = 'ComponentLayouts';

    /**
     * Get the options for the list.
     */
    protected function _getOptions(&$node)
    {
        $options    = array();
        $path1      = null;
        $path2      = null;

        // Load template entries for each menuid
        $db         = JFactory::getDBO();
        $query      = 'SELECT template'
            . ' FROM #__template_styles'
            . ' WHERE client_id = 0 AND home = 1';
        $db->setQuery($query);
        $template   = $db->loadResult();

        if ($view = $node->attributes('view') && $extn = $node->attributes('extension'))
        {
            $view   = preg_replace('#\W#', '', $view);
            $extn   = preg_replace('#\W#', '', $extn);
            $path1  = JPATH_SITE.DS.'components'.DS.$extn.DS.'views'.DS.$view.DS.'tmpl';
            $path2  = JPATH_SITE.DS.'templates'.DS.$template.DS.'html'.DS.$extn.DS.$view;
            $options[]  = JHTML::_('select.option', '', JText::_('JOPTION_USE_MENU_REQUEST_SETTING'));
        }

        if ($path1 && $path2)
        {
            jimport('joomla.filesystem.file');
            $path1 = JPath::clean($path1);
            $path2 = JPath::clean($path2);

            $files  = JFolder::files($path1, '^[^_]*\.php$');
            foreach ($files as $file) {
                $options[]  = JHTML::_('select.option', JFile::stripExt($file));
            }

            if (is_dir($path2) && $files = JFolder::files($path2, '^[^_]*\.php$'))
            {
                $options[]  = JHTML::_('select.optgroup', JText::_('JOPTION_FROM_DEFAULT_TEMPLATE'));
                foreach ($files as $file) {
                    $options[]  = JHTML::_('select.option', JFile::stripExt($file));
                }
                $options[]  = JHTML::_('select.optgroup', JText::_('JOPTION_FROM_DEFAULT_TEMPLATE'));
            }
        }

        // Merge any additional options in the XML definition.
        $options = array_merge(parent::_getOptions($node), $options);

        return $options;
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.