Skip to content

Commit

Permalink
Merge pull request #313 from infograf768/new_metadata
Browse files Browse the repository at this point in the history
Adding new metadata to prepare for 3.7.
  • Loading branch information
infograf768 authored Oct 27, 2016
2 parents 85b5353 + 82f1e6c commit 144fe2a
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 46 deletions.
5 changes: 5 additions & 0 deletions component/admin/language/en-GB/en-GB.com_localise.ini
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,16 @@ COM_LOCALISE_FIELDSET_LANGUAGE_AUTHOR="Author details"
COM_LOCALISE_FIELDSET_LANGUAGE_AUTHOR_DESC="The author of the file"
COM_LOCALISE_FIELDSET_LANGUAGE_LANGUAGE="Language details"
COM_LOCALISE_FIELDSET_LANGUAGE_LANGUAGE_DESC="The description of the language"
COM_LOCALISE_FIELDSET_LANGUAGE_META_DESC="Metadata"
COM_LOCALISE_FIELDSET_LANGUAGE_PERMISSIONS="Permissions"
COM_LOCALISE_HEADER_LANGUAGE_EDIT="Edit language"
COM_LOCALISE_HEADER_LANGUAGE_NEW="New language"
COM_LOCALISE_LABEL_LANGUAGE_AUTHOR="Author"
COM_LOCALISE_LABEL_LANGUAGE_AUTHOR_DESC="The name of the author"
COM_LOCALISE_LABEL_LANGUAGE_AUTHORCOPYRIGHT="Author Copyright"
COM_LOCALISE_LABEL_LANGUAGE_AUTHORCOPYRIGHT_DESC="Translation Team or Translator's name for Core files, 3pd author for non-core files"
COM_LOCALISE_LABEL_LANGUAGE_CALENDAR_DESC="Enter the calendar type for this language. Example: 'gregorian' or 'jalali'."
COM_LOCALISE_LABEL_LANGUAGE_CALENDAR="Calendar"
COM_LOCALISE_LABEL_LANGUAGE_CLIENT="Location"
COM_LOCALISE_LABEL_LANGUAGE_CLIENT_DESC="The location this xml belongs to"
COM_LOCALISE_LABEL_LANGUAGE_COPYRIGHT="Author copyright"
Expand All @@ -115,6 +118,8 @@ COM_LOCALISE_LABEL_LANGUAGE_LOCALE="Locale"
COM_LOCALISE_LABEL_LANGUAGE_LOCALE_DESC="List of locales for the language. Use the utf8 locales separated by a comma. <br />For example: en_GB.utf8, en_GB.UTF-8"
COM_LOCALISE_LABEL_LANGUAGE_NAME="Language name"
COM_LOCALISE_LABEL_LANGUAGE_NAME_DESC="[Name of language] ([Country code or name])"
COM_LOCALISE_LABEL_LANGUAGE_NATIVE_NAME_DESC="Enter the native name for this language. Example: 'Français (France)` for French."
COM_LOCALISE_LABEL_LANGUAGE_NATIVE_NAME="Native Name"
COM_LOCALISE_LABEL_LANGUAGE_PDFFONTNAME="PDF Font name"
COM_LOCALISE_LABEL_LANGUAGE_PDFFONTNAME_DESC="The PDF Font to be used for this language"
COM_LOCALISE_LABEL_LANGUAGE_RTL="RTL"
Expand Down
92 changes: 56 additions & 36 deletions component/admin/models/forms/language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,6 @@
label="COM_LOCALISE_LABEL_LANGUAGE_CLIENT"
description="COM_LOCALISE_LABEL_LANGUAGE_CLIENT_DESC"
required="true" />
<field
name="firstDay"
type="list"
default="0"
required="true"
label="COM_LOCALISE_LABEL_LANGUAGE_FIRSTDAY"
description="COM_LOCALISE_LABEL_LANGUAGE_FIRSTDAY_DESC">
<option value="0">SUNDAY</option>
<option value="1">MONDAY</option>
<option value="2">TUESDAY</option>
<option value="3">WEDNESDAY</option>
<option value="4">THURSDAY</option>
<option value="5">FRIDAY</option>
<option value="6">SATURDAY</option>
</field>
<field
name="weekEnd"
type="text"
class="ltr"
size="10"
label="COM_LOCALISE_LABEL_LANGUAGE_WEEKEND"
description="COM_LOCALISE_LABEL_LANGUAGE_WEEKEND_DESC" />
<field
name="tag"
type="text"
Expand All @@ -46,17 +24,34 @@
name="name"
type="text"
required="true"
class="span4"
default="[Name of language] ([Country name])"
label="COM_LOCALISE_LABEL_LANGUAGE_NAME"
description="COM_LOCALISE_LABEL_LANGUAGE_NAME_DESC" />
<field
name="description"
type="textarea"
class="span4"
default="[Name of language] [site, administrator or installation] language for Joomla"
label="COM_LOCALISE_LABEL_LANGUAGE_DESCRIPTION"
description="COM_LOCALISE_LABEL_LANGUAGE_DESCRIPTION_DESC" />
<field
name="version"
type="text"
required="true"
class="ltr"
label="COM_LOCALISE_LABEL_LANGUAGE_VERSION"
description="COM_LOCALISE_LABEL_LANGUAGE_VERSION_DESC" />
<field
name="asset_id"
type="hidden"
filter="unset" />
<field
name="id"
type="hidden" />
</fieldset>
<fieldset
name="meta"
description="COM_LOCALISE_FIELDSET_LANGUAGE_META_DESC">

