/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


#ifndef DDWEBRENDERTAG_H
#define DDWEBRENDERTAG_H

#include <dddataobject.h>
#include <ddconfig.h>
#include <ddmapptr.h>
#include <dditem.h>

class ddwebrendertagblock;

/// ddwebrenderer: Rendert BBCodes
/**
	Ex dditemblock bzw. dditemblockarticle, rendert die BBCodes. Wurde nötig, um die neuen Bild-Tags
	zu rendern, da diese jetzt auch die Id und den domainnamen benötigen.
*/

class ddwebrendertag : public ddbasename
{

public:
    
	ddwebrendertag( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual ~ddwebrendertag();
	
	virtual ddwebrendertag* create( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual size_t render( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& rawkey, const ddstring& param, size_t beg, ddstring& target );

	void dump() const;
		
protected:
		
	ddwebrendertagblock* 	_parent;
	ddstring 							_tagbegin;
	ddstring 							_tagend;
		
};

/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/

/// ddwebrendertagoptend: Ein BBCode-Tag mit optionalem Ende
/**
	Typisches Legacy-Problem: <li> Tags wurden bisher als single-Tags verwendet,
	der w3c standard schreibt aber ein end-tag vor und der neue Editor fügt das auch 
	ein, also muss das end-tag als nur dann gerendert werden wenns da ist.
*/

class ddwebrendertagoptend : public ddwebrendertag
{

public:
    
	ddwebrendertagoptend( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual ~ddwebrendertagoptend();
	
	virtual ddwebrendertag* create( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual size_t render( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& rawkey, const ddstring& param, size_t beg, ddstring& target );

};


/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


/// ddwebrendererblock: Rendert BBCodes
/**
	Ex dditemblock bzw. dditemblockarticle, rendert die BBCodes. Wurde nötig, um die neuen Bild-Tags
	zu rendern, da diese jetzt auch die Id und den domainnamen benötigen.
*/

class ddwebrendertagparam : public ddwebrendertag
{

public:
    
	ddwebrendertagparam( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual ~ddwebrendertagparam();
	
	virtual ddwebrendertag* create( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual size_t render( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& rawkey, const ddstring& param, size_t beg, ddstring& target );

protected:

	ddstringrow _tagparam;		
		
};


/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


/// ddwebrendererlist: Rendert Aufzählungen
/**
	
	Unterstützt werden die in der SN-Hilfe angegebenen Formate:

	[list]		: bobbel
	[list=1]	: numeriert
	[list=i]	: römisch klein
	[list=I]	: römisch groß
	[list=a]	: buchstaben klein
	[list=A]	: buchstaben groß

	Der Hack an det janze ist, das mal <ul>, mal <ol>s generiert werden müssen
	
*/

class ddwebrendertaglist : public ddwebrendertag
{

public:
    
	ddwebrendertaglist( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual ~ddwebrendertaglist();
	
	virtual ddwebrendertag* create( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual size_t render( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& rawkey, const ddstring& param, size_t beg, ddstring& target );
		
};


/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


/// ddwebrendererimage: Rendert BBCodes
/**
	Ex dditemblock bzw. dditemblockarticle, rendert die BBCodes. Wurde nötig, um die neuen Bild-Tags
	zu rendern, da diese jetzt auch die Id und den domainnamen benötigen.
*/

class ddwebrendertagimage : public ddwebrendertagparam
{

public:
    
	ddwebrendertagimage( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual ~ddwebrendertagimage();
	
	virtual ddwebrendertag* create( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual size_t render( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& rawkey, const ddstring& param, size_t beg, ddstring& target );
		
protected:

	ddstringrow _imagevotes;		

};


/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


/// ddwebrendererblock: Rendert BBCodes
/**
	Ex dditemblock bzw. dditemblockarticle, rendert die BBCodes. Wurde nötig, um die neuen Bild-Tags
	zu rendern, da diese jetzt auch die Id und den domainnamen benötigen.
*/

class ddwebrendertagurl : public ddwebrendertagparam
{

public:
    
	ddwebrendertagurl( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual ~ddwebrendertagurl();
	
	virtual ddwebrendertag* create( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual size_t render( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& rawkey, const ddstring& param, size_t beg, ddstring& target );
		
};


/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


/// ddwebrendererblock: Rendert BBCodes
/**
	Ex dditemblock bzw. dditemblockarticle, rendert die BBCodes. Wurde nötig, um die neuen Bild-Tags
	zu rendern, da diese jetzt auch die Id und den domainnamen benötigen.
*/

class ddwebrendertagcode : public ddwebrendertag
{

public:
    
	ddwebrendertagcode( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual ~ddwebrendertagcode();
	
	virtual ddwebrendertag* create( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual size_t render( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& rawkey, const ddstring& param, size_t beg, ddstring& target );

};


/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


/// ddwebrenderervideo: Rendert BBCodes
/**
	Ex dditemblock bzw. dditemblockarticle, rendert die BBCodes. Wurde nötig, um die neuen Bild-Tags
	zu rendern, da diese jetzt auch die Id und den domainnamen benötigen.
*/

class ddwebrendertagvideo : public ddwebrendertagparam
{

public:
	/*
		video	 	 = "video,<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='|1|' height='|2|' id='|3|' name='|4|'>
						<param name='movie' value='/video/player-viral.swf'>
						<param name='allowfullscreen' value='true'>
						<param name='allowscriptaccess' value='always'>
						<param name='play' value='true'>
						<param name='wmode' value='transparent'>
						<param name='flashvars' value='file=|5|&|autostart=true|'>
						<embed
						type='application/x-shockwave-flash'
						id='single2'
						name='single2'
						src='/video/player-viral.swf'
						width='|7|'
						height='|8|'
						bgcolor='undefined'
						allowscriptaccess='always'
						allowfullscreen='true'
						wmode='transparent'
						flashvars='file=|9|&|autostart=true|'
						/>
						</object>";

	*/
	
	enum dd_videotag_fields
	{
		videotag_width1			= 1,
		videotag_height1		= 3,
		videotag_id1				= 5,
		videotag_name1 			= 7,
		videotag_file1			= 9,
		videotag_img1				= 11,
		videotag_id2				= 13,
		videotag_name2 			= 15,		
		videotag_width2			= 17,
		videotag_height2		= 19,
		videotag_file2			= 21,
		videotag_img2				= 23,
	};
	
	//[video=testvideo.mp4300;300;moo.jpg;]
	enum dd_videoparam_fields
	{
		videoparam_file			= 0,
		videoparam_width		= 1,
		videoparam_height		= 2,
		videoparam_image		= 3,
	};

	ddwebrendertagvideo( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual ~ddwebrendertagvideo();
	
	virtual ddwebrendertag* create( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual size_t render( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& rawkey, const ddstring& param, size_t beg, ddstring& target );
			
};




/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


/// ddwebrenderervideo: Rendert BBCodes
/**
	Ex dditemblock bzw. dditemblockarticle, rendert die BBCodes. Wurde nötig, um die neuen Bild-Tags
	zu rendern, da diese jetzt auch die Id und den domainnamen benötigen.
*/

class ddwebrendertagyoutube : public ddwebrendertagparam
{

public:
	/*
							
	youtube	=	"<object width='425' height='344'><param name='movie' value='http://www.youtube.com/v/l5Y2Y2UISAY&hl=de&fs=1'></param>
						<param name='allowFullScreen' value='true'></param>
						<param name='allowscriptaccess' value='always'></param>
						<embed 
							src='http://www.youtube.com/v/l5Y2Y2UISAY&hl=de&fs=1' 
							type='application/x-shockwave-flash' 
							allowscriptaccess='always' 
							allowfullscreen='true' 
							width='425' 
							height='344'>
						</embed>
						</object>";
	

	*/
	
	

	ddwebrendertagyoutube( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual ~ddwebrendertagyoutube();
	
	virtual ddwebrendertag* create( const ddstring& name, ddwebrendertagblock* parent, const ddstring& begin, const ddstring& end="" );
	virtual size_t render( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& rawkey, const ddstring& param, size_t beg, ddstring& target );
			
};


/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


/// ddwebrendererblock: Rendert BBCodes
/**
	Ex dditemblock bzw. dditemblockarticle, rendert die BBCodes. Wurde nötig, um die neuen Bild-Tags
	zu rendern, da diese jetzt auch die Id und den domainnamen benötigen.
*/

class ddwebrendertagfactory : public ddmapptr<ddwebrendertag>
{

public:
    
	ddwebrendertagfactory();
	virtual ~ddwebrendertagfactory();
	
	ddwebrendertag* create_tag( const ddstring& name, ddwebrendertagblock* parent, const ddstring& tagdata, ddstring& key );
	
};


/***************************************************************************

    supportware
    Copyright (C) 2001-2007 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


/// ddwebrendererblock: Rendert BBCodes
/**
	Ex dditemblock bzw. dditemblockarticle, rendert die BBCodes. Wurde nötig, um die neuen Bild-Tags
	zu rendern, da diese jetzt auch die Id und den domainnamen benötigen.
*/

class ddwebrendertagblock : public ddbasename, public ddmapptr<ddwebrendertag>
{

public:
    
  ddwebrendertagblock( const ddstring& name, bool nofollow, bool chopflag );
  virtual ~ddwebrendertagblock();
  
  inline bool get_no_follow_flag()
  {
  	return _nofollow;
  }
  
  inline bool get_chop_flag()
  {
  	return _chopflag;
  }
  
  void render( ddwebpage& pagelet, dditem& item, dddatastaterow& row, const ddstring& source );
	
	void dump() const;
	 
protected:	
 	
 	size_t render_tag( ddwebpage& pagelet, dddatastaterow& row, ddstring& source, const ddstring& key, size_t beg, ddstring& target );
	
	virtual bool 			re_replace_br( ddstring& target, size_t& p1 );
	
	bool							_nofollow;
	bool							_chopflag;
	
};


/***************************************************************************

    supportware
    Copyright (C) 2001-2008 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/

/// ddwebviewmap: eine ptrmap mit tabellen
/**	
	
	ddwebviewmap: eine ptrmap mit tabellen

*/

class ddwebrendertagblockmap : public ddmapptr<ddwebrendertagblock>
{

public:

	ddwebrendertagblockmap();
	virtual ~ddwebrendertagblockmap();
	
	void init_tag_blocks( ddconfig& config );
	
protected:

	void add_tag_block( ddconfig& config, ddconfigsection& section );
	
	ddwebrendertagfactory _tagfactory;
	
};


#endif
