Index: inc/admin/lib.themeconfig.php
===================================================================
--- inc/admin/lib.themeconfig.php	(revision 2658)
+++ inc/admin/lib.themeconfig.php	(revision 2659)
@@ -21,6 +21,13 @@
 class dcThemeConfig
 {
-	// Utilities
-
+
+/**
+ * Compute contrast ratio between two colors
+ *
+ * @param  string $color      text color
+ * @param  string $background background color
+ *
+ * @return float             computed ratio
+ */
 	public static function computeContrastRatio($color,$background)
 	{
@@ -48,4 +55,13 @@
 	}
 
+/**
+ * Compute WCAG contrast ration level
+ *
+ * @param  float  $ratio computed ratio between foreground and backround color
+ * @param  string  $size  font size as defined in CSS
+ * @param  boolean $bold  true if bold font
+ *
+ * @return string         WCAG contrast ratio level (AAA, AA or <nothing>)
+ */
 	public static function contrastRatioLevel($ratio,$size,$bold=false)
 	{
@@ -97,4 +113,14 @@
 	}
 
+/**
+ * Return full information about constrat ratio
+ *
+ * @param  string  $color      text color
+ * @param  string  $background background color
+ * @param  string  $size       font size
+ * @param  boolean $bold       bold font
+ *
+ * @return string              contrast ratio including WCAG level
+ */
 	public static function contrastRatio($color,$background,$size='',$bold=false)
 	{
@@ -109,4 +135,11 @@
 	}
 
+/**
+ * Check font size
+ *
+ * @param  string $s font size
+ *
+ * @return string    checked font size
+ */
 	public static function adjustFontSize($s)
 	{
@@ -120,4 +153,11 @@
 	}
 
+/**
+ * Check object position, should be x:y
+ *
+ * @param  string $p position
+ *
+ * @return string    checked position
+ */
 	public static function adjustPosition($p)
 	{
@@ -130,4 +170,11 @@
 	}
 
+/**
+ * Check a CSS color
+ *
+ * @param  string $c CSS color
+ *
+ * @return string    checked CSS color
+ */
 	public static function adjustColor($c)
 	{
@@ -151,5 +198,11 @@
 	}
 
-	// CSS file management
+/**
+ * Check and clean CSS
+ *
+ * @param  string $css CSS to be checked
+ *
+ * @return string      checked CSS
+ */
 	public static function cleanCSS($css)
 	{
@@ -158,4 +211,11 @@
 	}
 
+/**
+ * Return real path of a user defined CSS
+ *
+ * @param  string $folder CSS folder
+ *
+ * @return string         real path of CSS
+ */
 	public static function cssPath($folder)
 	{
@@ -164,4 +224,11 @@
 	}
 
+/**
+ * Retirn URL of a user defined CSS
+ *
+ * @param  string $folder CSS folder
+ *
+ * @return string         CSS URL
+ */
 	public static function cssURL($folder)
 	{
@@ -170,4 +237,12 @@
 	}
 
+/**
+ * Check if user defined CSS may be written
+ *
+ * @param  string  $folder CSS folder
+ * @param  boolean $create create CSS folder if necessary
+ *
+ * @return boolean          true if CSS folder exists and may be written, else false
+ */
 	public static function canWriteCss($folder,$create=false)
 	{
@@ -201,4 +276,12 @@
 	}
 
+/**
+ * Store CSS property value in associated array
+ *
+ * @param  array $css       CSS associated array
+ * @param  string $selector selector
+ * @param  string $prop     property
+ * @param  string $value    value
+ */
 	public static function prop(&$css,$selector,$prop,$value)
 	{
@@ -208,4 +291,13 @@
 	}
 
+/**
+ * Store background image property in CSS associated array
+ *
+ * @param  string $folder   image folder
+ * @param  array $css       CSS associated array
+ * @param  string $selector selector
+ * @param  boolean $value   false for default, true if image should be set
+ * @param  string $image    image filename
+ */
 	public static function backgroundImg($folder,&$css,$selector,$value,$image)
 	{
@@ -216,4 +308,11 @@
 	}
 
+/**
+ * Write CSS file
+ *
+ * @param  string $folder CSS folder
+ * @param  string $theme  CSS filename
+ * @param  string $css    CSS file content
+ */
 	public static function writeCss($folder,$theme,$css)
 	{
@@ -221,4 +320,10 @@
 	}
 
+/**
+ * Delete CSS file
+ *
+ * @param  string $folder CSS folder
+ * @param  string $theme  CSS filename to be removed
+ */
 	public static function dropCss($folder,$theme)
 	{
@@ -229,4 +334,11 @@
 	}
 
+/**
+ * Return public URL of user defined CSS
+ *
+ * @param  string $folder CSS folder
+ *
+ * @return string         CSS file URL
+ */
 	public static function publicCssUrlHelper($folder)
 	{
@@ -242,4 +354,11 @@
 	}
 
+/**
+ * Return real path of folder images
+ *
+ * @param  string $folder images folder
+ *
+ * @return string         real path of folder
+ */
 	public static function imagesPath($folder)
 	{
@@ -248,4 +367,11 @@
 	}
 
+/**
+ * Return URL of images folder
+ *
+ * @param  string $folder images folder
+ *
+ * @return string         URL of images folder
+ */
 	public static function imagesURL($folder)
 	{
@@ -254,4 +380,12 @@
 	}
 
+/**
+ * Check if images folder exists and may be written
+ *
+ * @param  string  $folder images folder
+ * @param  boolean $create create the folder if not exists
+ *
+ * @return boolean          true if folder exists and may be written
+ */
 	public static function canWriteImages($folder,$create=false)
 	{
@@ -291,5 +425,14 @@
 	}
 
-	public static function uploadImage($folder,$f)
+/**
+ * Upload an image in images folder
+ *
+ * @param  string $folder images folder
+ * @param  string $f      image filename
+ * @param  int    $width  check accurate width of uploaded image if <> 0
+ *
+ * @return string         full pathname of uploaded image
+ */
+	public static function uploadImage($folder,$f,$width=0)
 	{
 		if (!self::canWriteImages($folder,true)) {
@@ -310,7 +453,9 @@
 		}
 
-		$s = getimagesize($dest);
-		if ($s[0] != 800) {
-			throw new Exception(__('Uploaded image is not 800 pixels wide.'));
+		if ($width) {
+			$s = getimagesize($dest);
+			if ($s[0] != $width) {
+				throw new Exception(sprintf(__('Uploaded image is not %s pixels wide.'),$width));
+			}
 		}
 
@@ -318,22 +463,26 @@
 	}
 
+/**
+ * Delete an image from images folder (with its thumbnails if any)
+ *
+ * @param  string $folder images folder
+ * @param  string $img    image filename
+ */
 	public static function dropImage($folder,$img)
 	{
+		global $core;
+
 		$img = path::real(self::imagesPath($folder).'/'.$img);
 		if (is_writable(dirname($img))) {
+			// Delete thumbnails if any
+			try {
+				$media = new dcMedia($core);
+				$media->imageThumbRemove($img);
+			} catch (Exception $e) {
+				$core->error->add($e->getMessage());
+			}
+			// Delete image
 			@unlink($img);
-			// Following lines should be replaced by a media thumbnails removal tool
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_sq.jpg');
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_m.jpg');
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_s.jpg');
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_sq.jpg');
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_t.jpg');
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_sq.png');
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_m.png');
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_s.png');
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_sq.png');
-			@unlink(dirname($img).'/.'.basename($img,'.png').'_t.png');
-		}
-	}
-
+		}
+	}
 }
