settings['full_domain_name'], '/',SITEURL).'/wp-content/plugins/' . PLUGIN_BASENAME.'/'); define('POSTTHUMB_USE_HS', $PTRevisited->settings['hs_use']=='true'); define('POSTTHUMB_USE_TB', $PTRevisited->settings['tb_use']=='true'); // call classes if (POSTTHUMB_USE_HS == 'true') include(PT_ABSPATH . 'lib/post-thumb-highslide.php'); if (POSTTHUMB_USE_TB == 'true') include(PT_ABSPATH . 'lib/post-thumb-thickbox.php'); ################################################################################ ########## MAIN CLASS ################################################################################ class PostThumbRevisited { var $settings; var $post_array = array(); var $wordtube_options; var $playertype; var $playertypemp3; var $wordtube_abspath; var $wt_path = 'wordtube'; var $table_pt_post; var $LoadPostLimit = 200; /** * PostThumbRevisited * * Constructor for the PostThumbRevisited class. */ function PostThumbRevisited () { global $table_prefix, $wpdb, $wp_query; // Load language file $locale = get_locale(); if ( !empty($locale) ) load_textdomain('post-thumb', PT_ABSPATH.'languages/' . 'post-thumb'.$locale.'.mo'); // Insert the menu and options add_option('post_thumbnail_settings','','Post Thumb Revisited Options'); if (function_exists('pt_include_header')) add_action('wp_head', array(&$this, 'pt_include_header')); $this->table_pt_post = $table_prefix . "pt_post"; $this->settings = pt_GetStarterOptions(); $wpdb->wordtube = $table_prefix . 'wordtube'; $wpdb->wordtube_med2play = $table_prefix . 'wordtube_med2play'; if (is_admin()) { include ( PT_ABSPATH . '/post-thumb-options.php' ); $PTAdmin = new PostThumbAdmin($this); } else { if (is_feed()) { $PTRevisited->settings['hs_use']='false'; $PTRevisited->settings['tb_use']='false'; } $this->GetPostList(); } // add filters if ($this->settings['pt_replace'] == 'true') add_filter('the_content', array(&$this, 'pt_ReplaceImage'), 31); if ($this->settings['hs_post'] == 'true') { add_filter('the_content', array(&$this, 'pt_ReplaceThumbnails')); if ($this->settings['hs_wordtube'] == 'true') { $this->InitWordTube(); if ($this->settings['wt_media'] == 'true') add_filter('the_content', array(&$this, 'pt_ReplaceWTMedia')); if ($this->settings['wt_playlist'] == 'true') add_filter('the_content', array(&$this, 'pt_ReplaceWTPlaylist')); } if ($this->settings['hs_youtube'] == 'true') add_filter('the_content', array(&$this, 'pt_ReplaceYoutube')); } } /***********************************************************************************/ /* Retrieve posts informations /***********************************************************************************/ function GetPostList () { global $wpdb; if($wpdb->get_var("show tables like '$this->table_pt_post'") == $this->table_pt_post) { $dbresults = $wpdb->get_results(" SELECT * FROM ".$this->table_pt_post." ORDER BY post_id DESC LIMIT ".$this->LoadPostLimit); if ($dbresults) { foreach ($dbresults as $dbresult) : $this->post_array[$dbresult->post_id] = stripslashes($dbresult->body); endforeach; } unset($dbresults); } } /***********************************************************************************/ /* Get thumbnail. Loop function. /***********************************************************************************/ function GetPostData ($key) { if (array_key_exists($key, $this->post_array)) return unserialize($this->post_array[$key]); else return ''; } /***********************************************************************************/ /* Get thumbnail. Loop function. /***********************************************************************************/ function GetThumb ($arg='') { global $post; setup_postdata($post); return $this->GetSingleThumb ($post, $arg, $beforeli, $afterli, $this->GetPostData($post->ID)); } /***********************************************************************************/ /* Get thumbnail. Loop function. /***********************************************************************************/ function GetSingleThumb ($post, $arg='', $before='', $after='', $post_array='') { $path = pathinfo($post_array['media_url']); if ($post_array['media_url'] != '' && $path['extension']=='') { $p = new pt_post_thumbnail( $this->settings, $post, $arg, $post_array['image_url'], $post_array['media_url'], $post_array['permalink'], $post_array['title'], $post_array['date'], $post_array['author'], true); $p->InitWordTube($this->wordtube_options, $this->playertype); $post_link = $p->pt_GetImgHTML(); unset ($p); } if ($post_array['media_url'] != '') { $p = new pt_post_thumbnail( $this->settings, $post, $arg, $post_array['image_url'], $post_array['media_url'], $post_array['permalink'], $post_array['title'], $post_array['date'], $post_array['author'], true); $p->InitWordTube($this->wordtube_options, $this->playertype); $post_link = $p->pt_GetImgHTML(); unset ($p); } elseif ($post_array['image_url'] != '') { $p = new pt_post_thumbnail( $this->settings, $post, $arg, $post_array['image_url'], $post_array['media_url'], $post_array['permalink'], $post_array['title'], $post_array['date'], $post_array['author'], true); $post_link = $p->pt_GetImgHTML(); unset ($p); } else { $p = new pt_post_thumbnail($this->settings, $post, $arg); $post_link = $p->pt_GetImgHTML(); unset ($p); } if ( !empty($post_link) ) return $before.$post_link.$after; else return ''; } /***********************************************************************************/ /* Returns recent posts /***********************************************************************************/ function GetTheRecentThumbs ($arg='', $beforeli='', $afterli='', $before='', $after='') { // Create a query object to retrieve posts $my_query = new WP_Query(); parse_str($arg, $new_args); $new_args = array_change_key_case($new_args, CASE_UPPER); // Retrieves specific parameters if (isset($new_args['MEDIA'])) $media = $new_args['MEDIA']; else $media = 'all'; if (isset($new_args['LIMIT'])) { $limit = $new_args['LIMIT']; settype($limit,"integer"); } else $limit = 8; if (isset($new_args['OFFSET'])) { $offset = $new_args['OFFSET']; settype($offset,"integer"); } else $offset = 0; if (isset($new_args['CATEGORY'])) { $cat_ID = $new_args['CATEGORY'];$catid = explode(',', $cat_ID);$cat_arg = '&cat='.$cat_ID; } else {$cat_arg = '';$cat_ID='';$catid=array();} $content = $before; $l = $limit+$offset; // Retrieve only images if ($media == '0') { $i = 1; foreach ($this->post_array as $key => $post_arrayS) : $post_array = $this->GetPostData($key); if ($i > $l) break; if ($i > $offset) { if ($post_array['media_url'] == '' && $this->in_category($post_array, $catid)) { $content .= $this->GetSingleThumb ('', $arg, $beforeli, $afterli, $post_array); $i++; } } else { if ($post_array['media_url'] == '' && in_category($post_array, $cat_ID)) $i++; } endforeach; } // Retrieve non-youtube media elseif ($media == '1') { $i = 1; foreach ($this->post_array as $key => $post_arrayS) : $post_array = $this->GetPostData($key); if ($i > $l) break; if ($i > $offset) { if ($post_array['media_url'] != '' && $this->in_category($post_array, $catid)) { $path = pathinfo($post_array['media_url']); if ($path['extension'] != '') { $content .= $this->GetSingleThumb ('', $arg, $beforeli, $afterli, $post_array); $i++; } } } else { if ($post_array['media_url'] != '') $i++; } endforeach; } // Retrieve youtube media elseif ($media == '2') { $i = 1; foreach ($this->post_array as $key => $post_arrayS) : $post_array = $this->GetPostData($key); if ($i > $l) break; if ($i > $offset) { if ($post_array['media_url'] != '' && $this->in_category($post_array, $catid)) { $path = pathinfo($post_array['media_url']); if ($path['extension'] == '') { $content .= $this->GetSingleThumb ('', $arg, $beforeli, $afterli, $post_array); $i++; } } } else { if ($post_array['media_url'] != '') { $path = pathinfo($post_array['media_url']); if ($path['extension'] == '') $i++; } } endforeach; } // Retrieve all-media elseif ($media == '3') { $i = 1; foreach ($this->post_array as $key => $post_arrayS) : $post_array = $this->GetPostData($key); if ($i > $l) break; if ($i > $offset) { if ($post_array['media_url'] != '' && $this->in_category($post_array, $catid)) { $content .= $this->GetSingleThumb ('', $arg, $beforeli, $afterli, $post_array); $i++; } } else { if ($post_array['media_url'] != '') $i++; } endforeach; } else { $posts = $my_query->query('showposts='.$limit.'&offset='.$offset.$cat_arg); foreach ($posts as $post) : $post_array = $this->GetPostData($post->ID); $content .= $this->GetSingleThumb ($post, $arg, $beforeli, $afterli, $post_array); endforeach; unset ($my_query); unset ($posts); } $content .= $after; return $content; } /****************************************************************/ /* Returns true if post is in category id /****************************************************************/ function in_category($post_array, $catid='') { if ($catid[0] == '') return true; if ($catid[0] < 0) { $catid= explode('-', implode('', $catid)); return (count(array_intersect($catid, unserialize($post_array['categories']))) == 0); } else return (count(array_intersect($catid, unserialize($post_array['categories']))) != 0); } /***********************************************************************************/ /* Return random thumbnails. /* /* LIMIT: number of thumbnail to display. Default is 1. /***********************************************************************************/ function GetRandomThumb ($arg='', $beforeli='', $afterli='', $before='', $after='') { parse_str($arg, $new_args); $new_args = array_change_key_case($new_args, CASE_UPPER); // Retrieves specific parameters if (isset($new_args['LIMIT'])) { $limit = $new_args['LIMIT']; settype($limit,"integer"); } else $limit = 1; if (isset($new_args['CATEGORY'])) $catid = explode(',', $new_args['CATEGORY']); else $catid =array(); if (isset($new_args['ALTAPPEND'])) $altappend = $new_args['ALTAPPEND']; else $altappend = 'azerty123456789'; if (isset($new_args['BASENAME'])) $basename = ($new_args['BASENAME'] == 1); else $basename = false; $posts = $this->RandomId($limit, $catid); if ($limit == 1) $random_str = $this->GetSingleThumb ('', $arg.'&ALTAPPEND='.$altappend, $beforeli, $afterli, $this->GetPostData($posts)); else { $i = 1; foreach ($posts as $post) : if ($basename) $add = $i; else $add = ''; $random_str .= $this->GetSingleThumb ('', $arg.'&ALTAPPEND='.$altappend.$add, $beforeli, $afterli, $this->GetPostData($post)); $i++; endforeach; } return $random_str; } /****************************************************************/ /* Returns displayable post content /****************************************************************/ function RandomId($limit=1, $catid='') { if ($catid[0] == '') $ret = array_rand ($this->post_array, $limit); else { $rand = array(); $i = 0; foreach ($this->post_array as $key => $post_arrayS) : $post_array = $this->GetPostData($key); if ($this->in_category($post_array, $catid)) { $rand[$key]=$post_array; $i++; } endforeach; if ($i < $limit) $limit = $i; $ret = array_rand ($rand, $limit); } unset($rand); return $ret; } /****************************************************************/ /* Returns displayable post content /****************************************************************/ function pt_TheExcerpt($length=40, $title_after= false, $arg='') { global $post; setup_postdata($post); $p = new pt_post_thumbnail($this->settings, $post, $arg); $post_link = $p->pt_GetImgHTML(); unset ($p); $post->post_content = exclude_regex($post->post_content); $excerpt = get_excerpt_revisited($length); if ($title_after) $title = '

