custom repacement tag call

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Pappnase

custom repacement tag call

Post by Pappnase »

hello

you have created your own replacement tag!? i will start in the next days an add-on area at the docu site! so if you have one send it to me with an short discription. and i will publish it at the docu site. but please only send RT's wich will work as external solution in the frontend_render folder.

the e-mail adress you will find at the docu page (imprint)
Pappnase

Post by Pappnase »

hello

never thought that there will be to this thread no response!
User avatar
wireless
Posts: 138
Joined: Sun 24. Oct 2004, 04:35
Location: Houston, Texas

Post by wireless »

Bring on the Tags :-)
Pappnase

add on section in the docu / add on section in der docu

Post by Pappnase »

hello

today i open the add on section! i will hope that i will get new tags in the future ;-)

http://www.phpwcms-docu.de/add_on_en.phtml

-------

hallo

heute habe ich die add on ecke auf der docuseite eröffnet. hoffe das der eine oder andere zum aufbau etwas dazu beiträgt! ;-)

http://www.phpwcms-docu.de/add_on_de.phtml
Paal
Posts: 204
Joined: Wed 6. Oct 2004, 19:54
Location: Budapest, Hungary
Contact:

Re: add on section in the docu / add on section in der docu

Post by Paal »

Pappnase wrote:hello

today i open the add on section! i will hope that i will get new tags in the future ;-)

http://www.phpwcms-docu.de/add_on_en.phtml

-------

hallo

heute habe ich die add on ecke auf der docuseite eröffnet. hoffe das der eine oder andere zum aufbau etwas dazu beiträgt! ;-)

http://www.phpwcms-docu.de/add_on_de.phtml
In this page:
http://www.phpwcms-docu.de/add_on_repla ... s_en.phtml
To change the date language and format please check this link. Languagesettngs.

A Special thank to KUBENS who create this Tag for the docupage.
Not "Languagesettings"?

Tnx, Paul
Pappnase

Post by Pappnase »

THANKS!
User avatar
Kosse
Posts: 1066
Joined: Thu 9. Sep 2004, 12:08
Location: Brussels, Belgium
Contact:

Not frontend render

Post by Kosse »

Hi Pappnase
It is not frontend_render implemented but is this what you're talking about?

http://www.phpwcms.de/forum/viewtopic.php?p=30787

Saludos
Pappnase

Re: Not frontend render

Post by Pappnase »

Kosse wrote:Hi Pappnase
It is not frontend_render implemented but is this what you're talking about?

http://www.phpwcms.de/forum/viewtopic.php?p=30787

Saludos
hello marcos

thansk for the link but as i say without source changes! and when you need to add something into frontfunc it's an source change ;)
User avatar
Kosse
Posts: 1066
Joined: Thu 9. Sep 2004, 12:08
Location: Brussels, Belgium
Contact:

Good luck with it

Post by Kosse »

Sorry Pappnase, I thought I might be a little too "anxious" by posting it, I edited the post and maybe in a near future I'll be able to do it the "proper" way...
Good luck with your issue, I think it is the good way to do it.
Ibis Fernandez
Posts: 67
Joined: Tue 22. Jun 2004, 19:54
Contact:

Post by Ibis Fernandez »

hey guys, not being too familiar with PHP, I was wondering if someone can post an easy example to see what the file should look like. I have done a few replacement tags in front.func.inc but I have no Idea about how to format the stuff so it works from the frontend_render folder.

If someone could please post a frontend_render folder equivalent to the {image} tag, that would be greatly appreaciated, cause then i could see what the difference would be and I can port my tags over to this format.

My current replacement tags include:

Pop-Up Window Button : Iserts a booton that when clicked laches the link in a pop-up window.

Flash Embbeder: Inserts a flash file via replacement tag which allows for greater custimaztion


Mp3 Player: Inserts a flash based MP3 player which plays the mp3 file of your choice

FLV Loader: Inserts a movie player that streams flash video files.

Flash Based Image Viewer: It's a flash movie that loads any given flash files into itself. It preloads the file and and allows for additional stuff like watermarking without actually modifying the image file itself.

