⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resource.class.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
    $mimetype = mimeinfo("type", $resource->reference);    $pagetitle = strip_tags($course->shortname.': '.format_string($resource->name));    $formatoptions = new object();    $formatoptions->noclean = true;    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";        }    }    $navigation = build_navigation($this->navlinks, $cm);/// 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('&amp;', $querys);    }    /// Set up some variables    $inpopup = optional_param('inpopup', 0, PARAM_BOOL);   $fullurl =  $resource->reference. '&amp;HIVE_SESSION='.$SESSION->HIVE_SESSION;    if (!empty($querystring)) {        $urlpieces = parse_url($resource->reference);        if (empty($urlpieces['query'])) {            $fullurl .= '?'.$querystring;        } else {            $fullurl .= '&amp;'.$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, $navigation, "", "", 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, $navigation, "", "", 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, $navigation, "", "", true,                update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));        echo "\n<script 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&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";        echo "<p>&nbsp;</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    $frameset = optional_param('frameset', '', PARAM_ALPHA);    if (empty($frameset) and !$embedded and !$inpopup and $resource->options == "frame" and empty($USER->screenreader)) {        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>" . format_string($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}&amp;type={$resource->type}&amp;frameset=top\" title=\"".get_string('modulename','resource')."\"/>";        if (!empty($localpath)) {  // Show it like this so we interpose some HTML            echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;inpopup=true\" title=\"".get_string('modulename','resource')."\"/>";        } else {            echo "<frame src=\"$fullurl\" title=\"".get_string('modulename','resource')."\"/>";        }        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($frameset) and $frameset == "top") {        print_header($pagetitle, $course->fullname, $navigation, "", "", true,                update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));        echo '<div class="summary">'.format_text($resource->summary, FORMAT_HTML, $formatoptions).'</div>';        if (!empty($localpath)) {  // Show some help            echo '<div class="mdl-right 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, $navigation, "", "", 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.'&amp;" />';            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.'&amp;" ';            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锟

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -