feedback = $_SESSION['sloodle_presenter_feedback']; unset($_SESSION['sloodle_presenter_feedback']); // Construct a SLOODLE Session and load a module $this->_session = new SloodleSession(false); $this->presenter = new SloodleModulePresenter($this->_session); if (!$this->presenter->load($this->cm->id)) return false; $this->_session->module = $this->presenter; // Load available Presenter plugins if (!$this->_session->plugins->load_plugins('presenter')) { error('Failed to load Presenter plugins.'); return false; } } /** * Process any form data which has been submitted. */ function process_form() { global $CFG; // Slight hack to put this here. We need to have the permissions checked before we do this. // Default to view mode. Only allow other types if the user has sufficient permission if ($this->canedit) { $this->presenter_mode = optional_param('mode', 'view', PARAM_TEXT); } else { $this->presenter_mode = 'view'; } // If we're in moving mode, then grab the entry ID if ($this->presenter_mode == 'moveslide') $this->movingentryid = (int)optional_param('entry', 0); // Make sure Moodle includes our JavaScript files if necessary if ($this->presenter_mode == 'edit' || $this->presenter_mode == 'addfiles') { sloodle_require_js($CFG->wwwroot .'/mod/sloodle/lib/jquery/jquery.js'); sloodle_require_js($CFG->wwwroot .'/mod/sloodle/lib/jquery/jquery.uploadify.js'); sloodle_require_js($CFG->wwwroot .'/mod/sloodle/lib/jquery/jquery.checkboxes.js'); sloodle_require_js($CFG->wwwroot .'/mod/sloodle/lib/multiplefileupload/extra.js'); sloodle_require_js($CFG->wwwroot .'/lib/filelib.php'); } if ( $this->presenter_mode == 'addfiles') { sloodle_require_js($CFG->wwwroot .'/mod/sloodle/lib/js/presenter_addfiles.js"'); } // Should we process any incoming editing commands? if ($this->canedit) { // We may want to redirect afterwards to prevent an argument showing up in the address bar $redirect = false; // Are we deleting a single slide? if ($this->presenter_mode == 'deleteslide') { // Make sure the session key is specified and valid if (required_param('sesskey') != sesskey()) { error('Invalid session key'); exit(); } // Determine what slide is to be deleted $entryid = (int)required_param('entry', PARAM_INT); // Get the requested slide from the presentation $entry = $this->presenter->get_slide($entryid); if ($entry) { // Delete the slide $this->presenter->delete_entry($entryid); // Set our feedback information, so the user knows it has been successful $_SESSION['sloodle_presenter_feedback'] = get_string('presenter:deletedslide', 'sloodle', $entry->name); } else { // Set our feedback information, so the user knows it has not been successful; $_SESSION['sloodle_presenter_feedback'] = get_string('presenter:deletedslides', 'sloodle', 0); } // Redirect back to the edit tab to get rid of our messy request parameters (and to prevent accidental repeat of the operation) $redirect = true; } // Are we deleting multiple slides? if ($this->presenter_mode == 'deletemultiple') { // Make sure the session key is specified and valid if (required_param('sesskey') != sesskey()) { error('Invalid session key'); exit(); } // Fetch the IDs of the slides which are being deleted if (isset($_REQUEST['entriesstr'])) $entryids = explode(',',$_REQUEST['entriesstr']); else error("Expected HTTP parameter 'entries' not found."); // Go through the given entry IDs and attempt to delete them $numdeleted = 0; foreach ($entryids as $entryid) { if ($this->presenter->delete_entry($entryid)) $numdeleted++; } // Set our feedback information so the user knows whether or not this was successful $_SESSION['sloodle_presenter_feedback'] = get_string('presenter:deletedslides', 'sloodle', $numdeleted); // Redirect back to the edit tab to get rid of our messy request parameters (and to prevent accidental repeat of the operation) $redirect = true; } // Are we relocating an entry? if ($this->presenter_mode == 'setslideposition') { $entryid = (int)required_param('entry', PARAM_INT); $position = (int)required_param('position', PARAM_INT); $this->presenter->relocate_entry($entryid, $position); $redirect = true; } // Has a new entry been added? if (isset($_REQUEST['fileaddentry']) ||isset($_REQUEST['sloodleaddentry'])) { if (isset($_REQUEST['fileaddentry'])) { $urls = $_REQUEST['fileurl']; $names = $_REQUEST['filename']; $i = 0; foreach ($urls as $u) { $fnamelen= strlen($u); $extension= substr($u,$fnamelen-4); $ftype = strtolower($extension); switch ($ftype){ case ".mov": $ftype = "video"; break; case ".mp4": $ftype = "video"; break; case ".jpg": $ftype = "image"; break; case ".png": $ftype = "image"; break; case ".gif": $ftype = "image"; break; case ".bmp": $ftype = "image"; break; case ".htm": $ftype = "web"; break; case "html": $ftype = "web"; break; } $this->presenter->add_entry(sloodle_clean_for_db($u), $ftype, sloodle_clean_for_db($names[$i++])); } $redirect = true; } if (isset($_REQUEST['sloodleaddentry'])) { if ($_REQUEST['sloodleentryurl']!='') { $sloodleentryurl = sloodle_clean_for_db($_REQUEST['sloodleentryurl']); $sloodleentrytype = sloodle_clean_for_db($_REQUEST['sloodleentrytype']); $sloodleentryname = sloodle_clean_for_db($_REQUEST['sloodleentryname']); $sloodleentryposition = (int)$_REQUEST['sloodleentryposition']; // Store the type in session data for next time we're adding a slide $_SESSION['sloodle_presenter_add_type'] = $sloodleentrytype; $this->presenter->add_entry($sloodleentryurl, $sloodleentrytype, $sloodleentryname, $sloodleentryposition); } } $redirect = true; } // Has an existing entry been edited? if (isset($_REQUEST['sloodleeditentry'])) { $sloodleentryid = (int)$_REQUEST['sloodleentryid']; $sloodleentryurl = sloodle_clean_for_db($_REQUEST['sloodleentryurl']); $sloodleentrytype = sloodle_clean_for_db($_REQUEST['sloodleentrytype']); $sloodleentryname = sloodle_clean_for_db($_REQUEST['sloodleentryname']); $sloodleentryposition = (int)$_REQUEST['sloodleentryposition']; $this->presenter->edit_entry($sloodleentryid, $sloodleentryurl, $sloodleentrytype, $sloodleentryname, $sloodleentryposition); $redirect = true; } // Redirect back to the edit page -- this is used to get rid of intermediate parameters. if ($redirect && headers_sent() == false) { header("Location: ".SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=edit"); exit(); } } } /** * Render the View of the Presenter. * Called from with the {@link render()} function when necessary. */ function render_view() { //display any feedback if (!empty($this->feedback)) echo $this->feedback; // Get a list of entry slides in this presenter $entries = $this->presenter->get_slides(); if (!is_array($entries)) $entries = array(); $numentries = count($entries); // Open the presentation box //sloodle_print_box_start('generalbox boxaligncenter boxwidthwide'); // Was a specific entry requested? This is the number of entry within the presentation, NOT entry ID. // They start at 1 and go up from there within each presentation. if (isset($_REQUEST['sloodledisplayentry'])) { $displayentrynum = (int)$_REQUEST['sloodledisplayentry']; if ($displayentrynum < 1 || $displayentrynum > $numentries) $displayentrynum = 1; } else { $displayentrynum = 1; } // Do we have any entries to work with? if ($numentries > 0) { // Yes - go through them to figure out which entry to display $currententry = null; foreach ($entries as $entryid => $entry) { // Check if this is our current entry if ($displayentrynum == $entry->slideposition) { $currententry = $entry; } } // Display the entry header echo "
"; echo "

