/** * Determine if a given value is unique within the metamodel. * * @param string $strField the attribute name. * * @param mixed $varNew the value that shall be checked. * * @param int $intId the (optional) id of the item currently in scope - pass null for new items. * * @return bool true if the values is not yet contained within the table, false otherwise. */ public function isUniqueValue($strField, $varNew, $intId = null) { $objFilter = $this->objMetaModel->getEmptyFilter(); $objAttribute = $this->objMetaModel->getAttribute($strField); if ($objAttribute) { $this->calculateSubfilter(array('operation' => '=', 'property' => $objAttribute->getColName(), 'value' => $varNew), $objFilter); $arrIds = $objFilter->getMatchingIds(); return count($arrIds) == 0 || $arrIds == array($intId); } return false; }
/** * Prepare the rendering */ public function prepare() { if ($this->objItems) { return $this; } // create an empty filter object if not done before if (!$this->objFilter) { $this->objFilter = $this->objMetaModel->getEmptyFilter(); } if ($this->objFilterSettings) { $this->objFilterSettings->addRules($this->objFilter, $this->arrParam); } $this->modifyFilter(); $intTotal = $this->objMetaModel->getCount($this->objFilter); $this->calculatePagination($intTotal); $this->objItems = $this->objMetaModel->findByFilter($this->objFilter, $this->strSortBy, $this->intOffset, $this->intLimit, $this->strSortDirection, $this->getAttributeNames()); return $this; }