Dotclear

Changeset 389


Ignore:
Timestamp:
04/05/08 21:21:00 (16 years ago)
Author:
sacha
Message:

My Favicon : Mimetypes auto-detection

Location:
plugins/myfavicon
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • plugins/myfavicon/_define.php

    r388 r389  
    1919     /* Description*/    "Add a customized favicon to your blog", 
    2020     /* Author */        "Oleksandr Syenchuk", 
    21      /* Version */       '0.1', 
     21     /* Version */       '0.2', 
    2222     /* Permissions */   'contentadmin' 
    2323); 
  • plugins/myfavicon/_install.php

    r388 r389  
    3030# New install / update 
    3131$sets->put('favicon_url','','string','Favicon URL',false); 
    32 $sets->put('favicon_mimetype','image/png','string','Favicon MIME type',false); 
    3332 
    3433# --SETTING NEW VERSION-- 
  • plugins/myfavicon/_public.php

    r388 r389  
    2424class myFavicon 
    2525{ 
     26     #FIXME Mimetypes in common/lib.files.php (Clearbricks) are not enough 
    2627     public static $allowed_mimetypes = array( 
    27           'image/x-icon', 
    28           'image/png', 
    29           'image/bmp', 
    30           'image/gif', 
    31           'image/jpeg', 
    32           'video/x-mng' 
     28          'ico' => 'image/x-icon', 
     29          'png' => 'image/png', 
     30          'bmp' => 'image/bmp', 
     31          'gif' => 'image/gif', 
     32          'jpg' => 'image/jpeg', 
     33          'mng' => 'video/x-mng' 
    3334     ); 
    3435      
     
    5051     } 
    5152 
    52      private static function faviconHTML(&$sets) 
     53     private static function faviconHTML(&$settings) 
    5354     { 
    54           $favicon_url = $sets->favicon_url; 
    55           $favicon_mimetype = $sets->favicon_mimetype; 
     55          $favicon_url = $settings->favicon_url; 
    5656           
    57           if (empty($favicon_url) || empty($favicon_mimetype) 
    58           || !in_array($favicon_mimetype,self::$allowed_mimetypes)) { 
     57          if (empty($favicon_url)) { 
    5958               return; 
    6059          } 
    6160           
    62           return '<link rel="icon" type="'.$favicon_mimetype. 
     61          $extension = files::getExtension($favicon_url); 
     62           
     63          if (!isset(self::$allowed_mimetypes[$extension])) { 
     64               $mimetype = files::getMimeType($favicon_url); 
     65               if (!in_array($mimetype,self::$allowed_mimetypes)) { 
     66                    return; 
     67               } 
     68          } 
     69          else { 
     70               $mimetype = self::$allowed_mimetypes[$extension]; 
     71          } 
     72           
     73          return '<link rel="icon" type="'.$mimetype. 
    6374               '" href="'.html::escapeHTML($favicon_url).'" />'; 
    6475     } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map