'.get_the_title().'

'; else $title = ''; // Display everything echo $post_link; echo $title; echo $excerpt; } /****************************************************************/ /* Filter function (if Highslide is activated) /****************************************************************/ function pt_ReplaceWTMedia($content) { $return = $this->pt_CleanWTMedia($content); // Replace wordTube MEDIA with parameters $pattern = '/\[MEDIA=([0-9]+%?)\]/i'; if (preg_match_all($pattern, $return, $matches, PREG_SET_ORDER)) { $play_width = $this->settings['wordtube_pwidth']; $play_height = $this->settings['wordtube_pheight']; foreach ($matches as $match) : $replacement = $this->pt_GetwordTubeMedia($match[1], $play_width, $play_height); $return = str_replace($match[0], $replacement, $return); $i++; endforeach; } $pattern = '/\[MEDIA=([0-9]+%?)(.*?)\]/i'; if (preg_match_all($pattern, $return, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : $str_match = strtoupper($match[0]); if (preg_match('/\[(.*?)WIDTH=([0-9]+%?)(.*?)\]/i', $str_match, $foo3)) $play_width = $foo3[2]; else $play_width = $this->settings['wordtube_pwidth']; if (preg_match('/\[(.*?)HEIGHT=([0-9]+%?)(.*?)\]/i', $str_match, $foo4)) $play_height = $foo4[2]; else $play_height = $this->settings['wordtube_pheight']; $replacement = $this->pt_GetwordTubeMedia($match[1], $play_width, $play_height); $return = str_replace($match[0], $replacement, $return); $i++; endforeach; } return $return; } /****************************************************************/ /* Filter function (if Highslide is activated) /****************************************************************/ function pt_ReplaceWTPlaylist($content) { global $wpdb; $return = $this->pt_CleanWTPlaylist($content); // Replace wordTube post-thumb ptplaylist $pattern = '/\[PTPLAYLIST=\((.*?)\)(.*?)]/i'; if (preg_match_all($pattern, $return, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : $str_match = strtoupper($match[0]); $vid_array = explode(",",$match[1]); if ($match[1] != '0') $where = "WHERE vid IN ('" . implode("','", $vid_array) . "')"; $dbresults = $wpdb->get_results("SELECT * FROM $wpdb->wordtube $where"); if ($dbresults) { $replacement = ''; $mp3 = strpos($str_match, 'MP3'); $flv = strpos($str_match, 'FLV'); if (preg_match('/\[(.*?)WIDTH=([0-9]+%?)(.*?)\]/i', $str_match, $foo3)) $play_width = $foo3[2]; else $play_width = $this->settings['wordtube_pwidth']; if (preg_match('/\[(.*?)HEIGHT=([0-9]+%?)(.*?)\]/i', $str_match, $foo4)) $play_height = $foo4[2]; else $play_height = $this->settings['wordtube_pheight']; foreach ($dbresults as $media) : $replacement .= $this->pt_ReturnMediaFromPlaylist($media, $play_width, $play_height, $mp3, $flv); endforeach; $return = str_replace($match[0], $replacement, $return); } unset($dbresults); $i++; endforeach; } // Replace wordTube ptplaylist $pattern = '/\[PTPLAYLIST=([0-9]+%?)(.*?)]/i'; if (preg_match_all($pattern, $return, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : $str_match = strtoupper($match[0]); $dbresults = $this->pt_GetwordTubePlaylist($match[1]); if ($dbresults) { $replacement = ''; $mp3 = strpos($str_match, 'MP3'); $flv = strpos($str_match, 'FLV'); if (preg_match('/\[(.*?)WIDTH=([0-9]+%?)(.*?)\]/i', $str_match, $foo3)) $play_width = $foo3[2]; else $play_width = $this->settings['wordtube_pwidth']; if (preg_match('/\[(.*?)HEIGHT=([0-9]+%?)(.*?)\]/i', $str_match, $foo4)) $play_height = $foo4[2]; else $play_height = $this->settings['wordtube_pheight']; foreach ($dbresults as $media) : $replacement .= $this->pt_ReturnMediaFromPlaylist($media, $play_width, $play_height, $mp3, $flv); endforeach; $return = str_replace($match[0], $replacement, $return); } unset($dbresults); endforeach; } return $return; } /****************************************************************/ /* Filter function (if Highslide is activated) /****************************************************************/ function pt_CleanWTPlaylist($content) { // Replace wordTube post-thumb ptplaylist $pattern = '/\

