ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

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 }
global $ilDB

References $ilDB.

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

+ 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.

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 }

References $ilDB.

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

+ 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 255 of file class.ilInternalLink.php.

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

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

Referenced by ilPageObject\resolveIntLinks().

+ 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 296 of file class.ilInternalLink.php.

297 {
298 if (!is_int(strpos($a_target, "__")))
299 {
300 $target = explode("_", $a_target);
301 if ($target[1] > 0)
302 {
303 return $target[1];
304 }
305 }
306 return false;
307 }

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().

+ 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 343 of file class.ilInternalLink.php.

344 {
345 $target = explode("_", $a_target);
346 return $target[count($target) - 2];
347 }

Referenced by ilLMObject\updateInternalLinks().

+ 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 157 of file class.ilInternalLink.php.

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

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

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

+ 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 93 of file class.ilInternalLink.php.

94 {
95 global $ilias, $ilDB;
96
97 $q = "SELECT * FROM int_link WHERE ".
98 "target_type = ".$ilDB->quote($a_target_type, "text")." AND ".
99 "target_id = ".$ilDB->quote((int) $a_target_id, "integer")." AND ".
100 "target_inst = ".$ilDB->quote((int) $a_target_inst, "integer");
101 $source_set = $ilDB->query($q);
102 $sources = array();
103 while ($source_rec = $ilDB->fetchAssoc($source_set))
104 {
105 $sources[$source_rec["source_type"].":".$source_rec["source_id"].":".$source_rec["source_lang"]] =
106 array("type" => $source_rec["source_type"], "id" => $source_rec["source_id"],
107 "lang" => $source_rec["source_lang"]);
108 }
109
110 return $sources;
111 }

References $ilDB.

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

+ 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 121 of file class.ilInternalLink.php.

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

References $ilDB.

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

+ 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 314 of file class.ilInternalLink.php.

315 {
316 if (!is_int(strpos($a_target, "__")))
317 {
318 $target = explode("_", $a_target);
319 if ($target[1] > 0)
320 {
321 return "il__".$target[2]."_".$target[3];
322 }
323 }
324 return false;
325 }

Referenced by ilPageObject\resolveIntLinks().

+ 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.

68 {
69 global $ilDB;
70
71 $ilDB->replace("int_link",
72 array(
73 "source_type" => array("text", $a_source_type),
74 "source_id" => array("integer", (int) $a_source_id),
75 "source_lang" => array("text", $a_source_lang),
76 "target_type" => array("text", $a_target_type),
77 "target_id" => array("integer", (int) $a_target_id),
78 "target_inst" => array("integer", (int) $a_target_inst)
79 ),
80 array()
81 );
82 }

References $ilDB.

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

+ Here is the caller graph for this function:

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