<field
name="rtl"
type="radio"
Expand All @@ -75,13 +70,45 @@
label="COM_LOCALISE_LABEL_LANGUAGE_LOCALE"
description="COM_LOCALISE_LABEL_LANGUAGE_LOCALE_DESC" />
<field
name="asset_id"
type="hidden"
filter="unset" />
name="firstDay"
type="list"
default="0"
required="true"
label="COM_LOCALISE_LABEL_LANGUAGE_FIRSTDAY"
description="COM_LOCALISE_LABEL_LANGUAGE_FIRSTDAY_DESC">
<option value="0">SUNDAY</option>
<option value="1">MONDAY</option>
<option value="2">TUESDAY</option>
<option value="3">WEDNESDAY</option>
<option value="4">THURSDAY</option>
<option value="5">FRIDAY</option>
<option value="6">SATURDAY</option>
</field>
<field
name="id"
type="hidden" />
name="weekEnd"
type="text"
class="ltr"
size="10"
label="COM_LOCALISE_LABEL_LANGUAGE_WEEKEND"
description="COM_LOCALISE_LABEL_LANGUAGE_WEEKEND_DESC" />
</fieldset>
<fieldset
name="metanew">
<field
name="nativeName"
type="text"
required="true"
label="COM_LOCALISE_LABEL_LANGUAGE_NATIVE_NAME"
description="COM_LOCALISE_LABEL_LANGUAGE_NATIVE_NAME_DESC" />
<field
name="calendar"
type="text"
default="gregorian"
required="true"
label="COM_LOCALISE_LABEL_LANGUAGE_CALENDAR"
description="COM_LOCALISE_LABEL_LANGUAGE_CALENDAR_DESC" />
</fieldset>

<fieldset
name="permissions"
label="COM_LOCALISE_FIELDSET_LANGUAGE_PERMISSIONS">
Expand Down Expand Up @@ -120,13 +147,6 @@
class="validate-url ltr"
label="COM_LOCALISE_LABEL_LANGUAGE_URL"
description="COM_LOCALISE_LABEL_LANGUAGE_URL_DESC" />
<field
name="version"
type="text"
required="true"
class="ltr"
label="COM_LOCALISE_LABEL_LANGUAGE_VERSION"
description="COM_LOCALISE_LABEL_LANGUAGE_VERSION_DESC" />
<field
name="creationDate"
type="text"
Expand Down
26 changes: 26 additions & 0 deletions component/admin/models/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,25 @@ public function getForm($data = array(), $loadData = true)
$form->setFieldAttribute('firstDay', 'required', 'false');
$form->setFieldAttribute('firstDay', 'disabled', 'true');

$form->setFieldAttribute('calendar', 'required', 'false');
$form->setFieldAttribute('calendar', 'disabled', 'true');

$form->setFieldAttribute('authorEmail', 'disabled', 'true');
$form->setFieldAttribute('authorUrl', 'disabled', 'true');
$form->setFieldAttribute('copyright', 'disabled', 'true');
}
}

// Calendar and Native Name fields are new in 3.7.x
if (version_compare(JVERSION, '3.7', 'lt'))
{
$form->setFieldAttribute('calendar', 'required', 'false');
$form->setFieldAttribute('calendar', 'disabled', 'true');

$form->setFieldAttribute('nativeName', 'required', 'false');
$form->setFieldAttribute('nativeName', 'disabled', 'true');
}

return $form;
}

Expand Down Expand Up @@ -266,6 +279,8 @@ public function validate($form, $data, $group = null)
$form->setFieldAttribute('locale', 'required', 'false');

$form->setFieldAttribute('firstDay', 'required', 'false');

$form->setFieldAttribute('calendar', 'required', 'false');
}