\"source}\" title=\"".get_string('directlink', 'sloodle')."\">{$currententry->name}\"

\n"; // Display the presentation controls $strof = get_string('of', 'sloodle'); $strviewprev = get_string('viewprev', 'sloodle'); $strviewnext = get_string('viewnext', 'sloodle'); $strviewjumpforward = get_string('jumpforward', 'sloodle'); $strviewjumpback = get_string('jumpback', 'sloodle'); echo '

'; // if ($displayentrynum > 1) echo "cm->id}&sloodledisplayentry=",$displayentrynum - 1,"#slide\" title=\"{$strviewprev}\">←"; // else echo ""; // echo " {$displayentrynum} {$strof} {$numentries} "; // if ($displayentrynum < $numentries) echo "cm->id}&sloodledisplayentry=",$displayentrynum + 1,"#slide\" title=\"{$strviewnext}\">→"; //else echo ""; echo "

\n"; global $OUTPUT; echo '
'; echo ''; echo '
'; $entrynumcounter=1; $jumpNumber=5; //display >> $arrowLinks = new stdClass(); $arrowLinks->class='texrender'; $arrowLinks->size = array('40px', '40px','40px','40px','40px'); $arrowLinks->cellpadding='1'; $arrowLinks->width='500px'; $slideLinks= new stdClass(); $slideLinks->class='texrender'; $slideLinks->size = array('20px', '20px','20px','20px','20px','20px','20px'); $slideLinks->cellpadding='1'; $row = array(); $arow = array(); $start = $displayentrynum - $jumpNumber-1; if ($start>=0) $arow[]= "cm->id}&sloodledisplayentry={$start}#slide\" title=\"{$strviewjumpback} ".$jumpNumber." slides\">\"{$strviewjumpback}"; else $arow[]="\"{$strviewjumpback}"; $prev=$displayentrynum-1; if ($displayentrynum>=2) $arow[]= "cm->id}&sloodledisplayentry={$prev}#slide\" title=\"{$strviewprev}\">\"{$strviewprev}\" "; else $arow[]= "\"{$strviewprev}\""; // display hyperlinks for each slide $row=""; foreach ($entries as $entryid => $entry) { //get start and end slides $start = $displayentrynum - $jumpNumber; if ($start<0) $start =0; $end = $displayentrynum + $jumpNumber; if ($end>$numentries) $end =$numentries; if (($entrynumcounter >= $start)&& ($entrynumcounter<=$end)){ if ($entrynumcounter==$displayentrynum) $row.= ""; else $row.= ""; } $entrynumcounter++; } $row.="
"."cm->id}&sloodledisplayentry=".$entrynumcounter."#slide\" title=\"{$entry->name}\">{$entrynumcounter}cm->id}&sloodledisplayentry=".$entrynumcounter."#slide\" title=\"{$entry->name}\">{$entrynumcounter}
"; $arow[]=$row; $end = $displayentrynum + $jumpNumber+1; $next=$displayentrynum+1; if ($displayentrynum+1 <=$numentries) $arow[]= "cm->id}&sloodledisplayentry={$next}#slide\" title=\"{$strviewnext}\">\"{$strviewnext}\" "; else $arow[]="\"{$strviewnext}\""; if ($end<=$numentries) $arow[]= "cm->id}&sloodledisplayentry=".$end."#slide\" title=\"{$strviewjumpforward} ".$jumpNumber." slides\">\"{$strviewjumpforward} "; else $arow[]="\"{$strviewjumpforward}"; //$slideLinks->data[]=$row; $arrowLinks->data[]=$arow; echo '
'; sloodle_print_table($arrowLinks); echo '
'; echo "

