ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilInternalLink Class Reference

Class ilInternalLink. More...

+ Collaboration diagram for ilInternalLink:

Public Member Functions

 _deleteAllLinksOfSource ($a_source_type, $a_source_id, $a_lang="-")
 Delete all links of a given source. More...
 
 _deleteAllLinksToTarget ($a_target_type, $a_target_id, $a_target_inst=0)
 Delete all links to a given target. More...
 
 _saveLink ($a_source_type, $a_source_id, $a_target_type, $a_target_id, $a_target_inst=0, $a_source_lang="-")
 save internal link information More...
 
 _getSourcesOfTarget ($a_target_type, $a_target_id, $a_target_inst)
 get all sources of a link target More...
 
 _getTargetsOfSource ($a_source_type, $a_source_id, $a_source_lang="-")
 Get all targets of a source object (e.g., a page) More...
 
 _getIdForImportId ($a_type, $a_target)
 Get current id for an import id. More...
 
 _exists ($a_type, $a_target)
 Check if internal link refers to a valid target. More...
 
 _extractInstOfTarget ($a_target)
 Extract installation id out of target. More...
 
 _removeInstFromTarget ($a_target)
 Removes installation id from target string. More...
 
 _extractObjIdOfTarget ($a_target)
 Extract object id out of target. More...
 
 _extractTypeOfTarget ($a_target)
 Extract type out of target. More...
 

Detailed Description

Class ilInternalLink.

Some methods to handle internal links

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 14 of file class.ilInternalLink.php.

Member Function Documentation

◆ _deleteAllLinksOfSource()

ilInternalLink::_deleteAllLinksOfSource (   $a_source_type,
  $a_source_id,
  $a_lang = "-" 
)

Delete all links of a given source.

Parameters
string$a_source_typesource type
int$a_source_ifsource id
int$a_langsource language

Definition at line 23 of file class.ilInternalLink.php.

Referenced by SurveyQuestion\_resolveIntLinks(), assQuestion\_resolveIntLinks(), assQuestion\copySuggestedSolutionFiles(), SurveyQuestion\delete(), ilPageObject\deleteInternalLinks(), assQuestion\deleteSuggestedSolutions(), SurveyQuestion\saveMaterial(), and SurveyQuestion\syncWithOriginal().

24  {
25  global $ilias, $ilDB;
26 
27  $lang_where = "";
28  if ($a_lang != "")
29  {
30  $lang_where = " AND source_lang = ".$ilDB->quote($a_lang, "text");
31  }
32 
33  $q = "DELETE FROM int_link WHERE source_type = ".
34  $ilDB->quote($a_source_type, "text")." AND source_id=".
35  $ilDB->quote((int) $a_source_id, "integer").
36  $lang_where;
37  $ilDB->manipulate($q);
38  }
+ Here is the caller graph for this function:

◆ _deleteAllLinksToTarget()

ilInternalLink::_deleteAllLinksToTarget (   $a_target_type,
  $a_target_id,
  $a_target_inst = 0 
)

Delete all links to a given target.

Parameters
string$a_target_typetarget type
int$a_target_idtarget id
int$a_target_insttarget installation id

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

Referenced by ilPortfolioPage\delete(), and ilWikiPage\delete().

48  {
49  global $ilias, $ilDB;
50 
51  $ilDB->manipulateF("DELETE FROM int_link WHERE target_type = %s ".
52  " AND target_id = %s AND target_inst = %s ",
53  array("text", "integer", "integer"),
54  array($a_target_type, (int) $a_target_id, (int) $a_target_inst));
55  }
+ Here is the caller graph for this function:

◆ _exists()

ilInternalLink::_exists (   $a_type,
  $a_target 
)

Check if internal link refers to a valid target.

Parameters
string$a_typetarget type ("PageObject" | "StructureObject" | "GlossaryItem" | "MediaObject")
string$a_targettarget id, e.g. "il__pg_244")
Returns
boolean true/false

Definition at line 256 of file class.ilInternalLink.php.

