Skip to content

Commit

Permalink
Revert "css fix thanks @C-Lodder"
Browse files Browse the repository at this point in the history
This reverts commit f7320cf.
  • Loading branch information
brianteeman committed Aug 25, 2016
1 parent f7320cf commit 90a89fd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 136 deletions.
128 changes: 10 additions & 118 deletions components/com_config/model/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package Joomla.Site
* @subpackage com_config
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

Expand Down Expand Up @@ -131,137 +131,29 @@ public function getPositions()

// Load templateDetails.xml file
$path = JPath::clean(JPATH_BASE . '/templates/' . $templateName . '/templateDetails.xml');
$currentTemplatePositions = array();
$currentPositions = array();

if (file_exists($path))
{
$xml = simplexml_load_file($path);

if (isset($xml->positions[0]))
{
// Load language files
$lang->load('tpl_' . $templateName . '.sys', JPATH_BASE, null, false, true)
|| $lang->load('tpl_' . $templateName . '.sys', JPATH_BASE . '/templates/' . $templateName, null, false, true);

foreach ($xml->positions[0] as $position)
{
$value = (string) $position;
$text = preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'TPL_' . strtoupper($templateName) . '_POSITION_' . strtoupper($value));
// Load language files
$lang->load('tpl_' . $templateName . '.sys', JPATH_BASE, null, false, true)
|| $lang->load('tpl_' . $templateName . '.sys', JPATH_BASE . '/templates/' . $templateName, null, false, true);

$key = (string) $position;
$value = preg_replace('/[^a-zA-Z0-9_\-]/', '_', 'TPL_' . strtoupper($templateName) . '_POSITION_' . strtoupper($key));

// Construct list of positions
$currentTemplatePositions[] = self::createOption($value, JText::_($text) . ' [' . $value . ']');
$currentPositions[$key] = JText::_($value) . ' [' . $key . ']';
}
}
}

$templateGroups = array();

// Add an empty value to be able to deselect a module position
$option = self::createOption();
$templateGroups[''] = self::createOptionGroup('', array($option));

$templateGroups[$templateName] = self::createOptionGroup($templateName, $currentTemplatePositions);

// Add custom position to options
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION');

$editPositions = true;
$customPositions = self::getActivePositions(0, $editPositions);
$templateGroups[$customGroupText] = self::createOptionGroup($customGroupText, $customPositions);

return $templateGroups;
}

/**
* Get a list of modules positions
*
* @param integer $clientId Client ID
* @param boolean $editPositions Allow to edit the positions
*
* @return array A list of positions
*/
public static function getActivePositions($clientId, $editPositions = false)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('DISTINCT(position)')
->from('#__modules')
->where($db->quoteName('client_id') . ' = ' . (int) $clientId)
->order('position');

$db->setQuery($query);

try
{
$positions = $db->loadColumn();
$positions = is_array($positions) ? $positions : array();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());

return;
}

// Build the list
$options = array();

foreach ($positions as $position)
{
if (!$position && !$editPositions)
{
$options[] = JHtml::_('select.option', 'none', ':: ' . JText::_('JNONE') . ' ::');
}
else
{
$options[] = JHtml::_('select.option', $position, $position);
}
}

return $options;
}

/**
* Create and return a new Option
*
* @param string $value The option value [optional]
* @param string $text The option text [optional]
*
* @return object The option as an object (stdClass instance)
*
* @since 3.0
*/
private static function createOption($value = '', $text = '')
{
if (empty($text))
{
$text = $value;
}

$option = new stdClass;
$option->value = $value;
$option->text = $text;

return $option;
}

/**
* Create and return a new Option Group
*
* @param string $label Value and label for group [optional]
* @param array $options Array of options to insert into group [optional]
*
* @return array Return the new group as an array
*
* @since 3.0
*/
private static function createOptionGroup($label = '', $options = array())
{
$group = array();
$group['value'] = $label;
$group['text'] = $label;
$group['items'] = $options;

return $group;
return $currentPositions;
}
}
18 changes: 3 additions & 15 deletions components/com_config/view/modules/tmpl/default_positions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@
* @package Joomla.Site
* @subpackage com_config
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;
$positions = $this->model->getPositions();

// Add custom position to options
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION');

// Build field
$attr = array(
'id' => 'jform_position',
'list.select' => $this->item['position'],
'list.attr' => 'class="chzn-custom-value" '
. 'data-custom_group_text="' . $customGroupText . '" '
. 'data-no_results_text="' . JText::_('COM_MODULES_ADD_CUSTOM_POSITION') . '" '
. 'data-placeholder="' . JText::_('COM_MODULES_TYPE_OR_SELECT_POSITION') . '" '
);
$positions = $this->model->getPositions();

echo JHtml::_('select.groupedlist', $positions, 'jform[position]', $attr);
echo JHtml::_('select.genericlist', $positions, 'jform[position]', '', '', '', $this->item['position']);
4 changes: 1 addition & 3 deletions media/jui/css/chosen.css
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,7 @@ This file is generated by `grunt build`, do not edit it by hand.
background-image: -moz-linear-gradient(#eeeeee 20%, #ffffff 80%);
background-image: -o-linear-gradient(#eeeeee 20%, #ffffff 80%);
background-image: linear-gradient(#eeeeee 20%, #ffffff 80%);
/* JUI remove next line */
/* box-shadow: 0 1px 0 #fff inset; */

box-shadow: 0 1px 0 #fff inset;
}
.chzn-container-active.chzn-with-drop .chzn-single div {
border-left: none;
Expand Down

0 comments on commit 90a89fd

Please sign in to comment.