/**
  * 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
  * @param PageContainer $objParentPageContainer
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 protected final function addToIndex($strIndexPath, $strKey, $objParentPageContainer = null, $arrParentFolderIds = array())
 {
     try {
         $this->core->logger->debug('massiveart->generic->data->types->GenericDataTypeAbstract->addToIndex(' . $strIndexPath . ', ' . $strKey . ')');
         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);
             }
         }
         Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
         $objDoc = new Zend_Search_Lucene_Document();
         $objDoc->addField(Zend_Search_Lucene_Field::keyword('key', $strKey));
         if ($this->setup->getLanguageFallbackId() > 0 && $this->setup->getLanguageFallbackId() != $this->setup->getLanguageId()) {
             $objDoc->addField(Zend_Search_Lucene_Field::keyword('languageId', $this->setup->getLanguageFallbackId()));
         } else {
             $objDoc->addField(Zend_Search_Lucene_Field::keyword('languageId', $this->setup->getLanguageId()));
         }
         $objDoc->addField(Zend_Search_Lucene_Field::keyword('rootLevelId', $this->setup->getRootLevelId()));
         $objDoc->addField(Zend_Search_Lucene_Field::unIndexed('date', $this->setup->getPublishDate('d.m.Y')));
         $objDoc->addField(Zend_Search_Lucene_Field::unIndexed('elementTypeId', $this->setup->getElementTypeId()));
         if ($objParentPageContainer !== null && $objParentPageContainer instanceof PageContainer) {
             if (count($objParentPageContainer->getEntries()) > 0) {
                 $objDoc->addField(Zend_Search_Lucene_Field::unIndexed('parentPages', serialize($objParentPageContainer->getEntries())));
                 $objDoc->addField(Zend_Search_Lucene_Field::keyword('rootLevelId', end($objParentPageContainer->getEntries())->rootLevelId));
             }
         }
         if (count($arrParentFolderIds) > 0) {
             $objDoc->addField(Zend_Search_Lucene_Field::unStored('parentFolderIds', implode(',', $arrParentFolderIds)));
         }
         /**
          * index fields
          */
         foreach ($this->setup->FieldNames() as $strField => $intFieldType) {
             $objField = $this->setup->getField($strField);
             if (is_object($objField) && $objField->idSearchFieldTypes != Search::FIELD_TYPE_NONE) {
                 $this->indexFieldNow($objField, $strField, $intFieldType, $objField->getValue(), $objDoc);
             }
         }
         foreach ($this->setup->MultiplyRegionIds() as $intRegionId) {
             $objRegion = $this->setup->getRegion($intRegionId);
             if ($objRegion instanceof GenericElementRegion) {
                 $intRegionPosition = 0;
                 foreach ($objRegion->RegionInstanceIds() as $intRegionInstanceId) {
                     $intRegionPosition++;
                     foreach ($objRegion->FieldNames() as $strField => $intFieldType) {
                         $objField = $objRegion->getField($strField);
                         if (is_object($objField) && $objField->idSearchFieldTypes != Search::FIELD_TYPE_NONE) {
                             $this->indexFieldNow($objField, $objField->name . '_' . $intRegionPosition, $intFieldType, $objField->getInstanceValue($intRegionInstanceId), $objDoc);
                         }
                     }
                 }
             }
         }
         // Add document to the index.
         $this->objIndex->addDocument($objDoc);
         unset($objDoc);
         $this->objIndex->optimize();
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
Exemple #3
0
 /**
  * update
  * @param GenericSetup $objGenericSetup
  * @param object Global
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function update(GenericSetup &$objGenericSetup, $objGlobal)
 {
     $this->core->logger->debug('global->models->Model_Globals->update()');
     $intUserId = Zend_Auth::getInstance()->getIdentity()->id;
     $strWhere = $this->getGlobalTable()->getAdapter()->quoteInto('globalId = ?', $objGlobal->globalId);
     $strWhere .= $this->getGlobalTable()->getAdapter()->quoteInto(' AND version = ?', $objGlobal->version);
     $this->getGlobalTable()->update(array('idUsers' => $intUserId, 'changed' => date('Y-m-d H:i:s')), $strWhere);
     /**
      * update language specific global properties
      */
     $strWhere .= $this->getGlobalTable()->getAdapter()->quoteInto(' AND idLanguages = ?', $this->intLanguageId);
     $intNumOfEffectedRows = $this->getGlobalPropertyTable()->update(array('idGenericForms' => $objGenericSetup->getGenFormId(), 'idTemplates' => $objGenericSetup->getTemplateId(), 'idGlobalTypes' => $objGenericSetup->getElementTypeId(), 'showInNavigation' => $objGenericSetup->getShowInNavigation(), 'idLanguageFallbacks' => $objGenericSetup->getLanguageFallbackId(), 'idUsers' => $intUserId, 'creator' => $objGenericSetup->getCreatorId(), 'idStatus' => $objGenericSetup->getStatusId(), 'published' => $objGenericSetup->getPublishDate(), 'changed' => date('Y-m-d H:i:s')), $strWhere);
     /**
      * insert language specific global properties
      */
     if ($intNumOfEffectedRows == 0) {
         $arrProperties = array('globalId' => $objGlobal->globalId, 'version' => $objGlobal->version, 'idLanguages' => $this->intLanguageId, 'idLanguageFallbacks' => $objGenericSetup->getLanguageFallbackId(), 'idGenericForms' => $objGenericSetup->getGenFormId(), 'idTemplates' => $objGenericSetup->getTemplateId(), 'idGlobalTypes' => $objGenericSetup->getElementTypeId(), 'showInNavigation' => $objGenericSetup->getShowInNavigation(), 'idUsers' => $intUserId, 'creator' => $objGenericSetup->getCreatorId(), 'publisher' => $intUserId, 'created' => date('Y-m-d H:i:s'), 'published' => $objGenericSetup->getPublishDate(), 'idStatus' => $objGenericSetup->getStatusId());
         $this->getGlobalPropertyTable()->insert($arrProperties);
     }
 }