Public Member Functions

ilInternalLink Class Reference

Public Member Functions

 _deleteAllLinksOfSource ($a_source_type, $a_source_id)
 delete all links of a given source
 _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

Detailed Description

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_type source type
int $a_source_if source id

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

References $ilias, and $q.

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

        {
                global $ilias;

                $q = "DELETE FROM int_link WHERE source_type='$a_source_type' AND source_id='$a_source_id'";
                $ilias->db->query($q);
        }

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_type target type ("PageObject" | "StructureObject" | "GlossaryItem" | "MediaObject")
string $a_target target id, e.g. "il__pg_244")
Returns:
boolean true/false

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

References $ref_id, $tree, 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, "_")))
                                {
                                        $ref_id = ilInternalLink::_extractObjIdOfTarget($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_target import target id (e.g. "il_2_pg_22")

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

Referenced by ilPageObject::resolveIntLinks().

        {
                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_target import target id (e.g. "il_2_pg_22")

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

Referenced by _exists(), ilLMObject::_exists(), ilGlossaryTerm::_exists(), ilObjMediaObject::_exists(), and ilObjContentObject::exportXMLMediaObjects().

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

Here is the caller graph for this function:

ilInternalLink::_getIdForImportId ( a_type,
a_target 
)

get current id for an import id

Parameters:
string $a_type target type ("PageObject" | "StructureObject" | "GlossaryItem" | "MediaObject")
string $a_target import target id (e.g. "il_2_pg_22")
Returns:
string current target id (e.g. "il__pg_244")

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

References $id.

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

        {
                switch($a_type)
                {
                        case "PageObject":
                                $id = ilLMObject::_getIdForImportId($a_target);
                                if($id > 0)
                                {
                                        return "il__pg_".$id;
                                }
                                break;

                        case "StructureObject":
                                $id = ilLMObject::_getIdForImportId($a_target);
                                if($id > 0)
                                {
                                        return "il__st_".$id;
                                }
                                break;

                        case "GlossaryItem":
                                $id = ilGlossaryTerm::_getIdForImportId($a_target);
                                if($id > 0)
                                {
                                        return "il__git_".$id;
                                }
                                break;

                        case "MediaObject":
                                $id = ilObjMediaObject::_getIdForImportId($a_target);
                                if($id > 0)
                                {
                                        return "il__mob_".$id;
                                }
                                break;
                }
                return false;
        }

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_type target type
int $a_target_id target id
int $a_target_inst target installation id
Returns:
array sources (array of array("type", "id"))

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

References $ilias, and $q.

Referenced by ilGlossaryPresentationGUI::listDefinitions(), and ilContObjParser::processPagesToParse().

        {
                global $ilias;

                $q = "SELECT * FROM int_link WHERE ".
                        "target_type = '$a_target_type' AND ".
                        "target_id = '$a_target_id' AND ".
                        "target_inst = '$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_type source type (e.g. "lm:pg" | "dbk:pg")
int $a_source_id source id
Returns:
array targets (array of array("type", "id", "inst"))

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

References $q.

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_target import target id (e.g. "il_2_pg_22")

Definition at line 235 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_type source type
int $a_source_if source id
string $a_target_type target type
int $a_target_id target id
int $a_target_inst target installation id

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

References $ilias, and $q.

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

        {
                global $ilias;

                $q = "REPLACE INTO int_link (source_type, source_id, target_type, target_id, target_inst) VALUES".
                        " ('$a_source_type', '$a_source_id', '$a_target_type', '$a_target_id', '$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: