|
Friday 16 June 2006 10:40:48 am
Comment44896
Based on Samuel post I patched the extension "Import XML Data Topic" for a support of the data type 'ezxmltext'. It is a bit of a hack because I had to define a fake 'http' class in order to use ez xml validation. Here the code: add this case statement in 'importXMLDatafunctioncollection.php'
case 'ezxmltext':
if( $xml_content_string ) // should be outside the 'switch' statement
{
// Get the embedded data by cutting out everything between the escape tokens
$begin_escape_string = '<![CDATA[';
$end_escape_string = ']]>';
$start_pos = strpos($xml_content_string, $begin_escape_string );
$end_pos = strpos($xml_content_string, $end_escape_string );
if( $start_pos && $end_pos )
{
$embedded_content = substr( $xml_content_string, $start_pos + strlen( $begin_escape_string) , ( $end_pos - $start_pos - strlen($begin_escape_string) ) );
// ez allows a data validation for the datatype ezxmltext
require_once('kernel/classes/datatypes/ezxmltext/handlers/input/ezsimplifiedxmlinput.php');
// but unfortunately the method expect a "http" object and the
// 'contentobjectattribute'
// so here a lot of code just to make this function happy
$fakeHttp = new fakeHttp( $embedded_content );
$myhandler = new eZSimplifiedXMLInput(); // get the handler for input validation
$myhandler->validateInput( $fakeHttp, '', $attribute ); // tons of magic happens here
// I don't have the set the value to the attribute
// the function 'validateInput' does it already
//$attribute->setAttribute( 'data_text', $embedded_content );
// debug the $attribute object
//echo "<pre>";
//print_r( $attribute );
//echo "</pre>";
}
}
break;
add this class to the file
class FakeHttp
{
var $data;
function FakeHttp( $data )
{
$this->data = $data;
}
function postVariable ( $whatever )
{
return $this->data;
}
function hasPostVariable( $whatever )
{
return true;
}
}
http://www.mugo.ca
Mugo Web, eZ Partner in Vancouver, Canada
|