1<?php 2/* 3 +-----------------------------------------------------------------------------+ 4 | ILIAS open source | 5 +-----------------------------------------------------------------------------+ 6 | Copyright (c) 1998-2008 ILIAS open source, University of Cologne | 7 | | 8 | This program is free software; you can redistribute it and/or | 9 | modify it under the terms of the GNU General Public License | 10 | as published by the Free Software Foundation; either version 2 | 11 | of the License, or (at your option) any later version. | 12 | | 13 | This program is distributed in the hope that it will be useful, | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | GNU General Public License for more details. | 17 | | 18 | You should have received a copy of the GNU General Public License | 19 | along with this program; if not, write to the Free Software | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 21 +-----------------------------------------------------------------------------+ 22*/ 23 24include_once("Services/Table/classes/class.ilTable2GUI.php"); 25 26/** 27* TableGUI class for (broken) links in learning module 28* 29* @author Alex Killing <alex.killing@gmx.de> 30* @version $Id$ 31* 32* @ingroup ModulesLearningModule 33*/ 34class ilLinksTableGUI extends ilTable2GUI 35{ 36 public function __construct( 37 $a_parent_obj, 38 $a_parent_cmd, 39 $a_lm_id, 40 $a_lm_type 41 ) { 42 global $DIC; 43 44 $this->ctrl = $DIC->ctrl(); 45 $this->lng = $DIC->language(); 46 $ilCtrl = $DIC->ctrl(); 47 $lng = $DIC->language(); 48 49 parent::__construct($a_parent_obj, $a_parent_cmd); 50 51 $this->addColumn($lng->txt("pg"), "", ""); 52 $this->addColumn($lng->txt("cont_internal_links"), "", ""); 53 $this->setEnableHeader(true); 54 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); 55 $this->setRowTemplate( 56 "tpl.links_table_row.html", 57 "Modules/LearningModule" 58 ); 59 $this->lm_id = $a_lm_id; 60 $this->lm_type = $a_lm_type; 61 $this->getLinks(); 62 63 $this->setTitle($lng->txt("cont_internal_links")); 64 } 65 66 /** 67 * Get pages incl. links 68 */ 69 public function getLinks() 70 { 71 $pages = ilLMPageObject::getPagesWithLinksList($this->lm_id, $this->lm_type); 72 $this->setData($pages); 73 } 74 75 /** 76 * Standard Version of Fill Row. Most likely to 77 * be overwritten by derived class. 78 */ 79 protected function fillRow($a_set) 80 { 81 $lng = $this->lng; 82 $ilCtrl = $this->ctrl; 83 84 $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]); 85 $ilCtrl->setParameterByClass( 86 "illmpageobjectgui", 87 "obj_id", 88 $a_set["obj_id"] 89 ); 90 $this->tpl->setVariable( 91 "HREF_PAGE", 92 $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "edit") 93 ); 94 95 include_once("./Modules/LearningModule/classes/class.ilLMPage.php"); 96 $page_object = new ilLMPage($a_set["obj_id"]); 97 $page_object->buildDom(); 98 $int_links = $page_object->getInternalLinks(); 99 100 foreach ($int_links as $link) { 101 $target = $link["Target"]; 102 if (substr($target, 0, 4) == "il__") { 103 $target_arr = explode("_", $target); 104 $target_id = $target_arr[count($target_arr) - 1]; 105 $type = $link["Type"]; 106 107 switch ($type) { 108 case "PageObject": 109 $this->tpl->setCurrentBlock("link"); 110 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg")); 111 if (ilLMObject::_exists($target_id)) { 112 $lm_id = ilLMObject::_lookupContObjID($target_id); 113 $add_str = ($lm_id != $this->lm_id) 114 ? " (" . ilObject::_lookupTitle($lm_id) . ")" 115 : ""; 116 $this->tpl->setVariable( 117 "TXT_LINK_TITLE", 118 ilLMObject::_lookupTitle($target_id) . $add_str 119 ); 120 } else { 121 $this->tpl->setVariable( 122 "TXT_MISSING", 123 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>" 124 ); 125 } 126 $this->tpl->parseCurrentBlock(); 127 break; 128 129 case "StructureObject": 130 $this->tpl->setCurrentBlock("link"); 131 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st")); 132 if (ilLMObject::_exists($target_id)) { 133 $lm_id = ilLMObject::_lookupContObjID($target_id); 134 $add_str = ($lm_id != $this->lm_id) 135 ? " (" . ilObject::_lookupTitle($lm_id) . ")" 136 : ""; 137 $this->tpl->setVariable( 138 "TXT_LINK_TITLE", 139 ilLMObject::_lookupTitle($target_id) . $add_str 140 ); 141 } else { 142 $this->tpl->setVariable( 143 "TXT_MISSING", 144 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>" 145 ); 146 } 147 $this->tpl->parseCurrentBlock(); 148 break; 149 150 case "GlossaryItem": 151 $this->tpl->setCurrentBlock("link"); 152 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term")); 153 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php"); 154 if (ilGlossaryTerm::_exists($target_id)) { 155 $this->tpl->setVariable( 156 "TXT_LINK_TITLE", 157 ilGlossaryTerm::_lookGlossaryTerm($target_id) 158 ); 159 } else { 160 $this->tpl->setVariable( 161 "TXT_MISSING", 162 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>" 163 ); 164 } 165 $this->tpl->parseCurrentBlock(); 166 break; 167 168 case "MediaObject": 169 $this->tpl->setCurrentBlock("link"); 170 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob")); 171 if (ilObject::_exists($target_id)) { 172 $this->tpl->setVariable( 173 "TXT_LINK_TITLE", 174 ilObject::_lookupTitle($target_id) 175 ); 176 } else { 177 $this->tpl->setVariable( 178 "TXT_MISSING", 179 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>" 180 ); 181 } 182 $this->tpl->parseCurrentBlock(); 183 break; 184 185 case "RepositoryItem": 186 $this->tpl->setCurrentBlock("link"); 187 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item")); 188 $obj_type = ilObject::_lookupType($target_id, true); 189 $obj_id = ilObject::_lookupObjId($target_id); 190 if (ilObject::_exists($obj_id)) { 191 $this->tpl->setVariable( 192 "TXT_LINK_TITLE", 193 ilObject::_lookupTitle($obj_id) . " (" . 194 $lng->txt(("obj_" . $obj_type)) 195 . ")" 196 ); 197 } else { 198 $this->tpl->setVariable( 199 "TXT_MISSING", 200 "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>" 201 ); 202 } 203 $this->tpl->parseCurrentBlock(); 204 break; 205 206 } 207 } else { 208 $type = $link["Type"]; 209 210 switch ($type) { 211 case "PageObject": 212 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg")); 213 break; 214 case "StructureObject": 215 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st")); 216 break; 217 case "GlossaryItem": 218 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term")); 219 break; 220 case "MediaObject": 221 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob")); 222 break; 223 case "RepositoryItem": 224 $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item")); 225 break; 226 } 227 228 $this->tpl->setCurrentBlock("link"); 229 $this->tpl->setVariable( 230 "TXT_MISSING", 231 "<b>" . $lng->txt("cont_target_missing") . " [" . $target . "]" . "</b>" 232 ); 233 $this->tpl->parseCurrentBlock(); 234 } 235 } 236 } 237} 238