Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
c91b3a34
Commit
c91b3a34
authored
2 years ago
by
Peter Thienel
Committed by
Jan-Hendrik Willms
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "Löschen eines Studienganges... I18N - Fehler"
Closes #555 Merge request
studip/studip!269
parent
840e59f8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/classes/I18NStringDatafield.php
+30
-18
30 additions, 18 deletions
lib/classes/I18NStringDatafield.php
lib/models/ModuleManagementModel.php
+1
-1
1 addition, 1 deletion
lib/models/ModuleManagementModel.php
with
31 additions
and
19 deletions
lib/classes/I18NStringDatafield.php
+
30
−
18
View file @
c91b3a34
...
@@ -13,12 +13,24 @@
...
@@ -13,12 +13,24 @@
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @category Stud.IP
* @since 4.1
* @since 4.1
*
*
*/
*/
class
I18NStringDatafield
extends
I18NString
class
I18NStringDatafield
extends
I18NString
{
{
/**
* Sets the metadata (database info object_id) of this i18n datafield.
*
* @param array $metadata Database info for object_id.
*/
public
function
setMetadata
(
$metadata
)
{
if
(
is_null
(
$metadata
[
'table'
]))
{
$this
->
metadata
=
$metadata
;
}
}
/**
/**
* Return an array containg the text in all additional languages.
* Return an array containg the text in all additional languages.
*
*
...
@@ -32,7 +44,7 @@ class I18NStringDatafield extends I18NString
...
@@ -32,7 +44,7 @@ class I18NStringDatafield extends I18NString
}
}
return
$this
->
lang
;
return
$this
->
lang
;
}
}
/**
/**
* Stores the i18n String manually in the database
* Stores the i18n String manually in the database
*
*
...
@@ -44,10 +56,11 @@ class I18NStringDatafield extends I18NString
...
@@ -44,10 +56,11 @@ class I18NStringDatafield extends I18NString
$object_id
=
$this
->
metadata
[
'object_id'
];
$object_id
=
$this
->
metadata
[
'object_id'
];
/* Replace translations */
/* Replace translations */
$deleted
=
$db
->
execute
(
"DELETE FROM `datafields_entries` "
$deleted
=
$db
->
execute
(
"DELETE FROM `datafields_entries` "
.
"WHERE `datafield_id` = ? "
.
"WHERE `datafield_id` = ? "
.
"AND `range_id` = ? "
.
"AND `range_id` = ? "
.
"AND `sec_range_id` = ? "
.
"AND `sec_range_id` = ? "
.
"AND `lang` <> ?"
,
$object_id
);
.
"AND `lang` <> ''"
,
[
$object_id
[
0
],
$object_id
[
1
],
$object_id
[
2
]]);
$i18nSQL
=
$db
->
prepare
(
"INSERT INTO `datafields_entries` "
$i18nSQL
=
$db
->
prepare
(
"INSERT INTO `datafields_entries` "
.
"(`datafield_id`, `range_id`, `sec_range_id`, `content`, `lang`) "
.
"(`datafield_id`, `range_id`, `sec_range_id`, `content`, `lang`) "
.
"VALUES (?,?,?,?,?)"
);
.
"VALUES (?,?,?,?,?)"
);
...
@@ -59,10 +72,10 @@ class I18NStringDatafield extends I18NString
...
@@ -59,10 +72,10 @@ class I18NStringDatafield extends I18NString
}
}
}
}
}
}
/**
/**
* Returns an I18NString object by given object_id, table and field.
* Returns an I18NString object by given object_id, table and field.
*
*
* @param string $object_id The id of the object with i18n fields.
* @param string $object_id The id of the object with i18n fields.
* @param string $table The name of the table with the original values.
* @param string $table The name of the table with the original values.
* @param string $field The name of the i18n field.
* @param string $field The name of the i18n field.
...
@@ -81,16 +94,15 @@ class I18NStringDatafield extends I18NString
...
@@ -81,16 +94,15 @@ class I18NStringDatafield extends I18NString
.
"AND `sec_range_id` = ? "
.
"AND `sec_range_id` = ? "
.
"AND `lang` = ''"
,
$object_id
);
.
"AND `lang` = ''"
,
$object_id
);
}
}
// var_dump($object_id, $base); exit;
$table
=
null
;
$table
=
null
;
$field
=
null
;
$field
=
null
;
return
new
self
(
$base
,
self
::
fetchDataForField
(
$object_id
,
$table
,
$field
),
return
new
self
(
$base
,
self
::
fetchDataForField
(
$object_id
,
$table
,
$field
),
compact
(
'object_id'
,
'table'
,
'field'
));
compact
(
'object_id'
,
'table'
,
'field'
));
}
}
/**
/**
* Retrieves all translations for one field.
* Retrieves all translations for one field.
*
*
* @param string $object_id The id of the object with i18n fields.
* @param string $object_id The id of the object with i18n fields.
* @param string $table The name of the table with the original values.
* @param string $table The name of the table with the original values.
* @param string $field The name oof the i18n field.
* @param string $field The name oof the i18n field.
...
@@ -106,11 +118,11 @@ class I18NStringDatafield extends I18NString
...
@@ -106,11 +118,11 @@ class I18NStringDatafield extends I18NString
.
"AND `sec_range_id` = ? "
.
"AND `sec_range_id` = ? "
.
"AND `lang` <> ''"
,
$object_id
);
.
"AND `lang` <> ''"
,
$object_id
);
}
}
/**
/**
* This function is not used in the context of datafields, so it always
* This function is not used in the context of datafields, so it always
* returns an empty array.
* returns an empty array.
*
*
* @param string $object_id The id of the object with i18n fields.
* @param string $object_id The id of the object with i18n fields.
* @param string $table The name of the table with the original values.
* @param string $table The name of the table with the original values.
* @return array An empty array.
* @return array An empty array.
...
@@ -119,11 +131,11 @@ class I18NStringDatafield extends I18NString
...
@@ -119,11 +131,11 @@ class I18NStringDatafield extends I18NString
{
{
return
[];
return
[];
}
}
/**
/**
* Removes all translations by given object id and table name. Accepts the
* Removes all translations by given object id and table name. Accepts the
* language as third parameter to remove only translations to this language.
* language as third parameter to remove only translations to this language.
*
*
* @param string $object_id The id of the sorm object.
* @param string $object_id The id of the sorm object.
* @param string $table The table name.
* @param string $table The table name.
* @param string $lang Optional name of language.
* @param string $lang Optional name of language.
...
@@ -147,5 +159,5 @@ class I18NStringDatafield extends I18NString
...
@@ -147,5 +159,5 @@ class I18NStringDatafield extends I18NString
.
'AND `table` = ?'
,
.
'AND `table` = ?'
,
$object_id
);
$object_id
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
lib/models/ModuleManagementModel.php
+
1
−
1
View file @
c91b3a34
...
@@ -810,7 +810,7 @@ abstract class ModuleManagementModel extends SimpleORMap
...
@@ -810,7 +810,7 @@ abstract class ModuleManagementModel extends SimpleORMap
* @return string The currently selected language.
* @return string The currently selected language.
*/
*/
public
static
final
function
getLanguage
()
public
static
final
function
getLanguage
()
{
return
'DE'
;
{
$language
=
self
::
$language
?:
$GLOBALS
[
'MVV_LANGUAGES'
][
'default'
];
$language
=
self
::
$language
?:
$GLOBALS
[
'MVV_LANGUAGES'
][
'default'
];
return
$language
;
return
$language
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment