Plugin Directory

Changeset 571748


Ignore:
Timestamp:
07/13/2012 01:25:23 PM (14 years ago)
Author:
oshingler
Message:
 
Location:
olimometer
Files:
64 added
4 edited

Legend:

Unmodified
Added
Removed
  • olimometer/trunk/olimometer-class.php

    r571083 r571748  
    3232    public $olimometer_paypal_signature;
    3333    public $olimometer_paypal_extra_value = 0.00;
     34    public $olimometer_number_format = 0;
    3435   
    3536    private $olimometer_table_name = "olimometer_olimometers";
     
    6566        $this->olimometer_paypal_signature = $query_results['olimometer_paypal_signature'];
    6667        $this->olimometer_paypal_extra_value = $query_results['olimometer_paypal_extra_value'];
     68        $this->olimometer_number_format = $query_results['olimometer_number_format'];
    6769
    6870    }
     
    108110                                                                'olimometer_paypal_password' => $this->olimometer_paypal_password,
    109111                                                                'olimometer_paypal_signature' => $this->olimometer_paypal_signature,
    110                                                                 'olimometer_paypal_extra_value' => $this->olimometer_paypal_extra_value ) );
     112                                                                'olimometer_paypal_extra_value' => $this->olimometer_paypal_extra_value,
     113                                                                'olimometer_number_format' => $this->olimometer_number_format
     114                                                                 ) );
    111115           
    112116            // Find out the olimometer_id of the record just created and save it to the object.
     
    135139                                'olimometer_paypal_password' => $this->olimometer_paypal_password,
    136140                                'olimometer_paypal_signature' => $this->olimometer_paypal_signature,
    137                                 'olimometer_paypal_extra_value' => $this->olimometer_paypal_extra_value
     141                                'olimometer_paypal_extra_value' => $this->olimometer_paypal_extra_value,
     142                                'olimometer_number_format' => $this->olimometer_number_format
    138143                        ),
    139144                        array( 'olimometer_id' => $this->olimometer_id )
     
    180185            $the_olimometer_text = $the_olimometer_text." class='".$css_class."'";
    181186        }
    182         $the_olimometer_text = $the_olimometer_text." alt='Olimometer 2.31'>";
     187        $the_olimometer_text = $the_olimometer_text." alt='Olimometer 2.32'>";
    183188       
    184189        return $the_olimometer_text;
  • olimometer/trunk/olimometer.php

    r571083 r571748  
    66Author: Oliver Shingler
    77Author URI: http://www.olivershingler.co.uk
    8 Version: 2.31
     8Version: 2.32
    99*/
    1010
     
    124124    $an_olimometer = new Olimometer();
    125125    $an_olimometer->olimometer_id = $current_olimometer_id;
     126   
     127
     128       
     129   
    126130   
    127131    // Get values from form and dump in to the object
     
    146150    $an_olimometer->olimometer_paypal_signature = $_REQUEST['olimometer_paypal_signature'];
    147151    $an_olimometer->olimometer_paypal_extra_value = $_REQUEST['olimometer_paypal_extra_value'];
     152    $an_olimometer->olimometer_number_format = $_REQUEST['olimometer_number_format'];
    148153   
    149154    // Save it
     
    417422            ?>" size="40" aria-required="true" />
    418423            <p><span class="description">Input the total amount you would like to raise.</span></p></td>
     424        </tr>
     425       
     426        <tr class="form-field form-required">
     427            <th scope="row" valign="top"><label for="name">Number Format</label></th>
     428            <td>
     429                <select name="olimometer_number_format">
     430            <option value="0" <?php if($current_olimometer->olimometer_number_format==0) { echo "SELECTED"; } ?>>1000</option>
     431            <option value="1" <?php if($current_olimometer->olimometer_number_format==1) { echo "SELECTED"; } ?>>1,000</option>
     432            <option value="2" <?php if($current_olimometer->olimometer_number_format==2) { echo "SELECTED"; } ?>>1000.00</option>
     433            <option value="3" <?php if($current_olimometer->olimometer_number_format==3) { echo "SELECTED"; } ?>>1,000.00</option>
     434            </select>
     435            <p><span class="description">Please choose a display format for your values.</span></p></td>
    419436        </tr>
    420437
     
    974991************************/
    975992global $olimometer_db_version;
    976 $olimometer_db_version = "2.30";
     993$olimometer_db_version = "2.32";
    977994
    978995function olimometer_install() {
     
    10041021  olimometer_paypal_password VARCHAR(255),
    10051022  olimometer_paypal_signature VARCHAR(255),
     1023  olimometer_number_format tinyint,
    10061024  UNIQUE KEY olimometer_id (olimometer_id)
    10071025    );";
     
    10301048        // Yes it has!
    10311049        // If currently installed database version is less than current version required for this plugin, then we need to upgrade
    1032         $required_db_version = 2.30;
     1050        $required_db_version = 2.32;
    10331051        $installed_db_version = get_option("olimometer_db_version");
    10341052        if($installed_db_version < $required_db_version) {
  • olimometer/trunk/readme.txt

    r571083 r571748  
    105105== Changelog ==
    106106
     107= 2.32 =
     108* Values can be formatted, for example with decimal places and a comma to delimit thousands. See the Number Format option on the settings page.
     109
    107110= 2.31 =
    108111* Fixed bug causing image creation failure on some systems (literal path requirements)
     
    205208== Upgrade Notice ==
    206209
     210= 2.32 =
     211* Values can be formatted, for example with decimal places and a comma to delimit thousands. See the Number Format option on the settings page.
     212
    207213= 2.31 =
    208214* Fixed bug causing image creation failure on some systems (literal path requirements)
  • olimometer/trunk/thermometer.php

    r571083 r571748  
    6565    $font_height = $olimometer_to_display->olimometer_font_height;
    6666    $suffix = $olimometer_to_display->olimometer_suffix;
     67   
     68    // Value layout array:
     69   
     70        // No dp, no thousands
     71        $olimometer_display_array[0][0] = 0;
     72        $olimometer_display_array[0][1] = '';
     73        // no dp, thousands marker
     74        $olimometer_display_array[1][0] = 0;
     75        $olimometer_display_array[1][1] = ',';
     76        // 2dp, no thousands
     77        $olimometer_display_array[2][0] = 2;
     78        $olimometer_display_array[2][1] = '';
     79        // 2dp, thousands marker
     80        $olimometer_display_array[3][0] = 2;
     81        $olimometer_display_array[3][1] = ',';
     82       
     83    // Display converted values:
     84    $olimometer_display_dp = $olimometer_display_array[$olimometer_to_display->olimometer_number_format][0];
     85    $olimometer_display_thousands = $olimometer_display_array[$olimometer_to_display->olimometer_number_format][1];
     86    //$olimometer_display_dp = 2;
     87    //$olimometer_display_thousands = ',';
     88    $display_total_value = number_format($total_value,$olimometer_display_dp,'.',$olimometer_display_thousands);
     89    $display_progress_value = number_format($progress_value,$olimometer_display_dp,'.',$olimometer_display_thousands);
     90    $display_zero = number_format(0,$olimometer_display_dp,'.',$olimometer_display_thousands);
     91   
    6792
    6893
     
    153178        // Are we showing the target labels?
    154179        if($show_target == 1) {
    155             $the_box = calculateTextBox($currency_symbol.$total_value.$suffix_symbol, $font_name, $font_height, 0);
     180            $the_box = calculateTextBox($currency_symbol.$display_total_value.$suffix_symbol, $font_name, $font_height, 0);
    156181            //$the_box = imagettfbboxextended($font_height, 0, $font_name, $currency_symbol.$total_value.$suffix_symbol);
    157182            $top_text_width = $the_box["width"];
     
    164189        if($show_progress == 1) {
    165190            // Calculate the width of it
    166             $the_box2 = calculateTextBox($progress_label.' '.$currency_symbol.$progress_value.$suffix_symbol, $font_name, $font_height, 0);
     191            $the_box2 = calculateTextBox($progress_label.' '.$currency_symbol.$display_progress_value.$suffix_symbol, $font_name, $font_height, 0);
    167192            //$the_box2 = imagettfbboxextended($font_height, 0, $font_name, $progress_label.' '.$currency_symbol.$progress_value.$suffix_symbol);
    168193            $progress_text_width = $the_box2["width"] + 2;
     
    217242        // - Add value labels to the right of the thermometer
    218243        if($show_target == 1) {
    219             imagettftext($new_image, $font_height, 0, 0, $font_height+2, $text_colour_rgb, $font_name, $currency_symbol.'0'.$suffix_symbol);
    220             imagettftext($new_image, $font_height, 0, $image_height-$top_text_width, $font_height+2, $text_colour_rgb, $font_name, $currency_symbol.$total_value.$suffix_symbol);
     244            imagettftext($new_image, $font_height, 0, 0, $font_height+2, $text_colour_rgb, $font_name, $currency_symbol.$display_zero.$suffix_symbol);
     245            imagettftext($new_image, $font_height, 0, $image_height-$top_text_width, $font_height+2, $text_colour_rgb, $font_name, $currency_symbol.$display_total_value.$suffix_symbol);
    221246        }
    222247        // - If the Progress label is needed, show it!
     
    231256                $progress_label_x = ($new_image_width-$progress_text_width)/2;
    232257            }
    233             imagettftext($new_image, $font_height, 0, $progress_label_x, $therm_bulb_height+$top_of_therm+$font_height+5, $text_colour_rgb, $font_name, $progress_label.' '.$currency_symbol.$progress_value.$suffix_symbol);
     258            imagettftext($new_image, $font_height, 0, $progress_label_x, $therm_bulb_height+$top_of_therm+$font_height+5, $text_colour_rgb, $font_name, $progress_label.' '.$currency_symbol.$display_progress_value.$suffix_symbol);
    234259            //imagettftext($new_image, $font_height, 0, 30, $therm_bulb_height+4, $text_colour_rgb, $font_name, "Testing");
    235260        }
     
    320345        // Are we showing the target labels?
    321346        if($show_target == 1) {
    322             $the_box = calculateTextBox($currency_symbol.$total_value.$suffix_symbol, $font_name, $font_height, 0);
     347            $the_box = calculateTextBox($currency_symbol.$display_total_value.$suffix_symbol, $font_name, $font_height, 0);
    323348            //$the_box = imagettfbboxextended($font_height, 0, $font_name, $currency_symbol.$total_value.$suffix_symbol);
    324349            $top_text_width = $the_box["width"];
     
    331356        if($show_progress == 1) {
    332357            // Calculate the width of it
    333         $the_box2 = calculateTextBox($progress_label.' '.$currency_symbol.$progress_value.$suffix_symbol, $font_name, $font_height, 0);
     358        $the_box2 = calculateTextBox($progress_label.' '.$currency_symbol.$display_progress_value.$suffix_symbol, $font_name, $font_height, 0);
    334359        //$the_box2 = imagettfbboxextended($font_height, 0, $font_name, $progress_label.' '.$currency_symbol.$progress_value.$suffix_symbol);
    335360        $progress_text_width = $the_box2["width"] + 2;
     
    368393        // - Add value labels to the right of the thermometer
    369394        if($show_target == 1) {
    370             imagettftext($new_image, $font_height, 0, $therm_text_xpos, $font_height*1.2, $text_colour_rgb, $font_name, $currency_symbol.$total_value.$suffix_symbol);
    371             imagettftext($new_image, $font_height, 0, $therm_text_xpos, $bulb_ypos+10, $text_colour_rgb, $font_name, $currency_symbol.'0'.$suffix_symbol);
     395            imagettftext($new_image, $font_height, 0, $therm_text_xpos, $font_height*1.2, $text_colour_rgb, $font_name, $currency_symbol.$display_total_value.$suffix_symbol);
     396            imagettftext($new_image, $font_height, 0, $therm_text_xpos, $bulb_ypos+10, $text_colour_rgb, $font_name, $currency_symbol.$display_zero.$suffix_symbol);
    372397        }
    373398        // - If the Progress label is needed, show it!
    374399        if($show_progress == 1) {
    375         imagettftext($new_image, $font_height, 0, 0, $image_height-(ceil($font_height/2)), $text_colour_rgb, $font_name, $progress_label.' '.$currency_symbol.$progress_value.$suffix_symbol);
     400        imagettftext($new_image, $font_height, 0, 0, $image_height-(ceil($font_height/2)), $text_colour_rgb, $font_name, $progress_label.' '.$currency_symbol.$display_progress_value.$suffix_symbol);
    376401        }
    377402        // - Set transparancy if required using supplied background colour as mask
Note: See TracChangeset for help on using the changeset viewer.