Beispiel #1
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->em = \Env::get('em');
     if ($this->em) {
         $this->nodeRepo = $this->em->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Node');
         $this->pageRepo = $this->em->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Page');
         $this->logRepo = $this->em->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry');
     }
     $this->messages = array();
     $fallback_lang_codes = \FWLanguage::getFallbackLanguageArray();
     $active_langs = \FWLanguage::getActiveFrontendLanguages();
     // get all active languages and their fallbacks
     foreach ($active_langs as $lang) {
         $this->fallbacks[\FWLanguage::getLanguageCodeById($lang['id'])] = array_key_exists($lang['id'], $fallback_lang_codes) ? \FWLanguage::getLanguageCodeById($fallback_lang_codes[$lang['id']]) : null;
     }
 }
Beispiel #2
0
 /**
  * Generates a list of pages pointing to $page
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to get referencing pages for
  * @param array $subPages (optional, by reference) Do not use, internal
  * @return array List of pages (ID as key, page object as value)
  */
 protected function getPagesPointingTo($page, &$subPages = array())
 {
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $em = $cx->getDb()->getEntityManager();
     $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
     $fallback_lang_codes = \FWLanguage::getFallbackLanguageArray();
     $active_langs = \FWLanguage::getActiveFrontendLanguages();
     // get all active languages and their fallbacks
     // $fallbacks[<langId>] = <fallsBackToLangId>
     // if <langId> has no fallback <fallsBackToLangId> will be null
     $fallbacks = array();
     foreach ($active_langs as $lang) {
         $fallbacks[\FWLanguage::getLanguageCodeById($lang['id'])] = array_key_exists($lang['id'], $fallback_lang_codes) ? \FWLanguage::getLanguageCodeById($fallback_lang_codes[$lang['id']]) : null;
     }
     // get all symlinks and fallbacks to it
     $query = '
         SELECT
             p
         FROM
             Cx\\Core\\ContentManager\\Model\\Entity\\Page p
         WHERE
             (
                 p.type = ?1 AND
                 (
                     p.target LIKE ?2';
     if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
         $query .= ' OR
                     p.target LIKE ?3';
     }
     $query .= '
                 )
             ) OR
             (
                 p.type = ?4 AND
                 p.node = ' . $page->getNode()->getId() . '
             )
     ';
     $q = $em->createQuery($query);
     $q->setParameter(1, 'symlink');
     $q->setParameter('2', '%NODE_' . $page->getNode()->getId() . '%');
     if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
         $q->setParameter('3', '%NODE_' . strtoupper($page->getModule()) . '%');
     }
     $q->setParameter(4, 'fallback');
     $result = $q->getResult();
     if (!$result) {
         return $subPages;
     }
     foreach ($result as $subPage) {
         if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_SYMLINK) {
             $subPages[$subPage->getId()] = $subPage;
         } else {
             if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK) {
                 // check if $subPage is a fallback to $page
                 $targetLang = \FWLanguage::getLanguageCodeById($page->getLang());
                 $currentLang = \FWLanguage::getLanguageCodeById($subPage->getLang());
                 while ($currentLang && $currentLang != $targetLang) {
                     $currentLang = $fallbacks[$currentLang];
                 }
                 if ($currentLang && !isset($subPages[$subPage->getId()])) {
                     $subPages[$subPage->getId()] = $subPage;
                     // recurse!
                     $this->getPagesPointingTo($subPage, $subPages);
                 }
             }
         }
     }
     return $subPages;
 }
 protected function getFallbackArray()
 {
     $fallbacks = \FWLanguage::getFallbackLanguageArray();
     $output = array();
     foreach ($fallbacks as $key => $value) {
         $output[\FWLanguage::getLanguageCodeById($key)] = \FWLanguage::getLanguageCodeById($value);
     }
     return $output;
 }
