-
-<tr valign="top">
- <td align="right" nowrap="nowrap">
-
-
-<script language="javascript" type="text/javascript">
- function showhide (id, set) {
- divobj = document.getElementById(id);
- butobj = document.getElementById(id+'button');
- prefobj = document.getElementById(id+'pref');
- if (set == true) {
- if (prefobj.value == '1') {
- divobj.style.display = 'block';
- butobj.value = '<?php print_string("hidesettings") ?>';
- } else {
- divobj.style.display = 'none';
- butobj.value = '<?php print_string("showsettings") ?>...';
- }
- } else {
- if (prefobj.value == '1') {
- divobj.style.display = 'none';
- butobj.value = '<?php print_string("showsettings") ?>...';
- prefobj.value = '0';
- } else {
- divobj.style.display = 'block';
- butobj.value = '<?php print_string("hidesettings") ?>';
- prefobj.value = '1';
- }
- }
- }
-</script>
-
-
- <b><?php echo $strfilename ?>:</b>
- </td>
- <td>
- <?php
- echo "<input type=\"text\" name=\"reference\" size=\"90\" value=\"$form->reference\" alt=\"reference\" /><br />";
-//MW add image icon next to Hive... button
- ?>
- </td>
- </tr>
- <tr valign="top">
- <td align="right" nowrap="nowrap">
- <img src="<?php echo $CFG->wwwroot.'/mod/resource/type/repository/hive/hp-footer-hive-powered.gif' ?>" align="top" />
- </td>
- <td>
- <?php
-//MW END
-//MW add controls to popup
- $options = 'menubar,location,toolbar,scrollbars,resizable,width=750,height=500';
- button_to_popup_window ('/mod/resource/type/repository/hive/openlitebrowse.php',
- 'LiteBrowse', 'Browse for content in Hive', 500, 750,
- 'Browse for content in the HarvestRoad Hive repository', $options);
- button_to_popup_window ('/mod/resource/type/repository/hive/openlitesearch.php',
- 'LiteSearch', 'Search for content in Hive ', 500, 750,
- 'Search for content in the HarvestRoad Hive repository', $options);
- helpbutton("hive", "HarvestRoad Hive", "resource/type", true);
-//MW END
-// button_to_popup_window ('/mod/resource/type/repository/hive/openhive.php', 'Hive', 'Hive', 500, 750, $strchooseafile);
- ?>
- </td>
-</tr>
-
-<tr><td colspan="2"><hr /></td></tr>
-
-<tr>
- <td align="right"><b><?php print_string("display", "resource") ?>:</b></td>
- <td>
- <input type="button" value="hide settings" id="windowsettingsbutton" onclick="javascript: return showhide('windowsettings');" />
- <input type="hidden" name="windowsettingspref" id="windowsettingspref"
- value="<?php echo get_user_preferences('resource_windowsettingspref', $CFG->resource_windowsettings); ?>" />
- <?php helpbutton("window", get_string("display", "resource"), "resource", true) ?>
- </td>
-</tr>
-<tr><td colspan="2">
-
- <div id="windowsettings">
-
-<table align="center">
-
-
-<tr valign="top">
-
- <td colspan="2">
- <script type="text/javascript">
- var popupitems = [<?php echo $popupoptions; ?>];
- var frameitem = [<?php echo $frameoption; ?>];
- var allitems = [<?php echo $alloptions; ?>];
- </script>
- <input type="radio" name="windowpopup" value="0" alt="<?php print_string('pagewindow', 'resource') ?>" <?php echo ($windowtype != "popup") ? "checked=\"checked\"" : "" ?>
- onclick="lockoptions('form', 'windowpopup[0]', frameitem);
- return lockoptions('form', 'windowpopup[1]', popupitems);" />
- <b title="<?php print_string("pagedisplay", "resource") ?>"><?php print_string("pagewindow", "resource") ?></b>
- <blockquote>
- <input type="hidden" name="hframepage" value="0" />
- <input type="checkbox" name="framepage" value="1" <?php echo ($form->options == "frame") ? "checked=\"checked\"" : "" ?> alt="<?php print_string('frameifpossible', 'resource') ?>" />
- <?php print_string("frameifpossible", "resource") ?>
- </blockquote>
- </td>
-</tr>
-
-<tr valign="top">
-
- <td colspan="2">
- <input name="windowpopup" type="radio" value="1" alt="<?php p($strnewwindow)?>" <?php echo ($windowtype == "popup") ? "checked=\"checked\"" : "" ?>
- onclick="lockoptions('form', 'windowpopup[0]', frameitem);
- return lockoptions('form', 'windowpopup[1]', popupitems);" />
- <b title="<?php p($strnewwindowopen) ?>"><?php p($strnewwindow) ?></b>
- <blockquote>
- <?php
- foreach ($window as $name => $value) {
- if ($name == "height" or $name == "width") {
- continue;
- }
- echo "<input name=\"h$name\" type=\"hidden\" value=\"0\" />";
- echo "<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." alt=\"$name\" />";
- $stringname = "str$name";
- echo $$stringname."<br />";
- }
- ?>
-
- <input name="hwidth" type="hidden" value="0" />
- <input name="width" type="text" size="4" value="<?php p($window->width) ?>" alt="<?php p($strwidth) ?>" />
- <?php p($strwidth) ?><br />
-
- <input name="hheight" type="hidden" value="0" />
- <input name="height" type="text" size="4" value="<?php p($window->height) ?>" alt="<?php p($strheight) ?>" />
- <?php p($strheight) ?><br />
- <?php
- if ($windowtype == "page") {
- echo "<script type=\"text/javascript\">";
- echo "lockoptions('form','windowpopup[1]', popupitems);";
- echo "</script>";
- } else {
- echo "<script type=\"text/javascript\">";
- echo "lockoptions('form','windowpopup[0]', frameitem);";
- echo "</script>";
- }
- ?>
- </blockquote>
- </td>
-</tr>
-
-</table>
-
- </div>
-
-</td></tr>
-
-<tr>
- <td align="right"><b><?php print_string("parameters", "resource") ?>:</b></td>
- <td>
- <input type="button" value="hide settings" id="parametersettingsbutton" onclick="javascript: return showhide('parametersettings');" />
- <input type="hidden" name="parametersettingspref" id="parametersettingspref"
- value="<?php echo get_user_preferences('resource_parametersettingspref', $CFG->resource_parametersettings); ?>" />
- <?php helpbutton("parameters", get_string("parameters", "resource"), "resource", true) ?>
- </td>
-</tr>
-<tr><td colspan="2">
-
- <div id="parametersettings">
-
-<table align="center">
-
- <tr>
- <td align="center"><?php print_string("parameter", "resource") ?></td>
- <td align="center"><?php print_string("variablename", "resource") ?></td>
- </tr>
-
-<?php
-
-for ($i=0; $i < $this->maxparameters; $i++) {
- echo "<tr>\n";
- echo "<td valign=\"top\">\n";
- echo "<select name=\"parameter$i\">\n";
- echo "<option value=\"-\">-- ".get_string('chooseparameter', 'resource')." --</option>\n";
- foreach ($this->parameters as $field=>$fieldarr) {
- if ($fieldarr['value'] === "optgroup") {
- echo "<optgroup label=\"{$fieldarr['langstr']}\">\n";
- } elseif ($fieldarr['value'] === "/optgroup") {
- echo "</optgroup>\n";
- } else {
- echo "<option value=\"$field\"";
- if ($alltextfield[$i]['parameter'] == $field) {
- echo " selected=\"selected\"";
- }
- echo ">{$fieldarr['langstr']}</option>\n";
- }
- }
- echo "</select>\n";
- echo "</td>\n";
- echo "<td valign=\"top\">\n";
- echo "<input type=\"text\" name=\"parse$i\" value=\"{$alltextfield[$i]['parse']}\" alt=\"parameter$i\"/>\n";
- echo "</td>\n";
- echo "</tr>\n";
-}
-
-?>
-
-
-</table>
-
- </div>
-
-
-<script language="javascript" type="text/javascript">
- showhide('parametersettings', true);
- showhide('windowsettings', true);
-</script>
-
-
-</td></tr>
-
-<?php print_visible_setting($form); ?>
+\r
+<tr valign="top">\r
+ <td align="right" nowrap="nowrap">\r
+\r
+\r
+<script language="javascript" type="text/javascript">\r
+ function showhide (id, set) {\r
+ divobj = document.getElementById(id);\r
+ butobj = document.getElementById(id+'button');\r
+ prefobj = document.getElementById(id+'pref');\r
+ if (set == true) {\r
+ if (prefobj.value == '1') {\r
+ divobj.style.display = 'block';\r
+ butobj.value = '<?php print_string("hidesettings") ?>';\r
+ } else {\r
+ divobj.style.display = 'none';\r
+ butobj.value = '<?php print_string("showsettings") ?>...';\r
+ }\r
+ } else {\r
+ if (prefobj.value == '1') {\r
+ divobj.style.display = 'none';\r
+ butobj.value = '<?php print_string("showsettings") ?>...';\r
+ prefobj.value = '0';\r
+ } else {\r
+ divobj.style.display = 'block';\r
+ butobj.value = '<?php print_string("hidesettings") ?>';\r
+ prefobj.value = '1';\r
+ }\r
+ }\r
+ }\r
+</script>\r
+\r
+\r
+ <b><?php echo $strfilename ?>:</b>\r
+ </td>\r
+ <td>\r
+ <?php\r
+ echo "<input type=\"text\" name=\"reference\" size=\"90\" value=\"$form->reference\" alt=\"reference\" /><br />";\r
+ ?>\r
+ </td>\r
+ </tr>\r
+ <tr valign="top">\r
+ <td align="right" nowrap="nowrap">\r
+ <img src="<?php echo $CFG->wwwroot.'/mod/resource/type/repository/hive/hp-footer-hive-powered.gif' ?>" align="top" />\r
+ </td>\r
+ <td>\r
+ <?php\r
+ $options = 'menubar,location,toolbar,scrollbars,resizable,width=750,height=500';\r
+ button_to_popup_window ('/mod/resource/type/repository/hive/openlitebrowse.php',\r
+ 'LiteBrowse', 'Browse for content in Hive', 500, 750,\r
+ 'Browse for content in the HarvestRoad Hive repository', $options);\r
+ button_to_popup_window ('/mod/resource/type/repository/hive/openlitesearch.php',\r
+ 'LiteSearch', 'Search for content in Hive ', 500, 750,\r
+ 'Search for content in the HarvestRoad Hive repository', $options);\r
+ helpbutton("hive", "HarvestRoad Hive", "resource/type", true);\r
+ ?>\r
+ </td>\r
+</tr>\r
+\r
+<tr><td colspan="2"><hr /></td></tr>\r
+\r
+<tr>\r
+ <td align="right"><b><?php print_string("display", "resource") ?>:</b></td>\r
+ <td>\r
+ <input type="button" value="hide settings" id="windowsettingsbutton" onclick="javascript: return showhide('windowsettings');" />\r
+ <input type="hidden" name="windowsettingspref" id="windowsettingspref" \r
+ value="<?php echo get_user_preferences('resource_windowsettingspref', $CFG->resource_windowsettings); ?>" />\r
+ <?php helpbutton("window", get_string("display", "resource"), "resource", true) ?>\r
+ </td>\r
+</tr>\r
+<tr><td colspan="2">\r
+\r
+ <div id="windowsettings">\r
+\r
+<table align="center">\r
+\r
+\r
+<tr valign="top">\r
+\r
+ <td colspan="2">\r
+ <script type="text/javascript">\r
+ var popupitems = [<?php echo $popupoptions; ?>];\r
+ var frameitem = [<?php echo $frameoption; ?>];\r
+ var allitems = [<?php echo $alloptions; ?>];\r
+ </script>\r
+ <input type="radio" name="windowpopup" value="0" alt="<?php print_string('pagewindow', 'resource') ?>" <?php echo ($windowtype != "popup") ? "checked=\"checked\"" : "" ?> \r
+ onclick="lockoptions('form', 'windowpopup[0]', frameitem); \r
+ return lockoptions('form', 'windowpopup[1]', popupitems);" />\r
+ <b title="<?php print_string("pagedisplay", "resource") ?>"><?php print_string("pagewindow", "resource") ?></b>\r
+ <blockquote>\r
+ <input type="hidden" name="hframepage" value="0" />\r
+ <input type="checkbox" name="framepage" value="1" <?php echo ($form->options == "frame") ? "checked=\"checked\"" : "" ?> alt="<?php print_string('frameifpossible', 'resource') ?>" />\r
+ <?php print_string("frameifpossible", "resource") ?>\r
+ </blockquote>\r
+ </td>\r
+</tr>\r
+\r
+<tr valign="top">\r
+ \r
+ <td colspan="2">\r
+ <input name="windowpopup" type="radio" value="1" alt="<?php p($strnewwindow)?>" <?php echo ($windowtype == "popup") ? "checked=\"checked\"" : "" ?>\r
+ onclick="lockoptions('form', 'windowpopup[0]', frameitem); \r
+ return lockoptions('form', 'windowpopup[1]', popupitems);" />\r
+ <b title="<?php p($strnewwindowopen) ?>"><?php p($strnewwindow) ?></b>\r
+ <blockquote>\r
+ <?php\r
+ foreach ($window as $name => $value) {\r
+ if ($name == "height" or $name == "width") {\r
+ continue;\r
+ }\r
+ echo "<input name=\"h$name\" type=\"hidden\" value=\"0\" />";\r
+ echo "<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." alt=\"$name\" />";\r
+ $stringname = "str$name";\r
+ echo $$stringname."<br />";\r
+ }\r
+ ?>\r
+\r
+ <input name="hwidth" type="hidden" value="0" />\r
+ <input name="width" type="text" size="4" value="<?php p($window->width) ?>" alt="<?php p($strwidth) ?>" />\r
+ <?php p($strwidth) ?><br />\r
+\r
+ <input name="hheight" type="hidden" value="0" />\r
+ <input name="height" type="text" size="4" value="<?php p($window->height) ?>" alt="<?php p($strheight) ?>" />\r
+ <?php p($strheight) ?><br />\r
+ <?php\r
+ if ($windowtype == "page") {\r
+ echo "<script type=\"text/javascript\">";\r
+ echo "lockoptions('form','windowpopup[1]', popupitems);";\r
+ echo "</script>";\r
+ } else {\r
+ echo "<script type=\"text/javascript\">";\r
+ echo "lockoptions('form','windowpopup[0]', frameitem);";\r
+ echo "</script>";\r
+ }\r
+ ?>\r
+ </blockquote>\r
+ </td>\r
+</tr>\r
+\r
+</table>\r
+\r
+ </div>\r
+\r
+</td></tr>\r
+\r
+<tr>\r
+ <td align="right"><b><?php print_string("parameters", "resource") ?>:</b></td>\r
+ <td>\r
+ <input type="button" value="hide settings" id="parametersettingsbutton" onclick="javascript: return showhide('parametersettings');" />\r
+ <input type="hidden" name="parametersettingspref" id="parametersettingspref" \r
+ value="<?php echo get_user_preferences('resource_parametersettingspref', $CFG->resource_parametersettings); ?>" />\r
+ <?php helpbutton("parameters", get_string("parameters", "resource"), "resource", true) ?>\r
+ </td>\r
+</tr>\r
+<tr><td colspan="2">\r
+\r
+ <div id="parametersettings">\r
+\r
+<table align="center">\r
+\r
+ <tr>\r
+ <td align="center"><?php print_string("parameter", "resource") ?></td>\r
+ <td align="center"><?php print_string("variablename", "resource") ?></td>\r
+ </tr>\r
+\r
+<?php\r
+\r
+for ($i=0; $i < $this->maxparameters; $i++) {\r
+ echo "<tr>\n";\r
+ echo "<td valign=\"top\">\n";\r
+ echo "<select name=\"parameter$i\">\n";\r
+ echo "<option value=\"-\">-- ".get_string('chooseparameter', 'resource')." --</option>\n";\r
+ foreach ($this->parameters as $field=>$fieldarr) {\r
+ if ($fieldarr['value'] === "optgroup") {\r
+ echo "<optgroup label=\"{$fieldarr['langstr']}\">\n";\r
+ } elseif ($fieldarr['value'] === "/optgroup") {\r
+ echo "</optgroup>\n";\r
+ } else {\r
+ echo "<option value=\"$field\"";\r
+ if ($alltextfield[$i]['parameter'] == $field) {\r
+ echo " selected=\"selected\"";\r
+ }\r
+ echo ">{$fieldarr['langstr']}</option>\n";\r
+ }\r
+ }\r
+ echo "</select>\n";\r
+ echo "</td>\n";\r
+ echo "<td valign=\"top\">\n";\r
+ echo "<input type=\"text\" name=\"parse$i\" value=\"{$alltextfield[$i]['parse']}\" alt=\"parameter$i\"/>\n";\r
+ echo "</td>\n";\r
+ echo "</tr>\n";\r
+}\r
+\r
+?>\r
+\r
+\r
+</table>\r
+ \r
+ </div>\r
+\r
+\r
+<script language="javascript" type="text/javascript">\r
+ showhide('parametersettings', true);\r
+ showhide('windowsettings', true);\r
+</script>\r
+\r
+\r
+</td></tr>\r
+\r
+<?php print_visible_setting($form); ?>\r
-<?php // $Id$
-
-/**
-* Extend the base resource class for repository resources
-*
-* Extend the base resource class for respoitory resources
-*
-*/
-class resource_repository extends resource_base {
-
-function resource_repository($cmid=0) {
- parent::resource_base($cmid);
-}
-
-var $parameters;
-var $maxparameters = 5;
-
-
-/**
-* Sets the parameters property of the extended class
-*
-* Sets the parameters property of the extended repository resource class
-*
-* @param USER global object
-* @param CFG global object
-*/
-function set_parameters() {
- global $USER, $CFG;
-
- if (! empty($this->course->lang)) {
- $CFG->courselang = $this->course->lang;
- }
-
- if (empty($USER->id)) { // No need to set up parameters
- $this->parameters = array();
- return;
- }
-
- $site = get_site();
-
- $this->parameters = array(
-
- 'label1' => array('langstr' => get_string('user'),
- 'value' => 'optgroup'),
-
- 'userid' => array('langstr' => 'id',
- 'value' => $USER->id),
- 'userusername' => array('langstr' => get_string('username'),
- 'value' => $USER->username),
- 'userpassword' => array('langstr' => get_string('password'),
- 'value' => $USER->password),
- 'useridnumber' => array('langstr' => get_string('idnumber'),
- 'value' => $USER->idnumber),
- 'userfirstname' => array('langstr' => get_string('firstname'),
- 'value' => $USER->firstname),
- 'userlastname' => array('langstr' => get_string('lastname'),
- 'value' => $USER->lastname),
- 'userfullname' => array('langstr' => get_string('fullname'),
- 'value' => fullname($USER)),
- 'useremail' => array('langstr' => get_string('email'),
- 'value' => $USER->email),
- 'usericq' => array('langstr' => get_string('icqnumber'),
- 'value' => $USER->icq),
- 'userphone1' => array('langstr' => get_string('phone').' 1',
- 'value' => $USER->phone1),
- 'userphone2' => array('langstr' => get_string('phone').' 2',
- 'value' => $USER->phone2),
- 'userinstitution' => array('langstr' => get_string('institution'),
- 'value' => $USER->institution),
- 'userdepartment' => array('langstr' => get_string('department'),
- 'value' => $USER->department),
- 'useraddress' => array('langstr' => get_string('address'),
- 'value' => $USER->address),
- 'usercity' => array('langstr' => get_string('city'),
- 'value' => $USER->city),
- 'usertimezone' => array('langstr' => get_string('timezone'),
- 'value' => get_user_timezone_offset()),
- 'userurl' => array('langstr' => get_string('webpage'),
- 'value' => $USER->url),
-
- 'label2' => array('langstr' => "",
- 'value' =>'/optgroup'),
- 'label3' => array('langstr' => get_string('course'),
- 'value' => 'optgroup'),
-
- 'courseid' => array('langstr' => 'id',
- 'value' => $this->course->id),
- 'coursefullname' => array('langstr' => get_string('fullname'),
- 'value' => $this->course->fullname),
- 'courseshortname' => array('langstr' => get_string('shortname'),
- 'value' => $this->course->shortname),
- 'courseidnumber' => array('langstr' => get_string('idnumber'),
- 'value' => $this->course->idnumber),
- 'coursesummary' => array('langstr' => get_string('summary'),
- 'value' => $this->course->summary),
- 'courseformat' => array('langstr' => get_string('format'),
- 'value' => $this->course->format),
- 'courseteacher' => array('langstr' => get_string('wordforteacher'),
- 'value' => $this->course->teacher),
- 'courseteachers' => array('langstr' => get_string('wordforteachers'),
- 'value' => $this->course->teachers),
- 'coursestudent' => array('langstr' => get_string('wordforstudent'),
- 'value' => $this->course->student),
- 'coursestudents' => array('langstr' => get_string('wordforstudents'),
- 'value' => $this->course->students),
-
- 'label4' => array('langstr' => "",
- 'value' =>'/optgroup'),
- 'label5' => array('langstr' => get_string('miscellaneous'),
- 'value' => 'optgroup'),
-
- 'lang' => array('langstr' => get_string('preferredlanguage'),
- 'value' => current_language()),
- 'sitename' => array('langstr' => get_string('fullsitename'),
- 'value' => $site->fullname),
- 'serverurl' => array('langstr' => get_string('serverurl', 'resource', $CFG),
- 'value' => $CFG->wwwroot),
- 'currenttime' => array('langstr' => get_string('time'),
- 'value' => time()),
- 'encryptedcode' => array('langstr' => get_string('encryptedcode'),
- 'value' => $this->set_encrypted_parameter()),
-
- 'label6' => array('langstr' => "",
- 'value' =>'/optgroup')
- );
-
-}
-
-
-/**
-* Add new instance of repository resource
-*
-* Create alltext field before calling base class function.
-*
-* @param resource object
-*/
-function add_instance($resource) {
- $optionlist = array();
-
- for ($i = 0; $i < $this->maxparameters; $i++) {
- $parametername = "parameter$i";
- $parsename = "parse$i";
- if (!empty($resource->$parsename) and $resource->$parametername != "-") {
- $optionlist[] = $resource->$parametername."=".$resource->$parsename;
- }
- }
-
- $resource->alltext = implode(',', $optionlist);
-
- return parent::add_instance($resource);
-}
-
-
-/**
-* Update instance of repository resource
-*
-* Create alltext field before calling base class function.
-*
-* @param resource object
-*/
-function update_instance($resource) {
- $optionlist = array();
-
- for ($i = 0; $i < $this->maxparameters; $i++) {
- $parametername = "parameter$i";
- $parsename = "parse$i";
- if (!empty($resource->$parsename) and $resource->$parametername != "-") {
- $optionlist[] = $resource->$parametername."=".$resource->$parsename;
- }
- }
-
- $resource->alltext = implode(',', $optionlist);
-
- return parent::update_instance($resource);
-}
-
-
-/**
-* Display the repository resource
-*
-* Displays a repository resource embedded, in a frame, or in a popup.
-* Output depends on type of file resource.
-*
-* @param CFG global object
-*/
-function display() {
- global $CFG, $THEME, $SESSION;
-
-/// Set up generic stuff first, including checking for access
- parent::display();
-
-/// Set up some shorthand variables
- $cm = $this->cm;
- $course = $this->course;
- $resource = $this->resource;
-
-
- $this->set_parameters(); // set the parameters array
-
-///////////////////////////////////////////////
-
- /// Possible display modes are:
- /// File displayed in a frame in a normal window
- /// File displayed embedded in a normal page
- /// File displayed in a popup window
- /// File displayed emebedded in a popup window
-
-
- /// First, find out what sort of file we are dealing with.
- require_once($CFG->libdir.'/filelib.php');
-
- $querystring = '';
- $resourcetype = '';
- $embedded = false;
- $mimetype = mimeinfo("type", $resource->reference);
- $pagetitle = strip_tags($course->shortname.': '.format_string($resource->name));
-
- if ($resource->options != "frame") {
- if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image
- $resourcetype = "image";
- $embedded = true;
-
- } else if ($mimetype == "audio/mp3") { // It's an MP3 audio file
- $resourcetype = "mp3";
- $embedded = true;
-
- } else if (substr($mimetype, 0, 10) == "video/x-ms") { // It's a Media Player file
- $resourcetype = "mediaplayer";
- $embedded = true;
-
- } else if ($mimetype == "video/quicktime") { // It's a Quicktime file
- $resourcetype = "quicktime";
- $embedded = true;
-
- } else if ($mimetype == "text/html") { // It's a web page
- $resourcetype = "html";
- }
- }
-
-
-
-/// Form the parse string
- if (!empty($resource->alltext)) {
- $querys = array();
- $parray = explode(',', $resource->alltext);
- foreach ($parray as $fieldstring) {
- $field = explode('=', $fieldstring);
- $querys[] = urlencode($field[1]).'='.urlencode($this->parameters[$field[0]]['value']);
- }
- $querystring = implode('&', $querys);
- }
-
-
- /// Set up some variables
-
- $inpopup = !empty($_GET["inpopup"]);
-
-
- $fullurl = $CFG->hiveprotocol .'://'. $CFG->hivehost .':'. $CFG->hiveport .''. $CFG->hivepath . '?'. $resource->reference . '&HIVE_SESSION='.$SESSION->HIVE_SESSION;
-
- if (!empty($querystring)) {
- $urlpieces = parse_url($resource->reference);
- if (empty($urlpieces['query'])) {
- $fullurl .= '?'.$querystring;
- } else {
- $fullurl .= '&'.$querystring;
- }
- }
-
- /// MW check that the HIVE_SESSION is there
- if (empty($SESSION->HIVE_SESSION)) {
- if ($inpopup) {
- print_header($pagetitle, $course->fullname);
- } else {
- print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
- }
- notify('You do not have access to HarvestRoad Hive. This resource is unavailable.');
- if ($inpopup) {
- close_window_button();
- }
- print_footer('none');
- die;
- }
- /// MW END
-
-
- /// Print a notice and redirect if we are trying to access a file on a local file system
- /// and the config setting has been disabled
- if (!$CFG->resource_allowlocalfiles and (strpos($resource->reference, RESOURCE_LOCALPATH) === 0)) {
- if ($inpopup) {
- print_header($pagetitle, $course->fullname);
- } else {
- print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
- }
- notify(get_string('notallowedlocalfileaccess', 'resource', ''));
- if ($inpopup) {
- close_window_button();
- }
- print_footer('none');
- die;
- }
-
-
- /// Check whether this is supposed to be a popup, but was called directly
-
- if ($resource->popup and !$inpopup) { /// Make a page and a pop-up window
-
- print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
-
-
- echo "\n<script language=\"javascript\" type=\"text/javascript\">";
- echo "\n<!--\n";
- echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
- echo "\n-->\n";
- echo '</script>';
-
- if (trim(strip_tags($resource->summary))) {
- $formatoptions->noclean = true;
- print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
- }
-
- $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
-
- echo "<p> </p>";
- echo '<p align="center">';
- print_string('popupresource', 'resource');
- echo '<br />';
- print_string('popupresourcelink', 'resource', $link);
- echo "</p>";
-
- print_footer($course);
- exit;
- }
-
-
- /// Now check whether we need to display a frameset
-
- if (empty($_GET['frameset']) and !$embedded and !$inpopup and $resource->options == "frame") {
- echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
- echo "<html dir=\"ltr\">\n";
- echo '<head>';
- echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />';
- echo "<title>{$course->shortname}: ".strip_tags(format_string($resource->name,true))."</title></head>\n";
- echo "<frameset rows=\"$CFG->resource_framesize,*\">";
- echo "<frame src=\"view.php?id={$cm->id}&type={$resource->type}&frameset=top\" />";
- if (!empty($localpath)) { // Show it like this so we interpose some HTML
- echo "<frame src=\"view.php?id={$cm->id}&type={$resource->type}&inpopup=true\" />";
- } else {
- echo "<frame src=\"$fullurl\" />";
- }
- echo "</frameset>";
- echo "</html>";
- exit;
- }
-
-
- /// We can only get here once per resource, so add an entry to the log
-
- add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
-
-
- /// If we are in a frameset, just print the top of it
-
- if (!empty($_GET['frameset']) and $_GET['frameset'] == "top") {
- print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
-
- $options->para = false;
- echo '<div class="summary">'.format_text($resource->summary, FORMAT_HTML, $options).'</div>';
- if (!empty($localpath)) { // Show some help
- echo '<div align="right" class="helplink">';
- link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
- echo '</div>';
- }
- echo '</body></html>';
- exit;
- }
-
-
- /// Display the actual resource
-
- if ($embedded) { // Display resource embedded in page
- $strdirectlink = get_string("directlink", "resource");
-
- if ($inpopup) {
- print_header($pagetitle);
- } else {
- print_header($pagetitle, $course->fullname, "$this->navigation <a title=\"$strdirectlink\" target=\"$CFG->framename\" href=\"$fullurl\"> ".format_string($resource->name,true)."</a>", "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "self"));
-
- }
-
- if ($resourcetype == "image") {
- echo "<center><p>";
- echo "<img title=\"".strip_tags(format_string($resource->name,true))."\" class=\"resourceimage\" src=\"$fullurl\" alt=\"\" />";
- echo "</p></center>";
-
- } else if ($resourcetype == "mp3") {
- if (!empty($THEME->resource_mp3player_colors)) {
- $c = $THEME->resource_mp3player_colors; // You can set this up in your theme/xxx/config.php
- } else {
- $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
- 'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'.
- 'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes';
- }
- $c .= '&volText='.get_string('vol', 'resource').'&panText='.get_string('pan','resource');
- $c = htmlentities($c);
- echo '<div class="mp3player" align="center">';
- echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
- echo ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
- echo ' width="600" height="70" id="mp3player" align="">';
- echo '<param name="movie" value="'.$CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.$fullurl.'">';
- echo '<param name="quality" value="high">';
- echo '<param name="bgcolor" value="#333333">';
- echo '<param name="flashvars" value="'.$c.'&" />';
- echo '<embed src="'.$CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.$fullurl.'" ';
- echo ' quality="high" bgcolor="#333333" width="600" height="70" name="mp3player" ';
- echo ' type="application/x-shockwave-flash" ';
- echo ' flashvars="'.$c.'&" ';
- echo ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
- echo '</embed>';
- echo '</object>';
- echo '</div>';
-
-
- } else if ($resourcetype == "mediaplayer") {
- echo "<center><p>";
- echo '<object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';
- echo ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
- echo ' standby="Loading Microsoft® Windows® Media Player components..." ';
- echo ' id="msplayer" align="" type="application/x-oleobject">';
- echo "<param name=\"Filename\" value=\"$fullurl\">";
- echo '<param name="ShowControls" value="true" />';
- echo '<param name="AutoRewind" value="true" />';
- echo '<param name="AutoStart" value="true" />';
- echo '<param name="Autosize" value="true" />';
- echo '<param name="EnableContextMenu" value="true" />';
- echo '<param name="TransparentAtStart" value="false" />';
- echo '<param name="AnimationAtStart" value="false" />';
- echo '<param name="ShowGotoBar" value="false" />';
- echo '<param name="EnableFullScreenControls" value="true" />';
- echo "\n<embed src=\"$fullurl\" name=\"msplayer\" type=\"$mimetype\" ";
- echo ' ShowControls="1" AutoRewind="1" AutoStart="1" Autosize="0" EnableContextMenu="1"';
- echo ' TransparentAtStart="0" AnimationAtStart="0" ShowGotoBar="0" EnableFullScreenControls="1"';
- echo ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/">';
- echo '</embed>';
- echo '</object>';
- echo "</p></center>";
-
- } else if ($resourcetype == "quicktime") {
-
- echo "<center><p>";
- echo '<object classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
- echo ' codebase="http://www.apple.com/qtactivex/qtplugin.cab" ';
- echo ' height="450" width="600"';
- echo ' id="quicktime" align="" type="application/x-oleobject">';
- echo "<param name=\"src\" value=\"$fullurl\" />";
- echo '<param name="autoplay" value="true" />';
- echo '<param name="loop" value="true" />';
- echo '<param name="controller" value="true" />';
- echo '<param name="scale" value="aspect" />';
- echo "\n<embed src=\"$fullurl\" name=\"quicktime\" type=\"$mimetype\" ";
- echo ' height="450" width="600" scale="aspect"';
- echo ' autoplay="true" controller="true" loop="true" ';
- echo ' pluginspage="http://quicktime.apple.com/">';
- echo '</embed>';
- echo '</object>';
- echo "</p></center>";
- }
-
- if (trim($resource->summary)) {
- $formatoptions->noclean = true;
- print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
- }
-
- if ($inpopup) {
- echo "<center><p>(<a href=\"$fullurl\">$strdirectlink</a>)</p></center>";
- } else {
- print_spacer(20,20);
- print_footer($course);
- }
-
- } else { // Display the resource on it's own
- if (!empty($localpath)) { // Show a link to help work around browser security
- echo '<div align="right" class="helplink">';
- link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
- echo '</div>';
- echo "<center><p>(<a href=\"$fullurl\">$fullurl</a>)</p></center>";
- }
- redirect($fullurl);
- }
-
-}
-
-
-
-/**
-* Setup a new repository resource
-*
-* Display a form to create a new or edit an existing repository resource
-*
-* @param form object
-* @param CFG global object
-* @param usehtmleditor global integer
-* @param RESOURCE_WINDOW_OPTIONS global array
-*/
-function setup($form) {
- global $CFG, $usehtmleditor, $RESOURCE_WINDOW_OPTIONS;
-
- parent::setup($form);
-
- $this->set_parameters(); // set the parameter array for the form
-
-
- $strfilename = get_string("location");
- $strnote = get_string("note", "resource");
- $strchooseafile = get_string("chooseafile", "resource");
- $strnewwindow = get_string("newwindow", "resource");
- $strnewwindowopen = get_string("newwindowopen", "resource");
- $strsearch = get_string("searchweb", "resource");
-
- foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
- $stringname = "str$optionname";
- $$stringname = get_string("new$optionname", "resource");
- $window->$optionname = "";
- $jsoption[] = "\"$optionname\"";
- }
-
- $frameoption = "\"framepage\"";
- $popupoptions = implode(",", $jsoption);
- $jsoption[] = $frameoption;
- $alloptions = implode(",", $jsoption);
-
-
-
- if ($form->instance) { // Re-editing
- if (!$form->popup) {
- $windowtype = "page"; // No popup text => in page
- foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
- $defaultvalue = "resource_popup$optionname";
- $window->$optionname = $CFG->$defaultvalue;
- }
- } else {
- $windowtype = "popup";
- $rawoptions = explode(',', $form->popup);
- foreach ($rawoptions as $rawoption) {
- $option = explode('=', trim($rawoption));
- $optionname = $option[0];
- $optionvalue = $option[1];
- if ($optionname == 'height' or $optionname == 'width') {
- $window->$optionname = $optionvalue;
- } else if ($optionvalue) {
- $window->$optionname = 'checked="checked"';
- }
- }
- }
- } else {
- foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
- $defaultvalue = "resource_popup$optionname";
-
- if ($optionname == 'height' or $optionname == 'width') {
- $window->$optionname = $CFG->$defaultvalue;
- } else if ($CFG->$defaultvalue) {
- $window->$optionname = 'checked="checked"';
- }
- }
-
- $windowtype = ($CFG->resource_popup) ? 'popup' : 'page';
- if (empty($form->options)) {
- $form->options = 'frame';
- $form->reference = $CFG->resource_defaulturl;
- }
- }
- if (empty($form->reference)) {
- $form->reference = $CFG->resource_defaulturl;
- }
-
-
-/// set the 5 parameter defaults
- $alltextfield = array();
- for ($i = 0; $i < $this->maxparameters; $i++) {
- $alltextfield[] = array('parameter' => '',
- 'parse' => '');
- }
- /// load up any stored parameters
- if (!empty($form->alltext)) {
- $parray = explode(',', $form->alltext);
- foreach ($parray as $key => $fieldstring) {
- $field = explode('=', $fieldstring);
- $alltextfield[$key]['parameter'] = $field[0];
- $alltextfield[$key]['parse'] = $field[1];
- }
- }
-
-
- include("$CFG->dirroot/mod/resource/type/repository/repository.html");
-
- parent::setup_end();
-}
-
-//backwards compatible with existing resources
-function set_encrypted_parameter() {
- global $CFG;
-
- if (!empty($this->resource->reference) && file_exists($CFG->dirroot ."/mod/resource//type/file/externserverfile.php")) {
- include $CFG->dirroot ."/mod/resource/type/file/externserverfile.php";
- if (function_exists(extern_server_file)) {
- return extern_server_file($this->resource->reference);
- }
- }
- return md5($_SERVER['REMOTE_ADDR'].$CFG->resource_secretphrase);
-}
-
-}
-
-?>
+<?php // $Id$\r
+\r
+/**\r
+* Extend the base resource class for repository resources\r
+*\r
+* Extend the base resource class for respoitory resources\r
+*\r
+*/\r
+class resource_repository extends resource_base {\r
+\r
+function resource_repository($cmid=0) {\r
+ parent::resource_base($cmid);\r
+}\r
+\r
+var $parameters;\r
+var $maxparameters = 5;\r
+\r
+\r
+/**\r
+* Sets the parameters property of the extended class\r
+*\r
+* Sets the parameters property of the extended repository resource class\r
+*\r
+* @param USER global object\r
+* @param CFG global object\r
+*/\r
+function set_parameters() {\r
+ global $USER, $CFG;\r
+\r
+ if (! empty($this->course->lang)) {\r
+ $CFG->courselang = $this->course->lang;\r
+ }\r
+\r
+ if (empty($USER->id)) { // No need to set up parameters\r
+ $this->parameters = array();\r
+ return;\r
+ }\r
+\r
+ $site = get_site();\r
+\r
+ $this->parameters = array(\r
+\r
+ 'label1' => array('langstr' => get_string('user'),\r
+ 'value' => 'optgroup'),\r
+\r
+ 'userid' => array('langstr' => 'id',\r
+ 'value' => $USER->id),\r
+ 'userusername' => array('langstr' => get_string('username'),\r
+ 'value' => $USER->username),\r
+ 'userpassword' => array('langstr' => get_string('password'),\r
+ 'value' => $USER->password),\r
+ 'useridnumber' => array('langstr' => get_string('idnumber'),\r
+ 'value' => $USER->idnumber),\r
+ 'userfirstname' => array('langstr' => get_string('firstname'),\r
+ 'value' => $USER->firstname),\r
+ 'userlastname' => array('langstr' => get_string('lastname'),\r
+ 'value' => $USER->lastname),\r
+ 'userfullname' => array('langstr' => get_string('fullname'),\r
+ 'value' => fullname($USER)),\r
+ 'useremail' => array('langstr' => get_string('email'),\r
+ 'value' => $USER->email),\r
+ 'usericq' => array('langstr' => get_string('icqnumber'),\r
+ 'value' => $USER->icq),\r
+ 'userphone1' => array('langstr' => get_string('phone').' 1',\r
+ 'value' => $USER->phone1),\r
+ 'userphone2' => array('langstr' => get_string('phone').' 2',\r
+ 'value' => $USER->phone2),\r
+ 'userinstitution' => array('langstr' => get_string('institution'),\r
+ 'value' => $USER->institution),\r
+ 'userdepartment' => array('langstr' => get_string('department'),\r
+ 'value' => $USER->department),\r
+ 'useraddress' => array('langstr' => get_string('address'),\r
+ 'value' => $USER->address),\r
+ 'usercity' => array('langstr' => get_string('city'),\r
+ 'value' => $USER->city),\r
+ 'usertimezone' => array('langstr' => get_string('timezone'),\r
+ 'value' => get_user_timezone_offset()),\r
+ 'userurl' => array('langstr' => get_string('webpage'),\r
+ 'value' => $USER->url),\r
+\r
+ 'label2' => array('langstr' => "",\r
+ 'value' =>'/optgroup'),\r
+ 'label3' => array('langstr' => get_string('course'),\r
+ 'value' => 'optgroup'),\r
+\r
+ 'courseid' => array('langstr' => 'id',\r
+ 'value' => $this->course->id),\r
+ 'coursefullname' => array('langstr' => get_string('fullname'),\r
+ 'value' => $this->course->fullname),\r
+ 'courseshortname' => array('langstr' => get_string('shortname'),\r
+ 'value' => $this->course->shortname),\r
+ 'courseidnumber' => array('langstr' => get_string('idnumber'),\r
+ 'value' => $this->course->idnumber),\r
+ 'coursesummary' => array('langstr' => get_string('summary'),\r
+ 'value' => $this->course->summary),\r
+ 'courseformat' => array('langstr' => get_string('format'),\r
+ 'value' => $this->course->format),\r
+ 'courseteacher' => array('langstr' => get_string('wordforteacher'),\r
+ 'value' => $this->course->teacher),\r
+ 'courseteachers' => array('langstr' => get_string('wordforteachers'),\r
+ 'value' => $this->course->teachers),\r
+ 'coursestudent' => array('langstr' => get_string('wordforstudent'),\r
+ 'value' => $this->course->student),\r
+ 'coursestudents' => array('langstr' => get_string('wordforstudents'),\r
+ 'value' => $this->course->students),\r
+\r
+ 'label4' => array('langstr' => "",\r
+ 'value' =>'/optgroup'),\r
+ 'label5' => array('langstr' => get_string('miscellaneous'),\r
+ 'value' => 'optgroup'),\r
+\r
+ 'lang' => array('langstr' => get_string('preferredlanguage'),\r
+ 'value' => current_language()),\r
+ 'sitename' => array('langstr' => get_string('fullsitename'),\r
+ 'value' => $site->fullname),\r
+ 'serverurl' => array('langstr' => get_string('serverurl', 'resource', $CFG),\r
+ 'value' => $CFG->wwwroot),\r
+ 'currenttime' => array('langstr' => get_string('time'),\r
+ 'value' => time()),\r
+ 'encryptedcode' => array('langstr' => get_string('encryptedcode'),\r
+ 'value' => $this->set_encrypted_parameter()),\r
+\r
+ 'label6' => array('langstr' => "",\r
+ 'value' =>'/optgroup')\r
+ );\r
+\r
+}\r
+\r
+\r
+/**\r
+* Add new instance of repository resource\r
+*\r
+* Create alltext field before calling base class function.\r
+*\r
+* @param resource object\r
+*/\r
+function add_instance($resource) {\r
+ $optionlist = array();\r
+\r
+ for ($i = 0; $i < $this->maxparameters; $i++) {\r
+ $parametername = "parameter$i";\r
+ $parsename = "parse$i";\r
+ if (!empty($resource->$parsename) and $resource->$parametername != "-") {\r
+ $optionlist[] = $resource->$parametername."=".$resource->$parsename;\r
+ }\r
+ }\r
+\r
+ $resource->alltext = implode(',', $optionlist);\r
+\r
+ return parent::add_instance($resource);\r
+}\r
+\r
+\r
+/**\r
+* Update instance of repository resource\r
+*\r
+* Create alltext field before calling base class function.\r
+*\r
+* @param resource object\r
+*/\r
+function update_instance($resource) {\r
+ $optionlist = array();\r
+\r
+ for ($i = 0; $i < $this->maxparameters; $i++) {\r
+ $parametername = "parameter$i";\r
+ $parsename = "parse$i";\r
+ if (!empty($resource->$parsename) and $resource->$parametername != "-") {\r
+ $optionlist[] = $resource->$parametername."=".$resource->$parsename;\r
+ }\r
+ }\r
+\r
+ $resource->alltext = implode(',', $optionlist);\r
+\r
+ return parent::update_instance($resource);\r
+}\r
+\r
+\r
+/**\r
+* Display the repository resource\r
+*\r
+* Displays a repository resource embedded, in a frame, or in a popup.\r
+* Output depends on type of file resource.\r
+*\r
+* @param CFG global object\r
+*/\r
+function display() {\r
+ global $CFG, $THEME, $SESSION;\r
+\r
+/// Set up generic stuff first, including checking for access\r
+ parent::display();\r
+\r
+/// Set up some shorthand variables\r
+ $cm = $this->cm;\r
+ $course = $this->course;\r
+ $resource = $this->resource;\r
+\r
+\r
+ $this->set_parameters(); // set the parameters array\r
+\r
+///////////////////////////////////////////////\r
+\r
+ /// Possible display modes are:\r
+ /// File displayed in a frame in a normal window\r
+ /// File displayed embedded in a normal page\r
+ /// File displayed in a popup window\r
+ /// File displayed emebedded in a popup window\r
+\r
+\r
+ /// First, find out what sort of file we are dealing with.\r
+ require_once($CFG->libdir.'/filelib.php');\r
+\r
+ $querystring = '';\r
+ $resourcetype = '';\r
+ $embedded = false;\r
+ $mimetype = mimeinfo("type", $resource->reference);\r
+ $pagetitle = strip_tags($course->shortname.': '.format_string($resource->name));\r
+\r
+ if ($resource->options != "frame") {\r
+ if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image\r
+ $resourcetype = "image";\r
+ $embedded = true;\r
+\r
+ } else if ($mimetype == "audio/mp3") { // It's an MP3 audio file\r
+ $resourcetype = "mp3";\r
+ $embedded = true;\r
+\r
+ } else if (substr($mimetype, 0, 10) == "video/x-ms") { // It's a Media Player file\r
+ $resourcetype = "mediaplayer";\r
+ $embedded = true;\r
+\r
+ } else if ($mimetype == "video/quicktime") { // It's a Quicktime file\r
+ $resourcetype = "quicktime";\r
+ $embedded = true;\r
+\r
+ } else if ($mimetype == "text/html") { // It's a web page\r
+ $resourcetype = "html";\r
+ }\r
+ }\r
+\r
+\r
+\r
+/// Form the parse string\r
+ if (!empty($resource->alltext)) {\r
+ $querys = array();\r
+ $parray = explode(',', $resource->alltext);\r
+ foreach ($parray as $fieldstring) {\r
+ $field = explode('=', $fieldstring);\r
+ $querys[] = urlencode($field[1]).'='.urlencode($this->parameters[$field[0]]['value']);\r
+ }\r
+ $querystring = implode('&', $querys);\r
+ }\r
+\r
+\r
+ /// Set up some variables\r
+\r
+ $inpopup = !empty($_GET["inpopup"]);\r
+ \r
+ $fullurl = $resource->reference. '&HIVE_SESSION='.$SESSION->HIVE_SESSION;\r
+ if (!empty($querystring)) {\r
+ $urlpieces = parse_url($resource->reference);\r
+ if (empty($urlpieces['query'])) {\r
+ $fullurl .= '?'.$querystring;\r
+ } else {\r
+ $fullurl .= '&'.$querystring;\r
+ }\r
+ }\r
+\r
+ /// MW check that the HIVE_SESSION is there\r
+ if (empty($SESSION->HIVE_SESSION)) {\r
+ if ($inpopup) {\r
+ print_header($pagetitle, $course->fullname);\r
+ } else {\r
+ print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));\r
+ }\r
+ notify('You do not have access to HarvestRoad Hive. This resource is unavailable.');\r
+ if ($inpopup) {\r
+ close_window_button();\r
+ }\r
+ print_footer('none');\r
+ die;\r
+ }\r
+ /// MW END\r
+\r
+\r
+ /// Print a notice and redirect if we are trying to access a file on a local file system\r
+ /// and the config setting has been disabled\r
+ if (!$CFG->resource_allowlocalfiles and (strpos($resource->reference, RESOURCE_LOCALPATH) === 0)) {\r
+ if ($inpopup) {\r
+ print_header($pagetitle, $course->fullname);\r
+ } else {\r
+ print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));\r
+ }\r
+ notify(get_string('notallowedlocalfileaccess', 'resource', ''));\r
+ if ($inpopup) {\r
+ close_window_button();\r
+ }\r
+ print_footer('none');\r
+ die;\r
+ }\r
+\r
+\r
+ /// Check whether this is supposed to be a popup, but was called directly\r
+\r
+ if ($resource->popup and !$inpopup) { /// Make a page and a pop-up window\r
+\r
+ print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));\r
+\r
+\r
+ echo "\n<script language=\"javascript\" type=\"text/javascript\">";\r
+ echo "\n<!--\n";\r
+ echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";\r
+ echo "\n-->\n";\r
+ echo '</script>';\r
+\r
+ if (trim(strip_tags($resource->summary))) {\r
+ $formatoptions->noclean = true;\r
+ print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");\r
+ }\r
+\r
+ $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";\r
+\r
+ echo "<p> </p>";\r
+ echo '<p align="center">';\r
+ print_string('popupresource', 'resource');\r
+ echo '<br />';\r
+ print_string('popupresourcelink', 'resource', $link);\r
+ echo "</p>";\r
+\r
+ print_footer($course);\r
+ exit;\r
+ }\r
+\r
+\r
+ /// Now check whether we need to display a frameset\r
+\r
+ if (empty($_GET['frameset']) and !$embedded and !$inpopup and $resource->options == "frame") {\r
+ echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";\r
+ echo "<html dir=\"ltr\">\n";\r
+ echo '<head>';\r
+ echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />';\r
+ echo "<title>{$course->shortname}: ".strip_tags(format_string($resource->name,true))."</title></head>\n";\r
+ echo "<frameset rows=\"$CFG->resource_framesize,*\">";\r
+ echo "<frame src=\"view.php?id={$cm->id}&type={$resource->type}&frameset=top\" />";\r
+ if (!empty($localpath)) { // Show it like this so we interpose some HTML\r
+ echo "<frame src=\"view.php?id={$cm->id}&type={$resource->type}&inpopup=true\" />";\r
+ } else {\r
+ echo "<frame src=\"$fullurl\" />";\r
+ }\r
+ echo "</frameset>";\r
+ echo "</html>";\r
+ exit;\r
+ }\r
+\r
+\r
+ /// We can only get here once per resource, so add an entry to the log\r
+\r
+ add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);\r
+\r
+\r
+ /// If we are in a frameset, just print the top of it\r
+\r
+ if (!empty($_GET['frameset']) and $_GET['frameset'] == "top") {\r
+ print_header($pagetitle, $course->fullname, "$this->navigation ".format_string($resource->name), "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));\r
+\r
+ $options->para = false;\r
+ echo '<div class="summary">'.format_text($resource->summary, FORMAT_HTML, $options).'</div>';\r
+ if (!empty($localpath)) { // Show some help\r
+ echo '<div align="right" class="helplink">';\r
+ link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));\r
+ echo '</div>';\r
+ }\r
+ echo '</body></html>';\r
+ exit;\r
+ }\r
+\r
+\r
+ /// Display the actual resource\r
+\r
+ if ($embedded) { // Display resource embedded in page\r
+ $strdirectlink = get_string("directlink", "resource");\r
+\r
+ if ($inpopup) {\r
+ print_header($pagetitle);\r
+ } else {\r
+ print_header($pagetitle, $course->fullname, "$this->navigation <a title=\"$strdirectlink\" target=\"$CFG->framename\" href=\"$fullurl\"> ".format_string($resource->name,true)."</a>", "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "self"));\r
+\r
+ }\r
+\r
+ if ($resourcetype == "image") {\r
+ echo "<center><p>";\r
+ echo "<img title=\"".strip_tags(format_string($resource->name,true))."\" class=\"resourceimage\" src=\"$fullurl\" alt=\"\" />";\r
+ echo "</p></center>";\r
+\r
+ } else if ($resourcetype == "mp3") {\r
+ if (!empty($THEME->resource_mp3player_colors)) {\r
+ $c = $THEME->resource_mp3player_colors; // You can set this up in your theme/xxx/config.php\r
+ } else {\r
+ $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.\r
+ 'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'.\r
+ 'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes';\r
+ }\r
+ $c .= '&volText='.get_string('vol', 'resource').'&panText='.get_string('pan','resource');\r
+ $c = htmlentities($c);\r
+ echo '<div class="mp3player" align="center">';\r
+ echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';\r
+ echo ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';\r
+ echo ' width="600" height="70" id="mp3player" align="">';\r
+ echo '<param name="movie" value="'.$CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.$fullurl.'">';\r
+ echo '<param name="quality" value="high">';\r
+ echo '<param name="bgcolor" value="#333333">';\r
+ echo '<param name="flashvars" value="'.$c.'&" />';\r
+ echo '<embed src="'.$CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.$fullurl.'" ';\r
+ echo ' quality="high" bgcolor="#333333" width="600" height="70" name="mp3player" ';\r
+ echo ' type="application/x-shockwave-flash" ';\r
+ echo ' flashvars="'.$c.'&" ';\r
+ echo ' pluginspage="http://www.macromedia.com/go/getflashplayer">';\r
+ echo '</embed>';\r
+ echo '</object>';\r
+ echo '</div>';\r
+\r
+\r
+ } else if ($resourcetype == "mediaplayer") {\r
+ echo "<center><p>";\r
+ echo '<object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';\r
+ echo ' codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';\r
+ echo ' standby="Loading Microsoft® Windows® Media Player components..." ';\r
+ echo ' id="msplayer" align="" type="application/x-oleobject">';\r
+ echo "<param name=\"Filename\" value=\"$fullurl\">";\r
+ echo '<param name="ShowControls" value="true" />';\r
+ echo '<param name="AutoRewind" value="true" />';\r
+ echo '<param name="AutoStart" value="true" />';\r
+ echo '<param name="Autosize" value="true" />';\r
+ echo '<param name="EnableContextMenu" value="true" />';\r
+ echo '<param name="TransparentAtStart" value="false" />';\r
+ echo '<param name="AnimationAtStart" value="false" />';\r
+ echo '<param name="ShowGotoBar" value="false" />';\r
+ echo '<param name="EnableFullScreenControls" value="true" />';\r
+ echo "\n<embed src=\"$fullurl\" name=\"msplayer\" type=\"$mimetype\" ";\r
+ echo ' ShowControls="1" AutoRewind="1" AutoStart="1" Autosize="0" EnableContextMenu="1"';\r
+ echo ' TransparentAtStart="0" AnimationAtStart="0" ShowGotoBar="0" EnableFullScreenControls="1"';\r
+ echo ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/">';\r
+ echo '</embed>';\r
+ echo '</object>';\r
+ echo "</p></center>";\r
+\r
+ } else if ($resourcetype == "quicktime") {\r
+\r
+ echo "<center><p>";\r
+ echo '<object classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';\r
+ echo ' codebase="http://www.apple.com/qtactivex/qtplugin.cab" ';\r
+ echo ' height="450" width="600"';\r
+ echo ' id="quicktime" align="" type="application/x-oleobject">';\r
+ echo "<param name=\"src\" value=\"$fullurl\" />";\r
+ echo '<param name="autoplay" value="true" />';\r
+ echo '<param name="loop" value="true" />';\r
+ echo '<param name="controller" value="true" />';\r
+ echo '<param name="scale" value="aspect" />';\r
+ echo "\n<embed src=\"$fullurl\" name=\"quicktime\" type=\"$mimetype\" ";\r
+ echo ' height="450" width="600" scale="aspect"';\r
+ echo ' autoplay="true" controller="true" loop="true" ';\r
+ echo ' pluginspage="http://quicktime.apple.com/">';\r
+ echo '</embed>';\r
+ echo '</object>';\r
+ echo "</p></center>";\r
+ }\r
+\r
+ if (trim($resource->summary)) {\r
+ $formatoptions->noclean = true;\r
+ print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");\r
+ }\r
+\r
+ if ($inpopup) {\r
+ echo "<center><p>(<a href=\"$fullurl\">$strdirectlink</a>)</p></center>";\r
+ } else {\r
+ print_spacer(20,20);\r
+ print_footer($course);\r
+ }\r
+\r
+ } else { // Display the resource on it's own\r
+ if (!empty($localpath)) { // Show a link to help work around browser security\r
+ echo '<div align="right" class="helplink">';\r
+ link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));\r
+ echo '</div>';\r
+ echo "<center><p>(<a href=\"$fullurl\">$fullurl</a>)</p></center>";\r
+ }\r
+ redirect($fullurl);\r
+ }\r
+\r
+}\r
+\r
+\r
+\r
+/**\r
+* Setup a new repository resource\r
+*\r
+* Display a form to create a new or edit an existing repository resource\r
+*\r
+* @param form object\r
+* @param CFG global object\r
+* @param usehtmleditor global integer\r
+* @param RESOURCE_WINDOW_OPTIONS global array\r
+*/\r
+function setup($form) {\r
+ global $CFG, $usehtmleditor, $RESOURCE_WINDOW_OPTIONS;\r
+\r
+ parent::setup($form);\r
+\r
+ $this->set_parameters(); // set the parameter array for the form\r
+\r
+\r
+ $strfilename = get_string("location");\r
+ $strnote = get_string("note", "resource");\r
+ $strchooseafile = get_string("chooseafile", "resource");\r
+ $strnewwindow = get_string("newwindow", "resource");\r
+ $strnewwindowopen = get_string("newwindowopen", "resource");\r
+ $strsearch = get_string("searchweb", "resource");\r
+\r
+ foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {\r
+ $stringname = "str$optionname";\r
+ $$stringname = get_string("new$optionname", "resource");\r
+ $window->$optionname = "";\r
+ $jsoption[] = "\"$optionname\"";\r
+ }\r
+\r
+ $frameoption = "\"framepage\"";\r
+ $popupoptions = implode(",", $jsoption);\r
+ $jsoption[] = $frameoption;\r
+ $alloptions = implode(",", $jsoption);\r
+\r
+\r
+\r
+ if ($form->instance) { // Re-editing\r
+ if (!$form->popup) {\r
+ $windowtype = "page"; // No popup text => in page\r
+ foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {\r
+ $defaultvalue = "resource_popup$optionname";\r
+ $window->$optionname = $CFG->$defaultvalue;\r
+ }\r
+ } else {\r
+ $windowtype = "popup";\r
+ $rawoptions = explode(',', $form->popup);\r
+ foreach ($rawoptions as $rawoption) {\r
+ $option = explode('=', trim($rawoption));\r
+ $optionname = $option[0];\r
+ $optionvalue = $option[1];\r
+ if ($optionname == 'height' or $optionname == 'width') {\r
+ $window->$optionname = $optionvalue;\r
+ } else if ($optionvalue) {\r
+ $window->$optionname = 'checked="checked"';\r
+ }\r
+ }\r
+ }\r
+ } else {\r
+ foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {\r
+ $defaultvalue = "resource_popup$optionname";\r
+\r
+ if ($optionname == 'height' or $optionname == 'width') {\r
+ $window->$optionname = $CFG->$defaultvalue;\r
+ } else if ($CFG->$defaultvalue) {\r
+ $window->$optionname = 'checked="checked"';\r
+ }\r
+ }\r
+\r
+ $windowtype = ($CFG->resource_popup) ? 'popup' : 'page';\r
+ if (empty($form->options)) {\r
+ $form->options = 'frame';\r
+ $form->reference = $CFG->resource_defaulturl;\r
+ }\r
+ }\r
+ if (empty($form->reference)) {\r
+ $form->reference = $CFG->resource_defaulturl;\r
+ }\r
+\r
+\r
+/// set the 5 parameter defaults\r
+ $alltextfield = array();\r
+ for ($i = 0; $i < $this->maxparameters; $i++) {\r
+ $alltextfield[] = array('parameter' => '',\r
+ 'parse' => '');\r
+ }\r
+ /// load up any stored parameters\r
+ if (!empty($form->alltext)) {\r
+ $parray = explode(',', $form->alltext);\r
+ foreach ($parray as $key => $fieldstring) {\r
+ $field = explode('=', $fieldstring);\r
+ $alltextfield[$key]['parameter'] = $field[0];\r
+ $alltextfield[$key]['parse'] = $field[1];\r
+ }\r
+ }\r
+\r
+\r
+ include("$CFG->dirroot/mod/resource/type/repository/repository.html");\r
+\r
+ parent::setup_end();\r
+}\r
+\r
+//backwards compatible with existing resources\r
+function set_encrypted_parameter() {\r
+ global $CFG;\r
+\r
+ if (!empty($this->resource->reference) && file_exists($CFG->dirroot ."/mod/resource//type/file/externserverfile.php")) {\r
+ include $CFG->dirroot ."/mod/resource/type/file/externserverfile.php";\r
+ if (function_exists(extern_server_file)) {\r
+ return extern_server_file($this->resource->reference);\r
+ }\r
+ }\r
+ return md5($_SERVER['REMOTE_ADDR'].$CFG->resource_secretphrase);\r
+}\r
+\r
+}\r
+\r
+?>\r