Plugin Directory

Changeset 161694


Ignore:
Timestamp:
10/08/2009 10:18:47 PM (16 years ago)
Author:
Astrodan
Message:

Updated to v0.5, changelog see wpmathpublisher.php

Location:
wpmathpublisher
Files:
32 added
4 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • wpmathpublisher/trunk/mathpublisher.php

    r100541 r161694  
    17101710   
    17111711    }
    1712 $valign=$v-1000;
     1712$valign=$v-1000-4;
    17131713return '<img src="'.$pathtoimg."math_".$v."_".$nameimg.'" style="vertical-align:'.$valign.'px;'.' display: inline-block;" alt="'.$text.'" title="'.$text.'"/>';
    17141714}
  • wpmathpublisher/trunk/readme.txt

    r100688 r161694  
    33Tags: math, post, equation, formula
    44Requires at least: 2.5
    5 Tested up to: 2.7
    6 Stable tag: 0.4.3.1
     5Tested up to: 2.8.4
     6Stable tag: 0.5
    77
    88Plugin that allows formulars to be included in blog texts (as graphics)
     
    2121* Basic function: Convert equations into graphics
    2222* 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 defaults to 12px, but can be choosen individually for each image
     23* Font size default value can be set, but also changed for every single image if necessary
    2424* If you just want to output a formula there is a "noparse" attribute that will output the pure text nicely formatted
    2525* Saves the images on the webspace, which saves processor time
     
    2828**Configuration**:
    2929
    30 To configure the plugin there is an easy to use admin panel page (since v0.3.1). Here you can choose the RGB-components of the font and background color. In addition to that you can choose an alpha-transparency. To have a look at the result there is a small and (I'm afraid) quite bad preview.
    31 If you want to change the size of the font used in the image output, use the "size" attribute in yout posts: [math size="16"]x^2[/math]
     30To configure the plugin there is an easy to use admin panel page (since v0.3.1).
     31Here you can choose the RGB-components of the font and background color. In addition to that you can choose an alpha-transparency.
     32Furthermore you can choose a default font-size used for the images
    3233
    3334**Commands**:
     
    3738**Translation**:
    3839
    39 So far there is no translation to this plugin, though it supports this. As a feature to be added in future i plan to translate it into german. Other languages would be welcome, so contact me if you need the po-file.
    40 A german description and some installetion notes can be found on the [plugins homepage](http://blog.kraeuterbruederchen.de/wordpress/wpmathpublisher/ "Plugins Homepage")
     40The plugin ist currently available in
     41* English (default)
     42* German (Translated by me)
    4143
    4244== Installation ==
     
    47491. Extract the package using any programm you want (i.e.: [7zip](http://7zip.org/ "7zip archiving tool"))
    48501. Upload the extracted folder, including all subfolders (no matter if empty or not) to the plugin directory of your wordpress installation (/wp-content/plugins/)
    49 1. Make sure the the script can write in the folder /wp-content/plugins/wpmathpubisher/img (chmod 777). This is necessary, because this is where the script saves the images
    50511. Activate the plugin in your wordpress administration center
     521. If necessary, create the folder "img" as subdirectory of the wpmathpublisher directory and set it to chmod 777
    51531. Done. Go for it!
    52 
    53 == Frequently Asked Questions ==
    54 
    55 = How can i change the default font size? =
    56 
    57 Currently there is no comfortable way to do this. But if you are confident of doing some easy editing the code, do the folling changes:
    58 * Choose "edit Plugin" on your Wordpress-Plugin-Page
    59 * Scroll down. There will be a line "var $size = 12;" - change the "12" to your desired font size
    60 * Scroll down further. There is a line "update_option('wpmathpublisher_size', 12);" - again, change the *"12"*
    6154
    6255== Screenshots ==
  • wpmathpublisher/trunk/wpmathpublisher.php

    r100688 r161694  
    66Author: Timm Severin
    77Author URI: http://kraeuterbruederchen.de
    8 Version: 0.4.3.1
     8Text Domain: wpmathpublisher
     9Version: 0.5
    910
    1011Copyright:
     
    2930    v 0.4.3.1 [2009-03-08]
    3031        ! fixed a problem with the svn, reupload for complete installation
     32    v 0.4.4 [2009-09-*] (never uploaded)
     33        ! fixed height of text in graphics as suggested by a productive user ;)
     34    v 0.5
     35        - removed reading options written by older versions of this plugin
     36        + added german translation ("Sie" und "Du")
     37        + will create image folder if possible
     38        + if image folder is not writeable or could not be created, plugin will output a message in admin center
     39        + added option to change default fontsize
     40        ! exported display settings of admin page to css-file
    3141       
    3242Roadmap:
    33     - translate into german
    3443    - add option to change default fontset
    35     - add attribute noparse
     44    - display maximum font size / minimum font size
     45    - nicer font-chooser
    3646*/
    3747
     
    4656    define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
    4757   
     58define('WPMP_TEXTDOMAIN', 'wpmathpublisher');
     59define ('WPMP_FOLDER', basename(dirname(__FILE__)));
     60define('WPMP_BASEDIR', WP_PLUGIN_DIR.'/'.WPMP_FOLDER);
     61define('WPMP_BASEURL', WP_PLUGIN_URL.'/'.WPMP_FOLDER);
     62
     63define('WPMP_FONT_MAX', 24);
     64define('WPMP_FONT_MIN', 10);
     65   
    4866// Include PhpMathPublisher
    4967include_once('mathpublisher.php');
     
    5472    var $size = 12;
    5573    var $imgPath = '';
     74    var $ready = true;
    5675   
    5776    // constructor
    5877    function WpMathPublisher() {
    59         // get path for saving images - create if necessary
    60         $this->imgPath = WP_PLUGIN_URL.'/wpmathpublisher/img/';
     78        $this->__construct();
     79    }
     80   
     81    // constructor for later php versions
     82    function __construct() {
     83        // get path for saving images - create if necessary     
     84        $imgDir = WPMP_BASEDIR.'/img/';
     85        if(!is_dir($imgDir) && !mkdir($imgDir))
     86            $this->ready = false;
     87        if(!is_writeable($imgDir))
     88            $this->ready = false;
     89           
     90       
     91        $this->imgPath = WPMP_BASEURL.'/img/';
    6192
    6293        $this->readOptions();
    6394    }
    6495   
    65     // add theme page
     96    ## add theme page
    6697    function admin_menu() {
    67         add_theme_page(__('WpMathPublisher'), __('WpMathPublisher'), 5, WP_PLUGIN_DIR.'/wpmathpublisher/inc/admin_themePage.php');    // original function, can still be found somewhere down there, but has been replaced by external file. May not be up to date!
     98        wp_enqueue_style('wpmathpublisher', WPMP_BASEURL.'/style.css');
     99        add_theme_page(__('WpMathPublisher', WPMP_TEXTDOMAIN), __('WpMathPublisher', WPMP_TEXTDOMAIN), 5, WPMP_BASEDIR.'/inc/admin_themePage.php');
     100    }
     101   
     102    ## initialization function
     103    function init() {
     104        load_plugin_textdomain(WPMP_TEXTDOMAIN, WPMP_BASEDIR.'/locale', WPMP_FOLDER.'/locale');
     105       
     106        if(!$this->ready) {
     107            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        }
    68109    }
    69110   
    70111    ## activation / deactivation
    71112    function activate() {
    72         if(!is_dir(WP_PLUGIN_DIR.'/wpmathpublisher/img/')) {
    73             if(!mkdir(WP_PLUGIN_DIR.'/wpmathpublisher/img/', 0777)) {
     113        if(!is_dir(WPMP_BASEDIR.'/img/')) {
     114            if(!mkdir(WPMP_BASEDIR.'/img/', 0777)) {
    74115                deactivate_plugins(basename(__FILE__)); // Deactivate itself
    75116            }
    76         } elseif(!chmod(WP_PLUGIN_DIR.'/wpmathpublisher/img/')) {
     117        } elseif(!chmod(WPMP_BASEDIR.'/img/')) {
    77118            deactivate_plugins(basename(__FILE__)); // Deactivate itself
    78119        }
    79        
    80         $this->readOldValues();
    81    
     120           
    82121        add_option('wpmathpublisher_font', $this->font);
    83122        add_option('wpmathpublisher_back', $this->back);
     
    93132    }
    94133   
     134    ## resets the plugins options to default values
    95135    function toDefaults() {
    96136        update_option('wpmathpublisher_font', array('red' => 0, 'green' => 0, 'blue' => 0, 'alpha' => 0));
     
    101141       
    102142        return true;
    103     }
    104    
    105     function readOldValues() {
    106         if($value = get_option('wpmathpublisher_fontRed'))
    107             $this->font['red'] = $value;
    108         if($value = get_option('wpmathpublisher_fontGreen'))
    109             $this->font['green'] = $value;
    110         if($value = get_option('wpmathpublisher_fontBlue'))
    111             $this->font['blue'] = $value;
    112         if($value = get_option('wpmathpublisher_fontAlpha'))
    113             $this->font['alpha'] = $value;
    114         if($value = get_option('wpmathpublisher_backRed'))
    115             $this->back['red'] = $value;
    116         if($value = get_option('wpmathpublisher_backGreen'))
    117             $this->back['green'] = $value;
    118         if($value = get_option('wpmathpublisher_backBlue'))
    119             $this->back['blue'] = $value;
    120         if($value = get_option('wpmathpublisher_backAlpha'))
    121             $this->back['alpha'] = $value;
    122        
    123         delete_option('wpmathpublisher_fontRed');
    124         delete_option('wpmathpublisher_fontGreen');
    125         delete_option('wpmathpublisher_fontBlue');
    126         delete_option('wpmathpublisher_fontAlpha');
    127         delete_option('wpmathpublisher_fontValue');
    128         delete_option('wpmathpublisher_backRed');
    129         delete_option('wpmathpublisher_backGreen');
    130         delete_option('wpmathpublisher_backBlue');
    131         delete_option('wpmathpublisher_backAlpha');
    132         delete_option('wpmathpublisher_backValue');
    133143    }
    134144   
     
    143153    }
    144154   
    145     // function that checks whtere given rgb values are valid
     155    ## function that checks whether given rgb values are valid
    146156    function checkRGB($_red, $_green, $_blue, $_alpha=0) {
    147157        $message = '';
    148158        if(!is_numeric($_red) || $_red < 0 || $_red > 255)
    149             $message .= '<br />'. __('&raquo; value of red component is invalid');
     159            $message .= '<li>'. __('value of red component is invalid', WPMP_TEXTDOMAIN).'</li>';
    150160        if(!is_numeric($_green) || $_green < 0 || $_green > 255)
    151             $message .= '<br />'. __('&raquo; value of green component is invalid');
     161            $message .= '<li>'. __('value of green component is invalid', WPMP_TEXTDOMAIN).'</li>';
    152162        if(!is_numeric($_blue) || $_blue < 0 || $_blue > 255)
    153             $message .= '<br />'. __('&raquo; value of blue component is invalid');
     163            $message .= '<li>'. __('value of blue component is invalid', WPMP_TEXTDOMAIN).'</li>';
    154164        if(!is_numeric($_alpha) || $_alpha < 0 || $_alpha > 127)
    155             $message .= '<br />'. __('&raquo; transparency value is invalid');
     165            $message .= '<li>'. __('transparency value is invalid', WPMP_TEXTDOMAIN).'</li>';
    156166       
    157167        return $message;
    158168    }
    159169   
    160     //parses shortcode
     170    ## parses shortcode
    161171    function parseMath($attributes, $content) {
    162         if(isset($attributes['noparse']) && $attributes['noparse'] == 'true') {
     172        $attrString = '';
     173       
     174        if(!$this->ready) {
     175            foreach($attributes as $key => $value)
     176                $attrString .= ' '.$key.'='.$value;
     177           
     178            $output = '[math'.$attrString.']'.$content.'[/math]';
     179           
     180            return $output;
     181        } elseif(isset($attributes['noparse']) && $attributes['noparse'] == 'true') {
    163182            unset($attributes['noparse']);
    164             $attrString = '';
    165183            foreach($attributes as $key => $value)
    166184                $attrString .= ' '.$key.'='.$value;
     
    176194    // function to delete all images in cache
    177195    function clearCache() {
    178         $basePath = WP_PLUGIN_DIR.'/wpmathpublisher/img';
     196        $basePath = WPMP_BASEDIR.'/img';
    179197   
    180198        $dir = dir($basePath);
     
    211229//register_deactivation_hook(__FILE__, array($myWpMathPublisher, 'deactivate'));
    212230
    213 //add_filter('the_content', array($myWpMathPublisher, 'mathpublish'), 1);
     231add_action('init', array($myWpMathPublisher, 'init'));
    214232add_action('admin_menu', array($myWpMathPublisher, 'admin_menu'));
    215233add_shortcode('math', array($myWpMathPublisher, 'parseMath'));
Note: See TracChangeset for help on using the changeset viewer.