PageRenderTime 56ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/wordpress/wp-content/plugins/podpress/podpress_theme.php

https://github.com/bill742/verbalbrew
PHP | 285 lines | 241 code | 23 blank | 21 comment | 94 complexity | 87a373ffbdfcdb49f1b6603b7bcf6709 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-3.0, AGPL-1.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. /*
  3. License:
  4. ==============================================================================
  5. Copyright 2006 Dan Kuykendall (email : dan@kuykendall.org)
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-107 USA
  17. */
  18. if (!function_exists('podPress_webContent')) {
  19. function podPress_webContent($podPressTemplateData) {
  20. GLOBAL $podPress, $post;
  21. $divider = ' | ';
  22. $podPressPlayBlockScripts = '';
  23. $podPressContentAll = '';
  24. if ( TRUE === defined('PODPRESS_SHOW_SECTION_MARKERS') AND TRUE === constant('PODPRESS_SHOW_SECTION_MARKERS') ) {
  25. $podpress_section_begin = "<!-- Begin: podPress -->\n";
  26. $podpress_section_end = "\n<!-- End: podPress -->\n";
  27. $podpress_downloadlinks_section_begin = "<!-- Begin: podPress download link line -->\n";
  28. $podpress_downloadlinks_section_end = "\n<!-- End: podPress download link line -->\n";
  29. } else {
  30. $podpress_section_begin = '';
  31. $podpress_section_end = '';
  32. $podpress_downloadlinks_section_begin = '';
  33. $podpress_downloadlinks_section_end = '';
  34. }
  35. if ( TRUE == isset($podPress->settings['do_not_use_the_target_attribute']) AND TRUE === $podPress->settings['do_not_use_the_target_attribute'] ) {
  36. $target_attribute = '';
  37. } else {
  38. $target_attribute = ' target="new"';
  39. }
  40. foreach ($podPressTemplateData['files'] as $key=>$val) {
  41. $podPressContent = '';
  42. $podPressDownloadlinks = '';
  43. $GLOBALS['podPressPlayer']++;
  44. if(empty($val['dimensionW'])) {
  45. $val['dimensionW'] = "''";
  46. }
  47. if(empty($val['dimensionH'])) {
  48. $val['dimensionH'] = "''";
  49. }
  50. $dividerNeeded = false;
  51. $podPressEpisodeTitle = stripslashes(htmlspecialchars_decode(__($val['title'], 'podpress'))); // if the title is not given by the author then it will be a defaultTitle (see podPress_defaultTitles)
  52. if($val['enablePlayer']) {
  53. if($podPressContent != '') {
  54. $podPressContent .= "<br />\n";
  55. }
  56. if ( $podPress->settings['contentAutoDisplayPlayer'] ) {
  57. $style = ' style="display:block;" ';
  58. $style_wrap_1pixelout = ' display:block;';
  59. } else {
  60. $style = ' style="display:none;" ';
  61. $style_wrap_1pixelout = ' display:none;';
  62. }
  63. if ( 'audio_mp3' == $val['type'] AND TRUE == isset($podPress->settings['player']['listenWrapper']) AND TRUE == $podPress->settings['player']['listenWrapper'] AND FALSE == $podPress->settings['enablePodangoIntegration'] AND TRUE == isset($podPress->settings['mp3Player']) AND '1pixelout' == $podPress->settings['mp3Player'] ) {
  64. $podPressContent .= "\n".'<div class="podpress_listenwrapper_container" id="podpress_lwc_'.$GLOBALS['podPressPlayer'].'" style="background-image:url('.PODPRESS_URL.'/images/listen_wrapper.gif);'.$style_wrap_1pixelout.'"><div class="podpress_mp3_borderleft"></div><div class="podpress_1pixelout_container"><div id="podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'"><!-- podPress --></div></div></div>'."\n";
  65. } elseif ( 'audio_mp3' == $val['type'] AND (False == isset($podPress->settings['player']['listenWrapper']) OR FALSE == $podPress->settings['player']['listenWrapper']) AND FALSE == $podPress->settings['enablePodangoIntegration'] AND TRUE == isset($podPress->settings['mp3Player']) AND '1pixelout' == $podPress->settings['mp3Player'] ) {
  66. $podPressContent .= "\n".'<div class="podpress_playerspace podpress_playerspace_'.$val['type'].' podpress_mp3player"'.$style.'><div id="podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'"><!-- podPress --></div></div>'."\n";
  67. } else {
  68. $podPressContent .= "\n".'<div class="podpress_playerspace podpress_playerspace_'.$val['type'].'"><div id="podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'"'.$style.'><!-- podPress --></div></div>'."\n";
  69. }
  70. }
  71. $podPressDownloadlinks .= $podpress_downloadlinks_section_begin.'<div class="podPress_downloadlinks podPress_downloadlinks_'.$val['type'].'">';
  72. if(isset($val['image'])) {
  73. if($val['enableDownload'] && !empty($val['URI'])) {
  74. if ( 0 === strpos($val['type'], 'embed_') ) {
  75. $podPressDownloadlinks .= '<a href="'.$val['URI'].'"'.$target_attribute.' title="'.attribute_escape(sprintf(__('Direct Link to %1$s', 'podpress'), $podPressEpisodeTitle)).'" class="podpress_downloadimglink podpress_downloadimglink_'.$val['type'].'">';
  76. } else {
  77. $podPressDownloadlinks .= '<a href="'.$val['URI'].'"'.$target_attribute.' title="'.attribute_escape(sprintf(__('Download: %1$s', 'podpress'), $podPressEpisodeTitle)).'" class="podpress_downloadimglink podpress_downloadimglink_'.$val['type'].'">';
  78. }
  79. }
  80. $podPressDownloadlinks .= '<img src="'.podPress_url().'images/'.$val['image'].'" class="podPress_imgicon podpress_imgicon_'.$val['type'].'" alt="" />';
  81. if($val['enableDownload'] && !empty($val['URI'])) {
  82. $podPressDownloadlinks .= '</a>';
  83. }
  84. if(!$podPressTemplateData['showDownloadText'] == 'enabled') {
  85. $val['enableDownload'] = false;
  86. }
  87. }
  88. // ntm: this is not in use unless the option at the podPress general settings page will uncommented
  89. if(TRUE == isset($val['enableTorrentDownload']) AND TRUE === $val['enableTorrentDownload']) {
  90. $podPressDownloadlinks .= '<a href="'.$val['URI_torrent'].'"'.$target_attribute.' title="'.attribute_escape(sprintf(__('Download: %1$s - .torrent file', 'podpress'), $podPressEpisodeTitle)).'">';
  91. if(strstr($val['image'], '_button')) {
  92. $torrentimg = 'misc_torrent_button.png';
  93. } else {
  94. $torrentimg = 'misc_torrent_icon.png';
  95. }
  96. $podPressDownloadlinks .= '<img src="'.podPress_url().'images/'.$torrentimg.'" class="podPress_imgicon" alt="" />';
  97. $podPressDownloadlinks .= '</a>';
  98. }
  99. $podPressDownloadlinks .= ' ';
  100. $podPressDownloadlinks .= '<span class="podpress_mediafile_title podpress_mediafile_title_'.$val['type'].'">'.$podPressEpisodeTitle.'</span>';
  101. if ( isset($podPressTemplateData['showDuration']) AND 'disabled' != $podPressTemplateData['showDuration'] AND FALSE == empty($val['duration'])) {
  102. if ( empty($podPressTemplateData['showDuration']) OR 'enabled' == $podPressTemplateData['showDuration'] ) {
  103. $podPressTemplateData['showDuration'] = 'colon';
  104. }
  105. if ( isset($podPress->settings['contentDurationdivider']) ) {
  106. $podPressDownloadlinks .= ' <span class="podpress_mediafile_dursize podpress_mediafile_dursize_'.$val['type'].'">[ '.$podPress->millisecondstostring($podPress->strtomilliseconds($val['duration']), 'h:m:s:ms', $podPress->settings['contentDurationdivider']);
  107. } else {
  108. $podPressDownloadlinks .= ' <span class="podpress_mediafile_dursize podpress_mediafile_dursize_'.$val['type'].'">[ '.$podPress->millisecondstostring($podPress->strtomilliseconds($val['duration']), 'h:m:s:ms');
  109. }
  110. $durationfilesizeseparator = ' | ';
  111. } else {
  112. $durationfilesizeseparator = ' <span class="podpress_mediafile_dursize podpress_mediafile_dursize_'.$val['type'].'">[ ';
  113. }
  114. if ( 'enabled' == $podPressTemplateData['showfilesize'] AND FALSE == empty($val['size']) AND FALSE === stristr($val['type'], 'embed_') ) {
  115. $size_mb = round(($val['size']/1048576), 2);
  116. if ( 0.01 > $size_mb ) {
  117. $size_mb = 0.01;
  118. }
  119. $podPressDownloadlinks .= $durationfilesizeseparator.$size_mb.' '.__('MB', 'podpress').' ]</span>';
  120. } else {
  121. if ( ' <span class="podpress_mediafile_dursize podpress_mediafile_dursize_'.$val['type'].'">[ ' != $durationfilesizeseparator) {
  122. $podPressDownloadlinks .= ' ]</span>';
  123. }
  124. }
  125. if($val['enablePlayer'] || $val['enablePopup'] || $val['enableDownload'] || !$val['authorized']) {
  126. $podPressDownloadlinks .= ' ';
  127. }
  128. if(!$val['authorized']) {
  129. $podPressDownloadlinks .= ' <a href="'.get_option('siteurl').'/wp-login.php" class="podpress_protected_link">'.__('(Protected Content)', 'podpress').'</a><br/>'."\n";
  130. } else {
  131. if($val['enablePlayer']) {
  132. if ($dividerNeeded) {
  133. $hideplayerplaynow_divider = $divider;
  134. } else {
  135. $hideplayerplaynow_divider = '';
  136. }
  137. if ( (TRUE == isset($val['enableTorrentDownload']) AND TRUE == $val['enableTorrentDownload']) OR (TRUE == isset($val['enableTorrentDownload']) AND 'on' == $val['disablePreview']) ) {
  138. $previewVal = 'nopreview';
  139. } else {
  140. $previewVal = 'false';
  141. }
  142. if ($val['enablePlaylink']) {
  143. if ($podPress->settings['contentAutoDisplayPlayer']) {
  144. $podPressDownloadlinks .= '<a href="#podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'" class="podpress_playlink podpress_playlink_'.$val['type'].'" onclick="javascript:podPressShowHidePlayer(\''.$GLOBALS['podPressPlayer'].'\', \''.js_escape($val['URI_Player']).'\', '.strval(intval($val['dimensionW'])).', '.strval(intval($val['dimensionH'])).', \''.$previewVal.'\', \''.$val['previewImage'].'\', \''.js_escape($val['title']).'\', \''.js_escape($val['artist']).'\'); return false;"><span id="podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'_PlayLink" class="podPress_playerspace_playlink">'.$hideplayerplaynow_divider.__('Play Now', 'podpress').'</span></a>';
  145. } else {
  146. $podPressDownloadlinks .= '<a href="#podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'" class="podpress_playlink podpress_playlink_'.$val['type'].'" onclick="javascript:podPressShowHidePlayer(\''.$GLOBALS['podPressPlayer'].'\', \''.js_escape($val['URI_Player']).'\', '.strval(intval($val['dimensionW'])).', '.strval(intval($val['dimensionH'])).', \'force\', \''.$val['previewImage'].'\', \''.js_escape($val['title']).'\', \''.js_escape($val['artist']).'\'); return false;"><span id="podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'_PlayLink" class="podPress_playerspace_playlink">'.$hideplayerplaynow_divider.__('Play Now', 'podpress').'</span></a>';
  147. }
  148. $dividerNeeded = true;
  149. } else {
  150. $podPressDownloadlinks .= '<span id="podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'_PlayLink" style="display:none">'.$hideplayerplaynow_divider.__('Play Now', 'podpress').'</span>';
  151. $dividerNeeded = false;
  152. }
  153. $podPressDownloadlinks .= '<input type="hidden" id="podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'_OrigURL" value="'.attribute_escape($podPress->convertPodcastFileNameToValidWebPath($val['URI_orig'])).'" />';
  154. if ($podPress->settings['contentAutoDisplayPlayer']) {
  155. $podPressPlayBlockScripts .= 'podPressShowHidePlayer(\''.$GLOBALS['podPressPlayer'].'\', \''.js_escape($val['URI_Player']).'\', '.strval(intval($val['dimensionW'])).', '.strval(intval($val['dimensionH'])).', \''.$previewVal.'\', \''.js_escape($val['previewImage']).'\', \''.js_escape($val['title']).'\', \''.js_escape($val['artist']).'\');';
  156. }
  157. }
  158. if ( $val['enablePopup'] AND FALSE === strpos($val['type'], 'ebook_') ) {
  159. if($dividerNeeded) {
  160. $podPressDownloadlinks .= $divider;
  161. }
  162. $podPressDownloadlinks .= '<a href="#podPressPlayerSpace_'.$GLOBALS['podPressPlayer'].'" class="podpress_playinpopup podpress_playinpopup_'.$val['type'].'" onclick="javascript:podPressPopupPlayer(\''.$GLOBALS['podPressPlayer'].'\', \''.js_escape($val['URI_Player']).'\', '.strval(intval($val['dimensionW'])).', '.strval(intval($val['dimensionH'])).', \''.js_escape(get_bloginfo('name')).'\', \''.$post->ID.'\', \''.js_escape($val['title']).'\', \''.js_escape($val['artist']).'\'); return false;">'.__('Play in Popup', 'podpress').'</a>';
  163. $dividerNeeded = true;
  164. }
  165. if($val['enableDownload'] && $podPressTemplateData['showDownloadText'] == 'enabled') {
  166. if($dividerNeeded) {
  167. $podPressDownloadlinks .= $divider;
  168. }
  169. if ( 0 === strpos($val['type'], 'embed_') ) {
  170. $podPressDownloadlinks .= '<a href="'.$val['URI'].'"'.$target_attribute.' class="podpress_downloadlink podpress_downloadlink_'.$val['type'].'">'.__('Direct Link', 'podpress').'</a>';
  171. $val['stats'] = false;
  172. } else {
  173. $podPressDownloadlinks .= '<a href="'.$val['URI'].'"'.$target_attribute.' class="podpress_downloadlink podpress_downloadlink_'.$val['type'].'">'.__('Download', 'podpress').'</a>';
  174. if($val['stats'] && $podPressTemplateData['showDownloadStats'] == 'enabled') {
  175. $podPressDownloadlinks .= ' ('.$val['stats']['total'].')';
  176. $val['stats'] = false;
  177. }
  178. }
  179. $dividerNeeded = true;
  180. }
  181. if($val['stats'] && $podPressTemplateData['showDownloadStats'] == 'enabled') {
  182. if($dividerNeeded) {
  183. $podPressDownloadlinks .= $divider;
  184. }
  185. $podPressDownloadlinks .= ' <span class="podpress_downloadnr podpress_downloadnr_'.$val['type'].'">'.__('Downloads', 'podpress').' '.$val['stats']['total'].'</span>';
  186. $dividerNeeded = true;
  187. }
  188. }
  189. $podPressDownloadlinks .= '</div>'.$podpress_downloadlinks_section_end;
  190. $podPressContentAll .= $podPressContent.apply_filters('podpress_downloadlinks', $podPressDownloadlinks);
  191. }
  192. if ($podPress->settings['contentAutoDisplayPlayer']) {
  193. if ( TRUE === defined('PODPRESS_ADD_CDATA_SECTION_TO_POSTSCRIPT') AND TRUE === constant('PODPRESS_ADD_CDATA_SECTION_TO_POSTSCRIPT') ) {
  194. $cdata_section_begin = '/* <![CDATA[ */ ';
  195. $cdata_section_end = ' /* ]]> */';
  196. } else {
  197. $cdata_section_begin = '';
  198. $cdata_section_end = '';
  199. }
  200. $podPressPlayBlockScripts = apply_filters('podpress_post_scriptblock', '<script type="text/javascript">' . $cdata_section_begin . $podPressPlayBlockScripts . $cdata_section_end . '</script>');
  201. }
  202. return apply_filters('podpress_post_content', $podpress_section_begin.'<div class="podPress_content podPress_content_'.$val['type'].'">'.$podPressContentAll.'</div>'."\n".$podPressPlayBlockScripts.$podpress_section_end);
  203. }
  204. }
  205. if (!function_exists('podPress_defaultTitles')) {
  206. function podPress_defaultTitles($filetype) {
  207. switch($filetype) {
  208. case 'audio_mp3':
  209. case 'audio_ogg':
  210. return __('Standard Podcast', 'podpress');
  211. break;
  212. case 'audio_m4a':
  213. case 'audio_mp4':
  214. return __('Enhanced Podcast', 'podpress');
  215. break;
  216. case 'audio_m3u':
  217. return __('Streaming Audio', 'podpress');
  218. break;
  219. case 'video_m4v':
  220. return __('Podcast Video', 'podpress');
  221. break;
  222. case 'video_mp4':
  223. case 'video_mov':
  224. case 'video_qt':
  225. return __('Podcast Video', 'podpress');
  226. break;
  227. case 'video_ogv':
  228. case 'video_avi':
  229. case 'video_mpg':
  230. case 'video_asf':
  231. case 'video_wmv':
  232. return __('Online Video', 'podpress');
  233. break;
  234. case 'audio_wma':
  235. return __('Online Audio', 'podpress');
  236. break;
  237. case 'video_swf':
  238. return __('Flash Content', 'podpress');
  239. break;
  240. case 'video_flv':
  241. return __('Flash Video', 'podpress');
  242. break;
  243. case 'embed_youtube':
  244. return __('YouTube', 'podpress');
  245. break;
  246. case 'ebook_pdf':
  247. case 'ebook_epub':
  248. return __('eBook', 'podpress');
  249. break;
  250. case 'misc_torrent':
  251. return __('Torrent File', 'podpress');
  252. case 'misc_other':
  253. default:
  254. return __('Other Media', 'podpress');
  255. }
  256. }
  257. }
  258. ?>