"; echo '
'; echo '
'; // Get the frame dimensions for this Presenter $framewidth = $this->presenter->get_frame_width(); $frameheight = $this->presenter->get_frame_height(); // Get the plugin for this slide $slideplugin = $this->_session->plugins->get_plugin('presenter-slide', $currententry->type); if (is_object($slideplugin)) { // Render the content for the web echo $slideplugin->render_slide_for_browser($currententry); } else { echo '

',get_string('unknowntype','sloodle'),': presenter-slide::',$currententry->type, '

'; } // Display a direct link to the media echo "

"; print ''; print_string('trydirectlink', 'sloodle'); print ""; echo "

\n"; echo "
"; } else { echo '

'.get_string('presenter:empty', 'sloodle').'

'; if ($this->canedit) echo '

'.get_string('presenter:clickaddslide', 'sloodle').'

'; } } /** * Render the Edit mode of the Presenter (lists all the slides and allows re-ordering). * Called from with the {@link render()} function when necessary. */ function render_edit() { //display any feedback if (!empty($this->feedback)) echo $this->feedback; global $CFG; $streditpresenter = get_string('presenter:edit', 'sloodle'); $strviewanddelete = get_string('presenter:viewanddelete', 'sloodle'); $strnoentries = get_string('noentries', 'sloodle'); $strnoslides = get_string('presenter:empty', 'sloodle'); $strdelete = get_string('delete', 'sloodle'); $stradd = get_string('presenter:add', 'sloodle'); $straddatend = get_string('presenter:addatend', 'sloodle'); $straddbefore = get_string('presenter:addbefore', 'sloodle'); $strtype = get_string('type', 'sloodle'); $strurl = get_string('url', 'sloodle'); $strname = get_string('name', 'sloodle'); $stryes = get_string('yes'); $strno = get_string('no'); $strmove = get_string('move'); $stredit = get_string('edit', 'sloodle'); $strview = get_string('view', 'sloodle'); $strdelete = get_string('delete'); $strmoveslide = get_string('presenter:moveslide', 'sloodle'); $streditslide = get_string('presenter:editslide', 'sloodle'); $strviewslide = get_string('presenter:viewslide', 'sloodle'); $strdeleteslide = get_string('presenter:deleteslide', 'sloodle'); // pixpath breaks in Moodle 2. if ( SLOODLE_IS_ENVIRONMENT_MOODLE_2 ) { global $OUTPUT; $moveheregif = $OUTPUT->pix_url('movehere'); $movegif = $OUTPUT->pix_url('t/move'); $editgif = $OUTPUT->pix_url('t/edit'); $previewgif = $OUTPUT->pix_url('t/preview'); $deletegif = $OUTPUT->pix_url('t/delete'); } else { $moveheregif = "{$CFG->pixpath}/movehere.gif"; $movegif = "{$CFG->pixpath}/t/move.gif"; $editgif = "{$CFG->pixpath}/t/edit.gif"; $previewgif = "{$CFG->pixpath}/t/preview.gif"; $deletegif = "{$CFG->pixpath}/t/delete.gif"; } // Get a list of entry URLs $entries = $this->presenter->get_slides(); if (!is_array($entries)) $entries = array(); $numentries = count($entries); // Any images to display? if ($entries === false || count($entries) == 0) { echo '

