PageRenderTime 34ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/digg-digg/include/dd-class.php

https://github.com/lloyddobbler/diggdigg
PHP | 2122 lines | 1457 code | 503 blank | 162 comment | 46 complexity | 2e42e73ef908bad58f1dcfb0c220ddcc MD5 | raw file
  1. <?php
  2. // XXX: NEW BUTTONS: Extend this base class. Set defaults as class properties
  3. class BaseDD {
  4. //String for replacement.
  5. const VOTE_URL = 'VOTE_URL';
  6. const VOTE_TITLE = 'VOTE_TITLE';
  7. const VOTE_IMAGE = 'VOTE_IMAGE';
  8. const VOTE_BUTTON_DESIGN = 'VOTE_BUTTON_DESIGN';
  9. const SCHEDULER_TIMER = 'SCHEDULER_TIMER';
  10. const POST_ID = 'POST_ID';
  11. const VOTE_BUTTON_DESIGN_LAZY_WIDTH = 'VOTE_BUTTON_DESIGN_LAZY_WIDTH';
  12. const VOTE_BUTTON_DESIGN_LAZY_HEIGHT = 'VOTE_BUTTON_DESIGN_LAZY_HEIGHT';
  13. //default value
  14. const DEFAULT_APPEND_TYPE = 'none';
  15. const DEFAULT_OPTION_AJAX = 'false';
  16. const DEFAULT_BUTTON_DESIGN = 'Normal';
  17. const DEFAULT_BUTTON_WEIGHT = '100';
  18. // define properties
  19. var $name; //name of the vote button
  20. var $websiteURL; //website URL
  21. var $apiURL; //Button API for development
  22. var $baseURL; // vote button URL, before construt
  23. var $baseURL_lazy; // vote button URL, before construt, lazy version
  24. var $baseURL_lazy_script; // jQuery script , lazy version
  25. var $scheduler_lazy_script; //scheduler function
  26. var $scheduler_lazy_timer; //miliseconds
  27. var $finalURL; //final URL for display, after constructs
  28. var $finalURL_lazy;//final lazy URL for display, after constructs
  29. var $finalURL_lazy_script;//final jQuery, after constructs
  30. var $final_scheduler_lazy_script; //final scheduler, after constructs
  31. var $isEncodeRequired = true; //is URL or title need encode?
  32. var $islazyLoadAvailable = true; //is lazy load avaliable?
  33. //contains DD option value, in array
  34. var $wp_options;
  35. var $option_append_type;
  36. var $option_button_design;
  37. var $option_button_weight;
  38. var $option_ajax_left_float;
  39. var $option_lazy_load;
  40. var $button_weight_value;
  41. //default float button design
  42. var $float_button_design = self::DEFAULT_BUTTON_DESIGN;
  43. //default button layout, suit in most cases
  44. var $buttonLayout = array(
  45. "Normal" => "Normal",
  46. "Compact" => "Compact"
  47. );
  48. // Default options
  49. var $append_type = 'none';
  50. var $button_design = 'Normal';
  51. var $ajax_left_float = false;
  52. var $lazy_load = false;
  53. public function getButtonDesign($button){
  54. return $this->buttonLayout[$button];
  55. }
  56. //default lazy button layout, suit in most cases
  57. var $buttonLayoutLazy = array(
  58. "Normal" => "Normal",
  59. "Compact" => "Compact"
  60. );
  61. public function getButtonDesignLazy($button){
  62. return $this->buttonLayoutLazy[$button];
  63. }
  64. var $buttonLayoutLazyWidth = array(
  65. "Normal" => "51",
  66. "Compact" => "120"
  67. );
  68. public function getButtonDesignLazyWidth($button){
  69. return $this->buttonLayoutLazyWidth[$button];
  70. }
  71. var $buttonLayoutLazyHeight = array(
  72. "Normal" => "69",
  73. "Compact" => "22"
  74. );
  75. public function getButtonDesignLazyHeight($button){
  76. return $this->buttonLayoutLazyHeight[$button];
  77. }
  78. function BaseDD($name, $websiteURL, $apiURL, $baseURL) {
  79. $this->name = $name;
  80. $this->websiteURL = $websiteURL;
  81. $this->apiURL = $apiURL;
  82. $this->baseURL = $baseURL;
  83. $this->initWPOptions();
  84. }
  85. private function initWPOptions() {
  86. $this->wp_options = array();
  87. // XXX: Set default options in the subclass
  88. $this->wp_options[$this->option_append_type] = $this->append_type;
  89. //$this->wp_options[$this->option_append_type] = self::DEFAULT_APPEND_TYPE;
  90. $this->wp_options[$this->option_button_design] = $this->button_design;
  91. //$this->wp_options[$this->option_button_design] = self::DEFAULT_BUTTON_DESIGN;
  92. $this->wp_options[$this->option_ajax_left_float] = $this->ajax_left_float;
  93. //$this->wp_options[$this->option_ajax_left_float] = self::DEFAULT_OPTION_AJAX;
  94. $this->wp_options[$this->option_lazy_load] = $this->lazy_load;
  95. //$this->wp_options[$this->option_lazy_load] = self::DEFAULT_OPTION_AJAX;
  96. $this->wp_options[$this->option_button_weight] = $this->button_weight_value;
  97. }
  98. public function getOptionLazyLoad(){
  99. return $this->wp_options[$this->option_lazy_load];
  100. }
  101. public function getOptionAjaxLeftFloat(){
  102. return $this->wp_options[$this->option_ajax_left_float];
  103. }
  104. public function getOptionButtonWeight(){
  105. return $this->wp_options[$this->option_button_weight];
  106. }
  107. public function getOptionAppendType(){
  108. return $this->wp_options[$this->option_append_type];
  109. }
  110. public function getOptionButtonDesign(){
  111. return $this->wp_options[$this->option_button_design];
  112. }
  113. //construct base URL, based on $lazy value
  114. public function constructURL($url, $title,$button, $postId, $lazy, $globalcfg = ''){
  115. //rawurlencode - replace space with %20
  116. //urlencode - replace space with +
  117. if($this->isEncodeRequired){
  118. $title = rawurlencode($title);
  119. $url = rawurlencode($url);
  120. }
  121. if($lazy==DD_EMPTY_VALUE || $lazy==false){
  122. $this->constructNormalURL($url, $title,$button, $postId);
  123. }else{
  124. $this->constructLazyLoadURL($url, $title,$button, $postId);
  125. }
  126. }
  127. public function constructNormalURL($url, $title,$button, $postId){
  128. $finalURL = $this->baseURL;
  129. $finalURL = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesign($button),$finalURL);
  130. $finalURL = str_replace(self::VOTE_TITLE,$title,$finalURL);
  131. $finalURL = str_replace(self::VOTE_URL,$url,$finalURL);
  132. $this->finalURL = $finalURL;
  133. }
  134. public function constructLazyLoadURL($url, $title,$button, $postId){
  135. $finalURL_lazy = $this->baseURL_lazy;
  136. $finalURL_lazy = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  137. $finalURL_lazy = str_replace(self::VOTE_TITLE,$title,$finalURL_lazy);
  138. $finalURL_lazy = str_replace(self::VOTE_URL,$url,$finalURL_lazy);
  139. $finalURL_lazy = str_replace(self::POST_ID,$postId,$finalURL_lazy);
  140. $this->finalURL_lazy = $finalURL_lazy;
  141. //lazy loading javascript
  142. $finalURL_lazy_script = $this->baseURL_lazy_script;
  143. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN_LAZY_WIDTH,$this->getButtonDesignLazyWidth($button),$finalURL_lazy_script);
  144. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN_LAZY_HEIGHT,$this->getButtonDesignLazyHeight($button),$finalURL_lazy_script);
  145. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy_script);
  146. $finalURL_lazy_script = str_replace(self::VOTE_TITLE,$title,$finalURL_lazy_script);
  147. $finalURL_lazy_script = str_replace(self::VOTE_URL,$url,$finalURL_lazy_script);
  148. $finalURL_lazy_script = str_replace(self::POST_ID,$postId,$finalURL_lazy_script);
  149. $this->finalURL_lazy_script = $finalURL_lazy_script;
  150. //scheduler to run the lazy loading
  151. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  152. $final_scheduler_lazy_script = str_replace(self::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  153. $final_scheduler_lazy_script = str_replace(self::POST_ID,$postId,$final_scheduler_lazy_script);
  154. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  155. }
  156. }
  157. //iframe class has different construct URL for normal and lazy load
  158. class BaseIFrameDD extends BaseDD{
  159. const EXTRA_VALUE = "EXTRA_VALUE";
  160. var $buttonLayoutWidthHeight = array(
  161. "Normal" => "height=\"69\" width=\"51\"",
  162. "Compact" => "height=\"22\" width=\"120\"",
  163. );
  164. public function getIframeWH($button){
  165. return $this->buttonLayoutWidthHeight[$button];
  166. }
  167. public function constructNormalURL($url, $title,$button, $postId){
  168. $finalURL = $this->baseURL;
  169. $finalURL = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesign($button),$finalURL);
  170. $finalURL = str_replace(parent::VOTE_TITLE,$title,$finalURL);
  171. $finalURL = str_replace(parent::VOTE_URL,$url,$finalURL);
  172. $finalURL = str_replace(parent::POST_ID,$postId,$finalURL);
  173. $finalURL = str_replace(self::EXTRA_VALUE,$this->getIframeWH($button),$finalURL);
  174. $this->finalURL = $finalURL;
  175. }
  176. public function constructLazyLoadURL($url, $title,$button, $postId){
  177. $finalURL_lazy = $this->baseURL_lazy;
  178. $finalURL_lazy = str_replace(self::POST_ID,$postId,$finalURL_lazy);
  179. $this->finalURL_lazy = $finalURL_lazy;
  180. $finalURL_lazy_script = $this->baseURL_lazy_script;
  181. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN_LAZY_WIDTH,$this->getButtonDesignLazyWidth($button),$finalURL_lazy_script);
  182. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN_LAZY_HEIGHT,$this->getButtonDesignLazyHeight($button),$finalURL_lazy_script);
  183. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy_script);
  184. $finalURL_lazy_script = str_replace(self::VOTE_TITLE,$title,$finalURL_lazy_script);
  185. $finalURL_lazy_script = str_replace(self::VOTE_URL,$url,$finalURL_lazy_script);
  186. $finalURL_lazy_script = str_replace(self::POST_ID,$postId,$finalURL_lazy_script);
  187. $this->finalURL_lazy_script = $finalURL_lazy_script;
  188. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  189. $final_scheduler_lazy_script = str_replace(self::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  190. $final_scheduler_lazy_script = str_replace(self::POST_ID,$postId,$final_scheduler_lazy_script);
  191. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  192. }
  193. }
  194. //warning : in baseURL or lazyURL, all text have to enclose by html tag, else it will display pure text in the_excerpt mode
  195. // DEFAULT BUTTONS (IN THEIR DEFAULT ORDER)
  196. // TODO: consider tidying this up by loading these classes from separate files
  197. /******************************************************************************************
  198. *
  199. * http://www.twitter.com
  200. * //data-counturl
  201. */
  202. class DD_Twitter extends BaseDD{
  203. var $append_type = 'left_float';
  204. var $button_design = 'Normal';
  205. var $ajax_left_float = 'on';
  206. var $lazy_load = false;
  207. const NAME = "Twitter";
  208. const URL_WEBSITE = "http://www.twitter.com";
  209. const URL_API = "http://twitter.com/goodies/tweetbutton";
  210. const DEFAULT_BUTTON_WEIGHT = "110";
  211. const BASEURL ="<a href=\"http://twitter.com/share\" class=\"twitter-share-button\" data-url=\"VOTE_URL\" data-count=\"VOTE_BUTTON_DESIGN\" data-text=\"VOTE_TITLE\" data-via=\"VOTE_SOURCE\" ></a><script type=\"text/javascript\" src=\"http://platform.twitter.com/widgets.js\"></script>";
  212. const OPTION_APPEND_TYPE = "dd_twitter_appendType";
  213. const OPTION_BUTTON_DESIGN = "dd_twitter_buttonDesign";
  214. const OPTION_BUTTON_WEIGHT = "dd_twitter_button_weight";
  215. const OPTION_AJAX_LEFT_FLOAT = "dd_twitter_ajax_left_float";
  216. const OPTION_LAZY_LOAD = "dd_twitter_lazy_load";
  217. const BASEURL_LAZY ="<div class='dd-twitter-ajax-load dd-twitter-POST_ID'></div><a href=\"http://twitter.com/share\" class=\"twitter-share-button\" data-url=\"VOTE_URL\" data-count=\"VOTE_BUTTON_DESIGN\" data-text=\"VOTE_TITLE\" data-via=\"VOTE_SOURCE\" ></a>";
  218. const BASEURL_LAZY_SCRIPT = " function loadTwitter_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-twitter-POST_ID').remove();\$.getScript('http://platform.twitter.com/widgets.js'); }); }";
  219. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadTwitter_POST_ID()',SCHEDULER_TIMER);";
  220. const SCHEDULER_LAZY_TIMER = "1000";
  221. var $buttonLayout = array(
  222. "Normal" => "vertical",
  223. "Compact" => "horizontal"
  224. );
  225. var $buttonLayoutLazy = array(
  226. "Normal" => "vertical",
  227. "Compact" => "horizontal"
  228. );
  229. var $isEncodeRequired = false;
  230. const VOTE_SOURCE = "VOTE_SOURCE";
  231. public function DD_Twitter() {
  232. $this->option_append_type = self::OPTION_APPEND_TYPE;
  233. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  234. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  235. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  236. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  237. $this->baseURL_lazy = self::BASEURL_LAZY;
  238. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  239. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  240. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  241. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  242. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  243. }
  244. public function constructURL($url, $title,$button, $postId, $lazy, $globalcfg = ''){
  245. if($this->isEncodeRequired){
  246. $title = rawurlencode($title);
  247. $url = rawurlencode($url);
  248. }
  249. $twitter_source = '';
  250. if($globalcfg!=''){
  251. $twitter_source = $globalcfg[DD_GLOBAL_TWITTER_OPTION][DD_GLOBAL_TWITTER_OPTION_SOURCE];
  252. }
  253. if($lazy==DD_EMPTY_VALUE){
  254. //format twitter source
  255. $this->baseURL = str_replace(self::VOTE_SOURCE,$twitter_source,$this->baseURL);
  256. $this->constructNormalURL($url, $title,$button, $postId);
  257. }else{
  258. //format twitter source
  259. $this->baseURL_lazy = str_replace(self::VOTE_SOURCE,$twitter_source,$this->baseURL_lazy);
  260. $this->constructLazyLoadURL($url, $title,$button, $postId);
  261. }
  262. }
  263. public function constructLazyLoadURL($url, $title,$button, $postId){
  264. $finalURL_lazy = $this->baseURL_lazy;
  265. $finalURL_lazy = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  266. $finalURL_lazy = str_replace(parent::VOTE_TITLE,$title,$finalURL_lazy);
  267. $finalURL_lazy = str_replace(parent::VOTE_URL,$url,$finalURL_lazy);
  268. $finalURL_lazy = str_replace(parent::POST_ID,$postId,$finalURL_lazy);
  269. $this->finalURL_lazy = $finalURL_lazy;
  270. $finalURL_lazy_script = $this->baseURL_lazy_script;
  271. $finalURL_lazy_script = str_replace(parent::POST_ID,$postId,$finalURL_lazy_script);
  272. $this->finalURL_lazy_script = $finalURL_lazy_script;
  273. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  274. $final_scheduler_lazy_script = str_replace(parent::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  275. $final_scheduler_lazy_script = str_replace(parent::POST_ID,$postId,$final_scheduler_lazy_script);
  276. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  277. }
  278. }
  279. /******************************************************************************************
  280. * Buffer Button
  281. * http://bufferapp.com/goodies/button
  282. *
  283. */
  284. class DD_Buffer extends BaseDD{
  285. var $append_type = 'after_content';
  286. var $button_design = 'Normal';
  287. var $ajax_left_float = 'on';
  288. var $lazy_load = false;
  289. const NAME = "Buffer";
  290. const URL_WEBSITE = "http://bufferapp.com/";
  291. const URL_API = "http://bufferapp.com/goodies/button/";
  292. const DEFAULT_BUTTON_WEIGHT = "99";
  293. var $isEncodeRequired = false;
  294. const BASEURL = '<a href="http://bufferapp.com/add" class="buffer-add-button" data-count="VOTE_BUTTON_DESIGN" data-url="VOTE_URL" data-via="VOTE_BUFFER_SOURCE"></a><script type="text/javascript" src="http://static.bufferapp.com/js/button.js"></script>';
  295. const BASEURL_LAZY = '<a href="http://bufferapp.com/add" class="buffer-add-button" data-count="VOTE_BUTTON_DESIGN" data-url="VOTE_URL" data-via="VOTE_BUFFER_SOURCE"></a>';
  296. const BASEURL_LAZY_SCRIPT = "function loadBuffer_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-buffer-POST_ID').remove();\$.getScript('http://static.bufferapp.com/js/button.js'); }); }";
  297. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadBuffer_POST_ID()',SCHEDULER_TIMER);";
  298. const SCHEDULER_LAZY_TIMER = "1000";
  299. const OPTION_APPEND_TYPE = "dd_buffer_appendType";
  300. const OPTION_BUTTON_DESIGN = "dd_buffer_buttonDesign";
  301. const OPTION_BUTTON_WEIGHT = "dd_buffer_button_weight";
  302. const OPTION_AJAX_LEFT_FLOAT = "dd_buffer_ajax_left_float";
  303. const OPTION_LAZY_LOAD = "dd_buffer_lazy_load";
  304. const VOTE_BUFFER_SOURCE = "VOTE_BUFFER_SOURCE";
  305. var $buttonLayout = array(
  306. "Normal" => "vertical",
  307. "Compact" => "horizontal",
  308. "No Count" => "none"
  309. );
  310. var $buttonLayoutLazy = array(
  311. "Normal" => "vertical",
  312. "Compact" => "horizontal",
  313. "No Count" => "none"
  314. );
  315. // XXX: Old-style constructor
  316. public function DD_Buffer() {
  317. $this->option_append_type = self::OPTION_APPEND_TYPE;
  318. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  319. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  320. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  321. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  322. $this->baseURL_lazy = self::BASEURL_LAZY;
  323. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  324. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  325. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  326. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  327. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  328. }
  329. public function constructURL($url, $title, $button, $postId, $lazy, $globalcfg = ''){
  330. if($this->isEncodeRequired){
  331. $title = rawurlencode($title);
  332. $url = rawurlencode($url);
  333. }
  334. $buffer_source = '';
  335. if($globalcfg!=''){
  336. $buffer_source = $globalcfg[DD_GLOBAL_BUFFER_OPTION][DD_GLOBAL_BUFFER_OPTION_SOURCE];
  337. }
  338. if($lazy==DD_EMPTY_VALUE || $lazy==false){
  339. //format twitter source
  340. $this->baseURL = str_replace(self::VOTE_BUFFER_SOURCE,$buffer_source,$this->baseURL);
  341. $this->constructNormalURL($url, $title,$button, $postId);
  342. }else{
  343. //format twitter source
  344. $this->baseURL_lazy = str_replace(self::VOTE_BUFFER_SOURCE,$buffer_source,$this->baseURL_lazy);
  345. $this->constructLazyLoadURL($url, $title,$button, $postId);
  346. }
  347. }
  348. public function constructNormalURL($url, $title, $button, $postId){
  349. $finalURL = $this->baseURL;
  350. $finalURL = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesign($button),$finalURL);
  351. $finalURL = str_replace(self::VOTE_TITLE,$title,$finalURL);
  352. $finalURL = str_replace(self::VOTE_URL,$url,$finalURL);
  353. $finalURL = str_replace(parent::POST_ID,$postId,$finalURL);
  354. $this->finalURL = $finalURL;
  355. }
  356. public function constructLazyLoadURL($url, $title,$button, $postId){
  357. $finalURL_lazy = $this->baseURL_lazy;
  358. $finalURL_lazy = str_replace(parent::VOTE_URL,$url,$finalURL_lazy);
  359. $finalURL_lazy = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  360. $finalURL_lazy = str_replace(parent::POST_ID,$postId,$finalURL_lazy);
  361. $this->finalURL_lazy = $finalURL_lazy;
  362. $finalURL_lazy_script = $this->baseURL_lazy_script;
  363. $finalURL_lazy_script = str_replace(parent::POST_ID,$postId,$finalURL_lazy_script);
  364. $this->finalURL_lazy_script = $finalURL_lazy_script;
  365. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  366. $final_scheduler_lazy_script = str_replace(parent::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  367. $final_scheduler_lazy_script = str_replace(parent::POST_ID,$postId,$final_scheduler_lazy_script);
  368. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  369. }
  370. }
  371. /******************************************************************************************
  372. *
  373. * Facebook Like (XFBML)
  374. * https://developers.facebook.com/tools/lint/
  375. *
  376. */
  377. class DD_FbLike_XFBML extends BaseDD{
  378. var $append_type = 'left_float';
  379. var $button_design = 'Like Button Count';
  380. var $ajax_left_float = 'on';
  381. var $lazy_load = false;
  382. const NAME = "Facebook Like (XFBML)";
  383. const URL_WEBSITE = "http://www.facebook.com";
  384. const URL_API = "http://developers.facebook.com/docs/reference/plugins/like";
  385. const BASEURL = "<script src=\"http://connect.facebook.net/FACEBOOK_LOCALE/all.js#xfbml=1\"></script><fb:like href=\"VOTE_URL\" FACEBOOK_SEND FACEBOOK_SHOW_FACE VOTE_BUTTON_DESIGN ></fb:like>";
  386. const FB_LOCALES = "http://www.facebook.com/translations/FacebookLocales.xml";
  387. const DEFAULT_BUTTON_WEIGHT = "96";
  388. const OPTION_APPEND_TYPE = "dd_fblike_xfbml_appendType";
  389. const OPTION_BUTTON_DESIGN = "dd_fblike_xfbml_buttonDesign";
  390. const OPTION_BUTTON_WEIGHT = "dd_fblike_xfbml_button_weight";
  391. const OPTION_AJAX_LEFT_FLOAT = "dd_fblike_xfbml_ajax_left_float";
  392. const OPTION_LAZY_LOAD = "dd_fblike_xfbml_lazy_load";
  393. const LIKE_STANDARD = " width=\"450\" ";
  394. const LIKE_BUTTON_COUNT= " layout=\"button_count\" width=\"92\" ";
  395. const LIKE_BOX_COUNT= " layout=\"box_count\" width=\"50\" ";
  396. const RECOMMEND_STANDARD = " action=\"recommend\" width=\"400\" ";
  397. const RECOMMEND_BUTTON_COUNT= " action=\"recommend\" layout=\"button_count\" width=\"130\" ";
  398. const RECOMMEND_BOX_COUNT= " action=\"recommend\" layout=\"box_count\" width=\"90\" ";
  399. const FACEBOOK_SEND = "FACEBOOK_SEND"; //send=\"true\"
  400. const FACEBOOK_SHOW_FACE = "FACEBOOK_SHOW_FACE"; //show_faces=\"true\"
  401. const FACEBOOK_LOCALE = "FACEBOOK_LOCALE";
  402. var $islazyLoadAvailable = false;
  403. var $float_button_design = "Like Box Count";
  404. var $buttonLayout = array(
  405. "Like Standard" => self::LIKE_STANDARD,
  406. "Like Button Count" => self::LIKE_BUTTON_COUNT,
  407. "Like Box Count" => self::LIKE_BOX_COUNT,
  408. "Recommend Standard" => self::RECOMMEND_STANDARD,
  409. "Recommend Button Count" => self::RECOMMEND_BUTTON_COUNT,
  410. "Recommend Box Count" => self::RECOMMEND_BOX_COUNT
  411. );
  412. public function DD_FbLike_XFBML() {
  413. $this->option_append_type = self::OPTION_APPEND_TYPE;
  414. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  415. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  416. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  417. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  418. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  419. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  420. }
  421. public function constructURL($url, $title,$button, $postId, $lazy, $globalcfg = ''){
  422. if($this->isEncodeRequired){
  423. $title = rawurlencode($title);
  424. $url = rawurlencode($url);
  425. }
  426. $fb_locale = '';
  427. $fb_send = '';
  428. $fb_face = '';
  429. $fb_send_value = '';
  430. $fb_face_value = '';
  431. if($globalcfg!=''){
  432. $fb_locale = $globalcfg[DD_GLOBAL_FACEBOOK_OPTION][DD_GLOBAL_FACEBOOK_OPTION_LOCALE];
  433. $fb_send = $globalcfg[DD_GLOBAL_FACEBOOK_OPTION][DD_GLOBAL_FACEBOOK_OPTION_SEND];
  434. $fb_face = $globalcfg[DD_GLOBAL_FACEBOOK_OPTION][DD_GLOBAL_FACEBOOK_OPTION_FACE];
  435. if($fb_send == DD_DISPLAY_ON){
  436. $fb_send_value = "send=\"true\"";
  437. }else{
  438. $fb_send_value = "send=\"false\"";
  439. }
  440. if($fb_face == DD_DISPLAY_ON){
  441. $fb_face_value = "show_faces=\"true\"";
  442. }else{
  443. $fb_face_value = "show_faces=\"false\"";
  444. }
  445. }
  446. //show face and send button
  447. $this->baseURL = str_replace(self::FACEBOOK_LOCALE,$fb_locale,$this->baseURL);
  448. $this->baseURL = str_replace(self::FACEBOOK_SEND,$fb_send_value,$this->baseURL);
  449. $this->baseURL = str_replace(self::FACEBOOK_SHOW_FACE,$fb_face_value,$this->baseURL);
  450. $this->constructNormalURL($url, $title,$button, $postId);
  451. }
  452. }
  453. /******************************************************************************************
  454. *
  455. * http://www.google.com/+1/button/
  456. * http://www.google.com/webmasters/+1/button/
  457. *
  458. */
  459. class DD_Google1 extends BaseDD{
  460. var $append_type = 'left_float';
  461. var $button_design = 'Normal';
  462. var $ajax_left_float = 'on';
  463. var $lazy_load = false;
  464. const NAME = "Google +1";
  465. const URL_WEBSITE = "http://www.google.com/+1/button/";
  466. const URL_API = "http://code.google.com/apis/+1button/";
  467. const DEFAULT_BUTTON_WEIGHT = "95";
  468. var $isEncodeRequired = false;
  469. const BASEURL = "<script type='text/javascript' src='https://apis.google.com/js/plusone.js'></script><g:plusone size='VOTE_BUTTON_DESIGN' href='VOTE_URL'></g:plusone>";
  470. const BASEURL_LAZY = "<div class='dd-google1-ajax-load dd-google1-POST_ID'></div><g:plusone size='VOTE_BUTTON_DESIGN' href='VOTE_URL'></g:plusone>";
  471. const BASEURL_LAZY_SCRIPT = " function loadGoogle1_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-google1-POST_ID').remove();\$.getScript('https://apis.google.com/js/plusone.js'); }); }";
  472. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadGoogle1_POST_ID()',SCHEDULER_TIMER);";
  473. const SCHEDULER_LAZY_TIMER = "1000";
  474. const OPTION_APPEND_TYPE = "dd_google1_appendType";
  475. const OPTION_BUTTON_DESIGN = "dd_google1_buttonDesign";
  476. const OPTION_BUTTON_WEIGHT = "dd_google1_button_weight";
  477. const OPTION_AJAX_LEFT_FLOAT = "dd_google1_ajax_left_float";
  478. const OPTION_LAZY_LOAD = "dd_google1_lazy_load";
  479. var $buttonLayout = array(
  480. "Normal" => "tall",
  481. "Compact (15px)" => "small",
  482. "Compact (20px)" => "medium",
  483. "Compact (24px)" => "none"
  484. );
  485. var $buttonLayoutLazy = array(
  486. "Normal" => "tall",
  487. "Compact (15px)" => "small",
  488. "Compact (20px)" => "medium",
  489. "Compact (24px)" => "none"
  490. );
  491. public function DD_Google1() {
  492. $this->option_append_type = self::OPTION_APPEND_TYPE;
  493. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  494. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  495. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  496. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  497. $this->baseURL_lazy = self::BASEURL_LAZY;
  498. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  499. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  500. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  501. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  502. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  503. }
  504. public function constructLazyLoadURL($url, $title,$button, $postId){
  505. $finalURL_lazy = $this->baseURL_lazy;
  506. $finalURL_lazy = str_replace(parent::VOTE_URL,$url,$finalURL_lazy);
  507. $finalURL_lazy = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  508. $finalURL_lazy = str_replace(parent::POST_ID,$postId,$finalURL_lazy);
  509. $this->finalURL_lazy = $finalURL_lazy;
  510. $finalURL_lazy_script = $this->baseURL_lazy_script;
  511. $finalURL_lazy_script = str_replace(parent::POST_ID,$postId,$finalURL_lazy_script);
  512. $this->finalURL_lazy_script = $finalURL_lazy_script;
  513. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  514. $final_scheduler_lazy_script = str_replace(parent::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  515. $final_scheduler_lazy_script = str_replace(parent::POST_ID,$postId,$final_scheduler_lazy_script);
  516. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  517. }
  518. }
  519. /******************************************************************************************
  520. *
  521. * http://www.linkedin.com
  522. *
  523. */
  524. class DD_Linkedin extends BaseDD{
  525. var $append_type = 'left_float';
  526. var $button_design = 'Normal';
  527. var $ajax_left_float = 'on';
  528. var $lazy_load = false;
  529. const NAME = "Linkedin";
  530. const URL_WEBSITE = "http://www.linkedin.com";
  531. const URL_API = "http://www.linkedin.com/publishers";
  532. const DEFAULT_BUTTON_WEIGHT = "94";
  533. const BASEURL = "<script src='//platform.linkedin.com/in.js' type='text/javascript'></script><script type='IN/Share' date-url='VOTE_URL' data-counter='VOTE_BUTTON_DESIGN'></script>";
  534. const BASEURL_LAZY = "<div class='dd-linkedin-ajax-load dd-linkedin-POST_ID'></div><script type='IN/share' data-url='VOTE_URL' data-counter='VOTE_BUTTON_DESIGN'></script>";
  535. const BASEURL_LAZY_SCRIPT = " function loadLinkedin_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-linkedin-POST_ID').remove();\$.getScript('http://platform.linkedin.com/in.js'); }); }";
  536. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadLinkedin_POST_ID()',SCHEDULER_TIMER);";
  537. const SCHEDULER_LAZY_TIMER = "1000";
  538. const OPTION_APPEND_TYPE = "dd_linkedin_appendType";
  539. const OPTION_BUTTON_DESIGN = "dd_linkedin_buttonDesign";
  540. const OPTION_BUTTON_WEIGHT = "dd_linkedin_button_weight";
  541. const OPTION_AJAX_LEFT_FLOAT = "dd_linkedin_ajax_left_float";
  542. const OPTION_LAZY_LOAD = "dd_linkedin_lazy_load";
  543. var $buttonLayout = array(
  544. "Normal" => "top",
  545. "Compact" => "right",
  546. "NoCount" => "none"
  547. );
  548. var $buttonLayoutLazy = array(
  549. "Normal" => "top",
  550. "Compact" => "right",
  551. "NoCount" => "none"
  552. );
  553. var $isEncodeRequired = false;
  554. public function DD_Linkedin() {
  555. $this->option_append_type = self::OPTION_APPEND_TYPE;
  556. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  557. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  558. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  559. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  560. $this->baseURL_lazy = self::BASEURL_LAZY;
  561. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  562. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  563. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  564. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  565. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  566. }
  567. public function constructLazyLoadURL($url, $title,$button, $postId){
  568. $finalURL_lazy = $this->baseURL_lazy;
  569. $finalURL_lazy = str_replace(self::VOTE_URL,$url,$finalURL_lazy);
  570. $finalURL_lazy = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  571. $finalURL_lazy = str_replace(self::POST_ID,$postId,$finalURL_lazy);
  572. $this->finalURL_lazy = $finalURL_lazy;
  573. $finalURL_lazy_script = $this->baseURL_lazy_script;
  574. $finalURL_lazy_script = str_replace(self::POST_ID,$postId,$finalURL_lazy_script);
  575. $this->finalURL_lazy_script = $finalURL_lazy_script;
  576. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  577. $final_scheduler_lazy_script = str_replace(self::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  578. $final_scheduler_lazy_script = str_replace(self::POST_ID,$postId,$final_scheduler_lazy_script);
  579. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  580. }
  581. }
  582. // NON-DEFAULTS
  583. /******************************************************************************************
  584. *
  585. * Pinterest
  586. * http://pinterest.com/about/goodies/#button_for_websites
  587. *
  588. */
  589. class DD_Pinterest extends BaseDD{
  590. const NAME = "Pinterest";
  591. const URL_WEBSITE = "http://pinterest.com";
  592. const URL_API = "http://pinterest.com/about/goodies/#button_for_websites";
  593. const DEFAULT_BUTTON_WEIGHT = "10";
  594. const BASEURL = '<a href="http://pinterest.com/pin/create/button/?url=VOTE_URL&description=VOTE_TITLE&media=VOTE_IMAGE" class="pin-it-button" count-layout="VOTE_BUTTON_DESIGN"></a><script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>';
  595. const BASEURL_LAZY = '<a href="http://pinterest.com/pin/create/button/?url=VOTE_URL&description=VOTE_TITLE&media=VOTE_IMAGE" class="pin-it-button dd-pinterest-ajax-load dd-pinterest-POST_ID" count-layout="VOTE_BUTTON_DESIGN"></a>';
  596. const BASEURL_LAZY_SCRIPT = "function loadPinterest_POST_ID(){ jQuery(document).ready(function(\$) { \$.getScript('http://assets.pinterest.com/js/pinit.js'); }); }";
  597. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadPinterest_POST_ID()',SCHEDULER_TIMER);";
  598. const SCHEDULER_LAZY_TIMER = "1000";
  599. const OPTION_APPEND_TYPE = "dd_pinterest_appendType";
  600. const OPTION_BUTTON_DESIGN = "dd_pinterest_buttonDesign";
  601. const OPTION_BUTTON_WEIGHT = "dd_pinterest_button_weight";
  602. const OPTION_AJAX_LEFT_FLOAT = "dd_pinterest_ajax_left_float";
  603. const OPTION_LAZY_LOAD = "dd_pinterest_lazy_load";
  604. var $buttonLayout = array(
  605. "Normal" => "vertical",
  606. "Compact" => "horizontal",
  607. "No Count" => "none"
  608. );
  609. var $buttonLayoutLazy = array(
  610. "Normal" => "vertical",
  611. "Compact" => "horizontal",
  612. "No Count" => "none"
  613. );
  614. public function DD_Pinterest() {
  615. $this->option_append_type = self::OPTION_APPEND_TYPE;
  616. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  617. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  618. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  619. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  620. $this->baseURL_lazy = self::BASEURL_LAZY;
  621. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  622. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  623. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  624. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  625. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  626. }
  627. //construct base URL, based on $lazy value
  628. public function constructURL($url, $title, $button, $postId, $lazy, $globalcfg = ''){
  629. //rawurlencode - replace space with %20
  630. //urlencode - replace space with +
  631. if($this->isEncodeRequired) {
  632. $title = rawurlencode($title);
  633. $url = rawurlencode($url);
  634. }
  635. if($lazy==DD_EMPTY_VALUE || $lazy==false){
  636. $this->constructNormalURL($url, $title,$button, $postId);
  637. }else{
  638. $this->constructLazyLoadURL($url, $title,$button, $postId);
  639. }
  640. }
  641. public function constructNormalURL($url, $title,$button, $postId){
  642. $finalURL = $this->baseURL;
  643. $finalURL = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesign($button),$finalURL);
  644. $finalURL = str_replace(self::VOTE_TITLE,$title,$finalURL);
  645. $finalURL = str_replace(self::VOTE_URL,$url,$finalURL);
  646. $finalURL = str_replace(parent::POST_ID,$postId,$finalURL);
  647. $finalURL = str_replace(parent::VOTE_TITLE,$title,$finalURL);
  648. $finalURL = str_replace(parent::VOTE_URL,$url,$finalURL);
  649. // If theme uses post thumbnails, grab the chosen thumbnail if not grab the first image attached to post
  650. if(current_theme_supports('post-thumbnails')){
  651. $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($postId), 'full');
  652. } else {
  653. $image_args = array(
  654. 'order' => 'ASC',
  655. 'orderby' => 'menu_order',
  656. 'post_type' => 'attachment',
  657. 'post_parent' => $postId,
  658. 'post_mime_type' => 'image',
  659. 'post_status' => null,
  660. 'numberposts' => -1,
  661. );
  662. $attachments = get_posts($image_args);
  663. if ($attachments) {
  664. $thumb = wp_get_attachment_image_src($attachments[0]->ID, 'full');
  665. }
  666. }
  667. if($thumb){
  668. $image = $thumb[0];
  669. } else {
  670. $image = '';
  671. }
  672. $finalURL = str_replace(parent::VOTE_IMAGE,$image,$finalURL);
  673. $this->finalURL = $finalURL;
  674. }
  675. public function constructLazyLoadURL($url, $title,$button, $postId){
  676. $finalURL_lazy = $this->baseURL_lazy;
  677. $finalURL_lazy = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  678. $finalURL_lazy = str_replace(parent::POST_ID,$postId,$finalURL_lazy);
  679. $finalURL_lazy = str_replace(parent::VOTE_TITLE,$title,$finalURL_lazy);
  680. $finalURL_lazy = str_replace(parent::VOTE_URL,$url,$finalURL_lazy);
  681. if(current_theme_supports('post-thumbnails')) $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($postId), 'full' );
  682. else $thumb = false;
  683. if($thumb) $image = $thumb[0];
  684. else $image = '';
  685. $finalURL_lazy = str_replace(parent::VOTE_IMAGE,$image,$finalURL_lazy);
  686. $this->finalURL_lazy = $finalURL_lazy;
  687. $finalURL_lazy_script = $this->baseURL_lazy_script;
  688. $finalURL_lazy_script = str_replace(parent::VOTE_TITLE,$title,$finalURL_lazy_script);
  689. $finalURL_lazy_script = str_replace(parent::VOTE_URL,$url,$finalURL_lazy_script);
  690. $finalURL_lazy_script = str_replace(parent::POST_ID,$postId,$finalURL_lazy_script);
  691. $this->finalURL_lazy_script = $finalURL_lazy_script;
  692. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  693. $final_scheduler_lazy_script = str_replace(parent::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  694. $final_scheduler_lazy_script = str_replace(parent::POST_ID,$postId,$final_scheduler_lazy_script);
  695. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  696. }
  697. }
  698. /******************************************************************************************
  699. *
  700. * Flattr
  701. * http://developers.flattr.net/button/
  702. *
  703. */
  704. class DD_Flattr extends BaseDD{
  705. const NAME = "Flattr";
  706. const URL_WEBSITE = "http://flattr.com";
  707. const URL_API = "http://developers.flattr.net/button/";
  708. const DEFAULT_BUTTON_WEIGHT = "10";
  709. const BASEURL = '<script src="http://api.flattr.com/js/0.6/load.js?mode=auto"></script><a class="FlattrButton" href="VOTE_URL" style="display:none;" title="VOTE_TITLE" data-flattr-uid="VOTE_FLATTR_UID" data-flattr-button="VOTE_BUTTON_DESIGN" data-flattr-category="text"></a>';
  710. const BASEURL_LAZY = '<a class="FlattrButton" href="VOTE_URL" style="display:none;" title="VOTE_TITLE" data-flattr-uid="VOTE_FLATTR_UID" data-flattr-button="VOTE_BUTTON_DESIGN" data-flattr-category="text"></a>';
  711. const BASEURL_LAZY_SCRIPT = "function loadFlattr_POST_ID(){ jQuery(document).ready(function(\$) { \$.getScript('http://api.flattr.com/js/0.6/load.js?mode=auto'); }); }";
  712. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadFlattr_POST_ID()',SCHEDULER_TIMER);";
  713. const SCHEDULER_LAZY_TIMER = "1000";
  714. const OPTION_APPEND_TYPE = "dd_flattr_appendType";
  715. const OPTION_BUTTON_DESIGN = "dd_flattr_buttonDesign";
  716. const OPTION_BUTTON_WEIGHT = "dd_flattr_button_weight";
  717. const OPTION_AJAX_LEFT_FLOAT = "dd_flattr_ajax_left_float";
  718. const OPTION_LAZY_LOAD = "dd_flattr_lazy_load";
  719. var $buttonLayout = array(
  720. "Normal" => "default",
  721. "Compact" => "compact"
  722. );
  723. var $buttonLayoutLazy = array(
  724. "Normal" => "default",
  725. "Compact" => "compact"
  726. );
  727. const VOTE_FLATTR_UID = 'VOTE_FLATTR_UID';
  728. public function DD_Flattr() {
  729. $this->option_append_type = self::OPTION_APPEND_TYPE;
  730. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  731. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  732. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  733. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  734. $this->baseURL = self::BASEURL;
  735. $this->baseURL_lazy = self::BASEURL_LAZY;
  736. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  737. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  738. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  739. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  740. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  741. }
  742. //construct base URL, based on $lazy value
  743. public function constructURL($url, $title, $button, $postId, $lazy, $globalcfg = ''){
  744. $flattr_uid = 'flattr';
  745. if($globalcfg!=''){
  746. $flattr_uid = $globalcfg[DD_GLOBAL_FLATTR_OPTION][DD_GLOBAL_FLATTR_OPTION_UID];
  747. if(empty($flattr_uid)) $flattr_uid = 'flattr';
  748. }
  749. if($lazy==DD_EMPTY_VALUE || $lazy==false){
  750. $this->baseURL = str_replace(self::VOTE_FLATTR_UID, $flattr_uid, $this->baseURL);
  751. $this->constructNormalURL($url, $title, $button, $postId);
  752. }else{
  753. $this->baseURL_lazy = str_replace(self::VOTE_FLATTR_UID, $flattr_uid, $this->baseURL_lazy);
  754. $this->constructLazyLoadURL($url, $title, $button, $postId);
  755. }
  756. }
  757. public function constructNormalURL($url, $title, $button, $postId){
  758. $finalURL = $this->baseURL;
  759. $finalURL = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesign($button),$finalURL);
  760. $finalURL = str_replace(self::VOTE_TITLE,$title,$finalURL);
  761. $finalURL = str_replace(self::VOTE_URL,$url,$finalURL);
  762. $finalURL = str_replace(parent::POST_ID,$postId,$finalURL);
  763. $this->finalURL = $finalURL;
  764. }
  765. public function constructLazyLoadURL($url, $title, $button, $postId){
  766. $finalURL_lazy = $this->baseURL_lazy;
  767. $finalURL_lazy = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  768. $finalURL_lazy = str_replace(parent::VOTE_TITLE,$title,$finalURL_lazy);
  769. $finalURL_lazy = str_replace(parent::VOTE_URL,$url,$finalURL_lazy);
  770. $finalURL_lazy = str_replace(parent::POST_ID,$postId,$finalURL_lazy);
  771. $this->finalURL_lazy = $finalURL_lazy;
  772. $finalURL_lazy_script = $this->baseURL_lazy_script;
  773. $finalURL_lazy_script = str_replace(parent::POST_ID,$postId,$finalURL_lazy_script);
  774. $this->finalURL_lazy_script = $finalURL_lazy_script;
  775. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  776. $final_scheduler_lazy_script = str_replace(parent::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  777. $final_scheduler_lazy_script = str_replace(parent::POST_ID,$postId,$final_scheduler_lazy_script);
  778. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  779. }
  780. }
  781. /******************************************************************************************
  782. *
  783. * Facebook Like (IFrame)
  784. *
  785. */
  786. class DD_FbLike extends BaseIFrameDD{
  787. const NAME = "Facebook Like (IFrame)";
  788. const URL_WEBSITE = "http://www.facebook.com";
  789. const URL_API = "http://developers.facebook.com/docs/reference/plugins/like";
  790. const BASEURL = "<iframe src='http://www.facebook.com/plugins/like.php?href=VOTE_URL&amp;locale=FACEBOOK_LOCALE&amp;VOTE_BUTTON_DESIGN' scrolling='no' frameborder='0' style='border:none; overflow:hidden; EXTRA_VALUE' allowTransparency='true'></iframe>";
  791. const FB_LOCALES = "http://www.facebook.com/translations/FacebookLocales.xml";
  792. const DEFAULT_BUTTON_WEIGHT = "96";
  793. const OPTION_APPEND_TYPE = "dd_fblike_appendType";
  794. const OPTION_BUTTON_DESIGN = "dd_fblike_buttonDesign";
  795. const OPTION_BUTTON_WEIGHT = "dd_fblike_button_weight";
  796. const OPTION_AJAX_LEFT_FLOAT = "dd_fblike_ajax_left_float";
  797. const OPTION_LAZY_LOAD = "dd_fblike_lazy_load";
  798. const BASEURL_LAZY = "<div class='dd-fblike-ajax-load dd-fblike-POST_ID'></div><iframe class=\"DD_FBLIKE_AJAX_POST_ID\" src='' height='0' width='0' scrolling='no' frameborder='0' allowTransparency='true'></iframe>";
  799. const BASEURL_LAZY_SCRIPT = " function loadFBLike_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-fblike-POST_ID').remove();\$('.DD_FBLIKE_AJAX_POST_ID').attr('width','VOTE_BUTTON_DESIGN_LAZY_WIDTH');\$('.DD_FBLIKE_AJAX_POST_ID').attr('height','VOTE_BUTTON_DESIGN_LAZY_HEIGHT');\$('.DD_FBLIKE_AJAX_POST_ID').attr('src','http://www.facebook.com/plugins/like.php?href=VOTE_URL&amp;locale=FACEBOOK_LOCALE&amp;VOTE_BUTTON_DESIGN'); }); }";
  800. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadFBLike_POST_ID()',SCHEDULER_TIMER);";
  801. const SCHEDULER_LAZY_TIMER = "1000";
  802. const LIKE_STANDARD = "layout=standard&amp;action=like&amp;width=350&amp;height=24&amp;colorscheme=light"; //350x24
  803. const LIKE_BUTTON_COUNT= "layout=button_count&amp;action=like&amp;width=92&amp;height=20&amp;colorscheme=light"; //92x20
  804. const LIKE_BOX_COUNT= "layout=box_count&amp;action=like&amp;width=50&amp;height=60&amp;colorscheme=light"; //50x60
  805. const RECOMMEND_STANDARD = "layout=standard&amp;action=recommend&amp;width=400&amp;height=24&amp;colorscheme=light"; //400x24
  806. const RECOMMEND_BUTTON_COUNT= "layout=button_count&amp;action=recommend&amp;width=130&amp;height=20&amp;colorscheme=light"; //130x20
  807. const RECOMMEND_BOX_COUNT= "layout=box_count&amp;action=recommend&amp;width=90&amp;height=60&amp;colorscheme=light"; //90x60
  808. const EXTRA_VALUE = "EXTRA_VALUE";
  809. const FACEBOOK_LOCALE = "FACEBOOK_LOCALE";
  810. var $float_button_design = "Like Box Count";
  811. var $buttonLayout = array(
  812. "Like Standard" => self::LIKE_STANDARD,
  813. "Like Button Count" => self::LIKE_BUTTON_COUNT,
  814. "Like Box Count" => self::LIKE_BOX_COUNT,
  815. "Recommend Standard" => self::RECOMMEND_STANDARD,
  816. "Recommend Button Count" => self::RECOMMEND_BUTTON_COUNT,
  817. "Recommend Box Count" => self::RECOMMEND_BOX_COUNT
  818. );
  819. var $buttonLayoutLazy = array(
  820. "Like Standard" => self::LIKE_STANDARD,
  821. "Like Button Count" => self::LIKE_BUTTON_COUNT,
  822. "Like Box Count" => self::LIKE_BOX_COUNT,
  823. "Recommend Standard" => self::RECOMMEND_STANDARD,
  824. "Recommend Button Count" => self::RECOMMEND_BUTTON_COUNT,
  825. "Recommend Box Count" => self::RECOMMEND_BOX_COUNT
  826. );
  827. var $buttonLayoutWidthHeight = array(
  828. "Like Standard" => "width:500px; height:24px;",
  829. "Like Button Count" => "width:92px; height:20px;",
  830. "Like Box Count" => "width:50px; height:62px;",
  831. "Recommend Standard" => "width:500px; height:24px;",
  832. "Recommend Button Count" => "width:130px; height:20px;",
  833. "Recommend Box Count" => "width:90px; height:60px;"
  834. );
  835. var $buttonLayoutLazyWidth = array(
  836. "Like Standard" => "500",
  837. "Like Button Count" => "92",
  838. "Like Box Count" => "50",
  839. "Recommend Standard" => "500",
  840. "Recommend Button Count" => "130",
  841. "Recommend Box Count" => "90"
  842. );
  843. var $buttonLayoutLazyHeight = array(
  844. "Like Standard" => "24",
  845. "Like Button Count" => "20",
  846. "Like Box Count" => "62",
  847. "Recommend Standard" => "24",
  848. "Recommend Button Count" => "20",
  849. "Recommend Box Count" => "60"
  850. );
  851. public function DD_FbLike() {
  852. $this->option_append_type = self::OPTION_APPEND_TYPE;
  853. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  854. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  855. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  856. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  857. $this->baseURL_lazy = self::BASEURL_LAZY;
  858. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  859. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  860. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  861. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  862. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  863. }
  864. public function constructLazyLoadURL($url, $title,$button, $postId){
  865. $finalURL_lazy = $this->baseURL_lazy;
  866. $finalURL_lazy = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  867. $finalURL_lazy = str_replace(parent::VOTE_TITLE,$title,$finalURL_lazy);
  868. $finalURL_lazy = str_replace(parent::VOTE_URL,$url,$finalURL_lazy);
  869. $finalURL_lazy = str_replace(parent::POST_ID,$postId,$finalURL_lazy);
  870. $this->finalURL_lazy = $finalURL_lazy;
  871. $finalURL_lazy_script = $this->baseURL_lazy_script;
  872. $finalURL_lazy_script = str_replace(parent::VOTE_BUTTON_DESIGN_LAZY_WIDTH,$this->getButtonDesignLazyWidth($button),$finalURL_lazy_script);
  873. $finalURL_lazy_script = str_replace(parent::VOTE_BUTTON_DESIGN_LAZY_HEIGHT,$this->getButtonDesignLazyHeight($button),$finalURL_lazy_script);
  874. $finalURL_lazy_script = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy_script);
  875. $finalURL_lazy_script = str_replace(parent::VOTE_TITLE,$title,$finalURL_lazy_script);
  876. $finalURL_lazy_script = str_replace(parent::VOTE_URL,$url,$finalURL_lazy_script);
  877. $finalURL_lazy_script = str_replace(parent::POST_ID,$postId,$finalURL_lazy_script);
  878. //add new line
  879. //convert &amp; to &
  880. $finalURL_lazy_script = str_replace("&amp;","&",$finalURL_lazy_script);
  881. $this->finalURL_lazy_script = $finalURL_lazy_script;
  882. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  883. $final_scheduler_lazy_script = str_replace(parent::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  884. $final_scheduler_lazy_script = str_replace(parent::POST_ID,$postId,$final_scheduler_lazy_script);
  885. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  886. }
  887. public function constructURL($url, $title,$button, $postId, $lazy, $globalcfg = ''){
  888. if($this->isEncodeRequired){
  889. $title = rawurlencode($title);
  890. $url = rawurlencode($url);
  891. }
  892. $facebook_locale = '';
  893. if($globalcfg!=''){
  894. $facebook_locale = $globalcfg[DD_GLOBAL_FACEBOOK_OPTION][DD_GLOBAL_FACEBOOK_OPTION_LOCALE];
  895. }
  896. if($lazy==DD_EMPTY_VALUE){
  897. $this->baseURL = str_replace(self::FACEBOOK_LOCALE,$facebook_locale,$this->baseURL);
  898. $this->constructNormalURL($url, $title,$button, $postId);
  899. }else{
  900. $this->baseURL_lazy_script = str_replace(self::FACEBOOK_LOCALE,$facebook_locale,$this->baseURL_lazy_script);
  901. $this->constructLazyLoadURL($url, $title,$button, $postId);
  902. }
  903. }
  904. }
  905. /******************************************************************************************
  906. *
  907. * http://www.digg.com
  908. *
  909. */
  910. class DD_Digg extends BaseDD{
  911. }
  912. /******************************************************************************************
  913. *
  914. * http://www.reddit.com
  915. *
  916. */
  917. class DD_Reddit extends BaseIFrameDD{
  918. const NAME = "Reddit";
  919. const URL_WEBSITE = "http://www.reddit.com";
  920. const URL_API = "http://www.reddit.com/buttons/";
  921. const DEFAULT_BUTTON_WEIGHT = "99";
  922. const BASEURL = "<iframe src=\"http://www.reddit.com/static/button/VOTE_BUTTON_DESIGN&url=VOTE_URL&title=VOTE_TITLE&newwindow='1'\" EXTRA_VALUE scrolling='no' frameborder='0'></iframe>";
  923. const BASEURL_LAZY = "<div class='dd-reddit-ajax-load dd-reddit-POST_ID'></div><iframe class='DD_REDDIT_AJAX_POST_ID' src='' height='0' width='0' scrolling='no' frameborder='0'></iframe>";
  924. const BASEURL_LAZY_SCRIPT = " function loadReddit_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-reddit-POST_ID').remove();\$('.DD_REDDIT_AJAX_POST_ID').attr('width','VOTE_BUTTON_DESIGN_LAZY_WIDTH');\$('.DD_REDDIT_AJAX_POST_ID').attr('height','VOTE_BUTTON_DESIGN_LAZY_HEIGHT');\$('.DD_REDDIT_AJAX_POST_ID').attr('src','http://www.reddit.com/static/button/VOTE_BUTTON_DESIGN&url=VOTE_URL&title=VOTE_TITLE&newwindow=1'); }); }";
  925. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadReddit_POST_ID()',SCHEDULER_TIMER);";
  926. const SCHEDULER_LAZY_TIMER = "1000";
  927. const OPTION_APPEND_TYPE = "dd_reddit_appendType";
  928. const OPTION_BUTTON_DESIGN = "dd_reddit_buttonDesign";
  929. const OPTION_BUTTON_WEIGHT = "dd_reddit_button_weight";
  930. const OPTION_AJAX_LEFT_FLOAT = "dd_reddit_ajax_left_float";
  931. const OPTION_LAZY_LOAD = "dd_reddit_lazy_load";
  932. var $buttonLayout = array(
  933. "Normal" => "button2.html?width=51",
  934. "Compact" => "button1.html?width=120",
  935. "Icon" => "button3.html?width=69"
  936. );
  937. var $buttonLayoutLazy = array(
  938. "Normal" => "button2.html?width=51",
  939. "Compact" => "button1.html?width=120",
  940. "Icon" => "button3.html?width=69"
  941. );
  942. var $buttonLayoutLazyWidth = array(
  943. "Normal" => "51",
  944. "Compact" => "120",
  945. "Icon" => "69"
  946. );
  947. var $buttonLayoutLazyHeight = array(
  948. "Normal" => "69",
  949. "Compact" => "22",
  950. "Icon" => "52"
  951. );
  952. var $buttonLayoutWidthHeight = array(
  953. "Normal" => "height=\"69\" width=\"51\"",
  954. "Compact" => "height=\"22\" width=\"120\"",
  955. "Icon" => "height=\"52\" width=\"69\""
  956. );
  957. public function DD_Reddit() {
  958. $this->option_append_type = self::OPTION_APPEND_TYPE;
  959. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  960. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  961. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  962. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  963. $this->baseURL_lazy = self::BASEURL_LAZY;
  964. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  965. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  966. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  967. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  968. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  969. }
  970. }
  971. /******************************************************************************************
  972. *
  973. * http://www.google.com/buzz
  974. *
  975. */
  976. class DD_GBuzz extends BaseDD{
  977. }
  978. /******************************************************************************************
  979. *
  980. * http://www.dzone.com
  981. *
  982. */
  983. class DD_DZone extends BaseDD{
  984. const NAME = "DZone";
  985. const URL_WEBSITE = "http://www.dzone.com";
  986. const URL_API = "http://www.dzone.com/links/buttons.jsp";
  987. const BASEURL = "<iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=VOTE_URL&amp;title=VOTE_TITLE&amp;t=VOTE_BUTTON_DESIGN frameborder='0' scrolling='no'></iframe>";
  988. const BASEURL_LAZY = "<div class='dd-dzone-ajax-load dd-dzone-POST_ID'></div><iframe class='DD_DZONE_AJAX_POST_ID' src='' height='0' width='0' scrolling='no' frameborder='0'></iframe>";
  989. const BASEURL_LAZY_SCRIPT = " function loadDzone_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-dzone-POST_ID').remove();\$('.DD_DZONE_AJAX_POST_ID').attr('width','VOTE_BUTTON_DESIGN_LAZY_WIDTH');\$('.DD_DZONE_AJAX_POST_ID').attr('height','VOTE_BUTTON_DESIGN_LAZY_HEIGHT');\$('.DD_DZONE_AJAX_POST_ID').attr('src','http://widgets.dzone.com/links/widgets/zoneit.html?url=VOTE_URL&title=VOTE_TITLE&t=VOTE_BUTTON_DESIGN'); }); }";
  990. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadDzone_POST_ID()',SCHEDULER_TIMER);";
  991. const SCHEDULER_LAZY_TIMER = "1000";
  992. const OPTION_APPEND_TYPE = "dd_dzone_appendType";
  993. const OPTION_BUTTON_DESIGN = "dd_dzone_buttonDesign";
  994. const OPTION_BUTTON_WEIGHT = "dd_dzone_button_weight";
  995. const OPTION_AJAX_LEFT_FLOAT = "dd_dzone_ajax_left_float";
  996. const OPTION_LAZY_LOAD = "dd_dzone_lazy_load";
  997. const DEFAULT_BUTTON_WEIGHT = "97";
  998. var $buttonLayout = array(
  999. "Normal" => "1' height='70' width='50'",
  1000. "Compact" => "2' height='25' width='155'"
  1001. );
  1002. var $buttonLayoutLazy = array(
  1003. "Normal" => "1",
  1004. "Compact" => "2"
  1005. );
  1006. var $buttonLayoutLazyWidth = array(
  1007. "Normal" => "50",
  1008. "Compact" => "155"
  1009. );
  1010. var $buttonLayoutLazyHeight = array(
  1011. "Normal" => "70",
  1012. "Compact" => "25"
  1013. );
  1014. public function DD_DZone() {
  1015. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1016. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1017. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1018. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1019. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1020. $this->baseURL_lazy = self::BASEURL_LAZY;
  1021. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  1022. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  1023. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  1024. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1025. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1026. }
  1027. public function constructLazyLoadURL($url, $title,$button, $postId){
  1028. $finalURL_lazy = $this->baseURL_lazy;
  1029. $finalURL_lazy = str_replace(self::POST_ID,$postId,$finalURL_lazy);
  1030. $this->finalURL_lazy = $finalURL_lazy;
  1031. $finalURL_lazy_script = $this->baseURL_lazy_script;
  1032. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN_LAZY_WIDTH,$this->getButtonDesignLazyWidth($button),$finalURL_lazy_script);
  1033. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN_LAZY_HEIGHT,$this->getButtonDesignLazyHeight($button),$finalURL_lazy_script);
  1034. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy_script);
  1035. $finalURL_lazy_script = str_replace(self::VOTE_TITLE,$title,$finalURL_lazy_script);
  1036. $finalURL_lazy_script = str_replace(self::VOTE_URL,$url,$finalURL_lazy_script);
  1037. $finalURL_lazy_script = str_replace(self::POST_ID,$postId,$finalURL_lazy_script);
  1038. $this->finalURL_lazy_script = $finalURL_lazy_script;
  1039. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  1040. $final_scheduler_lazy_script = str_replace(self::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  1041. $final_scheduler_lazy_script = str_replace(self::POST_ID,$postId,$final_scheduler_lazy_script);
  1042. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  1043. }
  1044. }
  1045. /******************************************************************************************
  1046. *
  1047. * http://www.facebook.com
  1048. * FB share API is missing from Facebook.com, all redirect to FB Like API?
  1049. */
  1050. class DD_FbShare extends BaseDD{
  1051. const NAME = "Facebook Share";
  1052. const URL_WEBSITE = "http://www.facebook.com";
  1053. const URL_API = "http://www.facebook.com/share/";
  1054. const BASEURL = "<a name='fb_share' type='VOTE_BUTTON_DESIGN' share_url='VOTE_URL' href='http://www.facebook.com/sharer.php'></a><script src='http://static.ak.fbcdn.net/connect.php/js/FB.Share' type='text/javascript'></script>";
  1055. const DEFAULT_BUTTON_WEIGHT = "95";
  1056. const OPTION_APPEND_TYPE = "dd_fbshare_appendType";
  1057. const OPTION_BUTTON_DESIGN = "dd_fbshare_buttonDesign";
  1058. const OPTION_BUTTON_WEIGHT = "dd_fbshare_button_weight";
  1059. const OPTION_AJAX_LEFT_FLOAT = "dd_fbshare_ajax_left_float";
  1060. const OPTION_LAZY_LOAD = "dd_fbshare_lazy_load";
  1061. const BASEURL_LAZY = "<div class='dd-fbshare-ajax-load dd-fbshare-POST_ID'></div><a class='DD_FBSHARE_AJAX_POST_ID' name='fb_share' type='VOTE_BUTTON_DESIGN' share_url='VOTE_URL' href='http://www.facebook.com/sharer.php'></a>";
  1062. const BASEURL_LAZY_SCRIPT = " function loadFBShare_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-fbshare-POST_ID').remove(); \$.getScript('http://static.ak.fbcdn.net/connect.php/js/FB.Share'); }); }";
  1063. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadFBShare_POST_ID()',SCHEDULER_TIMER);";
  1064. const SCHEDULER_LAZY_TIMER = "1000";
  1065. var $buttonLayout = array(
  1066. "Normal" => "box_count",
  1067. "Compact" => "button_count"
  1068. );
  1069. var $buttonLayoutLazy = array(
  1070. "Normal" => "box_count",
  1071. "Compact" => "button_count"
  1072. );
  1073. var $isEncodeRequired = false;
  1074. public function DD_FbShare() {
  1075. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1076. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1077. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1078. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1079. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1080. $this->baseURL_lazy = self::BASEURL_LAZY;
  1081. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  1082. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  1083. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  1084. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1085. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1086. }
  1087. public function constructLazyLoadURL($url, $title,$button, $postId){
  1088. $finalURL_lazy = $this->baseURL_lazy;
  1089. $finalURL_lazy = str_replace(self::VOTE_URL,$url,$finalURL_lazy);
  1090. $finalURL_lazy = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  1091. $finalURL_lazy = str_replace(self::POST_ID,$postId,$finalURL_lazy);
  1092. $this->finalURL_lazy = $finalURL_lazy;
  1093. $finalURL_lazy_script = $this->baseURL_lazy_script;
  1094. $finalURL_lazy_script = str_replace(self::POST_ID,$postId,$finalURL_lazy_script);
  1095. $this->finalURL_lazy_script = $finalURL_lazy_script;
  1096. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  1097. $final_scheduler_lazy_script = str_replace(self::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  1098. $final_scheduler_lazy_script = str_replace(self::POST_ID,$postId,$final_scheduler_lazy_script);
  1099. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  1100. }
  1101. }
  1102. /******************************************************************************************
  1103. *
  1104. * http://www.fbshare.me
  1105. *
  1106. */
  1107. class DD_FbShareMe extends BaseDD{
  1108. const NAME = "fbShare.me";
  1109. const URL_WEBSITE = "http://www.fbshare.me";
  1110. const URL_API = "http://www.fbshare.me";
  1111. const DEFAULT_BUTTON_WEIGHT = "94";
  1112. const BASEURL = "<script>var fbShare = {url: 'VOTE_URL',size: 'VOTE_BUTTON_DESIGN',}</script><script src='http://widgets.fbshare.me/files/fbshare.js'></script>";
  1113. const OPTION_APPEND_TYPE = "dd_fbshareme_appendType";
  1114. const OPTION_BUTTON_DESIGN = "dd_fbshareme_buttonDesign";
  1115. const OPTION_BUTTON_WEIGHT = "dd_fbshareme_button_weight";
  1116. const OPTION_AJAX_LEFT_FLOAT = "dd_fbshareme_ajax_left_float";
  1117. const OPTION_LAZY_LOAD = "dd_fbshareme_lazy_load";
  1118. const BASEURL_LAZY = "<div class='dd-fbshareme-ajax-load dd-fbshareme-POST_ID'></div><iframe class=\"DD_FBSHAREME_AJAX_POST_ID\" src='' height='0' width='0' scrolling='no' frameborder='0' allowtransparency='true'></iframe>";
  1119. const BASEURL_LAZY_SCRIPT = " function loadFBShareMe_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-fbshareme-POST_ID').remove();\$('.DD_FBSHAREME_AJAX_POST_ID').attr('width','VOTE_BUTTON_DESIGN_LAZY_WIDTH');\$('.DD_FBSHAREME_AJAX_POST_ID').attr('height','VOTE_BUTTON_DESIGN_LAZY_HEIGHT');\$('.DD_FBSHAREME_AJAX_POST_ID').attr('src','http://widgets.fbshare.me/files/fbshare.php?url=VOTE_URL&size=VOTE_BUTTON_DESIGN'); }); }";
  1120. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadFBShareMe_POST_ID()',SCHEDULER_TIMER);";
  1121. const SCHEDULER_LAZY_TIMER = "1000";
  1122. var $buttonLayout = array(
  1123. "Normal" => "large",
  1124. "Compact" => "small"
  1125. );
  1126. var $buttonLayoutLazy = array(
  1127. "Normal" => "large",
  1128. "Compact" => "small"
  1129. );
  1130. var $buttonLayoutLazyWidth = array(
  1131. "Normal" => "53",
  1132. "Compact" => "80"
  1133. );
  1134. var $buttonLayoutLazyHeight = array(
  1135. "Normal" => "69",
  1136. "Compact" => "18"
  1137. );
  1138. var $isEncodeRequired = false;
  1139. public function DD_FbShareMe() {
  1140. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1141. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1142. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1143. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1144. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1145. $this->baseURL_lazy = self::BASEURL_LAZY;
  1146. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  1147. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  1148. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  1149. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1150. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1151. }
  1152. public function constructLazyLoadURL($url, $title,$button, $postId){
  1153. $finalURL_lazy = $this->baseURL_lazy;
  1154. $finalURL_lazy = str_replace(self::POST_ID,$postId,$finalURL_lazy);
  1155. $this->finalURL_lazy = $finalURL_lazy;
  1156. $finalURL_lazy_script = $this->baseURL_lazy_script;
  1157. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN_LAZY_WIDTH,$this->getButtonDesignLazyWidth($button),$finalURL_lazy_script);
  1158. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN_LAZY_HEIGHT,$this->getButtonDesignLazyHeight($button),$finalURL_lazy_script);
  1159. $finalURL_lazy_script = str_replace(self::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy_script);
  1160. $finalURL_lazy_script = str_replace(self::VOTE_TITLE,$title,$finalURL_lazy_script);
  1161. $finalURL_lazy_script = str_replace(self::VOTE_URL,$url,$finalURL_lazy_script);
  1162. $finalURL_lazy_script = str_replace(self::POST_ID,$postId,$finalURL_lazy_script);
  1163. $this->finalURL_lazy_script = $finalURL_lazy_script;
  1164. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  1165. $final_scheduler_lazy_script = str_replace(self::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  1166. $final_scheduler_lazy_script = str_replace(self::POST_ID,$postId,$final_scheduler_lazy_script);
  1167. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  1168. }
  1169. }
  1170. /******************************************************************************************
  1171. *
  1172. * http://www.delicious.com
  1173. *
  1174. */
  1175. class DD_Delicious extends BaseDD{
  1176. const NAME = "Delicious";
  1177. const URL_WEBSITE = "http://www.delicious.com";
  1178. const URL_API = "http://www.delicious.com/help/feeds";
  1179. const DEFAULT_BUTTON_WEIGHT = "93";
  1180. const BASEURL = "<div class='VOTE_BUTTON_DESIGN dd_delicious'><a class='VOTE_BUTTON_DESIGN' href='http://delicious.com/save' onclick=\"window.open('http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url='+encodeURIComponent('VOTE_URL')+'&amp;title='+encodeURIComponent('VOTE_TITLE'),'delicious', 'toolbar=no,width=550,height=550'); return false;\"><span id='DD_DELICIOUS_AJAX_POST_ID'><div style='padding-top:3px'>SAVED_COUNT</div></span></a></div>";
  1181. const OPTION_APPEND_TYPE = "dd_delicious_appendType";
  1182. const OPTION_BUTTON_DESIGN = "dd_delicious_buttonDesign";
  1183. const OPTION_BUTTON_WEIGHT = "dd_delicious_button_weight";
  1184. const OPTION_AJAX_LEFT_FLOAT = "dd_delicious_ajax_left_float";
  1185. const OPTION_LAZY_LOAD = "dd_delicious_lazy_load";
  1186. const BASEURL_LAZY = "<div class='VOTE_BUTTON_DESIGN dd_delicious'><a href='http://delicious.com/save' onclick=\"window.open('http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url='+encodeURIComponent('VOTE_URL')+'&amp;title='+encodeURIComponent('VOTE_TITLE'),'delicious', 'toolbar=no,width=550,height=550'); return false;\"><span id='DD_DELICIOUS_AJAX_POST_ID'>SAVED_COUNT</span></a></div>";
  1187. const BASEURL_LAZY_SCRIPT = " function loadDelicious_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-delicious-POST_ID').remove();\$.getJSON('http://feeds.delicious.com/v2/json/urlinfo/data?url=VOTE_URL&amp;callback=?',function(data) {var msg ='';var count = 0;if (data.length > 0) {count = data[0].total_posts;if(count ==0){msg = '0';}else if(count ==1){msg = '1';}else{msg = count}}else{msg = '0';}\$('#DD_DELICIOUS_AJAX_POST_ID').text(msg);}); }); }";
  1188. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadDelicious_POST_ID()',SCHEDULER_TIMER);";
  1189. const SCHEDULER_LAZY_TIMER = "1000";
  1190. const SAVED_COUNT = "SAVED_COUNT";
  1191. var $isEncodeRequired = false;
  1192. var $buttonLayout = array(
  1193. "Normal" => DD_PLUGIN_STYLE_DELICIOUS,
  1194. "Compact" => DD_PLUGIN_STYLE_DELICIOUS_COMPACT
  1195. );
  1196. var $buttonLayoutLazy = array(
  1197. "Normal" => DD_PLUGIN_STYLE_DELICIOUS,
  1198. "Compact" => DD_PLUGIN_STYLE_DELICIOUS_COMPACT
  1199. );
  1200. public function DD_Delicious() {
  1201. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1202. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1203. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1204. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1205. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1206. $this->baseURL_lazy = self::BASEURL_LAZY;
  1207. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  1208. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  1209. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  1210. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1211. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1212. }
  1213. public function constructNormalURL($url, $title,$button, $postId){
  1214. $count = '';
  1215. $shareUrl = urlencode($url);
  1216. $deliciousStats = json_decode(file_get_contents('http://feeds.delicious.com/v2/json/urlinfo/data?url='.$shareUrl));
  1217. if(!empty($deliciousStats)){
  1218. if($deliciousStats->total_posts == 0) {
  1219. $count = '0';
  1220. } elseif($deliciousStats->total_posts == 1) {
  1221. $count = '1';
  1222. } else {
  1223. $count = $deliciousStats->total_posts;
  1224. }
  1225. }else{
  1226. $count = '0';
  1227. }
  1228. $finalURL = $this->baseURL;
  1229. $finalURL = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesign($button),$finalURL);
  1230. $finalURL = str_replace(parent::VOTE_TITLE,$title,$finalURL);
  1231. $finalURL = str_replace(parent::VOTE_URL,$url,$finalURL);
  1232. $finalURL = str_replace(self::SAVED_COUNT,$count,$finalURL);
  1233. $this->finalURL = $finalURL;
  1234. }
  1235. public function constructLazyLoadURL($url, $title,$button, $postId){
  1236. $finalURL_lazy = $this->baseURL_lazy;
  1237. $finalURL_lazy = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy);
  1238. $finalURL_lazy = str_replace(parent::VOTE_TITLE,$title,$finalURL_lazy);
  1239. $finalURL_lazy = str_replace(parent::VOTE_URL,$url,$finalURL_lazy);
  1240. $finalURL_lazy = str_replace(parent::POST_ID,$postId,$finalURL_lazy);
  1241. //add new line
  1242. $finalURL_lazy = str_replace(self::SAVED_COUNT,'',$finalURL_lazy);
  1243. $this->finalURL_lazy = $finalURL_lazy;
  1244. $finalURL_lazy_script = $this->baseURL_lazy_script;
  1245. $finalURL_lazy_script = str_replace(parent::VOTE_BUTTON_DESIGN_LAZY_WIDTH,$this->getButtonDesignLazyWidth($button),$finalURL_lazy_script);
  1246. $finalURL_lazy_script = str_replace(parent::VOTE_BUTTON_DESIGN_LAZY_HEIGHT,$this->getButtonDesignLazyHeight($button),$finalURL_lazy_script);
  1247. $finalURL_lazy_script = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesignLazy($button),$finalURL_lazy_script);
  1248. $finalURL_lazy_script = str_replace(parent::VOTE_TITLE,$title,$finalURL_lazy_script);
  1249. $finalURL_lazy_script = str_replace(parent::VOTE_URL,$url,$finalURL_lazy_script);
  1250. $finalURL_lazy_script = str_replace(parent::POST_ID,$postId,$finalURL_lazy_script);
  1251. $this->finalURL_lazy_script = $finalURL_lazy_script;
  1252. $final_scheduler_lazy_script = $this->scheduler_lazy_script;
  1253. $final_scheduler_lazy_script = str_replace(parent::SCHEDULER_TIMER,$this->scheduler_lazy_timer,$final_scheduler_lazy_script);
  1254. $final_scheduler_lazy_script = str_replace(parent::POST_ID,$postId,$final_scheduler_lazy_script);
  1255. $this->final_scheduler_lazy_script = $final_scheduler_lazy_script;
  1256. }
  1257. }
  1258. /******************************************************************************************
  1259. *
  1260. * http://www.stumbleupon.com
  1261. *
  1262. */
  1263. class DD_StumbleUpon extends BaseDD{
  1264. const NAME = "Stumbleupon";
  1265. const URL_WEBSITE = "http://www.stumbleupon.com";
  1266. const URL_API = "http://www.stumbleupon.com/badges/";
  1267. const BASEURL = "<script src='http://www.stumbleupon.com/hostedbadge.php?s=VOTE_BUTTON_DESIGN&amp;r=VOTE_URL'></script>";
  1268. const DEFAULT_BUTTON_WEIGHT = "97";
  1269. const OPTION_APPEND_TYPE = "dd_stumbleupon_appendType";
  1270. const OPTION_BUTTON_DESIGN = "dd_stumbleupon_buttonDesign";
  1271. const OPTION_BUTTON_WEIGHT = "dd_stumbleupon_button_weight";
  1272. const OPTION_AJAX_LEFT_FLOAT = "dd_stumbleupon_ajax_left_float";
  1273. const OPTION_LAZY_LOAD = "dd_stumbleupon_lazy_load";
  1274. var $islazyLoadAvailable = false;
  1275. var $buttonLayout = array(
  1276. "Normal" => "5",
  1277. "Compact" => "1"
  1278. );
  1279. public function DD_StumbleUpon() {
  1280. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1281. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1282. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1283. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1284. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1285. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1286. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1287. }
  1288. }
  1289. /******************************************************************************************
  1290. *
  1291. * http://buzz.yahoo.com
  1292. *
  1293. */
  1294. class DD_YBuzz extends BaseDD{
  1295. const NAME = "Yahoo Buzz";
  1296. const URL_WEBSITE = "http://buzz.yahoo.com";
  1297. const URL_API = "http://buzz.yahoo.com/buttons";
  1298. const DEFAULT_BUTTON_WEIGHT = "90";
  1299. const BASEURL = "<script type='text/javascript'>yahooBuzzArticleHeadline=\"VOTE_TITLE\";yahooBuzzArticleId=\"VOTE_URL\";</script><script type='text/javascript' src='http://d.yimg.com/ds/badge2.js' badgetype='VOTE_BUTTON_DESIGN'></script>";
  1300. const OPTION_APPEND_TYPE = "dd_ybuzz_appendType";
  1301. const OPTION_BUTTON_DESIGN = "dd_ybuzz_buttonDesign";
  1302. const OPTION_BUTTON_WEIGHT = "dd_ybuzz_button_weight";
  1303. const OPTION_AJAX_LEFT_FLOAT = "dd_ybuzz_ajax_left_float";
  1304. const OPTION_LAZY_LOAD = "dd_ybuzz_lazy_load";
  1305. var $islazyLoadAvailable = false;
  1306. var $buttonLayout = array(
  1307. "Normal" => "square",
  1308. "Compact" => "small-votes",
  1309. "Compact_Text" => "text-votes"
  1310. );
  1311. var $isEncodeRequired = false;
  1312. public function DD_YBuzz() {
  1313. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1314. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1315. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1316. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1317. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1318. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1319. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1320. }
  1321. }
  1322. /******************************************************************************************
  1323. *
  1324. * http://www.blogengage.com
  1325. *
  1326. */
  1327. class DD_BlogEngage extends BaseDD{
  1328. const NAME = "BlogEngage";
  1329. const URL_WEBSITE = "http://www.blogengage.com";
  1330. const URL_API = "http://www.blogengage.com/profile_promo.php";
  1331. const DEFAULT_BUTTON_WEIGHT = "84";
  1332. const BASEURL = "<script type='text/javascript'>submit_url = 'VOTE_URL';</script><script src='http://blogengage.com/evb/VOTE_BUTTON_DESIGN'></script>";
  1333. const OPTION_APPEND_TYPE = "dd_blogengage_appendType";
  1334. const OPTION_BUTTON_DESIGN = "dd_blogengage_buttonDesign";
  1335. const OPTION_BUTTON_WEIGHT = "dd_blogengage_button_weight";
  1336. const OPTION_AJAX_LEFT_FLOAT = "dd_blogengage_ajax_left_float";
  1337. const OPTION_LAZY_LOAD = "dd_blogengage_lazy_load";
  1338. var $islazyLoadAvailable = false;
  1339. var $isEncodeRequired = false;
  1340. var $buttonLayout = array(
  1341. "Normal" => "button4.php"
  1342. );
  1343. public function DD_BlogEngage() {
  1344. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1345. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1346. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1347. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1348. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1349. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1350. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1351. }
  1352. }
  1353. /******************************************************************************************
  1354. *
  1355. * http://www.designbump.com
  1356. *
  1357. */
  1358. class DD_DesignBump extends BaseDD{
  1359. const NAME = "DesignBump";
  1360. const URL_WEBSITE = "http://www.designbump.com";
  1361. const URL_API = "http://designbump.com/content/evb";
  1362. const DEFAULT_BUTTON_WEIGHT = "87";
  1363. const BASEURL = "<script type='text/javascript'>url_site='VOTE_URL'; </script> <script src='http://designbump.com/sites/all/modules/drigg_external/js/button.js' type='text/javascript'></script>";
  1364. const OPTION_APPEND_TYPE = "dd_designbump_appendType";
  1365. const OPTION_BUTTON_DESIGN = "dd_designbump_buttonDesign";
  1366. const OPTION_BUTTON_WEIGHT = "dd_designbump_button_weight";
  1367. const OPTION_AJAX_LEFT_FLOAT = "dd_designbump_ajax_left_float";
  1368. const OPTION_LAZY_LOAD = "dd_designbump_lazy_load";
  1369. var $islazyLoadAvailable = false;
  1370. var $isEncodeRequired = false;
  1371. var $buttonLayout = array(
  1372. "Normal" => "Normal"
  1373. );
  1374. public function DD_DesignBump() {
  1375. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1376. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1377. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1378. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1379. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1380. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1381. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1382. }
  1383. }
  1384. /******************************************************************************************
  1385. *
  1386. * http://www.thewebblend.com
  1387. *
  1388. */
  1389. class DD_TheWebBlend extends BaseDD{
  1390. const NAME = "TheWebBlend";
  1391. const URL_WEBSITE = "http://www.thewebblend.com";
  1392. const URL_API = "http://thewebblend.com/tools/vote";
  1393. const DEFAULT_BUTTON_WEIGHT = "85";
  1394. const BASEURL = "<script type='text/javascript'>url_site='VOTE_URL'; VOTE_BUTTON_DESIGN</script><script src='http://thewebblend.com/sites/all/modules/drigg_external/js/button.js' type='text/javascript'></script>";
  1395. const OPTION_APPEND_TYPE = "dd_webblend_appendType";
  1396. const OPTION_BUTTON_DESIGN = "dd_webblend_buttonDesign";
  1397. const OPTION_BUTTON_WEIGHT = "dd_webblend_button_weight";
  1398. const OPTION_AJAX_LEFT_FLOAT = "dd_webblend_ajax_left_float";
  1399. const OPTION_LAZY_LOAD = "dd_webblend_lazy_load";
  1400. var $islazyLoadAvailable = false;
  1401. var $isEncodeRequired = false;
  1402. var $buttonLayout = array(
  1403. "Normal" => "",
  1404. "Compact" => "badge_size='compact';"
  1405. );
  1406. public function DD_TheWebBlend() {
  1407. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1408. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1409. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1410. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1411. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1412. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1413. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1414. }
  1415. }
  1416. /******************************************************************************************
  1417. *
  1418. * http://www.tweetmeme.com/
  1419. *
  1420. */
  1421. class DD_TweetMeme extends BaseDD{
  1422. const NAME = "TweetMeme";
  1423. const URL_WEBSITE = "http://www.tweetmeme.com/";
  1424. const URL_API = "http://wordpress.org/extend/plugins/tweetmeme/";
  1425. const DEFAULT_BUTTON_WEIGHT = "97";
  1426. const BASEURL ="<iframe src='http://api.tweetmeme.com/button.js?url=VOTE_URL&source=VOTE_SOURCE&service=VOTE_SERVICE_NAME&service_api=VOTE_SERVICE_API&style=VOTE_BUTTON_DESIGN frameborder='0' scrolling='no'></iframe>";
  1427. const OPTION_APPEND_TYPE = "dd_tweetmeme_appendType";
  1428. const OPTION_BUTTON_DESIGN = "dd_tweetmeme_buttonDesign";
  1429. const OPTION_BUTTON_WEIGHT = "dd_tweetmeme_button_weight";
  1430. const OPTION_AJAX_LEFT_FLOAT = "dd_tweetmeme_ajax_left_float";
  1431. const OPTION_LAZY_LOAD = "dd_tweetmeme_lazy_load";
  1432. const BASEURL_LAZY = "<div class='dd-tweetmeme-ajax-load dd-tweetmeme-POST_ID'></div><iframe class='DD_TWEETMEME_AJAX_POST_ID' src='' height='0' width='0' scrolling='no' frameborder='0'></iframe>";
  1433. const BASEURL_LAZY_SCRIPT = " function loadTweetMeme_POST_ID(){ jQuery(document).ready(function(\$) { \$('.dd-tweetmeme-POST_ID').remove();\$('.DD_TWEETMEME_AJAX_POST_ID').attr('width','VOTE_BUTTON_DESIGN_LAZY_WIDTH');\$('.DD_TWEETMEME_AJAX_POST_ID').attr('height','VOTE_BUTTON_DESIGN_LAZY_HEIGHT');\$('.DD_TWEETMEME_AJAX_POST_ID').attr('src','http://api.tweetmeme.com/button.js?url=VOTE_URL&source=VOTE_SOURCE&style=VOTE_BUTTON_DESIGN&service=VOTE_SERVICE_NAME&service_api=VOTE_SERVICE_API'); }); }";
  1434. const SCHEDULER_LAZY_SCRIPT = "window.setTimeout('loadTweetMeme_POST_ID()',SCHEDULER_TIMER);";
  1435. const SCHEDULER_LAZY_TIMER = "1000";
  1436. var $buttonLayout = array(
  1437. "Normal" => "normal' height='61' width='50'",
  1438. "Compact" => "compact' height='20' width='90'"
  1439. );
  1440. var $buttonLayoutLazy = array(
  1441. "Normal" => "normal",
  1442. "Compact" => "compact"
  1443. );
  1444. var $buttonLayoutLazyWidth = array(
  1445. "Normal" => "50",
  1446. "Compact" => "90"
  1447. );
  1448. var $buttonLayoutLazyHeight = array(
  1449. "Normal" => "61",
  1450. "Compact" => "20"
  1451. );
  1452. var $isEncodeRequired = false;
  1453. const VOTE_SOURCE = "VOTE_SOURCE";
  1454. const VOTE_SERVICE_NAME = "VOTE_SERVICE_NAME";
  1455. const VOTE_SERVICE_API = "VOTE_SERVICE_API";
  1456. public function DD_TweetMeme() {
  1457. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1458. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1459. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1460. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1461. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1462. $this->baseURL_lazy = self::BASEURL_LAZY;
  1463. $this->baseURL_lazy_script = self::BASEURL_LAZY_SCRIPT;
  1464. $this->scheduler_lazy_script = self::SCHEDULER_LAZY_SCRIPT;
  1465. $this->scheduler_lazy_timer = self::SCHEDULER_LAZY_TIMER;
  1466. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1467. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1468. }
  1469. public function constructURL($url, $title,$button, $postId, $lazy, $globalcfg = ''){
  1470. if($this->isEncodeRequired){
  1471. $title = rawurlencode($title);
  1472. $url = rawurlencode($url);
  1473. }
  1474. $source = '';
  1475. $service = '';
  1476. $serviceapi = '';
  1477. if($globalcfg!=''){
  1478. $source = $globalcfg[DD_GLOBAL_TWEETMEME_OPTION][DD_GLOBAL_TWEETMEME_OPTION_SOURCE];
  1479. $service = $globalcfg[DD_GLOBAL_TWEETMEME_OPTION][DD_GLOBAL_TWEETMEME_OPTION_SERVICE];
  1480. $serviceapi = $globalcfg[DD_GLOBAL_TWEETMEME_OPTION][DD_GLOBAL_TWEETMEME_OPTION_SERVICE_API];
  1481. }
  1482. if($lazy==DD_EMPTY_VALUE){
  1483. $this->baseURL = str_replace(self::VOTE_SOURCE,$source,$this->baseURL);
  1484. $this->baseURL = str_replace(self::VOTE_SERVICE_NAME,$service,$this->baseURL);
  1485. $this->baseURL = str_replace(self::VOTE_SERVICE_API,$serviceapi,$this->baseURL);
  1486. $this->constructNormalURL($url, $title,$button, $postId);
  1487. }else{
  1488. $this->baseURL_lazy_script = str_replace(self::VOTE_SOURCE,$source,$this->baseURL_lazy_script);
  1489. $this->baseURL_lazy_script = str_replace(self::VOTE_SERVICE_NAME,$service,$this->baseURL_lazy_script);
  1490. $this->baseURL_lazy_script = str_replace(self::VOTE_SERVICE_API,$serviceapi,$this->baseURL_lazy_script);
  1491. $this->constructLazyLoadURL($url, $title,$button, $postId);
  1492. }
  1493. }
  1494. }
  1495. /******************************************************************************************
  1496. *
  1497. * http://www.topsy.com
  1498. *
  1499. */
  1500. class DD_Topsy extends BaseDD{
  1501. const NAME = "Topsy";
  1502. const URL_WEBSITE = "http://www.topsy.com";
  1503. const URL_API = "http://labs.topsy.com/button/retweet-button/";
  1504. const DEFAULT_BUTTON_WEIGHT = "96";
  1505. const BASEURL = "<script type=\"text/javascript\" src=\"http://cdn.topsy.com/topsy.js?init=topsyWidgetCreator\"></script><div class=\"topsy_widget_data\"><!--{\"url\":\"VOTE_URL\",\"style\":\"VOTE_BUTTON_DESIGN\",\"theme\":\"VOTE_THEME\",\"nick\":\"VOTE_SOURCE\"}--></div>";
  1506. const OPTION_APPEND_TYPE = "dd_topsy_appendType";
  1507. const OPTION_BUTTON_DESIGN = "dd_topsy_buttonDesign";
  1508. const OPTION_BUTTON_WEIGHT = "dd_topsy_button_weight";
  1509. const OPTION_AJAX_LEFT_FLOAT = "dd_topsy_ajax_left_float";
  1510. const OPTION_LAZY_LOAD = "dd_topsy_lazy_load";
  1511. const VOTE_SOURCE = "VOTE_SOURCE";
  1512. const VOTE_THEME = "VOTE_THEME";
  1513. var $islazyLoadAvailable = false;
  1514. var $isEncodeRequired = false;
  1515. var $buttonLayout = array(
  1516. "Normal" => "big",
  1517. "Compact" => "compact"
  1518. );
  1519. public function DD_Topsy() {
  1520. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1521. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1522. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1523. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1524. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1525. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1526. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1527. }
  1528. public function constructURL($url, $title,$button, $postId, $lazy, $globalcfg = ''){
  1529. if($this->isEncodeRequired){
  1530. $title = rawurlencode($title);
  1531. $url = rawurlencode($url);
  1532. }
  1533. $source = '';
  1534. $theme = '';
  1535. if($globalcfg!=''){
  1536. $source = $globalcfg[DD_GLOBAL_TOPSY_OPTION][DD_GLOBAL_TOPSY_OPTION_SOURCE];
  1537. $theme = $globalcfg[DD_GLOBAL_TOPSY_OPTION][DD_GLOBAL_TOPSY_OPTION_THEME];
  1538. }
  1539. $finalURL = '';
  1540. $finalURL = str_replace(parent::VOTE_BUTTON_DESIGN,$this->getButtonDesign($button),$this->baseURL);
  1541. $finalURL = str_replace(parent::VOTE_URL,$url,$finalURL);
  1542. $finalURL = str_replace(self::VOTE_SOURCE,$source,$finalURL);
  1543. $finalURL = str_replace(self::VOTE_THEME,$theme,$finalURL);
  1544. $this->finalURL = $finalURL;
  1545. }
  1546. }
  1547. /******************************************************************************************
  1548. *
  1549. * Post comments
  1550. *
  1551. */
  1552. class DD_Comments extends BaseDD{
  1553. const NAME = "Comments";
  1554. const URL_WEBSITE = "http://none";
  1555. const URL_API = "http://none";
  1556. const DEFAULT_BUTTON_WEIGHT = "88";
  1557. const BASEURL = "<div id='dd_comments'><a class='clcount' href=VOTE_URL><span class='ctotal'>COMMENTS_COUNT</span></a><a class='clink' href=VOTE_URL></a></div>";
  1558. const OPTION_APPEND_TYPE = "dd_comments_appendType";
  1559. const OPTION_BUTTON_DESIGN = "dd_comments_buttonDesign";
  1560. const OPTION_BUTTON_WEIGHT = "dd_comments_button_weight";
  1561. const OPTION_AJAX_LEFT_FLOAT = "dd_comments_ajax_left_float";
  1562. const OPTION_LAZY_LOAD = "dd_comments_lazy_load";
  1563. const COMMENTS_COUNT = "COMMENTS_COUNT";
  1564. const COMMENTS_RESPONSE_ID = "#respond";
  1565. var $islazyLoadAvailable = false;
  1566. var $buttonLayout = array(
  1567. "Normal" => "Normal",
  1568. );
  1569. public function DD_Comments() {
  1570. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1571. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1572. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1573. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1574. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1575. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1576. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1577. }
  1578. public function constructURL($url, $title,$button, $postId, $lazy, $globalcfg = '', $commentcount = ''){
  1579. $result = '';
  1580. $url = $url . self::COMMENTS_RESPONSE_ID;
  1581. $result = str_replace(self::VOTE_URL,$url,$this->baseURL);
  1582. $result = str_replace(self::COMMENTS_COUNT,$commentcount,$result);
  1583. $this->finalURL = $result;
  1584. }
  1585. }
  1586. /******************************************************************************************
  1587. *
  1588. * http://www.serpd.com
  1589. *
  1590. */
  1591. class DD_Serpd extends BaseDD{
  1592. const NAME = "Serpd";
  1593. const URL_WEBSITE = "http://www.serpd.com";
  1594. const URL_API = "http://www.serpd.com/widgets/";
  1595. const BASEURL = "<script type=\"text/javascript\">submit_url = \"VOTE_URL\";</script><script type=\"text/javascript\" src=\"http://www.serpd.com/index.php?page=evb\"></script>";
  1596. const OPTION_APPEND_TYPE = "dd_serpd_appendType";
  1597. const OPTION_BUTTON_DESIGN = "dd_serpd_buttonDesign";
  1598. const OPTION_BUTTON_WEIGHT = "dd_serpd_button_weight";
  1599. const OPTION_AJAX_LEFT_FLOAT = "dd_serpd_ajax_left_float";
  1600. const OPTION_LAZY_LOAD = "dd_serpd_lazy_load";
  1601. const DEFAULT_BUTTON_WEIGHT = "86";
  1602. var $islazyLoadAvailable = false;
  1603. var $isEncodeRequired = false;
  1604. var $buttonLayout = array(
  1605. "Normal" => "",
  1606. );
  1607. public function DD_Serpd() {
  1608. $this->option_append_type = self::OPTION_APPEND_TYPE;
  1609. $this->option_button_design = self::OPTION_BUTTON_DESIGN;
  1610. $this->option_button_weight = self::OPTION_BUTTON_WEIGHT;
  1611. $this->option_ajax_left_float = self::OPTION_AJAX_LEFT_FLOAT;
  1612. $this->option_lazy_load = self::OPTION_LAZY_LOAD;
  1613. $this->button_weight_value = self::DEFAULT_BUTTON_WEIGHT;
  1614. parent::BaseDD(self::NAME, self::URL_WEBSITE, self::URL_API, self::BASEURL);
  1615. }
  1616. }
  1617. ?>