Beispiel #4
0
 public function resolve()
 {
     // $this->resolveAlias() also sets $this->page
     $aliaspage = $this->resolveAlias();
     if ($aliaspage != null) {
         $this->lang = $aliaspage->getTargetLangId();
         $aliaspage = clone $aliaspage;
         $aliaspage->setVirtual(true);
     } else {
         $this->lang = \Env::get('init')->getFallbackFrontendLangId();
         //try to find the language in the url
         $extractedLanguage = \FWLanguage::getLanguageIdByCode($this->url->getLangDir());
         $activeLanguages = \FWLanguage::getActiveFrontendLanguages();
         if (!$extractedLanguage) {
             $this->redirectToCorrectLanguageDir();
         }
         if (!in_array($extractedLanguage, array_keys($activeLanguages))) {
             $this->lang = \FWLanguage::getDefaultLangId();
             $this->redirectToCorrectLanguageDir();
         }
         //only set langid according to url if the user has not explicitly requested a language change.
         if (!isset($_REQUEST['setLang'])) {
             $this->lang = $extractedLanguage;
             //the user wants to change the language, but we're still inside the wrong language directory.
         } else {
             if ($this->lang != $extractedLanguage) {
                 $this->redirectToCorrectLanguageDir();
             }
         }
     }
     // used for LinkGenerator
     define('FRONTEND_LANG_ID', $this->lang);
     // used to load template file
     \Env::get('init')->setFrontendLangId($this->lang);
     global $section, $command, $history, $sessionObj, $url, $_CORELANG, $page, $pageId, $themesPages, $page_template, $isRegularPageRequest, $now, $start, $end, $plainSection;
     $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : '';
     $command = isset($_REQUEST['cmd']) ? contrexx_addslashes($_REQUEST['cmd']) : '';
     $history = isset($_REQUEST['history']) ? intval($_REQUEST['history']) : 0;
     // Initialize page meta
     $page = null;
     $pageAccessId = 0;
     $page_protected = $pageId = $themesPages = $page_template = null;
     // If standalone is set, then we will not have to initialize/load any content page related stuff
     $isRegularPageRequest = !isset($_REQUEST['standalone']) || $_REQUEST['standalone'] == 'false';
     // Regular page request
     if ($isRegularPageRequest) {
         // TODO: history (empty($history) ? )
         if (isset($_GET['pagePreview']) && $_GET['pagePreview'] == 1 && empty($sessionObj)) {
             $sessionObj = \cmsSession::getInstance();
         }
         $this->init($url, $this->lang, \Env::get('em'), ASCMS_INSTANCE_OFFSET . \Env::get('virtualLanguageDirectory'), \FWLanguage::getFallbackLanguageArray());
         try {
             $this->resolvePage();
             $page = $this->getPage();
             // TODO: should this check (for type 'application') moved to \Cx\Core\ContentManager\Model\Entity\Page::getCmd()|getModule() ?
             // only set $section and $command if the requested page is an application
             $command = $this->getCmd();
             $section = $this->getSection();
         } catch (\Cx\Core\Routing\ResolverException $e) {
             try {
                 $this->legacyResolve($url, $section, $command);
                 $page = $this->getPage();
                 $command = $this->getCmd();
                 $section = $this->getSection();
             } catch (\Cx\Core\Routing\ResolverException $e) {
                 // legacy resolving also failed.
                 // provoke a 404
                 $page = null;
             }
         }
         if (!$page || !$page->isActive()) {
             //fallback for inexistant error page
             if ($section == 'Error') {
                 // If the error module is not installed, show this
                 die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
             } else {
                 //page not found, redirect to error page.
                 \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Error'));
                 exit;
             }
         }
         // TODO: question: what do we need this for? I think there is no need for this (had been added in r15026)
         //legacy: re-populate cmd and section into $_GET
         $_GET['cmd'] = $command;
         $_GET['section'] = $section;
         // END of TODO question
         //check whether the page is active
         $now = new \DateTime('now');
         $start = $page->getStart();
         $end = $page->getEnd();
         $pageId = $page->getId();
         //access: frontend access id for default requests
         $pageAccessId = $page->getFrontendAccessId();
         //revert the page if a history param has been given
         if ($history) {
             //access: backend access id for history requests
             $pageAccessId = $page->getBackendAccessId();
             $logRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry');
             try {
                 $logRepo->revert($page, $history);
             } catch (\Gedmo\Exception\UnexpectedValueException $e) {
             }
             $logRepo->revert($page, $history);
         }
         /*
                                     //404 for inactive pages
                                     if(($start > $now && $start != null) || ($now > $end && $end != null)) {
                                         if ($section == 'Error') {
                                             // If the error module is not installed, show this
                                             die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
                                         }
                                         \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?section=Error&id=404');
                                         exit;
                                         }*/
         \Env::get('init')->setCustomizedTheme($page->getSkin(), $page->getCustomContent(), $page->getUseSkinForAllChannels());
         $themesPages = \Env::get('init')->getTemplates($page);
         //replace the {NODE_<ID>_<LANG>}- placeholders
         \LinkGenerator::parseTemplate($themesPages);
         //TODO: analyze those, take action.
         //$page_protected = $objResult->fields['protected'];
         $page_protected = $page->isFrontendProtected();
         //$page_access_id = $objResult->fields['frontend_access_id'];
         $page_template = $themesPages['content'];
         // Authentification for protected pages
         // This is only done for regular page requests ($isRegularPageRequest == TRUE)
         $this->checkPageFrontendProtection($page, $history);
         //TODO: history
     }
     // TODO: refactor system to be able to remove this backward compatibility
     // Backwards compatibility for code pre Contrexx 3.0 (update)
     $_GET['cmd'] = $_POST['cmd'] = $_REQUEST['cmd'] = $command;
     $_GET['section'] = $_POST['section'] = $_REQUEST['section'] = $section;
     // the system should directly use $this->url->getParamArray() instead of using the super globals
     $qsArr = $this->url->getParamArray();
     foreach ($qsArr as $qsParam => $qsArgument) {
         $_GET[$qsParam] = $_REQUEST[$qsParam] = $qsArgument;
     }
     // To clone any module, use an optional integer cmd suffix.
     // E.g.: "shop2", "gallery5", etc.
     // Mind that you *MUST* copy all necessary database tables, and fix any
     // references to your module (section and cmd parameters, database tables)
     // using the MODULE_INDEX constant in the right place both in your code
     // *AND* templates!
     // See the Shop module for an example.
     $arrMatch = array();
     if (preg_match('/^(\\D+)(\\d+)$/', $section, $arrMatch)) {
         // The plain section/module name, used below
         $plainSection = $arrMatch[1];
     } else {
         $plainSection = $section;
     }
     // The module index.
     // An empty or 1 (one) index represents the same (default) module,
     // values 2 (two) and larger represent distinct instances.
     $moduleIndex = empty($arrMatch[2]) || $arrMatch[2] == 1 ? '' : $arrMatch[2];
     define('MODULE_INDEX', $moduleIndex);
     // Start page or default page for no section
     if ($section == 'Home') {
         if (!\Env::get('init')->hasCustomContent()) {
             $page_template = $themesPages['home'];
         } else {
             $page_template = $themesPages['content'];
         }
     }
     // this is the case for standalone and backend requests
     if (!$this->page) {
         return null;
     }
     $this->page = clone $this->page;
     $this->page->setVirtual();
     // check for further URL parts to resolve
     if ($this->page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION && $this->page->getPath() != '/' . $this->url->getSuggestedTargetPath()) {
         // does this work for fallback(/aliases)?
         $additionalPath = substr('/' . $this->url->getSuggestedTargetPath(), strlen($this->page->getPath()));
         $componentController = $this->em->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent')->findOneBy(array('name' => $this->page->getModule()));
         if ($componentController) {
             $parts = explode('/', substr($additionalPath, 1));
             $componentController->resolve($parts, $this->page);
         }
     }
     return $this->page;
 }
 /**
  * Modify Form
  *
  * Shows the modifying page.
  * @access private
  * @param bool $copy If the form should be copied or not
  */
 function _modifyForm($copy = false)
 {
     global $_ARRAYLANG, $_CONFIG, $objDatabase;
     \JS::activate('cx');
     if ($copy) {
         $this->initContactForms();
     }
     $this->_objTpl->loadTemplateFile('module_contact_form_modify.html');
     $formId = isset($_REQUEST['formId']) ? intval($_REQUEST['formId']) : 0;
     $this->_pageTitle = !$copy && $formId != 0 ? $_ARRAYLANG['TXT_CONTACT_MODIFY_CONTACT_FORM'] : $_ARRAYLANG['TXT_CONTACT_ADD_NEW_CONTACT_FORM'];
     $actionTitle = $_ARRAYLANG['TXT_CONTACT_ADD_NEW_CONTACT_FORM'];
     $showForm = 0;
     $useCaptcha = 1;
     $saveDataInCRM = 0;
     $useCustomStyle = 0;
     $sendCopy = 0;
     $useEmailOfSender = 0;
     $sendHtmlMail = 1;
     $sendAttachment = 0;
     $emails = $_CONFIG['contactFormEmail'];
     $crmCustomerGroups = array();
     $arrActiveSystemFrontendLanguages = \FWLanguage::getActiveFrontendLanguages();
     if (count($arrActiveSystemFrontendLanguages) == 1) {
         $this->_objTpl->setVariable('CONTACT_LANGUAGE_TABS_DISPLAY', 'display: none');
     }
     if (isset($this->arrForms[$formId])) {
         // editing
         $actionTitle = $_ARRAYLANG['TXT_CONTACT_MODIFY_CONTACT_FORM'];
         $showForm = $this->arrForms[$formId]['showForm'];
         $useCaptcha = $this->arrForms[$formId]['useCaptcha'];
         $saveDataInCRM = $this->arrForms[$formId]['saveDataInCRM'];
         $useCustomStyle = $this->arrForms[$formId]['useCustomStyle'];
         $sendCopy = $this->arrForms[$formId]['sendCopy'];
         $useEmailOfSender = $this->arrForms[$formId]['useEmailOfSender'];
         $sendHtmlMail = $this->arrForms[$formId]['htmlMail'];
         $sendAttachment = $this->arrForms[$formId]['sendAttachment'];
         $emails = $this->arrForms[$formId]['emails'];
         $crmCustomerGroups = !empty($this->arrForms[$formId]['crmCustomerGroups']) ? $this->arrForms[$formId]['crmCustomerGroups'] : array();
     }
     if (count($arrActiveSystemFrontendLanguages) > 0) {
         $intLanguageCounter = 0;
         $arrLanguages = array(0 => '', 1 => '', 2 => '');
         $strJsTabToDiv = '';
         foreach ($arrActiveSystemFrontendLanguages as $langId => $arrLanguage) {
             // Bugfix: if only one language is activated, it must be true, so the fields can be saved
             if (count($arrActiveSystemFrontendLanguages) == 1) {
                 $boolLanguageIsActive = true;
             } elseif ($formId) {
                 $boolLanguageIsActive = isset($this->arrForms[$formId]['lang'][$langId]) && $this->arrForms[$formId]['lang'][$langId]['is_active'];
             } else {
                 $boolLanguageIsActive = $langId == FRONTEND_LANG_ID;
             }
             $arrLanguages[$intLanguageCounter % 3] .= '<input id="languagebar_' . $langId . '" ' . ($boolLanguageIsActive ? 'checked="checked"' : '') . ' type="checkbox" name="contactFormLanguages[' . $langId . ']" value="1" onclick="switchBoxAndTab(this, \'addFrom_' . $langId . '\');" /><label for="languagebar_' . $langId . '">' . contrexx_raw2xhtml($arrLanguage['name']) . ' [' . $arrLanguage['lang'] . ']</label><br />';
             $strJsTabToDiv .= 'arrTabToDiv["addFrom_' . $langId . '"] = "langTab_' . $langId . '";' . "\n";
             ++$intLanguageCounter;
         }
         $this->_objTpl->setVariable(array('TXT_CONTACT_LANGUAGE' => $_ARRAYLANG['TXT_CONTACT_LANGUAGE'], 'EDIT_LANGUAGES_1' => $arrLanguages[0], 'EDIT_LANGUAGES_2' => $arrLanguages[1], 'EDIT_LANGUAGES_3' => $arrLanguages[2], 'EDIT_JS_TAB_TO_DIV' => $strJsTabToDiv));
     }
     // TODO: this might be a bug. Shouldn't this be the MAX(of used IDs) when modifying a form
     $lastFieldId = 0;
     if (empty($_POST['saveForm'])) {
         // get the saved fields
         $fields = $this->getFormFields($formId);
         $recipients = $this->getRecipients($formId);
     } else {
         $fields = $this->_getFormFieldsFromPost();
         $recipients = $this->getRecipientsFromPost();
     }
     $objCrmLibrary = new \Cx\Modules\Crm\Controller\CrmLibrary('Crm');
     $memberships = array_keys($objCrmLibrary->getMemberships());
     $objCrmLibrary->getMembershipDropdown($this->_objTpl, $memberships, "contactMembership", $crmCustomerGroups);
     // make an empty one so at least one is parsed
     if (empty($fields)) {
         foreach ($arrActiveSystemFrontendLanguages as $lang) {
             $fields[0] = array('type' => 'text', 'order_id' => 0, 'is_required' => false, 'check_type' => 1, 'editType' => 'new');
             $fields[0]['lang'][$lang['id']] = array('name' => '', 'value' => '');
         }
     }
     if (!$formId) {
         $selectedInterfaceLanguage = FRONTEND_LANG_ID;
     } elseif (isset($this->arrForms[$formId]['lang'][FRONTEND_LANG_ID])) {
         $selectedInterfaceLanguage = FRONTEND_LANG_ID;
     } elseif (isset($this->arrForms[$formId]['lang'][\FWLanguage::getDefaultLangId()])) {
         $selectedInterfaceLanguage = \FWLanguage::getDefaultLangId();
     } elseif (count($this->arrForms[$formId]['lang'])) {
         $selectedInterfaceLanguage = key($this->arrForms[$formId]['lang']);
     }
     foreach (\FWLanguage::getLanguageArray() as $language) {
         if ($language['id'] == $selectedInterfaceLanguage && $language["frontend"] == 0) {
             $selectedInterfaceLanguage = \FWLanguage::getDefaultLangId();
         }
     }
     //Get the fallback languages array
     $fallBackArr = \FWLanguage::getFallbackLanguageArray();
     $strJsFallBackArr = '';
     foreach ($fallBackArr as $languageId => $fallBackLanguageId) {
         $strJsFallBackArr .= 'arrFallBackLang[' . $languageId . '] = "' . $fallBackLanguageId . '";' . "\n";
     }
     $this->_objTpl->setVariable(array('FALL_BACK_LANGUAGES' => $strJsFallBackArr, 'DEFAULT_LANGUAGE' => \FWLanguage::getDefaultLangId()));
     foreach ($arrActiveSystemFrontendLanguages as $langId => $lang) {
         $isSelectedInterfaceLanguage = $langId == $selectedInterfaceLanguage;
         $langVars = array('is_active' => $isSelectedInterfaceLanguage, 'name' => '', 'text' => '', 'feedback' => '', 'subject' => '', 'mailTemplate' => self::formMailTemplate);
         if (isset($this->arrForms[$formId]['lang'][$langId])) {
             $langVars = $this->arrForms[$formId]['lang'][$langId];
             $langVars['mailTemplate'] = preg_replace('/\\{([A-Z0-9_]*?)\\}/', '[[\\1]]', $langVars['mailTemplate']);
         }
         if (isset($this->arrForms[$formId]['lang'][$fallBackArr[$lang['id']]])) {
             $optionalLanguageId = $fallBackArr[$lang['id']];
         } elseif (isset($this->arrForms[$formId]['lang'][\FWLanguage::getDefaultLangId()])) {
             $optionalLanguageId = \FWLanguage::getDefaultLangId();
         } else {
             $optionalLanguageId = key($this->arrForms[$formId]['lang']);
         }
         $this->_objTpl->setVariable(array('LANG_ID' => $langId, 'LANG_NAME' => contrexx_raw2xhtml($lang['name']), 'TAB_CLASS_NAME' => $isSelectedInterfaceLanguage ? 'active' : 'inactive', 'CONTACT_LANGTAB_DISPLAY' => $langVars['is_active'] ? 'display:inline;' : 'display:none;'));
         $this->_objTpl->parse('languageTabs');
         $this->_objTpl->setVariable(array('LANG_ID' => $lang['id'], 'LANG_NAME' => contrexx_raw2xhtml($lang['name']), 'LANG_FORM_DISPLAY' => $isSelectedInterfaceLanguage ? 'block' : 'none', 'CONTACT_FORM_MAIL_TEMPLATE_HIDDEN' => !empty($langVars['mailTemplate']) ? contrexx_raw2xhtml($langVars['mailTemplate']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['mailTemplate']), 'CONTACT_FORM_SUBJECT' => !empty($langVars['subject']) ? contrexx_raw2xhtml($langVars['subject']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['subject'])));
         $this->_objTpl->parse('notificationLanguageForm');
         $this->_objTpl->setVariable(array('CONTACT_FORM_ID' => $formId, 'LANG_ID' => $lang['id'], 'LANG_FORM_DISPLAY' => $isSelectedInterfaceLanguage ? 'block' : 'none', 'CONTACT_FORM_NAME' => !empty($langVars['name']) ? contrexx_raw2xhtml($langVars['name']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['name']), 'CONTACT_FORM_FIELD_NEXT_ID' => $lastFieldId + 1, 'CONTACT_FORM_TEXT_HIDDEN' => !empty($langVars['text']) ? contrexx_raw2xhtml($langVars['text']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['text']), 'CONTACT_FORM_FEEDBACK_HIDDEN' => !empty($langVars['feedback']) ? contrexx_raw2xhtml($langVars['feedback']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['feedback']), 'CONTACT_FORM_RECIPIENT_NEXT_SORT' => $this->getHighestSortValue($formId) + 2, 'CONTACT_FORM_RECIPIENT_NEXT_ID' => $this->getLastRecipientId(true) + 2, 'CONTACT_FORM_FIELD_NEXT_TEXT_TPL' => $this->_getFormFieldAttribute($lastFieldId + 1, 'text', '', $isSelectedInterfaceLanguage, $lang['id']), 'CONTACT_FORM_FIELD_LABEL_NEXT_TPL' => $this->_getFormFieldAttribute($lastFieldId + 1, 'label', '', $isSelectedInterfaceLanguage, $lang['id']), 'CONTACT_FORM_FIELD_CHECK_MENU_NEXT_TPL' => $this->_getFormFieldCheckTypesMenu('contactFormFieldCheckType[' . ($lastFieldId + 1) . ']', 'contactFormFieldCheckType_' . ($lastFieldId + 1), 'text', 1), 'CONTACT_FORM_FIELD_CHECK_MENU_TPL' => $this->_getFormFieldCheckTypesMenu('contactFormFieldCheckType[0]', 'contactFormFieldCheckType_0', 'text', 1), 'CONTACT_FORM_FIELD_CHECK_BOX_NEXT_TPL' => $this->_getFormFieldRequiredCheckBox('contactFormFieldRequired[' . ($lastFieldId + 1) . ']', 'contactFormFieldRequired_' . ($lastFieldId + 1), 'text', false), 'CONTACT_FORM_FIELD_CHECK_BOX_TPL' => $this->_getFormFieldRequiredCheckBox('contactFormFieldRequired[0]', 'contactFormFieldRequired_0', 'text', false), 'CONTACT_ACTION_TITLE' => $actionTitle, 'CONTACT_FORM_FIELD_TEXT_TPL' => $this->_getFormFieldAttribute(0, 'text', '', false), 'CONTACT_FORM_FIELD_LABEL_TPL' => $this->_getFormFieldAttribute(0, 'label', '', false), 'CONTACT_FORM_FIELD_CHECKBOX_TPL' => $this->_getFormFieldAttribute(0, 'checkbox', 0), 'CONTACT_FORM_FIELD_COUNTRY_TPL' => $this->_getFormFieldAttribute(0, 'country', '', true, 0), 'CONTACT_FORM_FIELD_ACCESS_COUNTRY_TPL' => $this->_getFormFieldAttribute(0, 'access_country', '', true, 0), 'CONTACT_FORM_FIELD_CHECKBOX_GROUP_TPL' => $this->_getFormFieldAttribute(0, 'checkboxGroup', '', false), 'CONTACT_FORM_FIELD_DATE_TPL' => $this->_getFormFieldAttribute(0, 'date', '', false), 'CONTACT_FORM_FIELD_DATETIME_TPL' => $this->_getFormFieldAttribute(0, 'datetime', '', false), 'CONTACT_FORM_FIELD_HIDDEN_TPL' => $this->_getFormFieldAttribute(0, 'hidden', '', false), 'CONTACT_FORM_FIELD_RADIO_TPL' => $this->_getFormFieldAttribute(0, 'radio', '', false), 'CONTACT_FORM_FIELD_SELECT_TPL' => $this->_getFormFieldAttribute(0, 'select', '', false)));
         $this->_objTpl->parse('languageForm');
     }
     $this->_objTpl->setVariable('CONTACT_ACTIVE_LANG_NAME', contrexx_raw2xhtml($arrActiveSystemFrontendLanguages[$selectedInterfaceLanguage]['name']));
     $counter = 1;
     foreach ($fields as $fieldID => $field) {
         $realFieldID = $formId > 0 ? $fieldID : $counter;
         $fieldType = $field['type'] == 'special' ? $field['special_type'] : $field['type'];
         $first = true;
         /**
         While copying a template, the edittype of the field must be 'new'
         */
         if ($copy) {
             $field['editType'] = 'new';
         }
         foreach ($arrActiveSystemFrontendLanguages as $langId => $lang) {
             if ($formId) {
                 $isActive = $langId == $selectedInterfaceLanguage;
             } else {
                 // when creating a new form, the form shall be created for the currently selected frontend language
                 $isActive = $lang['id'] == FRONTEND_LANG_ID;
             }
             $show = $first && $isActive;
             if (isset($field['lang'][$fallBackArr[$lang['id']]])) {
                 $optionalLanguageId = $fallBackArr[$lang['id']];
             } elseif (isset($field['lang'][\FWLanguage::getDefaultLangId()])) {
                 $optionalLanguageId = \FWLanguage::getDefaultLangId();
             } else {
                 $optionalLanguageId = key($field['lang']);
             }
             $this->_objTpl->setVariable(array('LANG_ID' => $lang['id'], 'LANG_NAME_DISPLAY' => $show ? 'block' : 'none', 'LANG_VALUE_DISPLAY' => $show ? 'block' : 'none', 'FORM_FIELD_NAME' => isset($field['lang'][$lang['id']]) ? contrexx_raw2xhtml($field['lang'][$lang['id']]['name']) : contrexx_raw2xhtml($field['lang'][$optionalLanguageId]['name']), 'CONTACT_FORM_FIELD_VALUE' => $this->_getFormFieldAttribute($realFieldID, $fieldType, isset($field['lang'][$lang['id']]) ? contrexx_raw2xhtml($field['lang'][$lang['id']]['value']) : contrexx_raw2xhtml($field['lang'][$optionalLanguageId]['value']), $show, $lang['id'])));
             $this->_objTpl->parse('formFieldName');
             $this->_objTpl->parse('formFieldValue');
             if ($isActive) {
                 $first = false;
             }
         }
         $this->_objTpl->setVariable(array('CONTACT_FORM_FIELD_TYPE_MENU' => $this->_getFormFieldTypesMenu('contactFormFieldType[' . $realFieldID . ']', $fieldType, 'id="contactFormFieldType_' . $realFieldID . '" style="width:110px;" ' . 'class="contactFormFieldType" onchange="setFormFieldAttributeBox(this.getAttribute(\'id\'),this.value)"'), 'FORM_FIELD_CHECK_BOX' => $this->_getFormFieldRequiredCheckBox('contactFormFieldRequired[' . $realFieldID . ']', 'contactFormFieldRequired_' . $realFieldID, $fieldType, $field['is_required']), 'FORM_FIELD_CHECK_MENU' => $this->_getFormFieldCheckTypesMenu('contactFormFieldCheckType[' . $realFieldID . ']', 'contactFormFieldCheckType_' . $realFieldID, $fieldType, $field['check_type']), 'FORM_FIELD_ID' => $realFieldID, 'FORM_FIELD_TYPE' => $field['editType'], 'ROW_CLASS_NAME' => 'row' . ($counter % 2 == 0 ? '1' : '2')));
         $counter++;
         $this->_objTpl->parse('formField');
     }
     if (!$copy && $formId > 0) {
         $jsSubmitFunction = "updateContentSite()";
     } else {
         $jsSubmitFunction = "createContentSite()";
     }
     $this->_objTpl->setVariable(array('CONTACT_FORM_SHOW_FORM_YES' => $showForm ? 'checked="checked"' : '', 'CONTACT_FORM_SHOW_FORM_NO' => $showForm ? '' : 'checked="checked"', 'CONTACT_FORM_USE_CAPTCHA_YES' => $useCaptcha ? 'checked="checked"' : '', 'CONTACT_FORM_USE_CAPTCHA_NO' => $useCaptcha ? '' : 'checked="checked"', 'CONTACT_FORM_USE_CRMMODULE_YES' => $saveDataInCRM ? 'checked="checked"' : '', 'CONTACT_FORM_USE_CRMMODULE_NO' => $saveDataInCRM ? '' : 'checked="checked"', 'CONTACT_FORM_USE_CUSTOM_STYLE_YES' => $useCustomStyle ? 'checked="checked"' : '', 'CONTACT_FORM_USE_CUSTOM_STYLE_NO' => $useCustomStyle ? '' : 'checked="checked"', 'CONTACT_FORM_SEND_HTML_MAIL' => $sendHtmlMail ? 'checked="checked"' : '', 'CONTACT_MAIL_TEMPLATE_STYLE' => $sendHtmlMail ? 'table-row' : 'none', 'CONTACT_FORM_SEND_COPY_YES' => $sendCopy ? 'checked="checked"' : '', 'CONTACT_FORM_SEND_COPY_NO' => $sendCopy ? '' : 'checked="checked"', 'CONTACT_FORM_USE_EMAIL_OF_SENDER_YES' => $useEmailOfSender ? 'checked="checked"' : '', 'CONTACT_FORM_USE_EMAIL_OF_SENDER_NO' => $useEmailOfSender ? '' : 'checked="checked"', 'CONTACT_FORM_SEND_ATTACHMENT' => $sendAttachment ? 'checked="checked"' : '', 'CONTACT_FORM_EMAIL' => contrexx_raw2xhtml($emails), 'CONTACT_JS_SUBMIT_FUNCTION' => $jsSubmitFunction, 'FORM_COPY' => intval($copy), 'CONTACT_FORM_TEXT' => new \Cx\Core\Wysiwyg\Wysiwyg('contactFormTextEditor'), 'CONTACT_FORM_FEEDBACK' => new \Cx\Core\Wysiwyg\Wysiwyg('contactFormFeedbackEditor'), 'CONTACT_MAIL_TEMPLATE' => new \Cx\Core\Wysiwyg\Wysiwyg('contactMailTemplateEditor', '', 'fullpage'), 'TXT_CONTACT_FORM_FIELDS' => $_ARRAYLANG['TXT_CONTACT_FORM_FIELDS'], 'TXT_CONTACT_DELETE' => $_ARRAYLANG['TXT_CONTACT_DELETE'], 'TXT_CONTACT_MOVE_UP' => $_ARRAYLANG['TXT_CONTACT_MOVE_UP'], 'TXT_CONTACT_MOVE_DOWN' => $_ARRAYLANG['TXT_CONTACT_MOVE_DOWN'], 'TXT_CONTACT_NAME' => $_ARRAYLANG['TXT_CONTACT_NAME'], 'TXT_CONTACT_REGEX_EMAIL' => $_ARRAYLANG['TXT_CONTACT_REGEX_EMAIL'], 'TXT_CONTACT_ADD_OTHER_FIELD' => $_ARRAYLANG['TXT_CONTACT_ADD_OTHER_FIELD'], 'TXT_CONTACT_ADD_RECIPIENT' => $_ARRAYLANG['TXT_CONTACT_ADD_RECIPIENT'], 'TXT_CONTACT_FORM_VALUES' => $_ARRAYLANG['TXT_CONTACT_FORM_VALUES'], 'TXT_FORM_FIELDS' => $_ARRAYLANG['TXT_FORM_FIELDS'], 'TXT_FORM_RECIPIENTS' => $_ARRAYLANG['TXT_FORM_RECIPIENTS'], 'TXT_ADVANCED_SETTINGS' => $_ARRAYLANG['TXT_ADVANCED_SETTINGS'], 'TXT_CONTACT_FORM_NOTIFICATION' => $_ARRAYLANG['TXT_CONTACT_FORM_NOTIFICATION'], 'TXT_CONTACT_ID' => $_ARRAYLANG['TXT_CONTACT_ID'], 'TXT_CONTACT_NAME' => $_ARRAYLANG['TXT_CONTACT_NAME'], 'TXT_CONTACT_RECEIVER_ADDRESSES' => $_ARRAYLANG['TXT_CONTACT_RECEIVER_ADDRESSES'], 'TXT_CONTACT_RECEIVER_ADDRESSES_SELECTION' => $_ARRAYLANG['TXT_CONTACT_RECEIVER_ADDRESSES_SELECTION'], 'TXT_CONTACT_SAVE' => $_ARRAYLANG['TXT_CONTACT_SAVE'], 'TXT_CONTACT_SEPARATE_MULTIPLE_VALUES_BY_COMMA' => $_ARRAYLANG['TXT_CONTACT_SEPARATE_MULTIPLE_VALUES_BY_COMMA'], 'TXT_CONTACT_SEND_ATTACHMENT_DESCRIPTION' => $_ARRAYLANG['TXT_CONTACT_SEND_ATTACHMENT_DESCRIPTION'], 'TXT_CONTACT_FORM_DESC' => $_ARRAYLANG['TXT_CONTACT_FORM_DESC'], 'TXT_CONTACT_FEEDBACK' => $_ARRAYLANG['TXT_CONTACT_FEEDBACK'], 'TXT_CONTACT_VALUE_S' => $_ARRAYLANG['TXT_CONTACT_VALUE_S'], 'TXT_CONTACT_FIELD_NAME' => $_ARRAYLANG['TXT_CONTACT_FIELD_NAME'], 'TXT_CONTACT_TYPE' => $_ARRAYLANG['TXT_CONTACT_TYPE'], 'TXT_CONTACT_MANDATORY_FIELD' => $_ARRAYLANG['TXT_CONTACT_MANDATORY_FIELD'], 'TXT_CONTACT_FEEDBACK_EXPLANATION' => $_ARRAYLANG['TXT_CONTACT_FEEDBACK_EXPLANATION'], 'TXT_CONTACT_CONFIRM_CREATE_CONTENT_SITE' => $_ARRAYLANG['TXT_CONTACT_CONFIRM_CREATE_CONTENT_SITE'], 'TXT_CONTACT_CONFIRM_UPDATE_CONTENT_SITE' => $_ARRAYLANG['TXT_CONTACT_CONFIRM_UPDATE_CONTENT_SITE'], 'TXT_CONTACT_SHOW_FORM_AFTER_SUBMIT' => $_ARRAYLANG['TXT_CONTACT_SHOW_FORM_AFTER_SUBMIT'], 'TXT_CONTACT_YES' => $_ARRAYLANG['TXT_CONTACT_YES'], 'TXT_CONTACT_NO' => $_ARRAYLANG['TXT_CONTACT_NO'], 'TXT_CONTACT_CAPTCHA_PROTECTION' => $_ARRAYLANG['TXT_CONTACT_CAPTCHA_PROTECTION'], 'TXT_CONTACT_SAVE_DATA_IN_CRM' => $_ARRAYLANG['TXT_CONTACT_SAVE_DATA_IN_CRM'], 'TXT_CONTACT_CAPTCHA' => $_ARRAYLANG['TXT_CONTACT_CAPTCHA'], 'TXT_CONTACT_CAPTCHA_DESCRIPTION' => $_ARRAYLANG['TXT_CONTACT_CAPTCHA_DESCRIPTION'], 'TXT_CONTACT_SEND_COPY_DESCRIPTION' => $_ARRAYLANG['TXT_CONTACT_SEND_COPY_DESCRIPTION'], 'TXT_CONTACT_SEND_COPY' => $_ARRAYLANG['TXT_CONTACT_SEND_COPY'], 'TXT_CONTACT_USE_EMAIL_OF_SENDER_DESCRIPTION' => $_ARRAYLANG['TXT_CONTACT_USE_EMAIL_OF_SENDER_DESCRIPTION'], 'TXT_CONTACT_USE_EMAIL_OF_SENDER' => $_ARRAYLANG['TXT_CONTACT_USE_EMAIL_OF_SENDER'], 'TXT_CONTACT_SEND_ATTACHMENT' => $_ARRAYLANG['TXT_CONTACT_SEND_ATTACHMENT'], 'TXT_CONTACT_SEND_HTML_MAIL' => $_ARRAYLANG['TXT_CONTACT_SEND_HTML_MAIL'], 'TXT_CONTACT_CUSTOM_STYLE_DESCRIPTION' => $_ARRAYLANG['TXT_CONTACT_CUSTOM_STYLE_DESCRIPTION'], 'TXT_CONTACT_CUSTOM_STYLE' => $_ARRAYLANG['TXT_CONTACT_CUSTOM_STYLE'], 'TXT_CONTACT_SET_MANDATORY_FIELD' => $_ARRAYLANG['TXT_CONTACT_SET_MANDATORY_FIELD'], 'TXT_CONTACT_RECIPIENT_ALREADY_SET' => $_ARRAYLANG['TXT_CONTACT_RECIPIENT_ALREADY_SET'], 'TXT_CONTACT_EMAIL' => $_ARRAYLANG['TXT_CONTACT_EMAIL'], 'TXT_CONTACT_NAME' => $_ARRAYLANG['TXT_CONTACT_NAME'], 'TXT_CONTACT_SUBJECT' => $_ARRAYLANG['TXT_CONTACT_SUBJECT'], 'TXT_CONTACT_MAIL_TEMPLATE' => $_ARRAYLANG['TXT_CONTACT_MAIL_TEMPLATE'], 'TXT_NAME' => $_ARRAYLANG['TXT_CONTACT_FORM_NAME'], 'TXT_VALUES' => $_ARRAYLANG['TXT_CONTACT_FORM_VALUES'], 'TXT_TYPE' => $_ARRAYLANG['TXT_CONTACT_TYPE'], 'TXT_MANDATORY_FIELD' => $_ARRAYLANG['TXT_CONTACT_MANDATORY_FIELD'], 'TXT_CONTACT_VALIDATION' => $_ARRAYLANG['TXT_CONTACT_VALIDATION'], 'TXT_ADVANCED_VIEW' => $_ARRAYLANG['TXT_ADVANCED_VIEW'], 'TXT_SIMPLIFIED_VIEW' => $_ARRAYLANG['TXT_SIMPLIFIED_VIEW'], 'CONTACT_FORM_FIELDS_TITLE' => $_ARRAYLANG['TXT_CONTACT_FORM_FIELD_TITLE'], 'CONTACT_FORM_RECIPIENTS_TITLE' => $_ARRAYLANG['CONTACT_FORM_RECIPIENTS_TITLE'], 'CONTACT_FORM_SETTINGS' => $_ARRAYLANG['CONTACT_FORM_SETTINGS'], 'TXT_CONTACT_CHOOSE_MEMBERSHIPS' => $_ARRAYLANG['TXT_CONTACT_CHOOSE_MEMBERSHIPS'], 'TXT_CONTACT_ASSIGN_TO_CRM_CUSTOMER_GROUP' => $_ARRAYLANG['TXT_CONTACT_ASSIGN_TO_CRM_CUSTOMER_GROUP'], 'TXT_CONTACT_ASSIGN_CRM_CUSTOMER_GROUP_DESCRIPTION' => $_ARRAYLANG['TXT_CONTACT_ASSIGN_CRM_CUSTOMER_GROUP_DESCRIPTION']));
     if (empty($recipients)) {
         // make an empty one so there's at least one
         $recipients[0] = array('id' => 1, 'email' => '', 'editType' => 'new');
         foreach ($arrActiveSystemFrontendLanguages as $langID => $lang) {
             $recipients[0]['lang'][$langID] = '';
         }
     }
     foreach ($recipients as $recipientID => $recipientField) {
         if ($copy) {
             $recipients[$recipientID]['editType'] = 'new';
         }
     }
     // parse the recipients
     $this->_showRecipients($recipients);
 }