[ Index ] |
PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Wrapper Frontend Render Script for MediaBoxAdvanced 5 * 6 * Will replace MooTools 1.2 based Lightbox effect 7 * and handle [MEDIABOX] replacement tags. 8 * 9 * Sample Quicktime, white|black|my.css CSS 10 * <!-- MEDIABOX: white | @@More@@ -->[MEDIABOX quicktime|640 360|My Private Video]http://symboleffects.com/media/2007vfx.mov[/MEDIABOX] 11 */ 12 13 $mediaBox = array( 14 15 // set the CSS which should be used for mediaBox 16 // available by default: mediaboxAdvBlack.css, mediaboxAdvWhite.css 17 'css' => 'mediaboxAdvBlack21.css', 18 19 // default linktext 20 'linktext' => '@@More@@' 21 22 ); 23 24 25 // check if current JS Lib is MooTools 1.2 otherwise it will not load 26 if(PHPWCMS_JSLIB != 'mootools-1.2' || ( strpos($content['all'], '[MEDIABOX') === false && strpos($content['all'], 'rel="lightbox') === false ) ) { 27 28 // remove all [MEDIABOX] replacement tags 29 $content['all'] = preg_replace( array('/\[MEDIABOX.*?\]/i', '/\[\/MEDIABOX\]/i'), '', $content['all'] ); 30 31 } else { 32 33 // unset Slimbox CCC and JS 34 unset( 35 $block['custom_htmlhead']['lightbox.css'], 36 $block['custom_htmlhead']['slimbox.js'] 37 ); 38 39 // Set CSS color and/or More Text: 40 // <!-- MEDIABOX: black | @@More@@ --> 41 // <!-- MEDIABOX: white | @@More@@ --> 42 // <!-- MEDIABOX: myCustomMediaBox.css | @@More@@ --> 43 if(preg_match('/<!-- MEDIABOX:(.+?)-->/', $content['all'], $match)) { 44 45 $match = explode('|', trim($match[1]), 2); 46 $match[0] = trim($match[0]); 47 if($match[0] == 'black') { 48 $mediaBox['css'] = 'mediaboxAdvBlack21.css'; 49 } elseif($match[0] != 'white') { 50 $mediaBox['css'] = $match[0]; 51 } else { 52 $mediaBox['css'] = 'mediaboxAdvWhite21.css'; 53 } 54 $match[1] = empty($match[1]) ? '' : trim($match[1]); 55 if($match[1]) { 56 $mediaBox['linktext'] = $match[1]; 57 } 58 } 59 60 initJSLIb(); 61 62 // load mediaBox JavaScript and CSS 63 set_css_link( 'lib/mediabox/css/'.$mediaBox['css'] ); 64 initJSPlugin('Quickie-yui'); 65 $block['custom_htmlhead']['mediabox.js'] = getJavaScriptSourceLink(TEMPLATE_PATH.'lib/mediabox/mediaboxAdv-yui.js'); 66 $block['custom_htmlhead']['mediaboxvars.js'] = ' <script type="text/javascript">'.LF; 67 $block['custom_htmlhead']['mediaboxvars.js'] .= ' NonverBlasterPath="'.PHPWCMS_URL.TEMPLATE_PATH.'lib/nonverblaster/NonverBlaster.swf";'.LF; 68 $block['custom_htmlhead']['mediaboxvars.js'] .= ' JWPlayerPath="'.PHPWCMS_URL.TEMPLATE_PATH.'lib/jw_media_player/player.swf";'.LF; 69 $block['custom_htmlhead']['mediaboxvars.js'] .= ' </script>'; 70 71 72 // parse and render MEDIABOX 73 $content['all'] = preg_replace_callback('/\[MEDIABOX(.*?)\](.*?)\[\/MEDIABOX\]/is', 'renderMediaBox', $content['all']); 74 75 } 76 77 function renderMediaBox($match) { 78 79 $types = array('twitter', 'social', 'flash', 'audio', 'inline', 'external', 'quicktime'); 80 81 $set = trim($match[1]); 82 $inner = trim($match[2]); 83 84 $type = ''; 85 $caption = ''; 86 $url = ''; 87 $linktext = ''; 88 $html = ''; 89 $size = ''; 90 $lightbox = ''; 91 92 // define type, size, caption - elements divided by pipe | 93 $set = explode('|', $set, 3); 94 foreach($set as $key => $item) { 95 96 $item = trim($item); 97 if($item == '') { 98 continue; 99 } 100 if($type == '' && in_array(strtolower($item), $types)) { 101 $type = strtolower($item); 102 continue; 103 } 104 if(!$size && preg_match('/^([0-9]+).([0-9]+)$/', $item, $s)) { 105 $size = intval($s[1]) . ' ' . intval($s[2]); 106 continue; 107 } 108 109 $caption = $item; 110 111 break; 112 } 113 114 // check inner elements - elements divided by pipe | 115 // it is formatted this way: url | linktext 116 $inner = explode('|', $inner, 2); 117 $inner[0] = trim($inner[0]); 118 $inner[1] = empty($inner[1]) ? '' : trim($inner[1]); 119 if($inner[1]) { 120 $linktext = $inner[1]; 121 } elseif($caption) { 122 $linktext = explode('::', $caption); 123 $linktext = trim($linktext[0]); 124 } 125 if($linktext == '') { 126 $linktext = $GLOBALS['mediaBox']['linktext']; 127 } 128 129 // test if first element is URL 130 if( preg_match('/^http|https:\/\//i', $inner[0]) ) { 131 $url = $inner[0]; 132 } 133 134 // test against .flv, .mp3, .mp4, .aac, .m4a 135 if( preg_match('/(\.flv|\.mp3|\.mp4|\.m4a|\.aac|\.mov|\.m4v|\.aiff|\.avi|\.caf|\.dv|\.mid|\.m3u|\.mp2|\.qtz|\.f4v|\.f4p|\.f4a|\.f4b)$/i', $inner[0], $ext) ) { 136 137 $ext = strtolower($ext[1]); 138 $url = $inner[0]; 139 140 // set type Flash (Video) 141 if($ext === '.flv' || $ext === '.mp4' || $ext === '.m4v') { 142 $type = 'flash'; 143 } elseif($ext === '.mp3' || $ext === '.m4a' || $ext === '.aac' || $ext === '.f4a' || $ext === '.f4b') { 144 $type = 'audio'; 145 } else { 146 $type = 'quicktime'; 147 } 148 149 } 150 151 // what to do if URL is empty 152 if($url == '') { 153 $type = 'inline'; 154 $html = $inner[0]; 155 } 156 157 if($type != 'inline') { 158 159 if($type == 'audio' && $size == '') { 160 $size = '350 20'; 161 } 162 163 $lightbox = '<a href="' . html_specialchars($url) . '" '; 164 $lightbox .= 'rel="lightbox[' . trim( $type . ' ' . $size ) . ']"'; 165 $lightbox .= ' title="' . html_specialchars( $caption ? $caption : $linktext ) . '"'; 166 $lightbox .= '>' . html_specialchars( $linktext ) . '</a>'; 167 168 } else { 169 170 $id = 'mb_inline_' . generic_string(6, 1); 171 172 $lightbox = '<a href="#' . $id . '" '; 173 $lightbox .= 'rel="lightbox[' . trim( $type . ' ' . $size ) . ']"'; 174 $lightbox .= ' title="' . html_specialchars( $caption ? $caption : $linktext ) . '"'; 175 $lightbox .= '>' . html_specialchars( $linktext ) . '</a>'; 176 $lightbox .= LF . '<div id="' . $id . '" style="display:none;">'; 177 $lightbox .= $html; 178 //$lightbox .= '<p><a href="#" onclick="Mediabox.close();return false;">@@close onClick@@</a></p>'; 179 $lightbox .= '</div>'; 180 181 } 182 183 return $lightbox; 184 185 } 186 187 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Jan 29 16:31:14 2012 | Cross-referenced by PHPXref 0.7.1 |