return parent::validate($form, $data, $group);
Expand Down Expand Up @@ -356,6 +371,12 @@ public function save($data = array())
$text .= "\t" . '<description>' . htmlspecialchars($data['description'], ENT_COMPAT, 'UTF-8') . '</description>' . "\n";
$text .= "\t" . '<metadata>' . "\n";
$text .= "\t\t" . '<name>' . htmlspecialchars($data['name'], ENT_COMPAT, 'UTF-8') . '</name>' . "\n";

if (version_compare(JVERSION, '3.7', 'ge'))
{
$text .= "\t\t" . '<nativeName>' . htmlspecialchars($data['nativeName'], ENT_COMPAT, 'UTF-8') . '</nativeName>' . "\n";
}

$text .= "\t\t" . '<tag>' . htmlspecialchars($data['tag'], ENT_COMPAT, 'UTF-8') . '</tag>' . "\n";
$text .= "\t\t" . '<rtl>' . htmlspecialchars($data['rtl'], ENT_COMPAT, 'UTF-8') . '</rtl>' . "\n";

Expand All @@ -365,6 +386,11 @@ public function save($data = array())
$text .= "\t\t" . '<locale>' . htmlspecialchars($data['locale'], ENT_COMPAT, 'UTF-8') . '</locale>' . "\n";
$text .= "\t\t" . '<firstDay>' . htmlspecialchars($data['firstDay'], ENT_COMPAT, 'UTF-8') . '</firstDay>' . "\n";
$text .= "\t\t" . '<weekEnd>' . htmlspecialchars($data['weekEnd'], ENT_COMPAT, 'UTF-8') . '</weekEnd>' . "\n";

if (version_compare(JVERSION, '3.7', 'ge'))
{
$text .= "\t\t" . '<calendar>' . htmlspecialchars($data['calendar'], ENT_COMPAT, 'UTF-8') . '</calendar>' . "\n";
}
}

$text .= "\t" . '</metadata>' . "\n";
Expand Down
48 changes: 38 additions & 10 deletions component/admin/views/language/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,48 @@

<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'default', JText::_($fieldSets['default']->label, true)); ?>

<?php if (!empty($fieldSets['default']->description)):?>
<div class="span6">
<?php if (!empty($fieldSets['default']->description)) : ?>
<p class="tip"><?php echo JText::_($fieldSets['default']->description); ?></p>
<?php endif;?>

<?php foreach($this->form->getFieldset('default') as $field): ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
<?php foreach($this->form->getFieldset('default') as $field): ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="span6">
<?php if (!empty($fieldSets['meta']->description)) : ?>
<p class="tip"><?php echo JText::_($fieldSets['meta']->description); ?></p>
<?php endif;?>
<?php foreach ($this->form->getFieldset('meta') as $field) : ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
<?php if (version_compare(JVERSION, '3.7', 'ge')) : ?>
<?php foreach ($this->form->getFieldset('metanew') as $field) : ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
<?php endif;?>
</div>
<?php endforeach; ?>

<?php echo JHtml::_('bootstrap.endTab'); ?>

Expand Down
6 changes: 6 additions & 0 deletions media/com_localise/js/language-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
// Change attributes
$('#jform_locale').removeAttr('required').removeClass('required');
$('#jform_locale-lbl').removeClass('required').find('span.star').remove();
$('#jform_calendar').removeAttr('required').removeClass('required');
$('#jform_calendar-lbl').removeClass('required').find('span.star').remove();

// Hide fields
$('#jform_locale').closest('.control-group').fadeOut()
$('#jform_calendar').closest('.control-group').fadeOut();
$('#jform_firstDay-lbl').closest('.control-group').fadeOut();
$('#jform_weekEnd-lbl').closest('.control-group').fadeOut();
$('#jform_authorEmail').closest('.control-group').fadeOut();
Expand All @@ -34,9 +37,12 @@
// Change attributes
$('#jform_locale').attr('required', 'required').addClass('required');
$('#jform_locale-lbl').addClass('required').append('<span class=\"star\"> *</span>');
$('#jform_calendar').attr('required', 'required').addClass('required');
$('#jform_calendar-lbl').addClass('required').append('<span class=\"star\"> *</span>');

// Show fields
$('#jform_locale').closest('.control-group').fadeIn();
$('#jform_calendar').closest('.control-group').fadeIn();
$('#jform_firstDay').closest('.control-group').fadeIn();
$('#jform_weekEnd').closest('.control-group').fadeIn();
$('#jform_authorEmail').closest('.control-group').fadeIn();
Expand Down

0 comments on commit 144fe2a

Please sign in to comment.