ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLink.php
Go to the documentation of this file.
1 <?php
2 
25 class ilLink
26 {
27  protected const LINK_SCRIPT = "goto.php";
28 
29  public static function _getLink(
30  ?int $a_ref_id,
31  string $a_type = '',
32  array $a_params = array(),
33  string $append = ""
34  ): string {
35  global $DIC;
36 
37  $ilObjDataCache = $DIC["ilObjDataCache"];
38  $objDefinition = $DIC['objDefinition'];
39 
40  if ($a_type === '' && !is_null($a_ref_id)) {
41  $a_type = $ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($a_ref_id));
42  }
43  $param_string = '';
44  if (is_array($a_params) && count($a_params)) {
45  foreach ($a_params as $name => $value) {
46  $param_string .= ('&' . $name . '=' . $value);
47  }
48  }
49 
50  // workaround for administration links: https://mantis.ilias.de/view.php?id=33088
51  if (
52  $objDefinition->isAdministrationObject($a_type) &&
53  $param_string === '' &&
54  $append === ''
55  ) {
56  $determined_object_type = $ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($a_ref_id));
57  // https://mantis.ilias.de/view.php?id=34853
58  if ($determined_object_type === $a_type) {
59  return ILIAS_HTTP_PATH . '/ilias.php?baseClass=ilAdministrationGUI&cmd=jump&ref_id=' . $a_ref_id;
60  }
61  }
62  return ILIAS_HTTP_PATH . '/' . self::LINK_SCRIPT . '?target=' . $a_type . '_' . $a_ref_id . $append . '&client_id=' . CLIENT_ID . $param_string;
63  }
64 
72  public static function _getStaticLink(
73  ?int $a_ref_id,
74  string $a_type = '',
75  bool $a_fallback_goto = true,
76  string $append = ""
77  ): string {
78  global $DIC;
79 
80  $ilObjDataCache = $DIC["ilObjDataCache"];
81 
82  if ($a_type === '' && $a_ref_id) {
83  $a_type = $ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($a_ref_id));
84  }
85 
86  $robot_settings = ilRobotSettings::getInstance();
87  if (!$robot_settings->robotSupportEnabled()) {
88  if ($a_fallback_goto) {
89  return self::_getLink($a_ref_id, $a_type, array(), $append);
90  }
91 
92  return false;
93  }
94 
95  // urlencode for append is needed e.g. to process "/" in wiki page names correctly
96  return ILIAS_HTTP_PATH . '/goto_' . urlencode(CLIENT_ID) . '_' . $a_type . '_' . $a_ref_id . urlencode($append) . '.html';
97  }
98 }
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247
static getInstance()
get singleton instance
const CLIENT_ID
Definition: constants.php:41