/**
  * Returns true if the filter should be displayed
  * @param Mage_Catalog_Block_Layer_Filter_Abstract $filter
  * @param number $categoryId
  * @return bool
  */
 public function displayFilter(Mage_Catalog_Block_Layer_Filter_Abstract $filter, $categoryId)
 {
     $inclusionFilterRules = $this->getFilterRules(self::RULES_TYPE_INCLUSION);
     $exclusionFilterRules = $this->getFilterRules(self::RULES_TYPE_EXCLUSION);
     $display = true;
     /** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */
     $attribute = $filter->getAttributeModel();
     if (!$attribute) {
         return $display;
     }
     $code = $attribute->getAttributeCode();
     // if there is a rule for this code, validate
     if (isset($inclusionFilterRules[$code])) {
         $display = false;
         $rules = $inclusionFilterRules[$code];
         foreach ($rules as $rule) {
             // if there is not a value for the rule, then there is nothing to validate against and it has passed
             // if there is a value, then check that they match
             $ruleCategoryId = !$rule['category_id'] ? true : $rule['category_id'] == $categoryId;
             if ($ruleCategoryId) {
                 $display = true;
                 break;
             }
         }
     }
     if ($display == true && isset($exclusionFilterRules[$code])) {
         $rules = $exclusionFilterRules[$code];
         foreach ($rules as $rule) {
             if ($rule['category_id'] == $categoryId) {
                 $display = false;
                 break;
             }
         }
     }
     return $display;
 }