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

📄 resource.class.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php // $Id: resource.class.php,v 1.21.2.4 2009/03/23 09:47:13 mudrd8mz Exp $/*** 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($USER->id)) {   // No need to set up parameters        $this->parameters = array();        return;    }    $site = get_site();    $this->parameters = array(            '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('idnumbercourse'),                                       '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'   => format_string($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')    );    if (!empty($USER->id)) {        $userparameters = 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),            '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('phone2').' 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)         );         $this->parameters = $userparameters + $this->parameters;    }}function add_instance($resource) {    $this->_postprocess($resource);    return parent::add_instance($resource);}function update_instance($resource) {    $this->_postprocess($resource);/*    echo '<xmp>';    var_dump($_POST);    var_dump($resource);die;*/    return parent::update_instance($resource);}function _postprocess(&$resource) {    global $RESOURCE_WINDOW_OPTIONS;    $alloptions = $RESOURCE_WINDOW_OPTIONS;    if ($resource->windowpopup) {        $optionlist = array();        foreach ($alloptions as $option) {            $optionlist[] = $option."=".$resource->$option;            unset($resource->$option);        }        $resource->popup = implode(',', $optionlist);        unset($resource->windowpopup);        $resource->options = '';    } else {        if (empty($resource->framepage)) {            $resource->options = '';        } else {            $resource->options = 'frame';        }        unset($resource->framepage);        $resource->popup = '';    }    $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;        }        unset($resource->$parsename);        unset($resource->$parametername);    }    $resource->alltext = implode(',', $optionlist);}/*** 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;

⌨️ 快捷键说明

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