MDL-16089 some resource lib and lang pack cleanup
AMOS START MOV [displayauto,mod_resource],[resourcedisplayauto,core] MOV [displaydownload,mod_resource],[resourcedisplaydownload,core] MOV [displayembed,mod_resource],[resourcedisplayembed,core] MOV [displayframe,mod_resource],[resourcedisplayframe,core] MOV [displaynew,mod_resource],[resourcedisplaynew,core] MOV [displayopen,mod_resource],[resourcedisplayopen,core] MOV [displaypopup,mod_resource],[resourcedisplaypopup,core] AMOS END
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
require_once(dirname(__FILE__).'/../config.php');
|
||||
require_once($CFG->libdir . '/formslib.php');
|
||||
require_once($CFG->dirroot .'/course/lib.php');
|
||||
require_once($CFG->dirroot .'/mod/resource/lib.php');
|
||||
require_once($CFG->libdir .'/filelib.php');
|
||||
|
||||
define('GENERATOR_RANDOM', 0);
|
||||
|
||||
@@ -32,9 +32,6 @@ define('NO_MOODLE_COOKIES', true);
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/resource/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
require_once($CFG->dirroot.'/lib/moodlelib.php');
|
||||
|
||||
if (!is_enabled_auth('cas')) {
|
||||
echo "Plugin not enabled!";
|
||||
|
||||
@@ -32,8 +32,6 @@ define('NO_MOODLE_COOKIES', true);
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/resource/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
if (!is_enabled_auth('db')) {
|
||||
echo "Plugin not enabled!";
|
||||
|
||||
@@ -31,8 +31,6 @@ define('NO_MOODLE_COOKIES', true);
|
||||
require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); // global moodle config file.
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/resource/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
if (!is_enabled_auth('ldap')) {
|
||||
echo "Plugin not enabled!";
|
||||
|
||||
@@ -1442,6 +1442,13 @@ $string['resettask'] = 'Task';
|
||||
$string['resettodefaults'] = 'Reset to defaults';
|
||||
$string['resortcoursesbyname'] = 'Re-sort courses by name';
|
||||
$string['resource'] = 'Resource';
|
||||
$string['resourcedisplayauto'] = 'Automatic';
|
||||
$string['resourcedisplaydownload'] = 'Force download';
|
||||
$string['resourcedisplayembed'] = 'Embed';
|
||||
$string['resourcedisplayframe'] = 'In frame';
|
||||
$string['resourcedisplaynew'] = 'New window';
|
||||
$string['resourcedisplayopen'] = 'Open';
|
||||
$string['resourcedisplaypopup'] = 'In pop-up';
|
||||
$string['resources'] = 'Resources';
|
||||
$string['resources_help'] = 'Resource types enable almost any kind of web content to be inserted into the course.';
|
||||
$string['restore'] = 'Restore';
|
||||
|
||||
+48
-9
@@ -46,6 +46,45 @@ define('RESOURCE_LEGACYYFILES_DONE', 1);
|
||||
define('RESOURCELIB_LEGACYFILES_ACTIVE', 2);
|
||||
|
||||
|
||||
/**
|
||||
* Try on demand migration of file from old course files
|
||||
* @param string $filepath old file path
|
||||
* @param int $cmid migrated course module if
|
||||
* @param int $courseid
|
||||
* @param string $filearea new file area
|
||||
* @param int $itemid migrated file item id
|
||||
* @return mixed, false if not found, stored_file instance if migrated to new area
|
||||
*/
|
||||
function resourcelib_try_file_migration($filepath, $cmid, $courseid, $filearea, $itemid) {
|
||||
$fs = get_file_storage();
|
||||
|
||||
if (stripos($filepath, '/backupdata/') === 0 or stripos($filepath, '/moddata/') === 0) {
|
||||
// do not steal protected files!
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cmid)) {
|
||||
return false;
|
||||
}
|
||||
if (!$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pathnamehash = sha1($coursecontext->id.'course_content0'.$filepath);
|
||||
if (!$file = $fs->get_file_by_hash($pathnamehash)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// copy and keep the same path, name, etc.
|
||||
$file_record = array('contextid'=>$context->id, 'filearea'=>$filearea, 'itemid'=>$itemid);
|
||||
try {
|
||||
return $fs->create_file_from_storedfile($file_record, $file);
|
||||
} catch (Exception $e) {
|
||||
// file may exist - highly unlikely, we do not want upgrades to stop here
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of available display options
|
||||
* @param array $enabled list of options enabled in module configuration
|
||||
@@ -57,13 +96,13 @@ function resourcelib_get_displayoptions(array $enabled, $current=null) {
|
||||
$enabled[] = $current;
|
||||
}
|
||||
|
||||
$options = array(RESOURCELIB_DISPLAY_AUTO => get_string('displayauto', 'resource'),
|
||||
RESOURCELIB_DISPLAY_EMBED => get_string('displayembed', 'resource'),
|
||||
RESOURCELIB_DISPLAY_FRAME => get_string('displayframe', 'resource'),
|
||||
RESOURCELIB_DISPLAY_NEW => get_string('displaynew', 'resource'),
|
||||
RESOURCELIB_DISPLAY_DOWNLOAD => get_string('displaydownload', 'resource'),
|
||||
RESOURCELIB_DISPLAY_OPEN => get_string('displayopen', 'resource'),
|
||||
RESOURCELIB_DISPLAY_POPUP => get_string('displaypopup', 'resource'));
|
||||
$options = array(RESOURCELIB_DISPLAY_AUTO => get_string('resourcedisplayauto'),
|
||||
RESOURCELIB_DISPLAY_EMBED => get_string('resourcedisplayembed'),
|
||||
RESOURCELIB_DISPLAY_FRAME => get_string('resourcedisplayframe'),
|
||||
RESOURCELIB_DISPLAY_NEW => get_string('resourcedisplaynew'),
|
||||
RESOURCELIB_DISPLAY_DOWNLOAD => get_string('resourcedisplaydownload'),
|
||||
RESOURCELIB_DISPLAY_OPEN => get_string('resourcedisplayopen'),
|
||||
RESOURCELIB_DISPLAY_POPUP => get_string('resourcedisplaypopup'));
|
||||
|
||||
$result = array();
|
||||
|
||||
@@ -143,7 +182,7 @@ function resourcelib_embed_mp3($fullurl, $title, $clicktoopen) {
|
||||
$c .= '&volText='.get_string('vol', 'resource').'&panText='.get_string('pan','resource');
|
||||
$id = 'filter_mp3_'.time(); //we need something unique because it might be stored in text cache
|
||||
|
||||
$ufoargs = array('movie' => $CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.addslashes_js($fullurl),
|
||||
$ufoargs = array('movie' => $CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.urlencode($fullurl),
|
||||
'width' => 600,
|
||||
'height' => 70,
|
||||
'majorversion' => 6,
|
||||
@@ -184,7 +223,7 @@ function resourcelib_embed_flashvideo($fullurl, $title, $clicktoopen) {
|
||||
|
||||
$id = 'filter_flv_'.time(); //we need something unique because it might be stored in text cache
|
||||
|
||||
$ufoargs = array('movie' => $CFG->wwwroot.'/filter/mediaplugin/flvplayer.swf?file='.addslashes_js($fullurl),
|
||||
$ufoargs = array('movie' => $CFG->wwwroot.'/filter/mediaplugin/flvplayer.swf?file='.urlencode($fullurl),
|
||||
'width' => 600,
|
||||
'height' => 400,
|
||||
'majorversion' => 6,
|
||||
|
||||
@@ -28,7 +28,6 @@ if (!defined('MOODLE_INTERNAL')) {
|
||||
}
|
||||
|
||||
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
|
||||
require_once($CFG->dirroot.'/mod/resource/locallib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
class mod_imscp_mod_form extends moodleform_mod {
|
||||
|
||||
+1
-62
@@ -24,6 +24,7 @@
|
||||
**/
|
||||
|
||||
/** Include required libraries */
|
||||
//TODO: these dumb includes have to be removed and this script minimised by moving stuff to locallib.php!!!
|
||||
require_once($CFG->libdir.'/eventslib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
@@ -961,68 +962,6 @@ function lesson_get_file_info($browser, $areas, $course, $cm, $context, $fileare
|
||||
return new file_info_stored($browser, $context, $storedfile, $urlbase, $filearea, $itemid, true, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a function used to detect media types and generate html code.
|
||||
*
|
||||
* @global object $CFG
|
||||
* @global object $PAGE
|
||||
* @param object $lesson
|
||||
* @param object $context
|
||||
* @return string $code the html code of media
|
||||
*/
|
||||
function lesson_get_media_html($lesson, $context) {
|
||||
global $CFG, $PAGE, $OUTPUT;
|
||||
|
||||
// get the media file from file pool
|
||||
$browser = get_file_browser();
|
||||
$file_info = $browser->get_file_info($context, 'lesson_media_file', $lesson->id, '/', $lesson->mediafile);
|
||||
$url = $file_info->get_url();
|
||||
$title = $lesson->mediafile;
|
||||
|
||||
$clicktoopen = html_writer::link(new moodle_url($url), get_string('download'));
|
||||
|
||||
$mimetype = resourcelib_guess_url_mimetype($url);
|
||||
|
||||
// find the correct type and print it out
|
||||
if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image
|
||||
$code = resourcelib_embed_image($url, $title);
|
||||
|
||||
} else if ($mimetype == 'audio/mp3') {
|
||||
// MP3 audio file
|
||||
$code = resourcelib_embed_mp3($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'video/x-flv') {
|
||||
// Flash video file
|
||||
$code = resourcelib_embed_flashvideo($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'application/x-shockwave-flash') {
|
||||
// Flash file
|
||||
$code = resourcelib_embed_flash($url, $title, $clicktoopen);
|
||||
|
||||
} else if (substr($mimetype, 0, 10) == 'video/x-ms') {
|
||||
// Windows Media Player file
|
||||
$code = resourcelib_embed_mediaplayer($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'video/quicktime') {
|
||||
// Quicktime file
|
||||
$code = resourcelib_embed_quicktime($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'video/mpeg') {
|
||||
// Mpeg file
|
||||
$code = resourcelib_embed_mpeg($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'audio/x-pn-realaudio-plugin') {
|
||||
// RealMedia file
|
||||
$code = resourcelib_embed_real($url, $title, $clicktoopen);
|
||||
|
||||
} else {
|
||||
// anything else - just try object tag enlarged as much as possible
|
||||
$code = resourcelib_embed_general($url, $title, $clicktoopen, $mimetype);
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract class to provide a core functions to the all lesson classes
|
||||
*
|
||||
|
||||
@@ -569,3 +569,66 @@ function lesson_add_header_buttons($cm, $context, $extraeditbuttons=false, $less
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a function used to detect media types and generate html code.
|
||||
*
|
||||
* @global object $CFG
|
||||
* @global object $PAGE
|
||||
* @param object $lesson
|
||||
* @param object $context
|
||||
* @return string $code the html code of media
|
||||
*/
|
||||
function lesson_get_media_html($lesson, $context) {
|
||||
global $CFG, $PAGE, $OUTPUT;
|
||||
require_once("$CFG->libdir/resourcelib.php");
|
||||
|
||||
// get the media file from file pool
|
||||
$browser = get_file_browser();
|
||||
$file_info = $browser->get_file_info($context, 'lesson_media_file', $lesson->id, '/', $lesson->mediafile);
|
||||
$url = $file_info->get_url();
|
||||
$title = $lesson->mediafile;
|
||||
|
||||
$clicktoopen = html_writer::link(new moodle_url($url), get_string('download'));
|
||||
|
||||
$mimetype = resourcelib_guess_url_mimetype($url);
|
||||
|
||||
// find the correct type and print it out
|
||||
if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) { // It's an image
|
||||
$code = resourcelib_embed_image($url, $title);
|
||||
|
||||
} else if ($mimetype == 'audio/mp3') {
|
||||
// MP3 audio file
|
||||
$code = resourcelib_embed_mp3($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'video/x-flv') {
|
||||
// Flash video file
|
||||
$code = resourcelib_embed_flashvideo($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'application/x-shockwave-flash') {
|
||||
// Flash file
|
||||
$code = resourcelib_embed_flash($url, $title, $clicktoopen);
|
||||
|
||||
} else if (substr($mimetype, 0, 10) == 'video/x-ms') {
|
||||
// Windows Media Player file
|
||||
$code = resourcelib_embed_mediaplayer($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'video/quicktime') {
|
||||
// Quicktime file
|
||||
$code = resourcelib_embed_quicktime($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'video/mpeg') {
|
||||
// Mpeg file
|
||||
$code = resourcelib_embed_mpeg($url, $title, $clicktoopen);
|
||||
|
||||
} else if ($mimetype == 'audio/x-pn-realaudio-plugin') {
|
||||
// RealMedia file
|
||||
$code = resourcelib_embed_real($url, $title, $clicktoopen);
|
||||
|
||||
} else {
|
||||
// anything else - just try object tag enlarged as much as possible
|
||||
$code = resourcelib_embed_general($url, $title, $clicktoopen, $mimetype);
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
/**
|
||||
* This file plays the mediafile set in lesson settings.
|
||||
*
|
||||
* Almost all of this code is from /mod/resource/type/file/resource.class.php so major props for resource
|
||||
*
|
||||
* If there is a way to use the resource class instead of this code, please change to do so
|
||||
*
|
||||
*
|
||||
@@ -30,8 +28,6 @@
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/lesson/locallib.php');
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
require_once($CFG->libdir.'/resourcelib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
$printclose = optional_param('printclose', 0, PARAM_INT);
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
$string['configdisplayoptions'] = 'Select all options that should be available, existing settings are not modified. Hold CTRL key to select multiple fields.';
|
||||
$string['content'] = 'Page content';
|
||||
$string['contentheader'] = 'Content';
|
||||
$string['displaynew'] = 'New window';
|
||||
$string['displayopen'] = 'Open';
|
||||
$string['displayoptions'] = 'Available display options';
|
||||
$string['displayselect'] = 'Display';
|
||||
$string['displayselectexplain'] = 'Select display type.';
|
||||
|
||||
+1
-2
@@ -367,8 +367,7 @@ function page_pluginfile($course, $cminfo, $context, $filearea, $args, $forcedow
|
||||
if ($page->legacyfiles != RESOURCELIB_LEGACYFILES_ACTIVE) {
|
||||
return false;
|
||||
}
|
||||
require_once("$CFG->dirroot/mod/resource/db/upgradelib.php");
|
||||
if (!$file = resource_try_file_migration($relativepath, $cminfo->id, $cminfo->course, 'page_content', 0)) {
|
||||
if (!$file = resourcelib_try_file_migration($relativepath, $cminfo->id, $cminfo->course, 'page_content', 0)) {
|
||||
return false;
|
||||
}
|
||||
//file migrate - update flag
|
||||
|
||||
@@ -23,45 +23,6 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Try on demand migration of file from old course files
|
||||
* @param string $filepath old file path
|
||||
* @param int $cmid migrated course module if
|
||||
* @param int $courseid
|
||||
* @param string $filearea new file area
|
||||
* @param int $itemid migrated file item id
|
||||
* @return mixed, false if not found, stored_file instance if migrated to new area
|
||||
*/
|
||||
function resource_try_file_migration($filepath, $cmid, $courseid, $filearea, $itemid) {
|
||||
$fs = get_file_storage();
|
||||
|
||||
if (stripos($filepath, '/backupdata/') === 0 or stripos($filepath, '/moddata/') === 0) {
|
||||
// do not steal protected files!
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cmid)) {
|
||||
return false;
|
||||
}
|
||||
if (!$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pathnamehash = sha1($coursecontext->id.'course_content0'.$filepath);
|
||||
if (!$file = $fs->get_file_by_hash($pathnamehash)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// copy and keep the same path, name, etc.
|
||||
$file_record = array('contextid'=>$context->id, 'filearea'=>$filearea, 'itemid'=>$itemid);
|
||||
try {
|
||||
return $fs->create_file_from_storedfile($file_record, $file);
|
||||
} catch (Exception $e) {
|
||||
// file may exist - highly unlikely, we do not want upgrades to stop here
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate resource module data from 1.9 resource_old table to new resource table
|
||||
* @return void
|
||||
@@ -132,7 +93,7 @@ function resource_20_migrate() {
|
||||
}
|
||||
|
||||
// try migration of main file - ignore if does not exist
|
||||
if ($file = resource_try_file_migration($resource->mainfile, $candidate->cmid, $candidate->course, 'resource_content', 0)) {
|
||||
if ($file = resourcelib_try_file_migration($resource->mainfile, $candidate->cmid, $candidate->course, 'resource_content', 0)) {
|
||||
$resource->mainfile = $file->get_filepath().$file->get_filename();
|
||||
}
|
||||
|
||||
@@ -166,7 +127,7 @@ function resource_20_migrate() {
|
||||
}
|
||||
|
||||
// try migration of main file - ignore if does not exist
|
||||
if ($file = resource_try_file_migration($resource->mainfile, $candidate->cmid, $candidate->course, 'resource_content', 0)) {
|
||||
if ($file = resourcelib_try_file_migration($resource->mainfile, $candidate->cmid, $candidate->course, 'resource_content', 0)) {
|
||||
$resource->mainfile = $file->get_filepath().$file->get_filename();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,14 +59,7 @@ $string['deployall'] = 'Deploy all';
|
||||
$string['directlink'] = 'Direct link to this file';
|
||||
$string['directoryinfo'] = 'All the files in the chosen directory will be displayed.';
|
||||
$string['display'] = 'Window';
|
||||
$string['displayauto'] = 'Automatic';
|
||||
$string['displaydownload'] = 'Force download';
|
||||
$string['displayembed'] = 'Embed';
|
||||
$string['displayframe'] = 'In frame';
|
||||
$string['displaynew'] = 'New window';
|
||||
$string['displayopen'] = 'Open';
|
||||
$string['displayoptions'] = 'Available display options';
|
||||
$string['displaypopup'] = 'In pop-up';
|
||||
$string['displayselect'] = 'Display';
|
||||
$string['displayselectexplain'] = 'Choose display type, unfortunately not all types are suitable for all files.';
|
||||
$string['editingaresource'] = 'Editing a resource';
|
||||
|
||||
@@ -420,8 +420,7 @@ function resource_pluginfile($course, $cminfo, $context, $filearea, $args, $forc
|
||||
if ($resource->legacyfiles != RESOURCELIB_LEGACYFILES_ACTIVE) {
|
||||
return false;
|
||||
}
|
||||
require_once("$CFG->dirroot/mod/resource/db/upgradelib.php");
|
||||
if (!$file = resource_try_file_migration($relativepath, $cminfo->id, $cminfo->course, 'resource_content', 0)) {
|
||||
if (!$file = resourcelib_try_file_migration($relativepath, $cminfo->id, $cminfo->course, 'resource_content', 0)) {
|
||||
return false;
|
||||
}
|
||||
// file migrate - update flag
|
||||
|
||||
@@ -29,13 +29,7 @@ $string['configframesize'] = 'When a web page or an uploaded file is displayed w
|
||||
$string['configrolesinparams'] = 'Enable if you want to include localized role names in list of avaible parameter variables.';
|
||||
$string['configsecretphrase'] = 'This secret phrase is used to produce encrypted code value that can be sent to some servers as a parameter. The encrypted code is produced by an md5 value of the current user IP address concatenated with your secret phrase. ie code = md5(IP.secretphrase). Please note that this is not reliable because IP address may change and is often shared by different computers.';
|
||||
$string['contentheader'] = 'Content';
|
||||
$string['displayauto'] = 'Automatic';
|
||||
$string['displayembed'] = 'Embed';
|
||||
$string['displayframe'] = 'In frame';
|
||||
$string['displaynew'] = 'New window';
|
||||
$string['displayopen'] = 'Open';
|
||||
$string['displayoptions'] = 'Available display options';
|
||||
$string['displaypopup'] = 'In pop-up';
|
||||
$string['displayselect'] = 'Display';
|
||||
$string['displayselectexplain'] = 'Choose display type, unfortunately not all types are suitable for all URLs.';
|
||||
$string['externalurl'] = 'External URL';
|
||||
|
||||
Reference in New Issue
Block a user