2 gupik Mar 04, 2008 18:02
![](http://www.gravatar.com/avatar/a29c2900d81dc286e3b3a7044c2e6306?size=80&default=https%3A%2F%2Fforums.b2evolution.net%2Fmedia%2Fshared%2Fglobal%2Favatars%2Fdefault_avatar_unknown.jpg%3Fmtime%3D1659823855)
gupik wrote:
Hmm, another of my question would be: is it possible for a plugin to render HTML in the <HEAD> area of the page? Or are we forced to edit HTML-Header in skins folder?
http://doc.b2evolution.net/HEAD/plugins/Plugin.html#methodSkinBeginHtmlHead
There are possibilities without the hook also. The hook injects stuff at the very beginning of the <head> section. You may not always want that.
Good luck
1) yes ... if you need help then just holler with a tad more clarification of your problem
2) yes ... use SkinBeginHtmlHead()
;)
¥
*edit*
bugger
/me suffers from EdB syndrome :roll:
gupik wrote:
... and a stupid question: why can't I put a plugin into a folder? If I do so, b2evo doesn't see it... are there any special kinds of plugins that get displayed when in folders?
The folder needs a specific name /YOURPLUGIN_plugin/ with inside it the file _YOURPLUGIN.plugin.php. Look for similarities in all other plugins folders
Good luck
/me did it again B)
ALMOST got it...
Just I need my plugin to display THE SAME random string in both RenderItemAsHtml and SkinBeginHtmlHead....
argh... being a noob really hurts.
The variable I want to use is:
$movieid = md5(mt_rand());
... but how to make the plugin "accept" the variable? (I get error "undefined variable or sth when I type it just like that)
$this->movieid
OK... thanks :) I'll try it.
... and how to get a blog folder path? (http://www.domain.com/blog/). I already know the this->get_plugin_url(), but I think it's not enough and some js must be called through a full address...
OK, I'll show you something:
I get the error:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/yot/ftp/blog/plugins/jwplayer_plugin/_jwplayer.plugin.php on line 51
The code:
/**
* Perform rendering
*
* @see Plugin::RenderItemAsHtml()
*/
$movieid = md5(mt_rand());
function RenderItemAsHtml( & $params )
{
$content = & $params['data'];
// flash:
$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '
<object id="'.$this->$movieid.'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="\\2" height="\\3">
<param name="movie" value="'.$this->get_plugin_url().'mediaplayer.swf" />
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="flashvars" value="height=\\3&width=\\2&file=\\1&image=\\4&displayheight=\\3&showstop=true" />
</object>', $content );
return true;
}
function SkinBeginHtmlHead( $params = array() )
{
echo '<script type="text/javascript" src="'.$this->get_plugin_url().'swobject.js"></script>'."\n";
echo '<script type="text/javascript">'."\n";
echo 'swfobject.registerObject("'.$this->$movieid.'", "9.0.0", "'.$this->get_plugin_url().'expressInstall.swf");'."\n";
echo '</script>'."\n";
}
What wrong here? It just doesn't like
$movieid = md5(mt_rand());
Because line 51 it's exactly this line.
Still, I'd want to insert this code:
<div id="player">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('http://www.domain.com/plugins/mediaplayer.swf','mpl','470','255','8');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addVariable('width','470');
so.addVariable('height','255');
so.addVariable('file','/upload/movie.flv');
so.write('player');
</script>
into this:
function RenderItemAsHtml( & $params )
{
$content = & $params['data'];
// flash:
$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '
HERE GOES THE JAVASCRIPT
', $content );
return true;
}
What I really mean is: the " ; " marks are a bit irritating. :) They break the function. What should it look like to be properly read? Should I insert before any " ; " the /n ot /t... there was something like that...
gupik wrote:
OK... thanks :) I'll try it.
... and how to get a blog folder path? (http://www.domain.com/blog/). I already know the this->get_plugin_url(), but I think it's not enough and some js must be called through a full address...
OK, I'll show you something:
I get the error:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/yot/ftp/blog/plugins/jwplayer_plugin/_jwplayer.plugin.php on line 51
The variable is outside a function. Get it inside.
The plugin fodler path is $plugins_path. You must global it first:
global $plugins_path;
before you can use it.
Do have a look at other plugins. Have a particular good look at the code from the video plugin.
Good luck
OK, but just as I said, I need the same randomed variable in both RenderItemAsHtml and SkinBeginHtmlHead. If I just enter here and there $movieid = md5(mt_rand()); , I'll get two strings. They must be the same to make things work...
And what about putting javascript into RenderItemAsHtml?
For some odd reason $plugins_path returns not Http://... but the system folders, like home/domain/ftp/...blabla. So this doesn't help.
Thanks for help :)
gupik wrote:
OK, but just as I said, I need the same randomed variable in both RenderItemAsHtml and SkinBeginHtmlHead. If I just enter here and there $movieid = md5(mt_rand()); , I'll get two strings. They must be the same to make things work...
function generateRandom ()
{
$foo = md5(mt_rand());
return $foo;
}
First occasion:
$movieid = generateRandom();
second and subsequent occasion:
$this->movieid;
Or something like that.
Good luck
Thank you very much! :D *hugz*
Now I only need to make RenderItemAsHtml display javascript...
(BTW... I'm a girl, so don't get that hugz too seriously :P)
gupik,
You must escape all special characters like ' and " in the javascript code. I think this will do:
<script type=\"text\/javascript\">
var so = new SWFObject(\'http:\/\/www.domain.com\/plugins\/mediaplayer.swf\',\'mpl\',\'470\',\'255\',\'8\');
so.addParam(\'allowscriptaccess\',\'always\');
so.addParam(\'allowfullscreen\',\'true\');
so.addVariable(\'width\',\'470\');
so.addVariable(\'height\',\'255\');
so.addVariable(\'file\',\'\/upload\/movie.flv\');
so.write(\'player\');
<\/script>
Yeah, I have just figured it out. ^^ I thought that " ; " sign will cause problems, but it doesn't...
BTW, your randomizing function still doesn't work... this time it gives me an error "Call to undefined function". Isn't it strange? We have just defined it...
My code looked like this:
function generateRandom ()
{
$foo = md5(mt_rand());
return $foo;
}
function RenderItemAsHtml( & $params )
{
$content = & $params['data'];
$movieid = generateRandom();
// flash:
$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '
<div id="'.$movieid.'">Media Player</div>
...blabla
$movieid = $this->generateRandom();
Thanks! :D
And the last question:
Putting the lines of code one under another by hitting "Enter" make the render function display "<br />" in the code. How to make a line break without "<br />"?
Thanks :D
echo "\n"
The \n *must* be within double quotes, so if you are echoing in single qoutes, you *must* concatenate. Example:
echo ( 'sometext' . "\n" . 'someothertext' );
Does it all work as expected?
emm... well... I still mean the function RenderItemAsHtml. :) I'd like the javascript to be nicely displayed with linebreaks...
If I hit just "enter", I get BRs... and they shouldn't be displayed in this script. >>
<div id="wbytVHuynZWhCynztIRRHvNxr">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>
<script type="text/javascript"> <br />
// <![CDATA[ <br />
var so = new SWFObject('/plugins/jwplayer_plugin/mediaplayer.swf','mpl','400','300','8');so.addParam('allowscriptaccess','always');so.addParam('allowfullscreen','true');so.addVariable('width','400');so.addVariable('height','300');so.addVariable('showstop','true');so.addVariable('file','http://www.manjikai.com/podcast/audio/y-podcast-2007-04-17-81464.flv');so.addVariable('image','/splash/splash-manji.jpg');so.addVariable('displayheight','300');so.write('wbytVHuynZWhCynztIRRHvNxr'); <br /> // ]]> <br />
</script> <br />
The movie above uses custom splash image. </center><p></p>
Is there a solution?
'<script type=\"text\/javascript\">'."\n".
'var so = new SWFObject(\'http:\/\/www.domain.com\/plugins'\/mediaplayer.swf\',\'mpl\',\'470\',\'255\',\'8\');'."\n".
'so.addParam(\'allowscriptaccess\',\'always\');'."\n".
'so.addParam(\'allowfullscreen\',\'true\');'."\n".
'so.addVariable(\'width\',\'470\');'."\n".
'so.addVariable(\'height\',\'255\');'."\n".
'so.addVariable(\'file\',\'\/upload\/movie.flv\');'."\n".
'so.write(\'player\');'."\n".
'<\/script>'."\n"'
unfortunately, it still displays <br /> .... maybe \t\n?
Hmm...
I beat javascript to death with good old fashioned echo. In other words, I did not try to actually directly write javascript. Like so:
echo '<script type="text/javascript">'."\n";
echo '//<![CDATA['."\n";
echo 'var CommentTags = new Array();'."\n";
echo 'var CommentLinks = new Array();'."\n";
echo 'var CommentOpenTags = new Array();'."\n";
echo 'function CommentButton(id, display, tagStyle, tagStart, tagEnd, tit, open) {'."\n";
echo 'this.id = id;'."\n";
echo 'this.display = display;'."\n";
echo 'this.tagStyle = tagStyle;'."\n";
echo 'this.tagStart = tagStart;'."\n";
echo 'this.tagEnd = tagEnd;'."\n";
echo 'this.tit = tit;'."\n";
echo 'this.open = open;'."\n";
echo '}'."\n";
Ocassionally you come across something that you have to escape, but I found that in general this was pretty slick. AND it works :) Though for my purposes I do believe there is a much sweeter method to get 'er done. Live, learn, leave the junk behind without ever actually cleaning up yah?
Hi gupik,
The <br/> things come from the breaks (Enter) in the code. You should use my code in one line but I won't reproduce that here. EdB' s solution overcomes this problem and therefore is probably what you are looking for.
Good luck
Yeah, I have put it in one line, and guess what... :D
I'll try again, maybe magic happens...
... BTW, if I think a good way, echo can't be used in renderItemAsHtml...?
True dat, but this will:
$my_script = '<script type="text/javascript">'."\n";
$my_script .= '//<![CDATA['."\n";
$my_script .= 'var CommentTags = new Array();'."\n";
$my_script .= 'var CommentLinks = new Array();'."\n";
$my_script .= 'var CommentOpenTags = new Array();'."\n";
$my_script .= 'function CommentButton(id, display, tagStyle, tagStart, tagEnd, tit, open) {'."\n";
$my_script .= 'this.id = id;'."\n";
$my_script .= 'this.display = display;'."\n";
$my_script .= 'this.tagStyle = tagStyle;'."\n";
Obviously you continue until $my_script holds the entire script you need, then use it as you see fit. In my creative commons license, in the RenderItemAsHtml function, I build up pretty much the entire replacement string that way. It's not javascript in that case, but it *is* html (and an RDF equivalent), and javascript is pretty much html with a bad reputation.
Hmm... I'll try to figure it out... If I blow up my brain, I'll let you know :)
Not much to it really.
$a_variable = 'a string of characters ';
So now add another string of characters to it. Two ways, the second of which is nicer:
$a_variable = $a_variable.'another string of characters ';
OR
$a_variable .= 'another string of characters ';
The [[dot equals]] basically means "add this to the end of whatever the variable is". Groovy eh?
gupik,
In your code this translates as follows:
function RenderItemAsHtml( & $params )
{
$content = & $params['data'];
$my_script = '<script type="text/javascript">'."\n";
$my_script .= '//<![CDATA['."\n";
$my_script .= 'var CommentTags = new Array();'."\n";
$my_script .= 'var CommentLinks = new Array();'."\n";
$my_script .= 'var CommentOpenTags = new Array();'."\n";
$my_script .= 'function CommentButton(id, display, tagStyle, tagStart, tagEnd, tit, open) {'."\n";
$my_script .= 'this.id = id;'."\n";
$my_script .= 'this.display = display;'."\n";
$my_script .= 'this.tagStyle = tagStyle;'."\n";
// flash:
$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', $my_script, $content );
return true;
}
But replace with your actual data
Dammit... things are a bit complicated for me if the function has this construction:
$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', ' BLABLA JAVA ', $content );
... help? :/
This java just doesn't want to display the flash object when in IE... I think I need to add CDATA to make it display properly... and these tags need linebreaks :(
you might try \r\n in stead of \n
I don't hive you much chance but being Internet Explorer, who knows.
Afwas wrote:
gupik,
In your code this translates as follows:
function RenderItemAsHtml( & $params ) { $content = & $params['data']; $my_script = '<script type="text/javascript">'."\n"; $my_script .= '//<![CDATA['."\n"; $my_script .= 'var CommentTags = new Array();'."\n"; $my_script .= 'var CommentLinks = new Array();'."\n"; $my_script .= 'var CommentOpenTags = new Array();'."\n"; $my_script .= 'function CommentButton(id, display, tagStyle, tagStart, tagEnd, tit, open) {'."\n"; $my_script .= 'this.id = id;'."\n"; $my_script .= 'this.display = display;'."\n"; $my_script .= 'this.tagStyle = tagStyle;'."\n"; // flash: $content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', $my_script, $content ); return true; }
But replace with your actual data
Nooo.... it still displays that freakin' <br />!!!
My code:
function RenderItemAsHtml( & $params )
{
$content = & $params['data'];
$movieid = $this->strrand(25);
$my_script = '<div id="'.$movieid.'">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>'."\n";
$my_script .= '<script type="text/javascript">'."\n";
$my_script .= '//<![CDATA['."\n";
$my_script .= 'var so = new SWFObject(\''.$this->get_plugin_url().'mediaplayer.swf\',\'mpl\',\'\\2\',\'\\3\',\'8\');'."\n";
$my_script .= 'so.addParam(\'allowscriptaccess\',\'always\');'."\n";
$my_script .= 'so.addParam(\'allowfullscreen\',\'true\');'."\n";
$my_script .= 'so.addVariable(\'width\',\'\\2\');so.addVariable(\'height\',\'\\3\');'."\n";
$my_script .= 'so.addVariable(\'showstop\',\'true\');so.addVariable(\'file\',\'\\1\');'."\n";
$my_script .= 'so.addVariable(\'image\',\'\\4\');so.addVariable(\'displayheight\',\'\\3\');'."\n";
$my_script .= 'so.write(\''.$movieid.'\');'."\n";
$my_script .= '// ]]>'."\n";
$my_script .= ' </script>'."\n";
// flash:
$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', $my_script, $content );
...O_O
PS. I'll be near commiting a suicide when we'll finally figue it out... but IE still won't display it as it should, LOL... but I saw an example on the site which IE properly read... so there's hope...
I admire you, really :)
Gupik,
You must do the escape trick (\) with every quote and /. You didn't escape the first three and last two lines of $my_script.
What is the exact output you get? Can you copy/paste it here for us to have a look at it?
Here it is:
<div id="HPVekPBsrekacTAWTOWyAIRXI">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>
<script type="text/javascript">
//<![CDATA[<br />
var so = new SWFObject('/plugins/jwplayer_plugin/mediaplayer.swf','mpl','400','300','8');<br />
so.addParam('allowscriptaccess','always');<br />
so.addParam('allowfullscreen','true');<br />
so.addVariable('width','400');so.addVariable('height','300');<br />
so.addVariable('showstop','true');so.addVariable('file','http://www.manjikai.com/podcast/audio/y-podcast-2007-04-17-81464.flv');<br />
so.addVariable('image','/splash/splash-manji.jpg');so.addVariable('displayheight','300');<br />
so.write('HPVekPBsrekacTAWTOWyAIRXI');<br />
// ]]><br />
</script>
Another thing you can do to "clean up" the look of the code is ... well heck I'll show you one line and you'll see:
$my_script .= 'so.addParam(\'allowscriptaccess\',\'always\');'."\n";
Changes to this:
$my_script .= "so.addParam('allowscriptaccess','always');"."\n";
Technically speaking I could go one step further and do this:
$my_script .= "so.addParam('allowscriptaccess','always');\n";
hey... Do you have spaces after your "\n"; bits? If so you might consider removing them just to see.
Anyway all I did was replace ' with " around the bits to add to the so.addParam bit so that I would not have to escape all the 's that are part of each line.
gupik,
You do use a text editor like notepad++ or crimson editor or Scintilla or whatever and *not* a html editor?
I wrote it like this:
function RenderItemAsHtml( & $params )
{
$content = & $params['data'];
$movieid = $this->strrand(25);
$my_script = "<div id=\"$movieid\">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>\n";
$my_script .= "<script type=\"text/javascript\">"."\n";
$my_script .= "//<![CDATA["."\n";
$my_script .= "var so = new SWFObject('".$this->get_plugin_url()."mediaplayer.swf','mpl','\\2','\\3','8');\n";
$my_script .= "so.addParam('allowscriptaccess','always');\n";
$my_script .= "so.addParam('allowfullscreen','true');\n";
$my_script .= "so.addVariable('width','\\2');so.addVariable('height','\\3');\n";
$my_script .= "so.addVariable('showstop','true');so.addVariable('file','\\1');\n";
$my_script .= "so.addVariable('image','\\4');so.addVariable('displayheight','\\3');\n";
$my_script .= "so.write('$movieid');"."\n";
$my_script .= "// ]]>"."\n";
$my_script .= " </script>\n";
// flash:
$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', $my_script, $content );
... and it still shows the same output. Deleting /n merges the lines... I wrote "."/n" near the places in which line breaks are crucial (I think)... the rest can be merged.
What do you think?
I use simple notepad...
What bothers me is: between </div> and <script... > There's a correct line break, and then there are that <br />...
Another variation I made, and still the same (it only added the tab space)
$my_script = "\n\t"."<div id=\"$movieid\">Media Player: you have to have Adobe flash plugin installed and Javascript enabled.</div>";$my_script .= "\n\t"."<script type=\"text/javascript\">";$my_script .= "\n\t"."//<![CDATA[";$my_script .= "\n\t"."var so = new SWFObject('".$this->get_plugin_url()."mediaplayer.swf','mpl','\\2','\\3','8');";$my_script .= "\n\t"."so.addParam('allowscriptaccess','always');";$my_script .= "\n\t"."so.addParam('allowfullscreen','true');";$my_script .= "\n\t"."so.addVariable('width','\\2');so.addVariable('height','\\3');";$my_script .= "\n\t"."so.addVariable('showstop','true');so.addVariable('file','\\1');";$my_script .= "\n\t"."so.addVariable('image','\\4');so.addVariable('displayheight','\\3');";$my_script .= "\n\t"."so.write('$movieid');"; $my_script .= "\n\t"."// ]]>"; $my_script .= "\n\t"." </script>";
I always refresh both plugin and the page...
I may be way off-base, but when ever I'm working on plugins I DELETE the plugin then re-install it. Now, if you are seeing a change each time you upload your new material and refresh the plugin then obviously I'm just crazy.
Also do I understand that this is an IE issue? In other words is it working in Firefox or some other browser but not in IE, or is IE the only browser you've been testing with?
You delete it via ftp or just in the CP? Because I delete it in CP... and still the same.
Yup, it's only IE issue... but it really works in IE with that CDATA comments (I saw it in the other site. The only thing I missed in my code were CDATA tags). In other browsers it works without CDATA (and without any need to make line breaks). In Firefox it even works with that <BR />s :D.
Anyway, I can just leave it and use "Object" tag... (it also validates XHTML strict) but I have heard that SWFobject is just sooo great :) It skips the IE "click to activate" stupidity, for example... and has best cross-browser compability. Youtube uses it...
It's 5.00 a.m. where I live... I better go to bed or I'll smash my head onto keyboard :P Thanks for help, see you tomorrow :D
For anybody who would like to experiment: here's the latest update of the plugin:
http://blog.manjikai.com/media/users/admin/Tools/jwplayer.zip
I will look at it tomorrow.
Change
var $priority = 65;
to
var $priority = 10;
You must make sure your priority is higher (and the number lower) than the autop plugin.
This is a likely cause of your <br /> problem.
Good luck
Afwas wrote:
I will look at it tomorrow.
Change
var $priority = 65;
to
var $priority = 10;
You must make sure your priority is higher (and the number lower) than the autop plugin.
This is a likely cause of your <br /> problem.Good luck
I'll need it :)
I changed to priority = 10 and still the same... The auto_p 's priority is 70.
change your plugins priority to 80 ;)
¥
gupik,
The player crashes my browser. Can you have a look at: http://www.blog.hemminga.net/index.php?blog=9 ?
Good luck
SWFObject is used only for FLV player, not yet for mp3 player. :) I can see your player, it's all OK... which browser do you have? I'm worried about your browser's crashing...
OK, I'll try to change the priority.
It's an mp3 indeed and set up with the mp3 player.
I use FireFox 2 and FireFox 3.
My RSS viewer also crashed upon opening the mp3 in the player :/
Yes! :) Now it works! (The flv player) No more <BR />! (The priority set to 80 helped).
Please try to put mp3 into FLV player. It also plays mp3s, just set the height to 20 and put any splash image you like. Tell me if it crashes, ok?
If not, then I'll just delete the mp3 players... these just have nice skins, nothing more.
Well it doesn't crash, actually it plays! Any examples of splash screens? I tried classic.swf, but it leaves a black bar.
I will update swfobject in a second to newest one with patch for IE (it didn't play because of a described somewhere issue...). In a minute I'll deliver updated zip file.
Here's the demo of a player (playing flv file):
http://blog.manjikai.com/dojo.php/basic-flowplayer-integration-plugin
A splash screen is just a simple JPG file.
BTW, instead of a file you can also insert xml files with playlists, but I'll need to make a separate admin button for it (player that plays a playlist doesn't need a splash image)
In this package I'll also include a very nice playlist generator script.
See the player with a playlist in action here:
http://www.jeroenwijering.com/?page=wizard&example=22
OK, plugin updated :)
http://blog.manjikai.com/media/users/admin/Tools/jwplayer_plugin.zip
Now to make another admin button for player with a playlist :D
Can you tell me how this player acts in any rss reader?
EDIT: Hmmm... I think I know wht this plugin breaks RSS reader. The "my_script" part gets read by the reader. As I see the Videoplug plugin, we would need some kind of RenderItemAsXml:
/**
* Perform rendering for XML feeds
*
* @see Plugin::RenderItemAsXml()
*/
function RenderItemAsXml( & $params )
{
$this->RenderItemAsHtml( $params );
/*
$content = & $params['data'];
$Item = & $params['Item'];
$my_script = "";
$sc_script = "";
$content = preg_replace( '¤\[object:flv(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '<p>Media file</p>', $content );
$content = preg_replace( '¤\[object:mp3player:(.+?) width:(.+?) height:(.+?)]¤', '<p>mp3 file</p>', $content );
*/
return true;
}
This is what I added, but it doesn't work...
I try to implement a proper rendering from RSS... without any success.
Can you tell me what's wrong here? (code) It's based on video plugin...
function RenderItemAsHtml( & $params )
{
$content = & $params['data'];
$movieid = $this->strrand(25);
// flash:
$content = preg_replace( '¤\[object:flv:(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '<div id=\''.$movieid.'\' style=\'display:block\'></div>'."\n\t".'<script type=\'text/javascript\'>'."\n\t".'//<![CDATA['."\n\t"."\n\t".'var so = new SWFObject(\''.$this->get_plugin_url().'mediaplayer.swf\',\'mpl\',\'\\2\',\'\\3\',\'8\');'."\n\t".'so.addParam(\'allowscriptaccess\',\'always\');'."\n\t".'so.addParam(\'allowfullscreen\',\'true\');'."\n\t".'so.addVariable(\'width\',\'\\2\');'."\n\t".'so.addVariable(\'height\',\'\\3\');'."\n\t".'so.addVariable(\'showstop\',\'true\');'."\n\t".'so.addVariable(\'file\',\'\\1\');'."\n\t".'so.addVariable(\'image\',\'\\4\');'."\n\t".'so.addVariable(\'displayheight\',\'\\3\');'."\n\t".'so.write(\''.$movieid.'\');'."\n\t"."\n\t".'// ]]>'."\n\t".' </script>' , $content );
$movieid = $this->strrand(25);
// mp3:
$content = preg_replace( '¤\[object:mp3player:(.+?) width:(.+?) height:(.+?)]¤', '<div id=\''.$movieid.'\' style=\'display:block\'></div>'."\n\t".'<script type=\'text/javascript\'>'."\n\t".'//<![CDATA['."\n\t"."\n\t".'var so = new SWFObject(\''.$this->get_plugin_url().'mediaplayer.swf\',\'mpl\',\'\\2\',\'\\3\',\'8\');'."\n\t".'so.addParam(\'allowscriptaccess\',\'always\');'."\n\t".'so.addParam(\'allowfullscreen\',\'true\');'."\n\t".'so.addVariable(\'width\',\'\\2\');'."\n\t".'so.addVariable(\'height\',\'\\3\');'."\n\t".'so.addVariable(\'showstop\',\'true\');'."\n\t".'so.addVariable(\'file\',\'\\1\');'."\n\t".'so.write(\''.$movieid.'\');'."\n\t"."\n\t".'// ]]>'."\n\t".' </script>' , $content );
return true;
}
/**
* Perform rendering for XML feeds
*
* @see Plugin::RenderItemAsXml()
*/
function RenderItemAsXml( & $params )
{
$this->RenderItemAsHtml( $params );
/*
$content = & $params['data'];
$Item = & $params['Item'];
$content = preg_replace( '¤\[object:flv(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '<p>Media file</p>', $content );
$content = preg_replace( '¤\[object:mp3player:(.+?) width:(.+?) height:(.+?)]¤', '<p>MP3 file</p>', $content );
return true;
*/
}
function RenderItemAsXml( & $params )
{
$return_this = $this->RenderItemAsHtml( $params );
return $return_this;
}
Is it a whole function or should I enter something into it as well?... o_O?
Hmm... this function, judging from the source code of the xml page from the reader (standard firefox reader), outputs the post twice, and the output is without a proper rendering. What I want accomplish is to make the renderItemAsXml completely change the output of RenderItemAsHtml... just as in videoplugin.
Hmm... I have a feeling that it has something to do with "CDATA"...
perhaps it is
return true;
You want to copy the complete code from renderItemAsHtml and redo it, the way you want it to be output in the RSS.
I have this function as follows:
function RenderItemAsXml( & $params )
{
$return_this = $this->RenderItemAsHtml( $params );
/*
$content = & $params['data'];
$Item = & $params['Item'];
$content = preg_replace( '¤\[object:flv(.+?) width:(.+?) height:(.+?) bonus:(.+?)]¤', '<p>Media file</p>', $content );
$content = preg_replace( '¤\[object:mp3player:(.+?) width:(.+?) height:(.+?)]¤', '<p>MP3 file</p>', $content );
return $return_this;
*/
}
It still breaks the output of RSS...
EDIT:
OK, I eliminated the CDATA in javascript, as I supposed it was the case of RSS reader breaks... but well, is it possible to completely eliminate the javascript output in the XML? I have written in the RenderItemAsXml "Media file" and "MP3 file" but it doesn't appear...
See here:
http://blog.manjikai.com/dojo.php/basic-flowplayer-integration-plugin
Also: click the Entries RSS at the very bottom.
Try:
function RenderItemAsXml( & $params )
{
$return_this = $this->RenderItemAsHtml( $params );
return true;
}
as far as I see, it displays the same ...
What about RSS enclosure? ...
Hmm, another of my question would be: is it possible for a plugin to render HTML in the <HEAD> area of the page? Or are we forced to edit HTML-Header in skins folder?
... and a stupid question: why can't I put a plugin into a folder? If I do so, b2evo doesn't see it... are there any special kinds of plugins that get displayed when in folders?