ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 33 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 80 of file class.ilObjLanguageAccess.php.

80 : bool
81 {
82 global $DIC;
83 $ilSetting = $DIC->settings();
84 $ilUser = $DIC->user();
85 $rbacsystem = $DIC->rbac()->system();
86
87 if ($ilUser->getId()) {
89 return $rbacsystem->checkAccess("read,write", $ref_id);
90 }
91 return false;
92 }
static _lookupLangFolderRefId()
Lookup the ref_id of the global language folder.
$ref_id
Definition: ltiauth.php:66
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26

References $DIC, $ilSetting, $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 46 of file class.ilObjLanguageAccess.php.

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

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

Referenced by ilFooterStandardGroupsProvider\getEntries().

+ 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 199 of file class.ilObjLanguageAccess.php.

199 : array
200 {
201 $saved = [];
202 $lang_ext_maintenance_from_session = ilSession::get("lang_ext_maintenance");
203 if (is_array($lang_ext_maintenance_from_session) && isset($lang_ext_maintenance_from_session["used_modules"])) {
204 $saved = $lang_ext_maintenance_from_session["used_modules"];
205 }
206 return $saved;
207 }
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 214 of file class.ilObjLanguageAccess.php.

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

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 138 of file class.ilObjLanguageAccess.php.

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

References _lookupLangFolderRefId().

Referenced by ilFooterStandardGroupsProvider\getEntries().

+ 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 159 of file class.ilObjLanguageAccess.php.

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

References $DIC.

Referenced by ilLanguageExtTableGUI\__construct(), ilObjLanguageExtGUI\addAdminLocatorItems(), ilObjLanguageExtGUI\getAdminTabs(), ilFooterStandardGroupsProvider\getEntries(), 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 119 of file class.ilObjLanguageAccess.php.

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

References $DIC, $ilDB, and $q.

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 100 of file class.ilObjLanguageAccess.php.

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

References $DIC, $ilDB, and $q.

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 183 of file class.ilObjLanguageAccess.php.

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

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

Referenced by ilDataCollectionGlobalTemplate\printToStdout(), and ILIAS\components\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 35 of file class.ilObjLanguageAccess.php.

Referenced by _checkTranslate().


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