Exemple #1
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);
     }
 }
 /**
  * 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);
     }
 }