Thursday 05 February 2009 2:06:17 am
I found a solution and would like to have your opinion. My problem deals with the inheritance between classes. So I solved it by using an extended attribute filter. Here is the code for this filter :
class eZMultiClassAttributeFilter
{
/**
* Constructor
*
*/
function __construct()
{
}
public function filterAttributes($params)
{
$sqlJoins = "";
$subrequest = array();
$attribId = '(';
foreach ( $params as $key => $sort )
{
if ($key > 0)
{
$attribId .= ',';
}
if (! is_numeric( $sort[0] ))
{
$attribId .= eZContentObjectTreeNode::classAttributeIDByIdentifier( $sort[0] );
} else
{
$attribId .= $sort[0];
}
}
$attribId .= ')';
$subrequest = "SELECT attr.contentobject_id
FROM ezcontentobject_attribute as attr, ezcontentobject as obj
WHERE obj.id = attr.contentobject_id
AND attr.version = obj.current_version
AND attr.contentclassattribute_id in $attribId
AND attr.data_int = 0 ";
$sqlJoins .= " ezcontentobject.id in (" . $subrequest . ") AND";
return array('tables' => '', 'joins' => $sqlJoins, 'colums' => '' );
}
}
it would need some more improvements on the attribute filtering but this solution solved my problem.
|