19 $handle = @opendir($dir);
20 while ($file = @readdir($handle)) {
21 if (eregi(
"^\.{1,2}$", $file)) {
24 if (is_dir($dir . $file)) {
25 $totalsize =
get_dir_size($dir . $file .
"/", $totalsize);
27 $totalsize += filesize($dir . $file);
54 return file_get_contents(
elgg_extract(
'tmp_name', $file));
72 $square =
false, $upscale =
false) {
84 $maxheight, $square, 0, 0, 0, 0, $upscale);
112 if ($imgsizearray ==
false) {
116 $width = $imgsizearray[0];
117 $height = $imgsizearray[1];
119 $accepted_formats = array(
120 'image/jpeg' =>
'jpeg',
121 'image/pjpeg' =>
'jpeg',
122 'image/png' =>
'png',
123 'image/x-png' =>
'png',
128 $load_function =
"imagecreatefrom" . $accepted_formats[$imgsizearray[
'mime']];
129 if (!is_callable($load_function)) {
135 'maxwidth' => $maxwidth,
136 'maxheight' => $maxheight,
138 'upscale' => $upscale,
150 $original_image = call_user_func($load_function,
$input_name);
151 if (!$original_image) {
156 $new_image = imagecreatetruecolor(
$params[
'newwidth'],
$params[
'newheight']);
162 imagefilledrectangle(
164 imagecolorallocate($new_image, 255, 255, 255)
167 $rtn_code = imagecopyresampled( $new_image,
183 imagejpeg($new_image, null, 90);
184 $jpeg = ob_get_clean();
186 imagedestroy($new_image);
187 imagedestroy($original_image);
237 $selection_width =
$x2 -
$x1;
238 $selection_height =
$y2 -
$y1;
241 $selection_width = $width;
242 $selection_height = $height;
250 if ($crop ==
true && $selection_width != $selection_height) {
255 $new_width = $new_height = min($maxwidth, $maxheight);
258 $selection_width = $selection_height = min($selection_width, $selection_height);
268 $widthoffset = floor(($width - $selection_width) / 2);
269 $heightoffset = floor(($height - $selection_height) / 2);
273 $new_width = $maxwidth;
274 $new_height = $maxheight;
277 if (($selection_height / (
float)$new_height) > ($selection_width / (
float)$new_width)) {
278 $new_width = floor($new_height * $selection_width / (
float)$selection_height);
280 $new_height = floor($new_width * $selection_height / (
float)$selection_width);
293 if (!$upscale && ($selection_height < $new_height || $selection_width < $new_width)) {
296 $new_height = $selection_height;
297 $new_width = $selection_width;
299 if ($selection_height < $new_height && $selection_width < $new_width) {
300 $new_height = $selection_height;
301 $new_width = $selection_width;
307 'newwidth' => $new_width,
308 'newheight' => $new_height,
309 'selectionwidth' => $selection_width,
310 'selectionheight' => $selection_height,
311 'xoffset' => $widthoffset,
312 'yoffset' => $heightoffset,
327 if ($file->canEdit()) {
328 $thumbnail = $file->thumbnail;
329 $smallthumb = $file->smallthumb;
330 $largethumb = $file->largethumb;
333 $delfile->owner_guid = $file->owner_guid;
334 $delfile->setFilename($thumbnail);
339 $delfile->owner_guid = $file->owner_guid;
340 $delfile->setFilename($smallthumb);
345 $delfile->owner_guid = $file->owner_guid;
346 $delfile->setFilename($largethumb);
350 return $file->delete();
367 case "application/msword":
370 case "application/pdf":
375 if (substr_count($mimetype,
'text/')) {
379 if (substr_count($mimetype,
'audio/')) {
383 if (substr_count($mimetype,
'image/')) {
387 if (substr_count($mimetype,
'video/')) {
391 if (substr_count($mimetype,
'opendocument')) {
407 if (!$handle = opendir($directory)) {
412 while (($file = readdir($handle)) !==
false) {
413 if (in_array($file, array(
'.',
'..'))) {
417 $path =
"$directory/$file";
431 return rmdir($directory);
452 $file_path = $CONFIG->dataroot . $dir;
453 if (file_exists($file_path)) {
483 $DEFAULT_FILE_STORE = $filestore;
499 if (isset($CONFIG->dataroot)) {
519 $value[] =
"{$CONFIG->path}engine/tests/ElggCoreFilestoreTest.php";
get_dir_size($dir, $totalsize=0)
Get the size of the specified directory.
$DEFAULT_FILE_STORE
Variable holding the default datastore.
clear_user_files($user)
Removes all user files.
file_get_general_file_type($mimetype)
Returns an overall file type from the mimetype.
$guid
Removes an admin notice.
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Register a callback as a plugin hook handler.
set_default_filestore(ElggFilestore $filestore)
Set the default filestore for the system.
if(!$owner||!($owner instanceof ElggUser)||!$owner->canEdit()) $x1
get_image_resize_parameters($width, $height, $options)
Calculate the parameters for resizing an image.
get_default_filestore()
Return the default filestore.
get_resized_image_from_existing_file($input_name, $maxwidth, $maxheight, $square=false, $x1=0, $y1=0, $x2=0, $y2=0, $upscale=false)
Gets the jpeg contents of the resized version of an already uploaded image (Returns false if the file...
get_uploaded_file($input_name)
Get the contents of an uploaded file.
elgg global
Pointer to the global context.
file_delete($guid)
Delete an ElggFile file.
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
get_resized_image_from_uploaded_file($input_name, $maxwidth, $maxheight, $square=false, $upscale=false)
Gets the jpeg contents of the resized version of an uploaded image (Returns false if the uploaded fil...
delete_directory($directory)
Delete a directory and all its contents.
_elgg_filestore_init()
Initialize the file library.
_elgg_filestore_test($hook, $type, $value)
Unit tests for files.
get_entity($guid)
Loads and returns an entity object from a guid.