ILIAS  release_8 Revision v8.24
ilObjLanguageAccess Class Reference
+ Collaboration diagram for ilObjLanguageAccess:

Static Public Member Functions

static _checkTranslate ()
 Permission check for translations. More...
 
static _checkMaintenance ()
 Permission check for language maintenance (import/export) More...
 
static _lookupLangFolderRefId ()
 Lookup the ref_id of the global language folder. More...
 
static _lookupId (string $a_key)
 Lookup the object ID for a language key. More...
 
static _getTranslationLink ()
 Get the link to translate the current page. More...
 
static _isPageTranslation ()
 Check if the current request is a page translation. More...
 
static _saveUsages ()
 Store the collected language variable usages in the user session This should be called as late as possible in a request. More...
 
static _getSavedModules ()
 Get the stored modules from the user session. More...
 
static _getSavedTopics ()
 Get the stored topics from the user session. More...
 

Static Protected Attributes

static bool $cached_check_translate
 

Detailed Description

Definition at line 34 of file class.ilObjLanguageAccess.php.

Member Function Documentation

◆ _checkMaintenance()

static ilObjLanguageAccess::_checkMaintenance ( )
static

Permission check for language maintenance (import/export)

  • The user must have read and write permissions to the language folder

Return whether maintenance is possible (true/false)

Definition at line 81 of file class.ilObjLanguageAccess.php.

81 : bool
82 {
83 global $DIC;
84 $ilSetting = $DIC->settings();
85 $ilUser = $DIC->user();
86 $rbacsystem = $DIC->rbac()->system();
87
88 if ($ilUser->getId()) {
90 return $rbacsystem->checkAccess("read,write", $ref_id);
91 }
92 return false;
93 }
static _lookupLangFolderRefId()
Lookup the ref_id of the global language folder.
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$ref_id
Definition: ltiauth.php:67
global $ilSetting
Definition: privfeed.php:17

References $DIC, $ilSetting, $ilUser, $ref_id, and _lookupLangFolderRefId().

Referenced by ilObjLanguageExtGUI\executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _checkTranslate()

static ilObjLanguageAccess::_checkTranslate ( )
static

Permission check for translations.

This check is used for displaying the translation link on each page

  • The page translation of the current language must be turned on
  • The user must have read and write permissions to the language folder

Return whether translation is possible (true/false)

Definition at line 47 of file class.ilObjLanguageAccess.php.

47 : bool
48 {
49 global $DIC;
50 $lng = $DIC->language();
51 $ilSetting = $DIC->settings();
52 $ilUser = $DIC->user();
53 $rbacsystem = $DIC->rbac()->system();
54
55 if (isset(self::$cached_check_translate)) {
57 }
58
59 if (!$ilSetting->get("lang_translate_" . $lng->getLangKey())) {
60 self::$cached_check_translate = false;
62 }
63
64 if ($ilUser->getId()) {
66 self::$cached_check_translate = $rbacsystem->checkAccess("read,write", $ref_id);
67 } else {
68 self::$cached_check_translate = false;
69 }
70
72 }
$lng

References $cached_check_translate, $DIC, $ilSetting, $ilUser, $lng, $ref_id, and _lookupLangFolderRefId().

Referenced by ilDataCollectionGlobalTemplate\fillFooter(), ilGlobalTemplate\fillFooter(), and ILIAS\UICore\PageContentProvider\getFooterModification().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSavedModules()

static ilObjLanguageAccess::_getSavedModules ( )
static

Get the stored modules from the user session.

Return list of module names

Definition at line 200 of file class.ilObjLanguageAccess.php.

200 : array
201 {
202 $saved = [];
203 $lang_ext_maintenance_from_session = ilSession::get("lang_ext_maintenance");
204 if (is_array($lang_ext_maintenance_from_session) && isset($lang_ext_maintenance_from_session["used_modules"])) {
205 $saved = $lang_ext_maintenance_from_session["used_modules"];
206 }
207 return $saved;
208 }
static get(string $a_var)

References ilSession\get().

Referenced by ilObjLanguageExtGUI\initAddNewEntryForm(), and ilObjLanguageExtGUI\viewObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSavedTopics()

static ilObjLanguageAccess::_getSavedTopics ( )
static

Get the stored topics from the user session.

Return list of module names

Definition at line 215 of file class.ilObjLanguageAccess.php.

215 : array
216 {
217 $saved = [];
218 $lang_ext_maintenance_from_session = ilSession::get("lang_ext_maintenance");
219 if (is_array($lang_ext_maintenance_from_session) && isset($lang_ext_maintenance_from_session["used_topics"])) {
220 $saved = $lang_ext_maintenance_from_session["used_topics"];
221 }
222 return $saved;
223 }

References ilSession\get().

Referenced by ilObjLanguageExtGUI\initAddNewEntryForm(), and ilObjLanguageExtGUI\viewObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getTranslationLink()

static ilObjLanguageAccess::_getTranslationLink ( )
static

Get the link to translate the current page.

Return translation link

Definition at line 139 of file class.ilObjLanguageAccess.php.

