<?
	require_once("objects/domains/_base.php");

	// $spaw_root = getenv('DOCUMENT_ROOT').dirname(getenv('PHP_SELF')).'/objects/extern/spaw/';
	$spaw_root = dirname($_SERVER["SCRIPT_FILENAME"]).'/objects/extern/spaw/';
	// include $spaw_root.'spaw_control.class.php';


	class DomRichText extends DomBase
	{
		function DomRichText($str) 
		{
			$this->DomBase($str);
			$this->title = $GLOBALS[cat_m_dom_richtext];

			$this->sql = $this->name.' text';
			$this->valid = true;
		}
		
		function onEditForm($str)
		{
			$val = $str[$this->name];
			$s = "<tr><td class='einfo' align='center' valign='top' colspan='2'><font class='etitle'>";
			$s .= $this->info;
			$s .= "</font><br><font class='ecomment' valign='top'>";		
			$s .= $this->comment; 
			$s .= "</font></td></tr><tr><td class='eedit' colspan='2'>";
		
			$sw = new SPAW_Wysiwyg('dom_'.$this->name,$val);
			$s .= $sw->getHtml();

			$s .= "</td></tr>";
			return $s;		
		}


		function getFromInput()
		{
			$s =  $GLOBALS['dom_'.$this->name];

			$s = eregi_replace("<?xml([^>]*)>","",$s);
			$s = str_replace("class=MsoNormal","",$s);
			$s = str_replace("<o:p>","",$s);
			$s = str_replace("</o:p>","",$s);

			$s = str_replace("<?","",$s);
			$s = str_replace("?>","",$s);

			$s = eregi_replace("<SPAN([^>]*)>","",$s);
			$s = eregi_replace("</SPAN>","",$s);

			$s = eregi_replace(" size=([0-9+-]*)","",$s);
			$s = eregi_replace(" face=([^>]*)","",$s);
			$s = eregi_replace("<FONT></FONT>","",$s);

			while(ereg("img_url=([^']*)'",$s,$r)) {
			        $p = '';
				$f = substr($r[1],0,-1);
				$f = str_replace("CAT2/objects/extern/spaw/dialogs/../../../../../","",$f);
				if(file_exists('../'.$f)) {
					$k =  getImageSize('../'.$f);
					$p = "\'".$f."\',\'\',\'width=".($k[0] + 20).",height=".($k[1] + 20).",scrollbars=no,toolbar=no,location=no,status=no,resizable=no\')";
				};
				$s = str_replace("\'objects/extern/spaw/img_popup.php?".$r[0].",\'Image\',\'width=500,height=300,scrollbars=no,toolbar=no,location=no,status=no,resizable=yes,screenX=120,screenY=100\');return false;",$p,$s);				
			}

	        	return $s;
		}

	};




?>