00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00036 class ilLocatorGUI
00037 {
00043 var $tpl;
00044
00050 var $lng;
00051
00058 var $locator_data;
00059
00067 var $locator_level;
00068
00075 var $display_frame;
00076
00082 function ilLocatorGUI($a_display_frame = true)
00083 {
00084 global $tpl, $lng, $tree;
00085
00086 $this->tpl =& $tpl;
00087 $this->lng =& $lng;
00088 $this->display_frame = $a_display_frame;
00089
00090 $this->items = array();
00091 }
00092
00099 function addRepositoryItems($a_ref_id = 0)
00100 {
00101 global $tree;
00102
00103 if ($a_ref_id == 0)
00104 {
00105 $a_ref_id = $_GET["ref_id"];
00106 }
00107
00108 $pre = "";
00109 if (defined("ILIAS_MODULE"))
00110 {
00111 $pre = "../";
00112 }
00113
00114 if ($a_ref_id > 0)
00115 {
00116 $path = $tree->getPathFull($a_ref_id);
00117
00118
00119 foreach ($path as $key => $row)
00120 {
00121 if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp", "icrs")))
00122 {
00123 continue;
00124 }
00125 if ($row["title"] == "ILIAS")
00126 {
00127 $row["title"] = $this->lng->txt("repository");
00128 }
00129
00130 $this->addItem($row["title"],
00131 $pre."repository.php?cmd=frameset&ref_id=".$row["child"],
00132 ilFrameTargetInfo::_getFrame("MainContent"));
00133 }
00134 }
00135 }
00136
00143 function addAdministrationItems($a_ref_id = 0)
00144 {
00145 global $tree, $ilCtrl, $objDefinition, $lng;
00146
00147 if ($a_ref_id == 0)
00148 {
00149 $a_ref_id = $_GET["ref_id"];
00150 }
00151
00152 if ($a_ref_id > 0)
00153 {
00154 $path = $tree->getPathFull($a_ref_id);
00155
00156
00157 foreach ($path as $key => $row)
00158 {
00159 if (!in_array($row["type"], array("root", "cat", "crs", "fold", "grp", "icrs")))
00160 {
00161 continue;
00162 }
00163
00164 if ($row["child"] == ROOT_FOLDER_ID)
00165 {
00166 $row["title"] = $lng->txt("repository");
00167 }
00168
00169 $class_name = $objDefinition->getClassName($row["type"]);
00170 $class = strtolower("ilObj".$class_name."GUI");
00171 $ilCtrl->setParameterByClass($class, "ref_id", $row["child"]);
00172 $this->addItem($row["title"],
00173 $ilCtrl->getLinkTargetbyClass($class, "view"));
00174 }
00175 }
00176 }
00177
00185 function addItem($a_title, $a_link, $a_frame = "")
00186 {
00187
00188 $this->entries[] = array("title" => $a_title,
00189 "link" => $a_link, "frame" => $a_frame);
00190 }
00191
00192 function clearItems()
00193 {
00194 $this->entries = array();
00195 }
00196
00200 function getItems()
00201 {
00202 return $this->entries;
00203 }
00204
00208 function navigate($newLocLevel,$newLocName,$newLocLink,$newLocTarget)
00209 {
00210 if ($newLocLevel > -1)
00211 {
00212
00213 if ($this->display_frame) {
00214 $this->locator_data = $_SESSION["locator_data"];
00215 $this->locator_level = $_SESSION["locator_level"];
00216 }
00217
00218 if ($newLocLevel < $this->locator_level)
00219 {
00220
00221 for ($i = $this->locator_level ; $i >= $newLocLevel ; $i --)
00222 {
00223 $this->locator_data[$i][0] = "";
00224 $this->locator_data[$i][1] = "";
00225 $this->locator_data[$i][2] = "";
00226 }
00227 }
00228
00229 $this->locator_data[$newLocLevel][0] = $newLocName;
00230 $this->locator_data[$newLocLevel][1] = $newLocLink;
00231 $this->locator_data[$newLocLevel][2] = $newLocTarget;
00232
00233
00234 $this->locator_level = $newLocLevel;
00235
00236
00237 if ($this->display_frame) {
00238 $_SESSION["locator_data"] = $this->locator_data;
00239 $_SESSION["locator_level"] = $this->locator_level;
00240 }
00241 }
00242 }
00243
00247 function output()
00248 {
00249
00250 if ($this->display_frame) {
00251 $this->locator_data = $_SESSION["locator_data"];
00252 $this->locator_level = $_SESSION["locator_level"];
00253 }
00254
00255
00256 if ($this->display_frame) {
00257 $this->tpl = new ilTemplate("tpl.locator_frame.html", true, true);
00258 } else {
00259 $this->tpl->addBlockFile("LOCATOR", "locator", "tpl.locator.html");
00260 }
00261
00262
00263 $this->tpl->setVariable("TXT_LOCATOR", $this->lng->txt("locator"));
00264
00265
00266
00267 if ($this->locator_level < 0)
00268 {
00269 $this->tpl->setCurrentBlock("locator_text");
00270 $this->tpl->setVariable("ITEM", " - ERROR Locator array empty! -");
00271
00272 $this->tpl->parseCurrentBlock();
00273 }
00274 else
00275 {
00276 for ($i = 0 ; $i <= $this->locator_level ; $i ++)
00277 {
00278
00279 if ( ($this->locator_data[$i][0] != "") & ($this->locator_data[$i][1] != "") )
00280 {
00281
00282 if ($i == $this->locator_level)
00283 {
00284 if ($this->display_frame) {
00285 $this->tpl->setCurrentBlock("locator_text");
00286 $this->tpl->setVariable("ITEM", $this->locator_data[$i][0]);
00287 $this->tpl->parseCurrentBlock("locator_text");
00288 } else {
00289 $this->tpl->setCurrentBlock("locator_text");
00290 $this->tpl->setVariable("ITEM", $this->locator_data[$i][0]);
00291 $this->tpl->setVariable("LINK_ITEM", $this->locator_data[$i][1]);
00292 $this->tpl->setVariable("LINK_TARGET", $this->locator_data[$i][2]);
00293 $this->tpl->parseCurrentBlock("locator_text");
00294 }
00295 }
00296 else
00297 {
00298 if ($this->display_frame) {
00299 $this->tpl->setCurrentBlock("locator_link");
00300 $this->tpl->setVariable("ITEM", $this->locator_data[$i][0]);
00301 $this->tpl->setVariable("LINK_ITEM", $this->locator_data[$i][1]);
00302 $this->tpl->setVariable("LINK_TARGET", $this->locator_data[$i][2]);
00303 $this->tpl->parseCurrentBlock("locator_link");
00304 } else {
00305 $this->tpl->touchBlock("locator_separator");
00306 $this->tpl->setCurrentBlock("locator_item");
00307 $this->tpl->setVariable("ITEM", $this->locator_data[$i][0]);
00308 $this->tpl->setVariable("LINK_ITEM", $this->locator_data[$i][1]);
00309 $this->tpl->setVariable("LINK_TARGET", $this->locator_data[$i][2]);
00310 $this->tpl->parseCurrentBlock("locator_item");
00311 }
00312 }
00313 }
00314 }
00315 }
00316
00317
00318 if ($this->display_frame) {
00319 $this->tpl->show();
00320 }
00321 }
00322
00323 }
00324 ?>