RSS Parser: grabs and parses articles from any rss url and iserts the the desired number of links onto the article. (I use this to showcase the latest articles from various websites.)
Ibis Fernandez
Cinestar Filmworks
http://flashfilmmaker.com
http://cinestarfilmworks.com
Author of Macromedia Flash Animation and Cartooning: A Creative Guide
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Post by jsw_nz »

Hi Ibiz...you say you have them working already in front.func?

Should be relatively easy to port to frontend_render....similar syntax...sometimes need to buffer.

if you have some urls and want to post code for each I....(and I guess others) would be interested in taking a look :D .....

btw, have always enjoyed your unique sites. :D
Ibis Fernandez
Posts: 67
Joined: Tue 22. Jun 2004, 19:54
Contact:

Post by Ibis Fernandez »

yes i have them working and some of them are already posted in the mods section. And yes Im sure the conversion will be fairly easy, which is why Im looking for someone to give me a sample of how they would go about convertingting the {image} tag... which I feel is the easiest, and that that way I can tell them appart from the front.func.inc version...

I really like the idea of providing these mods in this format cause I hate having to respond to every little silly thing... where does this go blah blah blah... and had I know this was available I would have done them this way the first time around.

Anywho thanks for the kind words and your offer to help.

One of the tags is as follows:

Code: Select all

// FLASH Loader Replacement tag (Requires flashcntrl.swf to exist in include folder!)	
	$search[33]   	= '/\{FLASHLOADER:(.*),(.*?)x(.*?)\}/';
	$replace[33]	= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="$2" height="$3"><param name="movie" value="/include/flashcntrl.swf?movie=$1"><param name="quality" value="high"><embed src="/include/flashcntrl.swf?movie=$1" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="$2" height="$3"></embed></object>';
this one calls a file called flashctrl.swf and loads it along with the movie I wanted. The functionality is that it preloads the movie based on the users brodbad or low band speed and has a nifty VCR style controls... very useful for quickly adding tutorials and stuff I dont have to worry about creating preloaders, or navigation stuff, I just iupload my swf and emmbed it using the tag. The ctrol file does the rest.
Ibis Fernandez
Cinestar Filmworks
http://flashfilmmaker.com
http://cinestarfilmworks.com
Author of Macromedia Flash Animation and Cartooning: A Creative Guide
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Post by jsw_nz »

Hi Ibis

You could try someting like this (placing in frontend_render folder):

Code: Select all

Syntax:
   
{FLASHLOADER:mySwf.swf:width: height}

function embedFlashLoader($swf,$width,$height){
     $embedString  = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
     $embedString .= " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"";
     $embedString .= " width=\"".$width."\" height=\"".$height."\">";
     $embedString .= " <param name=\"movie\" value=\"/include/flashcntrl.swf\">";
     $embedString .= " <param name=\"quality\" value=\"high\">";
     $embedString .= " <param name=\"FlashVars\" value=\"movie=".$swf."\">";
     $embedString .= " <embed src=\"/include/flashcntrl.swf\" width=\"".$width."\" height=\"".$height."\"";
     $embedString .= " quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"";
     $embedString .= " type=\"application/x-shockwave-flash\" flashvars=\"movie=".$swf."\"></embed></object>";
	return $embedString;	
 }

if(!( strpos($content["all"],'{FLASHLOADER:')===false ) ) { 
     $content["all"] = preg_replace('/\{FLASHLOADER:(.*?):(\d*):(\d*)\}/e','embedFlashLoader("$1","$2","$3");',$content["all"]);
	}
This version uses FlashVars which is the equivalent of the ?get syntax.
I remember reading somewher of a server-side php class that reads the swf header info and returns height, width, framerate, etc.....would be nice to incorporate this, so that you would not have to embed width and height params, other than if you wanted to override defaults...will go looking for this again.
:D

UPDATE: found it:

http://www.phpclasses.org/browse/package/1653.html
SWF header parser
This class is meant to parse the header of Shockwave Flash animation files (.swf) to extract metadata information like the width and height of animation, compression status and uncompressed size, frame rate and total number of frames.

This class parses Flash files using only PHP code, so no special extension is necessary.

Supports both, compressed and uncompressed SWF Flash movies
Ibis Fernandez
Posts: 67
Joined: Tue 22. Jun 2004, 19:54
Contact:

Post by Ibis Fernandez »