References $ref_id, ilObjMediaObject\_exists(), ilGlossaryTerm\_exists(), ilPageObject\_exists(), ilLMObject\_exists(), and _extractObjIdOfTarget().

Referenced by ilPageObject\resolveIntLinks().

257  {
258  global $tree;
259 
260  switch($a_type)
261  {
262  case "PageObject":
263  case "StructureObject":
264  return ilLMObject::_exists($a_target);
265  break;
266 
267  case "GlossaryItem":
268  return ilGlossaryTerm::_exists($a_target);
269  break;
270 
271  case "MediaObject":
272  return ilObjMediaObject::_exists($a_target);
273  break;
274 
275  case "WikiPage":
276  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
277  return ilWikiPage::_exists("wiki", (int)$a_target);
278  break;
279 
280  case "RepositoryItem":
281  if (is_int(strpos($a_target, "_")))
282  {
284  return $tree->isInTree($ref_id);
285  }
286  break;
287  }
288  return false;
289  }
_exists($a_id)
checks wether a glossary term with specified id exists or not
_exists($a_id)
checks wether a lm content object with specified id exists or not
static _exists($a_parent_type, $a_id, $a_lang="")
Checks whether page exists.
static _exists($a_id)
checks wether a lm content object with specified id exists or not
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _extractInstOfTarget()

ilInternalLink::_extractInstOfTarget (   $a_target)

Extract installation id out of target.

Parameters
string$a_targetimport target id (e.g. "il_2_pg_22")

Definition at line 297 of file class.ilInternalLink.php.

Referenced by _getIdForImportId(), ilPageObject\_handleImportRepositoryLinks(), ilPCQuestion\afterPageUpdate(), ilPCQuestionGUI\edit(), ilQuestionExporter\exportQuestion(), ilPCQuestionGUI\feedback(), ilPageObject\getQuestionIds(), ilPageObject\newIIMCopies(), ilPageObject\newMobCopies(), ilPageObject\newQuestionCopies(), ilPageObject\resolveIntLinks(), ilPCQuestionGUI\setTabs(), and ilLMObject\updateInternalLinks().

298  {
299  if (!is_int(strpos($a_target, "__")))
300  {
301  $target = explode("_", $a_target);
302  if ($target[1] > 0)
303  {
304  return $target[1];
305  }
306  }
307  return false;
308  }
+ Here is the caller graph for this function:

◆ _extractObjIdOfTarget()

◆ _extractTypeOfTarget()

ilInternalLink::_extractTypeOfTarget (   $a_target)

Extract type out of target.

Parameters
string$a_targetimport target id (e.g. "il_2_pg_22")

Definition at line 344 of file class.ilInternalLink.php.

Referenced by ilLMObject\updateInternalLinks().

345  {
346  $target = explode("_", $a_target);
347  return $target[count($target) - 2];
348  }
+ Here is the caller graph for this function:

◆ _getIdForImportId()

ilInternalLink::_getIdForImportId (   $a_type,
  $a_target 
)

Get current id for an import id.

Parameters
string$a_typetarget type ("PageObject" | "StructureObject" | "GlossaryItem" | "MediaObject")
string$a_targetimport target id (e.g. "il_2_pg_22")
Returns
string current target id (e.g. "il__pg_244")

Definition at line 161 of file class.ilInternalLink.php.

References _extractInstOfTarget(), ilObject\_getAllReferences(), ilGlossaryTerm\_getIdForImportId(), ilLMObject\_getIdForImportId(), and ilObject\_getIdForImportId().

Referenced by SurveyQuestion\_resolveInternalLink(), assQuestion\_resolveInternalLink(), ilMapArea\_resolveIntLinks(), and ilPageObject\resolveIntLinks().

