Permalink
Browse files

Converted comments to phpdoc style. Functions require additional docu…

…menting.
  • Loading branch information...
1 parent b68275d commit 99c253167160fe2826149fdbccfd039df7cef083 dhawes committed Sep 26, 2004
Showing with 61 additions and 26 deletions.
  1. +61 −26 lib/gdlib.php
View
@@ -1,13 +1,38 @@
-<?php // $Id$
- // Collection of routines in Moodle related to processing
- // images using GD.
-
-
+<?php
+
+/**
+ * gdlib.php - Collection of routines in Moodle related to
+ * processing images using GD
+ *
+ * @author ?
+ * @version $Id$
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package moodlecore
+ */
+
+/**
+ * short description (optional)
+ *
+ * long description
+ * @uses $CFG
+ * @param type? $dst_img description?
+ * @param type? $src_img description?
+ * @param type? $dst_x description?
+ * @param type? $dst_y description?
+ * @param type? $src_x description?
+ * @param type? $src_y description?
+ * @param type? $dst_w description?
+ * @param type? $dst_h description?
+ * @param type? $src_w description?
+ * @param type? $src_h description?
+ * @return ?
+ * @todo Finish documenting this function
+ */
function ImageCopyBicubic ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {
global $CFG;
- if (function_exists("ImageCopyResampled") and $CFG->gdversion >= 2) {
+ if (function_exists('ImageCopyResampled') and $CFG->gdversion >= 2) {
return ImageCopyResampled($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y,
$dst_w, $dst_h, $src_w, $src_h);
}
@@ -46,9 +71,19 @@ function ImageCopyBicubic ($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $
}
}
-function save_profile_image($id, $uploadmanager, $dir="users") {
-// Given an upload manager with the right settings, this function performs a virus scan, and then scales and crops
-// it and saves it in the right place to be a "user" or "group" image.
+/**
+ * Given an upload manager with the right settings, this function performs a virus scan, and then scales and crops
+ * it and saves it in the right place to be a "user" or "group" image.
+ *
+ * @uses $CFG
+ * @param int $id description?
+ * @param object $uploadmanager description?
+ * @param string $dir description?
+ * @return boolean
+ * @todo Finish documenting this function
+ */
+function save_profile_image($id, $uploadmanager, $dir='users') {
+//
global $CFG;
@@ -62,19 +97,19 @@ function save_profile_image($id, $uploadmanager, $dir="users") {
umask(0000);
- if (!file_exists("$CFG->dataroot/$dir")) {
- if (! mkdir("$CFG->dataroot/$dir", $CFG->directorypermissions)) {
+ if (!file_exists($CFG->dataroot .'/'. $dir)) {
+ if (! mkdir($CFG->dataroot .'/'. $dir, $CFG->directorypermissions)) {
return false;
}
}
- if (!file_exists("$CFG->dataroot/$dir/$id")) {
- if (! mkdir("$CFG->dataroot/$dir/$id", $CFG->directorypermissions)) {
+ if (!file_exists($CFG->dataroot .'/'. $dir .'/'. $id)) {
+ if (! mkdir($CFG->dataroot .'/'. $dir .'/'. $id, $CFG->directorypermissions)) {
return false;
}
}
- $destination = "$CFG->dataroot/$dir/$id";
+ $destination = $CFG->dataroot .'/'. $dir .'/'. $id;
if (!$uploadmanager->save_files($destination)) {
return false;
}
@@ -94,28 +129,28 @@ function save_profile_image($id, $uploadmanager, $dir="users") {
switch ($image->type) {
case 1:
- if (function_exists("ImageCreateFromGIF")) {
+ if (function_exists('ImageCreateFromGIF')) {
$im = ImageCreateFromGIF($originalfile);
} else {
- notice("GIF not supported on this server");
+ notice('GIF not supported on this server');
unlink($originalfile);
return false;
}
break;
case 2:
- if (function_exists("ImageCreateFromJPEG")) {
+ if (function_exists('ImageCreateFromJPEG')) {
$im = ImageCreateFromJPEG($originalfile);
} else {
- notice("JPEG not supported on this server");
+ notice('JPEG not supported on this server');
unlink($originalfile);
return false;
}
break;
case 3:
- if (function_exists("ImageCreateFromPNG")) {
+ if (function_exists('ImageCreateFromPNG')) {
$im = ImageCreateFromPNG($originalfile);
} else {
- notice("PNG not supported on this server");
+ notice('PNG not supported on this server');
unlink($originalfile);
return false;
}
@@ -127,7 +162,7 @@ function save_profile_image($id, $uploadmanager, $dir="users") {
unlink($originalfile);
- if (function_exists("ImageCreateTrueColor") and $CFG->gdversion >= 2) {
+ if (function_exists('ImageCreateTrueColor') and $CFG->gdversion >= 2) {
$im1 = ImageCreateTrueColor(100,100);
$im2 = ImageCreateTrueColor(35,35);
} else {
@@ -159,15 +194,15 @@ function save_profile_image($id, $uploadmanager, $dir="users") {
ImageLine ($im2, 34, 34, 34, 0, $black2);
ImageLine ($im2, 34, 0, 0, 0, $black2);
- if (ImageJpeg($im1, "$CFG->dataroot/$dir/$id/f1.jpg", 90) and
- ImageJpeg($im2, "$CFG->dataroot/$dir/$id/f2.jpg", 95) ) {
- @chmod("$CFG->dataroot/$dir/$id/f1.jpg", 0666);
- @chmod("$CFG->dataroot/$dir/$id/f2.jpg", 0666);
+ if (ImageJpeg($im1, $CFG->dataroot .'/'. $dir .'/'. $id .'/f1.jpg', 90) and
+ ImageJpeg($im2, $CFG->dataroot .'/'. $dir .'/'. $id .'/f2.jpg', 95) ) {
+ @chmod($CFG->dataroot .'/'. $dir .'/'. $id .'/f1.jpg', 0666);
+ @chmod($CFG->dataroot .'/'. $dir .'/'. $id .'/f2.jpg', 0666);
return 1;
} else {
return 0;
}
}
-?>
+?>

0 comments on commit 99c2531

Please sign in to comment.