Public Member Functions

ilInternalLink Class Reference
[Services/COPage]

Class ilInternalLink. More...

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
 _extractTypeOfTarget ($a_target)
 extract type out of target

Detailed Description

Class ilInternalLink.

Some methods to handle internal links

Author:
Alex Killing <alex.killing@gmx.de>
Version:
Id:
class.ilInternalLink.php 17107 2008-08-04 17:26:48Z 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_type source type
int $a_source_if source id

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

References $ilias.

Referenced by assQuestion::_resolveIntLinks(), SurveyQuestion::_resolveIntLinks(), SurveyQuestion::delete(), assQuestion::deleteSuggestedSolutions(), ilPageObject::saveInternalLinks(), assQuestion::saveToDb(), SurveyQuestion::saveToDb(), assQuestion::syncWithOriginal(), and SurveyQuestion::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::_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 203 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, "_")))
                                {
                                        $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 239 of file class.ilInternalLink.php.

Referenced by ilPageObject::_handleImportRepositoryLinks(), and 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 275 of file class.ilInternalLink.php.

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

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

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

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

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

References ilObject::_getAllReferences().

Referenced by assQuestion::_resolveInternalLink(), SurveyQuestion::_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;
                                
                        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)
                                {
                                        $refs = ilObject::_getAllReferences($id);
//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_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 82 of file class.ilInternalLink.php.

References $ilias.

Referenced by ilPageObject::_handleImportRepositoryLinks(), 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_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 109 of file class.ilInternalLink.php.

Referenced by ilObjContentObject::exportHTMLPages(), ilPageObjectGUI::showPage(), ilLMPresentationGUI::showPrintView(), and ilLMObject::updateInternalLinks().

        {
                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 257 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 60 of file class.ilInternalLink.php.

References $ilias.

Referenced by assQuestion::_resolveIntLinks(), SurveyQuestion::_resolveIntLinks(), ilPageObject::saveInternalLinks(), assQuestion::saveToDb(), SurveyQuestion::saveToDb(), assQuestion::syncWithOriginal(), and SurveyQuestion::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: