29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-25 23:02:55 +00:00

[imp] [#30342] Small improvement in mod_custom to remove some hardcode

(Fix #879) Thanks Naouak and julienV
This commit is contained in:
Jean-Marie Simonet 2014-03-16 11:16:50 +01:00
parent 7503c12d48
commit 01490e403d
3 changed files with 16 additions and 4 deletions

View File

@ -15,18 +15,24 @@ JHtml::_('behavior.formvalidation');
JHtml::_('behavior.combobox');
JHtml::_('formbehavior.chosen', 'select');
$hasContent = empty($this->item->module) || $this->item->module == 'custom' || $this->item->module == 'mod_custom';
$hasContent = empty($this->item->module) || isset($this->item->xml->customContent);
$hasContentFieldName = "content";
// For a later improvement
if ($hasContent)
{
$hasContentFieldName = "content";
}
// Get Params Fieldsets
$this->fieldsets = $this->form->getFieldsets('params');
$script = "Joomla.submitbutton = function(task)
{
if (task == 'module.cancel' || document.formvalidator.isValid(document.id('module-form'))) {";
if ($hasContent)
{
$script .= $this->form->getField('content')->save();
$script .= $this->form->getField($hasContentFieldName)->save();
}
$script .= " Joomla.submitform(task, document.getElementById('module-form'));
if (self != top)
@ -101,7 +107,7 @@ JFactory::getDocument()->addScriptDeclaration($script);
<?php
if ($hasContent)
{
echo $this->form->getInput('content');
echo $this->form->getInput($hasContentFieldName);
}
$this->fieldset = 'basic';
$html = JLayoutHelper::render('joomla.edit.fieldset', $this);

View File

@ -12,6 +12,9 @@
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>MOD_CUSTOM_XML_DESCRIPTION</description>
<customContent />
<files>
<filename module="mod_custom">mod_custom.php</filename>
<filename>index.html</filename>

View File

@ -12,6 +12,9 @@
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>MOD_CUSTOM_XML_DESCRIPTION</description>
<customContent />
<files>
<filename module="mod_custom">mod_custom.php</filename>
<filename>index.html</filename>