| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
global $wp_version; |
|---|
| 42 |
if (isset($wp_version) && version_compare($wp_version, '2.5', '>=')) { |
|---|
| 43 |
define('AKV_25', true); |
|---|
| 44 |
define('AKV_25s', 'true'); |
|---|
| 45 |
} |
|---|
| 46 |
else { |
|---|
| 47 |
define('AKV_25', false); |
|---|
| 48 |
define('AKV_25s', 'false'); |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
if (!function_exists('is_admin_page')) { |
|---|
| 52 |
function is_admin_page() { |
|---|
| 53 |
if (function_exists('is_admin')) { |
|---|
| 54 |
return is_admin(); |
|---|
| 55 |
} |
|---|
| 56 |
if (function_exists('check_admin_referer')) { |
|---|
| 57 |
return true; |
|---|
| 58 |
} |
|---|
| 59 |
else { |
|---|
| 60 |
return false; |
|---|
| 61 |
} |
|---|
| 62 |
} |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
if (is_admin_page() && !AKV_25) { |
|---|
| 66 |
wp_enqueue_script('jquery'); |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
if (!function_exists('wp_prototype_before_jquery')) { |
|---|
| 70 |
function wp_prototype_before_jquery( $js_array ) { |
|---|
| 71 |
if ( false === $jquery = array_search( 'jquery', $js_array ) ) |
|---|
| 72 |
return $js_array; |
|---|
| 73 |
|
|---|
| 74 |
if ( false === $prototype = array_search( 'prototype', $js_array ) ) |
|---|
| 75 |
return $js_array; |
|---|
| 76 |
|
|---|
| 77 |
if ( $prototype < $jquery ) |
|---|
| 78 |
return $js_array; |
|---|
| 79 |
|
|---|
| 80 |
unset($js_array[$prototype]); |
|---|
| 81 |
|
|---|
| 82 |
array_splice( $js_array, $jquery, 0, 'prototype' ); |
|---|
| 83 |
|
|---|
| 84 |
return $js_array; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); |
|---|
| 88 |
} |
|---|
| 89 |
|
|---|
| 90 |
function cf_answerlink_header() { |
|---|
| 91 |
print(' |
|---|
| 92 |
<script type="text/javascript"> |
|---|
| 93 |
|
|---|
| 94 |
// var jQuery = jQuery.noConflict(); |
|---|
| 95 |
var akv_25 = '.AKV_25s.'; |
|---|
| 96 |
|
|---|
| 97 |
function al_show() { |
|---|
| 98 |
try { |
|---|
| 99 |
if (typeof document.body.style.maxHeight === "undefined") {//if IE 6 |
|---|
| 100 |
jQuery("body","html").css({height: "100%", width: "100%"}); |
|---|
| 101 |
jQuery("html").css("overflow","hidden"); |
|---|
| 102 |
if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6 |
|---|
| 103 |
jQuery("body").append("<iframe id=\'TB_HideSelect\'></iframe><div id=\'TB_overlay\'></div><div id=\'TB_window\'></div>"); |
|---|
| 104 |
jQuery("#TB_overlay").click(al_remove); |
|---|
| 105 |
} |
|---|
| 106 |
}else{//all others |
|---|
| 107 |
if(document.getElementById("TB_overlay") === null){ |
|---|
| 108 |
jQuery("body").append(\'<div id="TB_overlay"></div><div id="TB_window"></div>\'); |
|---|
| 109 |
jQuery("#TB_overlay").click(al_remove); |
|---|
| 110 |
} |
|---|
| 111 |
} |
|---|
| 112 |
|
|---|
| 113 |
TB_WIDTH = 700; |
|---|
| 114 |
TB_HEIGHT = 500; |
|---|
| 115 |
ajaxContentW = TB_WIDTH; |
|---|
| 116 |
ajaxContentH = TB_HEIGHT; |
|---|
| 117 |
|
|---|
| 118 |
al_position(); |
|---|
| 119 |
if(frames[\'TB_iframeContent\'] === undefined){//be nice to safari |
|---|
| 120 |
jQuery("#TB_load").remove(); |
|---|
| 121 |
jQuery("#TB_window").css({display:"block"}); |
|---|
| 122 |
jQuery(document).keyup( function(e){ var key = e.keyCode; if(key == 27){al_remove();}}); |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
} catch(e) { |
|---|
| 126 |
//nothing here |
|---|
| 127 |
} |
|---|
| 128 |
} |
|---|
| 129 |
|
|---|
| 130 |
//helper functions below |
|---|
| 131 |
function al_remove() { |
|---|
| 132 |
jQuery("#TB_imageOff").unbind("click"); |
|---|
| 133 |
jQuery("#TB_overlay").unbind("click"); |
|---|
| 134 |
jQuery("#TB_closeWindowButton").unbind("click"); |
|---|
| 135 |
jQuery("#TB_window").fadeOut("fast",function(){jQuery(\'#TB_window,#TB_overlay,#TB_HideSelect\').remove();}); |
|---|
| 136 |
jQuery("#TB_load").remove(); |
|---|
| 137 |
if (typeof document.body.style.maxHeight == "undefined") {//if IE 6 |
|---|
| 138 |
jQuery("body","html").css({height: "auto", width: "auto"}); |
|---|
| 139 |
jQuery("html").css("overflow",""); |
|---|
| 140 |
} |
|---|
| 141 |
document.onkeydown = ""; |
|---|
| 142 |
return false; |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
function al_position() { |
|---|
| 146 |
jQuery("#TB_window").css({marginLeft: \'-\' + parseInt((TB_WIDTH / 2),10) + \'px\', width: 700 + \'px\'}); |
|---|
| 147 |
if ( !(jQuery.browser.msie && typeof XMLHttpRequest == \'function\')) { // take away IE6 |
|---|
| 148 |
jQuery("#TB_window").css({marginTop: \'-\' + parseInt((500 / 2),10) + \'px\'}); |
|---|
| 149 |
} |
|---|
| 150 |
} |
|---|
| 151 |
|
|---|
| 152 |
function requestAnswerLinkWindow() { |
|---|
| 153 |
if (document.getElementById("TB_window")) { |
|---|
| 154 |
return; |
|---|
| 155 |
} |
|---|
| 156 |
al_show(); |
|---|
| 157 |
al_position(); |
|---|
| 158 |
if (typeof tinyMCE != "undefined") { |
|---|
| 159 |
if (akv_25) { |
|---|
| 160 |
tinyMCE.triggerSave(false, false); |
|---|
| 161 |
} |
|---|
| 162 |
else { |
|---|
| 163 |
var inst = tinyMCE.getInstanceById("content"); |
|---|
| 164 |
if (inst) { |
|---|
| 165 |
inst.triggerSave(false, false); |
|---|
| 166 |
} |
|---|
| 167 |
} |
|---|
| 168 |
} |
|---|
| 169 |
jQuery("#TB_window").css({background: "#033c66"}).append(\'<iframe name="TB_iframeContent" id="TB_iframeContent" src="'.get_bloginfo('wpurl').'/index.php?cf_action=answerlink-init" border="0" frameborder="0" style="height: 500px; width: 700px; border: 0;"></iframe>\'); |
|---|
| 170 |
return false; |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
function addAnswerLinkTMCEButton() { |
|---|
| 174 |
if (!akv_25 && document.getElementById("mce_editor_0_wp_help")) { |
|---|
| 175 |
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>"); |
|---|
| 176 |
jQuery("#mce_editor_0_answerlink").bind("click", requestAnswerLinkWindow); |
|---|
| 177 |
} |
|---|
| 178 |
else if (akv_25 && jQuery("#content_wp_adv").size()) { |
|---|
| 179 |
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>"); |
|---|
| 180 |
jQuery("#mce_editor_0_answerlink").bind("click", requestAnswerLinkWindow); |
|---|
| 181 |
} |
|---|
| 182 |
else { |
|---|
| 183 |
setTimeout("addAnswerLinkTMCEButton();", 300); |
|---|
| 184 |
} |
|---|
| 185 |
} |
|---|
| 186 |
|
|---|
| 187 |
jQuery(window).load(function() { |
|---|
| 188 |
if (!jQuery.browser.opera) { |
|---|
| 189 |
if (document.getElementById("postdivrich")) { |
|---|
| 190 |
addAnswerLinkTMCEButton(); |
|---|
| 191 |
} |
|---|
| 192 |
else { |
|---|
| 193 |
jQuery("#ed_close").after("<input id=\"ed_answerlink\" class=\"ed_button\" title=\"Get Suggested links from Answers.com\" value=\"AnswerLinks\" type=\"button\" />"); |
|---|
| 194 |
jQuery("#ed_answerlink").bind("click", requestAnswerLinkWindow); |
|---|
| 195 |
} |
|---|
| 196 |
} |
|---|
| 197 |
}); |
|---|
| 198 |
|
|---|
| 199 |
</script> |
|---|
| 200 |
<link type="text/css" rel="stylesheet" href="'.get_bloginfo('wpurl').'/wp-content/plugins/answerlinks/thickbox.css" /> |
|---|
| 201 |
<style type="text/css"> |
|---|
| 202 |
#TB_window { |
|---|
| 203 |
height: 500px; |
|---|
| 204 |
width: 700px; |
|---|
| 205 |
} |
|---|
| 206 |
#TB_iframeContent { |
|---|
| 207 |
margin-top: 0; |
|---|
| 208 |
} |
|---|
| 209 |
</style> |
|---|
| 210 |
'); |
|---|
| 211 |
} |
|---|
| 212 |
add_action('admin_head', 'cf_answerlink_header'); |
|---|
| 213 |
|
|---|
| 214 |
function cf_answerlink_request_handler() { |
|---|
| 215 |
if (!empty($_REQUEST['cf_action'])) { |
|---|
| 216 |
switch ($_REQUEST['cf_action']) { |
|---|
| 217 |
case 'answerlink-init': |
|---|
| 218 |
print(' |
|---|
| 219 |
<html><body style="overflow: hidden;"> |
|---|
| 220 |
<div style="background: url('.get_bloginfo('wpurl').'/wp-content/plugins/answerlinks/images/loading.gif) center center no-repeat; height: 500px; width: 700px;"> |
|---|
| 221 |
</div> |
|---|
| 222 |
<form name="answerlink" id="answerlink" action="'.get_bloginfo('wpurl').'/index.php?nocache='.microtime().'" method="post"> |
|---|
| 223 |
<input type="hidden" name="content" id="al_iframe_content" value="" /> |
|---|
| 224 |
<input type="hidden" name="cf_action" value="answerlink-window" /> |
|---|
| 225 |
<input type="submit" /> |
|---|
| 226 |
</form> |
|---|
| 227 |
<script type="text/javascript"> |
|---|
| 228 |
document.getElementById("al_iframe_content").value = parent.document.getElementById("content").value; |
|---|
| 229 |
function submitForm() { |
|---|
| 230 |
document.answerlink.submit(); |
|---|
| 231 |
} |
|---|
| 232 |
window.onload = submitForm; |
|---|
| 233 |
</script> |
|---|
| 234 |
</body></html> |
|---|
| 235 |
'); |
|---|
| 236 |
die(); |
|---|
| 237 |
break; |
|---|
| 238 |
case 'answerlink-window': |
|---|
| 239 |
require_once(ABSPATH.WPINC.'/class-snoopy.php'); |
|---|
| 240 |
$snoop = new Snoopy; |
|---|
| 241 |
$snoop->read_timeout = 5; |
|---|
| 242 |
$snoop->submit( |
|---|
| 243 |
'http://alink.answers.com/link/xml' |
|---|
| 244 |
, array( |
|---|
| 245 |
'text' => stripslashes($_POST['content']) |
|---|
| 246 |
) |
|---|
| 247 |
); |
|---|
| 248 |
$parser = new XMLParser; |
|---|
| 249 |
$parser->parse($snoop->results); |
|---|
| 250 |
$data = $parser->document['TEXT'][0]; |
|---|
| 251 |
$content = $data['CONTENT'][0]['data']; |
|---|
| 252 |
$links = array(); |
|---|
| 253 |
if (is_array($data['LINKS'][0]['LINK'])) { |
|---|
| 254 |
foreach ($data['LINKS'][0]['LINK'] as $link) { |
|---|
| 255 |
$links[$link['ID'][0]['data']] = array( |
|---|
| 256 |
'id' => $link['ID'][0]['data'] |
|---|
| 257 |
, 'url' => $link['URL'][0]['data'] |
|---|
| 258 |
, 'phrase' => $link['PHRASE'][0]['data'] |
|---|
| 259 |
); |
|---|
| 260 |
} |
|---|
| 261 |
} |
|---|
| 262 |
@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); |
|---|
| 263 |
cf_answerlink_head_html(true); |
|---|
| 264 |
cf_answerlink_form($content, $links); |
|---|
| 265 |
cf_answerlink_foot_html(); |
|---|
| 266 |
die(); |
|---|
| 267 |
break; |
|---|
| 268 |
} |
|---|
| 269 |
} |
|---|
| 270 |
} |
|---|
| 271 |
add_action('init', 'cf_answerlink_request_handler', 9999); |
|---|
| 272 |
|
|---|
| 273 |
function cf_answerlink_head_html($meta = false) { |
|---|
| 274 |
|
|---|
| 275 |
if (strpos($_SERVER['HTTP_HOST'], 'wordpress.com') !== false) { |
|---|
| 276 |
$header_img = 'header.gif'; |
|---|
| 277 |
} |
|---|
| 278 |
else { |
|---|
| 279 |
$header_img = 'header-org.gif'; |
|---|
| 280 |
} |
|---|
| 281 |
|
|---|
| 282 |
print(' |
|---|
| 283 |
<html> |
|---|
| 284 |
<head> |
|---|
| 285 |
<style type="text/css"> |
|---|
| 286 |
body { |
|---|
| 287 |
color: #000; |
|---|
| 288 |
font-size: 12px; |
|---|
| 289 |
margin: 0; |
|---|
| 290 |
padding: 0; |
|---|
| 291 |
overflow: hidden; |
|---|
| 292 |
} |
|---|
| 293 |
|
|---|
| 294 |
#answerlinkform { |
|---|
| 295 |
overflow: hidden; |
|---|
| 296 |
} |
|---|
| 297 |
#al_header { |
|---|
| 298 |
background: url('.get_bloginfo('wpurl').'/wp-content/plugins/answerlinks/images/'.$header_img.') no-repeat; |
|---|
| 299 |
height: 61px; |
|---|
| 300 |
margin: 0; |
|---|
| 301 |
padding: 0; |
|---|
| 302 |
} |
|---|
| 303 |
#al_header span { |
|---|
| 304 |
display: none; |
|---|
| 305 |
} |
|---|
| 306 |
#al_content { |
|---|
| 307 |
background: url('.get_bloginfo('wpurl').'/wp-content/plugins/answerlinks/images/body.gif) no-repeat; |
|---|
| 308 |
height: 381px; |
|---|
| 309 |
padding: 0 15px; |
|---|
| 310 |
overflow: hidden; |
|---|
| 311 |
} |
|---|
| 312 |
#answerlinkform div.clear { |
|---|
| 313 |
clear: both; |
|---|
| 314 |
float: none; |
|---|
| 315 |
} |
|---|
| 316 |
#answerlinkform #answerlink_left { |
|---|
| 317 |
float: left; |
|---|
| 318 |
margin: 10px 10px 0 0; |
|---|
| 319 |
overflow: hidden; |
|---|
| 320 |
width: 450px; |
|---|
| 321 |
} |
|---|
| 322 |
#answerlinkform .content { |
|---|
| 323 |
background: #fff; |
|---|
| 324 |
border: 1px solid #ccc; |
|---|
| 325 |
height: 260px; |
|---|
| 326 |
line-height: 140%; |
|---|
| 327 |
margin: 0 0 10px 0; |
|---|
| 328 |
overflow: auto; |
|---|
| 329 |
padding: 7px; |
|---|
| 330 |
} |
|---|
| 331 |
#answerlinkform .content a { |
|---|
| 332 |
color: #000; |
|---|
| 333 |
border-color: #000; |
|---|
| 334 |
} |
|---|
| 335 |
#answerlinkform .content span { |
|---|
| 336 |
background: #ffc; |
|---|
| 337 |
padding: 2px; |
|---|
| 338 |
} |
|---|
| 339 |
#answerlinkform .content span.active { |
|---|
| 340 |
background: #d9ecf5; |
|---|
| 341 |
border: 2px solid #95c4dc; |
|---|
| 342 |
padding: 2px; |
|---|
| 343 |
} |
|---|
| 344 |
#answerlinkform .content span.linked { |
|---|
| 345 |
background: #e6f8d5; |
|---|
| 346 |
border: 1px solid #a1dc69; |
|---|
| 347 |
padding: 2px; |
|---|
| 348 |
} |
|---|
| 349 |
#answerlinkform .content span.unlinked { |
|---|
| 350 |
background: #eee; |
|---|
| 351 |
border: 1px solid #999; |
|---|
| 352 |
padding: 2px; |
|---|
| 353 |
} |
|---|
| 354 |
#answerlinkform .content span a { |
|---|
| 355 |
color: blue; |
|---|
| 356 |
border-color: blue; |
|---|
| 357 |
} |
|---|
| 358 |
#answerlinkform #answerlink_links { |
|---|
| 359 |
float: left; |
|---|
| 360 |
height: 360px; |
|---|
| 361 |
margin-top: 10px; |
|---|
| 362 |
overflow: auto; |
|---|
| 363 |
width: 190px; |
|---|
| 364 |
} |
|---|
| 365 |
#answerlinkform #answerlink_links h2 { |
|---|
| 366 |
background: #fff; |
|---|
| 367 |
border: 0; |
|---|
| 368 |
color: #777; |
|---|
| 369 |
font: bold 14px Verdana Arial, Helvetica, sans-serif; |
|---|
| 370 |
margin: 0; |
|---|
| 371 |
padding: 0 0 5px 0; |
|---|
| 372 |
} |
|---|
| 373 |
#answerlinkform #answerlink_links ul { |
|---|
| 374 |
border-top: 1px solid #ccc; |
|---|
| 375 |
list-style: none; |
|---|
| 376 |
} |
|---|
| 377 |
#answerlinkform #answerlink_links ul li { |
|---|
| 378 |
border-bottom: 1px solid #ccc; |
|---|
| 379 |
padding: 5px; |
|---|
| 380 |
} |
|---|
| 381 |
#answerlinkform #answerlink_links ul li input { |
|---|
| 382 |
margin-right: 5px; |
|---|
| 383 |
} |
|---|
| 384 |
#al_current_phrase_wrap label { |
|---|
| 385 |
color: #777; |
|---|
| 386 |
display: block; |
|---|
| 387 |
float: left; |
|---|
| 388 |
font-size: 12px; |
|---|
| 389 |
font-weight: bold; |
|---|
| 390 |
width: 100px; |
|---|
| 391 |
} |
|---|
| 392 |
#al_current_phrase_wrap span.block { |
|---|
| 393 |
float: left; |
|---|
| 394 |
width: 350px; |
|---|
| 395 |
} |
|---|
| 396 |
#al_current_phrase_wrap span.block a { |
|---|
| 397 |
border: 0; |
|---|
| 398 |
color: blue; |
|---|
| 399 |
text-decoration: underline; |
|---|
| 400 |
} |
|---|
| 401 |
#al_current_phrase_wrap span.block span.right { |
|---|
| 402 |
color: #777; |
|---|
| 403 |
float: right; |
|---|
| 404 |
} |
|---|
| 405 |
#al_current_phrase { |
|---|
| 406 |
display: block; |
|---|
| 407 |
font-size: 13px; |
|---|
| 408 |
font-weight: bold; |
|---|
| 409 |
} |
|---|
| 410 |
#al_wizard { |
|---|
| 411 |
margin: 10px 0 0 100px; |
|---|
| 412 |
} |
|---|
| 413 |
#al_wizard a, #al_wizard a img { |
|---|
| 414 |
border: 0; |
|---|
| 415 |
} |
|---|
| 416 |
#answerlinkform #al_wizard_complete { |
|---|
| 417 |
background: #ffc; |
|---|
| 418 |
display: none; |
|---|
| 419 |
font-weight: bold; |
|---|
| 420 |
margin: 5px 0 0 100px; |
|---|
| 421 |
padding: 10px; |
|---|
| 422 |
} |
|---|
| 423 |
#al_footer { |
|---|
| 424 |
background: url('.get_bloginfo('wpurl').'/wp-content/plugins/answerlinks/images/footer.gif) no-repeat; |
|---|
| 425 |
height: 58px; |
|---|
| 426 |
margin: 0; |
|---|
| 427 |
padding: 0; |
|---|
| 428 |
position: relative; |
|---|
| 429 |
text-align: center; |
|---|
| 430 |
} |
|---|
| 431 |
#al_footer input, #answerlink_button { |
|---|
| 432 |
background:transparent url(images/fade-butt.png) repeat scroll 0%; |
|---|
| 433 |
border-color:#CCCCCC rgb(153, 153, 153) rgb(153, 153, 153) rgb(204, 204, 204); |
|---|
| 434 |
border-style:double; |
|---|
| 435 |
border-width:3px; |
|---|
| 436 |
color:#333333; |
|---|
| 437 |
padding:0.25em; |
|---|
| 438 |
margin-top: 10px; |
|---|
| 439 |
} |
|---|
| 440 |
#al_footer a.about { |
|---|
| 441 |
top: 15px; |
|---|
| 442 |
position: absolute; |
|---|
| 443 |
right: 15px; |
|---|
| 444 |
} |
|---|
| 445 |
#al_footer a.contact { |
|---|
| 446 |
bottom: 15px; |
|---|
| 447 |
position: absolute; |
|---|
| 448 |
right: 15px; |
|---|
| 449 |
} |
|---|
| 450 |
</style> |
|---|
| 451 |
<script type="text/javascript" src="'.get_bloginfo('wpurl').'/wp-includes/js/jquery/jquery.js?ver=1.1.2"></script> |
|---|
| 452 |
<script type="text/javascript"> |
|---|
| 453 |
var answerlink = { |
|---|
| 454 |
links : new Array() |
|---|
| 455 |
, gte25 : '.AKV_25s.' |
|---|
| 456 |
} |
|---|
| 457 |
|
|---|
| 458 |
answerlink.link = { |
|---|
| 459 |
id : "" |
|---|
| 460 |
, url : "" |
|---|
| 461 |
, phrase : "" |
|---|
| 462 |
, linked : false |
|---|
| 463 |
} |
|---|
| 464 |
|
|---|
| 465 |
answerlink.enableLink = function(id) { |
|---|
| 466 |
var linkData = answerlink.getLink(id); |
|---|
| 467 |
var phrase = linkData[1]; |
|---|
| 468 |
var url = linkData[2]; |
|---|
| 469 |
jQuery("#" + id).html("<a href=\"" + url + "\" class=\"answerlink\">" + phrase + "</a>").removeClass("unlinked").addClass("linked"); |
|---|
| 470 |
jQuery("#alcb_" + id).attr("checked", "checked"); |
|---|
| 471 |
} |
|---|
| 472 |
|
|---|
| 473 |
answerlink.disableLink = function(id) { |
|---|
| 474 |
var linkData = answerlink.getLink(id); |
|---|
| 475 |
var phrase = linkData[1]; |
|---|
| 476 |
jQuery("#" + id).html(phrase).removeClass("linked").addClass("unlinked"); |
|---|
| 477 |
jQuery("#alcb_" + id).removeAttr("checked"); |
|---|
| 478 |
} |
|---|
| 479 |
|
|---|
| 480 |
answerlink.toggleLink = function(checkbox_id) { |
|---|
| 481 |
id = checkbox_id.replace("alcb_", ""); |
|---|
| 482 |
document.getElementById("answerlink_content").scrollTop = document.getElementById(id).offsetTop - 80; |
|---|
| 483 |
answerlink.setActiveLink(id); |
|---|
| 484 |
if (jQuery("#" + checkbox_id).attr("checked")) { |
|---|
| 485 |
answerlink.enableLink(id); |
|---|
| 486 |
} |
|---|
| 487 |
else { |
|---|
| 488 |
answerlink.disableLink(id); |
|---|
| 489 |
} |
|---|
| 490 |
} |
|---|
| 491 |
|
|---|
| 492 |
answerlink.applyLinks = function() { |
|---|
| 493 |
jQuery("#answerlink_content span").each(function() { |
|---|
| 494 |
if (jQuery(this).attr("id") && jQuery(this).attr("id").indexOf("alnk") != -1) { |
|---|
| 495 |
jQuery(this).before(this.innerHTML); |
|---|
| 496 |
jQuery(this).remove(); |
|---|
| 497 |
} |
|---|
| 498 |
}); |
|---|
| 499 |
var content = jQuery("#answerlink_content").html(); |
|---|
| 500 |
parent.jQuery("#content").val(content); |
|---|
| 501 |
if (typeof parent.tinyMCE != "undefined") { |
|---|
| 502 |
if (answerlink.gte25) { |
|---|
| 503 |
parent.tinyMCE.activeEditor.setContent(content); |
|---|
| 504 |
} |
|---|
| 505 |
else { |
|---|
| 506 |
var inst = parent.tinyMCE.getInstanceById("content"); |
|---|
| 507 |
if (inst) { |
|---|
| 508 |
parent.tinyMCE.setContent(content); |
|---|
| 509 |
inst.repaint(); |
|---|
| 510 |
} |
|---|
| 511 |
} |
|---|
| 512 |
} |
|---|
| 513 |
parent.al_remove(); |
|---|
| 514 |
} |
|---|
| 515 |
|
|---|
| 516 |
answerlink.getLink = function(id) { |
|---|
| 517 |
for (var i = 0; i < answerlink.links.length; i++) { |
|---|
| 518 |
var link = answerlink.links[i]; |
|---|
| 519 |
if (id == link[0]) { |
|---|
| 520 |
return [id, link[1], link[2]]; |
|---|
| 521 |
} |
|---|
| 522 |
} |
|---|
| 523 |
} |
|---|
| 524 |
|
|---|
| 525 |
answerlink.setLink = function(action) { |
|---|
| 526 |
var match = false; |
|---|
| 527 |
for (var i = 0; i < answerlink.links.length; i++) { |
|---|
| 528 |
var link = answerlink.links[i]; |
|---|
| 529 |
if (answerlink.activeLink == link[0]) { |
|---|
| 530 |
match = true; |
|---|
| 531 |
var url = link[2]; |
|---|
| 532 |
var next = false; |
|---|
| 533 |
if (i + 1 < answerlink.links.length) { |
|---|
| 534 |
var next = answerlink.links[i + 1][0]; |
|---|
| 535 |
var count = i + 2; |
|---|
| 536 |
} |
|---|
| 537 |
break; |
|---|
| 538 |
} |
|---|
| 539 |
} |
|---|
| 540 |
if (!match) { |
|---|
| 541 |
return; |
|---|
| 542 |
} |
|---|
| 543 |
switch (action) { |
|---|
| 544 |
case "enable": |
|---|
| 545 |
answerlink.enableLink(answerlink.activeLink); |
|---|
| 546 |
break; |
|---|
| 547 |
case "disable": |
|---|
| 548 |
answerlink.disableLink(answerlink.activeLink); |
|---|
| 549 |
break; |
|---|
| 550 |
} |
|---|
| 551 |
if (next) { |
|---|
| 552 |
answerlink.setActiveLink(next); |
|---|
| 553 |
document.getElementById("answerlink_content").scrollTop = document.getElementById(next).offsetTop - 80; |
|---|
| 554 |
} |
|---|
| 555 |
else { |
|---|
| 556 |
jQuery("#al_wizard").slideUp("normal", answerlink.finishedLinking); |
|---|
| 557 |
} |
|---|
| 558 |
} |
|---|
| 559 |
|
|---|
| 560 |
answerlink.setActiveLink = function(id) { |
|---|
| 561 |
jQuery("#answerlinkform .content span.active").removeClass("active"); |
|---|
| 562 |
answerlink.activeLink = id; |
|---|
| 563 |
jQuery("#" + id).addClass("active"); |
|---|
| 564 |
for (var i = 0; i < answerlink.links.length; i++) { |
|---|
| 565 |
if (id == answerlink.links[i]) { |
|---|
| 566 |
var count = i + 2; |
|---|
| 567 |
break; |
|---|
| 568 |
} |
|---|
| 569 |
} |
|---|
| 570 |
jQuery("#al_count").html(count); |
|---|
| 571 |
var linkData = answerlink.getLink(id); |
|---|
| 572 |
jQuery("#al_current_phrase").html(linkData[1]); |
|---|
| 573 |
jQuery("#al_current_link").html(linkData[2]).attr("href", linkData[2]); |
|---|
| 574 |
} |
|---|
| 575 |
|
|---|
| 576 |
answerlink.finishedLinking = function() { |
|---|
| 577 |
jQuery("#al_wizard_complete").slideDown(); |
|---|
| 578 |
} |
|---|
| 579 |
|
|---|
| 580 |
answerlink.cancel = function() { |
|---|
| 581 |
parent.al_remove(); |
|---|
| 582 |
} |
|---|
| 583 |
</script> |
|---|
| 584 |
'); |
|---|
| 585 |
if ($meta) { |
|---|
| 586 |
?> |
|---|
| 587 |
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> |
|---|
| 588 |
<?php |
|---|
| 589 |
} |
|---|
| 590 |
cf_answerlink_header(); |
|---|
| 591 |
print(' |
|---|
| 592 |
</head> |
|---|
| 593 |
<body> |
|---|
| 594 |
'); |
|---|
| 595 |
} |
|---|
| 596 |
|
|---|
| 597 |
function cf_answerlink_foot_html() { |
|---|
| 598 |
print(' |
|---|
| 599 |
</body> |
|---|
| 600 |
</html> |
|---|
| 601 |
'); |
|---|
| 602 |
} |
|---|
| 603 |
|
|---|
| 604 |
function cf_answerlink_nolinks() { |
|---|
| 605 |
print(' |
|---|
| 606 |
<div id="answerlinkform"> |
|---|
| 607 |
<h3 id="al_header"><span>AnswerLinks powered by <a href="http://www.answers.com" onclick="window.open(this.href); return false;">Answers.com</a></h3> |
|---|
| 608 |
|
|---|
| 609 |
<div id="al_content"> |
|---|
| 610 |
<p style="font-size: 14px; color: #666; padding: 50px 100px; text-align: center;">Sorry, we do not have any AnswerLinks to suggest at this time.</p> |
|---|
| 611 |
</div> |
|---|
| 612 |
<p id="al_footer"> |
|---|
| 613 |
<input type="button" name="cancel" value=" OK " onclick="answerlink.cancel();" /> |
|---|
| 614 |
<a href="http://www.answers.com/main/wordpress_howto.jsp" onclick="window.open(this.href); return false;" class="about">About This Feature</a> |
|---|
| 615 |
<a href="http://www.answers.com/main/contact_us.jsp" onclick="window.open(this.href); return false;" class="contact">Contact Answers.com</a> |
|---|
| 616 |
</p> |
|---|
| 617 |
</div> |
|---|
| 618 |
'); |
|---|
| 619 |
} |
|---|
| 620 |
|
|---|
| 621 |
function cf_answerlink_form($content = '', $links = array()) { |
|---|
| 622 |
if (count($links) == 0) { |
|---|
| 623 |
cf_answerlink_nolinks(); |
|---|
| 624 |
return; |
|---|
| 625 |
} |
|---|
| 626 |
print(' |
|---|
| 627 |
<div id="answerlinkform"> |
|---|
| 628 |
<h3 id="al_header"><span>AnswerLinks powered by <a href="http://www.answers.com" onclick="window.open(this.href); return false;">Answers.com</a></h3> |
|---|
| 629 |
|
|---|
| 630 |
<div id="al_content"> |
|---|
| 631 |
'); |
|---|
| 632 |
$content = apply_filters('the_content', $content); |
|---|
| 633 |
$link_js = array(); |
|---|
| 634 |
$i = 0; |
|---|
| 635 |
foreach ($links as $link) { |
|---|
| 636 |
if ($i == 0) { |
|---|
| 637 |
$first_link = $link; |
|---|
| 638 |
$i++; |
|---|
| 639 |
} |
|---|
| 640 |
$link_js[] = '["'.$link['id'].'", "'.$link['phrase'].'", "'.$link['url'].'"]'; |
|---|
| 641 |
} |
|---|
| 642 |
$link_js = ' |
|---|
| 643 |
answerlink.links = ['.implode(',', $link_js).']; |
|---|
| 644 |
'; |
|---|
| 645 |
$js = str_replace('"', '\"', 'answerlink.activeLink = "'.$first_link['id'].'"; '.str_replace("\n", ' ', $link_js).' jQuery("#" + answerlink.activeLink).addClass("active");'); |
|---|
| 646 |
|
|---|
| 647 |
print(' |
|---|
| 648 |
|
|---|
| 649 |
<script type="text/javascript"> |
|---|
| 650 |
|
|---|
| 651 |
answerlink.activeLink = "'.$first_link['id'].'"; '.str_replace("\n", ' ', $link_js).' |
|---|
| 652 |
|
|---|
| 653 |
</script> |
|---|
| 654 |
|
|---|
| 655 |
<div id="answerlink_left"> |
|---|
| 656 |
|
|---|
| 657 |
<div class="content" id="answerlink_content">'.$content.'</div> |
|---|
| 658 |
|
|---|
| 659 |
<div class="clear"></div> |
|---|
| 660 |
|
|---|
| 661 |
<p id="al_current_phrase_wrap"> |
|---|
| 662 |
<label for="al_current_phrase">Suggested link:</label> |
|---|
| 663 |
<span class="block"> |
|---|
| 664 |
<span class="right"><span id="al_count">1</span> of '.count($links).'</span> |
|---|
| 665 |
<span id="al_current_phrase">'.htmlspecialchars($first_link['phrase']).'</span> |
|---|
| 666 |
<a id="al_current_link" href="'.$first_link['url'].'" target="_blank">'.$first_link['url'].'</a> |
|---|
| 667 |
</span> |
|---|
| 668 |
</p> |
|---|
| 669 |
|
|---|
| 670 |
<div class="clear"></div> |
|---|
| 671 |
|
|---|
| 672 |
<p id="al_wizard"> |
|---|
| 673 |
<a href="#" onclick="answerlink.setLink(\'enable\'); return false;"><img src="'.get_bloginfo('wpurl').'/wp-content/plugins/answerlinks/images/button_link.gif" alt="Link" /></a> |
|---|
| 674 |
<a href="#" onclick="answerlink.setLink(\'disable\'); return false;"><img src="'.get_bloginfo('wpurl').'/wp-content/plugins/answerlinks/images/button_dontlink.gif" alt="Don\'t Link" /></a> |
|---|
| 675 |
</p> |
|---|
| 676 |
|
|---|
| 677 |
<p id="al_wizard_complete"> |
|---|
| 678 |
You\'re all done! Click OK below. |
|---|
| 679 |
</p> |
|---|
| 680 |
|
|---|
| 681 |
</div> |
|---|
| 682 |
|
|---|
| 683 |
<div id="answerlink_links"> |
|---|
| 684 |
<h2>Suggestions</h2> |
|---|
| 685 |
<ul> |
|---|
| 686 |
'); |
|---|
| 687 |
foreach ($links as $k => $v) { |
|---|
| 688 |
print(' |
|---|
| 689 |
<li> |
|---|
| 690 |
<input type="checkbox" name="answerlink_links" id="alcb_'.$v['id'].'" onclick="answerlink.toggleLink(this.id);" /> |
|---|
| 691 |
<label for="alcb_'.$v['id'].'" onclick="answerlink.toggleLink(this.getAttribute(\'for\'));">'.htmlspecialchars($v['phrase']).'</label> |
|---|
| 692 |
'); |
|---|
| 693 |
} |
|---|
| 694 |
print(' |
|---|
| 695 |
</ul> |
|---|
| 696 |
</div> |
|---|
| 697 |
|
|---|
| 698 |
</div> |
|---|
| 699 |
|
|---|
| 700 |
<p id="al_footer"> |
|---|
| 701 |
<input type="button" name="ok" value=" OK " onclick="answerlink.applyLinks();" /> |
|---|
| 702 |
<input type="button" name="cancel" value="Cancel" onclick="answerlink.cancel();" /> |
|---|
| 703 |
<a href="http://www.answers.com/main/wordpress_howto.jsp" onclick="window.open(this.href); return false;" class="about">About This Feature</a> |
|---|
| 704 |
<a href="http://www.answers.com/main/contact_us.jsp" onclick="window.open(this.href); return false;" class="contact">Contact Answers.com</a> |
|---|
| 705 |
</p> |
|---|
| 706 |
|
|---|
| 707 |
</div> |
|---|
| 708 |
|
|---|
| 709 |
'); |
|---|
| 710 |
} |
|---|
| 711 |
|
|---|
| 712 |
|
|---|
| 713 |
class XMLParser |
|---|
| 714 |
{ |
|---|
| 715 |
var $parser; |
|---|
| 716 |
var $filePath; |
|---|
| 717 |
var $document; |
|---|
| 718 |
var $currTag; |
|---|
| 719 |
var $tagStack; |
|---|
| 720 |
|
|---|
| 721 |
function XMLParser($path = '') |
|---|
| 722 |
{ |
|---|
| 723 |
$this->parser = xml_parser_create(); |
|---|
| 724 |
$this->filePath = $path; |
|---|
| 725 |
$this->document = array(); |
|---|
| 726 |
$this->currTag =& $this->document; |
|---|
| 727 |
$this->tagStack = array(); |
|---|
| 728 |
} |
|---|
| 729 |
|
|---|
| 730 |
function parse($data) |
|---|
| 731 |
|
|---|