Changeset 710347
- Timestamp:
- 05/09/2013 01:24:44 PM (13 years ago)
- Location:
- olimometer
- Files:
-
- 65 added
- 6 edited
-
tags/2.46 (added)
-
tags/2.46/LiberationSans-Regular.ttf (added)
-
tags/2.46/jscolor (added)
-
tags/2.46/jscolor/arrow.gif (added)
-
tags/2.46/jscolor/cross.gif (added)
-
tags/2.46/jscolor/demo.html (added)
-
tags/2.46/jscolor/hs.png (added)
-
tags/2.46/jscolor/hv.png (added)
-
tags/2.46/jscolor/jscolor.js (added)
-
tags/2.46/my-script.js (added)
-
tags/2.46/olimometer-class.php (added)
-
tags/2.46/olimometer.php (added)
-
tags/2.46/readme.txt (added)
-
tags/2.46/screenshot-1.jpg (added)
-
tags/2.46/screenshot-2.jpg (added)
-
tags/2.46/screenshot-3.jpg (added)
-
tags/2.46/screenshot-4.jpg (added)
-
tags/2.46/skins (added)
-
tags/2.46/skins.php (added)
-
tags/2.46/skins.xml (added)
-
tags/2.46/skins/oli-bold-chunky (added)
-
tags/2.46/skins/oli-bold-chunky/bold-chunky-bar.png (added)
-
tags/2.46/skins/oli-bold-chunky/bold-chunky-bottom.png (added)
-
tags/2.46/skins/oli-bold-chunky/bold-chunky-top.png (added)
-
tags/2.46/skins/oli-default (added)
-
tags/2.46/skins/oli-default/therm_bar_empty.png (added)
-
tags/2.46/skins/oli-default/therm_bulb.png (added)
-
tags/2.46/skins/oli-default/therm_top.png (added)
-
tags/2.46/skins/oli-ourprogress-blue (added)
-
tags/2.46/skins/oli-ourprogress-blue/therm_bar_empty.png (added)
-
tags/2.46/skins/oli-ourprogress-blue/therm_bulb.png (added)
-
tags/2.46/skins/oli-ourprogress-blue/therm_top.png (added)
-
tags/2.46/skins/oli-ourprogress-green (added)
-
tags/2.46/skins/oli-ourprogress-green/therm_bar_empty.png (added)
-
tags/2.46/skins/oli-ourprogress-green/therm_bulb.png (added)
-
tags/2.46/skins/oli-ourprogress-green/therm_top.png (added)
-
tags/2.46/skins/oli-ourprogress-red (added)
-
tags/2.46/skins/oli-ourprogress-red/therm_bar_empty.png (added)
-
tags/2.46/skins/oli-ourprogress-red/therm_bulb.png (added)
-
tags/2.46/skins/oli-ourprogress-red/therm_top.png (added)
-
tags/2.46/skins/oli-progpress-black (added)
-
tags/2.46/skins/oli-progpress-black/left.png (added)
-
tags/2.46/skins/oli-progpress-black/middle.png (added)
-
tags/2.46/skins/oli-progpress-black/right.png (added)
-
tags/2.46/skins/oli-rounded (added)
-
tags/2.46/skins/oli-rounded/rounded_bar.png (added)
-
tags/2.46/skins/oli-rounded/rounded_bottom.png (added)
-
tags/2.46/skins/oli-rounded/rounded_top.png (added)
-
tags/2.46/skins/oli-thinblackhorizontal (added)
-
tags/2.46/skins/oli-thinblackhorizontal/left.png (added)
-
tags/2.46/skins/oli-thinblackhorizontal/middle.png (added)
-
tags/2.46/skins/oli-thinblackhorizontal/right.png (added)
-
tags/2.46/skins/oli-thinbluehorizontal (added)
-
tags/2.46/skins/oli-thinbluehorizontal/left.png (added)
-
tags/2.46/skins/oli-thinbluehorizontal/middle.png (added)
-
tags/2.46/skins/oli-thinbluehorizontal/right.png (added)
-
tags/2.46/skins/oli-thinredhorizontal (added)
-
tags/2.46/skins/oli-thinredhorizontal/left.png (added)
-
tags/2.46/skins/oli-thinredhorizontal/middle.png (added)
-
tags/2.46/skins/oli-thinredhorizontal/right.png (added)
-
tags/2.46/skins/oli-watermaster (added)
-
tags/2.46/skins/oli-watermaster/watermaster-bar.png (added)
-
tags/2.46/skins/oli-watermaster/watermaster-bottom.png (added)
-
tags/2.46/skins/oli-watermaster/watermaster-top.png (added)
-
tags/2.46/thermometer.php (added)
-
trunk/olimometer-class.php (modified) (8 diffs)
-
trunk/olimometer.php (modified) (11 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/skins.php (modified) (1 diff)
-
trunk/skins.xml (modified) (1 diff)
-
trunk/thermometer.php (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
olimometer/trunk/olimometer-class.php
r698522 r710347 39 39 public $olimometer_stayclassypid = 0; 40 40 public $olimometer_stayclassyeid = 0; 41 public $olimometer_display_dp; 42 public $olimometer_display_thousands; 43 public $olimometer_display_decimal; 44 public $olimometer_link_disable = 0; 41 45 42 46 private $olimometer_default_link = "http://www.olivershingler.co.uk/oliblog/olimometer/"; … … 80 84 $this->olimometer_stayclassypid = $query_results['olimometer_stayclassypid']; 81 85 $this->olimometer_stayclassyeid = $query_results['olimometer_stayclassyeid']; 86 $this->olimometer_link_disable = $query_results['olimometer_link_disable']; 82 87 83 88 if($query_results['olimometer_link'] == "" || $query_results['olimometer_link'] == null) { … … 86 91 else { 87 92 $this->olimometer_link = $query_results['olimometer_link']; 93 } 94 95 if($this->olimometer_number_format == null) { 96 $this->olimometer_number_format = 0; 88 97 } 89 98 … … 167 176 'olimometer_overlay_y' => $this->olimometer_overlay_y, 168 177 'olimometer_stayclassypid' => $this->olimometer_stayclassypid, 169 'olimometer_stayclassyeid' => $this->olimometer_stayclassyeid 178 'olimometer_stayclassyeid' => $this->olimometer_stayclassyeid, 179 'olimometer_link_disable' => $this->olimometer_link_disable 170 180 ) ); 171 181 … … 203 213 'olimometer_overlay_y' => $this->olimometer_overlay_y, 204 214 'olimometer_stayclassypid' => $this->olimometer_stayclassypid, 205 'olimometer_stayclassyeid' => $this->olimometer_stayclassyeid 215 'olimometer_stayclassyeid' => $this->olimometer_stayclassyeid, 216 'olimometer_link_disable' => $this->olimometer_link_disable 206 217 ), 207 218 array( 'olimometer_id' => $this->olimometer_id ) 208 219 ); 209 /*210 $wpdb->update($table_name,211 array( 'olimometer_description' => $this->olimometer_description,212 'olimometer_progress_value' => $olimometer_progress_value,213 'olimometer_total_value' => $this->olimometer_total_value,214 'olimometer_currency' => $this->olimometer_currency,215 'olimometer_thermometer_bg_colour' => $this->olimometer_thermometer_bg_colour,216 'olimometer_text_colour' => $this->olimometer_text_colour,217 'olimometer_thermometer_height' => $this->olimometer_thermometer_height,218 'olimometer_transparent' => $this->olimometer_transparent,219 'olimometer_show_target' => $this->olimometer_show_target,220 'olimometer_show_progress' => $this->olimometer_show_progress,221 'olimometer_progress_label' => $this->olimometer_progress_label,222 'olimometer_font_height' => $this->olimometer_font_height,223 'olimometer_suffix' => $this->olimometer_suffix,224 'olimometer_skin_slug' => $this->olimometer_skin_slug,225 'olimometer_use_paypal' => $this->olimometer_use_paypal,226 'olimometer_paypal_username' => $this->olimometer_paypal_username,227 'olimometer_paypal_password' => $this->olimometer_paypal_password,228 'olimometer_paypal_signature' => $this->olimometer_paypal_signature,229 'olimometer_paypal_extra_value' => $olimometer_paypal_extra_value,230 'olimometer_number_format' => $this->olimometer_number_format,231 'olimometer_link' => $this->olimometer_link,232 'olimometer_overlay' => $this->olimometer_overlay,233 'olimometer_overlay_image' => $this->olimometer_overlay_image,234 'olimometer_overlay_x' => $this->olimometer_overlay_x,235 'olimometer_overlay_y' => $this->olimometer_overlay_y236 ),237 array( 'olimometer_id' => $this->olimometer_id )238 );239 */240 220 } 241 221 … … 245 225 function show($css_class = '') 246 226 { 227 // Make sure the progress value is updated in case it is pulled in from PayPal etc... 228 $this->update_progress(); 229 230 // And format... 231 $olimometer_font = "LiberationSans-Regular.ttf"; 232 $image_location = plugins_url('olimometer/thermometer.php', dirname(__FILE__) ); 233 if($this->olimometer_link_disable == 0) { 234 $the_olimometer_text = "<a href='".$this->olimometer_link."' target=_blank>"; 235 } 236 $the_olimometer_text = $the_olimometer_text."<img src='".$image_location."?olimometer_id=".$this->olimometer_id."' border=0"; 237 if(strlen($css_class) > 0) { 238 $the_olimometer_text = $the_olimometer_text." class='".$css_class."'"; 239 } 240 $the_olimometer_text = $the_olimometer_text." alt='Olimometer 2.47'>"; 241 if($this->olimometer_link_disable == 0) { 242 $the_olimometer_text = $the_olimometer_text."</a>"; 243 } 244 245 246 return $the_olimometer_text; 247 } 248 249 250 // Makes sure that the progress value is updated in case it is frmo a dynamic source such as PayPal. 251 // Should be called before a value is displayed 252 function update_progress() { 247 253 // If PayPal integration is configured, get the current balance and save it 248 254 if($this->olimometer_use_paypal == 1) { … … 301 307 } 302 308 } 303 304 305 $olimometer_font = "LiberationSans-Regular.ttf";306 307 $image_location = plugins_url('olimometer/thermometer.php', dirname(__FILE__) );308 309 310 $the_olimometer_text = "<a href='".$this->olimometer_link."' target=_blank><img src='".$image_location."?olimometer_id=".$this->olimometer_id."' border=0";311 if(strlen($css_class) > 0) {312 $the_olimometer_text = $the_olimometer_text." class='".$css_class."'";313 }314 $the_olimometer_text = $the_olimometer_text." alt='Olimometer 2.46'></a>";315 316 return $the_olimometer_text;317 //return null;318 309 } 319 310 … … 438 429 } 439 430 431 432 // Returns a formatted progress value string 433 function get_display_progress() { 434 $this->set_display_format(); 435 $display_string = number_format($this->olimometer_progress_value,$this->olimometer_display_dp,$this->olimometer_display_decimal,$this->olimometer_display_thousands); 436 return $this->wrap_prefix_and_suffix($display_string); 437 } 438 439 // Returns a formatted total to raise string 440 function get_display_total() { 441 $this->set_display_format(); 442 $display_string = number_format($this->olimometer_total_value,$this->olimometer_display_dp,$this->olimometer_display_decimal,$this->olimometer_display_thousands); 443 return $this->wrap_prefix_and_suffix($display_string); 444 } 445 446 // Returns a formatted '0' value string 447 function get_display_zero() { 448 $this->set_display_format(); 449 $display_string = number_format(0,$this->olimometer_display_dp,$this->olimometer_display_decimal,$this->olimometer_display_thousands); 450 return $this->wrap_prefix_and_suffix($display_string); 451 } 452 453 // How much do we need to raise to meet the target? 454 function get_display_remaining() { 455 $this->set_display_format(); 456 $togo = $this->olimometer_total_value - $this->olimometer_progress_value; 457 458 $display_string = number_format($togo,$this->olimometer_display_dp,$this->olimometer_display_decimal,$this->olimometer_display_thousands); 459 return $this->wrap_prefix_and_suffix($display_string); 460 } 461 462 function set_display_format() { 463 // Load display array values 464 // No dp, no thousands 465 $olimometer_display_array[0][0] = 0; 466 $olimometer_display_array[0][1] = ''; 467 $olimometer_display_array[0][2] = '.'; 468 // no dp, thousands marker 469 $olimometer_display_array[1][0] = 0; 470 $olimometer_display_array[1][1] = ','; 471 $olimometer_display_array[1][2] = '.'; 472 // 2dp, no thousands 473 $olimometer_display_array[2][0] = 2; 474 $olimometer_display_array[2][1] = ''; 475 $olimometer_display_array[2][2] = '.'; 476 // 2dp, thousands marker 477 $olimometer_display_array[3][0] = 2; 478 $olimometer_display_array[3][1] = ','; 479 $olimometer_display_array[3][2] = '.'; 480 // no dp, period thousands marker 481 $olimometer_display_array[4][0] = 0; 482 $olimometer_display_array[4][1] = '.'; 483 $olimometer_display_array[4][2] = ','; 484 // 2dp (comma), period thousands marker 485 $olimometer_display_array[5][0] = 2; 486 $olimometer_display_array[5][1] = '.'; 487 $olimometer_display_array[5][2] = ','; 488 // no dp, space thousands marker 489 $olimometer_display_array[6][0] = 0; 490 $olimometer_display_array[6][1] = ' '; 491 $olimometer_display_array[6][2] = '.'; 492 // 2dp (comma), space thousands marker 493 $olimometer_display_array[7][0] = 2; 494 $olimometer_display_array[7][1] = ' '; 495 $olimometer_display_array[7][2] = ','; 496 // 2dp (period), space thousands marker 497 $olimometer_display_array[8][0] = 2; 498 $olimometer_display_array[8][1] = '.'; 499 $olimometer_display_array[8][2] = ' '; 500 501 $this->olimometer_display_dp = $olimometer_display_array[$this->olimometer_number_format][0]; 502 $this->olimometer_display_thousands = $olimometer_display_array[$this->olimometer_number_format][1]; 503 $this->olimometer_display_decimal = $olimometer_display_array[$this->olimometer_number_format][2]; 504 } 505 506 507 // Returns a string wrapped with the required prefix and suffix 508 function wrap_prefix_and_suffix($formatted_value) { 509 // Figure out prefix and suffix values 510 switch($this->olimometer_currency) { 511 case 128: 512 $currency_symbol = "€"; 513 //$currency_symbol = "a"; 514 break; 515 case '': 516 $currency_symbol = ""; 517 break; 518 case 'x': 519 $currency_symbol = ""; 520 break; 521 case '10000': 522 $currency_symbol = "kr "; 523 break; 524 case '10001': 525 $currency_symbol = "CHF "; 526 break; 527 default: 528 $currency_symbol = "&#$this->olimometer_currency;"; 529 } 530 531 switch($this->olimometer_suffix) { 532 case 128: 533 $suffix_symbol = "€"; 534 break; 535 case '': 536 $suffix_symbol = ""; 537 break; 538 case 'x': 539 $suffix_symbol = ""; 540 break; 541 case '10000': 542 $suffix_symbol = " kr"; 543 break; 544 case '10001': 545 $suffix_symbol = " CHF"; 546 break; 547 default: 548 $suffix_symbol = "&#$this->olimometer_suffix;"; 549 } 550 return $currency_symbol.$formatted_value.$suffix_symbol; 551 } 440 552 441 553 } -
olimometer/trunk/olimometer.php
r698555 r710347 6 6 Author: Oliver Shingler 7 7 Author URI: http://www.olivershingler.co.uk 8 Version: 2.4 68 Version: 2.47 9 9 */ 10 10 … … 31 31 add_shortcode('show_olimometer','call_show_olimometer'); // Legacy 32 32 add_shortcode('olimometer','call_show_olimometer'); 33 add_shortcode('olimometer_progress','olimometer_progress'); 34 add_shortcode('olimometer_target','olimometer_target'); 35 add_shortcode('olimometer_remaining','olimometer_remaining'); 33 36 34 37 register_activation_hook(__FILE__,'olimometer_install'); … … 145 148 $an_olimometer->olimometer_number_format = $_REQUEST['olimometer_number_format']; 146 149 $an_olimometer->olimometer_link = $_REQUEST['olimometer_link']; 150 $an_olimometer->olimometer_link_disable = $_REQUEST['olimometer_link_disable']; 147 151 //echo "Overlay = xxx".$_REQUEST['olimometer_overlay']."xxx"; 148 152 $an_olimometer->olimometer_overlay = $_REQUEST['olimometer_overlay']; … … 152 156 $an_olimometer->olimometer_stayclassypid = $_REQUEST['olimometer_stayclassypid']; 153 157 $an_olimometer->olimometer_stayclassyeid = $_REQUEST['olimometer_stayclassyeid']; 158 154 159 155 160 // Save it … … 439 444 </table> 440 445 441 <p> 442 You can insert this Olimometer in to your posts and pages by using the following shortcode:<br /> 443 <i><b>[olimometer id=<?php echo $current_olimometer_id; ?>]</b></i> 444 </p> 446 You can use the following shortcodes in your posts and pages for this Olimometer:<br /> 447 <ol> 448 <li>Display the Olimometer: <i><b>[olimometer id=<?php echo $current_olimometer_id; ?>]</b></i></li> 449 <li>Display the Amount Raised: <i><b>[olimometer_progress id=<?php echo $current_olimometer_id; ?>]</b></i></li> 450 <li>Display the Target: <i><b>[olimometer_target id=<?php echo $current_olimometer_id; ?>]</b></i></li> 451 <li>Display the amount remaining to hit Target: <i><b>[olimometer_remaining id=<?php echo $current_olimometer_id; ?>]</b></i></li> 452 453 </ol> 445 454 446 455 <p class="submit"><input type="submit" class="button-primary" name="olimometer_submit" value="Save Changes" /><input type="submit" class="button-primary" name="olimometer_delete" value="Delete this Olimometer" /></p> … … 773 782 </tr> 774 783 784 <tr class="form-required"> 785 <th scope="row" valign="top"><label for="name">Disable Olimometer Hyperlink</label></th> 786 <td><input name="olimometer_link_disable" id="olimometer_link_disable" type="radio" value="0"<?php 787 if($current_olimometer->olimometer_link_disable == 0) { 788 echo " checked"; 789 } 790 791 ?>> No<br /> 792 <input name="olimometer_link_disable" id="olimometer_link_disable" type="radio" value="1"<?php 793 if($current_olimometer->olimometer_link_disable == 1) { 794 echo " checked"; 795 } 796 797 ?>> Yes 798 <p><span class="description">(Optional) Would you like to disable the hyperlink?</span></p></td> 799 </tr> 800 775 801 776 802 <!-- Overlay Image Begin --> … … 969 995 } 970 996 997 998 // Returns the given Olimometer's progress amount. 999 /*function olimometer_progress($olimometer_id) { 1000 // Load the olimometer 1001 $current_olimometer = new Olimometer(); 1002 $current_olimometer->load($olimometer_id); 1003 //return $current_olimometer->show($css_class); 1004 }*/ 971 1005 972 1006 /*************** … … 1247 1281 ************************/ 1248 1282 global $olimometer_db_version; 1249 $olimometer_db_version = "2.4 6";1283 $olimometer_db_version = "2.47"; 1250 1284 1251 1285 function olimometer_install() { … … 1285 1319 olimometer_stayclassypid int, 1286 1320 olimometer_stayclassyeid int, 1321 olimometer_link_disable int, 1287 1322 UNIQUE KEY olimometer_id (olimometer_id) 1288 1323 );"; … … 1311 1346 // Yes it has! 1312 1347 // If currently installed database version is less than current version required for this plugin, then we need to upgrade 1313 $required_db_version = 2.4 6;1348 $required_db_version = 2.47; 1314 1349 $installed_db_version = get_option("olimometer_db_version"); 1315 1350 if($installed_db_version < $required_db_version) { … … 1465 1500 } 1466 1501 1467 1468 1469 1502 // Shortcode to display the current amount raised all formatted nice and that 1503 function olimometer_progress($atts) { 1504 extract( shortcode_atts( array( 1505 'id' => '1', 1506 ), $atts ) ); 1507 1508 $an_olimometer = new Olimometer(); 1509 $an_olimometer->load($id); 1510 1511 return $an_olimometer->get_display_progress(); 1512 } 1513 1514 // Shortcode to display the target amount all formatted nice and that 1515 function olimometer_target($atts) { 1516 extract( shortcode_atts( array( 1517 'id' => '1', 1518 ), $atts ) ); 1519 1520 $an_olimometer = new Olimometer(); 1521 $an_olimometer->load($id); 1522 1523 return $an_olimometer->get_display_total(); 1524 } 1525 1526 // Shortcode to display the amount left to raise to meet the target formatted nice and that 1527 function olimometer_remaining($atts) { 1528 extract( shortcode_atts( array( 1529 'id' => '1', 1530 ), $atts ) ); 1531 1532 $an_olimometer = new Olimometer(); 1533 $an_olimometer->load($id); 1534 1535 return $an_olimometer->get_display_remaining(); 1536 } 1470 1537 1471 1538 -
olimometer/trunk/readme.txt
r698522 r710347 39 39 40 40 == Frequently Asked Questions == 41 42 = Can I display the progress / target / remaining values in a post or page? = 43 44 Yup. Use one of these shortcodes, replacing 1 with the actual ID of your Olimometer. 45 46 * Display the Amount Raised: [olimometer_progress id=1] 47 * Display the Target: [olimometer_target id=1] 48 * Display the amount remaining to hit Target: [olimometer_remaining id=1] 41 49 42 50 = How do I add a PayPal Donate button? = … … 99 107 100 108 109 110 101 111 == Screenshots == 102 112 … … 108 118 109 119 == Changelog == 120 121 = 2.47 = 122 * Added three new shortcodes to display a formatted value for progress, target and remaining values. See the Olimometer settings page for a list of shortcodes. 123 * You can now disable the Olimometer's hyperlink if required. 110 124 111 125 = 2.46 = … … 248 262 == Upgrade Notice == 249 263 264 = 2.47 = 265 * Added three new shortcodes to display a formatted value for progress, target and remaining values. See the Olimometer settings page for a list of shortcodes. 266 * You can now disable the Olimometer's hyperlink if required. 267 250 268 = 2.46 = 251 269 * Added support for StayClassy Events in addition to Projects -
olimometer/trunk/skins.php
r571083 r710347 1 1 <?php 2 2 3 3 // Olimometer Skin Loading functions 4 4 5 6 7 5 class Olimometer_Skins 8 6 -
olimometer/trunk/skins.xml
r571083 r710347 1 1 <olimometer> 2 3 2 <skin> 4 5 3 <skin_name>Olimometer Default Skin</skin_name> 6 7 4 <skin_slug>oli-default</skin_slug> 8 9 5 <bulb_file>therm_bulb.png</bulb_file> 10 11 6 <bar_file>therm_bar_empty.png</bar_file> 12 13 7 <top_file>therm_top.png</top_file> 14 15 8 <bar_colour>a23344</bar_colour> 16 17 9 <bar_pos>26</bar_pos> 18 19 10 <bar_width>4</bar_width> 20 21 11 <bar_end>7</bar_end> 22 23 12 <text_pos>60</text_pos> 24 25 13 <orientation>vertical</orientation> 26 27 14 </skin> 28 15 29 16 <skin> 30 31 17 <skin_name>Red and Rounded</skin_name> 32 33 18 <skin_slug>oli-rounded</skin_slug> 34 35 19 <bulb_file>rounded_bottom.png</bulb_file> 36 37 20 <bar_file>rounded_bar.png</bar_file> 38 39 21 <top_file>rounded_top.png</top_file> 40 41 22 <bar_colour>dc3429</bar_colour> 42 43 23 <bar_pos>29</bar_pos> 44 45 24 <bar_width>18</bar_width> 46 47 25 <bar_end>12</bar_end> 48 49 26 <text_pos>60</text_pos> 50 51 27 <orientation>vertical</orientation> 52 53 28 </skin> 54 29 55 30 <skin> 56 57 31 <skin_name>Bold and Chunky</skin_name> 58 59 32 <skin_slug>oli-bold-chunky</skin_slug> 60 61 33 <bulb_file>bold-chunky-bottom.png</bulb_file> 62 63 34 <bar_file>bold-chunky-bar.png</bar_file> 64 65 35 <top_file>bold-chunky-top.png</top_file> 66 67 36 <bar_colour>d3212f</bar_colour> 68 69 37 <bar_pos>15</bar_pos> 70 71 38 <bar_width>53</bar_width> 72 73 39 <bar_end>22</bar_end> 74 75 40 <text_pos>100</text_pos> 76 77 41 <orientation>vertical</orientation> 78 79 42 </skin> 80 43 81 44 <skin> 82 83 45 <skin_name>Watermaster</skin_name> 84 85 46 <skin_slug>oli-watermaster</skin_slug> 86 87 47 <bulb_file>watermaster-bottom.png</bulb_file> 88 89 48 <bar_file>watermaster-bar.png</bar_file> 90 91 49 <top_file>watermaster-top.png</top_file> 92 93 50 <bar_colour>3366ff</bar_colour> 94 95 51 <bar_pos>84</bar_pos> 96 97 52 <bar_width>24</bar_width> 98 99 53 <bar_end>130</bar_end> 100 101 54 <text_pos>60</text_pos> 102 103 55 <orientation>vertical</orientation> 104 105 56 </skin> 106 57 107 58 <skin> 108 109 59 <skin_name>Our Progress - Blue</skin_name> 110 111 60 <skin_slug>oli-ourprogress-blue</skin_slug> 112 113 61 <bulb_file>therm_bulb.png</bulb_file> 114 115 62 <bar_file>therm_bar_empty.png</bar_file> 116 117 63 <top_file>therm_top.png</top_file> 118 119 64 <bar_colour>164589</bar_colour> 120 121 65 <bar_pos>30</bar_pos> 122 123 66 <bar_width>12</bar_width> 124 125 67 <bar_end>24</bar_end> 126 127 68 <text_pos>70</text_pos> 128 129 69 <orientation>vertical</orientation> 130 131 70 </skin> 132 71 133 72 <skin> 134 135 73 <skin_name>Our Progress - Green</skin_name> 136 137 74 <skin_slug>oli-ourprogress-green</skin_slug> 138 139 75 <bulb_file>therm_bulb.png</bulb_file> 140 141 76 <bar_file>therm_bar_empty.png</bar_file> 142 143 77 <top_file>therm_top.png</top_file> 144 145 78 <bar_colour>05854a</bar_colour> 146 147 79 <bar_pos>30</bar_pos> 148 149 80 <bar_width>12</bar_width> 150 151 81 <bar_end>24</bar_end> 152 153 82 <text_pos>70</text_pos> 154 155 83 <orientation>vertical</orientation> 156 157 84 </skin> 158 85 159 86 <skin> 160 161 87 <skin_name>Our Progress - Red</skin_name> 162 163 88 <skin_slug>oli-ourprogress-red</skin_slug> 164 165 89 <bulb_file>therm_bulb.png</bulb_file> 166 167 <bar_file>therm_bar_empty.png</bar_file> 168 90 <bar_file>therm_bar_empty.png</bar_file> 169 91 <top_file>therm_top.png</top_file> 170 171 92 <bar_colour>891619</bar_colour> 172 173 93 <bar_pos>30</bar_pos> 174 175 94 <bar_width>12</bar_width> 176 177 95 <bar_end>24</bar_end> 178 179 96 <text_pos>70</text_pos> 180 181 97 <orientation>vertical</orientation> 182 183 98 </skin> 184 99 185 100 <skin> 186 187 101 <skin_name>ProgPress - Black</skin_name> 188 189 102 <skin_slug>oli-progpress-black</skin_slug> 190 191 103 <bulb_file>left.png</bulb_file> 192 193 104 <bar_file>middle.png</bar_file> 194 195 105 <top_file>right.png</top_file> 196 197 106 <bar_colour>000000</bar_colour> 198 199 107 <bar_pos>7</bar_pos> 200 201 108 <bar_width>19</bar_width> 202 203 109 <bar_end>20</bar_end> 204 205 110 <text_pos>0</text_pos> 206 207 111 <orientation>horizontal</orientation> 208 209 112 </skin> 210 113 211 114 <skin> 212 213 115 <skin_name>Horizontal - Thin Red</skin_name> 214 215 116 <skin_slug>oli-thinredhorizontal</skin_slug> 216 217 117 <bulb_file>left.png</bulb_file> 218 219 118 <bar_file>middle.png</bar_file> 220 221 119 <top_file>right.png</top_file> 222 223 120 <bar_colour>ff0000</bar_colour> 224 225 121 <bar_pos>0</bar_pos> 226 227 122 <bar_width>19</bar_width> 228 229 123 <bar_end>20</bar_end> 230 231 124 <text_pos>0</text_pos> 232 233 125 <orientation>horizontal</orientation> 234 235 126 </skin> 236 127 237 128 <skin> 238 239 129 <skin_name>Horizontal - Thin Blue</skin_name> 240 241 130 <skin_slug>oli-thinbluehorizontal</skin_slug> 242 243 131 <bulb_file>left.png</bulb_file> 244 245 132 <bar_file>middle.png</bar_file> 246 247 133 <top_file>right.png</top_file> 248 249 134 <bar_colour>0000ff</bar_colour> 250 251 135 <bar_pos>0</bar_pos> 252 253 136 <bar_width>19</bar_width> 254 255 137 <bar_end>20</bar_end> 256 257 138 <text_pos>0</text_pos> 258 259 139 <orientation>horizontal</orientation> 260 261 140 </skin> 262 141 263 142 <skin> 264 265 143 <skin_name>Horizontal - Thin Black</skin_name> 266 267 144 <skin_slug>oli-thinblackhorizontal</skin_slug> 268 269 145 <bulb_file>left.png</bulb_file> 270 271 146 <bar_file>middle.png</bar_file> 272 273 147 <top_file>right.png</top_file> 274 275 148 <bar_colour>000000</bar_colour> 276 277 149 <bar_pos>0</bar_pos> 278 279 150 <bar_width>19</bar_width> 280 281 151 <bar_end>20</bar_end> 282 283 152 <text_pos>0</text_pos> 284 285 153 <orientation>horizontal</orientation> 286 287 154 </skin> 288 155 -
olimometer/trunk/thermometer.php
r675314 r710347 57 57 $total_value = $olimometer_to_display->olimometer_total_value; 58 58 $progress_value = $olimometer_to_display->olimometer_progress_value; 59 $currency = $olimometer_to_display->olimometer_currency;60 59 $text_colour = $olimometer_to_display->olimometer_text_colour; 61 60 $transparent = $olimometer_to_display->olimometer_transparent; … … 64 63 $progress_label = $olimometer_to_display->olimometer_progress_label; 65 64 $font_height = $olimometer_to_display->olimometer_font_height; 66 $suffix = $olimometer_to_display->olimometer_suffix;67 65 68 66 // Overlay Variables … … 72 70 $overlay_y = $olimometer_to_display->olimometer_overlay_y; 73 71 74 if($olimometer_to_display->olimometer_number_format == null) { 75 $olimometer_number_format = 0; 76 } 77 else { 78 $olimometer_number_format = $olimometer_to_display->olimometer_number_format; 79 } 80 81 82 // Value layout array: 83 84 // No dp, no thousands 85 $olimometer_display_array[0][0] = 0; 86 $olimometer_display_array[0][1] = ''; 87 $olimometer_display_array[0][2] = '.'; 88 // no dp, thousands marker 89 $olimometer_display_array[1][0] = 0; 90 $olimometer_display_array[1][1] = ','; 91 $olimometer_display_array[1][2] = '.'; 92 // 2dp, no thousands 93 $olimometer_display_array[2][0] = 2; 94 $olimometer_display_array[2][1] = ''; 95 $olimometer_display_array[2][2] = '.'; 96 // 2dp, thousands marker 97 $olimometer_display_array[3][0] = 2; 98 $olimometer_display_array[3][1] = ','; 99 $olimometer_display_array[3][2] = '.'; 100 // no dp, period thousands marker 101 $olimometer_display_array[4][0] = 0; 102 $olimometer_display_array[4][1] = '.'; 103 $olimometer_display_array[4][2] = ','; 104 // 2dp (comma), period thousands marker 105 $olimometer_display_array[5][0] = 2; 106 $olimometer_display_array[5][1] = '.'; 107 $olimometer_display_array[5][2] = ','; 108 // no dp, space thousands marker 109 $olimometer_display_array[6][0] = 0; 110 $olimometer_display_array[6][1] = ' '; 111 $olimometer_display_array[6][2] = '.'; 112 // 2dp (comma), space thousands marker 113 $olimometer_display_array[7][0] = 2; 114 $olimometer_display_array[7][1] = ' '; 115 $olimometer_display_array[7][2] = ','; 116 // 2dp (period), space thousands marker 117 $olimometer_display_array[8][0] = 2; 118 $olimometer_display_array[8][1] = '.'; 119 $olimometer_display_array[8][2] = ' '; 120 121 122 // Display converted values: 123 $olimometer_display_dp = $olimometer_display_array[$olimometer_number_format][0]; 124 $olimometer_display_thousands = $olimometer_display_array[$olimometer_number_format][1]; 125 $olimometer_display_decimal = $olimometer_display_array[$olimometer_number_format][2]; 126 //$olimometer_display_dp = 2; 127 //$olimometer_display_thousands = ','; 128 $display_total_value = number_format($total_value,$olimometer_display_dp,$olimometer_display_decimal,$olimometer_display_thousands); 129 $display_progress_value = number_format($progress_value,$olimometer_display_dp,$olimometer_display_decimal,$olimometer_display_thousands); 130 $display_zero = number_format(0,$olimometer_display_dp,$olimometer_display_decimal,$olimometer_display_thousands); 131 132 // Figure out prefix and suffix values 133 switch($currency) { 134 case 128: 135 $currency_symbol = "€"; 136 break; 137 case '': 138 $currency_symbol = ""; 139 break; 140 case 'x': 141 $currency_symbol = ""; 142 break; 143 case '10000': 144 $currency_symbol = "kr "; 145 break; 146 case '10001': 147 $currency_symbol = "CHF "; 148 break; 149 default: 150 $currency_symbol = "&#$currency;"; 151 } 152 153 switch($suffix) { 154 case 128: 155 $suffix_symbol = "€"; 156 break; 157 case '': 158 $suffix_symbol = ""; 159 break; 160 case 'x': 161 $suffix_symbol = ""; 162 break; 163 case '10000': 164 $suffix_symbol = " kr"; 165 break; 166 case '10001': 167 $suffix_symbol = " CHF"; 168 break; 169 default: 170 $suffix_symbol = "&#$suffix;"; 171 } 172 72 73 $display_total_value = $olimometer_to_display->get_display_total(); 74 $display_progress_value = $olimometer_to_display->get_display_progress(); 75 $display_zero = $olimometer_to_display->get_display_zero(); 76 173 77 174 78 // Are we making a horizontal or a vertical thermometer? … … 180 84 $therm_bulb = imagecreatefrompng($therm_bulb_file); 181 85 list($therm_bulb_width, $therm_bulb_height) = getimagesize($therm_bulb_file); 182 //$bulb_ypos = $thermometer_height - $therm_bulb_height;183 184 //if the progress value and label are being shown, leave space at the bottom of the thermometer for the label.185 /*if($show_progress == 1) {186 $thermometer_height = $therm_bulb_height - ($font_height*2);187 }188 else {189 $thermometer_height = $therm_bulb_height;190 }*/191 192 86 193 87 //create temporary image … … 205 99 $therm_bar = imagecreatefrompng($therm_bar_file); 206 100 list($therm_bar_width, $therm_bar_height) = getimagesize($therm_bar_file); 207 208 101 209 102 //put the top on the thermometer 210 //$therm_top = imagecreatefromjpeg($therm_top_file);211 103 $therm_top = imagecreatefrompng($therm_top_file); 212 104 list($therm_top_width, $therm_top_height) = getimagesize($therm_top_file); 213 //$top_xpos = $thermometer_height-$therm_top_height;214 215 105 216 106 //work out length of mercury bar … … 229 119 230 120 //draw mercury line 231 //$mercury_colour_rgb = imagecolorat($therm_bulb, 27, 3); // Old method of getting colour.. use new skin specified value insead232 121 $mercury_colour_array = rgb2array($therm_bar_merc_colour); 233 122 $mercury_colour_rgb = imagecolorallocate($temp_new_image, $mercury_colour_array[0], $mercury_colour_array[1], $mercury_colour_array[2]); … … 244 133 // Are we showing the target labels? 245 134 if($show_target == 1) { 246 $the_box = calculateTextBox($currency_symbol.$display_total_value.$suffix_symbol, $font_name, $font_height, 0); 247 //$the_box = imagettfbboxextended($font_height, 0, $font_name, $currency_symbol.$total_value.$suffix_symbol); 135 $the_box = calculateTextBox($olimometer_to_display->get_display_total(), $font_name, $font_height, 0); 248 136 $top_text_width = $the_box["width"]; 249 250 // The width of the image file = label width + x_pos of label.251 //$new_image_width = $top_text_width + $therm_text_xpos + 2;252 137 } 253 138 … … 255 140 if($show_progress == 1) { 256 141 // Calculate the width of it 257 $the_box2 = calculateTextBox($progress_label.' '.$currency_symbol.$display_progress_value.$suffix_symbol, $font_name, $font_height, 0); 258 //$the_box2 = imagettfbboxextended($font_height, 0, $font_name, $progress_label.' '.$currency_symbol.$progress_value.$suffix_symbol); 142 $the_box2 = calculateTextBox($progress_label.' '.$olimometer_to_display->get_display_progress(), $font_name, $font_height, 0); 259 143 $progress_text_width = $the_box2["width"] + 2; 260 144 // Is this wider than our previously calculated value? … … 295 179 imagecopyresampled($new_image, $therm_top, $image_height-$therm_top_width, $top_of_therm, 0, 0, $therm_top_width, $therm_top_height, $therm_top_width, $therm_top_height); 296 180 // - Draw mercury line 297 //imagefilledrectangle($new_image, $therm_bulb_width, $therm_bar_merc_xpos+$top_of_therm, $top_of_bar,$therm_bar_merc_xpos+$therm_bar_merc_width+$top_of_therm, $mercury_colour_rgb);298 181 imagefilledrectangle($new_image, $therm_bulb_width, $therm_bar_merc_xpos+$top_of_therm, $filled_bar_length+$therm_bulb_width,$therm_bar_merc_xpos+$therm_bar_merc_width+$top_of_therm, $mercury_colour_rgb); 299 182 // - Add value labels to the right of the thermometer 300 183 if($show_target == 1) { 301 imagettftext($new_image, $font_height, 0, 0, $font_height+2, $text_colour_rgb, $font_name, $ currency_symbol.$display_zero.$suffix_symbol);302 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);184 imagettftext($new_image, $font_height, 0, 0, $font_height+2, $text_colour_rgb, $font_name, $olimometer_to_display->get_display_zero()); 185 imagettftext($new_image, $font_height, 0, $image_height-$top_text_width, $font_height+2, $text_colour_rgb, $font_name, $olimometer_to_display->get_display_total()); 303 186 } 304 187 // - If the Progress label is needed, show it! … … 313 196 $progress_label_x = ($new_image_width-$progress_text_width)/2; 314 197 } 315 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); 316 //imagettftext($new_image, $font_height, 0, 30, $therm_bulb_height+4, $text_colour_rgb, $font_name, "Testing"); 317 } 318 //$image_height-(ceil($font_height/2)) 198 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.' '.$olimometer_to_display->get_display_progress()); 199 } 319 200 // - Set transparancy if required using supplied background colour as mask 320 201 if ($transparent == 1) { … … 326 207 //if the progress value and label are being shown, leave space at the bottom of the thermometer for the label. 327 208 if($show_progress == 1) { 328 $thermometer_height = $image_height - ($font_height*2);209 $thermometer_height = $image_height - ($font_height*2); 329 210 } 330 211 else { 331 $thermometer_height = $image_height;212 $thermometer_height = $image_height; 332 213 } 333 214 … … 343 224 344 225 //read bulb image file and place at the bottom of new file 345 //$therm_bulb = imagecreatefromjpeg($therm_bulb_file);346 226 $therm_bulb = imagecreatefrompng($therm_bulb_file); 347 227 list($therm_bulb_width, $therm_bulb_height) = getimagesize($therm_bulb_file); … … 350 230 351 231 //read bar thermometer image 352 //$therm_bar = imagecreatefromjpeg($therm_bar_file);353 232 $therm_bar = imagecreatefrompng($therm_bar_file); 354 233 list($therm_bar_width, $therm_bar_height) = getimagesize($therm_bar_file); … … 356 235 357 236 //put the top on the thermometer 358 //$therm_top = imagecreatefromjpeg($therm_top_file);359 237 $therm_top = imagecreatefrompng($therm_top_file); 360 238 list($therm_top_width, $therm_top_height) = getimagesize($therm_top_file); … … 376 254 377 255 //draw mercury line 378 //$mercury_colour_rgb = imagecolorat($therm_bulb, 27, 3); // Old method of getting colour.. use new skin specified value insead379 256 $mercury_colour_array = rgb2array($therm_bar_merc_colour); 380 257 $mercury_colour_rgb = imagecolorallocate($temp_new_image, $mercury_colour_array[0], $mercury_colour_array[1], $mercury_colour_array[2]); … … 391 268 // Are we showing the target labels? 392 269 if($show_target == 1) { 393 $the_box = calculateTextBox($currency_symbol.$display_total_value.$suffix_symbol, $font_name, $font_height, 0); 394 //$the_box = imagettfbboxextended($font_height, 0, $font_name, $currency_symbol.$total_value.$suffix_symbol); 270 $the_box = calculateTextBox($olimometer_to_display->get_display_total(), $font_name, $font_height, 0); 395 271 $top_text_width = $the_box["width"]; 396 272 … … 402 278 if($show_progress == 1) { 403 279 // Calculate the width of it 404 $the_box2 = calculateTextBox($progress_label.' '.$currency_symbol.$display_progress_value.$suffix_symbol, $font_name, $font_height, 0); 405 //$the_box2 = imagettfbboxextended($font_height, 0, $font_name, $progress_label.' '.$currency_symbol.$progress_value.$suffix_symbol); 280 $the_box2 = calculateTextBox($progress_label.' '.$olimometer_to_display->get_display_progress(), $font_name, $font_height, 0); 406 281 $progress_text_width = $the_box2["width"] + 2; 407 282 // Is this wider than our previously calculated value? … … 422 297 // Are we using an overlay image? 423 298 if($overlay == 1) { 424 // Convert the image URL to a real file path425 //$wp_root_path = str_replace('/wp-content/themes', '', get_theme_root());426 //$converted_overlay_image = $wp_root_path.wp_make_link_relative( $overlay_image );427 428 299 // Load the overlay PNG 429 300 $overlay_image_object = imagecreatefrompng($overlay_image); … … 465 336 // - Add value labels to the right of the thermometer 466 337 if($show_target == 1) { 467 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);468 imagettftext($new_image, $font_height, 0, $therm_text_xpos, $bulb_ypos+10, $text_colour_rgb, $font_name, $ currency_symbol.$display_zero.$suffix_symbol);338 imagettftext($new_image, $font_height, 0, $therm_text_xpos, $font_height*1.2, $text_colour_rgb, $font_name, $olimometer_to_display->get_display_total()); 339 imagettftext($new_image, $font_height, 0, $therm_text_xpos, $bulb_ypos+10, $text_colour_rgb, $font_name, $olimometer_to_display->get_display_zero()); 469 340 } 470 341 // - If the Progress label is needed, show it! 471 342 if($show_progress == 1) { 472 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);343 imagettftext($new_image, $font_height, 0, 0, $image_height-(ceil($font_height/2)), $text_colour_rgb, $font_name, $progress_label.' '.$olimometer_to_display->get_display_progress()); 473 344 } 474 345
Note: See TracChangeset
for help on using the changeset viewer.