Help with small change to podcast plugin

Creating and modifying plugins.
Post Reply
perlnerd
Regular
Posts: 37
Joined: Mon Mar 27, 2006 11:02 pm

Help with small change to podcast plugin

Post by perlnerd »

I have the plugin setup to use the [podcast:...] tag and it is working fine. I'd like to configure it to only show the player and not the link to the file beside the player.

I've had a look at the code but can't seem to spot where I could change this behaviour.

Any help is appreciated. A pointer to the line of code I could comment out or modify would be great.

Thanks
Perlnerd
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Help with small change to podcast plugin

Post by garvinhicking »

Hi!

The magic lines that affect the output are those within the PHP filE:

Code: Select all

                    if ($tagging_switch == 'podcast') {
                        $eventData[$entryPos]['body'] = preg_replace(
                            $mediaLinkPattern,
                            '<a href="\4\5">\5</a>',
                            $entry['body']);

                        $eventData[$entryPos]['extended'] = preg_replace(
                            $mediaLinkPattern,
                            '<a href="\4\5">\5</a>',
                            $entry['extended']);
                    }
                    
                    if ($use_player && is_array($eventData[$entryPos])) {
                        $eventData[$entryPos]['body'] = preg_replace(
                            $playerRewritePattern,
                            '"\0". sprintf($this->playerHTML[strtolower("\3")], "\2", "\2"); ',
                            $eventData[$entryPos]['body']);

                        $eventData[$entryPos]['extended'] = preg_replace(
                            $playerRewritePattern,
                            '"\0". sprintf($this->playerHTML[strtolower("\3")], "\2", "\2"); ',
                            $eventData[$entryPos]['extended']);

                    }
This uses the template for HTML as defined here:

Code: Select all

                $playerRewritePattern =
                '@<a\s+.*href\s*=\s*(\'|")([^\'"]+\.('.
                implode('|', array_keys($this->playerHTML)).
                '))\1[^>]*>.*</a>@Usie'; //won't match nested tags, like <a .. <b>.. </b></a>. but that's ugly anyway.
So if you change that <a href...> html to suit your needs in the preg_replacement call , you should work it out?

Something like this:

Code: Select all

                    if ($tagging_switch == 'podcast') {
                        $eventData[$entryPos]['body'] = preg_replace(
                            $mediaLinkPattern,
                            '\5',
                            $entry['body']);

                        $eventData[$entryPos]['extended'] = preg_replace(
                            $mediaLinkPattern,
                            '\5',
                            $entry['extended']);
                    }
So, stripping the <a> tag at the required places...

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
perlnerd
Regular
Posts: 37
Joined: Mon Mar 27, 2006 11:02 pm

Post by perlnerd »

The regex upon regex was making my brain hurt....

The solution I came up with was pretty simple:

Code: Select all

if ($tagging_switch == 'podcast') {
                        $eventData[$entryPos]['body'] = preg_replace(
                            $mediaLinkPattern,
                            '<a href="\4\5">\5</a>',
                             $entry['body']);

                        $eventData[$entryPos]['extended'] = preg_replace(
                            $mediaLinkPattern,
                            '<a href="\4\5">\5</a>',
                            $entry['extended']);    
                    }
 
became:

Code: Select all


 if ($tagging_switch == 'podcast') {
                        $eventData[$entryPos]['body'] = preg_replace(
                            $mediaLinkPattern,
                            //'<a href="\4\5">\5</a>',
                            '<a href="\4\5"> </a>',   
                            $entry['body']);

                        $eventData[$entryPos]['extended'] = preg_replace(
                            $mediaLinkPattern,
                            //'<a href="\4\5">\5</a>',
                            '<a href="\4\5"> </a>', 
                            $entry['extended']);    
                    }
This seems to keep the regexes that follow happy but gets rid of any visible link.

Another question: Is there a way to get the podcast plugin to work on pages created with the "static pages" module?

Thanks
PerlNerd
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Glad you got it to work :)

Actually you should be able to make the podcast plugin also perform replacements on static pages, yes. You must enable the "Appl ymarkup transformations" option for the page then.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
bdconnolly
Regular
Posts: 140
Joined: Tue Apr 04, 2006 9:37 pm

Post by bdconnolly »

I am still not getting it to work in the static pages.

Thoughts?
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Did you configure the static pages plugin to "Apply Markup Transformations"?
Judebert
---
Website | Wishlist | PayPal
bdconnolly
Regular
Posts: 140
Joined: Tue Apr 04, 2006 9:37 pm

Post by bdconnolly »

yep.

I'm stumped.
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Weird; looks like the code expects the plugin to be configured for markup, then calls frontend_display hook, then checks if "markup_staticpage" has been set. The only plugin that can do that is serendipity_event_smartymarkup.

So, if you've got the Smarty markup plugin, it'll always override any other static page markup. Is it installed?
Judebert
---
Website | Wishlist | PayPal
Post Reply