We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

creating valid flash video code plugin

Development and Programming

box-head's avatar
box-head
177 posts
16 years ago
box-head's avatar box-head

I’ve been working on a plugin for taking standard/default embed video code from Vimeo/youtube and turning into XHTML valid code. It’s intended use is as a formatting option on custom fields within the publish page.

Here’s the code as is (minus the plugin_info and usage).

<?php
class Valid_flash_vid {

var $return_data = "";

    /** ----------------------------------------
    /**  Flash Video Validator
    /** ----------------------------------------*/

  function Valid_flash_vid($str = "")
  {
    global $TMPL;

    if ($str == '')
    {
      $str = $TMPL->tagdata;
    }
    
    $object = preg_replace('/<e.*<\/embed>/i', '', $str);
    preg_match_all('/height=[\'"]\d+[\'"]/i', $object, $matches);
    foreach ($matches as $val)
    {
        $theContent = preg_replace('/height=[\'"]\d+[\'"]/i', $val[0].' type="application/x-shockwave-flash"', $object);
    }

    preg_match_all('/htt.*=\w/i', $theContent, $matches2);
    foreach ($matches2 as $val)
    {
        $newContent = preg_replace('/type=[\'"].*?[\'"]/i', 'type="application/x-shockwave-flash" data="'.$val[0].'"', $theContent);
    }

    if(preg_match('//i', $newContent, $matches3) != 0)
    {
        foreach ($matches3 as $val)
        {
            $cleaned_amp = preg_replace('//i', $val.'', $newContent, 1);
        }
    } 
    else 
    {
        $cleaned = preg_replace('//i', '$1</param>', $newContent, 1);
        $cleaned_amp = str_replace('&', '&', $cleaned);
    }
    
    $this->return_data = $cleaned_amp;
  }
?>

Now i have this working on a number of pages on a development site but when I go to a single entry page I get these two errors (and nothing else).

Warning: Typography::require_once(./eecp/plugins/pi..php) [typography.require-once]: failed to open stream: No such file or directory in /var/www/vhosts/thebivouac.co.uk/httpdocs/dev/eecp/core/core.typography.php on line 475

Fatal error: Typography::require_once() [function.require]: Failed opening required './eecp/plugins/pi..php' (include_path='.:') in /var/www/vhosts/thebivouac.co.uk/httpdocs/dev/eecp/core/core.typography.php on line 475

I’ve investigated the typography class but I’m not sure what the problem is as it works on other pages?

This is my first ever plugin so any help would be much appreciated with the debugging (and any help with making the code more efficient).

Thanks

       
box-head's avatar
box-head
177 posts
16 years ago
box-head's avatar box-head

Any ideas anyone?

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

What plugin is it trying to access on the error message?

require_once(./eecp/plugins/pi..php)

Are you doing the require_once in your code that you didn’t copy above?

Edit: Sorry, just clicked - thought you might have truncated the error, but obviously it’s not had the plugin details set correctly, so doesn’t know the plugin name.

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

Have you tried outputting the value of $cleaned_amp to screen/template and returning “” for testing.

Can you post the differences in the 2 templates: “working on a number of pages on a development site” and “single entry page”.

I’m not great on the search patterns used, so not sure if these are an issue.

There’s no replacement for & in the $matches3 foreach loop - does this matter?

Also, each loop in the $matches3 will reset $cleaned_amp - should it?

Following on from these blind (stupid?) observations, have you got any example/test $str values?

       
Chris Newton's avatar
Chris Newton
440 posts
16 years ago
Chris Newton's avatar Chris Newton

In the code you have listed above, your class isn’t closed out:

class Valid_flash_vid {

doesn’t have a closing curly bracket. I didn’t look too closely, but I’d also suggest adding some CP info for the plugin:

$plugin_info = array(
    'pi_name'        => 'whatevs',
    'pi_version'     => '1.0',
    'pi_author'      => 'name',
    'pi_author_url'  => 'http://whatev.com/ee/',
    'pi_description' => 'Add stuff to stuff',
    'pi_usage'       => whatevs::usage()
);

And how are you using the plugin in your templates. Can you paste that in?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.