index.template.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. <?php
  2. function print_home_javascript() {
  3. ?>
  4. <html>
  5. <head>
  6. <script language="JavaScript">
  7. window.home();
  8. </script>
  9. </head>
  10. </html>
  11. <?php
  12. }
  13. function print_html_top($loadfrom = '') {
  14. ?>
  15. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  16. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <title><?php echo s(get_string('rezzer:sloodlesetup', 'sloodle')) ?></title>
  20. <link rel="apple-touch-icon" href="iui/iui-logo-touch-icon.png" />
  21. <style type="text/css" media="screen">@import "<?php echo $loadfrom?>iui/iui_avatarclassroom.css";</style>
  22. <style type="text/css" media="screen">@import "<?php echo $loadfrom?>layout.css";</style>
  23. <script type="application/x-javascript" src="../../../lib/jquery/jquery.js"></script>
  24. <script type="application/x-javascript" src="layout.js"></script>
  25. <!--
  26. -->
  27. <script type="text/javascript">
  28. var rezzer_uuid = '<?php echo htmlentities($_REQUEST['sloodleobjuuid']) ?>';
  29. var heartbeatMilliseconds = <?php echo (SLOODLE_REZZER_STATUS_CONFIRM_INTERVAL*1000/2);?> // We do automatic refreshes to see if anything has changed in-world. This decides how often.
  30. </script>
  31. </head>
  32. <body>
  33. <?php
  34. }
  35. function print_toolbar( $baseurl, $sitesURL ) {
  36. ?>
  37. <div class="toolbar">
  38. <h1 id="pageTitle"></h1>
  39. <a id="backButton" class="button" href="#sitelist"><?php echo ( $sitesURL != '' ) ? s(get_string('rezzer:avatarclassroom', 'sloodle')) : '' ?></a>
  40. <a class="button" onclick="document.location.href = '<?php echo $baseurl.'&logout=1&ts='.time()?>'" href="<?php echo $baseurl.'&logout=1&ts='.time()?>"><?php echo s(get_string('rezzer:logout', 'sloodle')) ?></a>
  41. </div>
  42. <?php
  43. }
  44. // A placeholder div
  45. // Never actually loaded - we intercept "sitelist" and use it to redirect to the api. site.
  46. function print_site_placeholder( $sitesURL ) {
  47. ?>
  48. <div id="sitelist" data-parent-url="<?php echo $sitesURL ?>" title="<?php echo ( $sitesURL != '' ) ? s(get_string('rezzer:avatarclassroom', 'sloodle')) : '' ?>"></div>
  49. <?php
  50. }
  51. function print_site_list( $sites ) {
  52. ?>
  53. <ul id="sitelist" title="<?php echo s(get_string('rezzer:avatarclassroom','sloodle')) ?>" selected="true">
  54. <li class="group"><?php echo s(get_string('rezzer:sites', 'sloodle')) ?></li>
  55. <?php foreach($sites as $site) { ?>
  56. <?php if ('http://'.$_SERVER["SERVER_NAME"] == $site) { ?>
  57. <li><a class="active_site_link" href="#site_1"><?php echo $site?></a></li>
  58. <?php } else { ?>
  59. <li><a href="<?php echo $site?>"><?php echo $site?></a></li>
  60. <?php } ?>
  61. <?php } ?>
  62. <li></li>
  63. <li class="group"><?php echo s(get_string('rezzer:addsite', 'sloodle'))?></li>
  64. <li><a href="#addsite"><?php echo s(get_string('rezzer:addsite', 'sloodle'))?></a></li>
  65. <li ></li>
  66. </ul>
  67. <?php
  68. }
  69. function print_controller_list( $courses, $controllers, $hasSites, $sitesURL, $hasCourses, $hasControllers, $hasControllersWithPermission) {
  70. $hasSites = false;
  71. $full = false;
  72. ?>
  73. <ul id="site_1" data-parent="sitelist" title="<?php echo "http://".$_SERVER["SERVER_NAME"]?>" <?php echo $hasSites ? '' : ' selected="true"' ?> >
  74. <div class="upper_button_zone">
  75. <span class="left_zone">
  76. <span class="title_text"><?php echo s( get_string('rezzer:controllers','sloodle')) ?></span>
  77. </span>
  78. <span class="right_zone">
  79. <span class="control_button reload_page_button" type="submit"><?php echo s(get_string('rezzer:refreshconfig', 'sloodle', "")) ?></span>
  80. </span>
  81. </div>
  82. <?php if (!$hasControllersWithPermission) { ?>
  83. <?php if (!$hasCourses) { ?>
  84. <li><?php echo s(get_string('rezzer:nocourses','sloodle'))?></li>
  85. <?php } else if (!$hasControllers) { ?>
  86. <li><?php echo s(get_string('rezzer:nocontrollers','sloodle'))?></li>
  87. <?php } else if (!$hasControllersWithPermission) { ?>
  88. <li><?php echo s(get_string('rezzer:nocontrollerswithpermission','sloodle'))?></li>
  89. <?php } ?>
  90. <?php } ?>
  91. <?php
  92. foreach($courses as $course) {
  93. $cid = $course->id;
  94. $cn = $course->fullname;
  95. if (isset($controllers[$cid])) {
  96. foreach($controllers[$cid] as $contid=>$cont) {
  97. ?>
  98. <li><a href="#controller_<?php echo intval($cid)?>-<?php echo intval($contid) ?>"><?php echo s( $cn ) ?> <?php echo s( $cont->name ) ?></a></li>
  99. <?php
  100. }
  101. }
  102. }
  103. ?>
  104. <?php if ($full) { ?>
  105. <li></li>
  106. <li class="group"><?php echo s(get_string('rezzer:addcontroller', 'sloodle'))?></li>
  107. <li><a href="#addcontroller"></a></li>
  108. <li></li>
  109. <?php } ?>
  110. </ul>
  111. <?php if ($full) { ?>
  112. <form data-parent="site_1" id="addcontroller" class="panel" title="Add a Course">
  113. <fieldset>
  114. <div class="row" style="height:60px;">
  115. <label for="course_name" name="course_name"><?php echo s(get_string('rezzer:name', 'sloodle'))?></label>
  116. <input id="course_name" name="course_name" class="panel" style="width:80%; height:40px; margin:10px;">
  117. </div>
  118. <div class="row" style="height:60px;">
  119. <label for="course"><?php echo s(get_string('rezzer:course'))?></label>
  120. <select id="course" class="az" name="course" style="height:40px; width:80%; margin:10px;">
  121. <option value="1">Japanese For Beginners</option>
  122. <option value="2">Spanish For Dummies</option>
  123. </select></div>
  124. <a class="active_button" type="submit" href="#">Add Course</a>
  125. </fieldset>
  126. </form>
  127. <?php }
  128. }
  129. function print_layout_list( $courses, $controllers, $courselayouts ) {
  130. foreach($courses as $course) {
  131. $cid = $course->id;
  132. $cn = $course->fullname;
  133. if (!isset($controllers[$cid])) {
  134. continue;
  135. }
  136. foreach($controllers[$cid] as $contid => $cont) {
  137. ?>
  138. <ul data-parent="site_1" id="controller_<?php echo intval($cid)?>-<?php echo intval($contid) ?>" title="<?php echo s( $cn ) ?> <?php echo s( $cont->name ) ?>" class="controllercourselayouts_<?php echo intval($cid)?>" data-id-prefix="layout_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-">
  139. <li class="group">Scenes</li>
  140. <?php
  141. $layouts = $courselayouts[ $cid ][$contid];
  142. foreach($layouts as $layout) {
  143. ?>
  144. <li data-layout-link-li-id="<?php echo intval($layout->id) ?>" ><a class="layout_link" href="#layout_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>"><?php echo s($layout->name) ?></a></li>
  145. <?php
  146. }
  147. ?>
  148. <li class="add_layout_above_me"></li>
  149. <li class="group"><?php echo s(get_string('rezzer:addlayout', 'sloodle'))?></li>
  150. <li><a class="add_layout_link" href="#addlayout_<?php echo intval($cid) ?>-<?php echo intval($contid) ?>"><?php echo s(get_string('rezzer:addlayout', 'sloodle'))?></a></li>
  151. </ul>
  152. <?php
  153. }
  154. }
  155. }
  156. function print_add_layout_forms( $courses, $controllers, $rezzeruuid ) {
  157. if (count($courses) > 0) {
  158. foreach($courses as $course) {
  159. $cid = $course->id;
  160. if ( (isset($controllers[$cid]) ) && (count($controllers[$cid]) > 0) ) {
  161. foreach($controllers[$cid] as $contid => $cont) {
  162. ?>
  163. <form data-parent="controller_<?php echo intval($cid)?>-<?php echo intval($contid) ?>" id="addlayout_<?php echo intval($cid)?>-<?php echo intval($contid) ?>" class="panel" title="<?php echo s(get_string('rezzer:addlayout', 'sloodle'))?> <?php echo s($course->fullname) ?>">
  164. <div class="upper_button_zone">
  165. <span class="left_zone">
  166. <span class="title_text"><?php echo s( get_string('rezzer:createscene','sloodle')) ?></span>
  167. </span>
  168. <span class="right_zone">
  169. <span data-creating-text="<?php echo s(get_string('rezzer:creatingscene', 'sloodle'))?>" data-create-text="<?php echo s(get_string('rezzer:createscenetitle','sloodle'))?>" class="control_button create_layout_button" type="submit" href="#"><?php echo s(get_string('rezzer:createscene','sloodle'))?></span>
  170. </span>
  171. </div>
  172. <input type="hidden" name="courseid" value="<?php echo intval($cid)?>" />
  173. <input type="hidden" name="rezzeruuid" value="<?php echo s($rezzeruuid)?>" />
  174. <input type="hidden" name="controllerid" value="<?php echo intval($contid)?>" />
  175. <fieldset>
  176. <div class="row" >
  177. <label for="layoutname"><?php echo s(get_string('rezzer:layoutname', 'sloodle'))?></label>
  178. <input id="layoutname" name="layoutname" class="panel" style="width:80%; height:40px; margin:10px;">
  179. </div>
  180. </fieldset>
  181. </form>
  182. <?php
  183. }
  184. }
  185. }
  186. }
  187. }
  188. function print_html_bottom() {
  189. ?>
  190. </body>
  191. </html>
  192. <?php
  193. }
  194. ?>
  195. <?php
  196. function print_layout_lists( $courses, $controllers, $courselayouts, $layoutentries, $rezzeruuid) {
  197. foreach($courses as $course) {
  198. $cid = $course->id;
  199. $cn = $course->fullname;
  200. if (!isset($controllers[$cid])) {
  201. continue;
  202. }
  203. foreach($controllers[$cid] as $contid => $cont) {
  204. $layouts = $courselayouts[ $cid ][$contid];
  205. foreach($layouts as $layout) {
  206. if ($layout->controllerid != $contid) {
  207. continue;
  208. }
  209. $hasactiveobjects = $layout->has_active_objects_rezzed_by_rezzer( $rezzeruuid );
  210. $entriesbygroup = $layoutentries[ $layout->id ];
  211. $rezzed_entries = $layout->rezzed_active_objects_by_layout_entry_id( $rezzeruuid );
  212. ?>
  213. <ul data-parent="controller_<?php echo intval($cid)?>-<?php echo intval($contid) ?>" class="layout_container layout_container_<?php echo intval($layout->id) ?>" id="layout_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>" title="<?php echo htmlentities( $layout->name ) ?>" data-rez-mode="<?php echo $hasactiveobjects ? 'rezzed' : 'unrezzed'?>" data-action-status="<?php echo $hasactiveobjects ? 'rezzed' : 'unrezzed'?>" data-connection-status="disconnected">
  214. <li class="group"><?php echo s( $layout->name ) ?></li>
  215. <li class="upper_button_zone">
  216. <span class="left_zone">
  217. <span class="title_text rename_input_text"><?php echo s( $layout->name) ?></span>
  218. <span style="display:none" class="rename_input"><input size="20" maxlength="20" class="rename_layout_input" data-rename-input-layoutid="<?php echo intval($layout->id) ?>" value="<?php echo s( $layout->name ) ?>" /></span>
  219. </span>
  220. <span class="right_zone">
  221. <span class="control_button rename_layout_button" data-layoutid="<?php echo intval($layout->id) ?>" data-renamed-text="<?php echo s(get_string('rezzer:renamelayout', 'sloodle'))?>" data-rename-text="<?php echo s(get_string('rezzer:renamelayout','sloodle'))?>" data-renaming-text="<?php echo s(get_string('rezzer:renaminglayout', 'sloodle'))?>" class="control_button" type="submit" ><?php echo s(get_string('rezzer:renamelayout','sloodle'))?></span>
  222. <span class="control_button delete_layout_button" data-layoutid="<?php echo intval($layout->id) ?>" data-deleted-text="<?php echo s(get_string('rezzer:deletedderezzingobjects', 'sloodle')) ?>" data-delete-text="<?php echo s(get_string('rezzer:deletelayout', 'sloodle'))?>" data-deleting-text="<?php echo s(get_string('rezzer:deletinglayout','sloodle'))?>" type="submit"><?php echo s(get_string('rezzer:deletelayout', 'sloodle'))?></span>
  223. <span class="control_button clone_layout_button" data-layoutid="<?php echo intval($layout->id) ?>" data-cloned-text="<?php echo s(get_string('rezzer:clonelayout','sloodle'))?>" data-cloning-text="<?php echo s(get_string('rezzer:cloninglayout','sloodle'))?>" data-clone-text="<?php echo s(get_string('rezzer:clonelayout','sloodle'))?>" type="submit" ><?php echo s(get_string('rezzer:clonelayout','sloodle'))?></span>
  224. <span class="control_button sync_object_positions" data-freeze-text="<?php echo s(get_string('rezzer:savecurrentposition', 'sloodle'))?>" data-freezing-text="<?php echo s(get_string('rezzer:savingcurrentposition', 'sloodle'))?>" type="submit" href="#clonelayout"><?php echo s(get_string('rezzer:savecurrentposition', 'sloodle'))?></span>
  225. <span id="derez_all_objects_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>" class="control_button derez_all_objects"> &nbsp; <?php echo s(get_string('rezzer:derezallobjects', 'sloodle'))?></span>
  226. <span id="rez_all_objects_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>" class="control_button rez_all_objects double_width"> &nbsp; <?php echo s(get_string('rezzer:rezallobjects', 'sloodle'))?></span>
  227. <span id="generate_standard_layout_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>" data-generate-text="<?php echo s(get_string('rezzer:importmoodleactivities','sloodle', $cn )) ?>" data-generating-text="<?php echo s(get_string('rezzer:importingmoodleactivities', 'sloodle'))?>" data-layoutid="<?php echo intval($layout->id) ?>" class="control_button double_width generate_standard_layout"><?php echo s(get_string('rezzer:importmoodleactivities', 'sloodle', $cn )) ?></span>
  228. </span>
  229. </li>
  230. <li class="fatal_error_zone">
  231. <span class="fatal_error_text">
  232. <?php echo s(get_string('rezzer:couldnotconnect', 'sloodle', $cn )) ?>
  233. </span>
  234. </li>
  235. <li class="delete_confirmation_zone confirmation_zone">
  236. <span class="delete_confirmation_text confirmation_text">
  237. <?php echo s(get_string('rezzer:reallydeletescene', 'sloodle'))?>
  238. </span>
  239. <span class="delete_confirmation_button_cancel confirmation_button_cancel"><?php echo s(get_string('No', 'sloodle')); ?></span>
  240. <span class="delete_confirmation_button_ok confirmation_button_ok"><?php echo s(get_string('rezzer:yesdeletelayout', 'sloodle')); ?></span>
  241. </li>
  242. <li class="clone_confirmation_zone confirmation_zone">
  243. <span class="clone_confirmation_text confirmation_text">
  244. <?php echo s(get_string('rezzer:reallyclonescene', 'sloodle'))?>
  245. </span>
  246. <span class="clone_confirmation_button_cancel confirmation_button_cancel"><?php echo s(get_string('No', 'sloodle')); ?></span>
  247. <span class="clone_confirmation_button_ok confirmation_button_ok"><?php echo s(get_string('rezzer:yesclonescene', 'sloodle')); ?></span>
  248. </li>
  249. <?php
  250. if (count($entriesbygroup) > 0) {
  251. foreach($entriesbygroup as $group => $entries) {
  252. ?>
  253. <li class="group"><?php echo htmlentities( get_string('objectgroup:'.$group, 'sloodle') ) ?></li>
  254. <?php
  255. foreach($entries as $e) {
  256. $isrezzed = isset( $rezzed_entries[ $e->id ]);
  257. //print "rezzedentries";
  258. //var_dump($rezzed_entries);
  259. /*
  260. $firstletter = substr($entryname, 0, 1);
  261. if ($lettergroup != $firstletter) {
  262. $lettergroup = $firstletter;
  263. }
  264. */
  265. print_rezzable_item_li( $e, $cid, $contid, $layout, $isrezzed);
  266. }
  267. ?>
  268. <li class="after_group_<?php echo $group?>"><a class="add_object_link" href="#addobjectgroup_<?php echo $group ?>_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>"><?php echo s(get_string('rezzer:addobjects', 'sloodle'))?></a></li>
  269. <li></li>
  270. <?php
  271. }
  272. }
  273. ?>
  274. </ul>
  275. <?php
  276. }
  277. }
  278. }
  279. ?>
  280. <span id="add_layout_lists_above_me"></span>
  281. <?php
  282. }
  283. function print_rezzable_item_li( $e, $cid, $contid, $layout, $isrezzed) {
  284. $entryname = $e->name;
  285. $entryname = preg_replace('/SLOODLE\s/', '', $entryname);
  286. $modTitle = $e->get_course_module_title();
  287. ?><li data-layoutentryid="<?php echo $e->id?>" id="layoutentryid_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>-<?php echo intval( $e->id ) ?>" class="rezzable_item <?php echo ( $isrezzed ? 'rezzed' : '' ) ?>"><a href="#configure_layoutentryid_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>-<?php echo intval( $e->id ) ?>"><?php echo s($entryname) ?><span class="module_info"><?php echo s($modTitle)?></span></span> <span class="rezzable_item_rez_button">&nbsp;</span><span class="rezzable_item_derez_button">&nbsp;</span> <span class="rezzable_item_status">&nbsp;</span> <span class="rezzable_item_positioning">&nbsp;</span> </a></li>
  288. <?php
  289. }
  290. function print_add_object_item_li( $object_title, $config, $cid, $contid, $layout) {
  291. if (!$config->do_show()) {
  292. return false;
  293. }
  294. $object_title = preg_replace('/^SLOODLE /', '', $object_title);
  295. $id = "linkto_addobject_{$cid}-{$contid}-{$layout->id}_{$config->type_for_link()}";
  296. ?>
  297. <li id="<?php echo $id?>"><a href="#addobject_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>_<?php echo $config->type_for_link()?>"><?php echo s($object_title) ?></a></li>
  298. <?php
  299. return $id;
  300. }
  301. function print_layout_add_object_groups( $courses, $controllers, $courselayouts, $objectconfigsbygroup) {
  302. foreach($courses as $course) {
  303. $cid = $course->id;
  304. $cn = $course->fullname;
  305. if (!isset($controllers[$cid])) {
  306. continue;
  307. }
  308. foreach($controllers[$cid] as $contid => $cont) {
  309. $layouts = $courselayouts[ $cid ][$contid];
  310. foreach($layouts as $layout) {
  311. ?>
  312. <?php
  313. foreach($objectconfigsbygroup as $group => $groupobjectconfigs) {
  314. ?>
  315. <ul <?php echo $group == 'misc' ? 'class="object_group_misc"' : '' ?> data-parent="layout_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>" id="addobjectgroup_<?php echo $group ?>_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>" title="<?php echo s(get_string('rezzer:addobjectsforgroup', 'sloodle', $group) ) ?>">
  316. <li class="group"><?php echo s(get_string('rezzer:addobjectsforgroup', 'sloodle', $group) ) ?></li>
  317. <?php
  318. foreach($groupobjectconfigs as $object_title => $config) {
  319. if (!$config) {
  320. continue;
  321. }
  322. print_add_object_item_li( $object_title, $config, $cid, $contid, $layout );
  323. }
  324. ?>
  325. <li></li>
  326. </ul>
  327. <?php
  328. }
  329. }
  330. }
  331. }
  332. ?>
  333. <span id="add_add_object_groups_above_me"></span>
  334. <?php
  335. }
  336. function print_add_object_forms($courses, $controllers, $courselayouts, $object_configs, $rezzeruuid ) {
  337. foreach($courses as $course) {
  338. $cid = $course->id;
  339. $cn = $course->fullname;
  340. if (!isset($controllers[$cid])) {
  341. continue;
  342. }
  343. foreach($controllers[$cid] as $contid => $cont) {
  344. if (!isset($courselayouts[ $cid ]) ) {
  345. continue;
  346. }
  347. $layouts = $courselayouts[ $cid ][$contid];
  348. foreach($layouts as $layout) {
  349. foreach($object_configs as $object_title => $config) {
  350. /*
  351. The following form is used for adding the object.
  352. But once it's been added, it will be clone()d to make a form to update the object we added.
  353. */
  354. print_add_object_form( $config, $cid, $contid, $layout, $object_title, $rezzeruuid );
  355. ?>
  356. <?php
  357. }
  358. }
  359. }
  360. }
  361. ?>
  362. <span id="add_add_object_forms_above_me"></span>
  363. <?php
  364. }
  365. function print_add_object_form( $config, $cid, $contid, $layout, $object_title, $rezzeruuid ) {
  366. if (!$config->do_show()) {
  367. return false;
  368. }
  369. $id = "addobject_{$cid}-{$contid}-{$layout->id}_{$config->type_for_link()}";
  370. ?>
  371. <form data-parent="addobjectgroup_<?php echo $config->group ?>_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>" class="add_object_form panel addobject_layout_<?php echo intval($layout->id) ?>_<?php echo $config->type_for_link()?>" id="<?php echo $id?>" title="<?php echo s($object_title) ?>" data-primname="<?php echo s($config->primname)?>" data-courseid="<?php echo intval($cid)?>" >
  372. <div class="upper_button_zone">
  373. <span class="left_zone">
  374. <span class="title_text"><?php echo s( $object_title) ?></span>
  375. </span>
  376. <span class="right_zone">
  377. <span data-delete-text="<?php echo s(get_string('rezzer:deleteobject', 'sloodle', $object_title)) ?>" data-deleting-text="<?php echo s(get_string('rezzer:deletingobject', 'sloodle', $object_title)) ?>" class="control_button delete_layout_entry_button hiddenButton" type="submit"><?php echo s(get_string('rezzer:deleteobject', 'sloodle', $object_title)) ?></span>
  378. <span data-refresh-text="<?php echo s(get_string('rezzer:refreshconfig', 'sloodle', $object_title)) ?>" data-refreshing-text="<?php echo s(get_string('rezzer:refreshingconfig', 'sloodle', $object_title)) ?>" class="control_button refresh_config_button" type="submit"><?php echo s(get_string('rezzer:refreshconfig', 'sloodle', $object_title)) ?></span>
  379. <span data-updating-text="<?php echo s(get_string('rezzer:updatingobject', 'sloodle', $object_title )) ?>" data-update-text="<?php echo s(get_string('rezzer:updateobject', 'sloodle', $object_title )) ?>" data-adding-text="<?php echo s( get_string('rezzer:addingobject', 'sloodle', $object_title )) ?>" data-add-text="<?php echo s( get_string('rezzer:addobject', 'sloodle', $object_title )) ?>" class="control_button add_to_layout_button" target="_self" type="submit"><?php echo s( get_string('rezzer:addobject', 'sloodle', $object_title) ) ?></span>
  380. </span>
  381. </div>
  382. <input type="hidden" name="rezzeruuid" value="<?php echo htmlentities($rezzeruuid) ?>" />
  383. <input type="hidden" name="objectname" value="<?php echo htmlentities($object_title) ?>" />
  384. <input type="hidden" name="objectgroup" value="<?php echo htmlentities($config->group) ?>" />
  385. <input type="hidden" name="layoutid" value="<?php echo intval($layout->id) ?>" />
  386. <input type="hidden" name="layoutentryid" value="0" />
  387. <input type="hidden" name="controllerid" value="<?php echo intval($contid) ?>" />
  388. <input type="hidden" name="courseid" value="<?php echo intval($cid) ?>" />
  389. <?php if ($config->module) {
  390. $moduleoptionselect = $config->course_module_select( $cid, $val = null );
  391. ?>
  392. <fieldset>
  393. <div class="row">
  394. <label for="<?php echo 'sloodlemoduleid' ?>"><?php echo $config->module_choice_message ? get_string($config->module_choice_message, 'sloodle') : ''?></label>
  395. <span class="sloodle_config" data-fieldname="sloodlemoduleid">
  396. <?php echo $moduleoptionselect ? $moduleoptionselect : '<span class="no_options_placeholder" data-fieldname="sloodlemoduleid">'.( ( $config->module_no_choices_message != '' ) ? get_string($config->module_no_choices_message , 'sloodle') : '' ) .'</span>' ?>
  397. </span>
  398. </div>
  399. </fieldset>
  400. <?php
  401. } ?>
  402. <?php foreach($config->field_set_row_groups() as $fsrg) { ?>
  403. <fieldset>
  404. <?php foreach($fsrg as $ctrls) { ?>
  405. <?php $ctrls_reversed = array_reverse($ctrls); ?>
  406. <?php $first_ctrl = array_shift($ctrls); ?>
  407. <div class="row" data-row-name="<?php echo isset($first_ctrl->row_name) ? $first_ctrl->row_name : '' ?>" >
  408. <label for="<?php echo isset($first_ctrl->fieldname) ? $first_ctrl->fieldname : '' ?>"><?php echo $first_ctrl->title ? s(get_string($first_ctrl->title,'sloodle')) : ''?></label>
  409. <?php foreach($ctrls_reversed as $ctrl) { ?>
  410. <?php $fieldname = $ctrl->fieldname; ?>
  411. <span class="sloodle_config object_<?php echo s($config->type_for_link())?>" data-courseid="<?php echo intval($cid)?>" data-fieldname="<?php echo $fieldname?>">
  412. <?php if ( ($ctrl->type == 'radio') || ($ctrl->type == 'yesno') ) { ?>
  413. <?php foreach($ctrl->options as $opn => $opv) { ?>
  414. <input type="radio" name="<?php echo $fieldname ?>" value="<?php echo $opn ?>" <?php echo $opn == $ctrl->default ? 'checked ' : '' ?>> <?php echo $ctrl->is_value_translatable ? get_string($opv, 'sloodle') : s($opv) ?> &nbsp; &nbsp;
  415. <?php } ?>
  416. <?php } else if ($ctrl->type == 'select') { ?>
  417. <select name="<?php echo $fieldname ?>">
  418. <?php foreach($ctrl->options as $opn => $opv) { ?>
  419. <option value="<?php echo $opn ?>" <?php echo $opn == $ctrl->default ? 'selected="selected"' : '' ?>> <?php echo $ctrl->is_value_translatable ? get_string($opv, 'sloodle') : s($opv) ?></option>
  420. <?php } ?>
  421. </select>
  422. <?php } else if ($ctrl->type == 'input') { ?>
  423. <input type="text" size="<?php echo $ctrl->size ?>" maxlength="<?php echo $ctrl->max_length ?>" name="<?php echo $fieldname ?>" value="<?php echo $ctrl->default ?>" />
  424. <?php } else { ?>
  425. <?php echo $ctrl->type?>
  426. <?php } ?>
  427. </span>
  428. <?php } ?>
  429. </div>
  430. <?php } ?>
  431. </fieldset>
  432. <?php } ?>
  433. </form>
  434. <br />
  435. <?php
  436. return $id;
  437. }
  438. /*
  439. Configuration form for each
  440. */
  441. function print_edit_object_forms($courses, $controllers, $courselayouts, $object_configs, $layoutentries, $rezzeruuid) {
  442. if (count($courses) > 0) {
  443. foreach($courses as $course) {
  444. $cid = $course->id;
  445. $cn = $course->fullname;
  446. if ( ( isset($controllers[$cid]) ) && (count($controllers[$cid]) > 0) ) {
  447. foreach($controllers[$cid] as $contid => $cont) {
  448. $layouts = $courselayouts[ $cid ][$contid];
  449. if (count($layouts) > 0) {
  450. foreach($layouts as $layout) {
  451. $entriesbygroup = $layoutentries[ $layout->id ];
  452. $lid = $layout->id;
  453. if (count($entriesbygroup) > 0) {
  454. foreach($entriesbygroup as $group => $entries) {
  455. if (count($entries) > 0) {
  456. foreach($entries as $e) {
  457. $entryname = $e->name;
  458. if (!isset($object_configs[$entryname])) {
  459. //print "error: no config for entry :$entryname:";
  460. //var_dump($object_configs);
  461. //print ":";
  462. //var_dump(array_keys($object_configs));
  463. //exit;
  464. continue; // No config - skip it.
  465. }
  466. $config = $object_configs[$entryname]; // TODO: Merge in the layout entries
  467. print_config_form( $e, $config, $cid, $contid, $lid, $group, $rezzeruuid );
  468. }
  469. }
  470. }
  471. }
  472. ?>
  473. <span id="add_configuration_above_me_layout_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($layout->id) ?>"></span>
  474. <?php
  475. }
  476. }
  477. }
  478. }
  479. }
  480. }
  481. ?>
  482. <span id="add_edit_object_forms_above_me"></span>
  483. <?php
  484. }
  485. function print_config_form( $e, $config, $cid, $contid, $lid, $group, $rezzeruuid ) {
  486. $lconfig = $e->get_layout_entry_configs_as_name_value_hash();
  487. $entryname = preg_replace('/SLOODLE\s/', '', $e->name);
  488. $object_title = $entryname;
  489. $id = "configure_layoutentryid_{$cid}-{$contid}-{$lid}-{$e->id}";
  490. ?>
  491. <form data-parent="layout_<?php echo intval($cid)?>-<?php echo intval($contid) ?>-<?php echo intval($lid) ?>" id="<?php echo $id?>" class="panel edit_object_form" title="<?php echo s($object_title) ?>" data-primname="<?php echo s($config->primname)?>" data-courseid="<?php echo intval($cid)?>">
  492. <div class="upper_button_zone">
  493. <span class="left_zone">
  494. <span class="title_text"><?php echo s( $object_title) ?></span>
  495. </span>
  496. <span class="right_zone">
  497. <span data-delete-text="<?php echo s(get_string('rezzer:deleteobject', 'sloodle', $object_title)) ?>" data-deleting-text="<?php echo s(get_string('rezzer:deletingobject', 'sloodle', $object_title)) ?>" class="control_button delete_layout_entry_button" type="submit"><?php echo s(get_string('rezzer:deleteobject', 'sloodle', $object_title)) ?></span>
  498. <span data-refresh-text="<?php echo s(get_string('rezzer:refreshconfig', 'sloodle', $object_title)) ?>" data-refreshing-text="<?php echo s(get_string('rezzer:refreshingconfig', 'sloodle', $object_title)) ?>" class="control_button refresh_config_button" type="submit"><?php echo s(get_string('rezzer:refreshconfig', 'sloodle', $object_title)) ?></span>
  499. <span data-updating-text="<?php echo s(get_string('rezzer:updatingobject', 'sloodle', $object_title )) ?>" data-update-text="<?php echo s(get_string('rezzer:updateobject', 'sloodle', $object_title )) ?>" class="control_button update_layout_entry_button" target="_self" type="submit"><?php echo s(get_string('rezzer:updateobject', 'sloodle', $object_title )) ?></span>
  500. </span>
  501. </div>
  502. <input type="hidden" name="layoutid" value="<?php echo intval($lid) ?>" />
  503. <input type="hidden" name="rezzeruuid" value="<?php echo htmlentities($rezzeruuid) ?>" />
  504. <input type="hidden" name="layoutentryid" value="<?php echo intval($e->id) ?>" />
  505. <input type="hidden" name="controllerid" value="<?php echo intval($contid) ?>" />
  506. <input type="hidden" name="objectgroup" value="<?php echo htmlentities( get_string('objectgroup:'.$group, 'sloodle' ) ) ?>" />
  507. <?php if ($config->module) {
  508. $moduleoptionselect = $config->course_module_select( $cid, isset($lconfig['sloodlemoduleid']) ? $lconfig['sloodlemoduleid'] : '');
  509. ?>
  510. <fieldset>
  511. <div class="row">
  512. <label for="<?php echo isset($config->fieldname) ? $config->fieldname : '' ?>"><?php echo get_string($config->module_choice_message, 'sloodle') ?></label>
  513. <span class="sloodle_config" data-courseid="<?php echo intval($cid)?>" data-fieldname="sloodlemoduleid" >
  514. <?php echo $moduleoptionselect ? $moduleoptionselect : '<span class="no_options_placeholder" data-fieldname="sloodlemoduleid">'.( ( $config->module_no_choices_message != '' ) ? get_string($config->module_no_choices_message, 'sloodle') : '').'</span>' ?>
  515. </span>
  516. </div>
  517. </fieldset>
  518. <?php
  519. } ?>
  520. <?php foreach($config->field_set_row_groups() as $fs => $fsrg) { ?>
  521. <fieldset>
  522. <?php if (count($fsrg) > 0) { ?>
  523. <?php foreach($fsrg as $ctrls) { ?>
  524. <?php $ctrls_reversed = array_reverse($ctrls); ?>
  525. <?php $first_ctrl = array_shift($ctrls); ?>
  526. <div class="row" data-row-name="<?php echo isset($first_ctrl->row_name) ? $first_ctrl->row_name : '' ?>" >
  527. <label for="<?php echo $first_ctrl->fieldname ?>"><?php echo get_string($first_ctrl->title, 'sloodle') ?></label>
  528. <?php foreach($ctrls_reversed as $ctrl) { ?>
  529. <?php $fieldname = $ctrl->fieldname; ?>
  530. <?php $val = isset($lconfig[$fieldname]) ? $lconfig[$fieldname] : ''; ?>
  531. <span class="sloodle_config object_<?php echo s($config->type_for_link())?>" data-courseid="<?php echo intval($cid)?>" data-fieldname="<?php echo $fieldname?>" >
  532. <?php if ( ($ctrl->type == 'radio') || ($ctrl->type == 'yesno') ) { ?>
  533. <?php foreach($ctrl->options as $opn => $opv) { ?>
  534. <input type="radio" name="<?php echo $fieldname ?>" value="<?php echo $opn ?>" <?php echo $opn == $val ? 'checked ' : '' ?>> <?php echo $ctrl->is_value_translatable ? get_string($opv, 'sloodle') : s($opv) ?> &nbsp; &nbsp;
  535. <?php } ?>
  536. <?php } else if ($ctrl->type == 'select') {?>
  537. <select name="<?php echo $fieldname ?>">
  538. <?php foreach($ctrl->options as $opn => $opv) { ?>
  539. <option value="<?php echo $opn ?>" <?php echo $opn == $val ? 'selected="selected"' : '' ?>> <?php echo $ctrl->is_value_translatable ? get_string($opv, 'sloodle') : s($opv) ?></option>
  540. <?php } ?>
  541. </select>
  542. <?php } else if ($ctrl->type == 'input') {?>
  543. <input type="text" size="<?php echo $ctrl->size ?>" maxlength="<?php echo $ctrl->max_length ?>" name="<?php echo $fieldname ?>" value="<?php echo $val ?>" />
  544. <?php } else {?>
  545. <?php echo $ctrl->type?>
  546. <?php } ?>
  547. </span>
  548. <?php } ?>
  549. </div>
  550. <?php } ?>
  551. <?php } ?>
  552. </fieldset>
  553. <?php } ?>
  554. </form>
  555. <br />
  556. <?php
  557. return $id;
  558. }
  559. ?>