* // $file - instance of stored_file or file_info * $icon = $OUTPUT->image_url(file_file_icon($file))->out(); * echo html_writer::empty_tag('img', array('src' => $icon, 'alt' => get_mimetype_description($file))); *
* echo $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file)); *
* $icon = $OUTPUT->image_url(file_folder_icon())->out(); * echo html_writer::empty_tag('img', array('src' => $icon)); *
* echo $OUTPUT->pix_icon(file_folder_icon(32), ''); *
* $mimetype = 'image/jpg'; * $icon = $OUTPUT->image_url(file_mimetype_icon($mimetype))->out(); * echo html_writer::empty_tag('img', array('src' => $icon, 'alt' => get_mimetype_description($mimetype))); *
* $filename = '.jpg'; * $icon = $OUTPUT->image_url(file_extension_icon($filename))->out(); * echo html_writer::empty_tag('img', array('src' => $icon, 'alt' => '...')); *
'. format_text($text, FORMAT_MOODLE, $options, $COURSE->id) .'
* $c = new curl; * // enable cache * $c = new curl(array('cache'=>true)); * // enable cookie * $c = new curl(array('cookie'=>true)); * // enable proxy * $c = new curl(array('proxy'=>true)); * * // HTTP GET Method * $html = $c->get('http://example.com'); * // HTTP POST Method * $html = $c->post('http://example.com/', array('q'=>'words', 'name'=>'moodle')); * // HTTP PUT Method * $html = $c->put('http://example.com/', array('file'=>'/var/www/test.txt'); *
* $c = new curl(); * $file1 = fopen('a', 'wb'); * $file2 = fopen('b', 'wb'); * $c->download(array( * array('url'=>'http://localhost/', 'file'=>$file1), * array('url'=>'http://localhost/20/', 'file'=>$file2) * )); * fclose($file1); * fclose($file2); *
* $c = new curl(); * $c->download(array( * array('url'=>'http://localhost/', 'filepath'=>'/tmp/file1.tmp'), * array('url'=>'http://localhost/20/', 'filepath'=>'/tmp/file2.tmp') * )); *
* $c = new curl(); * $file = fopen('savepath', 'w'); * $result = $c->download_one('http://localhost/', null, * array('file' => $file, 'timeout' => 5, 'followlocation' => true, 'maxredirs' => 3)); * fclose($file); * $download_info = $c->get_info(); * if ($result === true) { * // file downloaded successfully * } else { * $error_text = $result; * $error_code = $c->get_errno(); * } *
* $c = new curl(); * $result = $c->download_one('http://localhost/', null, * array('filepath' => 'savepath', 'timeout' => 5, 'followlocation' => true, 'maxredirs' => 3)); * // ... see above, no need to close handle and remove file if unsuccessful *
* $CFG->repositorycacheexpire = 120; * $CFG->curlcache = 120; * * $c = new curl(array('cache'=>true), 'module_cache'=>'repository'); * $ret = $c->get('http://www.google.com'); *