excellent work man on both account, I'll give it a shot and post my final mods here or where ever they are most appropriate... go get som sleep right now though so you may not hear from me for a good 12 hours or so LOL.... :shock:

I'll give it a shot as soon as i get rid of this damn pesky need for something as pointless as sleeping LOL.


Thanks!
Ibis Fernandez
Cinestar Filmworks
http://flashfilmmaker.com
http://cinestarfilmworks.com
Author of Macromedia Flash Animation and Cartooning: A Creative Guide
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Post by jsw_nz »

OK...got an alternative version that does not require entering width and height dimensions. It uses the class as mentioned, which reads swf- header information in binary format. I tweaked the class a wee bit to return only width dnd height parameters. It does require you to place the class file in your flash directory and call it via:

include ("flash/swfheader_wcms.class.php");

Here is REP TAG code:

Code: Select all


{SWFLOADER:fileName.swf}

// uses base.swf as assumed name for the base swf (change to suit)

function embedBaseLoader($loadExtSwf){
     include ("flash/swfheader_wcms.class.php");
     $swf = new swfheader();
     $dimensions = $swf->getDimensions("flash/base.swf");
     $dimensions_array = explode("|",$dimensions);
     $width=$dimensions_array[0];
     $height=$dimensions_array[1];
     $embedString = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
     $embedString .= " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"";
     $embedString .= " width=\"".$width."\" height=\"".$height."\">";
     $embedString .= " <param name=\"movie\" value=\"flash/base.swf\">";
     $embedString .= " <param name=\"quality\" value=\"high\">";
     $embedString .= " <param name=\"FlashVars\" value=\"movie=".$loadExtSwf."\">";
     $embedString .= " <embed src=\"flash/base.swf\" width=\"".$width."\" height=\"".$height."\"";
     $embedString .= " quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"";
     $embedString .= " type=\"application/x-shockwave-flash\" flashvars=\"movie=".$loadExtSwf."\"></embed></object>";

     return $embedString;	
 }

if(!( strpos($content["all"],'{SWFLOADER:')===false ) ) { 
     $content["all"] = preg_replace('/\{SWFLOADER:(.*?)\}/e','embedBaseLoader("$1");',$content["all"]);
     }
?>

Here is code for swfheader_wcms.class.php, a wee bit long, but should be a copy and paste situation:
UPDATE: to get width and height do not use this class
- read further on in this thread - recommendation by OliG


leaving it here if other paramaters (for other scripts) need these to be extracted - jsw_nz

Code: Select all

<?PHP 
//-----------------------------------------------------------------------------
// SWF HEADER - version 1.0
// Small utility class to determine basic data from a SWF file header
// Does not need any php-flash extension, based on raw binary data reading
//----------------------------------------------------------------------------- 
//	SWFHEADER CLASS - PHP SWF header parser
//	Copyright (C) 2004  Carlos Falo Hervás
//	This library is free software; you can redistribute it and/or
//	modify it under the terms of the GNU Lesser General Public
//	License as published by the Free Software Foundation; either
//	version 2.1 of the License, or (at your option) any later version.
//----------------------------------------------------------------------------- 

