Changeset 2659:4179a83ea959 for inc/admin/lib.themeconfig.php
- Timestamp:
- 02/13/14 16:48:49 (11 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.themeconfig.php
r2658 r2659 21 21 class dcThemeConfig 22 22 { 23 // Utilities 24 23 24 /** 25 * Compute contrast ratio between two colors 26 * 27 * @param string $color text color 28 * @param string $background background color 29 * 30 * @return float computed ratio 31 */ 25 32 public static function computeContrastRatio($color,$background) 26 33 { … … 48 55 } 49 56 57 /** 58 * Compute WCAG contrast ration level 59 * 60 * @param float $ratio computed ratio between foreground and backround color 61 * @param string $size font size as defined in CSS 62 * @param boolean $bold true if bold font 63 * 64 * @return string WCAG contrast ratio level (AAA, AA or <nothing>) 65 */ 50 66 public static function contrastRatioLevel($ratio,$size,$bold=false) 51 67 { … … 97 113 } 98 114 115 /** 116 * Return full information about constrat ratio 117 * 118 * @param string $color text color 119 * @param string $background background color 120 * @param string $size font size 121 * @param boolean $bold bold font 122 * 123 * @return string contrast ratio including WCAG level 124 */ 99 125 public static function contrastRatio($color,$background,$size='',$bold=false) 100 126 { … … 109 135 } 110 136 137 /** 138 * Check font size 139 * 140 * @param string $s font size 141 * 142 * @return string checked font size 143 */ 111 144 public static function adjustFontSize($s) 112 145 { … … 120 153 } 121 154 155 /** 156 * Check object position, should be x:y 157 * 158 * @param string $p position 159 * 160 * @return string checked position 161 */ 122 162 public static function adjustPosition($p) 123 163 { … … 130 170 } 131 171 172 /** 173 * Check a CSS color 174 * 175 * @param string $c CSS color 176 * 177 * @return string checked CSS color 178 */ 132 179 public static function adjustColor($c) 133 180 { … … 151 198 } 152 199 153 // CSS file management 200 /** 201 * Check and clean CSS 202 * 203 * @param string $css CSS to be checked 204 * 205 * @return string checked CSS 206 */ 154 207 public static function cleanCSS($css) 155 208 { … … 158 211 } 159 212 213 /** 214 * Return real path of a user defined CSS 215 * 216 * @param string $folder CSS folder 217 * 218 * @return string real path of CSS 219 */ 160 220 public static function cssPath($folder) 161 221 { … … 164 224 } 165 225 226 /** 227 * Retirn URL of a user defined CSS 228 * 229 * @param string $folder CSS folder 230 * 231 * @return string CSS URL 232 */ 166 233 public static function cssURL($folder) 167 234 { … … 170 237 } 171 238 239 /** 240 * Check if user defined CSS may be written 241 * 242 * @param string $folder CSS folder 243 * @param boolean $create create CSS folder if necessary 244 * 245 * @return boolean true if CSS folder exists and may be written, else false 246 */ 172 247 public static function canWriteCss($folder,$create=false) 173 248 { … … 201 276 } 202 277 278 /** 279 * Store CSS property value in associated array 280 * 281 * @param array $css CSS associated array 282 * @param string $selector selector 283 * @param string $prop property 284 * @param string $value value 285 */ 203 286 public static function prop(&$css,$selector,$prop,$value) 204 287 { … … 208 291 } 209 292 293 /** 294 * Store background image property in CSS associated array 295 * 296 * @param string $folder image folder 297 * @param array $css CSS associated array 298 * @param string $selector selector 299 * @param boolean $value false for default, true if image should be set 300 * @param string $image image filename 301 */ 210 302 public static function backgroundImg($folder,&$css,$selector,$value,$image) 211 303 { … … 216 308 } 217 309 310 /** 311 * Write CSS file 312 * 313 * @param string $folder CSS folder 314 * @param string $theme CSS filename 315 * @param string $css CSS file content 316 */ 218 317 public static function writeCss($folder,$theme,$css) 219 318 { … … 221 320 } 222 321 322 /** 323 * Delete CSS file 324 * 325 * @param string $folder CSS folder 326 * @param string $theme CSS filename to be removed 327 */ 223 328 public static function dropCss($folder,$theme) 224 329 { … … 229 334 } 230 335 336 /** 337 * Return public URL of user defined CSS 338 * 339 * @param string $folder CSS folder 340 * 341 * @return string CSS file URL 342 */ 231 343 public static function publicCssUrlHelper($folder) 232 344 { … … 242 354 } 243 355 356 /** 357 * Return real path of folder images 358 * 359 * @param string $folder images folder 360 * 361 * @return string real path of folder 362 */ 244 363 public static function imagesPath($folder) 245 364 { … … 248 367 } 249 368 369 /** 370 * Return URL of images folder 371 * 372 * @param string $folder images folder 373 * 374 * @return string URL of images folder 375 */ 250 376 public static function imagesURL($folder) 251 377 { … … 254 380 } 255 381 382 /** 383 * Check if images folder exists and may be written 384 * 385 * @param string $folder images folder 386 * @param boolean $create create the folder if not exists 387 * 388 * @return boolean true if folder exists and may be written 389 */ 256 390 public static function canWriteImages($folder,$create=false) 257 391 { … … 291 425 } 292 426 293 public static function uploadImage($folder,$f) 427 /** 428 * Upload an image in images folder 429 * 430 * @param string $folder images folder 431 * @param string $f image filename 432 * @param int $width check accurate width of uploaded image if <> 0 433 * 434 * @return string full pathname of uploaded image 435 */ 436 public static function uploadImage($folder,$f,$width=0) 294 437 { 295 438 if (!self::canWriteImages($folder,true)) { … … 310 453 } 311 454 312 $s = getimagesize($dest); 313 if ($s[0] != 800) { 314 throw new Exception(__('Uploaded image is not 800 pixels wide.')); 455 if ($width) { 456 $s = getimagesize($dest); 457 if ($s[0] != $width) { 458 throw new Exception(sprintf(__('Uploaded image is not %s pixels wide.'),$width)); 459 } 315 460 } 316 461 … … 318 463 } 319 464 465 /** 466 * Delete an image from images folder (with its thumbnails if any) 467 * 468 * @param string $folder images folder 469 * @param string $img image filename 470 */ 320 471 public static function dropImage($folder,$img) 321 472 { 473 global $core; 474 322 475 $img = path::real(self::imagesPath($folder).'/'.$img); 323 476 if (is_writable(dirname($img))) { 477 // Delete thumbnails if any 478 try { 479 $media = new dcMedia($core); 480 $media->imageThumbRemove($img); 481 } catch (Exception $e) { 482 $core->error->add($e->getMessage()); 483 } 484 // Delete image 324 485 @unlink($img); 325 // Following lines should be replaced by a media thumbnails removal tool 326 @unlink(dirname($img).'/.'.basename($img,'.png').'_sq.jpg'); 327 @unlink(dirname($img).'/.'.basename($img,'.png').'_m.jpg'); 328 @unlink(dirname($img).'/.'.basename($img,'.png').'_s.jpg'); 329 @unlink(dirname($img).'/.'.basename($img,'.png').'_sq.jpg'); 330 @unlink(dirname($img).'/.'.basename($img,'.png').'_t.jpg'); 331 @unlink(dirname($img).'/.'.basename($img,'.png').'_sq.png'); 332 @unlink(dirname($img).'/.'.basename($img,'.png').'_m.png'); 333 @unlink(dirname($img).'/.'.basename($img,'.png').'_s.png'); 334 @unlink(dirname($img).'/.'.basename($img,'.png').'_sq.png'); 335 @unlink(dirname($img).'/.'.basename($img,'.png').'_t.png'); 336 } 337 } 338 486 } 487 } 339 488 }
Note: See TracChangeset
for help on using the changeset viewer.