ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilHACPExplorer.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  +-----------------------------------------------------------------------------+
5  | ILIAS open source |
6  +-----------------------------------------------------------------------------+
7  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
8  | |
9  | This program is free software; you can redistribute it and/or |
10  | modify it under the terms of the GNU General Public License |
11  | as published by the Free Software Foundation; either version 2 |
12  | of the License, or (at your option) any later version. |
13  | |
14  | This program is distributed in the hope that it will be useful, |
15  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17  | GNU General Public License for more details. |
18  | |
19  | You should have received a copy of the GNU General Public License |
20  | along with this program; if not, write to the Free Software |
21  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22  +-----------------------------------------------------------------------------+
23 */
24 
25 require_once("classes/class.ilExplorer.php");
26 require_once("./Modules/ScormAicc/classes/AICC/class.ilAICCTree.php");
27 require_once("./Modules/ScormAicc/classes/AICC/class.ilAICCExplorer.php");
28 
33 {
34 
41  function ilHACPExplorer($a_target, &$a_slm_obj)
42  {
43  parent::ilExplorer($a_target);
44  $this->slm_obj =& $a_slm_obj;
45  $this->tree = new ilAICCTree($a_slm_obj->getId());
46  $this->root_id = $this->tree->readRootId();
47  $this->checkPermissions(false);
48  $this->outputIcons(true);
49  $this->setOrderColumn("");
50  }
51 
60  function formatObject($a_node_id,$a_option)
61  {
62  global $lng;
63  //echo "hacp: ".$a_option["title"]." >> ".implode(", ",$a_option["tab"])."<br>";
64 
65  if (!isset($a_node_id) or !is_array($a_option))
66  {
67  $this->ilias->raiseError(get_class($this)."::formatObject(): Missing parameter or wrong datatype! ".
68  "node_id: ".$a_node_id." options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
69  }
70 
71  $tpl = new ilTemplate("tpl.sahs_tree.html", true, true, "Modules/ScormAicc");
72 
73  if ($a_option["c_type"]=="sos")
74  return;
75 
76  if ($a_option["c_type"]=="srs")
77  return;
78 
79  if (is_array($a_option["tab"])) { //test if there are any tabs
80  foreach ($a_option["tab"] as $picture)
81  {
82  if ($picture == 'plus')
83  {
84  $target = $this->createTarget('+',$a_node_id);
85  $tpl->setCurrentBlock("expander");
86  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
87  $tpl->setVariable("IMGPATH", ilUtil::getImagePath("browser/plus.gif"));
88  $tpl->parseCurrentBlock();
89  }
90 
91  if ($picture == 'minus' && $this->show_minus)
92  {
93  $target = $this->createTarget('-',$a_node_id);
94  $tpl->setCurrentBlock("expander");
95  $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
96  $tpl->setVariable("IMGPATH", ilUtil::getImagePath("browser/minus.gif"));
97  $tpl->parseCurrentBlock();
98  }
99 
100  if ($picture == 'blank' or $picture == 'winkel'
101  or $picture == 'hoch' or $picture == 'quer' or $picture == 'ecke'
102  or ($picture == 'minus' && !$this->show_minus))
103  {
104  $picture = 'blank';
105  $tpl->setCurrentBlock("lines");
106  $tpl->setVariable("IMGPATH_LINES", ilUtil::getImagePath("browser/".$picture.".gif"));
107  $tpl->parseCurrentBlock();
108  }
109  }
110  }
111 
112  if ($this->output_icons) {
113  if ($this->isClickable($a_option["c_type"], $a_node_id) && $a_option["c_type"]!="sbl")
114  $this->getOutputIcons($tpl, $a_option, $a_node_id);
115  }
116 
117 
118  if ($this->isClickable($a_option["c_type"], $a_node_id)) // output link
119  {
120  $tpl->setCurrentBlock("link");
121  //$target = (strpos($this->target, "?") === false) ?
122  // $this->target."?" : $this->target."&";
123  //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
124  //$tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"], $this->textwidth, true));
125  $frame_target = $this->buildFrameTarget($a_option["c_type"], $a_node_id, $a_option["obj_id"]);
126  if ($frame_target != "")
127  {
128 // if ($this->api == 1)
129 // {
130 // $tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"], $this->textwidth, true));
131 // $tpl->setVariable("TARGET", " target=\"".$frame_target."\"");
132 // //$tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["c_type"]));
133 // $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["c_type"]));
134 // }
135 // else
136 // {
137  if ($a_option["c_type"]=="sbl") {
138  $tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"]." ($a_node_id)", $this->textwidth, true));
139  $tpl->setVariable("TARGET", " target=\"".$frame_target."\"");
140  $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["c_type"]));
141 
142  } else {
143  include_once("./Modules/ScormAicc/classes/AICC/class.ilAICCUnit.php");
144  $unit =& new ilAICCUnit($a_node_id);
145 
146  //guess the url to be able to launch most contents
147  $url=$unit->getCommand_line();
148  if (strlen($url)==0)
149  $url=$unit->getFilename();
150 
151 
152  //relative path?
153  if (substr($url,0,7)!="http://")
154  $url=$this->slm_obj->getDataDirectory("output")."/".$url;
155 
156  if (strlen($unit->getWebLaunch())>0)
157  $url.="?".$unit->getWebLaunch();
158 
159  $hacpURL=ILIAS_HTTP_PATH."/Modules/ScormAicc/sahs_server.php";
160 
161  //$url.="?aicc_url=$hacpURL&aicc_sid=".$this->slm_obj->ref_id;
162  //$aicc_sid=$this->slm_obj->ref_id."%20".session_id();
163  $aicc_sid=implode("_", array(session_id(), CLIENT_ID, $this->slm_obj->ref_id, $a_node_id));
164  if (strlen($unit->getWebLaunch())>0)
165  $url.="&";
166  else
167  $url.="?";
168  $url.="aicc_url=$hacpURL&aicc_sid=$aicc_sid";
169 
170 /*
171  foreach ($this->slm_obj as $key=>$value)
172  $output.="key=$key value=$value<br>";
173  $tpl->setVariable("TITLE", $output);
174 */
175  $tpl->setVariable("TITLE", ilUtil::shortenText($a_option["title"]." ($a_node_id)", $this->textwidth, true));
176  $tpl->setVariable("LINK_TARGET", "javascript:void(0);");
177  $tpl->setVariable("ONCLICK", " onclick=\"parent.$frame_target.location.href='$url'\"");
178 
179 
180 // }
181  }
182 
183  }
184  $tpl->parseCurrentBlock();
185  }
186  else // output text only
187  {
188  $tpl->setCurrentBlock("text");
189  $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText($a_option["title"], $this->textwidth, true));
190  $tpl->parseCurrentBlock();
191  }
192  $this->formatItemTable($tpl, $a_node_id, $a_option["c_type"]);
193 
194  $tpl->setCurrentBlock("row");
195  $tpl->parseCurrentBlock();
196 
197  $this->output[] = $tpl->get();
198  }
199 }
200 ?>