'.$strnoslides.'

'; echo '

'.$stradd.'


'; } else { // Are we being asked to confirm the deletion of a slide? if ($this->presenter_mode == 'confirmdeleteslide') { // Make sure the session key is specified and valid if (required_param('sesskey') != sesskey()) { error('Invalid session key'); exit(); } // Determine which slide is being deleted $entryid = (int)required_param('entry', PARAM_INT); // Make sure the specified entry is recognised if (isset($entries[$entryid])) { // Construct our links $linkYes = SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=deleteslide&entry={$entryid}&sesskey=".sesskey(); $linkNo = SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=edit"; // Output our confirmation form notice_yesno(get_string('presenter:confirmdelete', 'sloodle', $entries[$entryid]->name), $linkYes, $linkNo); echo "
"; } } // Are we being asked to confirm the deletion of multiple slides? $deletingentries = array(); if ($this->presenter_mode == 'confirmdeletemultiple') { // Make sure the session key is specified and valid if (required_param('sesskey') != sesskey()) { error('Invalid session key'); exit(); } // Grab the array of entries to be deleted if (isset($_REQUEST['entries'])) $deletingentries = $_REQUEST['entries']; if (is_array($deletingentries) && count($deletingentries) > 0) { // Construct our links $entriesparam = 'entriesstr='; $delim = ''; foreach($deletingentries as $de) { $entriesparam .= $delim.intval($de); $delim = ','; } $linkYes = SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=deletemultiple&{$entriesparam}&sesskey=".sesskey(); $linkNo = SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=edit"; // Output our confirmation form notice_yesno(get_string('presenter:confirmdeletemultiple', 'sloodle', count($deletingentries)), $linkYes, $linkNo); echo "
"; } else { // No slides selected. // Inform the user to select slides first, and then click the button again. notify(get_string('presenter:noslidesfordeletion', 'sloodle')); } } // Are we currently moving a slide? if ($this->presenter_mode == 'moveslide') { $linkCancel = SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=edit"; $strcancel = get_string('cancel'); // Display a message and an optional 'cancel' link sloodle_print_box_start('generalbox', 'notice'); echo "

", get_string('presenter:movingslide', 'sloodle', $entries[$this->movingentryid]->name), "

\n"; echo "

({$strcancel})

