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
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.
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?
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?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.