示例#1
0
 /**
  * Converts file_info object to element of repository return list
  *
  * @param file_info $fileinfo
  * @return array
  */
 private function get_node(file_info $fileinfo)
 {
     global $OUTPUT;
     $encodedpath = base64_encode(json_encode($fileinfo->get_params()));
     $node = array('title' => $fileinfo->get_visible_name(), 'datemodified' => $fileinfo->get_timemodified(), 'datecreated' => $fileinfo->get_timecreated());
     if ($fileinfo->is_directory()) {
         $node['path'] = $encodedpath;
         $node['thumbnail'] = $OUTPUT->pix_url(file_folder_icon(90))->out(false);
         $node['children'] = array();
     } else {
         $node['size'] = $fileinfo->get_filesize();
         $node['author'] = $fileinfo->get_author();
         $node['license'] = $fileinfo->get_license();
         $node['isref'] = $fileinfo->is_external_file();
         if ($fileinfo->get_status() == 666) {
             $node['originalmissing'] = true;
         }
         $node['source'] = $encodedpath;
         $node['thumbnail'] = $OUTPUT->pix_url(file_file_icon($fileinfo, 90))->out(false);
         $node['icon'] = $OUTPUT->pix_url(file_file_icon($fileinfo, 24))->out(false);
         if ($imageinfo = $fileinfo->get_imageinfo()) {
             // what a beautiful picture, isn't it
             $fileurl = new moodle_url($fileinfo->get_url());
             $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb', 'oid' => $fileinfo->get_timemodified()));
             $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $fileinfo->get_timemodified()));
             $node['image_width'] = $imageinfo['width'];
             $node['image_height'] = $imageinfo['height'];
         }
     }
     return $node;
 }