Skip to content

Commit

Permalink
Warning issues after fresh com_localise installation. (#47)
Browse files Browse the repository at this point in the history
* Try to solve issue at my repo PRs

* Bad merge

* Warning issues after fresh installation

* Add JM code to solve the 'branches issue'
  • Loading branch information
Valc authored Nov 13, 2021
1 parent 707be3e commit 044f343
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
14 changes: 8 additions & 6 deletions administrator/components/com_localise/Field/BranchesField.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ protected function getOptions()
{
$attributes = '';
$params = ComponentHelper::getParams('com_localise');
$branches = array();
$branches_path = JPATH_ROOT
. '/administrator/components/com_localise/customisedref/joomla_branches.txt';
if (File::exists($branches_path))
{
file_put_contents($branches_path, '');

file_put_contents($branches_path, '');


$branches_file = file_get_contents($branches_path);
$branches = preg_split("/\\r\\n|\\r|\\n/", $branches_file);
$branches_file = file_get_contents($branches_path);
$branches = preg_split("/\\r\\n|\\r|\\n/", $branches_file);
}

$gh_user = 'joomla';
$gh_project = 'joomla-cms';
Expand Down Expand Up @@ -96,7 +98,7 @@ protected function getOptions()
{
$branch_name = $active_branch->name;

if (!in_array($branch_name, $branches))
if (!in_array($branch_name, $branches) && is_numeric($branch_name[0]) && $branch_name[0] >= 4)
{
$branches[] = $branch_name;
Factory::getApplication()->enqueueMessage(
Expand Down
22 changes: 13 additions & 9 deletions administrator/components/com_localise/Field/ReleasesField.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,25 @@ protected function getOptions()
{
$attributes = '';
$params = ComponentHelper::getParams('com_localise');
$versions = array();
$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')
if (File::exists($versions_path))
{
file_put_contents($versions_path, '');
}
// 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);
$versions_file = file_get_contents($versions_path);
$versions = preg_split("/\\r\\n|\\r|\\n/", $versions_file);
}

$gh_user = 'joomla';
$gh_project = 'joomla-cms';
$gh_token = $params->get('gh_token', '');
$gh_user = 'joomla';
$gh_project = 'joomla-cms';
$gh_token = $params->get('gh_token', '');

$options = new Registry;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,12 +769,16 @@ public static function getSourceGithubfiles($gh_data = array())
$customisedref = $saved_ref;
$last_sources = self::getLastsourcereference();
$last_source = $last_sources[$gh_client];
$versions = array();

$versions_path = JPATH_ROOT
. '/administrator/components/com_localise/customisedref/stable_joomla_releases.txt';

$versions_file = file_get_contents($versions_path);
$versions = preg_split("/\\r\\n|\\r|\\n/", $versions_file);
if (File::exists($versions_path))
{
$versions_file = file_get_contents($versions_path);
$versions = preg_split("/\\r\\n|\\r|\\n/", $versions_file);
}

if ($saved_ref != '0' && !in_array($customisedref, $versions))
{
Expand Down
18 changes: 13 additions & 5 deletions administrator/components/com_localise/Model/TranslationsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,9 @@ private function scanOverride()
*/
private function getTranslations()
{
$app = Factory::getApplication();
$app = Factory::getApplication();
$params = ComponentHelper::getParams('com_localise');
$allow_develop = $params->get('gh_allow_develop', 0);

if (!isset($this->translations))
{
Expand All @@ -754,11 +756,17 @@ private function getTranslations()
return $this->translations;
}

$gh_data = array();
$gh_data['github_client'] = $filter_client;
// This will download from Github the set of core language files by client selected
// to be ready when a file is edited from 'translation' view.
// Only if 'Allow develop' is enabled from 'Options'.
if (isset($allow_develop) && $allow_develop)
{
$gh_data = array();
$gh_data['github_client'] = $filter_client;

$get_github_files = LocaliseHelper::getTargetgithubfiles($gh_data);
$get_customised_ref = LocaliseHelper::getSourceGithubfiles($gh_data);
$get_github_files = LocaliseHelper::getTargetgithubfiles($gh_data);
$get_customised_ref = LocaliseHelper::getSourceGithubfiles($gh_data);
}

$filter_state = $this->getState('filter.state') ? $this->getState('filter.state') : '.';
$filter_tag = $filter_tag ? ("^" . $filter_tag . "$") : '.';
Expand Down
1 change: 1 addition & 0 deletions administrator/components/com_localise/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
name="reference"
type="referencelanguage"
required="true"
default="en-GB"
label="COM_LOCALISE_LABEL_REFERENCE_LANGUAGE"
description="COM_LOCALISE_LABEL_REFERENCE_LANGUAGE_DESC" />
<field
Expand Down

0 comments on commit 044f343

Please sign in to comment.