ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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.
 _deleteAllLinksToTarget ($a_target_type, $a_target_id, $a_target_inst=0)
 Delete all links to a given target.
 _saveLink ($a_source_type, $a_source_id, $a_target_type, $a_target_id, $a_target_inst=0, $a_source_lang="-")
 save internal link information
 _getSourcesOfTarget ($a_target_type, $a_target_id, $a_target_inst)
 get all sources of a link target
 _getTargetsOfSource ($a_source_type, $a_source_id, $a_source_lang="-")
 Get all targets of a source object (e.g., a page)
 _getIdForImportId ($a_type, $a_target)
 Get current id for an import id.
 _exists ($a_type, $a_target)
 Check if internal link refers to a valid target.
 _extractInstOfTarget ($a_target)
 Extract installation id out of target.
 _removeInstFromTarget ($a_target)
 Removes installation id from target string.
 _extractObjIdOfTarget ($a_target)
 Extract object id out of target.
 _extractTypeOfTarget ($a_target)
 Extract type out of target.

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:
class.ilInternalLink.php 54412 2014-10-21 08:22:02Z akill

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

Member Function Documentation

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.

References $ilDB.

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

{
global $ilias, $ilDB;
$lang_where = "";
if ($a_lang != "")
{
$lang_where = " AND source_lang = ".$ilDB->quote($a_lang, "text");
}
$q = "DELETE FROM int_link WHERE source_type = ".
$ilDB->quote($a_source_type, "text")." AND source_id=".
$ilDB->quote((int) $a_source_id, "integer").
$lang_where;
$ilDB->manipulate($q);
}

+ Here is the caller graph for this function:

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.

References $ilDB.

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

{
global $ilias, $ilDB;
$ilDB->manipulateF("DELETE FROM int_link WHERE target_type = %s ".
" AND target_id = %s AND target_inst = %s ",
array("text", "integer", "integer"),
array($a_target_type, (int) $a_target_id, (int) $a_target_inst));
}

+ Here is the caller graph for this function:

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

References $ref_id, and _extractObjIdOfTarget().

Referenced by ilPageObject\resolveIntLinks().

{
global $tree;
switch($a_type)
{
case "PageObject":
case "StructureObject":
return ilLMObject::_exists($a_target);
break;
case "GlossaryItem":
return ilGlossaryTerm::_exists($a_target);
break;
case "MediaObject":
return ilObjMediaObject::_exists($a_target);
break;
case "WikiPage":
include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
return ilWikiPage::_exists("wiki", (int)$a_target);
break;
case "RepositoryItem":
if (is_int(strpos($a_target, "_")))
{
return $tree->isInTree($ref_id);
}
break;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

{
if (!is_int(strpos($a_target, "__")))
{
$target = explode("_", $a_target);
if ($target[1] > 0)
{
return $target[1];
}
}
return false;
}

+ Here is the caller graph for this function:

ilInternalLink::_extractTypeOfTarget (   $a_target)

Extract type out of target.

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

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

Referenced by ilLMObject\updateInternalLinks().

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

+ Here is the caller graph for this function:

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.

References _extractInstOfTarget(), and ilObject\_getAllReferences().

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

{
switch($a_type)
{
case "PageObject":
if($id > 0)
{
return "il__pg_".$id;
}
break;
case "StructureObject":
if($id > 0)
{
return "il__st_".$id;
}
break;
case "GlossaryItem":
if($id > 0)
{
return "il__git_".$id;
}
break;
case "WikiPage":
// no import IDs for wiki pages (yet)
//$id = ilGlossaryTerm::_getIdForImportId($a_target);
$id = 0;
if($id > 0)
{
return "il__wpage_".$id;
}
break;
case "MediaObject":
if($id > 0)
{
return "il__mob_".$id;
}
break;
case "RepositoryItem":
$tarr = explode("_", $a_target);
$import_id = $a_target;
// if a ref id part is given, strip this
// since this will not be part of an import id
if ($tarr[4] != "")
{
$import_id = $tarr[0]."_".$tarr[1]."_".$tarr[2]."_".$tarr[3];
}
if (ilInternalLink::_extractInstOfTarget($a_target) == IL_INST_ID
&& IL_INST_ID > 0)
{
// does it have a ref id part?
if ($tarr[4] != "")
{
return "il__obj_".$tarr[4];
}
}
$id = ilObject::_getIdForImportId($import_id);
//echo "-$a_target-$id-";
// get ref id for object id
// (see ilPageObject::insertInstIntoIDs for the export procedure)
if($id > 0)
{
//var_dump($refs);
foreach ($refs as $ref)
{
return "il__obj_".$ref;
}
}
break;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

References $ilDB.

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

{
global $ilias, $ilDB;
$q = "SELECT * FROM int_link WHERE ".
"target_type = ".$ilDB->quote($a_target_type, "text")." AND ".
"target_id = ".$ilDB->quote((int) $a_target_id, "integer")." AND ".
"target_inst = ".$ilDB->quote((int) $a_target_inst, "integer");
$source_set = $ilDB->query($q);
$sources = array();
while ($source_rec = $ilDB->fetchAssoc($source_set))
{
$sources[$source_rec["source_type"].":".$source_rec["source_id"].":".$source_rec["source_lang"]] =
array("type" => $source_rec["source_type"], "id" => $source_rec["source_id"],
"lang" => $source_rec["source_lang"]);
}
return $sources;
}

+ Here is the caller graph for this function:

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.

References $ilDB.

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

{
global $ilDB;
$lang_where = "";
if ($a_source_lang != "")
{
$lang_where = " AND source_lang = ".$ilDB->quote($a_source_lang, "text");
}
$q = "SELECT * FROM int_link WHERE ".
"source_type = ".$ilDB->quote($a_source_type, "text")." AND ".
"source_id = ".$ilDB->quote((int) $a_source_id, "integer").
$lang_where;
$target_set = $ilDB->query($q);
$targets = array();
while ($target_rec = $ilDB->fetchAssoc($target_set))
{
$targets[$target_rec["target_type"].":".$target_rec["target_id"].":".$target_rec["target_inst"]] =
array("type" => $target_rec["target_type"], "id" => $target_rec["target_id"],
"inst" => $target_rec["target_inst"]);
}
return $targets;
}

+ Here is the caller graph for this function:

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

Referenced by ilPageObject\resolveIntLinks().

{
if (!is_int(strpos($a_target, "__")))
{
$target = explode("_", $a_target);
if ($target[1] > 0)
{
return "il__".$target[2]."_".$target[3];
}
}
return false;
}

+ Here is the caller graph for this function:

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.

References $ilDB.

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

{
global $ilDB;
$ilDB->replace("int_link",
array(
"source_type" => array("text", $a_source_type),
"source_id" => array("integer", (int) $a_source_id),
"source_lang" => array("text", $a_source_lang),
"target_type" => array("text", $a_target_type),
"target_id" => array("integer", (int) $a_target_id),
"target_inst" => array("integer", (int) $a_target_inst)
),
array()
);
}

+ Here is the caller graph for this function:


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