mirror of
https://github.com/joomla/joomla-cms.git
synced 2024-06-27 07:33:41 +00:00
# [#23177] Ability to set a default template style per language when System - Language Filter plugin is on
git-svn-id: http://joomlacode.org/svn/joomla/development/trunk@19414 6f6e1ebd-4c2b-0410-823f-f34bde69bce9
This commit is contained in:
parent
8f6c4ea236
commit
4402c2d95d
|
@ -104,6 +104,33 @@ class TemplatesControllerStyles extends JControllerAdmin
|
|||
JError::raiseWarning(500, $e->getMessage());
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_templates&view=styles');
|
||||
}
|
||||
/**
|
||||
* Method to unset the default template for a client and for a language
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function unsetDefault()
|
||||
{
|
||||
// Initialise variables.
|
||||
$pks = JRequest::getVar('cid', array(), 'get', 'array');
|
||||
|
||||
try {
|
||||
if (empty($pks)) {
|
||||
throw new Exception(JText::_('COM_TEMPLATES_NO_TEMPLATE_SELECTED'));
|
||||
}
|
||||
|
||||
// Pop off the first element.
|
||||
$id = array_shift($pks);
|
||||
$model = $this->getModel();
|
||||
$model->unsetHome($id);
|
||||
$this->setMessage(JText::_('COM_TEMPLATES_SUCCESS_HOME_UNSET'));
|
||||
|
||||
} catch (Exception $e) {
|
||||
JError::raiseWarning(500, $e->getMessage());
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_templates&view=styles');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,21 +30,6 @@
|
|||
default="0"
|
||||
readonly="true" />
|
||||
|
||||
<field
|
||||
name="home"
|
||||
type="list"
|
||||
label="COM_TEMPLATES_FIELD_HOME_LABEL"
|
||||
description="COM_TEMPLATES_FIELD_HOME_DESC"
|
||||
class="inputbox"
|
||||
default="0">
|
||||
<option
|
||||
value="1">
|
||||
JYes</option>
|
||||
<option
|
||||
value="0">
|
||||
JNo</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="title"
|
||||
type="text"
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Id$ -->
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="home"
|
||||
type="radio"
|
||||
label="COM_TEMPLATES_FIELD_HOME_LABEL"
|
||||
description="COM_TEMPLATES_FIELD_HOME_ADMINISTRATOR_DESC"
|
||||
class="inputbox"
|
||||
default="0">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</form>
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Id$ -->
|
||||
<form>
|
||||
<fieldset>
|
||||
<field
|
||||
name="home"
|
||||
type="contentlanguage"
|
||||
label="COM_TEMPLATES_FIELD_HOME_LABEL"
|
||||
description="COM_TEMPLATES_FIELD_HOME_SITE_DESC"
|
||||
class="inputbox"
|
||||
default="0">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JALL</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</form>
|
|
@ -297,14 +297,18 @@ class TemplatesModelStyle extends JModelAdmin
|
|||
*/
|
||||
protected function preprocessForm($form, $data)
|
||||
{
|
||||
jimport('joomla.filesystem.file');
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
// Initialise variables.
|
||||
$clientId = $this->getState('item.client_id');
|
||||
$template = $this->getState('item.template');
|
||||
$lang = JFactory::getLanguage();
|
||||
$client = JApplicationHelper::getClientInfo($clientId);
|
||||
if (!$form->loadFile('style_'.$client->name, true)) {
|
||||
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
|
||||
}
|
||||
|
||||
jimport('joomla.filesystem.file');
|
||||
jimport('joomla.filesystem.folder');
|
||||
|
||||
$formFile = JPath::clean($client->path.'/templates/'.$template.'/templateDetails.xml');
|
||||
|
||||
// Load the core and/or local language file(s).
|
||||
|
@ -322,8 +326,8 @@ class TemplatesModelStyle extends JModelAdmin
|
|||
|
||||
// Disable home field if it is default style
|
||||
|
||||
if ((is_array($data) && array_key_exists('home',$data))
|
||||
|| ((is_object($data) && $data->home))){
|
||||
if ((is_array($data) && array_key_exists('home',$data) && $data['home']=='1')
|
||||
|| ((is_object($data) && isset($data->home) && $data->home=='1'))){
|
||||
$form->setFieldAttribute('home','readonly','true');
|
||||
}
|
||||
|
||||
|
@ -486,8 +490,9 @@ class TemplatesModelStyle extends JModelAdmin
|
|||
// Reset the home fields for the client_id.
|
||||
$db->setQuery(
|
||||
'UPDATE #__template_styles' .
|
||||
' SET home = 0' .
|
||||
' WHERE client_id = '.(int) $clientId
|
||||
' SET home = \'0\'' .
|
||||
' WHERE client_id = '.(int) $clientId .
|
||||
' AND home = \'1\''
|
||||
);
|
||||
|
||||
if (!$db->query()) {
|
||||
|
@ -497,7 +502,63 @@ class TemplatesModelStyle extends JModelAdmin
|
|||
// Set the new home style.
|
||||
$db->setQuery(
|
||||
'UPDATE #__template_styles' .
|
||||
' SET home = 1' .
|
||||
' SET home = \'1\'' .
|
||||
' WHERE id = '.(int) $id
|
||||
);
|
||||
|
||||
if (!$db->query()) {
|
||||
throw new Exception($db->getErrorMsg());
|
||||
}
|
||||
|
||||
// Clean the cache.
|
||||
$cache = JFactory::getCache();
|
||||
$cache->clean('com_templates');
|
||||
$cache->clean('_system');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to unset a template style as default for a language.
|
||||
*
|
||||
* @param int The primary key ID for the style.
|
||||
*
|
||||
* @return boolean True if successful.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function unsetHome($id = 0)
|
||||
{
|
||||
// Initialise variables.
|
||||
$user = JFactory::getUser();
|
||||
$db = $this->getDbo();
|
||||
|
||||
// Access checks.
|
||||
if (!$user->authorise('core.edit.state', 'com_templates')) {
|
||||
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
|
||||
}
|
||||
|
||||
// Lookup the client_id.
|
||||
$db->setQuery(
|
||||
'SELECT client_id, home' .
|
||||
' FROM #__template_styles' .
|
||||
' WHERE id = '.(int) $id
|
||||
);
|
||||
$style = $db->loadObject();
|
||||
|
||||
if ($error = $db->getErrorMsg()) {
|
||||
throw new Exception($error);
|
||||
}
|
||||
else if (!is_numeric($style->client_id)) {
|
||||
throw new Exception(JText::_('COM_TEMPLATES_ERROR_STYLE_NOT_FOUND'));
|
||||
}
|
||||
else if ($style->home=='1') {
|
||||
throw new Exception(JText::_('COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE'));
|
||||
}
|
||||
|
||||
// Set the new home style.
|
||||
$db->setQuery(
|
||||
'UPDATE #__template_styles' .
|
||||
' SET home = \'0\'' .
|
||||
' WHERE id = '.(int) $id
|
||||
);
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class TemplatesModelStyles extends JModelList
|
|||
$query->select(
|
||||
$this->getState(
|
||||
'list.select',
|
||||
'a.id, a.template, a.title, a.home, a.client_id'
|
||||
'a.id, a.template, a.title, a.home, a.client_id, l.title AS language_title, l.image as image'
|
||||
)
|
||||
);
|
||||
$query->from('`#__template_styles` AS a');
|
||||
|
@ -95,6 +95,9 @@ class TemplatesModelStyles extends JModelList
|
|||
$query->leftjoin('#__menu AS m ON m.template_style_id = a.id');
|
||||
$query->group('a.id');
|
||||
|
||||
// Join over the language
|
||||
$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.home');
|
||||
|
||||
// Filter by template.
|
||||
if ($template = $this->getState('filter.template')) {
|
||||
$query->where('a.template = '.$db->quote($template));
|
||||
|
|
|
@ -72,7 +72,7 @@ class TemplatesTableStyle extends JTable
|
|||
}
|
||||
|
||||
// Verify that the default style is not unset
|
||||
if ($array['home']==0 && $this->home) {
|
||||
if ($array['home']=='0' && $this->home=='1') {
|
||||
$this->setError(JText::_('COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE'));
|
||||
return false;
|
||||
}
|
||||
|
@ -105,11 +105,12 @@ class TemplatesTableStyle extends JTable
|
|||
*/
|
||||
public function store($updateNulls = false)
|
||||
{
|
||||
if ($this->home) {
|
||||
if ($this->home!='0') {
|
||||
$query = $this->_db->getQuery(true);
|
||||
$query->update('#__template_styles');
|
||||
$query->set('home=0');
|
||||
$query->set('home=\'0\'');
|
||||
$query->where('client_id='.(int)$this->client_id);
|
||||
$query->where('home='.$this->_db->quote($this->home));
|
||||
$this->_db->setQuery($query);
|
||||
$this->_db->query();
|
||||
}
|
||||
|
|
|
@ -102,7 +102,15 @@ $listDirn = $this->state->get('list.direction');
|
|||
</label>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php echo JHtml::_('jgrid.isdefault', $item->home, $i, 'styles.', $canChange && !$item->home);?>
|
||||
<?php if ($item->home=='0' || $item->home=='1'):?>
|
||||
<?php echo JHtml::_('jgrid.isdefault', $item->home!='0', $i, 'styles.', $canChange && $item->home!='1');?>
|
||||
<?php elseif ($canChange):?>
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&task=styles.unsetDefault&cid[]='.$item->id);?>">
|
||||
<?php echo JHtml::_('image', 'mod_languages/'.$item->image.'.gif', $item->language_title, array('title'=>JText::sprintf('COM_TEMPLATES_GRID_UNSET_LANGUAGE', $item->language_title)), true);?>
|
||||
</a>
|
||||
<?php else:?>
|
||||
<?php echo JHtml::_('image', 'mod_languages/'.$item->image.'.gif', $item->language_title, array('title'=>$item->language_title), true);?>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($item->assigned > 0) : ?>
|
||||
|
|
|
@ -14,7 +14,7 @@ COM_TEMPLATES_CONFIG_FIELDSET_DESC="Global Configuration for Templates"
|
|||
COM_TEMPLATES_CONFIG_POSITIONS_DESC="Enable the preview of the module positions in the template by appending tp=1 to the web address. Also enables the Preview button in the list of templates. Please refresh the page after changing this setting."
|
||||
COM_TEMPLATES_CONFIG_POSITIONS_LABEL="Preview Module Positions"
|
||||
COM_TEMPLATES_CONFIGURATION="Template Manager Options"
|
||||
COM_TEPLATES_ERR_XML="Template XML data non available"
|
||||
COM_TEMPLATES_ERR_XML="Template XML data non available"
|
||||
COM_TEMPLATES_ERROR_CANNOT_DELETE_LAST_STYLE="Cannot delete last style of a template"
|
||||
COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE="Cannot unset default style"
|
||||
COM_TEMPLATES_ERROR_EXTENSION_RECORD_NOT_FOUND="Extension record not found in database"
|
||||
|
@ -28,8 +28,9 @@ COM_TEMPLATES_ERROR_STYLE_REQUIRES_TITLE="The style requires a title"
|
|||
COM_TEMPLATES_ERROR_TEMPLATE_FOLDER_NOT_FOUND="Template folder not found"
|
||||
COM_TEMPLATES_FIELD_CLIENT_DESC="Whether this template is used for the frontend (0) or the backend (1)"
|
||||
COM_TEMPLATES_FIELD_CLIENT_LABEL="Location"
|
||||
COM_TEMPLATES_FIELD_HOME_DESC="This template is defined or not as default template"
|
||||
COM_TEMPLATES_FIELD_HOME_ADMINISTRATOR_DESC="This template style is defined or not as default template style"
|
||||
COM_TEMPLATES_FIELD_HOME_LABEL="Default"
|
||||
COM_TEMPLATES_FIELD_HOME_SITE_DESC="If the multilingual functionality is not implemented, please limit your choice between <b>No</b> and <b>All</b>. The template style will be defined or not as global default template style.<br />If the <b>System - Language Filter</b> plugin is enabled, and you use different template styles depending on your content languages, please assign a language to this style."
|
||||
COM_TEMPLATES_FIELD_SOURCE_DESC="Source code"
|
||||
COM_TEMPLATES_FIELD_SOURCE_LABEL="Source Code"
|
||||
COM_TEMPLATES_FIELD_TEMPLATE_DESC="Template Name"
|
||||
|
@ -40,6 +41,7 @@ COM_TEMPLATES_FILE_SAVE_SUCCESS="File successfully saved"
|
|||
COM_TEMPLATES_FILTER_TEMPLATE="- Select Template -"
|
||||
COM_TEMPLATES_FTP_DESC="???"
|
||||
COM_TEMPLATES_FTP_TITLE="???"
|
||||
COM_TEMPLATES_GRID_UNSET_LANGUAGE="Unset %s Default"
|
||||
COM_TEMPLATES_HEADING_ASSIGNED="Assigned"
|
||||
COM_TEMPLATES_HEADING_DEFAULT="Default"
|
||||
COM_TEMPLATES_HEADING_STYLE="Style"
|
||||
|
@ -65,6 +67,7 @@ COM_TEMPLATES_SUBMENU_STYLES="Styles"
|
|||
COM_TEMPLATES_SUBMENU_TEMPLATES="Templates"
|
||||
COM_TEMPLATES_SUCCESS_DUPLICATED="Style successfully duplicated."
|
||||
COM_TEMPLATES_SUCCESS_HOME_SET="Default style successfully set."
|
||||
COM_TEMPLATES_SUCCESS_HOME_UNSET="Language style successfully set."
|
||||
COM_TEMPLATES_TEMPLATE_ADD_CSS="Add new stylesheet"
|
||||
COM_TEMPLATES_TEMPLATE_ADD_ERROR="Add custom error page template (optional)"
|
||||
COM_TEMPLATES_TEMPLATE_CSS="Stylesheets"
|
||||
|
|
|
@ -14,7 +14,7 @@ COM_TEMPLATES_CONFIG_FIELDSET_DESC="Global Configuration for Templates"
|
|||
COM_TEMPLATES_CONFIG_POSITIONS_DESC="Enable the preview of the module positions in the template by appending tp=1 to the web address. Also enables the Preview button in the list of templates. Please refresh the page after changing this setting."
|
||||
COM_TEMPLATES_CONFIG_POSITIONS_LABEL="Preview Module Positions"
|
||||
COM_TEMPLATES_CONFIGURATION="Template Manager Options"
|
||||
COM_TEPLATES_ERR_XML="Template XML data non available"
|
||||
COM_TEMPLATES_ERR_XML="Template XML data non available"
|
||||
COM_TEMPLATES_ERROR_CANNOT_DELETE_LAST_STYLE="Cannot delete last style of a template"
|
||||
COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE="Cannot unset default style"
|
||||
COM_TEMPLATES_ERROR_EXTENSION_RECORD_NOT_FOUND="Extension record not found in database"
|
||||
|
@ -28,8 +28,9 @@ COM_TEMPLATES_ERROR_STYLE_REQUIRES_TITLE="The style requires a title"
|
|||
COM_TEMPLATES_ERROR_TEMPLATE_FOLDER_NOT_FOUND="Template folder not found"
|
||||
COM_TEMPLATES_FIELD_CLIENT_DESC="Whether this template is used for the frontend (0) or the backend (1)"
|
||||
COM_TEMPLATES_FIELD_CLIENT_LABEL="Location"
|
||||
COM_TEMPLATES_FIELD_HOME_DESC="This template is defined or not as default template"
|
||||
COM_TEMPLATES_FIELD_HOME_ADMINISTRATOR_DESC="This template style is defined or not as default template style"
|
||||
COM_TEMPLATES_FIELD_HOME_LABEL="Default"
|
||||
COM_TEMPLATES_FIELD_HOME_SITE_DESC="If the multilingual functionality is not implemented, please limit your choice between <b>No</b> and <b>All</b>. The template style will be defined or not as global default template style.<br />If the <b>System - Language Filter</b> plugin is enabled, and you use different template styles depending on your content languages, please assign a language to this style."
|
||||
COM_TEMPLATES_FIELD_SOURCE_DESC="Source code"
|
||||
COM_TEMPLATES_FIELD_SOURCE_LABEL="Source Code"
|
||||
COM_TEMPLATES_FIELD_TEMPLATE_DESC="Template Name"
|
||||
|
@ -40,6 +41,7 @@ COM_TEMPLATES_FILE_SAVE_SUCCESS="File successfully saved"
|
|||
COM_TEMPLATES_FILTER_TEMPLATE="- Select Template -"
|
||||
COM_TEMPLATES_FTP_DESC="???"
|
||||
COM_TEMPLATES_FTP_TITLE="???"
|
||||
COM_TEMPLATES_GRID_UNSET_LANGUAGE="Unset %s Default"
|
||||
COM_TEMPLATES_HEADING_ASSIGNED="Assigned"
|
||||
COM_TEMPLATES_HEADING_DEFAULT="Default"
|
||||
COM_TEMPLATES_HEADING_STYLE="Style"
|
||||
|
@ -65,6 +67,7 @@ COM_TEMPLATES_SUBMENU_STYLES="Styles"
|
|||
COM_TEMPLATES_SUBMENU_TEMPLATES="Templates"
|
||||
COM_TEMPLATES_SUCCESS_DUPLICATED="Style successfully duplicated."
|
||||
COM_TEMPLATES_SUCCESS_HOME_SET="Default style successfully set."
|
||||
COM_TEMPLATES_SUCCESS_HOME_UNSET="Language style successfully set."
|
||||
COM_TEMPLATES_TEMPLATE_ADD_CSS="Add new stylesheet"
|
||||
COM_TEMPLATES_TEMPLATE_ADD_ERROR="Add custom error page template (optional)"
|
||||
COM_TEMPLATES_TEMPLATE_CSS="Stylesheets"
|
||||
|
|
|
@ -106,7 +106,15 @@ $listDirn = $this->state->get('list.direction');
|
|||
</label>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php echo JHtml::_('jgrid.isdefault', $item->home, $i, 'styles.', $canChange && !$item->home);?>
|
||||
<?php if ($item->home=='0' || $item->home=='1'):?>
|
||||
<?php echo JHtml::_('jgrid.isdefault', $item->home!='0', $i, 'styles.', $canChange && $item->home!='1');?>
|
||||
<?php elseif ($canChange):?>
|
||||
<a href="<?php echo JRoute::_('index.php?option=com_templates&task=styles.unsetDefault&cid[]='.$item->id);?>">
|
||||
<?php echo JHtml::_('image', 'mod_languages/'.$item->image.'.gif', $item->language_title, array('title'=>JText::sprintf('COM_TEMPLATES_GRID_UNSET_LANGUAGE', $item->language_title)), true);?>
|
||||
</a>
|
||||
<?php else:?>
|
||||
<?php echo JHtml::_('image', 'mod_languages/'.$item->image.'.gif', $item->language_title, array('title'=>$item->language_title), true);?>
|
||||
<?php endif;?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($item->assigned > 0) : ?>
|
||||
|
|
|
@ -410,7 +410,13 @@ final class JSite extends JApplication
|
|||
|
||||
|
||||
$cache = JFactory::getCache('com_templates', '');
|
||||
if (!$templates = $cache->get('templates0')) {
|
||||
if ($this->_language_filter) {
|
||||
$tag = JFactory::getLanguage()->getTag();
|
||||
}
|
||||
else {
|
||||
$tag ='';
|
||||
}
|
||||
if (!$templates = $cache->get('templates0'.$tag)) {
|
||||
// Load styles
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
@ -426,11 +432,11 @@ final class JSite extends JApplication
|
|||
$template->params = $registry;
|
||||
|
||||
// Create home element
|
||||
if ($template->home == 1) {
|
||||
if ($template->home == '1' && !isset($templates[0]) || $this->_language_filter && $template->home == $tag) {
|
||||
$templates[0] = clone $template;
|
||||
}
|
||||
}
|
||||
$cache->store($templates, 'templates0');
|
||||
$cache->store($templates, 'templates0'.$tag);
|
||||
}
|
||||
|
||||
$template = $templates[$id];
|
||||
|
|
|
@ -27,6 +27,9 @@ $ -> Language fix or change
|
|||
- -> Removed
|
||||
! -> Note
|
||||
|
||||
09-Nov-2010 Jean-Marie Simonet
|
||||
# [#23177] Ability to set a default template style per language when System - Language Filter plugin is on
|
||||
|
||||
09-Nov-2010 Mark Dexter
|
||||
#[#23054] Follow up on Issue 22932 - Alternate Layouts for Components
|
||||
|
||||
|
|
|
@ -896,7 +896,7 @@ CREATE TABLE IF NOT EXISTS `#__template_styles` (
|
|||
`id` integer unsigned NOT NULL AUTO_INCREMENT,
|
||||
`template` varchar(50) NOT NULL DEFAULT '',
|
||||
`client_id` tinyint(1) unsigned NOT NULL DEFAULT 0,
|
||||
`home` tinyint(1) unsigned NOT NULL DEFAULT 0,
|
||||
`home` char(7) NOT NULL DEFAULT '0',
|
||||
`title` varchar(255) NOT NULL DEFAULT '',
|
||||
`params` varchar(10240) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
10
installation/sql/mysql/joomla_update_16beta14.sql
Normal file
10
installation/sql/mysql/joomla_update_16beta14.sql
Normal file
|
@ -0,0 +1,10 @@
|
|||
# $Id$
|
||||
|
||||
#
|
||||
# Database updates for 1.6 Beta 13 to Beta 14
|
||||
#
|
||||
|
||||
ALTER TABLE `#__template_styles`
|
||||
CHANGE `home` `home` char(7) NOT NULL DEFAULT '0';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user