/**
  * initDataTypeObject
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function initDataTypeObject()
 {
     $this->objDataType = GenericSetup::getDataTypeObject($this->setup->getFormTypeId());
     if ($this->objDataType instanceof GenericDataTypeAbstract) {
         $this->objDataType->setGenericSetup($this->setup);
     }
 }
 /**
  * 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;
 }
 /**
  * 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);
     }
 }
示例#4
0
 /**
  * buildTags
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.1
  */
 public function buildTags()
 {
     $element = $this->getElement();
     $helper = $element->helper;
     require_once GLOBAL_ROOT_PATH . $this->core->sysConfig->path->zoolu_modules . 'core/models/Tags.php';
     $objModelTags = new Model_Tags();
     $objMostUsedTags = $objModelTags->loadMostUsedTags(GenericSetup::getFormTypeHandle($element->formTypeId));
     $strOutput = $element->getView()->{$helper}($element->getName(), $element->getValue(), $element->getAttribs(), $element->options, $objMostUsedTags, $element->tagIds);
     return $strOutput;
 }
示例#5
0
 /**
  * update
  * @param GenericSetup $objGenericSetup
  * @param object Page
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function update(GenericSetup &$objGenericSetup, $objPage)
 {
     $this->core->logger->debug('cms->models->Model_Pages->update()');
     $intUserId = Zend_Auth::getInstance()->getIdentity()->id;
     $strWhere = $this->getPageTable()->getAdapter()->quoteInto('pageId = ?', $objPage->pageId);
     $strWhere .= $this->getPageTable()->getAdapter()->quoteInto(' AND version = ?', $objPage->version);
     $this->getPageTable()->update(array('idUsers' => $intUserId, 'changed' => date('Y-m-d H:i:s')), $strWhere);
     /**
      * update language specific page properties
      */
     $strWhere .= $this->getPageTable()->getAdapter()->quoteInto(' AND idLanguages = ?', $this->intLanguageId);
     $intNumOfEffectedRows = $this->getPagePropertyTable()->update(array('idGenericForms' => $objGenericSetup->getGenFormId(), 'idTemplates' => $objGenericSetup->getTemplateId(), 'idPageTypes' => $objGenericSetup->getElementTypeId(), 'showInNavigation' => $objGenericSetup->getShowInNavigation(), 'idDestination' => $objGenericSetup->getDestinationId(), 'idUsers' => $intUserId, 'creator' => $objGenericSetup->getCreatorId(), 'idStatus' => $objGenericSetup->getStatusId(), 'published' => $objGenericSetup->getPublishDate(), 'changed' => date('Y-m-d H:i:s')), $strWhere);
     /**
      * insert language specific page properties
      */
     if ($intNumOfEffectedRows == 0) {
         $arrProperties = array('pageId' => $objPage->pageId, 'version' => $objPage->version, 'idLanguages' => $this->intLanguageId, 'idGenericForms' => $objGenericSetup->getGenFormId(), 'idTemplates' => $objGenericSetup->getTemplateId(), 'idPageTypes' => $objGenericSetup->getElementTypeId(), 'showInNavigation' => $objGenericSetup->getShowInNavigation(), 'idDestination' => $objGenericSetup->getDestinationId(), 'idUsers' => $intUserId, 'creator' => $objGenericSetup->getCreatorId(), 'publisher' => $intUserId, 'created' => date('Y-m-d H:i:s'), 'published' => $objGenericSetup->getPublishDate(), 'idStatus' => $objGenericSetup->getStatusId());
         $this->getPagePropertyTable()->insert($arrProperties);
     }
 }
 /**
  * linkedpagefieldAction
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function linkedpagefieldAction()
 {
     $this->core->logger->debug('cms->controllers->PageController->linkedpagefieldAction()');
     $strFieldId = $this->objRequest->getParam('fieldId');
     $strFormId = $this->objRequest->getParam('formId');
     $intFormVersion = $this->objRequest->getParam('formVersion');
     $intPageId = $this->objRequest->getParam('pageId');
     $objFieldData = $this->getModelGenericForm()->loadFieldByName($strFieldId, $strFormId, $intFormVersion);
     if (count($objFieldData) > 0) {
         $objFieldRegionData = $objFieldData->current();
         require_once GLOBAL_ROOT_PATH . 'library/massiveart/generic/elements/generic.element.field.class.php';
         $objField = new GenericElementField();
         $objField->id = $objFieldRegionData->id;
         $objField->title = $objFieldRegionData->title;
         $objField->name = $objFieldRegionData->name;
         $objField->typeId = $objFieldRegionData->idFieldTypes;
         $objField->type = $objFieldRegionData->type;
         $objField->defaultValue = $objFieldRegionData->defaultValue;
         $objField->sqlSelect = $objFieldRegionData->sqlSelect;
         $objField->columns = $objFieldRegionData->columns;
         $objField->order = $objFieldRegionData->order;
         $objField->isCoreField = $objFieldRegionData->isCoreField;
         $objField->isKeyField = $objFieldRegionData->isKeyField;
         $objField->isSaveField = $objFieldRegionData->isSaveField;
         $objField->isRegionTitle = $objFieldRegionData->isRegionTitle;
         $objField->isDependentOn = $objFieldRegionData->isDependentOn;
         $objField->copyValue = $objFieldRegionData->copyValue;
         $objField->decorator = $objFieldRegionData->decorator;
         $objField->isMultiply = $objFieldRegionData->isMultiply;
         $objGenericSetup = new GenericSetup();
         $objGenericSetup->setLanguageId($this->getItemLanguageId());
         $objField->setGenericSetup($objGenericSetup);
         $objField->loadLinkPage($intPageId);
         require_once GLOBAL_ROOT_PATH . 'library/massiveart/generic/fields/InternalLink/forms/elements/InternalLink.php';
         $objElement = new Form_Element_InternalLink($strFieldId, array('value' => $objField->getValue(), 'label' => $objField->title, 'description' => $objField->description, 'fieldId' => $objField->id, 'columns' => $objField->columns, 'class' => $objField->type, 'height' => $objField->height, 'isGenericSaveField' => $objField->isSaveField, 'isCoreField' => $objField->isCoreField, 'LanguageId' => $this->objRequest->getParam("languageId", $this->core->intZooluLanguageId), 'isEmptyField' => 0, 'required' => $objField->isKeyField == 1 ? true : false));
         $objElement->addPrefixPath('Form_Decorator', GLOBAL_ROOT_PATH . 'library/massiveart/generic/forms/decorators/', 'decorator');
         $objElement->setDecorators(array($objField->decorator));
         if (count($objField->getProperties()) > 0) {
             foreach ($objField->getProperties() as $strProperty => $mixedPropertyValue) {
                 if (in_array($strProperty, GenericForm::$FIELD_PROPERTIES_TO_IMPART)) {
                     $objElement->{$strProperty} = $mixedPropertyValue;
                 }
             }
         }
         $objDecorator = $objElement->getDecorator($objField->decorator);
         $objDecorator->setElement($objElement);
         echo $objDecorator->buildInput();
     }
     $this->_helper->viewRenderer->setNoRender();
 }
 /**
  * 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);
     }
 }