MDL-33417 Show reference icon for files in filepicker

This commit is contained in:
Marina Glancy 2012-06-18 16:17:30 +08:00
parent f4a9bf65da
commit 1778f310f3
8 changed files with 76 additions and 14 deletions

View File

@ -565,7 +565,11 @@ class core_files_renderer extends plugin_renderer_base {
private function fp_js_template_iconfilename() {
$rv = '
<a class="fp-file" href="#" >
<div class="{!}fp-thumbnail"></div>
<div style="position:relative;">
<div class="{!}fp-thumbnail"></div>
<div class="fp-reficons1"></div>
<div class="fp-reficons2"></div>
</div>
<div class="fp-filename-field">
<p class="{!}fp-filename"></p>
</div>

View File

@ -226,6 +226,24 @@ abstract class file_info {
return 0;
}
/**
* Whether or not this is a external resource
*
* @return bool
*/
public function is_external_file() {
return false;
}
/**
* Returns file status flag.
*
* @return int 0 means file OK, anything else is a problem and file can not be used
*/
public function get_status() {
return 0;
}
/**
* Returns the localised human-readable name of the file together with virtual path
*

View File

@ -309,6 +309,24 @@ class file_info_stored extends file_info {
return $this->lf->get_sortorder();
}
/**
* Whether or not this is a external resource
*
* @return bool
*/
public function is_external_file() {
return $this->lf->is_external_file();
}
/**
* Returns file status flag.
*
* @return int 0 means file OK, anything else is a problem and file can not be used
*/
public function get_status() {
return $this->lf->get_status();
}
/**
* Returns list of children.
*

View File

@ -122,8 +122,12 @@ class repository_coursefiles extends repository {
'datemodified' => $child->get_timemodified(),
'datecreated' => $child->get_timecreated(),
'source'=> $encodedpath,
'isref' => $child->is_external_file(),
'thumbnail' => $OUTPUT->pix_url(file_file_icon($child, 90))->out(false)
);
if ($child->get_status() == 666) {
$node['originalmissing'] = true;
}
if ($imageinfo = $child->get_imageinfo()) {
$fileurl = new moodle_url($child->get_url());
$node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb', 'oid' => $child->get_timemodified()));

View File

@ -885,6 +885,22 @@ M.core_filepicker.init = function(Y, options) {
}
}, false);
},
classnamecallback : function(node) {
var classname = '';
if (node.children) {
classname = classname + ' fp-folder';
}
if (node.isref) {
classname = classname + ' fp-isreference';
}
if (node.refcount) {
classname = classname + ' fp-hasreferences';
}
if (node.originalmissing) {
classname = classname + ' fp-originalmissing';
}
return Y.Lang.trim(classname);
},
/** displays list of files in tree (list) view mode. If param appenditems is specified,
* appends those items to the end of the list. Otherwise (default behaviour)
* clears the contents and displays the items from this.filelist */
@ -920,9 +936,7 @@ M.core_filepicker.init = function(Y, options) {
this.content_scrolled();
}
},
classnamecallback : function(node) {
return node.children ? 'fp-folder' : '';
},
classnamecallback : this.classnamecallback,
dynload : this.active_repo.dynload,
filepath : this.filepath,
treeview_dynload : this.treeview_dynload
@ -961,9 +975,7 @@ M.core_filepicker.init = function(Y, options) {
this.select_file(node);
}
},
classnamecallback : function(node) {
return node.children ? 'fp-folder' : '';
}
classnamecallback : this.classnamecallback
};
this.fpnode.one('.fp-content').fp_display_filelist(options, list, this.lazyloading);
},
@ -998,9 +1010,7 @@ M.core_filepicker.init = function(Y, options) {
this.select_file(node);
}
},
classnamecallback : function(node) {
return node.children ? 'fp-folder' : '';
}
classnamecallback : this.classnamecallback
};
this.fpnode.one('.fp-content').fp_display_filelist(options, list, this.lazyloading);
},

View File

@ -230,6 +230,10 @@ class repository_local_file {
$node['size'] = $this->fileinfo->get_filesize();
$node['author'] = $this->fileinfo->get_author();
$node['license'] = $this->fileinfo->get_license();
$node['isref'] = $this->fileinfo->is_external_file();
if ($this->fileinfo->get_status() == 666) {
$node['originalmissing'] = true;
}
$node['source'] = $encodedpath;
$node['thumbnail'] = $OUTPUT->pix_url(file_file_icon($this->fileinfo, 90))->out(false);
$node['icon'] = $OUTPUT->pix_url(file_file_icon($this->fileinfo, 24))->out(false);

View File

@ -112,10 +112,14 @@ class repository_user extends repository {
'datecreated' => $child->get_timecreated(),
'author' => $child->get_author(),
'license' => $child->get_license(),
'isref' => $child->is_external_file(),
'source'=> $encodedpath,
'icon' => $OUTPUT->pix_url(file_file_icon($child, 24))->out(false),
'thumbnail' => $OUTPUT->pix_url(file_file_icon($child, 90))->out(false)
);
if ($child->get_status() == 666) {
$node['originalmissing'] = true;
}
if ($imageinfo = $child->get_imageinfo()) {
$fileurl = new moodle_url($child->get_url());
$node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb', 'oid' => $child->get_timemodified()));

View File

@ -293,10 +293,10 @@ a.ygtvspacer:hover {color: transparent;text-decoration: none;}
/*
* Icon view (File Manager only)
*/
.filemanager .fp-iconview .fp-reficons1 {position:absolute;height:100%;width:100%;top:0;left:0;z-index:1000;}
.filemanager .fp-iconview .fp-reficons2 {position:absolute;height:100%;width:100%;top:0;left:0;z-index:1001;}
.filemanager .fp-iconview .fp-file.fp-hasreferences .fp-reficons1 {background: url('[[pix:theme|fp/link]]') no-repeat;background-position:bottom right;}
.filemanager .fp-iconview .fp-file.fp-isreference .fp-reficons2 {background: url('[[pix:theme|fp/alias]]') no-repeat;background-position:bottom left;}
.fp-iconview .fp-reficons1 {position:absolute;height:100%;width:100%;top:0;left:0;z-index:1000;}
.fp-iconview .fp-reficons2 {position:absolute;height:100%;width:100%;top:0;left:0;z-index:1001;}
.fp-iconview .fp-file.fp-hasreferences .fp-reficons1 {background: url('[[pix:theme|fp/link]]') no-repeat;background-position:bottom right;}
.fp-iconview .fp-file.fp-isreference .fp-reficons2 {background: url('[[pix:theme|fp/alias]]') no-repeat;background-position:bottom left;}
.filemanager .fp-iconview .fp-file.fp-originalmissing .fp-thumbnail img {display:none;}
.filemanager .fp-iconview .fp-file.fp-originalmissing .fp-thumbnail {background: url([[pix:s/dead]]) no-repeat;background-position:center center;}