ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilSCORMOfflineModeGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
15{
16 public $refId;
17 public $lmId;
26 public $vers = "v1";
27
28 public function __construct($type)
29 {
30 global $ilias, $tpl, $lng, $ilCtrl;
31 include_once "./Modules/ScormAicc/classes/class.ilSCORMOfflineMode.php";
32 $this->ilias = $ilias;
33 $this->tpl = $tpl;
34 $lng->loadLanguageModule("sop");
35 $this->lng = $lng;
36 $this->ctrl = $ilCtrl;
37 $this->ctrl->saveParameter($this, "ref_id");
38 $this->offlineMode = new ilSCORMOfflineMode();
39 $this->offline_mode = $this->offlineMode->getOfflineMode();
40 }
41
42 public function executeCommand()
43 {
44 global $log, $tpl, $ilCtrl, $lng;
45 $this->refId = $_GET["ref_id"];
46 $this->lmId = ilObject::_lookupObjectId($this->refId);
47 $this->clientIdSop = $this->offlineMode->getClientIdSop();
48 $cmd = $ilCtrl->getCmd();
49 $this->sop_frm_url = $this->offlineMode->cmd_url . 'offlineMode_sop';
50 $this->sopcache_url = $this->offlineMode->cmd_url . 'offlineMode_sopcache';
51 $this->lm_frm_url = $this->offlineMode->lm_cmd_url . 'offlineMode_il2sop';
52 $this->lmcache_url = $this->offlineMode->lm_cmd_url . 'offlineMode_lmcache';
53 $this->tracking_url = $this->offlineMode->lm_cmd_url . 'offlineMode_tracking2sop';
54
55 switch ($cmd) {
56 case 'offlineMode_sop':
57 $log->write("offlineMode_sop");
58 $sop_cache = new ilTemplate('tpl.cache.html', true, true, 'Modules/ScormAicc');
59 //$sop_cache->setVariable("APPCACHE_URL",$ilCtrl->getLinkTarget($this,"offlineMode_sopcache")."&client_id=" . CLIENT_ID);
60 $sop_cache->setVariable("APPCACHE_URL", $this->sopcache_url);
61 $sop_cache->setVariable("CACHE_TITLE", "SOP Cache Page");
62 $this->sendHtml($sop_cache->get());
63 break;
64
65 case 'offlineMode_sopcache':
66 $log->write("offlineMode_manifest");
67 $sop_manifest = new ilTemplate('tpl.sop.appcache', true, true, 'Modules/ScormAicc');
68 $entries = $this->offlineMode->getSopManifestEntries();
69 $sop_manifest->setVariable("CACHE_ENTRIES", $entries);
70 $sop_manifest->setVariable("VERSION", $vers);
71 $this->sendManifest($sop_manifest->get());
72 break;
73
74 case 'offlineMode_il2sop':
75 $log->write("offlineMode_il2sop");
76 $lm_cache = new ilTemplate('tpl.cache.html', true, true, 'Modules/ScormAicc');
77 //$lm_cache->setVariable("APPCACHE_URL",$ilCtrl->getLinkTarget($this,"offlineMode_lmcache")."&client_id=" . CLIENT_ID);
78 $lm_cache->setVariable("APPCACHE_URL", $this->lmcache_url);
79 $lm_cache->setVariable("CACHE_TITLE", "LM Cache Page");
80 $this->sendHtml($lm_cache->get());
81 break;
82
83 case 'offlineMode_lmcache':
84 $log->write("offlineMode_lmcache");
85 $lm_manifest = new ilTemplate('tpl.lm.appcache', true, true, 'Modules/ScormAicc');
86 $entries = "";
87 if ($_COOKIE['purgeCache'] == 1) {
88 $log->write("purgeCache:" . $_COOKIE['purgeCache']);
89 } else {
90 $entries = $this->offlineMode->getLmManifestEntries();
91 }
92 $lm_manifest->setVariable("CACHE_ENTRIES", $entries);
93 $lm_manifest->setVariable("VERSION", $vers);
94 $this->sendManifest($lm_manifest->get());
95 break;
96
97 case 'offlineMode_tracking2sop':
98 $this->offlineMode->tracking2sop();
99 break;
100
101 case 'offlineMode_il2sopOk':
102 $this->offlineMode->setOfflineMode("offline");
103 $this->view($this->offlineMode->getOfflineMode(), $cmd);
104 break;
105
106 case 'offlineMode_sop2ilpush':
107 $this->offlineMode->sop2il();
108 break;
109
110 case 'offlineMode_sop2ilOk':
111 $this->offlineMode->setOfflineMode("online");
112 ilUtil::sendSuccess($this->lng->txt('sop_msg_push_tracking_ok'), true);
113 ilUtil::redirect($this->offlineMode->lm_info_url);
114 //$this->view($this->offlineMode->getOfflineMode(),$cmd);
115 break;
116
117 case 'offlineMode_player12':
118 $log->write("offlineMode_player12");
119 $player12 = new ilTemplate('tpl.player12.html', false, false, 'Modules/ScormAicc');
120 $player12->setVariable("SOP_TITLE", "ILIAS SCORM 1.2 Offline Player"); // ToDo: Language Support
121 $js_data = file_get_contents("./Modules/ScormAicc/scripts/basisAPI.js");
122 $js_data .= file_get_contents("./Modules/ScormAicc/scripts/SCORM1_2standard.js");
123 $player12->setVariable("SOP_SCRIPT", $js_data);
124 $this->sendHtml($player12->get());
125 break;
126
127 case 'offlineMode_player2004':
128 $log->write("offlineMode_player2004");
129
130 // language strings
131 $langstrings['btnStart'] = $lng->txt('scplayer_start');
132 $langstrings['btnExit'] = $lng->txt('scplayer_exit');
133 $langstrings['btnExitAll'] = $lng->txt('scplayer_exitall');
134 $langstrings['btnSuspendAll'] = $lng->txt('scplayer_suspendall');
135 $langstrings['btnPrevious'] = $lng->txt('scplayer_previous');
136 $langstrings['btnContinue'] = $lng->txt('scplayer_continue');
137 $langstrings['btnhidetree']=$lng->txt('scplayer_hidetree');
138 $langstrings['btnshowtree']=$lng->txt('scplayer_showtree');
139 $langstrings['linkexpandTree']=$lng->txt('scplayer_expandtree');
140 $langstrings['linkcollapseTree']=$lng->txt('scplayer_collapsetree');
141 $langstrings['contCreditOff']=$lng->txt('cont_credit_off');
142 // if ($this->slm->getAutoReviewChar() == "s") {
143 // $langstrings['contCreditOff']=$lng->txt('cont_sc_score_was_higher_message');
144 // }
145 // $config['langstrings'] = $langstrings;
146
147 //template variables
148 $player2004 = new ilTemplate('tpl.player2004.html', true, true, 'Modules/ScormAicc');
149
150 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
151 $player2004->setVariable("JS_FILE", iljQueryUtil::getLocaljQueryPath());
152
153 $player2004->setVariable('JSON_LANGSTRINGS', json_encode($langstrings));
154 $player2004->setVariable('TREE_JS', "./Modules/Scorm2004/scripts/ilNestedList.js");
155 $player2004->setVariable($langstrings);
156 $player2004->setVariable("DOC_TITLE", "ILIAS SCORM 2004 Offline Player");
157 $player2004->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
158
159 $player2004->setVariable('TIMESTAMP', sprintf('%d%03d', $tsint, 1000*(float) $tsfrac));
160 $player2004->setVariable('BASE_DIR', './Modules/Scorm2004/');
161
162 include_once "./Modules/Scorm2004/classes/ilSCORM13Player.php";
163 $player2004->setVariable('INLINE_CSS', ilSCORM13Player::getInlineCss());
164
165 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
166 $this->tpl->setVariable("JS_FILE", iljQueryUtil::getLocaljQueryPath());
167
168 $player2004->setVariable('JS_SCRIPTS', './Modules/Scorm2004/scripts/buildrte/rte.js');
169
170 //disable top menu
171 // if ($this->slm->getNoMenu()=="y") {
172 // $this->tpl->setVariable("VAL_DISPLAY", "style=\"display:none;\"");
173 // } else {
174 // $this->tpl->setVariable("VAL_DISPLAY", "");
175 // }
176
177 $this->sendHtml($player2004->get());
178 break;
179
180 case 'offlineMode_som':
181 $log->write("offlineMode_som");
182 $som = new ilTemplate('tpl.som.html', true, true, 'Modules/ScormAicc');
183 $som->setVariable("SOM_TITLE", "ILIAS SCORM Offline Manager"); // ToDo: Language Support
184 $som->setVariable("PLAYER12_URL", $this->offlineMode->player12_url);
185 $som->setVariable("PLAYER2004_URL", $this->offlineMode->player2004_url);
186 $this->sendHtml($som->get());
187 break;
188
189 default:
190 $this->view($this->offlineMode->getOfflineMode(), $cmd);
191 break;
192 }
193 }
194
195 public function view($offline_mode, $cmd)
196 {
197 global $tpl, $ilCtrl;
199 $tpl->addJavascript('./Modules/ScormAicc/scripts/ilsop.js');
200 $tpl->addJavascript('./libs/bower/bower_components/pouchdb/dist/pouchdb.min.js');
201 $tpl->addCss('./Modules/ScormAicc/templates/sop/sop.css', "screen");
202 $tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.scorm_offline_mode.html", "Modules/ScormAicc");
203 $tpl->setCurrentBlock('offline_content');
204 $tpl->setVariable("Command", $cmd);
205 $tpl->setVariable("CHECK_SYSTEM_REQUIREMENTS", $this->lng->txt('sop_check_system_requirements'));
206 $tpl->setVariable("SOP_SYSTEM_CHECK_HTTPS", $this->lng->txt('sop_system_check_https'));
207 $tpl->setVariable("SOP_SYSTEM_CHECK_ERROR", $this->lng->txt('sop_system_check_error'));
208 $tpl->setVariable("LM_NOT_EXISTS", $this->lng->txt('sop_lm_not_exists'));
209 $tpl->setVariable("EXPORT", $this->lng->txt('sop_export'));
210 $tpl->setVariable("DESC_EXPORT", $this->lng->txt('sop_desc_export'));
211 $tpl->setVariable("TEXT_START_OFFLINE", $this->lng->txt('sop_text_start_offline'));
212 $tpl->setVariable("START_SOP", $this->lng->txt('sop_start_sop')); // ToDo: lng files
213 $tpl->setVariable("TEXT_START_SOM", $this->lng->txt('sop_text_start_som'));
214 $tpl->setVariable("START_SOM", $this->lng->txt('sop_start_som'));
215 $tpl->setVariable("TEXT_PUSH_TRACKING", $this->lng->txt('sop_text_push_tracking'));
216 $tpl->setVariable("PUSH_TRACKING", $this->lng->txt('sop_push_tracking'));
217 $tpl->setVariable("CLIENT_ID", CLIENT_ID);
218 $tpl->setVariable("CLIENT_ID_SOP", $this->clientIdSop);
219 $tpl->setVariable("REF_ID", $_GET['ref_id']);
220 $tpl->setVariable("LM_ID", $this->lmId);
221 $tpl->setVariable("OFFLINE_MODE", $offline_mode);
222 $tpl->setVariable("PURGE_CACHE", $this->lng->txt('sop_purge_cache')); // ToDo
223 $tpl->setVariable("CMD_URL", $this->cmd_url);
224 $tpl->setVariable("LM_CMD_URL", $this->offlineMode->lm_cmd_url);
225 $tpl->setVariable("SOP_FRM_URL", $this->sop_frm_url);
226 $tpl->setVariable("LM_FRM_URL", $this->lm_frm_url);
227 $tpl->setVariable("PLAYER12_URL", $this->offlineMode->player12_url);
228 $tpl->setVariable("PLAYER2004_URL", $this->offlineMode->player2004_url);
229 $tpl->setVariable("SOM_URL", $this->offlineMode->som_url);
230 $tpl->setVariable("TRACKING_URL", $this->tracking_url);
231 $tpl->parseCurrentBlock();
232 $tpl->show();
233 }
234
236 {
237 global $ilTabs, $ilLocator,$tpl,$log;
238 $icon = ($offline_mode == "online") ? "icon_sahs.svg" : "icon_sahs_offline.svg";
239 $tabTitle = $this->lng->txt("offline_mode");
240 $thisurl =$this->ctrl->getLinkTarget($this, $a_active);
241 $ilTabs->addTab($a_active, $tabTitle, $thisurl);
242 $ilTabs->activateTab($a_active);
243 $tpl->getStandardTemplate();
244 $tpl->setTitle(ilObject::_lookupTitle($this->lmId));
245 $tpl->setTitleIcon(ilUtil::getImagePath($icon));
246 $ilLocator->addRepositoryItems();
247 $ilLocator->addItem(ilObject::_lookupTitle($this->lmId), $thisurl);
248 $tpl->setLocator();
249 }
250
251 public function sendHtml($html_str)
252 {
253 header('Content-Type: text/html');
254 header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
255 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Datum in der Vergangenheit
256 print $html_str;
257 }
258
259 public function sendManifest($manifest_str)
260 {
261 header('Content-Type: text/cache-manifest');
262 header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
263 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Datum in der Vergangenheit
264 print $manifest_str;
265 }
266}
sprintf('%.4f', $callTime)
$tpl
Definition: ilias.php:10
$_COOKIE['client_id']
Definition: server.php:9
if(! $in) print
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
GUI class ilSCORMOfflineModeGUI.
Class ilSCORMOfflineMode.
special template class to simplify handling of ITX/PEAR
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static redirect($a_script)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static getLocaljQueryPath()
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $lng
Definition: privfeed.php:17
$type