\n"; sloodle_print_box_end(); } // Setup a table object to display Presenter entries $entriesTable = new stdClass(); $entriesTable->head = array(get_string('position', 'sloodle'),'
'.get_string('selectall','sloodle').'
', get_string('name', 'sloodle'), get_string('type', 'sloodle'), get_string('actions', 'sloodle')); $entriesTable->align = array('center', 'center', 'left', 'left', 'center'); $entriesTable->size = array('5%', '5%', '30%', '20%', '30%'); // Go through each entry $numentries = count($entries); foreach ($entries as $entryid => $entry) { // Create a new row for the table $row = array(); // Extract the entry data $slideplugin = $this->_session->plugins->get_plugin('presenter-slide', $entry->type); if (is_object($slideplugin)) $entrytypename = $slideplugin->get_plugin_name(); else $entrytypename = '(unknown type)'; // Construct the link to the entry source $entrylink = "source}\" title=\"{$entry->source}\">{$entry->name}"; // If this is the slide being moved, then completely ignore it if ($this->movingentryid == $entryid) { continue; } // If we are in move mode, then add a 'move here' row before this slide if ($this->presenter_mode == 'moveslide') { $movelink = SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=setslideposition&entry={$this->movingentryid}&position={$entry->slideposition}"; $movebutton = "\"{$strmove}\"\n"; $entriesTable->data[] = array('', '', $movebutton, '', '', ''); // If the current row belongs to the slide being moved, then emphasise it, and append (moving) to the end if ($entryid == $this->movingentryid) $entrylink = "{$entrylink} (".get_string('moving','sloodle').')'; } // Define our action links $actionBaseLink = SLOODLE_WWWROOT."/view.php?id={$this->cm->id}"; $actionLinkMove = $actionBaseLink."&mode=moveslide&entry={$entryid}"; $actionLinkEdit = $actionBaseLink."&mode=editslide&entry={$entryid}"; $actionLinkView = $actionBaseLink."&mode=view&sloodledisplayentry={$entry->slideposition}#slide"; $actionLinkDelete = $actionBaseLink."&mode=confirmdeleteslide&entry={$entryid}&sesskey=".sesskey(); // Prepare the add buttons separately $actionLinkAdd = $actionBaseLink."&mode=addslide&sloodleentryposition={$entry->slideposition}"; $addButtons = "\"{$stradd}\"\n"; // Construct our list of action buttons $actionButtons = ''; $actionButtons .= "\"{$strmove}\"\n"; $actionButtons .= "\"{$stredit}\"\n"; $actionButtons .= "\"{$strview}\"\n"; $actionButtons .= "\"{$strdelete}\"\n"; $actionButtons .= $addButtons; //create checkbox for multiple edit functions $checked = ''; if (in_array($entryid, $deletingentries)) $checked = "checked=\"checked\""; $checkbox = "
"; // Add each item of data to our table row. // The first item is a check box for multiple deletes // The second items are the position and the name of the entry, hyperlinked to the resource. // The next is the name of the entry type. // The last is a list of action buttons -- move, edit, view, and delete. $row[] = $entry->slideposition; $row[] = $checkbox; $row[] = $entrylink; $row[] = $entrytypename; $row[] = $actionButtons; // Add the row to our table $entriesTable->data[] = $row; } // If we are in move mode, then add a final 'move here' row at the bottom // We need to add a final row at the bottom // Prepare the action link for this row $endentrynum = $entry->slideposition + 1; $actionLinkAdd = $actionBaseLink."&mode=addslide&sloodleentryposition={$endentrynum}"; $addButtons = "\"{$stradd}\"\n"; $sloodleInsert = get_string("presenter:sloodleinsert","sloodle"); // It will contain a last 'add' button, and possibly a 'move here' button too (if we are in move mode) $movebutton = ''; if ($this->presenter_mode == 'moveslide') { $movelink = SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=setslideposition&entry={$this->movingentryid}&position={$endentrynum}"; $movebutton = "\"{$strmove}\"\n"; } // Add a button to delete all selected slides $deleteButton = ''; $entriesTable->data[] = array('','
'.get_string('selectall','sloodle').'
', $movebutton , '', $deleteButton.'  '.$addButtons); // Put our table inside a form to allow us to delete multiple slides based on the checkboxes echo '
'; echo "cm->id}\" />\n"; // Course module ID so that the request comes to the right places echo "\n"; // The operation being conducted sloodle_print_table($entriesTable); echo "\n"; // Session key to ensure unauthorised deletions are not possible (e.g. using XSS) echo '
'; } } /** * Render the "Upload Many" tab. */ function render_add_files() { global $CFG; global $USER; /* Normally Moodle would use the itemid for something that the image belongs to, eg. a forum post. We don't really need one here - we have slides, but they are assigned after the file has been uploaded. We'll set this parameter to a unique ID per upload page. This will prevent clashes if you try to re-upload another file with the same name. (The upload component expects to know what the name of the uploaded file will be, so we have to assign it before doing the upload.) */ $itemid = time(); // Setup variables to store the data $entryid = 0; $entryname = ''; $entryurl = ''; $entrytype = ''; // Fetch a list of existing slides $entries = $this->presenter->get_entry_urls(); // Check what position we are adding the new slide to // (default to negative, which puts it at the end) $position = (int)optional_param('sloodleentryposition', '-1', PARAM_INT); // Fetch our translation strings $streditpresenter = get_string('presenter:edit', 'sloodle'); $strviewanddelete = get_string('presenter:viewanddelete', 'sloodle'); $strnoentries = get_string('noentries', 'sloodle'); $strdelete = get_string('delete', 'sloodle'); $strBulkUpload = get_string('presenter:bulkupload', 'sloodle'); $stradd = get_string('presenter:addfiles', 'sloodle'); $strtype = get_string('type', 'sloodle'); $strurl = get_string('url', 'sloodle'); $strname = get_string('name', 'sloodle'); $strposition = get_string('position', 'sloodle'); $strsave = get_string('save', 'sloodle'); $strend = get_string('end', 'sloodle'); $stryes = get_string('yes'); $strno = get_string('no'); $strcancel = get_string('cancel'); $strmove = get_string('move'); $stredit = get_string('edit', 'sloodle'); $strview = get_string('view', 'sloodle'); $strdelete = get_string('delete'); // Construct an array of available entry types, associating the identifier to the human-readable name. // In future, this will be built from a list of plugins, but for now we'll hard code it. $availabletypes = array(); $availabletypes['image'] = get_string('presenter:type:image','sloodle'); $availabletypes['video'] = get_string('presenter:type:video','sloodle'); $availabletypes['web'] = get_string('presenter:type:web','sloodle'); //display instructions echo get_string('presenter:uploadInstructions','sloodle'); // We'll post the data straight back to this page echo '
'; // Identify the module /* * Uploadify Multiple File uploader added by Paul Preibisch * @see http://www.uploadify.com/documentation * * @var uploadWwwDir - place to store files * @var uploadArray[] - array to hold complete file names * @var extension - temp var to hold extension type of current file * @var tableData - used to construct table rows * @uses upload.php - upload.php is the upload handler script * @uses uploader.swf - enables multiple file uploading */ $context = get_context_instance(CONTEXT_MODULE, $this->cm->id); $contextid = $context->id; echo '"; echo ''; //this div is where the uploaded files will be displayed echo '
'; echo '
'; echo '
'; // Add a button to let us cancel and go back to the main edit tab echo '
'; echo "cm->id}\" />"; echo ""; echo ""; echo '
'; } /** * Render the slide editing form of the Presenter (lets you edit a single slide). * Called from with the {@link render()} function when necessary. */ function render_slide_edit() { // Setup variables to store the data $entryid = 0; $entryname = ''; $entryurl = ''; $entrytype = ''; // Fetch a list of existing slides $entries = $this->presenter->get_slides(); // Check what position we are adding the new slide to // (default to negative, which puts it at the end) $position = (int)optional_param('sloodleentryposition', '-1', PARAM_INT); // Are we adding a slide, or editing one? $newslide = false; if ($this->presenter_mode == 'addslide') { // Adding a new slide $newslide = true; // Grab the last added type from session data if (isset($_SESSION['sloodle_presenter_add_type'])) $entrytype = $_SESSION['sloodle_presenter_add_type']; } else { // Editing an existing slide $entryid = (int)required_param('entry', PARAM_INT); // Fetch the slide details if (!isset($entries[$entryid])) { error("Cannot find entry {$entryid} in the database."); exit(); } $entryurl = $entries[$entryid]->source; $entrytype = $entries[$entryid]->type; $entryname = $entries[$entryid]->name; } // Fetch our translation strings $streditpresenter = get_string('presenter:edit', 'sloodle'); $strviewanddelete = get_string('presenter:viewanddelete', 'sloodle'); $strnoentries = get_string('noentries', 'sloodle'); $strdelete = get_string('delete', 'sloodle'); $stradd = get_string('presenter:add', 'sloodle'); $strtype = get_string('type', 'sloodle'); $strurl = get_string('url', 'sloodle'); $strname = get_string('name', 'sloodle'); $strposition = get_string('position', 'sloodle'); $strsave = get_string('save', 'sloodle'); $strend = get_string('end', 'sloodle'); $stryes = get_string('yes'); $strno = get_string('no'); $strcancel = get_string('cancel'); $strmove = get_string('move'); $stredit = get_string('edit', 'sloodle'); $strview = get_string('view', 'sloodle'); $strdelete = get_string('delete'); // Construct an array of available entry types, associating the identifier to the human-readable name. $availabletypes = array(); $pluginids = $this->_session->plugins->get_plugin_ids('presenter-slide'); if (!$pluginids) exit('Failed to query for SLOODLE Presenter slide plugins.'); foreach ($pluginids as $pluginid) { // Fetch the plugin and store its human-readable name $plugin = $this->_session->plugins->get_plugin('presenter-slide', $pluginid); $availabletypes[$pluginid] = $plugin->get_plugin_name(); } // We'll post the data straight back to this page echo '
'; // Identify the module echo "cm->id}\" />"; // Identify the entry being edited, if appropriate if (!$newslide) echo ""; // Add boxes for the URL and name of the entry echo '

