Merge branch 'wip-files23-fixes' of git://github.com/marinaglancy/moodle

This commit is contained in:
Dan Poltawski 2012-05-22 14:32:35 +08:00
commit 21878be7c8
24 changed files with 31 additions and 29 deletions

View File

@ -1385,7 +1385,7 @@ function &get_mimetypes_array() {
'dotm' => array ('type'=>'application/vnd.ms-word.template.macroEnabled.12', 'icon'=>'docx'),
'dcr' => array ('type'=>'application/x-director', 'icon'=>'flash'),
'dif' => array ('type'=>'video/x-dv', 'icon'=>'video', 'groups'=>array('mov'), 'string'=>'video'),
'dif' => array ('type'=>'video/x-dv', 'icon'=>'mov', 'groups'=>array('video'), 'string'=>'video'),
'dir' => array ('type'=>'application/x-director', 'icon'=>'flash'),
'dxr' => array ('type'=>'application/x-director', 'icon'=>'flash'),
'eps' => array ('type'=>'application/postscript', 'icon'=>'eps'),
@ -1402,18 +1402,18 @@ function &get_mimetypes_array() {
'hqx' => array ('type'=>'application/mac-binhex40', 'icon'=>'zip', 'groups'=>array('archive'), 'string'=>'archive'),
'htc' => array ('type'=>'text/x-component', 'icon'=>'html'),
'html' => array ('type'=>'text/html', 'icon'=>'html', 'groups'=>array('web_file')),
'xhtml'=> array ('type'=>'application/xhtml+xml', 'icon'=>'html'),
'xhtml'=> array ('type'=>'application/xhtml+xml', 'icon'=>'html', 'groups'=>array('web_file')),
'htm' => array ('type'=>'text/html', 'icon'=>'html', 'groups'=>array('web_file')),
'ico' => array ('type'=>'image/vnd.microsoft.icon', 'icon'=>'image', 'groups'=>array('image'), 'string'=>'image'),
'ics' => array ('type'=>'text/calendar', 'icon'=>'text'),
'isf' => array ('type'=>'application/inspiration', 'icon'=>'isf'),
'ist' => array ('type'=>'application/inspiration.template', 'icon'=>'isf'),
'java' => array ('type'=>'text/plain', 'icon'=>'text'),
'jcb' => array ('type'=>'text/xml', 'icon'=>'text'),
'jcl' => array ('type'=>'text/xml', 'icon'=>'text'),
'jcw' => array ('type'=>'text/xml', 'icon'=>'text'),
'jmt' => array ('type'=>'text/xml', 'icon'=>'text'),
'jmx' => array ('type'=>'text/xml', 'icon'=>'text'),
'jcb' => array ('type'=>'text/xml', 'icon'=>'xml'),
'jcl' => array ('type'=>'text/xml', 'icon'=>'xml'),
'jcw' => array ('type'=>'text/xml', 'icon'=>'xml'),
'jmt' => array ('type'=>'text/xml', 'icon'=>'xml'),
'jmx' => array ('type'=>'text/xml', 'icon'=>'xml'),
'jpe' => array ('type'=>'image/jpeg', 'icon'=>'jpeg', 'groups'=>array('image', 'web_image'), 'string'=>'image'),
'jpeg' => array ('type'=>'image/jpeg', 'icon'=>'jpeg', 'groups'=>array('image', 'web_image'), 'string'=>'image'),
'jpg' => array ('type'=>'image/jpeg', 'icon'=>'jpeg', 'groups'=>array('image', 'web_image'), 'string'=>'image'),
@ -1433,10 +1433,10 @@ function &get_mimetypes_array() {
'mpe' => array ('type'=>'video/mpeg', 'icon'=>'mpeg', 'groups'=>array('video'), 'string'=>'video'),
'mpg' => array ('type'=>'video/mpeg', 'icon'=>'mpeg', 'groups'=>array('video'), 'string'=>'video'),
'odt' => array ('type'=>'application/vnd.oasis.opendocument.text', 'icon'=>'odt', 'groups'=>array('odt')),
'ott' => array ('type'=>'application/vnd.oasis.opendocument.text-template', 'icon'=>'odt', 'groups'=>array('odt')),
'oth' => array ('type'=>'application/vnd.oasis.opendocument.text-web', 'icon'=>'odt', 'groups'=>array('odh')),
'odm' => array ('type'=>'application/vnd.oasis.opendocument.text-master', 'icon'=>'odh'),
'odt' => array ('type'=>'application/vnd.oasis.opendocument.text', 'icon'=>'odt', 'groups'=>array('document')),
'ott' => array ('type'=>'application/vnd.oasis.opendocument.text-template', 'icon'=>'odt', 'groups'=>array('document')),
'oth' => array ('type'=>'application/vnd.oasis.opendocument.text-web', 'icon'=>'oth', 'groups'=>array('document')),
'odm' => array ('type'=>'application/vnd.oasis.opendocument.text-master', 'icon'=>'odt'),
'odg' => array ('type'=>'application/vnd.oasis.opendocument.graphics', 'icon'=>'odg'),
'otg' => array ('type'=>'application/vnd.oasis.opendocument.graphics-template', 'icon'=>'odg'),
'odp' => array ('type'=>'application/vnd.oasis.opendocument.presentation', 'icon'=>'odp'),
@ -1595,22 +1595,22 @@ function mimeinfo_from_type($element, $mimetype) {
foreach($mimeinfo as $filetype => $values) {
if ($values['type'] == $mimetype) {
if ($cached[$mimetype] === null) {
$cached[$mimetype] = $filetype;
$cached[$mimetype] = '.'.$filetype;
}
if (!empty($values['defaulticon'])) {
$cached[$mimetype] = $filetype;
$cached[$mimetype] = '.'.$filetype;
break;
}
}
}
if (empty($cached[$mimetype])) {
$cached[$mimetype] = 'xxx';
$cached[$mimetype] = '.xxx';
}
}
if ($element === 'extension') {
return $cached[$mimetype];
} else {
return mimeinfo($element, '.'.$cached[$mimetype]);
return mimeinfo($element, $cached[$mimetype]);
}
}
@ -1831,7 +1831,7 @@ function file_get_typegroup($element, $groups) {
$mimeinfo = & get_mimetypes_array();
$cached[$element][$group] = array();
foreach ($mimeinfo as $extension => $value) {
$value['extension'] = $extension;
$value['extension'] = '.'.$extension;
if (empty($value[$element])) {
continue;
}
@ -1859,7 +1859,7 @@ function file_get_typegroup($element, $groups) {
*/
function file_extension_in_typegroup($filename, $groups, $checktype = false) {
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (!empty($extension) && in_array(strtolower($extension), file_get_typegroup('extension', $groups))) {
if (!empty($extension) && in_array('.'.strtolower($extension), file_get_typegroup('extension', $groups))) {
return true;
}
return $checktype && file_mimetype_in_typegroup(mimeinfo('type', $filename), $groups);

BIN
pix/f/moodle-128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
pix/f/moodle-24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
pix/f/moodle-256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
pix/f/moodle-32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
pix/f/moodle-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
pix/f/moodle-64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
pix/f/moodle-72.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
pix/f/moodle-80.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

BIN
pix/f/moodle-96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
pix/f/moodle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
pix/f/xml-128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
pix/f/xml-24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
pix/f/xml-256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
pix/f/xml-32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
pix/f/xml-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
pix/f/xml-64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
pix/f/xml-72.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
pix/f/xml-80.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
pix/f/xml-96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
pix/f/xml.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1728,9 +1728,8 @@ abstract class repository {
or (is_array($accepted_types) and in_array('*', $accepted_types))) {
return true;
} else {
$extensions = file_get_typegroup('extension', $accepted_types);
foreach ($extensions as $ext) {
if (preg_match('#\.'.$ext.'$#i', $value['title'])) {
foreach ($accepted_types as $ext) {
if (preg_match('#'.$ext.'$#i', $value['title'])) {
return true;
}
}

View File

@ -173,10 +173,7 @@ class repository_upload extends repository {
// check filetype
$filemimetype = mimeinfo('type', $_FILES[$elname]['name']);
if (!in_array($filemimetype, $this->mimetypes)) {
if ($sm->string_exists($filemimetype, 'mimetypes')) {
$filemimetype = get_string($filemimetype, 'mimetypes');
}
throw new moodle_exception('invalidfiletype', 'repository', '', $filemimetype);
throw new moodle_exception('invalidfiletype', 'repository', '', get_mimetype_description(array('filename' => $_FILES[$elname]['name'])));
}
}

View File

@ -111,17 +111,23 @@ class repository_youtube extends repository {
$links = $xml->children('http://www.w3.org/2005/Atom');
foreach ($xml->entry as $entry) {
$media = $entry->children('http://search.yahoo.com/mrss/');
$title = $media->group->title;
$title = (string)$media->group->title;
$description = (string)$media->group->description;
if (empty($description)) {
$description = $title;
}
$attrs = $media->group->thumbnail[2]->attributes();
$thumbnail = $attrs['url'];
$arr = explode('/', $entry->id);
$id = $arr[count($arr)-1];
$source = 'http://www.youtube.com/v/' . $id . '#' . $title;
$list[] = array(
'title'=>(string)$title,
'shorttitle'=>$title,
'thumbnail_title'=>$description,
'title'=>$title.'.avi', // this is a hack so we accept this file by extension
'thumbnail'=>(string)$attrs['url'],
'thumbnail_width'=>150,
'thumbnail_height'=>120,
'thumbnail_width'=>(int)$attrs['width'],
'thumbnail_height'=>(int)$attrs['height'],
'size'=>'',
'date'=>'',
'source'=>$source
@ -186,7 +192,7 @@ class repository_youtube extends repository {
* @return array
*/
public function supported_filetypes() {
return array('web_video');
return array('video');
}
/**