\[PTPLAYLIST=(.*?)]\<\/p>/i'; if (preg_match_all($pattern, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : $replacement = '[PTPLAYLIST='.$match[1].'(.*?)]'; $content = str_replace($match[0], $replacement, $content); endforeach; } return $content; } /****************************************************************/ /* Filter function (if Highslide is activated) /****************************************************************/ function pt_CleanWTMedia($content) { // Replace wordTube MEDIA with parameters $pattern = '/\

\[MEDIA=(.*?)\]\<\/p>/i'; if (preg_match_all($pattern, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : $replacement = '[MEDIA='.$match[1].'(.*?)]'; $content = str_replace($match[0], $replacement, $content); endforeach; } return $content; } /****************************************************************/ /* Returns wordTube media /****************************************************************/ function pt_ReturnMediaFromPlaylist($media, $play_width, $play_height, $mp3, $flv, $arg='') { if ($mp3 || $flv) { $med_url = pathinfo($media->file); if ($mp3) { if (strtoupper($med_url['extension']) == 'MP3') { $replacement = $this->pt_GetVideo($media->name, $media->file, $media->image, $play_width, $play_height, $arg, $media->vid); } } if ($flv) { if (strtoupper($med_url['extension']) == 'FLV') { $replacement = $this->pt_GetVideo($media->name, $media->file, $media->image, $play_width, $play_height, $arg, $media->vid); } } } else $replacement = $this->pt_GetVideo($media->name, $media->file, $media->image, $play_width, $play_height, $arg, $media->vid); return $replacement; } /****************************************************************/ /* Returns wordTube media /****************************************************************/ function pt_GetwordTubeMedia($vid, $play_width, $play_height, $arg='') { global $wpdb; $select = " SELECT * FROM $wpdb->wordtube WHERE vid = ".$vid; $media = $wpdb->get_row($select); if ($media) return $this->pt_GetVideo($media->name, $media->file, $media->image, $play_width, $play_height, $arg, $vid); else return ''; } /****************************************************************/ /* Returns wordTube playlist /****************************************************************/ function pt_GetwordTubePlaylist($pid) { global $wpdb; if ($pid == '0') $select = " SELECT * FROM {$wpdb->wordtube} ORDER BY vid DESC"; else $select = " SELECT * FROM {$wpdb->wordtube} w INNER JOIN {$wpdb->wordtube_med2play} m WHERE (m.playlist_id = '".$pid."' AND m.media_id = w.vid) GROUP BY w.vid ORDER BY m.rel_id DESC"; return $wpdb->get_results($select); } /****************************************************************/ /* Returns formatted wordTube playlist /****************************************************************/ function pt_GetWTMedia ($vid, $arg='', $play_width=0, $play_height=0) { if ($play_width == 0) $play_width = $this->settings['wordtube_pwidth']; if ($play_height == 0) $play_height = $this->settings['wordtube_pheight']; $replacement = $this->pt_GetwordTubeMedia($vid, $play_width, $play_height, $arg); return $replacement; } /****************************************************************/ /* Returns formatted wordTube playlist /****************************************************************/ function pt_GetWTPlaylist($pid, $arg='', $play_width=0, $play_height=0, $mp3=false, $flv=false) { if ($play_width == 0) $play_width = $this->settings['wordtube_pwidth']; if ($play_height == 0) $play_height = $this->settings['wordtube_pheight']; parse_str($arg, $new_args); $new_args = array_change_key_case($new_args, CASE_UPPER); if (isset($new_args['LIMIT'])) { $limit = $new_args['LIMIT']; settype($limit,"integer"); } else $limit = 5; if (isset($new_args['OFFSET'])) { $offset = $new_args['OFFSET']; settype($offset,"integer"); } else $offset = 0; $l = $limit+$offset; $dbresults = $this->pt_GetwordTubePlaylist($pid); if ($dbresults) { $replacement = ''; $i=1; foreach ($dbresults as $media) : if ($i > $l) break; if ($i > $offset) $replacement .= $this->pt_ReturnMediaFromPlaylist($media, $play_width, $play_height, $mp3, $flv, $arg); $i++; endforeach; } unset ($dbresults); return $replacement; } /****************************************************************/ /* Filter function (if Highslide is activated) /****************************************************************/ function pt_ReplaceThumbnails($content) { $r_ID = rand(); // Replace thumbnail $pattern = '/(.*?)/is'; if (preg_match_all($pattern,$content,$matches, PREG_SET_ORDER)) { $i=1; foreach ($matches as $match) : $ID = $r_ID.$i; $href = "\n".''; $img_src = "\n\t".''.$match[9].''; $caption = "\n".'

'.$match[9].'
'; $replacement = $href.$img_src.$caption; $content = str_replace($match[0], $replacement, $content); $i++; endforeach; } return $content; } /****************************************************************/ /* Filter function (if Highslide is activated) /****************************************************************/ function pt_ReplaceImage($content) { // Thumbnails image and replace $pattern = '//is'; if (preg_match_all($pattern, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : str_replace ("

\n".$match[0]."\n

", $match[0], $content); $replacement = $this->pt_MakeThumb($match); $content = str_replace($match[0], $replacement, $content); endforeach; } $pattern = '//is'; if (preg_match_all($pattern, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : str_replace ("

".$match[0]."

", $match[0], $content); $match2 = array( 1 => $match[1], 2 => $match[3], 3 => $match[4], 4 => $match[2], 5 => $match[5]); $replacement = $this->pt_MakeThumb($match2); $content = str_replace($match[0], $replacement, $content); endforeach; } return $content; } /****************************************************************/ /* Filter function (if Highslide is activated) /****************************************************************/ function pt_ReplaceYoutube($content) { // Replace Youtube $pattern1 = '/\[youtube=\((.*?)\)(.*?)\]/i'; $pattern2 = '@\@i'; $pattern3 = '/\(.*?)\<\/object>/is'; $pat_title = '/(.*?)title="(.*?)"/i'; if (preg_match_all($pattern2, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : if (preg_match($pat_title, $match[0], $mat_title)) $title = $mat_title[2]; else $title = ''; $thumb = 'http://img.youtube.com/vi/'.$match[2].'/0.jpg" width="'.$this->settings['youtube_width'].'" height="'.$this->settings['youtube_height']; $replacement = SetYoutubeVideo ($match[2], $title, $thumb, $this->settings); $content = str_replace($match[0],$replacement, $content); endforeach; } if (preg_match_all($pattern3, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : str_replace ('