139 : string
140 {
141 // ref id must be given to prevent params being deleted by ilAdministrtionGUI
142 return "ilias.php"
143 . "?ref_id=" . self::_lookupLangFolderRefId()
144 . "&baseClass=ilAdministrationGUI"
145 . "&cmdClass=ilobjlanguageextgui"
146 . "&view_mode=translate"
147 . "&reset_offset=true";
148 }

References _lookupLangFolderRefId().

Referenced by ilDataCollectionGlobalTemplate\fillFooter(), ilGlobalTemplate\fillFooter(), and ILIAS\UICore\PageContentProvider\getFooterModification().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isPageTranslation()

static ilObjLanguageAccess::_isPageTranslation ( )
static

Check if the current request is a page translation.

The page translation mode is used when the translation of a single page is called by the translation link on a page footer. On this screen only the topics stored from the calling page are shown for translation and only a save function for these topics is offered.

Returns
bool page translation (true or false)

Definition at line 160 of file class.ilObjLanguageAccess.php.

160 : bool
161 {
162 global $DIC;
163 $cmdClass = "";
164 $view_mode_get = "";
165 if ($DIC->http()->wrapper()->query()->has("cmdClass")) {
166 $cmdClass = $DIC->http()->wrapper()->query()->retrieve(
167 "cmdClass",
168 $DIC->refinery()->kindlyTo()->string()
169 );
170 }
171 if ($DIC->http()->wrapper()->query()->has("view_mode")) {
172 $view_mode_get = $DIC->http()->wrapper()->query()->retrieve(
173 "view_mode",
174 $DIC->refinery()->kindlyTo()->string()
175 );
176 }
177 return (strtolower($cmdClass) === "ilobjlanguageextgui" && $view_mode_get === "translate");
178 }

References $DIC.

Referenced by ilLanguageExtTableGUI\__construct(), ilObjLanguageExtGUI\addAdminLocatorItems(), ilDataCollectionGlobalTemplate\fillFooter(), ilGlobalTemplate\fillFooter(), ilObjLanguageExtGUI\getAdminTabs(), ILIAS\UICore\PageContentProvider\getFooterModification(), ilLanguageExtTableGUI\initFilter(), ilObjLanguageExtGUI\setTitleAndDescription(), and ilObjLanguageExtGUI\viewObject().

+ Here is the caller graph for this function:

◆ _lookupId()

static ilObjLanguageAccess::_lookupId ( string  $a_key)
static

Lookup the object ID for a language key.

$a_key language key Return language object id

Definition at line 120 of file class.ilObjLanguageAccess.php.

120 : int
121 {
122 global $DIC;
123 $ilDB = $DIC->database();
124
125 $q = "SELECT obj_id FROM object_data " .
126 " WHERE type = " . $ilDB->quote("lng", "text") .
127 " AND title = " . $ilDB->quote($a_key, "text");
128 $set = $ilDB->query($q);
129 $row = $ilDB->fetchAssoc($set);
130 return (int) $row["obj_id"];
131 }

References $DIC, and $ilDB.

Referenced by ilObjLanguageExtGUI\__construct().

+ Here is the caller graph for this function:

◆ _lookupLangFolderRefId()

static ilObjLanguageAccess::_lookupLangFolderRefId ( )
static

Lookup the ref_id of the global language folder.

Return language folder ref_id

Definition at line 101 of file class.ilObjLanguageAccess.php.

101 : int
102 {
103 global $DIC;
104 $ilDB = $DIC->database();
105
106 $q = "SELECT ref_id FROM object_reference r, object_data d" .
107 " WHERE r.obj_id = d.obj_id AND d.type = " . $ilDB->quote("lngf", "text");
108 $set = $ilDB->query($q);
109 $row = $ilDB->fetchAssoc($set);
110 return (int) $row["ref_id"];
111 }

References $DIC, and $ilDB.

Referenced by _checkMaintenance(), _checkTranslate(), and _getTranslationLink().

+ Here is the caller graph for this function:

◆ _saveUsages()

static ilObjLanguageAccess::_saveUsages ( )
static

Store the collected language variable usages in the user session This should be called as late as possible in a request.

Definition at line 184 of file class.ilObjLanguageAccess.php.

184 : void
185 {
186 global $DIC;
187 $lng = $DIC->language();
188
189 if (self::_checkTranslate() and !self::_isPageTranslation()) {
190 ilSession::set("lang_ext_maintenance", array("used_modules" => array_keys($lng->getUsedModules())));
191 ilSession::set("lang_ext_maintenance", array("used_topics" => array_keys($lng->getUsedTopics())));
192 }
193 }
static set(string $a_var, $a_val)
Set a value.

References $DIC, $lng, and ilSession\set().

Referenced by ilDataCollectionGlobalTemplate\printToStdout(), and ILIAS\Services\UICore\MetaTemplate\PageContentGUI\renderPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cached_check_translate

bool ilObjLanguageAccess::$cached_check_translate
staticprotected

Definition at line 36 of file class.ilObjLanguageAccess.php.

Referenced by _checkTranslate().


The documentation for this class was generated from the following file: