// section - the number of the section (eg week or topic)
// name - the name of the instance
// visible - is the instance visible or not
+// extra - contains extra string to include in any link
$mod = array();
$mod[$seq]->section = $section->section;
$mod[$seq]->name = urlencode(get_field($rawmods[$seq]->modname, "name", "id", $rawmods[$seq]->instance));
$mod[$seq]->visible = $rawmods[$seq]->visible;
+ $mod[$seq]->extra = "";
+
+ // This part is an ugly hack that doesn't belong here//
+ if ($mod[$seq]->mod == "resource") {
+ if ($resource = get_record("resource", "id", $rawmods[$seq]->instance)) {
+ if ($resource->type == 5 and $resource->alltext) {
+ $mod[$seq]->extra = urlencode("onClick=\"return ".
+ "openpopup('/mod/resource/view.php?id=".
+ $mod[$seq]->cm.
+ "','resource','$resource->alltext');\"");
+ }
+ }
+ }
}
}
}
" href=\"mod.php?moveto=$mod->id\">$strmovehere</a></font><br />\n";
}
$instancename = urldecode($modinfo[$modnumber]->name);
+ if (!empty($modinfo[$modnumber]->extra)) {
+ $extra = urldecode($modinfo[$modnumber]->extra);
+ } else {
+ $extra = "";
+ }
$link_css = $mod->visible ? "" : " class=\"dimmed\" ";
echo "<img src=\"$CFG->wwwroot/mod/$mod->modname/icon.gif\"".
" height=16 width=16 alt=\"$mod->modfullname\">".
- " <font size=2><a title=\"$mod->modfullname\" $link_css ".
+ " <font size=2><a title=\"$mod->modfullname\" $link_css $extra".
" href=\"$CFG->wwwroot/mod/$mod->modname/view.php?id=$mod->id\">$instancename</a></font>";
}
if (isediting($course->id)) {
document.form.message.value = text;\r
}\r
\r
-function openpopup(url,name,height,width) {\r
+function openpopup(url,name,options,fullscreen) {\r
fullurl = "<?php echo $CFG->wwwroot ?>" + url;\r
- options = "menubar=0,location=0,scrollbars,resizable,width="+width+",height="+height;\r
- windowobj = window.open(fullurl,name, options);\r
+ windowobj = window.open(fullurl,name,options);\r
+ if (fullscreen) {\r
+ windowobj.moveTo(0,0);\r
+ windowobj.resizeTo(screen.availWidth,screen.availHeight); \r
+ }\r
windowobj.focus();\r
+ return false;\r
}\r
\r
function copyrichtext(textname) { \r
}\r
echo " text = ' ' + text + ' ';\n";\r
echo " if ( $insertfield.createTextRange && $insertfield.caretPos) {\n";\r
- echo " var caretPos = $insertfield.caretPos;\n";\r
- echo " caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;\n";\r
+ echo " var caretPos = $insertfield.caretPos;\n";\r
+ echo " caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;\n";\r
echo " } else {\n";\r
- echo " $insertfield.value += text;\n";\r
+ echo " $insertfield.value += text;\n";\r
echo " }\n";\r
echo " $insertfield.focus();\n";\r
?>\r
}\r
\r
+function lockoptions(form, master, subitems) {\r
+ // subitems is an array of names of sub items\r
+ // requires that each item in subitems has a \r
+ // companion hidden item in the form with the \r
+ // same name but prefixed by "h"\r
+ if (eval("document."+form+"."+master+".checked")) {\r
+ for (i=0; i<subitems.length; i++) {\r
+ unlockoption(form, subitems[i]);\r
+ }\r
+ } else {\r
+ for (i=0; i<subitems.length; i++) {\r
+ lockoption(form, subitems[i]);\r
+ }\r
+ }\r
+ return(true);\r
+}\r
+function lockoption(form,item) {\r
+ eval("document."+form+"."+item+".disabled=true");/* IE thing */\r
+ eval("document."+form+".h"+item+".value=1");\r
+}\r
+function unlockoption(form,item) {\r
+ eval("document."+form+"."+item+".disabled=false");/* IE thing */\r
+ eval("document."+form+".h"+item+".value=0");\r
+}\r
+\r
<?php if ($focus) { echo "function setfocus() { document.$focus.focus() }\n"; } ?>\r
\r
// done hiding -->\r
}
-function link_to_popup_window ($url, $name="popup", $linkname="click here", $height=400, $width=500, $title="Popup window") {
+function link_to_popup_window ($url, $name="popup", $linkname="click here",
+ $height=400, $width=500, $title="Popup window") {
/// This will create a HTML link that will work on both
/// Javascript and non-javascript browsers.
/// Relies on the Javascript function openpopup in javascript.php
global $CFG;
- echo "\n<script language=\"javascript\">";
- echo "\n<!--";
- echo "\ndocument.write('<a title=\"".addslashes($title)."\" href=javascript:openpopup(\"$url\",\"$name\",\"$height\",\"$width\") >".addslashes($linkname)."</a>');";
- echo "\n//-->";
- echo "\n</script>";
- echo "\n<noscript>\n<a target=\"$name\" title=\"$title\" href=\"$CFG->wwwroot/$url\">$linkname</a>\n</noscript>\n";
+ $options = "menubar=0,location=0,scrollbars,resizable,width=$width,height=$height";
+ $fullscreen = 0;
+ echo "<a target=\"$name\" title=\"$title\" href=\"$CFG->wwwroot/$url\" ".
+ "onClick=\"return openpopup('$url', '$name', '$options', $fullscreen);\">$linkname</a>\n";
}
+
function close_window_button() {
/// Prints a simple button to close a window
- echo "<form><center>";
- echo "<input type=button onClick=\"self.close();\" value=\"".get_string("closewindow")."\">";
- echo "</center></form>";
+ echo "<center>\n";
+ echo "<script>\n";
+ echo "<!--\n";
+ echo "document.write('<form>');\n";
+ echo "document.write('<input type=button onClick=\"self.close();\" value=\"".get_string("closewindow")."\">');\n";
+ echo "document.write('</form>');\n";
+ echo "-->\n";
+ echo "</script>\n";
+ echo "<noscript>\n";
+ echo "<a href=\"".$_SERVER['HTTP_REFERER']."\"><---</a>\n";
+ echo "</noscript>\n";
+ echo "</center>\n";
}
break;
case WEBPAGE:
- case WEBLINK:
- case PROGRAM:
$strexampleurl = get_string("exampleurl", "resource");
?>
<tr valign="top">
<input name="reference" size="100" value="<? p($form->reference) ?>">
</td>
</tr>
+ <tr valign="top">
+ <td align="right" nowrap>
+ </td>
+ <td>
+ <p><?php echo "($strexample) $strexampleurl" ?></p>
+ </td>
+ </tr>
+
+ <?
+ break;
+
+ case WEBLINK:
+
+ $strexampleurl = get_string("exampleurl", "resource");
+ $strnewwindow = get_string("newwindow", "resource");
+ $strnewwindowopen = get_string("newwindowopen", "resource");
+
+ foreach ($RESOURCE_WINDOW_OPTIONS as $optionname) {
+ $stringname = "str$optionname";
+ $$stringname = get_string("new$optionname", "resource");
+ $window->$optionname = "";
+ $jsoption[] = "\"$optionname\"";
+ }
+ $alljsoptions = implode(",", $jsoption);
+
+ if ($form->instance) { // Re-editing
+ if (!$form->alltext) {
+ $newwindow = "";
+ } else {
+ $newwindow = "checked";
+ $rawoptions = explode(',', $form->alltext);
+ 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";
+ }
+ }
+ }
+ } else {
+ $newwindow = "checked";
+ $window->resizable = "checked";
+ $window->scrollbars = "checked";
+ $window->status = "checked";
+ $window->location = "checked";
+ $window->width = 620;
+ $window->height = 450;
+ }
+
+ echo $alloptions;
+
+ ?>
+
<tr valign="top">
<td align="right" nowrap>
- <p><b>(<?=$strexample?>)</b></p>
+ <p><b><?php p($strtypename) ?>:</b></p>
+ </td>
+ <td>
+ <input name="reference" size="100" value="<?php p($form->reference) ?>">
+ </td>
+ </tr>
+ <tr valign="top">
+ <td align="right" nowrap>
+ </td>
+ <td>
+ <p><?php echo "($strexample) $strexampleurl" ?></p>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td align="right" nowrap>
+ <p><b><?php p($strnewwindow) ?></b></p>
</td>
<td>
- <p><?=$strexampleurl?>
+ <script>
+ var subitems = [<?php echo $alljsoptions; ?>];
+ </script>
+ <input name="setnewwindow" type=hidden value=1>
+ <input name="newwindow" type=checkbox value=1 <?php p($newwindow) ?>
+ onclick="return lockoptions('theform','newwindow', subitems)">
+ <?php p($strnewwindowopen) ?>
+ <ul>
+ <?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.">";
+ $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) ?>">
+ <?php p($strwidth) ?><br />
+
+ <input name="hheight" type=hidden value=0>
+ <input name="height" type=text size=4 value="<?php p($window->height) ?>">
+ <?php p($strheight) ?><br />
+ <?php
+ if (!$newwindow) {
+ echo "<script>";
+ echo "lockoptions('theform','newwindow', subitems);";
+ echo "</script>";
+ }
+ ?>
+ </ul>
</p>
</td>
</tr>
<?
break;
+ case PROGRAM:
+ $strexampleurl = get_string("exampleurl", "resource");
+ ?>
+ <tr valign="top">
+ <td align="right" nowrap>
+ <p><b><?=$strtypename?>:</b></p>
+ </td>
+ <td>
+ <input name="reference" size="100" value="<? p($form->reference) ?>">
+ </td>
+ </tr>
+ <tr valign="top">
+ <td align="right" nowrap>
+ </td>
+ <td>
+ <p><?php echo "($strexample) $strexampleurl" ?></p>
+ </td>
+ </tr>
+
+ <?
+ break;
+
case UPLOADEDFILE:
$strfilename = get_string("filename", "resource");
$strnote = get_string("note", "resource");
$RESOURCE_FRAME_SIZE = 130;
+$RESOURCE_WINDOW_OPTIONS = array("resizable", "scrollbars", "directories", "location",
+ "menubar", "toolbar", "status", "height", "width");
function resource_add_instance($resource) {
// Given an object containing all the necessary data,
// will create a new instance and return the id number
// of the new instance.
+ global $RESOURCE_WINDOW_OPTIONS;
+
$resource->timemodified = time();
+ if (isset($resource->setnewwindow)) {
+ $optionlist = array();
+ foreach ($RESOURCE_WINDOW_OPTIONS as $option) {
+ if (isset($resource->$option)) {
+ $optionlist[] = $option."=".$resource->$option;
+ }
+ }
+ $resource->alltext = implode(',', $optionlist);
+ }
+
return insert_record("resource", $resource);
}
// (defined by the form in mod.html) this function
// will update an existing instance with new data.
+ global $RESOURCE_WINDOW_OPTIONS;
+
$resource->id = $resource->instance;
$resource->timemodified = time();
+ if (isset($resource->setnewwindow)) {
+ $optionlist = array();
+ foreach ($RESOURCE_WINDOW_OPTIONS as $option) {
+ if (isset($resource->$option)) {
+ $optionlist[] = $option."=".$resource->$option;
+ }
+ }
+ $resource->alltext = implode(',', $optionlist);
+ }
+
return update_record("resource", $resource);
}
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2002122300;
+$module->version = 2003072000;
$module->cron = 0;
?>