'; echo '

'; // Add a selection box for the entry type echo '

'; // Add a selection box to let the user change the position of the entry echo '

\n"; // Display an appropriate submit button if ($newslide) echo ' '; else echo ' '; // Close the form echo '
'; // Add a button to let us cancel and go back to the main edit tab echo '
'; echo "cm->id}\" />"; echo ""; echo ""; echo '
'; } /** * Render the tab for importing slides from some source. * If necessary, this will first display a form letting the user select which importer to use. * It will then rely on the plugin to sort out everything else. */ function render_import_slides() { global $CFG; // Construct an array of available importers, associating the identifier to the human-readable name. $availableimporters = array(); $pluginids = $this->_session->plugins->get_plugin_ids('presenter-importer'); if (!$pluginids) error('Failed to load any SLOODLE Presenter importer plugins. Please check your plugins folder.'); foreach ($pluginids as $pluginid) { // Fetch the plugin and store its human-readable name $plugin = $this->_session->plugins->get_plugin('presenter-importer', $pluginid); $availableimporters[$pluginid] = $plugin->get_plugin_name(); } // We are expecting a few parameters $position = (int)optional_param('sloodleentryposition', '-1', PARAM_INT); $plugintype = strtolower(optional_param('sloodleplugintype', '', PARAM_CLEAN)); // Fetch translation strings $strselectimporter = get_string('presenter:selectimporter', 'sloodle'); $strsubmit = get_string('submit'); $strincompatible = get_string('incompatible', 'sloodle'); $strcompatible = get_string('compatible', 'sloodle'); $strincompatibleplugin = get_string('incompatibleplugin', 'sloodle'); $strcheck = get_string('check', 'sloodle'); $strclicktocheck = get_string('clicktocheckcompatibility', 'sloodle'); $strclicktochecknoperm = get_string('clicktocheckcompatibility:nopermission', 'sloodle'); // Do we have a valid plugin type already specified? if (empty($plugintype) || !array_key_exists($plugintype, $availableimporters)) { // No - display a menu to select the desired importer // Sort the list of importers by name natcasesort($availableimporters); // Setup a base link for all importer types $baselink = "{$CFG->wwwroot}/mod/sloodle/view.php?id={$this->cm->id}&mode=importslides"; // Setup a base link for checking compatibility $checklink = "{$CFG->wwwroot}/mod/sloodle/view.php?id={$this->cm->id}&mode=compatibility"; // Make sure this user has site configuration permission, as running this test may reveal sensitive information about server architecture $module_context = get_context_instance(CONTEXT_MODULE, $this->cm->id); $cancheckcompatibility = (bool)has_capability('moodle/site:config', $module_context); // Go through each one and display it in a menu $table = new stdClass(); $table->head = array(get_string('name', 'sloodle'), get_string('description'), get_string('compatibility', 'sloodle')); $table->size = array('20%', '70%', '10%'); $table->align = array('center', 'left', 'center'); $table->data = array(); foreach ($availableimporters as $importerident => $importername) { // Get the description of the plugin $plugin = $this->_session->plugins->get_plugin('presenter-importer', $importerident); $desc = $plugin->get_plugin_description(); // Check the compatibility of the plugin $linkclass = ''; $compatibility = ''; if (!$plugin->check_compatibility()) { $linkclass = ' class="dimmed"'; $compatibility = '[ '.$strincompatible.' ]'; } // Construct this line of the table $line = array(); // Add the name of the importer to the table as a link $link = "{$baselink}&sloodleplugintype={$importerident}"; $line[] = "{$importername}
{$compatibility}"; // Add the description $line[] = $desc; // Add a link to a compatibility check if the user has permission. if ($cancheckcompatibility) { $link = "{$checklink}&sloodleplugintype={$importerident}"; $line[] = "{$strcheck}"; } else { $line[] = "-"; } $table->data[] = $line; } echo "

