ILIAS  Release_3_10_x_branch Revision 61812
 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)
 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)
 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)
 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 17719 2008-10-17 16:07:32Z akill

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

Member Function Documentation

ilInternalLink::_deleteAllLinksOfSource (   $a_source_type,
  $a_source_id 
)

delete all links of a given source

Parameters
string$a_source_typesource type
int$a_source_ifsource id

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

Referenced by SurveyQuestion\_resolveIntLinks(), assQuestion\_resolveIntLinks(), SurveyQuestion\delete(), assQuestion\deleteSuggestedSolutions(), ilPageObject\saveInternalLinks(), SurveyQuestion\saveToDb(), assQuestion\saveToDb(), SurveyQuestion\syncWithOriginal(), and assQuestion\syncWithOriginal().

{
global $ilias, $ilDB;
$q = "DELETE FROM int_link WHERE source_type=".$ilDB->quote($a_source_type).
" AND source_id=".$ilDB->quote($a_source_id);
$ilias->db->query($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 58 of file class.ilInternalLink.php.

Referenced by ilWikiPage\delete().

{
global $ilias, $ilDB;
$st = $ilDB->prepareManip("DELETE FROM int_link WHERE target_type = ? ".
" AND target_id = ? AND target_inst = ? ",
array("text", "integer", "integer"));
$ilDB->execute($st, array($a_target_type, $a_target_id, $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 220 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 "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 256 of file class.ilInternalLink.php.

Referenced by ilPageObject\_handleImportRepositoryLinks(), ilPageObject\resolveIntLinks(), 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::_extractObjIdOfTarget (   $a_target)

extract object id out of target

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

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

Referenced by ilObjMediaObject\_exists(), ilGlossaryTerm\_exists(), _exists(), ilLMObject\_exists(), ilPageObject\_handleImportRepositoryLinks(), ilObjMediaObject\getLinkedMediaObjects(), ilPageObject\moveIntLinks(), and ilLMObject\updateInternalLinks().

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

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

References 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 "MediaObject":
if($id > 0)
{
return "il__mob_".$id;
}
break;
case "RepositoryItem":
$id = ilObject::_getIdForImportId($a_target);
//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 99 of file class.ilInternalLink.php.

References DB_FETCHMODE_ASSOC.

Referenced by ilPageObject\_handleImportRepositoryLinks(), ilWikiPage\getLinksToPage(), ilWikiPage\getOrphanedPages(), ilGlossaryPresentationGUI\listDefinitions(), ilContObjParser\processPagesToParse(), and ilLMObject\updateInternalLinks().

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

+ Here is the caller graph for this function:

ilInternalLink::_getTargetsOfSource (   $a_source_type,
  $a_source_id 
)

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

References DB_FETCHMODE_ASSOC.

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

{
global $ilDB;
$q = "SELECT * FROM int_link WHERE ".
"source_type = ".$ilDB->quote($a_source_type)." AND ".
"source_id = ".$ilDB->quote($a_source_id);
$target_set = $ilDB->query($q);
$targets = array();
while ($target_rec = $target_set->fetchRow(DB_FETCHMODE_ASSOC))
{
$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 274 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 
)

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

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

{
global $ilias, $ilDB;
$q = "REPLACE INTO int_link (source_type, source_id, target_type, target_id, target_inst) VALUES".
" (".$ilDB->quote($a_source_type).
",".$ilDB->quote($a_source_id).
",".$ilDB->quote($a_target_type).
",".$ilDB->quote($a_target_id).
",".$ilDB->quote($a_target_inst).")";
$ilias->db->query($q);
}

+ Here is the caller graph for this function:


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