本文整理汇总了PHP中stored_file::get_author方法的典型用法代码示例。如果您正苦于以下问题:PHP stored_file::get_author方法的具体用法?PHP stored_file::get_author怎么用?PHP stored_file::get_author使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stored_file
的用法示例。
在下文中一共展示了stored_file::get_author方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emarking_create_anonymous_page_from_storedfile
function emarking_create_anonymous_page_from_storedfile(stored_file $file)
{
if (!$file) {
throw new Exception('Stored file does not exist');
}
// Get file storage and copy file to temp folder.
$fs = get_file_storage();
$tmppath = $file->copy_content_to_temp('emarking', 'anonymous');
// Treat the file as an image, get its size and draw a white rectangle.
$size = getimagesize($tmppath);
$image = imagecreatefrompng($tmppath);
$white = imagecolorallocate($image, 255, 255, 255);
$y2 = round($size[1] / 10, 0);
imagefilledrectangle($image, 0, 0, $size[0], $y2, $white);
// Save the new image to replace the file.
if (!imagepng($image, $tmppath)) {
return false;
}
clearstatcache();
$filenameanonymous = emarking_get_anonymous_filename($file->get_filename());
// Copy file from temp folder to Moodle's filesystem.
$filerecordanonymous = array('contextid' => $file->get_contextid(), 'component' => 'mod_emarking', 'filearea' => 'pages', 'itemid' => $file->get_itemid(), 'filepath' => '/', 'filename' => $filenameanonymous, 'timecreated' => $file->get_timecreated(), 'timemodified' => time(), 'userid' => $file->get_userid(), 'author' => $file->get_author(), 'license' => 'allrightsreserved');
$previousfile = $fs->get_file($file->get_contextid(), 'mod_emarking', 'pages', $file->get_itemid(), '/', $filenameanonymous);
if ($previousfile) {
$previousfile->delete();
}
$fileinfo = $fs->create_file_from_pathname($filerecordanonymous, $tmppath);
return $fileinfo;
}