/** * Process a placeholder node if it's part of 'contains()' * or equals ('=' or '==') expression. * @param epQueryNode &$node * @return boolean */ protected function processPlaceholder(epQueryNode &$node) { // done if not a placeholder node if ($node->getType() != EPQ_N_PLACEHOLDER) { return true; } // get placeholder value if (!($v =& $this->_getPlaceholderValue($node))) { return true; } // we only process array or epObject if (!is_array($v) && !$v instanceof epObject) { return true; } // get parent node if (!($parent =& $node->getParent())) { return true; } // path prefix for the placeholder value $prefix = ''; // is it a part of contains()? if (($parent_t = $parent->getType()) == EPQ_N_CONTAINS) { if ($var =& $parent->getChild('var')) { if ($path = $var->getParam('path')) { $this->pm->addContainedRoot($path, $prefix); } } } else { if ($parent_t == EPQ_N_EXPR_COMPARISON) { if ('=' == $parent->getParam('op')) { if ($left = $parent->getChild('left')) { if ($left->getType() == EPQ_N_VARIABLE) { $prefix = $left->getParam('path'); } } if ($right = $parent->getChild('right')) { if ($right->getType() == EPQ_N_VARIABLE) { $prefix = $right->getParam('path'); } } } } } // no more processing if prefix is still empty if (!$prefix) { return true; } // check if prefix points to an object and the placehodler // is a *persisted* epObject. a non-persisted object is // treated as an example object. if ($this->pm->isObject($prefix)) { if ($v instanceof epObject && $v->oid) { // if so, set 'specific' class on query path $this->pm->specificClass($prefix, $v->epGetClass()); } } // create a syntax tree for the array/object if (!($nodes =& $this->_createSyntaxNodes($v, $prefix))) { return true; } // make AND syntax nodes if (!($and_node = $this->_andNodes($nodes))) { return true; } // get parent's parent if (!($grand_parent = $parent->getParent())) { return true; } // call grand-parent to replace with parent this 'and' node $grand_parent->replaceChild($parent, $and_node); // keep the replaced node so later we can reverse $and_node->setParam("replaced", $parent); return true; }