'.$match[0].'

', $match[0], $content); if (preg_match($pat_title, $match[0], $mat_title)) $title = $mat_title[2]; else $title = ''; $thumb = 'http://img.youtube.com/vi/'.$match[2].'/0.jpg" width="'.$this->settings['youtube_width'].'" height="'.$this->settings['youtube_height']; $replacement = SetYoutubeVideo ($match[2], '', $thumb, $this->settings); $content = str_replace($match[0],$replacement, $content); endforeach; } if (preg_match_all($pattern1, $content, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) : $thumb = 'http://img.youtube.com/vi/'.$match[1].'/0.jpg" width="'.$this->settings['youtube_width'].'" height="'.$this->settings['youtube_height']; if (preg_match($pat_title, $match[0], $mat_title)) $title = $mat_title[2]; else $title = ''; $replacement = SetYoutubeVideo ($match[1], $title, $thumb, $this->settings); $content = str_replace($match[0],$replacement, $content); endforeach; } return $content; } /****************************************************************/ /* Filter function (if Highslide is activated) /****************************************************************/ function pt_MakeThumb($match) { // Initialize parameters $the_image = $match[2].'.'.$match[3]; $tags = $match[1].$match[4].$match[5]; // Extract alt attribute $pattern = '/(.*?)alt="(.*?)"(.*?)/i'; if (preg_match($pattern,$tags,$patch)) { $alt_text = $patch[2]; } // Extract title attribute $title = $alt_text; $pattern = '/(.*?)title="(.*?)"(.*?)/i'; if (preg_match($pattern,$tags,$patch)) { $title = $patch[2]; } // Extract align attribute $pattern = '/(.*?)align="(.*?)"(.*?)/i'; if (preg_match($pattern,$tags,$patch)) { $align = 'align="'.$patch[2].'"'; } // Set post-thumb additionnal parameter if ($this->settings['p_rounded'] == 'true') $p_rounded = 1; else $p_rounded = 0; if ($this->settings['p_keep_ratio'] == 'true') $p_keep_ratio = 1; else $p_keep_ratio = 0; $has_caption = ($this->settings['p_caption'] == 'true'); // Prepare parameter for thumbnail $arg = 'ALTAPPEND='.$this->settings['p_append_text']. '&WIDTH='.$this->settings['p_resize_width']. '&HEIGHT='.$this->settings['p_resize_height']. '&ROUNDED='.$p_rounded. '&KEEPRATIO='.$p_keep_ratio; // Retrieve thumbnail $t = new pt_thumbnail ($this->settings, $the_image, $arg); $add_tag = $align; // Add thumbnail & highslide expand to image if (POSTTHUMB_USE_HS) { $h = new pt_highslide ($the_image, $t->thumb_url, $alt_text); $h->set_borders ($this->settings['ovframe']); $h->set_title ($title); if ($has_caption) $h->set_caption ($alt_text); $h->set_html_size(); $h->set_href_text('', $add_tag); $h_str = $h->highslide_link (); unset ($h); } // Add thumbnail & thickbox class to image if (POSTTHUMB_USE_TB) { $h = new pt_thickbox ($the_image, $t->thumb_url, $alt_text); $h->set_href_text('', $add_tag); $h_str = $h->thickbox_link (); unset ($h); } unset ($t); return $h_str; } /****************************************************************/ /* Get category image /****************************************************************/ function InitWordTube () { // checks for player type and prefers the mediaplayer $wordtube_abspath = ABSPATH.'/wp-content/plugins/' . $this->wt_path.'/'; if (file_exists($wordtube_abspath.'mediaplayer.swf')) $this->playertype = 'mediaplayer.swf'; elseif (file_exists($wordtube_abspath.'mp3player.swf')) $this->playertype = 'mp3player.swf'; elseif (file_exists($wordtube_abspath.'flvplayer.swf')) $this->playertype = 'flvplayer.swf'; else $this->playertype = false; if (file_exists($wordtube_abspath.'mp3player.swf')) $this->playertypemp3 = 'mp3player.swf'; else $this->playertypemp3 = $this->playertype; $this->wordtube_options = get_option('wordtube_options'); } /****************************************************************/ /* Get category image /****************************************************************/ function pt_GetVideo ($name, $file, $image, $play_width, $play_height, $arg='', $vid) { // Init parameters $settings = ''; $path = pathinfo($file); $extension = strtolower($path['extension']); $hs_width = $play_width+20; $ID = 'v'.rand(); $playertype = $this->playertype; // Prepare the script string if ($extension == "flv") $text = $this->settings['wordtube_vtext']; elseif ($extension == "mp3") { $text = $this->settings['wordtube_mtext']; $playertype = $this->playertype; if ($this->wordtube_options['showeq']) $play_height=70; else $play_height = 20; } parse_str($arg, $new_args); $new_args = array_change_key_case($new_args, CASE_UPPER); if (isset($new_args['MYCLASSHREF'])) $myclasshref = $new_args['MYCLASSHREF']; else $myclasshref = ''; if (isset($new_args['MYCLASSIMG'])) $myclassimg = ' class="'.$new_args['MYCLASSIMG'].'"'; else $myclassimg = ''; // Get thumbnail if ($arg == '') $t = new pt_thumbnail($this->settings, $image, 'keepratio=0&width='.$this->settings['wordtube_width'].'&height='.$this->settings['wordtube_height'].'&altappend='.$this->settings['wordtube_text'].'&textbox=1&text='.$text); else $t = new pt_thumbnail($this->settings, $image, $arg); $thumb_url = $t->thumb_url; unset($t); // Prepare highslide html if (POSTTHUMB_USE_HS) { $replace = SetWordTubeMedia ($file, $image, $play_width, $play_height, $ID, $extension, $playertype, $this->wordtube_options, false, $vid); $h = new pt_highslide('#', $thumb_url, $name); $h->set_colors($this->settings['bgcolor']); $h->set_borders($this->settings['hsframe']); $h->set_size($play_width, $play_height); $h->set_myclasshref($myclasshref); $h->set_href_text($name, $myclassimg); $h->set_size($hs_width); $highslide = $h->highslide_link('swfObject', 'so'.$ID); unset($h); $replace .= $highslide; } elseif (POSTTHUMB_USE_TB) { $replace = SetWordTubeMedia ($file, $image, $play_width, $play_height, $ID, $extension, $playertype, $this->wordtube_options, true, $vid); $h = new pt_thickbox('', $thumb_url, $name); $h->set_size($play_width+5, $play_height+10); $h->set_href_text($name); $h->set_myclasshref($myclasshref); $h->set_body($replace); $replace = $h->thickbox_link('swfObject', $ID); } return $replace; } /****************************************************************/ /* Get category image /****************************************************************/ function pt_GetYoutube ($id, $title, $thumb) { return SetYoutubeVideo ($id, $title, $thumb, $this->settings); } /****************************************************************/ /* test if a call is in a frame /****************************************************************/ function is_inframe() { if (isset($_GET['inframe'])) $inframe = $_GET['inframe']; else $inframe = 0; define('POSTHUMB_INFRAME', $inframe); } /****************************************************************/ /* Includes features in header /****************************************************************/ function pt_include_header() { if (POSTTHUMB_USE_HS) { /* highslide includes ============================== */ ?> is_inframe(); } if (POSTTHUMB_USE_TB) { /* thickbox includes ============================== */ ?> post_id = $post->ID; $this->title = $post->post_title; $this->date = $post->post_date; $this->permalink = get_permalink($this->post_id); $author = get_author_name($post->post_author); $this->author= '
'.$author.''; } } /****************************************************************/ /* Get category image /****************************************************************/ function SetWordTubeMedia ($file, $image, $play_width, $play_height, $ID, $extension, $playertype, $wordtube_options='', $use_tb=false, $vid='') { // Init parameters $settings = ''; if ($wordtube_options == '') $wordtube_options = get_option('wordtube_options'); $hs_width = $play_width+20; $body = 'Get the Flash Player to see the wordTube Media Player.'; // Prepare the script settings string if ($extension == "mp3" && $wordtube_options['showeq']) { $settings .= "\n\t".'so'.$ID.'.addVariable("showeq", "true");'; $play_height = 70; // fixed for equalizer } elseif ($extension == "mp3") $play_height = 20; $settings .= "\n\t".'so'.$ID.'.addVariable("autostart", "true");'; if ($vid != '') $settings .= "\n\t".'so'.$ID.'.addVariable("id", "'.$vid.'");'; if ($wordtube_options['usewatermark']) $settings .= "\n\t".'so'.$ID.'.addVariable("logo", "'.$wordtube_options['watermarkurl'].'");'; if ($wordtube_options['repeat']) $settings .= "\n\t".'so'.$ID.'.addVariable("repeat", "true");'; if ($wordtube_options['overstretch']) $settings .= "\n\t".'so'.$ID.'.addVariable("overstretch", "'.$wordtube_options['overstretch'].'");'; if ($wordtube_options['showdigits']) $settings .= "\n\t".'so'.$ID.'.addVariable("showdigits", "true");'; if ($wordtube_options['showfsbutton']) $settings .= "\n\t".'so'.$ID.'.addVariable("showfsbutton", "true");'; if ($wordtube_options['statistic']) $settings .= "\n\t".'so'.$ID.'.addVariable("callback", "'.WORDTUBE_URLPATH.'wordtube-statistics.php");'; $settings .= "\n\t".'so'.$ID.'.addVariable("backcolor", "0x'.$wordtube_options['backcolor'].'");'; $settings .= "\n\t".'so'.$ID.'.addVariable("frontcolor", "0x'.$wordtube_options['frontcolor'].'");'; $settings .= "\n\t".'so'.$ID.'.addVariable("lightcolor", "0x'.$wordtube_options['lightcolor'].'");'; $settings .= "\n\t".'so'.$ID.'.addVariable("volume", "'.$wordtube_options['volume'].'");'; $settings .= "\n\t".'so'.$ID.'.addVariable("bufferlength", "'.$wordtube_options['bufferlength'].'");'; // neeeded for IE problems $settings .= "\n\t".'so'.$ID.'.addVariable("width", "'.$play_width.'");'; $settings .= "\n\t".'so'.$ID.'.addVariable("height", "'.$play_height.'");'; if ($wordtube_options['showfsbutton']) { $settings .= "\n\t".'so'.$ID.'.addParam("allowfullscreen", "true");'; } else { // transparent didn't work with fullscreen mode $settings .= "\n\t".'so'.$ID.'.addVariable("showfsbutton", "false");'; $settings .= "\n\t".'so'.$ID.'.addParam("wmode", "transparent");'; } // Starts build the final string wrapped in '."\n"; return $replace; } /****************************************************************/ /* Get category image /****************************************************************/ function SetYoutubeVideo ($ytb_ID, $title='', $thumb, $settings, $add_arg='') { $ID = 'y'.rand(); $url = 'http://www.youtube.com/watch?v='.$ytb_ID; if ($title == '') $title = 'Youtube video'; $replacement = "\n".''."\n"; if (class_exists('pt_highslide')) { $h = new pt_highslide($url, $thumb, $title); $h->set_colors($settings['bgcolor']); $h->set_borders($settings['hsframe']); $h->set_href_text($title, $add_arg); $h->set_bottom(__('Direct link to: ', 'post-thumb').$title, $url); $h->set_size($settings['youtube_pwidth']+20, $settings['youtube_pheight']+20); $replacement .= $h->highslide_link('swfObject', 'so'.$ID.'y'); unset($h); } elseif (class_exists('pt_thickbox')) { $h = new pt_thickbox($url, $thumb, $title); $h->set_size($settings['youtube_pwidth']+5, $settings['youtube_pheight']+10); $h->set_href_text($title); $h->set_body($replacement); $replacement = $h->thickbox_link('swfObject', $ID); unset($h); } else { $replacement = "\n".''; $replacement .= "\n\t".''; $replacement .= "\n".''; } return $replacement; } ?>