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