Source for file chromestyle.php

Documentation is available at chromestyle.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Form
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. JFormHelper::loadFieldClass('groupedlist');
  13.  
  14. /**
  15.  * Chrome Styles Form Field class for the Joomla Platform.
  16.  *
  17.  * @package     Joomla.Libraries
  18.  * @subpackage  Form
  19.  * @since       3.0
  20.  */
  21. {
  22.     /**
  23.      * The form field type.
  24.      *
  25.      * @var    string 
  26.      * @since  3.0
  27.      */
  28.     public $type = 'ChromeStyle';
  29.  
  30.     /**
  31.      * Method to get the list of template chrome style options
  32.      * grouped by template.
  33.      *
  34.      * @return  array  The field option objects as a nested array in groups.
  35.      *
  36.      * @since   3.0
  37.      */
  38.     protected function getGroups()
  39.     {
  40.         $groups array();
  41.  
  42.         // Add Module Style Field
  43.         $tmp '---' JText::_('JLIB_FORM_VALUE_FROM_TEMPLATE''---';
  44.         $groups[$tmp][JHtml::_('select.option''0'JText::_('JLIB_FORM_VALUE_INHERITED'));
  45.  
  46.         $templateStyles $this->getTemplateModuleStyles();
  47.  
  48.         // Create one new option object for each available style, grouped by templates
  49.         foreach ($templateStyles as $template => $styles)
  50.         {
  51.             $template ucfirst($template);
  52.             $groups[$templatearray();
  53.  
  54.             foreach ($styles as $style)
  55.             {
  56.                 $tmp JHtml::_('select.option'$template '-' $style$style);
  57.                 $groups[$template][$tmp;
  58.             }
  59.         }
  60.  
  61.         reset($groups);
  62.  
  63.         return $groups;
  64.     }
  65.  
  66.     /**
  67.      * Method to get the templates module styles.
  68.      *
  69.      * @return  array  The array of styles, grouped by templates.
  70.      *
  71.      * @since   3.0
  72.      */
  73.     protected function getTemplateModuleStyles()
  74.     {
  75.         $moduleStyles array();
  76.  
  77.         $templates array($this->getSystemTemplate());
  78.         $templates array_merge($templatesModulesHelper::getTemplates('site'));
  79.  
  80.         foreach ($templates as $template)
  81.         {
  82.             $modulesFilePath JPATH_SITE '/templates/' $template->element '/html/modules.php';
  83.  
  84.             // Is there modules.php for that template?
  85.             if (file_exists($modulesFilePath))
  86.             {
  87.                 $modulesFileData file_get_contents($modulesFilePath);
  88.  
  89.                 preg_match_all('/function[\s\t]*modChrome\_([a-z0-9\-\_]*)[\s\t]*\(/i'$modulesFileData$styles);
  90.  
  91.                 if (!array_key_exists($template->element$moduleStyles))
  92.                 {
  93.                     $moduleStyles[$template->elementarray();
  94.                 }
  95.  
  96.                 $moduleStyles[$template->element$styles[1];
  97.             }
  98.         }
  99.  
  100.         return $moduleStyles;
  101.     }
  102.  
  103.     /**
  104.      * Method to get the system template as an object.
  105.      *
  106.      * @return  array  The object of system template.
  107.      *
  108.      * @since   3.0
  109.      */
  110.     protected function getSystemTemplate()
  111.     {
  112.         $template new stdClass;
  113.         $template->element 'system';
  114.         $template->name    'system';
  115.         $template->enabled 1;
  116.  
  117.         return $template;
  118.     }
  119. }

Documentation generated on Tue, 19 Nov 2013 14:55:44 +0100 by phpDocumentor 1.4.3