162  {
163  switch($a_type)
164  {
165  case "PageObject":
166  $id = ilLMObject::_getIdForImportId($a_target);
167  if($id > 0)
168  {
169  return "il__pg_".$id;
170  }
171  break;
172 
173  case "StructureObject":
174  $id = ilLMObject::_getIdForImportId($a_target);
175  if($id > 0)
176  {
177  return "il__st_".$id;
178  }
179  break;
180 
181  case "GlossaryItem":
182  $id = ilGlossaryTerm::_getIdForImportId($a_target);
183  if($id > 0)
184  {
185  return "il__git_".$id;
186  }
187  break;
188 
189  case "WikiPage":
190  // no import IDs for wiki pages (yet)
191  //$id = ilGlossaryTerm::_getIdForImportId($a_target);
192  $id = 0;
193  if($id > 0)
194  {
195  return "il__wpage_".$id;
196  }
197  break;
198 
199  case "MediaObject":
200  $id = ilObjMediaObject::_getIdForImportId($a_target);
201  if($id > 0)
202  {
203  return "il__mob_".$id;
204  }
205  break;
206 
207  case "RepositoryItem":
208 
209  $tarr = explode("_", $a_target);
210  $import_id = $a_target;
211 
212  // if a ref id part is given, strip this
213  // since this will not be part of an import id
214  if ($tarr[4] != "")
215  {
216  $import_id = $tarr[0]."_".$tarr[1]."_".$tarr[2]."_".$tarr[3];
217  }
218  if (ilInternalLink::_extractInstOfTarget($a_target) == IL_INST_ID
219  && IL_INST_ID > 0)
220  {
221  // does it have a ref id part?
222  if ($tarr[4] != "")
223  {
224  return "il__obj_".$tarr[4];
225  }
226  }
227 
228  $id = ilObject::_getIdForImportId($import_id);
229 //echo "-$a_target-$id-";
230  // get ref id for object id
231  // (see ilPageObject::insertInstIntoIDs for the export procedure)
232  if($id > 0)
233  {
234  $refs = ilObject::_getAllReferences($id);
235 //var_dump($refs);
236  foreach ($refs as $ref)
237  {
238  return "il__obj_".$ref;
239  }
240  }
241  break;
242 
243  }
244  return false;
245  }
_getIdForImportId($a_import_id)
get current object id for import id (static)
static _getAllReferences($a_id)
get all reference ids of object
_getIdForImportId($a_import_id)
get current term id for import id (static)
_getIdForImportId($a_import_id)
get current object id for import id (static)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSourcesOfTarget()

ilInternalLink::_getSourcesOfTarget (   $a_target_type,
  $a_target_id,
  $a_target_inst 
)

get all sources of a link target

Parameters
string$a_target_typetarget type
int$a_target_idtarget id
int$a_target_insttarget installation id
Returns
array sources (array of array("type", "id"))

Definition at line 97 of file class.ilInternalLink.php.

Referenced by ilPageObject\_handleImportRepositoryLinks(), ilWebAccessChecker\checkAccessGlossaryTerm(), ilWikiPage\getLinksToPage(), ilWikiPage\getOrphanedPages(), ilGlossaryTerm\getUsages(), ilGlossaryPresentationGUI\listDefinitions(), ilContObjParser\processPagesToParse(), ilWikiPage\rename(), and ilLMObject\updateInternalLinks().

98  {
99  global $ilias, $ilDB;
100 
101  $q = "SELECT * FROM int_link WHERE ".
102  "target_type = ".$ilDB->quote($a_target_type, "text")." AND ".
103  "target_id = ".$ilDB->quote((int) $a_target_id, "integer")." AND ".
104  "target_inst = ".$ilDB->quote((int) $a_target_inst, "integer");
105  $source_set = $ilDB->query($q);
106  $sources = array();
107  while ($source_rec = $ilDB->fetchAssoc($source_set))
108  {
109  $sources[$source_rec["source_type"].":".$source_rec["source_id"].":".$source_rec["source_lang"]] =
110  array("type" => $source_rec["source_type"], "id" => $source_rec["source_id"],
111  "lang" => $source_rec["source_lang"]);
112  }
113 
114  return $sources;
115  }
+ Here is the caller graph for this function:

◆ _getTargetsOfSource()

ilInternalLink::_getTargetsOfSource (   $a_source_type,
  $a_source_id,
  $a_source_lang = "-" 
)

Get all targets of a source object (e.g., a page)

