/**
  * addField
  * @param GenericElementField $objField
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.2
  */
 public 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, array('LANGUAGE_ID' => $this->objGenericForm->Setup()->getFormLanguageId(), 'ROOTLEVEL_LANGUAGE_ID' => $this->objGenericForm->Setup()->getLanguageId()), $this->objGenericForm->Setup()->getRootLevelId());
             $sqlStmt = $this->core->dbh->query($sqlSelect)->fetchAll();
             if ($objField->idFieldTypeGroup == GenericSetup::FIELD_TYPE_SELECT_ID) {
                 $arrOptions[''] = $this->core->translate->_('Please_choose', false);
             }
             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->objGenericForm->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->objGenericForm->Setup()->getLanguageId(), 'FormLanguageId' => $this->objGenericForm->Setup()->getFormLanguageId(), '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->objGenericForm->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;
                 }
             }
         }
         if (!is_null($intRegionInstanceId)) {
             if (count($objField->getInstanceProperties($intRegionInstanceId)) > 0) {
                 foreach ($objField->getInstanceProperties($intRegionInstanceId) 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)->isStartElement = $this->objGenericForm->Setup()->getIsStartElement(false);
             $this->getElement($objField->name . $strNameExtension)->intFormTypeId = $this->objGenericForm->Setup()->getFormTypeId();
             $this->getElement($objField->name . $strNameExtension)->intElementTypeId = $this->objGenericForm->Setup()->getElementTypeId();
             $this->getElement($objField->name . $strNameExtension)->intParentTypeId = $this->objGenericForm->Setup()->getParentTypeId();
         }
         $this->objGenericForm->fieldAddedToSubform($this->intId, $objField->name);
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
 /**
  * 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();
 }