class swfheader {
	var $debug ;				// Output DEBUG info
	var $fname ;				// SWF file analyzed
	var $magic ;				// Magic in a SWF file (FWS or CWS)
	var $compressed ;		// Flag to indicate a compressed file (CWS)
	var $version ;			// Flash version
	var $size ;					// Uncompressed file size (in bytes)
	var $width ;				// Flash movie native width
	var $height ;				// Flash movie native height
	var $valid ;				// Valid SWF file
	var $fps ;					// Flash movie native frame-rate
	var $frames ;				// Flash movie total frames
	//--------------------------------------------------------------------------- 	
	// swfheader($debug) : 	Constructor, basically does nothing but initilize 
	//											debug and data fields
	//--------------------------------------------------------------------------- 
	function swfheader($debug = false) {
		$this->debug = false ;
		$this->init() ;
	  }
	//--------------------------------------------------------------------------- 	
	// init() : initialize the data fields to "empty" values
	//--------------------------------------------------------------------------- 
	function init() {
		$this->valid 			= false ;
		$this->fname		  = "" ;
		$this->magic			= "" ;
		$this->compressed = false ;
		$this->version 		= 0 ;
		$this->width 			= 0 ;
		$this->height			= 0 ;
		$this->size				= 0 ;
		$this->frames			= 0 ;
		$this->fps[] 			= Array() ;
	  }
	//---------------------------------------------------------------------------
	// loadswf($filename) : loads $filename and stores data from it's header
	//--------------------------------------------------------------------------- 
	function getDimensions($filename) {
		$this->fname = $filename ;
		$fp = @fopen($filename,"rb") ;
		if ($fp) {
			$this->magic = fread($fp,3) ;
			if ($this->magic!="FWS" && $this->magic!="CWS") {
				$this->valid =  0 ;
			} else {
				// Compression
				if (substr($this->magic,0,1)=="C") $this->compressed = true ;
					else $this->compressed = false ;
				// version
				$this->version = ord(fread($fp,1)) ;
				// Size
				$lg = 0 ;
				// 4 LSB-MSB
				for ($i=0;$i<4;$i++) {
					$t = ord(fread($fp,1)) ;
					$lg += ($t<<(8*$i)) ;
					}
				$this->size = $lg ;
				// RECT... we will "simulate" a stream from now on... read remaining file
				$buffer = fread($fp,$this->size) ;
				if ($this->compressed) {
					// First decompress GZ stream
					$buffer = gzuncompress($buffer,$this->size) ;
					}
				$b	= ord(substr($buffer,0,1)) ;
				$buffer = substr($buffer,1) ;
				$cbyte 	= $b ;
				$bits 	= $b>>3 ;
				$cval 	= "" ;
				// Current byte
				$cbyte &= 7 ;
				$cbyte<<= 5 ;
				// Current bit (first byte starts off already shifted)
				$cbit 	= 2 ;
				// Must get all 4 values in the RECT
				for ($vals=0;$vals<4;$vals++) {
					$bitcount = 0 ;
					while ($bitcount<$bits) {
						if ($cbyte&128) {
							$cval .= "1" ;
						} else {
							$cval.="0" ;
							}
						$cbyte<<=1 ;
						$cbyte &= 255 ;
						$cbit-- ;
						$bitcount++ ;
						// We will be needing a new byte if we run out of bits
						if ($cbit<0) {
							$cbyte	= ord(substr($buffer,0,1)) ;
							$buffer = substr($buffer,1) ;
							$cbit = 7 ;
							}
					  }
					// O.k. full value stored... calculate
					$c 		= 1 ;
					$val 	= 0 ;
					// Reverse string to allow for SUM(2^n*$atom)
					$tval = strrev($cval) ;
					for ($n=0;$n<strlen($tval);$n++) {
						$atom = substr($tval,$n,1) ;
						if ($atom=="1") $val+=$c ;
						// 2^n
						$c*=2 ;
					  }
					// TWIPS to PIXELS
					$val/=20 ;
					switch ($vals) {
						case 0:
							// tmp value
							$this->width = $val ;
						break ;
						case 1:
							$this->width = $val - $this->width ;
						break ;
						case 2:
							// tmp value
							$this->height = $val ;
						break ;
						case 3:
							$this->height = $val - $this->height ;
						break ;
					  }
					$cval = "" ;
				  }
				// Frame rate
				$this->fps = Array() ;
				for ($i=0;$i<2;$i++) {
					$t 			= ord(substr($buffer,0,1)) ;
					$buffer = substr($buffer,1) ;
					$this->fps[] = $t ;
					}
				// Frames
				$this->frames = 0 ;
				for ($i=0;$i<2;$i++) {
					$t 			= ord(substr($buffer,0,1)) ;
					$buffer = substr($buffer,1) ;
					$this->frames += ($t<<(8*$i)) ;
					}
				fclose($fp) ;
				$this->valid =  1 ;
	  		}
		} else {
			$this->valid = 0 ;
		  }
		if ($this->valid) {
			$this_width = $this->width;
			$this_height = $this->height;
			$swf_dimensions=$this->width."|".$this->height;
			return $swf_dimensions;
			}
 		}	
	}
?>
Hope this helps :D
Last edited by jsw_nz on Mon 1. Aug 2005, 02:15, edited 3 times in total.
Post Reply