Plugin Directory

Changeset 144083


Ignore:
Timestamp:
08/08/2009 09:07:45 PM (17 years ago)
Author:
UnderWordPressure
Message:

Parser Bugfix

Location:
faviroll/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • faviroll/trunk/Faviroll.class.php

    r139728 r144083  
    2525
    2626    // Members
    27     var $basename = null;
    2827    var $cachedir = null;
    2928    var $cacheurl = null;
    3029    var $pluginurl = null;
    31     var $plugindir = null;
    3230    var $lastcheck = null;
    3331    var $defaulticon = null;
    3432    var $transparency = null;
     33    var $debug = false;
    3534
    3635
     
    5049    function __construct($init=true) {
    5150
    52         $this->basename = plugin_basename(dirname(__FILE__));
    5351        $this->initURLsAndDirs();
    5452
     
    7876        if (empty($revisit))
    7977            $init && update_option('faviroll_revisit', 14);
     78
     79        // default is enabled background tranparency.
     80        $this->debug = get_option('faviroll_debug');
     81        if (empty($this->debug))
     82            $init && update_option('faviroll_debug','off');
     83
     84        $this->debug = (get_option('faviroll_debug') == 'on');
    8085
    8186        // caretaker
     
    186191
    187192                $handle = @fopen($icopath,'wb');
    188                 if ($handle) {
     193                if ($handle !== false) {
    189194                    fwrite($handle,$ico->rawdata);
    190195                    fflush($handle);
     
    402407
    403408        echo'</p></div><script type="text/javascript">var t = document.getElementById("message"); if (t){ t.style.display = "none"; }</script>';
     409
    404410        flush();
    405411        ob_flush();
     
    414420    function initURLsAndDirs() {
    415421
    416         $this->plugindir = $this->normalize(WP_PLUGIN_DIR.'/'.$this->basename);
    417         $this->cachedir = $this->normalize($this->plugindir.'/cache');
    418 
     422        $this->cachedir = $this->normalize(plugin_dir_path(__FILE__).'/cache');
    419423
    420424        // -------------- [Plugin URL ermitteln ] --------------
    421         $this->pluginurl = WP_PLUGIN_URL.'/'.$this->basename;
     425        $this->pluginurl = plugin_dir_url(__FILE__);
     426
    422427        $elems = parse_url($this->pluginurl);
    423428
     
    435440        if (!isset($request['path']))
    436441            return false;
     442
    437443
    438444        $cURL = trim(rtrim($request['path'],'/'));
     
    445451        }
    446452
    447         $this->cacheurl = $this->pluginurl.'/cache';
     453        $this->cacheurl = trim(rtrim($this->pluginurl,'/')).'/cache';
    448454        return true;
    449455    }
     
    459465        $cElems = explode('/',$current_url);
    460466        $pElems = explode('/',$plugin_url);
     467
    461468
    462469        // eleminate identically path elements from both arrays
     
    474481        } else {
    475482
     483            // Wenn der Request Path nicht mit Slash endet, entferne den letzten Namen,
     484            // da dann das Verzeichnis darüber gilt. Quasi der "dirname()"
    476485            if (substr($request_path,-1) != '/')
    477486                array_pop($cElems);
     
    522531Use your ftp client, or the following command to fix it:<br />
    523532<br />
    524 <code># chmod 0755 ".$this->cachedir."</code></p></div>";
     533<code># chmod 0775 ".$this->cachedir."</code></p></div>";
    525534
    526535    }
     
    533542        return $this->is__writable(rtrim($this->cachedir,'/').'/');
    534543    }
     544
    535545
    536546    /**
     
    618628        }
    619629
    620 # debugging
    621 #echo "<p>$typeOfURL<br>$faviconURL</p>";
    622 
    623630        if($this->validateURL($faviconURL))
    624631            return $faviconURL;
     
    664671    }
    665672
     673
     674    /**
     675     * TODO
     676     */
     677    function patchPlugin($plugindir,$activate=false) {
     678
     679        $result = null;
     680
     681        foreach (get_plugins() as $path => $data) {
     682            if (strpos($path,$plugindir) === 0) {
     683                $pluginfile = $path;
     684                break;
     685            }
     686        }
     687
     688        if (!isset($pluginfile))
     689            return true;
     690
     691        $pluginfile = WP_PLUGIN_DIR."/$pluginfile";
     692        if (!is_file($pluginfile) || !is_writable($pluginfile))
     693            return true;
     694
     695        switch ($plugindir) {
     696            case 'wp-render-blogroll-links':
     697
     698                break;
     699            default:
     700                break;
     701        }
     702
     703        return true;
     704    }
     705
     706
     707
     708
     709
     710
     711
    666712// -----------------------Non - Admin Functions -----------------------------------------------------------------------
    667713
     
    675721        $default_favicon = get_option('faviroll_default_favicon');
    676722
    677         // get cached icon list
     723        // get list of cached icons
    678724        $cacheIcons = $this->getCacheIcons();
    679725
     
    688734            $line = trim($line);
    689735
    690             if (!preg_match('/href=[\'"](.*)[\'"]/', $line, $matches) && !preg_match('/img/', $line)) {
     736            if (!(bool) @preg_match('/a[\s]+[^>]*?href[\s]?=[\s\"\']+(.*?)[\"\']+.*?>([^<]+|.*?)?<\/a>/i', $line, $matches)) {
    691737                // overhead stuff
    692738                $newContent[] = $line;
     
    694740            }
    695741
    696             if (count($matches) < 2) {
     742            if (count($matches) < 3) {
    697743                // overhead stuff
    698744                $newContent[] = $line;
     
    700746            }
    701747
    702             extract($this->getURLinfo($matches[1]),EXTR_OVERWRITE);
     748            $urlInfo = $this->getURLinfo($matches[1]);
     749            extract($urlInfo,EXTR_OVERWRITE);
     750
     751            // Es konnte keine Checksumme ermittelt werden
     752            // also einfach die Zeile as-is übernehmen
    703753            if (!isset($checksum)) {
    704                 // overhead stuff
    705754                $newContent[] = $line;
    706755                continue;
     
    717766            $newContent[] = $line;
    718767        }
     768
    719769
    720770        return "<!-- Begin:FaviRoll Plugin -->\n".implode("\n",$newContent)."\n<!-- End:FaviRoll Plugin -->";
  • faviroll/trunk/faviroll.php

    r140233 r144083  
    55Description: Locally caches all favicon.ico in PNG format and use this into the blogroll. Native ICO Images are not supported from all browsers/operating systems. <strong><a href="link-manager.php?page=faviroll.php">Settings &raquo; Faviroll</a></strong>
    66Author: grobator
    7 Version:  0.4.4
     7Version:  0.4.5
    88Author URI:  http://www.grobator.de/
    99----------------------------------------------------------------------------------------
     
    2626
    2727// Debug only on localhost
    28 if ($_SERVER['HTTP_HOST'] == 'localhost') error_reporting(E_ALL);
     28if ($_SERVER['HTTP_HOST'] == 'localhost') error_reporting(E_ALL);  // |E_STRICT
    2929
    3030require_once('Faviroll.class.php');
     
    3939}
    4040add_filter('wp_list_bookmarks', 'faviroll_list_bookmarks');
    41 
     41add_filter('wp_list_bookmarks_plus', 'faviroll_list_bookmarks');
    4242
    4343/**
     
    7676function faviroll_options(){
    7777
     78faviroll_activate();
    7879    $message = null;
    7980    $removeSettings = isset($_REQUEST['faviroll_remove_settings']);
     
    101102            update_option('faviroll_revisit'     , (int) trim($_REQUEST['faviroll_revisit']));
    102103            update_option('faviroll_transparency', (isset($_REQUEST['faviroll_transparency']) ? 'on' : 'off') );
     104            update_option('faviroll_debug'       , (isset($_REQUEST['faviroll_debug']) ? 'on' : 'off') );
    103105
    104106            $message = 'Settings updated';
     
    113115
    114116    $is_transparency = (get_option('faviroll_transparency') == 'on');
    115 
     117    $is_debugMode    = (get_option('faviroll_debug') == 'on');
    116118
    117119    if (!$removeSettings) {
     
    130132
    131133    echo '
    132             <div class="wrap">
    133                 <h2>'.__('FAVIcons for blogROLL', 'faviroll').'</h2>'.$faviroll->get_message($message).'
    134                 <form id="faviroll" name="faviroll" method="post">
    135                 <table class="form-table" summary="">
     134 <div class="wrap">
     135
     136  <h2 style="display:inline;">'.__('FAVIcons for blogROLL', 'faviroll').'</h2>'.$faviroll->get_message($message).'<br />
     137  <h4 style="display:inline;">Currently [ '.$faviroll->cacheIconsCount().' ] icons in the cache directory.</h4>
     138
     139 <div style="float: right;"><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
     140 <input type="hidden" name="cmd" value="_s-xclick">
     141 <input type="hidden" name="hosted_button_id" value="7362367">
     142 <input type="image" src="https://www.paypalobjects.com/WEBSCR-580-20090807-1/de_DE/DE/i/btn/x-click-butcc-donate.gif" border="0" name="submit" alt="Make a donation" title="Make a donation">
     143 <img alt="" border="0" src="https://www.paypal.com/de_DE/i/scr/pixel.gif" width="1" height="1">
     144 </form></div>
     145
     146   <form id="faviroll" name="faviroll" method="post">
     147    <table class="form-table" summary="">
     148     <tr>
     149      <td><strong>Settings</strong></td>
     150     </tr>
     151     <tr>
     152      <td scope="row" valign="top">Default Favicon URL:</td>
     153      <td><input type="text" name="faviroll_default_favicon" size="120" value="'.$default_favicon.'" /><br />(If the favicon on the link is missing this will be shown instead.)</td>
     154     </tr>
     155     <tr>
     156      <td scope="row">Favions revisit after:</td>
     157      <td><input type="text" name="faviroll_revisit" size="4" value="'.$revisit.'" /> days</td>
     158     </tr>
     159     <tr>
     160      <td scope="row">Use transparent background:</td>
     161      <td><input type="checkbox" name="faviroll_transparency" value="on"'.($is_transparency ? ' checked="checked"' : null).' /></td>
     162     </tr>
     163     <tr>
     164      <td scope="row">&nbsp;</td>
     165      <td><a href="plugin-editor.php?file=faviroll/style.css&plugin=faviroll/faviroll.php" title="Edit the faviroll css-styles">Edit faviroll stylesheet</a></td>
     166     </tr>
     167     <tr>
     168      <td colspan="2" width="98%"><hr size="1" /></td>
     169     </tr>
     170     <tr>
     171      <td><strong>Actions</strong></td>
     172     </tr>
     173     <tr>
     174      <td scope="row">(re)build FavIcons now:</td>
     175      <td><input type="checkbox" name="faviroll_renew_icons" value="true"'.(($faviroll->cacheIconsCount() == 0) ? ' checked="checked"' : null).' /></td>
     176     </tr>
     177     <tr>
     178      <td scope="row" title="This will remove plugin settings from database and drop the favicon cache">Remove settings:</td>
     179      <td><input type="checkbox" name="faviroll_remove_settings" value="true" />
     180     </tr>
     181';
     182/*
    136183                <tr>
    137                     <td><strong>Settings</strong></td>
     184                    <td scope="row" title="Write debug informations as comments into the HTML code">Debug mode:</td>
     185                    <td><input type="checkbox" name="faviroll_debug" value="true" '.($is_debugMode ? ' checked="checked"' : null).' /> &nbsp; ( just for Developers, normally switch off )
    138186                </tr>
    139                 <tr>
    140                     <td scope="row" valign="top">Default Favicon URL:</td>
    141                     <td><input type="text" name="faviroll_default_favicon" size="120" value="'.$default_favicon.'" /><br />(If the favicon on the link is missing this will be shown instead.)</td>
    142                 </tr>
    143                 <tr>
    144                     <td scope="row">Favions revisit after:</td>
    145                     <td><input type="text" name="faviroll_revisit" size="4" value="'.$revisit.'" /> days</td>
    146                 </tr>
    147                 <tr>
    148                     <td scope="row">Use transparent background:</td>
    149                     <td><input type="checkbox" name="faviroll_transparency" value="on"'.($is_transparency ? ' checked="checked"' : null).' />
    150                     &nbsp;&nbsp;&nbsp;<a href="plugin-editor.php?file=faviroll/style.css&plugin=faviroll/faviroll.php" title="Edit the faviroll css-styles">Edit faviroll stylesheet</a>
    151                 </td>
    152                 </tr>
    153                 <tr>
    154                     <td colspan="2" width="98%"><hr size="1" /></td>
    155                 </tr>
    156                 <tr>
    157                     <td><strong>Actions</strong></td>
    158                 </tr>
    159                 <tr>
    160                     <td scope="row">(re)build FavIcons now:</td>
    161                     <td><input type="checkbox" name="faviroll_renew_icons" value="true"'.(($faviroll->cacheIconsCount() == 0) ? ' checked="checked"' : null).' /></td>
    162                 </tr>
    163                 <tr>
    164                     <td scope="row" title="This will remove plugin settings from database and drop the favicon cache">Remove settings:</td>
    165                     <td><input type="checkbox" name="faviroll_remove_settings" value="true" />
    166                 </tr>
    167                 <tr>
    168                     <td class="submit"><input type="submit" name="submit_button" value="Submit" />
    169                         <input type="hidden" name="_wpnonce" value="'.$nonce.'" />
    170                     </td>
    171                 </tr>
    172                 </table>
    173                 </form>
    174             </div>
    175          ';
     187*/
     188    echo '     <tr>
     189      <td class="submit"><input type="submit" name="submit_button" value="Submit" /><input type="hidden" name="_wpnonce" value="'.$nonce.'" /></td>
     190     </tr>
     191    </table>
     192   </form>
     193  </div>
     194';
    176195
    177196        flush();
     
    198217add_action('wp_enqueue_scripts', 'faviroll_enqueue_scripts');
    199218
     219
     220/**
     221 * Actions on plugin activation
     222 */
     223function faviroll_activate() {
     224    $faviroll = new Faviroll();
     225    return $faviroll->patchPlugin('wp-render-blogroll-links',true);
     226}
     227register_activation_hook(__FILE__, 'faviroll_activate');
     228
     229
     230/**
     231 * Actions on plugin deactivation
     232 */
     233function faviroll_deactivate() {
     234    $faviroll = new Faviroll();
     235    return $faviroll->patchPlugin('wp-render-blogroll-links',false);
     236}
     237register_deactivation_hook(__FILE__, 'faviroll_deactivate');
     238
    200239/* eof */
    201240?>
  • faviroll/trunk/readme.txt

    r140233 r144083  
    44Requires at least: 2.7
    55Tested up to: 2.8
    6 Stable tag: 0.4.4
     6Stable tag: 0.4.5
    77
    88Locally caches all favicon.ico in PNG format and use this into the blogroll. Native ICO Images are not supported from all browsers (f.e. IE).
     
    20202. Faviroll configuration panel
    21213. (re)build the local cache with the remote favicons
     224. Remove the double slashes in WP-Render-Blogroll.php, if you want to have the faviroll icons in the blogroll of this plugin.
    2223
    2324== Installation ==
     
    3334
    3435== Changelog ==
     36= 0.4.5 =
     37* FIXED: Parser has not recognized Blogroll-Links with additional attributes like title="...", rel="...", etc.
     38Many many thanks for patient debugging support of: http://www.heiniger-net.ch/daniel
     39* prepared for the new version of http://wordpress.org/extend/plugins/wp-render-blogroll-links/
     40* Unfortunately this plugin needs a little patch. See Screenshot-4.
     41* If possible, the patch will done by the faviroll plugin automatically.
    3542= 0.4.4 =
     43* Settings panel now you can find under "Links".
    3644* Image type recognition. Just the ICO image is converted into PNG. All other image formats are bypass direct into the local cache. This will maximize the usage of the foreign favicons.
    3745= 0.4.3 =
Note: See TracChangeset for help on using the changeset viewer.