Tuesday 05 September 2006 3:19:04 pm
Hi My first attempt to create an own datatype was not very successful.
I have followed more or less the instructions found here: http://ez.no/products/ez_publish/documentation/development/extensions/datatypes/new_datatype ezclientiptype.php found in extension/clientip/datatypes/ezclientip looks like this:
<?php
/*
* Ins schmiroh 6.9.2006
* Followed instructions found in
* http://ez.no/products/ez_publish/documentation/development/extensions/datatypes/new_datatype
*/
// Include the super class file
include_once( "kernel/classes/ezdatatype.php" );
// Include the file which will be used to validate clientip
include_once( "lib/ezutils/classes/ezclientip.php" );
// Define the name of datatype string
define( "EZ_DATATYPESTRING_CLIENTIP", "ezclientip" );
class eZClientIPType extends eZDataType
{
/*!
Construction of the class, note that the second parameter in eZDataType
is the actual name showed in the datatype dropdown list.
*/
function eZEmailType()
{
$this->eZDataType( EZ_DATATYPESTRING_CLIENTIP, "Client IP" );
}
/*!
Validates the input and returns true if the input was valid for this
datatype. Here there are no rules for validating client ip, because it is
automatically set by the system and is read only.
*/
function validateObjectAttributeHTTPInput( &$http, $base,
&$contentObjectAttribute )
{
return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
}
/*!
There is no http input to be fetched. Therefore we leave this function empty.
*/
function fetchObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute )
{
return false; //not sure, if true or false
}
/*!
Store the content.
*/
function storeObjectAttribute( &$contentObjectattribute )
{
$data = $_SERVER['HTTP_CLIENT_IP'];
$contentObjectAttribute->setAttribute( "data_text", $data );
return false; //not sure, if true or false
}
/*!
Returns the content.
*/
function &objectAttributeContent( &$contentObjectAttribute )
{
return $contentObjectAttribute->attribute( "data_text" );
}
/*!
Returns the meta data used for storing search indices.
*/
function metaData( $contentObjectAttribute )
{
return $contentObjectAttribute->attribute( "data_text" );
}
/*!
Returns the text.
*/
function title( &$contentObjectAttribute )
{
return $contentObjectAttribute->attribute( "data_text" );
}
}
eZDataType::register( EZ_DATATYPESTRING_CLIENTIP, "ezclientiptype" );
All the other steps were followed really carefully, including activation in admin interface, but the new datatype ("Client IP") is not showing up in datatype dropdown. Maybe someone can have a look in the code above and finds a reason for this, or can give me any hint. Are there any logs available when activating a new datatype? Debugging information in admin interface does not give any info on that.
Thanks and regards, Roger
|