Skip to content

Commit

Permalink
Allows choosing as source pre-stable releases
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 committed Aug 9, 2017
1 parent 7840d68 commit 99f47ff
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
10 changes: 10 additions & 0 deletions component/admin/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@
name="sourcespacer"
class="text"
label="COM_LOCALISE_SOURCE_SPACER_LABEL" />
<field
name="pre_stable"
type="radio"
class="btn-group btn-group-yesno"
default="0"
label="COM_LOCALISE_LABEL_GITHUB_PRESTABLE"
description="COM_LOCALISE_LABEL_GITHUB_PRESTABLE_DESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field
name="customisedref"
type="releases"
Expand Down
2 changes: 2 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 @@ -534,6 +534,8 @@ COM_LOCALISE_LABEL_GITHUB_DEVELOP_TAB="en-GB reference language and development"
COM_LOCALISE_LABEL_GITHUB_DEVELOP_TAB_DESC="<strong>Important!</strong><br/> This feature lets fetch the en-GB reference language from the Joomla Github repository.<br/>It allows to deal with strings modified values and not only new strings. <br/>It will only work when 'Reference language' is set to 'English (en-GB)' in the 'Global configuration' tab.<br />It only handles 'en-GB' core language files."
COM_LOCALISE_LABEL_GITHUB_INSTALLATION_LAST_UPDATE="Last update - Installation"
COM_LOCALISE_LABEL_GITHUB_INSTALLATION_LAST_UPDATE_DESC="The last time installation language file has been updated from Github to get the target en-GB reference."
COM_LOCALISE_LABEL_GITHUB_PRESTABLE="Pre-stable Sources"
COM_LOCALISE_LABEL_GITHUB_PRESTABLE_DESC="Allows choosing in the field below non stable releases as source (alpha, beta, RC). Default is \"No\" to display only stable releases."
COM_LOCALISE_LABEL_GITHUB_SITE_LAST_UPDATE="Last update - Site"
COM_LOCALISE_LABEL_GITHUB_SITE_LAST_UPDATE_DESC="The last time site language files have been updated from Github to get the target en-GB reference."
COM_LOCALISE_LABEL_GITHUB_TOKEN="Github Token *"
Expand Down
32 changes: 26 additions & 6 deletions component/admin/models/fields/releases.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ protected function getOptions()
$params = JComponentHelper::getParams('com_localise');
$versions_path = JPATH_ROOT
. '/administrator/components/com_localise/customisedref/stable_joomla_releases.txt';

// Empty txt file to make sure it contains only stable releases after save.
if ($params->get('pre_stable', '0') == '0')
{
file_put_contents($versions_path, '');
}

$versions_file = file_get_contents($versions_path);
$versions = preg_split("/\\r\\n|\\r|\\n/", $versions_file);

Expand Down Expand Up @@ -93,13 +100,26 @@ protected function getOptions()
$excluded = 1;
}

// Filtering also by "is_numeric" disable betas or similar releases.
if (!in_array($tag_name, $versions) && is_numeric($undoted) && $excluded == 0)
// Filtering by "is_numeric" disable betas or similar releases.
if ($params->get('pre_stable', '0') == '0')
{
if (!in_array($tag_name, $versions) && is_numeric($undoted) && $excluded == 0)
{
$versions[] = $tag_name;
JFactory::getApplication()->enqueueMessage(
JText::sprintf('COM_LOCALISE_NOTICE_NEW_VERSION_DETECTED', $tag_name),
'notice');
}
}
else
{
$versions[] = $tag_name;
JFactory::getApplication()->enqueueMessage(
JText::sprintf('COM_LOCALISE_NOTICE_NEW_VERSION_DETECTED', $tag_name),
'notice');
if (!in_array($tag_name, $versions) && $excluded == 0)
{
$versions[] = $tag_name;
JFactory::getApplication()->enqueueMessage(
JText::sprintf('COM_LOCALISE_NOTICE_NEW_VERSION_DETECTED', $tag_name),
'notice');
}
}
}
}
Expand Down

0 comments on commit 99f47ff

Please sign in to comment.