Parameters
string$a_source_typesource type (e.g. "lm:pg" | "dbk:pg")
int$a_source_idsource id
Returns
array targets (array of array("type", "id", "inst"))

Definition at line 125 of file class.ilInternalLink.php.

Referenced by ilObjContentObject\exportHTMLPages(), ilSCORM2004Asset\getGlossaryTermIds(), ilPageObjectGUI\showPage(), and ilLMPresentationGUI\showPrintView().

126  {
127  global $ilDB;
128 
129  $lang_where = "";
130  if ($a_source_lang != "")
131  {
132  $lang_where = " AND source_lang = ".$ilDB->quote($a_source_lang, "text");
133  }
134 
135  $q = "SELECT * FROM int_link WHERE ".
136  "source_type = ".$ilDB->quote($a_source_type, "text")." AND ".
137  "source_id = ".$ilDB->quote((int) $a_source_id, "integer").
138  $lang_where;
139 
140  $target_set = $ilDB->query($q);
141  $targets = array();
142  while ($target_rec = $ilDB->fetchAssoc($target_set))
143  {
144  $targets[$target_rec["target_type"].":".$target_rec["target_id"].":".$target_rec["target_inst"]] =
145  array("type" => $target_rec["target_type"], "id" => $target_rec["target_id"],
146  "inst" => $target_rec["target_inst"]);
147  }
148 
149  return $targets;
150  }
+ Here is the caller graph for this function:

◆ _removeInstFromTarget()

ilInternalLink::_removeInstFromTarget (   $a_target)

Removes installation id from target string.

Parameters
string$a_targetimport target id (e.g. "il_2_pg_22")

Definition at line 315 of file class.ilInternalLink.php.

Referenced by ilPageObject\resolveIntLinks().

316  {
317  if (!is_int(strpos($a_target, "__")))
318  {
319  $target = explode("_", $a_target);
320  if ($target[1] > 0)
321  {
322  return "il__".$target[2]."_".$target[3];
323  }
324  }
325  return false;
326  }
+ Here is the caller graph for this function:

◆ _saveLink()

ilInternalLink::_saveLink (   $a_source_type,
  $a_source_id,
  $a_target_type,
  $a_target_id,
  $a_target_inst = 0,
  $a_source_lang = "-" 
)

save internal link information

Parameters
string$a_source_typesource type
int$a_source_ifsource id
string$a_target_typetarget type
int$a_target_idtarget id
int$a_target_insttarget installation id

Definition at line 66 of file class.ilInternalLink.php.

Referenced by SurveyQuestion\_resolveIntLinks(), assQuestion\_resolveIntLinks(), assQuestion\copySuggestedSolutionFiles(), ilWikiPage\saveInternalLinks(), ilPageObject\saveInternalLinks(), SurveyQuestion\saveMaterial(), and SurveyQuestion\syncWithOriginal().

68  {
69  global $ilias, $ilDB;
70 
71  $ilDB->manipulate("DELETE FROM int_link WHERE ".
72  "source_type = ".$ilDB->quote($a_source_type, "text")." AND ".
73  "source_id = ".$ilDB->quote((int) $a_source_id, "integer")." AND ".
74  "target_type = ".$ilDB->quote($a_target_type, "text")." AND ".
75  "target_id = ".$ilDB->quote((int) $a_target_id, "integer")." AND ".
76  "target_inst = ".$ilDB->quote((int) $a_target_inst, "integer")." AND ".
77  "source_lang = ".$ilDB->quote($a_source_lang, "text"));
78  $ilDB->manipulate("INSERT INTO int_link ".
79  "(source_type, source_id, target_type, target_id, target_inst, source_lang) VALUES (".
80  $ilDB->quote($a_source_type, "text").",".
81  $ilDB->quote((int) $a_source_id, "integer").",".
82  $ilDB->quote($a_target_type, "text").",".
83  $ilDB->quote((int) $a_target_id, "integer").",".
84  $ilDB->quote((int) $a_target_inst, "integer").",".
85  $ilDB->quote($a_source_lang, "text").")");
86  }
+ Here is the caller graph for this function:

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