Share » Forums » Developer » class and attribute filtering

class and attribute filtering

class and attribute filtering

Wednesday 04 February 2009 6:26:16 am - 1 reply

Author Message

Jean-Luc Chassaing

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.

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu