/** * getModelFiles * @author Cornelius Hansjakob <*****@*****.**> * @version 1.0 */ protected function getModelFiles() { if (null === $this->objModelFiles) { /** * autoload only handles "library" compoennts. * Since this is an application model, we need to require it * from its modules path location. */ require_once GLOBAL_ROOT_PATH . $this->core->sysConfig->path->zoolu_modules . 'core/models/Files.php'; $this->objModelFiles = new Model_Files(); $this->objModelFiles->setLanguageId($this->setup->getLanguageId()); } return $this->objModelFiles; }
/** * indexData * @param string $strIndexPath * @param string $strKey * @param array $arrParentPageContainer * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ public function indexData($strIndexPath, $strKey, $arrParentPageContainer = array(), $arrParentFolderIds = array()) { $this->core->logger->debug('massiveart->generic->data->GenericData->indexData(' . $strIndexPath . ', ' . $strKey . ')'); if ($this->objDataType instanceof GenericDataTypeAbstract) { if (count($arrParentPageContainer) > 0) { foreach ($arrParentPageContainer as $intRootLevelId => $objParentPageContainer) { if ($this->setup->getLanguageFallbackId() > 0 && $this->setup->getLanguageFallbackId() != $this->setup->getLanguageId()) { $this->objDataType->updateIndex($strIndexPath, $strKey . '_' . $this->setup->getLanguageFallbackId() . '_r' . $intRootLevelId, $objParentPageContainer, $arrParentFolderIds); } else { $this->objDataType->updateIndex($strIndexPath, $strKey . '_' . $this->setup->getLanguageId() . '_r' . $intRootLevelId, $objParentPageContainer, $arrParentFolderIds); } } } else { $this->objDataType->updateIndex($strIndexPath, $strKey . '_' . $this->setup->getLanguageId()); } } }
/** * addToIndex * @param string $strIndexPath * @param string $strKey * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ protected final function addToIndex($strIndexPath, $strKey) { try { if (!is_object($this->objIndex) || !$this->objIndex instanceof Zend_Search_Lucene) { if (count(scandir($strIndexPath)) > 2) { $this->objIndex = Zend_Search_Lucene::open($strIndexPath); } else { $this->objIndex = Zend_Search_Lucene::create($strIndexPath); } } $objDoc = new Zend_Search_Lucene_Document(); $objDoc->addField(Zend_Search_Lucene_Field::keyword('key', $strKey)); $objDoc->addField(Zend_Search_Lucene_Field::unIndexed('date', $this->setup->getPublishDate('d.m.Y'))); $objDoc->addField(Zend_Search_Lucene_Field::unIndexed('rootLevelId', $this->setup->getRootLevelId())); /** * index fields */ foreach ($this->setup->FieldNames() as $strField => $intFieldType) { $objField = $this->setup->getField($strField); if (is_object($objField) && $objField->idSearchFieldTypes != Search::FIELD_TYPE_NONE) { $strValue = ''; if (is_array($objField->getValue()) && $objField->sqlSelect != '') { $arrIds = $objField->getValue(); $sqlSelect = $objField->sqlSelect; if (is_array($arrIds)) { if (count($arrIds) > 0) { $strReplaceWhere = ''; foreach ($arrIds as $strId) { $strReplaceWhere .= $strId . ','; } $strReplaceWhere = trim($strReplaceWhere, ','); $objReplacer = new Replacer(); $sqlSelect = $objReplacer->sqlReplacer($sqlSelect, $this->setup->getLanguageId(), $this->setup->getRootLevelId(), ' AND tbl.id IN (' . $strReplaceWhere . ')'); $objCategoriesData = $this->core->dbh->query($sqlSelect)->fetchAll(Zend_Db::FETCH_OBJ); if (count($objCategoriesData) > 0) { foreach ($objCategoriesData as $objCategories) { $strValue .= $objCategories->title . ', '; } $strValue = rtrim($strValue, ', '); } } } } else { $strValue = $objField->getValue(); } if ($strValue != '') { switch ($objField->idSearchFieldTypes) { case Search::FIELD_TYPE_KEYWORD: $objDoc->addField(Zend_Search_Lucene_Field::keyword($strField, $strValue, $this->core->sysConfig->encoding->default)); break; case Search::FIELD_TYPE_UNINDEXED: $objDoc->addField(Zend_Search_Lucene_Field::unIndexed($strField, $strValue, $this->core->sysConfig->encoding->default)); break; case Search::FIELD_TYPE_BINARY: $objDoc->addField(Zend_Search_Lucene_Field::binary($strField, $strValue, $this->core->sysConfig->encoding->default)); break; case Search::FIELD_TYPE_TEXT: $objDoc->addField(Zend_Search_Lucene_Field::text($strField, $strValue, $this->core->sysConfig->encoding->default)); break; case Search::FIELD_TYPE_UNSTORED: $objDoc->addField(Zend_Search_Lucene_Field::unStored($strField, strip_tags($strValue), $this->core->sysConfig->encoding->default)); break; } } } } // Add document to the index. $this->objIndex->addDocument($objDoc); $this->objIndex->optimize(); } catch (Exception $exc) { $this->core->logger->err($exc); } }
/** * addField * @param GenericElementField $objField * @author Thomas Schedler <*****@*****.**> * @version 1.2 */ protected function addField(GenericElementField &$objField, $intRegionId, $strNameExtension = '', $intRegionInstanceId = null, $blnEmpty = false) { try { $sqlStmt = array(); $arrOptions = array(); /** * get array options for select output if sqlSelect is in database */ if ($objField->sqlSelect != '' && $objField->sqlSelect) { $objReplacer = new Replacer(); $sqlSelect = $objReplacer->sqlReplacer($objField->sqlSelect, $this->setup->getLanguageId(), $this->setup->getRootLevelId()); $sqlStmt = $this->core->dbh->query($sqlSelect)->fetchAll(); if ($objField->idFieldTypeGroup == GenericSetup::FIELD_TYPE_SELECT_ID) { $arrOptions[''] = 'Bitte wählen'; } foreach ($sqlStmt as $arrSql) { if (array_key_exists('depth', $arrSql)) { $arrOptions[$arrSql['id']] = array('title' => $arrSql['title'], 'depth' => $arrSql['depth']); } else { $arrOptions[$arrSql['id']] = $arrSql['title']; } } } if ($objField->type == GenericSetup::FIELD_TYPE_TEMPLATE) { $objField->defaultValue = $this->setup->getTemplateId(); } if (!is_null($intRegionInstanceId)) { $mixedValue = $objField->getInstanceValue($intRegionInstanceId); } else { $mixedValue = $objField->getValue(); } if ($blnEmpty == true) { $mixedValue = null; } $strCssClass = ''; if ($objField->isKeyField) { $strCssClass = ' keyfield'; } /** * add field to form */ $this->addElement($objField->type, $objField->name . $strNameExtension, array('value' => $mixedValue, 'label' => $objField->title, 'description' => $objField->description, 'decorators' => array($objField->decorator), 'fieldId' => $objField->id, 'columns' => $objField->columns, 'class' => $objField->type . $strCssClass, 'height' => $objField->height, 'isGenericSaveField' => $objField->isSaveField, 'isCoreField' => $objField->isCoreField, 'MultiOptions' => $arrOptions, 'LanguageId' => $this->setup->getLanguageId(), 'isEmptyField' => $blnEmpty == true ? 1 : 0, 'required' => $objField->isKeyField == 1 ? true : false)); $this->getElement($objField->name . $strNameExtension)->regionId = $intRegionId; $this->getElement($objField->name . $strNameExtension)->regionExtension = $strNameExtension; $this->getElement($objField->name . $strNameExtension)->formTypeId = $this->setup->getFormTypeId(); if (count($objField->getProperties()) > 0) { foreach ($objField->getProperties() as $strProperty => $mixedPropertyValue) { if (in_array($strProperty, self::$FIELD_PROPERTIES_TO_IMPART)) { $this->getElement($objField->name . $strNameExtension)->{$strProperty} = $mixedPropertyValue; } } } /** * template specific addons */ if ($objField->type == GenericSetup::FIELD_TYPE_TEMPLATE) { $this->getElement($objField->name . $strNameExtension)->isStartPage = $this->Setup()->getIsStartElement(false); $this->getElement($objField->name . $strNameExtension)->intElementTypeId = $this->Setup()->getElementTypeId(); $this->getElement($objField->name . $strNameExtension)->intParentTypeId = $this->Setup()->getParentTypeId(); } } catch (Exception $exc) { $this->core->logger->err($exc); } }