Changeset 38174

Show
Ignore:
Timestamp:
04/04/08 01:16:22 (3 months ago)
Author:
alexkingorg
Message:

first pass at 2.5 compatibility

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • answerlinks/trunk/answerlink.php

    r22302 r38174  
    3434Plugin Name: AnswerLinks 
    3535Description: Link to definitions and more on Answers.com from your posts. 
    36 Version: 1.0a 
     36Version: 1.1 
    3737Author: Answers.com and Crowd Favorite 
    3838Author URI: http://crowdfavorite.com 
    3939*/ 
     40 
     41global $wp_version; 
     42if (isset($wp_version) && version_compare($wp_version, '2.5', '>=')) { 
     43      define('AKV_25', true); 
     44      define('AKV_25s', 'true'); 
     45} 
     46else { 
     47      define('AKV_25', false); 
     48      define('AKV_25s', 'false'); 
     49} 
    4050 
    4151if (!function_exists('is_admin_page')) { 
     
    8292<script type="text/javascript"> 
    8393var jQuery = jQuery.noConflict(); 
     94 
     95var akv_25 = '.AKV_25s.'; 
    8496 
    8597function al_show() { 
     
    149161 
    150162      if (typeof tinyMCE != "undefined") { 
    151             var inst = tinyMCE.getInstanceById("content"); 
    152             if (inst) { 
    153                   inst.triggerSave(false, false); 
     163            if (akv_25) { 
     164                  tinyMCE.triggerSave(false, false); 
     165            } 
     166            else { 
     167                  var inst = tinyMCE.getInstanceById("content"); 
     168                  if (inst) { 
     169                        inst.triggerSave(false, false); 
     170                  } 
    154171            } 
    155172      } 
     
    161178 
    162179function addAnswerLinkTMCEButton() { 
    163       if (document.getElementById("mce_editor_0_wp_help")) { 
     180      if (!akv_25 && document.getElementById("mce_editor_0_wp_help")) { 
    164181            jQuery("#mce_editor_0_wp_help").after("<img src=\"'.get_bloginfo('wpurl').'/wp-includes/js/tinymce/themes/advanced/images/separator.gif\" class=\"mceSeparatorLine\" height=\"20\" width=\"2\" title=\"Get Suggested links from Answers.com\"><a id=\"mce_editor_0_answerlink\" href=\"'.get_bloginfo('wpurl').'/index.php\"class=\"mceButtonNormal thickbox\" target=\"_self\"><img src=\"'.get_bloginfo('wpurl').'/wp-content/plugins/answerlinks/images/mce_button.gif\" title=\"AnswerLinks\"></a>"); 
     182            jQuery("#mce_editor_0_answerlink").bind("click", requestAnswerLinkWindow); 
     183      } 
     184      else if (akv_25 && jQuery("#content_wp_adv").size()) { 
     185            jQuery("#content_wp_adv").parent().before("<td><a title=\"AnswerLinks\" onclick=\"return false;\" onmousedown=\"return false;\" class=\"mceButton mceButtonEnabled\" href=\"javascript:;\" id=\"mce_editor_0_answerlink\"><img src=\"'.get_bloginfo('wpurl').'/wp-content/plugins/answerlinks/images/mce_button.gif\" class=\"mceIcon\"/></a></td>"); 
    165186            jQuery("#mce_editor_0_answerlink").bind("click", requestAnswerLinkWindow); 
    166187      } 
     
    438459var answerlink = { 
    439460      links : new Array() 
     461      , gte25 : '.AKV_25s.' 
    440462} 
    441463 
     
    484506      parent.jQuery("#content").val(content); 
    485507      if (typeof parent.tinyMCE != "undefined") { 
    486             var inst = parent.tinyMCE.getInstanceById("content"); 
    487             if (inst) { 
    488                   parent.tinyMCE.setContent(content); 
    489                   inst.repaint(); 
     508            if (answerlink.gte25) { 
     509                  parent.tinyMCE.activeEditor.setContent(content); 
     510            } 
     511            else { 
     512                  var inst = parent.tinyMCE.getInstanceById("content"); 
     513                  if (inst) { 
     514                        parent.tinyMCE.setContent(content); 
     515                        inst.repaint(); 
     516                  } 
    490517            } 
    491518      } 
     
    698725      var $tagStack; 
    699726    
    700       function XMLParser($path
     727      function XMLParser($path = ''
    701728      { 
    702729      $this->parser = xml_parser_create(); 
     
    713740            xml_set_element_handler($this->parser, 'startHandler', 'endHandler'); 
    714741          
    715             if(!xml_parse($this->parser, $data, feof($fp))) 
     742            if(!xml_parse($this->parser, $data, true)) 
    716743            { 
    717744                  cf_answerlink_head_html(); 
     
    776803} 
    777804 
    778  
    779 /* proper TinyMCE plugin code 
    780  
    781 // PHP Code 
    782  
    783 function cf_answerlink_addMCE_plugin($plugins) { 
    784       $plugins[] = 'answerlink'; 
    785       return $plugins; 
    786 } 
    787 add_filter('mce_plugins', 'cf_answerlink_addMCE_plugin'); 
    788  
    789 // JS Code 
    790  
    791 answerlink_mce_plugin = { 
    792       getInfo: function() { 
    793             return { 
    794                   longname : "AnswerLink TinyMCE Plugin", 
    795                   author : "Crowd Favorite", 
    796                   authorurl : "http://crowdfavorite.com", 
    797                   infourl : "", 
    798                   version : "1.0" 
    799             }; 
    800       } 
    801 }; 
    802 if (typeof(tinyMCE) !== "undefined") { 
    803       tinyMCE.addPlugin("answerlink", answerlink_mce_plugin); 
    804 } 
    805 */ 
    806  
    807  
    808805?>