type = $type; $this->crits = $crits; } function testComp($comp) { $selected = true; foreach($this->crits as $attr => $value) { if ($attr == 'id') { if ($comp->getId() != $value) { $selected = false; break; } } else { if ($comp->$attr != $value) { $selected = false; break; } } } return $selected; } function visitFormosite(Formosite $comp, $level) { if ($this->testComp($comp)) { $this->matches[] = $comp; } } function visitPage(Page $comp, $level) { if ($this->testComp($comp)) { $this->matches[] = $comp; } } function visitBlock(Block $comp, $level) { if ($this->testComp($comp)) { $this->matches[] = $comp; } } function visitField(Field $comp, $level) { if ($this->testComp($comp)) { $this->matches[] = $comp; } } function unique() { $unique = (count($this->matches) == 1 && is_object($this->matches[0])) ? true : false; return $unique; } function matches($index='') { if ($index !== '' && is_numeric($index)) { return $this->matches[$index]; } else { return $this->matches; } } } ?>