{$strselectimporter}:

\n"; sloodle_print_table($table); return; } // Grab the importer plugin object $importer = $this->_session->plugins->get_plugin('presenter-importer', $plugintype); // Display a heading for this importer echo '

'.$importer->get_plugin_name()."

\n"; // Render the plugin display $importer->render("{$CFG->wwwroot}/mod/sloodle/view.php?id={$this->cm->id}", $this->presenter); } /** * Render a compatibility test of a particular plugin. */ function render_compatibility_test() { global $CFG; // Which plugin has been requested? $plugintype = strtolower(required_param('sloodleplugintype', PARAM_CLEAN)); // Attempt to load the specified plugin $plugin = $this->_session->plugins->get_plugin('presenter-importer', $plugintype); if ($plugin === false) exit(get_string('pluginloadfailed', 'sloodle')); $name = $plugin->get_plugin_name(); // Make sure this user has site configuration permission, as running this test may reveal sensitive information about server architecture $module_context = get_context_instance(CONTEXT_MODULE, $this->cm->id); if (!has_capability('moodle/site:config', $module_context)) error(get_string('clicktocheckcompatibility:nopermission', 'sloodle'), "{$CFG->wwwroot}/mod/sloodle/view.php?id={$this->cm->id}&mode=importslides"); // Display a heading for this compatibility check echo '

',get_string('runningcompatibilitycheck', 'sloodle'),'

'; echo '

'.$name."

\n"; echo "

( wwwroot}/mod/sloodle/view.php?id={$this->cm->id}&mode=importslides\">",get_string('presenter:backtoimporters','sloodle')," )

\n"; // Run the compatibility test echo "
"; $result = $plugin->run_compatibility_test(); echo "
\n"; if ($result) echo "

",get_string('compatibilitytestpassed', 'sloodle'),"

"; else echo "

",get_string('compatibilitytestfailed', 'sloodle'),"

"; echo "

( wwwroot}/mod/sloodle/view.php?id={$this->cm->id}&mode=importslides\">",get_string('presenter:backtoimporters','sloodle')," )

\n"; } /** * Render the view of the Presenter. */ function render() { global $CFG; // Setup our list of tabs // We will always have a view option $presenterTabs = array(); // Top level is rows of tabs $presenterTabs[0] = array(); // Second level is individual tabs in a row $presenterTabs[0][] = new tabobject(SLOODLE_PRESENTER_TAB_VIEW, SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=view", get_string('view', 'sloodle'), get_string('presenter:viewpresentation', 'sloodle'), true); // Does the user have authority to edit this module? if ($this->canedit) { // Add the 'Edit' tab, for editing the presentation as a whole $presenterTabs[0][] = new tabobject(SLOODLE_PRESENTER_TAB_EDIT, SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=edit", get_string('edit', 'sloodle'), get_string('presenter:edit', 'sloodle'), true); // Add the 'Add Slide' tab $presenterTabs[0][] = new tabobject(SLOODLE_PRESENTER_TAB_ADD_SLIDE, SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=addslide", get_string('presenter:add', 'sloodle'), get_string('presenter:add', 'sloodle'), true); // Add the 'Bulk Upload' tab $presenterTabs[0][] = new tabobject(SLOODLE_PRESENTER_TAB_ADD_FILES, SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=addfiles", get_string('presenter:bulkupload', 'sloodle'), get_string('presenter:bulkupload', 'sloodle'), true); // Add the 'Import Slides' tab $presenterTabs[0][] = new tabobject(SLOODLE_PRESENTER_TAB_IMPORT_SLIDES, SLOODLE_WWWROOT."/view.php?id={$this->cm->id}&mode=importslides", get_string('presenter:importslides', 'sloodle'), get_string('presenter:importslides', 'sloodle'), true); // If we are editing a slide, then add the 'Edit Slide' tab if ($this->presenter_mode == 'editslide') { $presenterTabs[0][] = new tabobject(SLOODLE_PRESENTER_TAB_EDIT_SLIDE, '', get_string('editslide', 'sloodle'), '', false); } } // Determine which tab should be active $selectedtab = SLOODLE_PRESENTER_TAB_VIEW; switch ($this->presenter_mode) { case 'edit': $selectedtab = SLOODLE_PRESENTER_TAB_EDIT; break; case 'addslide': $selectedtab = SLOODLE_PRESENTER_TAB_ADD_SLIDE; break; case 'addfiles': $selectedtab = SLOODLE_PRESENTER_TAB_ADD_FILES; break; case 'editslide': $selectedtab = SLOODLE_PRESENTER_TAB_EDIT_SLIDE; break; case 'moveslide': $selectedtab = SLOODLE_PRESENTER_TAB_EDIT; break; case 'deleteslide': $selectedtab = SLOODLE_PRESENTER_TAB_EDIT; break; case 'confirmdeleteslide': $selectedtab = SLOODLE_PRESENTER_TAB_EDIT; break; case 'deletemultiple': $selectedtab = SLOODLE_PRESENTER_TAB_EDIT; break; case 'confirmdeletemultiple': $selectedtab = SLOODLE_PRESENTER_TAB_EDIT; break; case 'importslides': $selectedtab = SLOODLE_PRESENTER_TAB_IMPORT_SLIDES; break; case 'compatibility': $selectedtab = SLOODLE_PRESENTER_TAB_IMPORT_SLIDES; break; } // Display the tabs print_tabs($presenterTabs, $selectedtab); echo "
\n"; // Call the appropriate render function, based on our mode switch ($this->presenter_mode) { case 'edit': $this->render_edit(); break; case 'addslide': $this->render_slide_edit(); break; case 'addfiles': $this->render_add_files(); break; case 'editslide': $this->render_slide_edit(); break; case 'moveslide': $this->render_edit(); break; case 'deleteslide': $this->render_edit(); break; case 'confirmdeleteslide': $this->render_edit(); break; case 'deletemultiple': $this->render_edit(); break; case 'confirmdeletemultiple': $this->render_edit(); break; case 'importslides': $this->render_import_slides(); break; case 'compatibility': $this->render_compatibility_test(); break; default: $this->render_view(); break; } echo "
\n"; } } ?>