ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPageLinker.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
15  protected $offline;
16 
20  protected $profile_back_url;
21 
25  protected $ctrl;
26 
30  protected $cmd_gui;
31 
35  public function __construct(string $cmd_gui_class, $offline = false, $profile_back_url = "", ilCtrl $ctrl = null)
36  {
37  global $DIC;
38 
39  $this->offline = $offline;
40  $this->profile_back_url = $profile_back_url;
41  $this->cmd_gui = $cmd_gui_class;
42 
43  $this->ctrl = (is_null($ctrl))
44  ? $DIC->ctrl()
45  : $ctrl;
46  }
47 
51  public function setOffline($offline = true)
52  {
53  $this->offline = $offline;
54  }
55 
56  public function setProfileBackUrl($url)
57  {
58  $this->profile_back_url = $url;
59  }
60 
61 
65  public function getLayoutLinkTargets() : array
66  {
67  $targets = [];
68 
69  return $targets;
70  }
71 
75  public function getLinkTargetsXML()
76  {
77  $layoutLinkTargets = $this->getLayoutLinkTargets();
78 
79  if (0 === count($layoutLinkTargets)) {
80  return '';
81  }
82 
83  $link_info = "<LinkTargets>";
84  foreach ($layoutLinkTargets as $k => $t) {
85  $link_info .= "<LinkTarget TargetFrame=\"" . $t["Type"] . "\" LinkTarget=\"" . $t["Frame"] . "\" OnClick=\"" . $t["OnClick"] . "\" />";
86  }
87  $link_info .= "</LinkTargets>";
88  return $link_info;
89  }
90 
94  public function getLinkXML($int_links) : string
95  {
96  $link_info = "<IntLinkInfos>";
97  foreach ($int_links as $int_link) {
98  $target = $int_link["Target"];
99  if (substr($target, 0, 4) == "il__") {
100  $target_arr = explode("_", $target);
101  $target_id = $target_arr[count($target_arr) - 1];
102  $type = $int_link["Type"];
103 
104  $targetframe = ($int_link["TargetFrame"] != "")
105  ? $int_link["TargetFrame"]
106  : "None";
107 
108  $ltarget = "_top";
109  if ($targetframe != "None") {
110  $ltarget = "_blank";
111  }
112 
113  // anchor
114  $anc = $anc_add = "";
115  if ($int_link["Anchor"] != "") {
116  $anc = $int_link["Anchor"];
117  $anc_add = "_" . rawurlencode($int_link["Anchor"]);
118  }
119 
120  $href = "";
121  $lcontent = "";
122  switch ($type) {
123  case "PageObject":
124  case "StructureObject":
126  if ($type == "PageObject") {
127  $href = "./goto.php?target=pg_" . $target_id . $anc_add;
128  } else {
129  $href = "./goto.php?target=st_" . $target_id;
130  }
131  if ($lm_id == "") {
132  $href = "";
133  }
134  break;
135 
136  case "GlossaryItem":
137  if ($targetframe == "None") {
138  $targetframe = "Glossary";
139  }
140  $href = "./goto.php?target=git_" . $target_id;
141  break;
142 
143  case "MediaObject":
144  if ($this->offline) {
145  $href = "media_" . $target_id . ".html";
146  } else {
147  $this->ctrl->setParameterByClass($this->cmd_gui, "mob_id", $target_id);
148  $href = $this->ctrl->getLinkTargetByClass(
149  $this->cmd_gui,
150  "displayMedia",
151  "",
152  false,
153  true
154  );
155  $this->ctrl->setParameterByClass($this->cmd_gui, "mob_id", "");
156  }
157  break;
158 
159  case "WikiPage":
161  break;
162 
163  case "PortfolioPage":
165  break;
166 
167  case "RepositoryItem":
168  $obj_type = ilObject::_lookupType($target_id, true);
170  $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
171  break;
172 
173  case "User":
174  $obj_type = ilObject::_lookupType($target_id);
175  if ($obj_type == "usr") {
176  include_once("./Services/User/classes/class.ilUserUtil.php");
177  $back = $this->profile_back_url;
178  //var_dump($back); exit;
179  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $target_id);
180  if (strlen($back)) {
181  $this->ctrl->setParameterByClass(
182  "ilpublicuserprofilegui",
183  "back_url",
184  rawurlencode($back)
185  );
186  }
187  $href = "";
188  include_once("./Services/User/classes/class.ilUserUtil.php");
190  $href = $this->ctrl->getLinkTargetByClass(
191  ["ildashboardgui", "ilpublicuserprofilegui"],
192  "getHTML",
193  "",
194  false,
195  true
196  );
197  }
198  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user_id", "");
199  $lcontent = ilUserUtil::getNamePresentation($target_id, false, false);
200  $lcontent = str_replace("&", "&amp;", htmlentities($lcontent));
201  }
202  break;
203 
204  }
205  if ($href != "") {
206  $anc_par = 'Anchor="' . $anc . '"';
207  $link_info .= "<IntLinkInfo Target=\"$target\" Type=\"$type\" " . $anc_par . " " .
208  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" LinkContent=\"$lcontent\" />";
209  }
210  }
211  }
212  $link_info .= "</IntLinkInfos>";
213  $link_info .= $this->getLinkTargetsXML();
214 
215  return $link_info;
216  }
217 
221  public function getFullscreenLink() : string
222  {
223  if ($this->offline) {
224  return "fullscreen.html";
225  }
226 
227  return $this->ctrl->getLinkTargetByClass($this->cmd_gui, "fullscreen", "", false, false);
228  }
229 }
$target_arr
Definition: goto.php:47
This class provides processing control methods.
Page linker.
$type
getLinkTargetsXML()
Get XMl for Link Targets.
static getGotoForPortfolioPageTarget($a_target, $a_offline=false)
Get goto href for internal wiki page link target.
$target_id
Definition: goto.php:49
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static hasPublicProfile($a_user_id)
Has public profile.
static _lookupObjId($a_id)
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static _lookupType($a_id, $a_reference=false)
lookup object type
__construct(string $cmd_gui_class, $offline=false, $profile_back_url="", ilCtrl $ctrl=null)
Constructor.
$DIC
Definition: xapitoken.php:46
$url
setOffline($offline=true)
getLinkXML($int_links)
static getGotoForWikiPageTarget($a_target, $a_offline=false)
Get goto href for internal wiki page link target.