Dotclear


Ignore:
Timestamp:
02/13/14 16:48:49 (11 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Some doc and minor refinement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/lib.themeconfig.php

    r2658 r2659  
    2121class dcThemeConfig 
    2222{ 
    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 */ 
    2532     public static function computeContrastRatio($color,$background) 
    2633     { 
     
    4855     } 
    4956 
     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 */ 
    5066     public static function contrastRatioLevel($ratio,$size,$bold=false) 
    5167     { 
     
    97113     } 
    98114 
     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 */ 
    99125     public static function contrastRatio($color,$background,$size='',$bold=false) 
    100126     { 
     
    109135     } 
    110136 
     137/** 
     138 * Check font size 
     139 * 
     140 * @param  string $s font size 
     141 * 
     142 * @return string    checked font size 
     143 */ 
    111144     public static function adjustFontSize($s) 
    112145     { 
     
    120153     } 
    121154 
     155/** 
     156 * Check object position, should be x:y 
     157 * 
     158 * @param  string $p position 
     159 * 
     160 * @return string    checked position 
     161 */ 
    122162     public static function adjustPosition($p) 
    123163     { 
     
    130170     } 
    131171 
     172/** 
     173 * Check a CSS color 
     174 * 
     175 * @param  string $c CSS color 
     176 * 
     177 * @return string    checked CSS color 
     178 */ 
    132179     public static function adjustColor($c) 
    133180     { 
     
    151198     } 
    152199 
    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 */ 
    154207     public static function cleanCSS($css) 
    155208     { 
     
    158211     } 
    159212 
     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 */ 
    160220     public static function cssPath($folder) 
    161221     { 
     
    164224     } 
    165225 
     226/** 
     227 * Retirn URL of a user defined CSS 
     228 * 
     229 * @param  string $folder CSS folder 
     230 * 
     231 * @return string         CSS URL 
     232 */ 
    166233     public static function cssURL($folder) 
    167234     { 
     
    170237     } 
    171238 
     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 */ 
    172247     public static function canWriteCss($folder,$create=false) 
    173248     { 
     
    201276     } 
    202277 
     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 */ 
    203286     public static function prop(&$css,$selector,$prop,$value) 
    204287     { 
     
    208291     } 
    209292 
     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 */ 
    210302     public static function backgroundImg($folder,&$css,$selector,$value,$image) 
    211303     { 
     
    216308     } 
    217309 
     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 */ 
    218317     public static function writeCss($folder,$theme,$css) 
    219318     { 
     
    221320     } 
    222321 
     322/** 
     323 * Delete CSS file 
     324 * 
     325 * @param  string $folder CSS folder 
     326 * @param  string $theme  CSS filename to be removed 
     327 */ 
    223328     public static function dropCss($folder,$theme) 
    224329     { 
     
    229334     } 
    230335 
     336/** 
     337 * Return public URL of user defined CSS 
     338 * 
     339 * @param  string $folder CSS folder 
     340 * 
     341 * @return string         CSS file URL 
     342 */ 
    231343     public static function publicCssUrlHelper($folder) 
    232344     { 
     
    242354     } 
    243355 
     356/** 
     357 * Return real path of folder images 
     358 * 
     359 * @param  string $folder images folder 
     360 * 
     361 * @return string         real path of folder 
     362 */ 
    244363     public static function imagesPath($folder) 
    245364     { 
     
    248367     } 
    249368 
     369/** 
     370 * Return URL of images folder 
     371 * 
     372 * @param  string $folder images folder 
     373 * 
     374 * @return string         URL of images folder 
     375 */ 
    250376     public static function imagesURL($folder) 
    251377     { 
     
    254380     } 
    255381 
     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 */ 
    256390     public static function canWriteImages($folder,$create=false) 
    257391     { 
     
    291425     } 
    292426 
    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) 
    294437     { 
    295438          if (!self::canWriteImages($folder,true)) { 
     
    310453          } 
    311454 
    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               } 
    315460          } 
    316461 
     
    318463     } 
    319464 
     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 */ 
    320471     public static function dropImage($folder,$img) 
    321472     { 
     473          global $core; 
     474 
    322475          $img = path::real(self::imagesPath($folder).'/'.$img); 
    323476          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 
    324485               @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     } 
    339488} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map