PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/wp-homepage-slideshow/functions.php

https://bitbucket.org/lgorence/quickpress
PHP | 372 lines | 330 code | 23 blank | 19 comment | 43 complexity | e83779508401ff8975b3d285ac84cd2d MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. function hss_get_def_settings()
  3. {
  4. $hss_settings = array('bannerWidth' => '700',
  5. 'bannerHeight' => '220',
  6. 'autoSlideTime' => '10',
  7. 'showPlay' => '1',
  8. 'backgroundColor' => 'FFFFFF',
  9. 'imagewidth' => '510',
  10. 'gradientColor1' => 'E1ED91',
  11. 'gradientColor2' => 'AFCB5A',
  12. 'menuColor' => 'ebf3e0',
  13. 'menuOverColor' => '7DAA20',
  14. 'menuTextColor' => '21428c',
  15. 'menuOverTextColor' => 'ffffff',
  16. 'transitionTime' => '1',
  17. 'menutransition' => '0.2',
  18. 'menuScrollSpeed' => '15',
  19. 'descbox_visible' => 'yes',
  20. 'boxwidth' => '250',
  21. 'boxheight' => '160',
  22. 'infoFontSizeBig' => '16',
  23. 'infoFontSizeSmall' => '12',
  24. 'menuFontSize' => '12',
  25. 'transition_type' => 'easeIn',
  26. 'transition' => 'left',
  27. 'cornerRadius' => '55',
  28. 'box_x' => '200',
  29. 'box_y' => '20',
  30. 'button_width' => '100',
  31. 'FindMoreColorBack' => '095373',
  32. 'FindMoreColorText' => 'ffffff',
  33. 'FindMoreAlpha' => '0.3',
  34. 'FindMoreName' => 'View More',
  35. 'FindMoreButtonColor' => 'f4c301',
  36. 'FindMoreButtonTextColor' => 'ffffff',
  37. 'pic' => 'modules/mod_homepageslideshow/models/sample_image_1.png&#13;modules/mod_homepageslideshow/models/sample_image_2.png&#13;modules/mod_homepageslideshow/models/sample_image_3.png&#13;modules/mod_homepageslideshow/models/sample_image_4.png',
  38. 'menutxt' => 'News one&#13;News two&#13;News three&#13;News four',
  39. 'showDesBigTxt' => '1',
  40. 'bigtext' => 'Title one&#13;Title two&#13;Titlethree&#13;Title four',
  41. 'showDesSmlTxt' => '1',
  42. 'stext' => 'Description one&#13;Description two&#13;Description three&#13;Description four',
  43. 'links' => 'http://xmlswf.com&#13;http://xmlswf.com&#13;http://xmlswf.com&#13;http://xmlswf.com&#13;',
  44. 'target' => '_self',
  45. 'wmode' => 'transparent'
  46. );
  47. return $hss_settings;
  48. }
  49. function __get_hss_xml_settings()
  50. {
  51. $ops = get_option('hss_settings', array());
  52. $xml_settings =' <baseDef autoSlideTime="'.$ops['autoSlideTime'].'" gradientColor1="0x'.$ops['gradientColor1'].'" showPlay="'.$ops['showPlay'].'" gradientColor2="0x'.$ops['gradientColor2'].'" menuColor="0x'.$ops['menuColor'].'" menuOverColor="0x'.$ops['menuOverColor'].'" menuTextColor= "0x'.$ops['menuTextColor'].'" menuOverTextColor="0x'.$ops['menuOverTextColor'].'" transitionTime="'.$ops['transitionTime'].'" menutransition="'.$ops['menutransition'].'" menuScrollSpeed ="'.$ops['menuScrollSpeed'].'" boxwidth="'.$ops['boxwidth'].'" boxheight="'.$ops['boxheight'].'" infoFontSizeBig="'.$ops['infoFontSizeBig'].'" infoFontSizeSmall="'.$ops['infoFontSizeSmall'].'" menuFontSize="'.$ops['menuFontSize'].'"
  53. transform="null"
  54. transition="'.$ops['transition'].'"
  55. transition_type="'.$ops['transition_type'].'"
  56. cornerRadius="'.$ops['cornerRadius'].'"
  57. box_x="'.$ops['box_x'].'"
  58. box_y="'.$ops['box_y'].'"
  59. button_width="'.$ops['button_width'].'"
  60. description_box_visible="'.($ops['descbox_visible']=="yes"?"true":"false").'"
  61. />';
  62. return $xml_settings;
  63. }
  64. function hss_get_album_dir($album_id)
  65. {
  66. global $ghss;
  67. $album_dir = HSS_PLUGIN_UPLOADS_DIR . "/{$album_id}_uploadfolder";
  68. return $album_dir;
  69. }
  70. /**
  71. * Get album url
  72. * @param $album_id
  73. * @return unknown_type
  74. */
  75. function hss_get_album_url($album_id)
  76. {
  77. global $ghss;
  78. $album_url = HSS_PLUGIN_UPLOADS_URL . "/{$album_id}_uploadfolder";
  79. return $album_url;
  80. }
  81. function hss_get_table_actions(array $tasks)
  82. {
  83. ?>
  84. <div class="bulk_actions">
  85. <form action="" method="post" class="bulk_form">Bulk action
  86. <select name="task">
  87. <?php foreach($tasks as $t => $label): ?>
  88. <option value="<?php print $t; ?>"><?php print $label; ?></option>
  89. <?php endforeach; ?>
  90. </select>
  91. <button class="button-secondary do_bulk_actions" type="submit">Do</button>
  92. </form>
  93. </div>
  94. <?php
  95. }
  96. function shortcode_display_hss_gallery($atts)
  97. {
  98. $vars = shortcode_atts( array(
  99. 'cats' => '',
  100. 'imgs' => '',
  101. ),
  102. $atts );
  103. //extract( $vars );
  104. $ret = display_hss_gallery($vars);
  105. return $ret;
  106. }
  107. function display_hss_gallery($vars)
  108. {
  109. global $wpdb, $ghss;
  110. $ops = get_option('hss_settings', array());
  111. //print_r($ops);
  112. $albums = null;
  113. $images = null;
  114. $cids = trim($vars['cats']);
  115. if (strlen($cids) != strspn($cids, "0123456789,")) {
  116. $cids = '';
  117. $vars['cats'] = '';
  118. }
  119. $imgs = trim($vars['imgs']);
  120. if (strlen($imgs) != strspn($imgs, "0123456789,")) {
  121. $imgs = '';
  122. $vars['imgs'] = '';
  123. }
  124. $categories = '';
  125. $xml_filename = '';
  126. if( !empty($cids) && $cids{strlen($cids)-1} == ',')
  127. {
  128. $cids = substr($cids, 0, -1);
  129. }
  130. if( !empty($imgs) && $imgs{strlen($imgs)-1} == ',')
  131. {
  132. $imgs = substr($imgs, 0, -1);
  133. }
  134. //check for xml file
  135. if( !empty($vars['cats']) )
  136. {
  137. $xml_filename = "cat_".str_replace(',', '', $cids) . '.xml';
  138. }
  139. elseif( !empty($vars['imgs']))
  140. {
  141. $xml_filename = "image_".str_replace(',', '', $imgs) . '.xml';
  142. }
  143. else
  144. {
  145. $xml_filename = "hss_all.xml";
  146. }
  147. //die(HSS_PLUGIN_XML_DIR . '/' . $xml_filename);
  148. if( !empty($vars['cats']) )
  149. {
  150. $query = "SELECT * FROM {$wpdb->prefix}hss_albums WHERE album_id IN($cids) AND status = 1 ORDER BY `order` ASC";
  151. //print $query;
  152. $albums = $wpdb->get_results($query, ARRAY_A);
  153. foreach($albums as $key => $album)
  154. {
  155. $images = $ghss->hss_get_album_images($album['album_id']);
  156. if ($images && !empty($images) && is_array($images)) {
  157. $album_dir = hss_get_album_url($album['album_id']);//HSS_PLUGIN_UPLOADS_URL . '/' . $album['album_id']."_".$album['name'];
  158. foreach($images as $key => $img)
  159. {
  160. if( $img['status'] == 0 ) continue;
  161. $categories .= ' <pic url="'.$img['link'].'" target="'.$ops['target'].'"
  162. FindMoreColorBack="0x'.$ops['FindMoreColorBack'].'" FindMoreColorText="0x'.$ops['FindMoreColorText'].'" FindMoreAlpha="'.$ops['FindMoreAlpha'].'" FindMoreButtonColor="0x'.$ops['FindMoreButtonColor'].'" FindMoreButtonTextColor ="0x'.$ops['FindMoreButtonTextColor'].'" ';
  163. $categories .= " pic=\"".str_replace(" ","-",$album_dir)."/big/{$img['image']}\">";
  164. $categories .= '<FindMoreName><![CDATA['.$ops['FindMoreName'].']]></FindMoreName> ';
  165. if ($ops['showDesBigTxt'] == 1) {
  166. $FindMoreText = '<![CDATA['.$img['description'].']]>';
  167. }else{
  168. $FindMoreText = '';
  169. }
  170. $categories .= '<FindMoreText>'.$FindMoreText.'</FindMoreText> ';
  171. if ($ops['showDesSmlTxt'] == 1) {
  172. $FindMoreSText = '<![CDATA['.$img['description2'].']]>';
  173. }else{
  174. $FindMoreSText = '';
  175. }
  176. $categories .= '<FindMoreSText>'.$FindMoreSText.'</FindMoreSText> ';
  177. $categories .= '<menuText><![CDATA['.$img['title'].']]></menuText>
  178. </pic>
  179. ';
  180. }
  181. }
  182. }
  183. //$xml_filename = "cat_".str_replace(',', '', $cids) . '.xml';
  184. }
  185. elseif( !empty($vars['imgs']))
  186. {
  187. $query = "SELECT * FROM {$wpdb->prefix}hss_images WHERE image_id IN($imgs) AND status = 1 ORDER BY `order` ASC";
  188. $images = $wpdb->get_results($query, ARRAY_A);
  189. if ($images && !empty($images) && is_array($images)) {
  190. foreach($images as $key => $img)
  191. {
  192. $album = $ghss->hss_get_album($img['category_id']);
  193. $album_dir = hss_get_album_url($album['album_id']);//HSS_PLUGIN_UPLOADS_URL . '/' . $album['album_id']."_".$album['name'];
  194. if( $img['status'] == 0 ) continue;
  195. $categories .= ' <pic url="'.$img['link'].'" target="'.$ops['target'].'"
  196. FindMoreColorBack="0x'.$ops['FindMoreColorBack'].'" FindMoreColorText="0x'.$ops['FindMoreColorText'].'" FindMoreAlpha="'.$ops['FindMoreAlpha'].'" FindMoreButtonColor="0x'.$ops['FindMoreButtonColor'].'" FindMoreButtonTextColor ="0x'.$ops['FindMoreButtonTextColor'].'" ';
  197. $categories .= " pic=\"".str_replace(" ","-",$album_dir)."/big/{$img['image']}\">";
  198. $categories .= '<FindMoreName><![CDATA['.$ops['FindMoreName'].']]></FindMoreName> ';
  199. if ($ops['showDesBigTxt'] == 1) {
  200. $FindMoreText = '<![CDATA['.$img['description'].']]>';
  201. }else{
  202. $FindMoreText = '';
  203. }
  204. $categories .= '<FindMoreText>'.$FindMoreText.'</FindMoreText> ';
  205. if ($ops['showDesSmlTxt'] == 1) {
  206. $FindMoreSText = '<![CDATA['.$img['description2'].']]>';
  207. }else{
  208. $FindMoreSText = '';
  209. }
  210. $categories .= '<FindMoreSText>'.$FindMoreSText.'</FindMoreSText> ';
  211. $categories .= '<menuText><![CDATA['.$img['title'].']]></menuText>
  212. </pic>
  213. ';
  214. }
  215. }
  216. }
  217. //no values paremeters setted
  218. else//( empty($vars['cats']) && empty($vars['imgs']))
  219. {
  220. $query = "SELECT * FROM {$wpdb->prefix}hss_albums WHERE status = 1 ORDER BY `order` ASC";
  221. $albums = $wpdb->get_results($query, ARRAY_A);
  222. foreach($albums as $key => $album)
  223. {
  224. $images = $ghss->hss_get_album_images($album['album_id']);
  225. $album_dir = hss_get_album_url($album['album_id']);//HSS_PLUGIN_UPLOADS_URL . '/' . $album['album_id']."_".$album['name'];
  226. if ($images && !empty($images) && is_array($images)) {
  227. foreach($images as $key => $img)
  228. {
  229. if($img['status'] == 0 ) continue;
  230. $categories .= ' <pic url="'.$img['link'].'" target="'.$ops['target'].'"
  231. FindMoreColorBack="0x'.$ops['FindMoreColorBack'].'" FindMoreColorText="0x'.$ops['FindMoreColorText'].'" FindMoreAlpha="'.$ops['FindMoreAlpha'].'" FindMoreButtonColor="0x'.$ops['FindMoreButtonColor'].'" FindMoreButtonTextColor ="0x'.$ops['FindMoreButtonTextColor'].'" ';
  232. $categories .= " pic=\"".str_replace(" ","-",$album_dir)."/big/{$img['image']}\">";
  233. $categories .= '<FindMoreName><![CDATA['.$ops['FindMoreName'].']]></FindMoreName> ';
  234. if ($ops['showDesBigTxt'] == 1) {
  235. $FindMoreText = '<![CDATA['.$img['description'].']]>';
  236. }else{
  237. $FindMoreText = '';
  238. }
  239. $categories .= '<FindMoreText>'.$FindMoreText.'</FindMoreText> ';
  240. if ($ops['showDesSmlTxt'] == 1) {
  241. $FindMoreSText = '<![CDATA['.$img['description2'].']]>';
  242. }else{
  243. $FindMoreSText = '';
  244. }
  245. $categories .= '<FindMoreSText>'.$FindMoreSText.'</FindMoreSText> ';
  246. $categories .= '<menuText><![CDATA['.$img['title'].']]></menuText>
  247. </pic>
  248. ';
  249. }
  250. }
  251. }
  252. //$xml_filename = "hss_all.xml";
  253. }
  254. $xml_tpl = __get_hss_xml_template();
  255. $settings = __get_hss_xml_settings();
  256. $xml = str_replace(array('{settings}', '{categories}'),
  257. array($settings, $categories), $xml_tpl);
  258. //write new xml file
  259. $thisSetting = hss_get_def_settings();
  260. $fh = fopen(HSS_PLUGIN_XML_DIR . '/' . $xml_filename, 'w+');
  261. fwrite($fh, $xml);
  262. fclose($fh);
  263. //print "<h3>Generated filename: $xml_filename</h3>";
  264. //print $xml;
  265. if( file_exists(HSS_PLUGIN_XML_DIR . '/' . $xml_filename ) )
  266. {
  267. $fh = fopen(HSS_PLUGIN_XML_DIR . '/' . $xml_filename, 'r');
  268. $xml = fread($fh, filesize(HSS_PLUGIN_XML_DIR . '/' . $xml_filename));
  269. fclose($fh);
  270. //print "<h3>Getting xml file from cache: $xml_filename</h3>";
  271. $ret_str = '<script type="text/javascript" src="'.HSS_PLUGIN_URL.'/js/swfobject.js"></script>
  272. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  273. <script type="text/javascript" src="'.HSS_PLUGIN_URL.'/js/jquery.touchSwipe.js"></script>
  274. <script type="text/javascript">
  275. var flashvars = {
  276. maxwidth: "'.$ops['bannerWidth'].'",
  277. maxheight: "'.$ops['bannerHeight'].'",
  278. imagewidth: "'.$ops['imagewidth'].'",
  279. baseColor: "'.$ops['baseColor'].'",
  280. xmlfileurl: "'.HSS_PLUGIN_URL.'/xml/'.$xml_filename.'"
  281. };
  282. var params = {
  283. bgcolor: "'.$ops['backgroundColor'].'",
  284. wmode : "'.$ops['wmode'].'"
  285. };
  286. var attributes = {
  287. id: "homepage_slideshow"
  288. };
  289. pluginPath = "'.HSS_PLUGIN_URL.'";
  290. filename = "'.$xml_filename.'";
  291. swfobject.embedSWF("'.HSS_PLUGIN_URL.'/js/wp-hss.swf", "homepageSlideshowInner", "'.$ops['bannerWidth'].'px", "'.$ops['bannerHeight'].'<?php echo $bannerHeight; ?>px", "10.0.0", false, flashvars, params, attributes);
  292. </script>
  293. <script type="text/javascript" src="'.HSS_PLUGIN_URL.'/js/jquery.homepage.slider.js"></script>
  294. <div id="homepageSlideshow"><div id="homepageSlideshowInner"></div></div>';
  295. $not_used_now = "
  296. <script language=\"javascript\">AC_FL_RunContent = 0;</script>
  297. <script src=\"".HSS_PLUGIN_URL."/js/AC_RunActiveContent.js\" language=\"javascript\"></script>
  298. <script language=\"javascript\">
  299. if (AC_FL_RunContent == 0) {
  300. alert(\"This page requires AC_RunActiveContent.js.\");
  301. } else {
  302. AC_FL_RunContent(
  303. 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
  304. 'width', '".$ops['bannerWidth']."',
  305. 'height', '".$ops['bannerHeight']."',
  306. 'src', '".HSS_PLUGIN_URL."/js/wp_homepageslideshow',
  307. 'quality', 'high',
  308. 'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
  309. 'align', 'middle',
  310. 'play', 'true',
  311. 'loop', 'true',
  312. 'scale', 'showall',
  313. 'wmode', '".$ops['wmode']."',
  314. 'devicefont', 'false',
  315. 'id', 'xmlswf_vmhss',
  316. 'bgcolor', '".$ops['backgroundColor']."',
  317. 'name', 'xmlswf_vmhss',
  318. 'menu', 'true',
  319. 'allowFullScreen', 'true',
  320. 'allowScriptAccess','sameDomain',
  321. 'movie', '".HSS_PLUGIN_URL."/js/wp_homepageslideshow',
  322. 'salign', '',
  323. 'flashVars','url=".HSS_PLUGIN_URL."/xml/$xml_filename'
  324. ); //end AC code
  325. }
  326. </script>
  327. ";
  328. //echo HSS_PLUGIN_UPLOADS_URL."<hr>";
  329. // print $xml;
  330. return $ret_str;
  331. }
  332. return true;
  333. }
  334. function __get_hss_xml_template()
  335. {
  336. $xml_tpl = '<?xml version="1.0" encoding="iso-8859-1"?>
  337. <slideshow >
  338. {settings}
  339. {categories}
  340. </slideshow>';
  341. return $xml_tpl;
  342. }
  343. ?>