Plugin Directory

Changeset 161987


Ignore:
Timestamp:
10/09/2009 08:58:36 PM (16 years ago)
Author:
Astrodan
Message:
 
Location:
wpmathpublisher
Files:
62 added
3 edited

Legend:

Unmodified
Added
Removed
  • wpmathpublisher/trunk/readme.txt

    r161694 r161987  
    44Requires at least: 2.5
    55Tested up to: 2.8.4
    6 Stable tag: 0.5
     6Stable tag: 0.6
    77
    88Plugin that allows formulars to be included in blog texts (as graphics)
     
    1919
    2020Currently it supports the following **features**:
    21 * Basic function: Convert equations into graphics
    22 * Font and background color can be chosen by you in the admin panel (alpha-transparency included, but if you are using Microsoft Internet Explorer you will need version 7 or greater to display the images correctly)
    23 * Font size default value can be set, but also changed for every single image if necessary
    24 * If you just want to output a formula there is a "noparse" attribute that will output the pure text nicely formatted
    25 * Saves the images on the webspace, which saves processor time
    26 * Clear image cache and let all images be regenerated by admin panel
     21
     22*   Basic function: Convert equations into graphics
     23*   Font and background color can be chosen by you in the admin panel (alpha-transparency included, but if you are using Microsoft Internet Explorer you will need version 7 or greater to display the images correctly)
     24*   Font size default value can be set, but also changed for every single image if necessary
     25*   If you just want to output a formula there is a "noparse" attribute that will output the pure text nicely formatted
     26*   Saves the images on the webspace, which saves processor time
     27*   Clear image cache and let all images be regenerated by admin panel
     28*   Integration in TinyMCE editor
    2729
    2830**Configuration**:
    2931
    3032To configure the plugin there is an easy to use admin panel page (since v0.3.1).
    31 Here you can choose the RGB-components of the font and background color. In addition to that you can choose an alpha-transparency.
     33Here you can change the the color by using a javascript color picker, and the transparency value for the graphic
    3234Furthermore you can choose a default font-size used for the images
    3335
     
    3941
    4042The plugin ist currently available in
    41 * English (default)
    42 * German (Translated by me)
     43*   English (default)
     44*   German (translated by me)
     45
     46== Changelog ==
     47
     48= 0.4 [2008-07-09] =
     49* Fixed keeping a variable for theme-page output that was meant to be only temporary
     50* added function to clear the image cache and let the images be regenerated
     51= 0.4.1 [2009-02-12] =
     52* Fixed error occuring while installation
     53= 0.4.2 [2009-03-08] =
     54* Cleaned up code
     55* removed making background transparent bye choosing so, use alpha = 127 instead
     56* offers change of size for each individual image
     57= v 0.4.3 [2009-03-08] =
     58* added noparse attribute
     59* added short user guide on plugins configuration page
     60* removed deactivation hook to preserve configuration if plugin is updated
     61= v 0.4.3.1 [2009-03-08] =
     62* fixed a problem with the svn, reupload for complete installation
     63= v 0.4.4 [2009-09-*] (never uploaded) =
     64* fixed height of text in graphics as suggested by a productive user ;)
     65= v 0.5 [2009-10-09] =
     66* removed reading options written by older versions of this plugin
     67* added german translation ("Sie" und "Du")
     68* will create image folder if possible
     69* if image folder is not writeable or could not be created, plugin will output a message in admin center
     70* added option to change default fontsize
     71* exported display settings of admin page to css-file
     72= v 0.6 [2009-10-09] =
     73* outputs allowed font size
     74* gone to be awesome ;)
     75* integration in tinymce 3.x
     76* added simple color-picker by integrating [jscolor](http://jscolor.com/ "JavaScript Color Picker")
     77* temporary added ability to import old database values - really got to get this saving stuff sorted out
     78* update of translation
    4379
    4480== Installation ==
     
    50861. Upload the extracted folder, including all subfolders (no matter if empty or not) to the plugin directory of your wordpress installation (/wp-content/plugins/)
    51871. Activate the plugin in your wordpress administration center
    52 1. If necessary, create the folder "img" as subdirectory of the wpmathpublisher directory and set it to chmod 777
     881. If necessary (script will tell you) , create the folder "img" as subdirectory of the wpmathpublisher directory and set it to chmod 777
    53891. Done. Go for it!
    5490
  • wpmathpublisher/trunk/style.css

    r161694 r161987  
    7878    background-repeat: no-repeat;
    7979}
     80
     81.comment {
     82    font-size: 70%;
     83    font-style: italic;
     84}
  • wpmathpublisher/trunk/wpmathpublisher.php

    r161694 r161987  
    77Author URI: http://kraeuterbruederchen.de
    88Text Domain: wpmathpublisher
    9 Version: 0.5
     9Version: 0.6
    1010
    1111Copyright:
     
    3232    v 0.4.4 [2009-09-*] (never uploaded)
    3333        ! fixed height of text in graphics as suggested by a productive user ;)
    34     v 0.5
     34    v 0.5 [2009-10-09]
    3535        - removed reading options written by older versions of this plugin
    3636        + added german translation ("Sie" und "Du")
     
    3939        + added option to change default fontsize
    4040        ! exported display settings of admin page to css-file
     41    v 0.6 [2009-10-09]
     42        + integration in tinymce 3.x
     43        + outputs allowed font size
     44        + added simple color-picker by integrating jscolor
     45        + temporary added ability to import old database values - really got to get this saving stuff sorted out
     46        ! update of translation
    4147       
    4248Roadmap:
    4349    - add option to change default fontset
    44     - display maximum font size / minimum font size
    45     - nicer font-chooser
     50    - add transparence slider
    4651*/
    4752
     
    6166define('WPMP_BASEURL', WP_PLUGIN_URL.'/'.WPMP_FOLDER);
    6267
    63 define('WPMP_FONT_MAX', 24);
    64 define('WPMP_FONT_MIN', 10);
    65    
    66 // Include PhpMathPublisher
     68## get other constants
     69include_once('constants.php');
     70   
     71## include PhpMathPublisher
    6772include_once('mathpublisher.php');
    6873 
    6974class WpMathPublisher {
    70     var $font = array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0);
    71     var $back = array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0);
     75    var $font = array('color' => '000000', 'alpha' => 0);
     76    var $back = array('color' => 'ffffff', 'alpha' => 0);
    7277    var $size = 12;
    7378    var $imgPath = '';
     
    97102    function admin_menu() {
    98103        wp_enqueue_style('wpmathpublisher', WPMP_BASEURL.'/style.css');
     104        wp_enqueue_script('wpmathpublisher-jscolor', WPMP_BASEURL.'/inc/jscolor/jscolor.js');
    99105        add_theme_page(__('WpMathPublisher', WPMP_TEXTDOMAIN), __('WpMathPublisher', WPMP_TEXTDOMAIN), 5, WPMP_BASEDIR.'/inc/admin_themePage.php');
    100106    }
     
    102108    ## initialization function
    103109    function init() {
     110        # get localization
    104111        load_plugin_textdomain(WPMP_TEXTDOMAIN, WPMP_BASEDIR.'/locale', WPMP_FOLDER.'/locale');
    105112       
    106         if(!$this->ready) {
     113        # output information if plugin is not ready
     114        if(!$this->ready)
    107115            echo '<div id="wpmp-warning" class="updated fade"><p><strong>'.__('WpMathPublisher not yet ready: ').'</strong>'.sprintf(__('Couldn\'t access image directory [%s], create it and chmod it to 777.', WPMP_TEXTDOMAIN), WPMP_FOLDER.'/img').'</p></div>';
    108         }
     116
     117        # add tinymce buttons (only if necessary)
     118        if(( current_user_can('edit_posts') || current_user_can('edit_pages') ) && get_user_option('rich_editing') ) {
     119            add_filter("mce_external_plugins", array($this, 'addTinyMcePlugin'));
     120            add_filter('mce_buttons', array($this, 'registerButton'));
     121        }
     122       
     123    }
     124   
     125    ## function to add button to tinymce
     126    function registerButton($_buttons) {
     127        array_push($_buttons, 'wpmathpublisher', '|');
     128        return $_buttons;
     129    }
     130   
     131    ## function to add plugin
     132    function addTinyMcePlugin($_pluginArray) {
     133        $_pluginArray['wpmathpublisher'] = WPMP_BASEURL.'/tinymce/editor_plugin.js';
     134        return $_pluginArray;
    109135    }
    110136   
     
    118144            deactivate_plugins(basename(__FILE__)); // Deactivate itself
    119145        }
     146       
     147        $font = get_option('wpmathpublisher_font');
     148        $back = get_option('wpmathpublisher_back');
     149        if(isset($font['red'])) {
     150            ## convert old values
     151            $fontColor = $this->convertRgbToHex($font);
     152            update_option('wpmathpublisher_font', array('color' => $fontColor, 'alpha' => $font['alpha']));
     153            $backColor = $this->convertRgbToHex($back);
     154            update_option('wpmathpublisher_back', array('color' => $backColor, 'alpha' => $back['alpha']));
     155           
     156            $this->clearCache();
     157            $this->readOptions();
     158        }
    120159           
    121160        add_option('wpmathpublisher_font', $this->font);
     
    134173    ## resets the plugins options to default values
    135174    function toDefaults() {
    136         update_option('wpmathpublisher_font', array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0));
    137         update_option('wpmathpublisher_back', array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 0));
     175        update_option('wpmathpublisher_font', array('color' => '000000', 'alpha' => 0));
     176        update_option('wpmathpublisher_back', array('color' => 'ffffff', 'alpha' => 0));
    138177        update_option('wpmathpublisher_size', 12);
    139178       
     
    154193   
    155194    ## function that checks whether given rgb values are valid
    156     function checkRGB($_red, $_green, $_blue, $_alpha=0) {
     195    function checkColor($_color, $_alpha=0) {
    157196        $message = '';
    158         if(!is_numeric($_red) || $_red < 0 || $_red > 255)
    159             $message .= '<li>'. __('value of red component is invalid', WPMP_TEXTDOMAIN).'</li>';
    160         if(!is_numeric($_green) || $_green < 0 || $_green > 255)
    161             $message .= '<li>'. __('value of green component is invalid', WPMP_TEXTDOMAIN).'</li>';
    162         if(!is_numeric($_blue) || $_blue < 0 || $_blue > 255)
    163             $message .= '<li>'. __('value of blue component is invalid', WPMP_TEXTDOMAIN).'</li>';
     197        if(!preg_match_all('~#?[0-9a-f]{6}~i', $_color, $colors) || empty($colors))
     198            $message .= '<li>'. __('invalid color value', WPMP_TEXTDOMAIN).'</li>';
    164199        if(!is_numeric($_alpha) || $_alpha < 0 || $_alpha > 127)
    165200            $message .= '<li>'. __('transparency value is invalid', WPMP_TEXTDOMAIN).'</li>';
    166201       
    167202        return $message;
     203    }
     204   
     205    ## function to convert hex to rgb
     206    function convertHexToRgb($_hex) {
     207        $rgb = array(
     208            'red' => hexdec(substr($_hex, 0, 2)),
     209            'green' => hexdec(substr($_hex, 2, 2)),
     210            'blue' => hexdec(substr($_hex, 4, 2))
     211        );
     212
     213        return $rgb;
     214    }
     215   
     216    ## function to convert rgb to hex
     217    function convertRgbToHex($_colors) {
     218        return sprintf('#%02X%02X%02X', $_colors['red'], $_colors['green'], $_colors['blue']);
    168219    }
    169220   
     
    192243    }
    193244   
    194     // function to delete all images in cache
     245    ## function to delete all images in cache
    195246    function clearCache() {
    196247        $basePath = WPMP_BASEDIR.'/img';
     
    210261    }
    211262
    212     // function to set the background-color of the images
     263    ## function to set the background-color of the images
    213264    function getBackgroundColor($_im) {
    214         $color = imagecolorallocatealpha($_im, $this->back['red'], $this->back['green'], $this->back['blue'], $this->back['alpha']);
     265        $color = $this->convertHexToRgb($this->back['color']);
     266        $color = imagecolorallocatealpha($_im, $color['red'], $color['green'], $color['blue'], $this->back['alpha']);
    215267        return $color;
    216268    }
    217269   
    218     // function to get the font color
     270    ## function to get the font color
    219271    function getFontColor($_im) {
    220         $color = imagecolorallocatealpha($_im, $this->font['red'], $this->font['green'], $this->font['blue'], $this->font['alpha']);
     272        $color = $this->convertHexToRgb($this->font['color']);
     273        $color = imagecolorallocatealpha($_im, $color['red'], $color['green'], $color['blue'], $this->font['alpha']);
    221274        return $color;
    222275    }
Note: See TracChangeset for help on using the changeset viewer.