Thread: Miscellaneous Hacks - aMP3 - (mp3 attachment player)
View Single Post
  #41  
Old 11-07-2007, 06:39 PM
derfelix derfelix is offline
 
Join Date: Nov 2001
Posts: 204
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is awsome..
just made it work in blogs..
if someone else is interested (and if I may)

here is the modification I applied..
in the product.xml find:
PHP Code:
if ($vbulletin->options['amp3_enabled']) { 
$vbulletin->templatecache['postbit_attachment'] = preg_replace('#<tr#''<tr style=\"vertical-align: top;\"',$vbulletin->templatecache['postbit_attachment']);

$vbulletin->templatecache['postbit_attachment'] = preg_replace('#\)</td>#'')" . ( ($attachment[attachmentextension] == "mp3")?("<div style=\'float: left;\'><script src=\'./clientscript/audio/audio-player.js\' language=\'JavaScript\'></script><object style=\'vertical-align: middle;\' id=\'./attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;d=$attachment[dateline]\' width=\'290\' height=\'24\' data=\'./clientscript/audio/player.swf\' type=\'application/x-shockwave-flash\'><param value=\'./clientscript/audio/player.swf\' name=\'movie\'/><param value=\'playerID=1&soundFile=./attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;d=$attachment[dateline]\' name=\'FlashVars\'/><param value=\'high\' name=\'quality\'/><param value=\'false\' name=\'menu\'/><param value=\'transparent\' name=\'wmode\'/></object></div>"):("") ) . "</td>',$vbulletin->templatecache['postbit_attachment']);

replace with:
PHP Code:
if ($vbulletin->options['amp3_enabled'] AND ($vbulletin->userinfo['userid'] > 0) ) 

    if((
strlen($vbulletin->templatecache['blog_entry_attachment'])>1) OR (strlen($vbulletin->templatecache['postbit_attachment'])>1))
    {
        
$cachedtemp = (THIS_SCRIPT == 'blog') ?  $vbulletin->templatecache['blog_entry_attachment'] : $vbulletin->templatecache['postbit_attachment'];
        
$attach_file = (THIS_SCRIPT == 'blog') ?  'blog_attachment' 'attachment';
        
$cachedtemp preg_replace('#<tr#''<tr style=\"vertical-align: top;\"',$cachedtemp);

        
$cachedtemp preg_replace('#\)</td>#'')" . ( ($attachment[attachmentextension] == "mp3")?("<div style=\'float: left;\'><script src=\'./clientscript/audio/audio-player.js\' language=\'JavaScript\'></script><object style=\'vertical-align: middle;\' id=\'./attachment.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;d=$attachment[dateline]\' width=\'290\' height=\'24\' data=\'./clientscript/audio/player.swf\' type=\'application/x-shockwave-flash\'><param value=\'./clientscript/audio/player.swf\' name=\'movie\'/><param value=\'playerID=1&soundFile=./'.$attach_file.'.php?$session[sessionurl]attachmentid=$attachment[attachmentid]&amp;d=$attachment[dateline]\' name=\'FlashVars\'/><param value=\'high\' name=\'quality\'/><param value=\'true\' name=\'menu\'/><param value=\'transparent\' name=\'wmode\'/></object></div>"):("") ) . "</td>',$cachedtemp);

        if(
THIS_SCRIPT == 'blog')
        {
            
$vbulletin->templatecache['blog_entry_attachment'] = $cachedtemp;
        }
        else
        {
            
$vbulletin->templatecache['postbit_attachment'] = $cachedtemp;
        }
        unset(
$cachedtemp);
    }

Actually the only thing I did was to change the template to parse if we are in blogs.. from $vbulletin->templatecache['postbit_attachment'] to $vbulletin->templatecache['blog_entry_attachment']
if we are not in blogs it works as usual..


It now seems to work fine in vblogs AND showthread
and i'm happy
Felix

[EDIT]: Just corrected one bracket.. and a line that got lost in cut & paste AND added that the player only appears for logged in users.. (if you want all users to see the player.. remove AND ($vbulletin->userinfo['userid'] > 0) at the beginning..)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01058 seconds
  • Memory Usage 1,796KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete