/**
     * Registers the JavaScript code for jQueryUi.Datepicker
     *
     * Also activates jQueryUi and tries to load the current language and use
     * that as the default.
     * Add element specific defaults and code in your method.
     */
    static function addDatepickerJs()
    {
        static $language_code = null;
        // Only run once
        if ($language_code) {
            return;
        }
        JS::activate('jqueryui');
        $language_code = FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID);
        //DBG::log("Language ID ".FRONTEND_LANG_ID.", code $language_code");
        // Must load timepicker as well, because the region file accesses it
        JS::registerJS('lib/javascript/jquery/ui/jquery-ui-timepicker-addon.js');
        // TODO: Add more languages to the i18n folder!
        JS::registerJS('lib/javascript/jquery/ui/i18n/' . 'jquery.ui.datepicker-' . $language_code . '.js');
        JS::registerCode('
cx.jQuery(function() {
  cx.jQuery.datepicker.setDefaults(cx.jQuery.datepicker.regional["' . $language_code . '"]);
});
');
    }
    /**
     * Register the JS code for the given input field ID
     * 
     * @param type $newsTagId HMTL ID attribute Value of the input field
     */
    public function registerTagJsCode($newsTagId = 'newsTags')
    {
        global $_ARRAYLANG;
        $allNewsTags = $this->getTags();
        $concatedTag = '';
        $tagCount = 0;
        foreach ($allNewsTags as $newsTag) {
            ++$tagCount;
            $concatedTag .= '"' . contrexx_raw2xhtml(addslashes($newsTag)) . '"' . ($tagCount != count($allNewsTags) ? ',' : '');
        }
        $newsTagsFormated = htmlspecialchars_decode($concatedTag);
        $placeholderText = $_ARRAYLANG['TXT_NEWS_ADD_TAGS'];
        $jsCode = <<<EOF
\$J(document).ready(function() {
var encoded = [{$newsTagsFormated}];
var decoded = [];
\$J.each(encoded, function(key, value){
    decoded.push(\$J("<div/>").html(value).text());
});
\$J("#{$newsTagId}").tagit({
    fieldName: "newsTags[]",
        availableTags : decoded,
        placeholderText : "{$placeholderText}",
        allowSpaces : true
    });
});
EOF;
        \JS::registerCode($jsCode);
    }
Example #3
0
 /**
  * Sets up the JavsScript cart
  *
  * Searches all $themesPages elements for the first occurrence of the
  * "shopJsCart" template block.
  * Generates the structure of the Javascript cart, puts it in the template,
  * and registers all required JS code.
  * Note that this is only ever called when the JS cart is enabled in the
  * extended settings!
  * @access  public
  * @global  array   $_ARRAYLANG   Language array
  * @global  array   $themesPages  Theme template array
  * @return  void
  * @static
  */
 static function setJsCart()
 {
     global $_ARRAYLANG, $themesPages;
     if (!\Cx\Core\Setting\Controller\Setting::getValue('use_js_cart', 'Shop')) {
         return;
     }
     $objTemplate = new \Cx\Core\Html\Sigma('.');
     $objTemplate->setErrorHandling(PEAR_ERROR_DIE);
     $match = null;
     $div_cart = $div_product = '';
     foreach ($themesPages as $index => $content) {
         //\DBG::log("Shop::setJsCart(): Section $index");
         $objTemplate->setTemplate($content, false, false);
         if (!$objTemplate->blockExists('shopJsCart')) {
             continue;
         }
         //\DBG::log("Shop::setJsCart(): In themespage $index: {$themesPages[$index]}");
         $objTemplate->setCurrentBlock('shopJsCart');
         // Set all language entries and replace formats
         $objTemplate->setGlobalVariable($_ARRAYLANG);
         if ($objTemplate->blockExists('shopJsCartProducts')) {
             $objTemplate->parse('shopJsCartProducts');
             $div_product = $objTemplate->get('shopJsCartProducts');
             //\DBG::log("Shop::setJsCart(): Got Product: $div_product");
             $objTemplate->replaceBlock('shopJsCartProducts', '[[SHOP_JS_CART_PRODUCTS]]');
         }
         $objTemplate->touchBlock('shopJsCart');
         $objTemplate->parse('shopJsCart');
         $div_cart = $objTemplate->get('shopJsCart');
         //\DBG::log("Shop::setJsCart(): Got Cart: $div_cart");
         if (preg_match('#^([\\n\\r]?[^<]*<.*id=["\']shopJsCart["\'][^>]*>)(([\\n\\r].*)*)(</[^>]*>[^<]*[\\n\\r]?)$#', $div_cart, $match)) {
             //\DBG::log("Shop::setJsCart(): Matched DIV {$match[1]}, content: {$match[2]}");
             $themesPages[$index] = preg_replace('@(<!--\\s*BEGIN\\s+(shopJsCart)\\s*-->.*?<!--\\s*END\\s+\\2\\s*-->)@s', $match[1] . $_ARRAYLANG['TXT_SHOP_CART_IS_LOADING'] . $match[4], $content);
             /*
             // Template use won't work, because it kills the remaining <!-- blocks -->!
                             $objTemplate->setTemplate($content, false, false);
                             $objTemplate->replaceBlock('shopJsCart',
                                 $match[1].
                                 $_ARRAYLANG['TXT_SHOP_CART_IS_LOADING'].
                                 $match[4]);
                             $themesPages[$index] = $objTemplate->get();
             */
             //\DBG::log("Shop::setJsCart(): Out themespage $index: {$themesPages[$index]}");
         }
         // One instance only (mind that there's a unique id attribute)
         self::$use_js_cart = true;
         break;
     }
     if (!self::$use_js_cart) {
         return;
     }
     self::registerJavascriptCode();
     \ContrexxJavascript::getInstance()->setVariable('TXT_SHOP_CART_IS_LOADING', $_ARRAYLANG['TXT_SHOP_CART_IS_LOADING'], 'shop/cart');
     \ContrexxJavascript::getInstance()->setVariable('TXT_SHOP_COULD_NOT_LOAD_CART', $_ARRAYLANG['TXT_SHOP_COULD_NOT_LOAD_CART'], 'shop/cart');
     \ContrexxJavascript::getInstance()->setVariable('TXT_EMPTY_SHOPPING_CART', $_ARRAYLANG['TXT_EMPTY_SHOPPING_CART'], 'shop/cart');
     \ContrexxJavascript::getInstance()->setVariable("url", (string) \Cx\Core\Routing\URL::fromModuleAndCMd('Shop' . MODULE_INDEX, 'cart', FRONTEND_LANG_ID, array('remoteJs' => 'addProduct')), 'shop/cart');
     \JS::registerJS(substr(\Cx\Core\Core\Controller\Cx::instanciate()->getModuleFolderName() . '/Shop/View/Script/cart.js', 1));
     \JS::registerCode("cartTpl = '" . preg_replace(array('/\'/', '/[\\n\\r]/', '/\\//'), array('\\\'', '\\n', '\\/'), $div_cart) . "';\n" . "cartProductsTpl = '" . preg_replace(array('/\'/', '/[\\n\\r]/', '/\\//'), array('\\\'', '\\n', '\\/'), $div_product) . "';\n");
 }
Example #4
0
 protected function actRenderCM()
 {
     global $_ARRAYLANG, $_CORELANG, $_CONFIG;
     \JS::activate('jqueryui');
     \JS::activate('cx');
     \JS::activate('ckeditor');
     \JS::activate('cx-form');
     \JS::activate('jstree');
     \JS::registerJS('lib/javascript/lock.js');
     \JS::registerJS('lib/javascript/jquery/jquery.history.max.js');
     // this can be used to debug the tree, just add &tree=verify or &tree=fix
     $tree = null;
     if (isset($_GET['tree'])) {
         $tree = contrexx_input2raw($_GET['tree']);
     }
     if ($tree == 'verify') {
         echo '<pre>';
         print_r($this->nodeRepository->verify());
         echo '</pre>';
     } else {
         if ($tree == 'fix') {
             // this should print "bool(true)"
             var_dump($this->nodeRepository->recover());
         }
     }
     $objCx = \ContrexxJavascript::getInstance();
     $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository();
     $defaultTheme = $themeRepo->getDefaultTheme();
     $objCx->setVariable('themeId', $defaultTheme->getId(), 'contentmanager/theme');
     foreach ($themeRepo->findAll() as $theme) {
         if ($theme == $defaultTheme) {
             $objCx->setVariable('themeName', $theme->getFoldername(), 'contentmanager/theme');
         }
     }
     $this->template->addBlockfile('ADMIN_CONTENT', 'content_manager', 'Skeleton.html');
     // user has no permission to create new page, hide navigation item in admin navigation
     if (!\Permission::checkAccess(127, 'static', true)) {
         $this->template->hideBlock('content_manager_create_new_page_navigation_item');
     }
     $this->template->touchBlock('content_manager');
     $this->template->addBlockfile('CONTENT_MANAGER_MEAT', 'content_manager_meat', 'Page.html');
     $this->template->touchBlock('content_manager_meat');
     if (\Permission::checkAccess(78, 'static', true)) {
         \JS::registerCode("var publishAllowed = true;");
     } else {
         \JS::registerCode("var publishAllowed = false;");
     }
     if (\Permission::checkAccess(78, 'static', true) && \Permission::checkAccess(115, 'static', true)) {
         \JS::registerCode("var aliasManagementAllowed = true;");
         $alias_permission = "block";
         $alias_denial = "none !important";
     } else {
         \JS::registerCode("var aliasManagementAllowed = false;");
         $alias_permission = "none !important";
         $alias_denial = "block";
     }
     $mediaBrowser = new MediaBrowser();
     $mediaBrowser->setCallback('target_page_callback');
     $mediaBrowser->setOptions(array('type' => 'button', 'data-cx-mb-views' => 'sitestructure', 'id' => 'page_target_browse'));
     $mediaBrowserCkeditor = new MediaBrowser();
     $mediaBrowserCkeditor->setCallback('ckeditor_image_callback');
     $mediaBrowserCkeditor->setOptions(array('id' => 'ckeditor_image_button', 'type' => 'button', 'style' => 'display:none'));
     $this->template->setVariable(array('MEDIABROWSER_BUTTON' => $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE']), 'MEDIABROWSER_BUTTON_CKEDITOR' => $mediaBrowserCkeditor->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
     $this->template->setVariable(array('ALIAS_PERMISSION' => $alias_permission, 'ALIAS_DENIAL' => $alias_denial, 'CONTREXX_BASE_URL' => ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/', 'CONTREXX_LANG' => \FWLanguage::getLanguageCodeById(BACKEND_LANG_ID)));
     global $_CORELANG;
     $this->template->setVariable($_CORELANG);
     $objCx->setVariable('TXT_CORE_CM_VIEW', $_CORELANG['TXT_CORE_CM_VIEW'], 'contentmanager/lang');
     $objCx->setVariable('TXT_CORE_CM_ACTIONS', $_CORELANG['TXT_CORE_CM_ACTIONS'], 'contentmanager/lang');
     $objCx->setVariable('TXT_CORE_CM_VALIDATION_FAIL', $_CORELANG['TXT_CORE_CM_VALIDATION_FAIL'], 'contentmanager/lang');
     $objCx->setVariable('TXT_CORE_CM_HOME_FAIL', $_CORELANG['TXT_CORE_CM_HOME_FAIL'], 'contentmanager/lang');
     $arrLangVars = array('actions' => array('new' => 'TXT_CORE_CM_ACTION_NEW', 'copy' => 'TXT_CORE_CM_ACTION_COPY', 'activate' => 'TXT_CORE_CM_ACTION_PUBLISH', 'deactivate' => 'TXT_CORE_CM_ACTION_UNPUBLISH', 'publish' => 'TXT_CORE_CM_ACTION_PUBLISH_DRAFT', 'show' => 'TXT_CORE_CM_ACTION_SHOW', 'hide' => 'TXT_CORE_CM_ACTION_HIDE', 'delete' => 'TXT_CORE_CM_ACTION_DELETE', 'recursiveQuestion' => 'TXT_CORE_CM_RECURSIVE_QUESTION'), 'tooltip' => array('TXT_CORE_CM_LAST_MODIFIED' => 'TXT_CORE_CM_LAST_MODIFIED', 'TXT_CORE_CM_PUBLISHING_INFO_STATUSES' => 'TXT_CORE_CM_PUBLISHING_INFO_STATUSES', 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_ACTIVATE' => 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_ACTIVATE', 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_DEACTIVATE' => 'TXT_CORE_CM_PUBLISHING_INFO_ACTION_DEACTIVATE', 'TXT_CORE_CM_PUBLISHING_DRAFT' => 'TXT_CORE_CM_PUBLISHING_DRAFT', 'TXT_CORE_CM_PUBLISHING_DRAFT_WAITING' => 'TXT_CORE_CM_PUBLISHING_DRAFT_WAITING', 'TXT_CORE_CM_PUBLISHING_LOCKED' => 'TXT_CORE_CM_PUBLISHING_LOCKED', 'TXT_CORE_CM_PUBLISHING_PUBLISHED' => 'TXT_CORE_CM_PUBLISHING_PUBLISHED', 'TXT_CORE_CM_PUBLISHING_UNPUBLISHED' => 'TXT_CORE_CM_PUBLISHING_UNPUBLISHED', 'TXT_CORE_CM_PAGE_INFO_STATUSES' => 'TXT_CORE_CM_PAGE_INFO_STATUSES', 'TXT_CORE_CM_PUBLISHING_INFO_TYPES' => 'TXT_CORE_CM_PUBLISHING_INFO_TYPES', 'TXT_CORE_CM_PAGE_INFO_ACTION_SHOW' => 'TXT_CORE_CM_PAGE_INFO_ACTION_SHOW', 'TXT_CORE_CM_PAGE_INFO_ACTION_HIDE' => 'TXT_CORE_CM_PAGE_INFO_ACTION_HIDE', 'TXT_CORE_CM_PAGE_STATUS_BROKEN' => 'TXT_CORE_CM_PAGE_STATUS_BROKEN', 'TXT_CORE_CM_PAGE_STATUS_VISIBLE' => 'TXT_CORE_CM_PAGE_STATUS_VISIBLE', 'TXT_CORE_CM_PAGE_STATUS_INVISIBLE' => 'TXT_CORE_CM_PAGE_STATUS_INVISIBLE', 'TXT_CORE_CM_PAGE_STATUS_PROTECTED' => 'TXT_CORE_CM_PAGE_STATUS_PROTECTED', 'TXT_CORE_CM_PAGE_TYPE_HOME' => 'TXT_CORE_CM_PAGE_TYPE_HOME', 'TXT_CORE_CM_PAGE_TYPE_CONTENT_SITE' => 'TXT_CORE_CM_PAGE_TYPE_CONTENT_SITE', 'TXT_CORE_CM_PAGE_TYPE_APPLICATION' => 'TXT_CORE_CM_PAGE_TYPE_APPLICATION', 'TXT_CORE_CM_PAGE_TYPE_REDIRECTION' => 'TXT_CORE_CM_PAGE_TYPE_REDIRECTION', 'TXT_CORE_CM_PAGE_TYPE_SYMLINK' => 'TXT_CORE_CM_PAGE_TYPE_SYMLINK', 'TXT_CORE_CM_PAGE_TYPE_FALLBACK' => 'TXT_CORE_CM_PAGE_TYPE_FALLBACK', 'TXT_CORE_CM_PAGE_MOVE_INFO' => 'TXT_CORE_CM_PAGE_MOVE_INFO', 'TXT_CORE_CM_TRANSLATION_INFO' => 'TXT_CORE_CM_TRANSLATION_INFO', 'TXT_CORE_CM_PREVIEW_INFO' => 'TXT_CORE_CM_PREVIEW_INFO'));
     foreach ($arrLangVars as $subscope => $arrLang) {
         foreach ($arrLang as $name => $value) {
             $objCx->setVariable($name, $_CORELANG[$value], 'contentmanager/lang/' . $subscope);
         }
     }
     // Mediabrowser
     $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
     $mediaBrowser->setOptions(array('type' => 'button'));
     $mediaBrowser->setCallback('setWebPageUrlCallback');
     $mediaBrowser->setOptions(array('data-cx-mb-startview' => 'sitestructure', 'id' => 'page_target_browse'));
     $this->template->setVariable(array('CM_MEDIABROWSER_BUTTON' => $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
     $toggleTitles = !empty($_SESSION['contentManager']['toggleStatuses']['toggleTitles']) ? $_SESSION['contentManager']['toggleStatuses']['toggleTitles'] : 'block';
     $toggleType = !empty($_SESSION['contentManager']['toggleStatuses']['toggleType']) ? $_SESSION['contentManager']['toggleStatuses']['toggleType'] : 'block';
     $toggleNavigation = !empty($_SESSION['contentManager']['toggleStatuses']['toggleNavigation']) ? $_SESSION['contentManager']['toggleStatuses']['toggleNavigation'] : 'block';
     $toggleBlocks = !empty($_SESSION['contentManager']['toggleStatuses']['toggleBlocks']) ? $_SESSION['contentManager']['toggleStatuses']['toggleBlocks'] : 'block';
     $toggleThemes = !empty($_SESSION['contentManager']['toggleStatuses']['toggleThemes']) ? $_SESSION['contentManager']['toggleStatuses']['toggleThemes'] : 'block';
     $toggleApplication = !empty($_SESSION['contentManager']['toggleStatuses']['toggleApplication']) ? $_SESSION['contentManager']['toggleStatuses']['toggleApplication'] : 'block';
     $toggleSidebar = !empty($_SESSION['contentManager']['toggleStatuses']['sidebar']) ? $_SESSION['contentManager']['toggleStatuses']['sidebar'] : 'block';
     $objCx->setVariable('toggleTitles', $toggleTitles, 'contentmanager/toggle');
     $objCx->setVariable('toggleType', $toggleType, 'contentmanager/toggle');
     $objCx->setVariable('toggleNavigation', $toggleNavigation, 'contentmanager/toggle');
     $objCx->setVariable('toggleBlocks', $toggleBlocks, 'contentmanager/toggle');
     $objCx->setVariable('toggleThemes', $toggleThemes, 'contentmanager/toggle');
     $objCx->setVariable('toggleApplication', $toggleApplication, 'contentmanager/toggle');
     $objCx->setVariable('sidebar', $toggleSidebar, 'contentmanager/toggle');
     // get initial tree data
     $objJsonData = new \Cx\Core\Json\JsonData();
     $treeData = $objJsonData->jsondata('node', 'getTree', array('get' => $_GET), false);
     $objCx->setVariable('tree-data', $treeData, 'contentmanager/tree');
     if (!empty($_GET['act']) && $_GET['act'] == 'new') {
         $this->template->setVariable(array('TITLES_DISPLAY_STYLE' => 'display: block;', 'TITLES_TOGGLE_CLASS' => 'open', 'TYPE_DISPLAY_STYLE' => 'display: block;', 'TYPE_TOGGLE_CLASS' => 'open', 'NAVIGATION_DISPLAY_STYLE' => 'display: block;', 'NAVIGATION_TOGGLE_CLASS' => 'open', 'BLOCKS_DISPLAY_STYLE' => 'display: block;', 'BLOCKS_TOGGLE_CLASS' => 'open', 'THEMES_DISPLAY_STYLE' => 'display: block;', 'THEMES_TOGGLE_CLASS' => 'open', 'APPLICATION_DISPLAY_STYLE' => 'display: block;', 'APPLICATION_TOGGLE_CLASS' => 'open', 'MULTIPLE_ACTIONS_STRIKE_STYLE' => 'display: none;'));
     } else {
         $this->template->setVariable(array('TITLES_DISPLAY_STYLE' => $toggleTitles == 'none' ? 'display: none;' : 'display: block;', 'TITLES_TOGGLE_CLASS' => $toggleTitles == 'none' ? 'closed' : 'open', 'TYPE_DISPLAY_STYLE' => $toggleType == 'none' ? 'display: none;' : 'display: block;', 'TYPE_TOGGLE_CLASS' => $toggleType == 'none' ? 'closed' : 'open', 'NAVIGATION_DISPLAY_STYLE' => $toggleNavigation == 'none' ? 'display: none;' : 'display: block;', 'NAVIGATION_TOGGLE_CLASS' => $toggleNavigation == 'none' ? 'closed' : 'open', 'BLOCKS_DISPLAY_STYLE' => $toggleBlocks == 'none' ? 'display: none;' : 'display: block;', 'BLOCKS_TOGGLE_CLASS' => $toggleBlocks == 'none' ? 'closed' : 'open', 'THEMES_DISPLAY_STYLE' => $toggleThemes == 'none' ? 'display: none;' : 'display: block;', 'THEMES_TOGGLE_CLASS' => $toggleThemes == 'none' ? 'closed' : 'open', 'APPLICATION_DISPLAY_STYLE' => $toggleApplication == 'none' ? 'display: none;' : 'display: block;', 'APPLICATION_TOGGLE_CLASS' => $toggleApplication == 'none' ? 'closed' : 'open'));
     }
     $modules = $this->db->Execute("SELECT * FROM " . DBPREFIX . "modules WHERE `status` = 'y' ORDER BY `name`");
     while (!$modules->EOF) {
         $this->template->setVariable('MODULE_KEY', $modules->fields['name']);
         //            $this->template->setVariable('MODULE_TITLE', $_CORELANG[$modules->fields['description_variable']]);
         $this->template->setVariable('MODULE_TITLE', ucwords($modules->fields['name']));
         $this->template->parse('module_option');
         $modules->MoveNext();
     }
     $newPageFirstLevel = isset($_GET['act']) && $_GET['act'] == 'new';
     if (\Permission::checkAccess(36, 'static', true)) {
         $this->template->touchBlock('page_permissions_tab');
         $this->template->touchBlock('page_permissions');
     } else {
         $this->template->hideBlock('page_permissions_tab');
         $this->template->hideBlock('page_permissions');
     }
     //show the caching options only if the caching system is actually active
     if ($_CONFIG['cacheEnabled'] == 'on') {
         $this->template->touchBlock('show_caching_option');
     } else {
         $this->template->hideBlock('show_caching_option');
     }
     if (\Permission::checkAccess(78, 'static', true)) {
         $this->template->hideBlock('release_button');
     } else {
         $this->template->hideBlock('publish_button');
         $this->template->hideBlock('refuse_button');
     }
     // show no access page if the user wants to create new page in first level but he does not have enough permissions
     if ($newPageFirstLevel) {
         \Permission::checkAccess(127, 'static');
     }
     $editViewCssClass = '';
     if ($newPageFirstLevel) {
         $editViewCssClass = 'edit_view';
         $this->template->hideBlock('refuse_button');
     }
     $cxjs = \ContrexxJavascript::getInstance();
     $cxjs->setVariable('confirmDeleteQuestion', $_ARRAYLANG['TXT_CORE_CM_CONFIRM_DELETE'], 'contentmanager/lang');
     $cxjs->setVariable('cleanAccessData', $objJsonData->jsondata('page', 'getAccessData', array(), false), 'contentmanager');
     $cxjs->setVariable('contentTemplates', $this->getCustomContentTemplates(), 'contentmanager');
     $cxjs->setVariable('defaultTemplates', $this->getDefaultTemplates(), 'contentmanager/themes');
     $cxjs->setVariable('templateFolders', $this->getTemplateFolders(), 'contentmanager/themes');
     $cxjs->setVariable('availableBlocks', $objJsonData->jsondata('Block', 'getBlocks', array(), false), 'contentmanager');
     // TODO: move including of add'l JS dependencies to cx obj from /cadmin/index.html
     $getLangOptions = $this->getLangOptions();
     $statusPageLayout = '';
     $languageDisplay = '';
     if ((!empty($_GET['act']) && $_GET['act'] == 'new' || !empty($_GET['page'])) && $getLangOptions == "") {
         $statusPageLayout = 'margin0';
         $languageDisplay = 'display:none';
     }
     $this->template->setVariable('ADMIN_LIST_MARGIN', $statusPageLayout);
     $this->template->setVariable('LANGUAGE_DISPLAY', $languageDisplay);
     // TODO: move including of add'l JS dependencies to cx obj from /cadmin/index.html
     $this->template->setVariable('SKIN_OPTIONS', $this->getSkinOptions());
     $this->template->setVariable('LANGSWITCH_OPTIONS', $this->getLangOptions());
     $this->template->setVariable('LANGUAGE_ARRAY', json_encode($this->getLangArray()));
     $this->template->setVariable('FALLBACK_ARRAY', json_encode($this->getFallbackArray()));
     $this->template->setVariable('LANGUAGE_LABELS', json_encode($this->getLangLabels()));
     $this->template->setVariable('EDIT_VIEW_CSS_CLASS', $editViewCssClass);
     $this->template->touchBlock('content_manager_language_selection');
     $editmodeTemplate = new \Cx\Core\Html\Sigma(ASCMS_CORE_PATH . '/ContentManager/View/Template/Backend');
     $editmodeTemplate->loadTemplateFile('content_editmode.html');
     $editmodeTemplate->setVariable(array('TXT_EDITMODE_TEXT' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_TEXT'], 'TXT_EDITMODE_CODE' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_MODE_PAGE'], 'TXT_EDITMODE_CONTENT' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_MODE_CONTENT']));
     $cxjs->setVariable(array('editmodetitle' => $_CORELANG['TXT_FRONTEND_EDITING_SELECTION_TITLE'], 'editmodecontent' => $editmodeTemplate->get(), 'ckeditorconfigpath' => substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT) + 1), 'regExpUriProtocol' => \FWValidator::REGEX_URI_PROTO, 'contrexxBaseUrl' => ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/', 'contrexxPathOffset' => ASCMS_PATH_OFFSET), 'contentmanager');
 }
Example #5
0
 /**
  * Generate the form and show hints if necessary.
  * If user input validation is successful a new transaction will be added.
  * In this case the form will be hidden and only a status message will be shown.
  *
  * @access      private
  */
 private function renderForm()
 {
     global $objDatabase, $_ARRAYLANG, $_CORELANG;
     //check the payment service provider configuration
     $objSettingsGeneral = new SettingsGeneral($objDatabase);
     if (!$objSettingsGeneral->getEpaymentStatus()) {
         $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_EPAYMENT_DEACTIVATED'];
         $this->objTemplate->hideblock('form');
         $this->objTemplate->hideblock('redirect');
         return;
     }
     //initialize variables
     $arrFieldValues = array();
     $arrFieldsToHighlight = array();
     $arrCssClasses = array();
     $cssHighlightingClass = 'highlight';
     $cssLabelClass = 'label';
     $htmlRequiredField = ' *';
     $arrSelectOptions[] = array();
     //validate submitted user data
     if (isset($_REQUEST['submit'])) {
         $arrFieldValues['invoice_number'] = !empty($_REQUEST['invoice_number']) && $_REQUEST['invoice_number'] !== $_ARRAYLANG['TXT_CHECKOUT_INVOICE_NUMBER'] . $htmlRequiredField ? $_REQUEST['invoice_number'] : '';
         $arrFieldValues['invoice_currency'] = !empty($_REQUEST['invoice_currency']) ? $_REQUEST['invoice_currency'] : '';
         $arrFieldValues['invoice_amount'] = !empty($_REQUEST['invoice_amount']) && $_REQUEST['invoice_amount'] !== $_ARRAYLANG['TXT_CHECKOUT_INVOICE_AMOUNT'] . $htmlRequiredField ? $_REQUEST['invoice_amount'] : '';
         $arrFieldValues['contact_title'] = !empty($_REQUEST['contact_title']) ? $_REQUEST['contact_title'] : '';
         $arrFieldValues['contact_forename'] = !empty($_REQUEST['contact_forename']) && $_REQUEST['contact_forename'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_FORENAME'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_forename'])) : '';
         $arrFieldValues['contact_surname'] = !empty($_REQUEST['contact_surname']) && $_REQUEST['contact_surname'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_SURNAME'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_surname'])) : '';
         $arrFieldValues['contact_company'] = !empty($_REQUEST['contact_company']) && $_REQUEST['contact_company'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COMPANY'] ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_company'])) : '';
         $arrFieldValues['contact_street'] = !empty($_REQUEST['contact_street']) && $_REQUEST['contact_street'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_STREET'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_street'])) : '';
         $arrFieldValues['contact_postcode'] = !empty($_REQUEST['contact_postcode']) && $_REQUEST['contact_postcode'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_POSTCODE'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_postcode'])) : '';
         $arrFieldValues['contact_place'] = !empty($_REQUEST['contact_place']) && $_REQUEST['contact_place'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PLACE'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_place'])) : '';
         $arrFieldValues['contact_country'] = !empty($_REQUEST['contact_country']) ? $_REQUEST['contact_country'] : '';
         $arrFieldValues['contact_phone'] = !empty($_REQUEST['contact_phone']) && $_REQUEST['contact_phone'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PHONE'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_phone'])) : '';
         $arrFieldValues['contact_email'] = !empty($_REQUEST['contact_email']) && $_REQUEST['contact_email'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_EMAIL'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_email'])) : '';
         //get keys of passed data
         if (!isset($this->arrCurrencies[$invoiceCurrency]) && ($key = array_search(strtoupper($invoiceCurrency), $this->arrCurrencies))) {
             $invoiceCurrency = $key;
         }
         if (strtolower($contactTitle) !== self::MISTER && strtolower($contactTitle) !== self::MISS) {
             if (ucfirst(strtolower($contactTitle)) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER']) {
                 $contactTitle = self::MISTER;
             } elseif (ucfirst(strtolower($contactTitle)) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS']) {
                 $contactTitle = self::MISS;
             }
         } else {
             $contactTitle = strtolower($contactTitle);
         }
         if (!isset($this->arrCountries[$contactCountry]) && ($key = array_search(ucfirst(strtolower($contactCountry)), $this->arrCountries))) {
             $contactCountry = $key;
         }
         $arrUserData['text']['invoice_number']['name'] = $_ARRAYLANG['TXT_CHECKOUT_INVOICE_NUMBER'];
         $arrUserData['text']['invoice_number']['value'] = $arrFieldValues['invoice_number'];
         $arrUserData['text']['invoice_number']['length'] = 255;
         $arrUserData['text']['invoice_number']['mandatory'] = 1;
         $arrUserData['selection']['invoice_currency']['name'] = $_ARRAYLANG['TXT_CHECKOUT_INVOICE_CURRENCY'];
         $arrUserData['selection']['invoice_currency']['value'] = $arrFieldValues['invoice_currency'];
         $arrUserData['selection']['invoice_currency']['options'] = $this->arrCurrencies;
         $arrUserData['selection']['invoice_currency']['mandatory'] = 1;
         $arrUserData['numeric']['invoice_amount']['name'] = $_ARRAYLANG['TXT_CHECKOUT_INVOICE_AMOUNT'];
         $arrUserData['numeric']['invoice_amount']['value'] = $arrFieldValues['invoice_amount'];
         $arrUserData['numeric']['invoice_amount']['length'] = 15;
         $arrUserData['numeric']['invoice_amount']['mandatory'] = 1;
         $arrUserData['selection']['contact_title']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE'];
         $arrUserData['selection']['contact_title']['value'] = $arrFieldValues['contact_title'];
         $arrUserData['selection']['contact_title']['options'] = array(self::MISTER => '', self::MISS => '');
         $arrUserData['selection']['contact_title']['mandatory'] = 1;
         $arrUserData['text']['contact_forename']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_FORENAME'];
         $arrUserData['text']['contact_forename']['value'] = $arrFieldValues['contact_forename'];
         $arrUserData['text']['contact_forename']['length'] = 255;
         $arrUserData['text']['contact_forename']['mandatory'] = 1;
         $arrUserData['text']['contact_surname']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_SURNAME'];
         $arrUserData['text']['contact_surname']['value'] = $arrFieldValues['contact_surname'];
         $arrUserData['text']['contact_surname']['length'] = 255;
         $arrUserData['text']['contact_surname']['mandatory'] = 1;
         $arrUserData['text']['contact_company']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COMPANY'];
         $arrUserData['text']['contact_company']['value'] = $arrFieldValues['contact_company'];
         $arrUserData['text']['contact_company']['length'] = 255;
         $arrUserData['text']['contact_company']['mandatory'] = 0;
         $arrUserData['text']['contact_street']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_STREET'];
         $arrUserData['text']['contact_street']['value'] = $arrFieldValues['contact_street'];
         $arrUserData['text']['contact_street']['length'] = 255;
         $arrUserData['text']['contact_street']['mandatory'] = 1;
         $arrUserData['text']['contact_postcode']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_POSTCODE'];
         $arrUserData['text']['contact_postcode']['value'] = $arrFieldValues['contact_postcode'];
         $arrUserData['text']['contact_postcode']['length'] = 255;
         $arrUserData['text']['contact_postcode']['mandatory'] = 1;
         $arrUserData['text']['contact_place']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PLACE'];
         $arrUserData['text']['contact_place']['value'] = $arrFieldValues['contact_place'];
         $arrUserData['text']['contact_place']['length'] = 255;
         $arrUserData['text']['contact_place']['mandatory'] = 1;
         $arrUserData['selection']['contact_country']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COUNTRY'];
         $arrUserData['selection']['contact_country']['value'] = $arrFieldValues['contact_country'];
         $arrUserData['selection']['contact_country']['options'] = $this->arrCountries;
         $arrUserData['selection']['contact_country']['mandatory'] = 1;
         $arrUserData['text']['contact_phone']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PHONE'];
         $arrUserData['text']['contact_phone']['value'] = $arrFieldValues['contact_phone'];
         $arrUserData['text']['contact_phone']['length'] = 255;
         $arrUserData['text']['contact_phone']['mandatory'] = 1;
         $arrUserData['email']['contact_email']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_EMAIL'];
         $arrUserData['email']['contact_email']['value'] = $arrFieldValues['contact_email'];
         $arrUserData['email']['contact_email']['length'] = 255;
         $arrUserData['email']['contact_email']['mandatory'] = 1;
         $arrFieldsToHighlight = $this->validateUserData($arrUserData);
         if (empty($arrFieldsToHighlight)) {
             //validation was successful. now add a new transaction.
             $id = $this->objTransaction->add(self::WAITING, $arrUserData['text']['invoice_number']['value'], $arrUserData['selection']['invoice_currency']['value'], $arrUserData['numeric']['invoice_amount']['value'], $arrUserData['selection']['contact_title']['value'], $arrUserData['text']['contact_forename']['value'], $arrUserData['text']['contact_surname']['value'], $arrUserData['text']['contact_company']['value'], $arrUserData['text']['contact_street']['value'], $arrUserData['text']['contact_postcode']['value'], $arrUserData['text']['contact_place']['value'], $arrUserData['selection']['contact_country']['value'], $arrUserData['text']['contact_phone']['value'], $arrUserData['email']['contact_email']['value']);
             if ($id) {
                 $objSettingsYellowpay = new SettingsYellowpay($objDatabase);
                 $arrYellowpay = $objSettingsYellowpay->get();
                 $arrOrder = array('ORDERID' => $id, 'AMOUNT' => intval($arrFieldValues['invoice_amount'] * 100), 'CURRENCY' => $this->arrCurrencies[$arrFieldValues['invoice_currency']], 'PARAMPLUS' => 'section=Checkout');
                 $arrSettings['postfinance_shop_id']['value'] = $arrYellowpay['pspid'];
                 $arrSettings['postfinance_hash_signature_in']['value'] = $arrYellowpay['sha_in'];
                 $arrSettings['postfinance_authorization_type']['value'] = $arrYellowpay['operation'];
                 $arrSettings['postfinance_use_testserver']['value'] = $arrYellowpay['testserver'];
                 $landingPage = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findOneByModuleCmdLang('Checkout', '', FRONTEND_LANG_ID);
                 $this->objTemplate->setVariable('CHECKOUT_YELLOWPAY_FORM', \Yellowpay::getForm($arrOrder, $_ARRAYLANG['TXT_CHECKOUT_START_PAYMENT'], false, $arrSettings, $landingPage));
                 if (\Yellowpay::$arrError) {
                     $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_FAILED_TO_INITIALISE_YELLOWPAY'];
                 } else {
                     $this->arrStatusMessages['ok'][] = $_ARRAYLANG['TXT_CHECKOUT_ENTRY_SAVED_SUCCESSFULLY'];
                 }
                 $this->objTemplate->hideBlock('form');
                 $this->objTemplate->touchBlock('redirect');
                 return;
             } else {
                 $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_ENTRY_SAVED_ERROR'];
             }
         }
     } else {
         //get passed data
         $arrFieldValues['invoice_number'] = !empty($_REQUEST['invoice_number']) ? $_REQUEST['invoice_number'] : '';
         $arrFieldValues['invoice_currency'] = !empty($_REQUEST['invoice_currency']) ? $_REQUEST['invoice_currency'] : '';
         $arrFieldValues['invoice_amount'] = !empty($_REQUEST['invoice_amount']) ? $_REQUEST['invoice_amount'] : '';
         $arrFieldValues['contact_title'] = !empty($_REQUEST['contact_title']) ? $_REQUEST['contact_title'] : '';
         $arrFieldValues['contact_forename'] = !empty($_REQUEST['contact_forename']) ? $_REQUEST['contact_forename'] : '';
         $arrFieldValues['contact_surname'] = !empty($_REQUEST['contact_surname']) ? $_REQUEST['contact_surname'] : '';
         $arrFieldValues['contact_company'] = !empty($_REQUEST['contact_company']) ? $_REQUEST['contact_company'] : '';
         $arrFieldValues['contact_street'] = !empty($_REQUEST['contact_street']) ? $_REQUEST['contact_street'] : '';
         $arrFieldValues['contact_postcode'] = !empty($_REQUEST['contact_postcode']) ? $_REQUEST['contact_postcode'] : '';
         $arrFieldValues['contact_place'] = !empty($_REQUEST['contact_place']) ? $_REQUEST['contact_place'] : '';
         $arrFieldValues['contact_country'] = !empty($_REQUEST['contact_country']) ? $_REQUEST['contact_country'] : '';
         $arrFieldValues['contact_phone'] = !empty($_REQUEST['contact_phone']) ? $_REQUEST['contact_phone'] : '';
         $arrFieldValues['contact_email'] = !empty($_REQUEST['contact_email']) ? $_REQUEST['contact_email'] : '';
         //get keys of passed options selection
         if (!isset($this->arrCurrencies[$arrFieldValues['invoice_currency']]) && ($key = array_search(strtoupper($arrFieldValues['invoice_currency']), $this->arrCurrencies))) {
             $arrFieldValues['invoice_currency'] = $key;
         }
         if (strtolower($arrFieldValues['contact_title']) !== self::MISTER && strtolower($arrFieldValues['contact_title']) !== self::MISS) {
             if (ucfirst(strtolower($arrFieldValues['contact_title'])) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER']) {
                 $arrFieldValues['contact_title'] = self::MISTER;
             } elseif (ucfirst(strtolower($arrFieldValues['contact_title'])) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS']) {
                 $arrFieldValues['contact_title'] = self::MISS;
             }
         } else {
             $arrFieldValues['contact_title'] = strtolower($arrFieldValues['contact_title']);
         }
         if (!isset($this->arrCountries[$arrFieldValues['contact_country']]) && ($key = array_search(ucfirst(strtolower($arrFieldValues['contact_country'])), $this->arrCountries))) {
             $arrFieldValues['contact_country'] = $key;
         }
     }
     //get currency options
     $arrSelectOptions['currencies'][] = '<option value="0">' . $_ARRAYLANG['TXT_CHECKOUT_INVOICE_CURRENCY'] . $htmlRequiredField . '</option>';
     foreach ($this->arrCurrencies as $id => $currency) {
         $selected = $id == $arrFieldValues['invoice_currency'] ? ' selected="selected"' : '';
         $arrSelectOptions['currencies'][] = '<option value="' . $id . '"' . $selected . '>' . contrexx_raw2xhtml($currency) . '</option>';
     }
     //get title options
     $selectedMister = self::MISTER == $arrFieldValues['contact_title'] ? ' selected="selected"' : '';
     $selectedMiss = self::MISS == $arrFieldValues['contact_title'] ? ' selected="selected"' : '';
     $arrSelectOptions['titles'][] = '<option value="0">' . $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE'] . $htmlRequiredField . '</option>';
     $arrSelectOptions['titles'][] = '<option value="' . self::MISTER . '"' . $selectedMister . '>' . $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER'] . '</option>';
     $arrSelectOptions['titles'][] = '<option value="' . self::MISS . '"' . $selectedMiss . '>' . $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS'] . '</option>';
     //get country options
     if (!empty($this->arrCountries)) {
         //$arrSelectOptions['countries'][] = '<option value="0">'.$_ARRAYLANG['TXT_CHECKOUT_CONTACT_COUNTRY'].$htmlRequiredField.'</option>';
         foreach ($this->arrCountries as $id => $name) {
             if (\Cx\Core\Country\Controller\Country::getAlpha2ById($id) != 'CH') {
                 continue;
             }
             $selected = $id == $arrFieldValues['contact_country'] ? ' selected="selected"' : '';
             $arrSelectOptions['countries'][] = '<option value="' . $id . '"' . $selected . '>' . contrexx_raw2xhtml($name) . '</option>';
         }
     }
     // check wihch css classes have to be set
     foreach ($arrFieldValues as $name => $value) {
         if (isset($arrFieldsToHighlight[$name])) {
             $arrCssClasses[$name][] = $cssHighlightingClass;
         }
         if (empty($value)) {
             $arrCssClasses[$name][] = $cssLabelClass;
         }
         $arrCssClasses[$name] = implode(' ', $arrCssClasses[$name]);
     }
     \JS::activate('jquery');
     \JS::registerCode($this->getJavascript($htmlRequiredField));
     $this->objTemplate->setVariable(array('TXT_CHECKOUT_DESCRIPTION' => $_ARRAYLANG['TXT_CHECKOUT_DESCRIPTION'], 'TXT_CHECKOUT_BILL_DATA' => $_ARRAYLANG['TXT_CHECKOUT_BILL_DATA'], 'TXT_CHECKOUT_CONTACT_DATA' => $_ARRAYLANG['TXT_CHECKOUT_CONTACT_DATA'], 'CHECKOUT_INVOICE_NUMBER' => !empty($arrFieldValues['invoice_number']) ? $arrFieldValues['invoice_number'] : $_ARRAYLANG['TXT_CHECKOUT_INVOICE_NUMBER'] . $htmlRequiredField, 'CHECKOUT_INVOICE_CURRENCY_OPTIONS' => !empty($arrSelectOptions['currencies']) ? implode($arrSelectOptions['currencies']) : '', 'CHECKOUT_INVOICE_AMOUNT' => !empty($arrFieldValues['invoice_amount']) ? $arrFieldValues['invoice_amount'] : $_ARRAYLANG['TXT_CHECKOUT_INVOICE_AMOUNT'] . $htmlRequiredField, 'CHECKOUT_CONTACT_TITLE_OPTIONS' => !empty($arrSelectOptions['titles']) ? implode($arrSelectOptions['titles']) : '', 'CHECKOUT_CONTACT_FORENAME' => !empty($arrFieldValues['contact_forename']) ? $arrFieldValues['contact_forename'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_FORENAME'] . $htmlRequiredField, 'CHECKOUT_CONTACT_SURNAME' => !empty($arrFieldValues['contact_surname']) ? $arrFieldValues['contact_surname'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_SURNAME'] . $htmlRequiredField, 'CHECKOUT_CONTACT_COMPANY' => !empty($arrFieldValues['contact_company']) ? $arrFieldValues['contact_company'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COMPANY'], 'CHECKOUT_CONTACT_STREET' => !empty($arrFieldValues['contact_street']) ? $arrFieldValues['contact_street'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_STREET'] . $htmlRequiredField, 'CHECKOUT_CONTACT_POSTCODE' => !empty($arrFieldValues['contact_postcode']) ? $arrFieldValues['contact_postcode'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_POSTCODE'] . $htmlRequiredField, 'CHECKOUT_CONTACT_PLACE' => !empty($arrFieldValues['contact_place']) ? $arrFieldValues['contact_place'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PLACE'] . $htmlRequiredField, 'CHECKOUT_CONTACT_COUNTRY_OPTIONS' => !empty($arrSelectOptions['countries']) ? implode($arrSelectOptions['countries']) : '', 'CHECKOUT_CONTACT_PHONE' => !empty($arrFieldValues['contact_phone']) ? $arrFieldValues['contact_phone'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PHONE'] . $htmlRequiredField, 'CHECKOUT_CONTACT_EMAIL' => !empty($arrFieldValues['contact_email']) ? $arrFieldValues['contact_email'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_EMAIL'] . $htmlRequiredField, 'CHECKOUT_INVOICE_NUMBER_CLASS' => $arrCssClasses['invoice_number'], 'CHECKOUT_INVOICE_CURRENCY_CLASS' => $arrCssClasses['invoice_currency'], 'CHECKOUT_INVOICE_AMOUNT_CLASS' => $arrCssClasses['invoice_amount'], 'CHECKOUT_CONTACT_TITLE_CLASS' => $arrCssClasses['contact_title'], 'CHECKOUT_CONTACT_FORENAME_CLASS' => $arrCssClasses['contact_forename'], 'CHECKOUT_CONTACT_SURNAME_CLASS' => $arrCssClasses['contact_surname'], 'CHECKOUT_CONTACT_COMPANY_CLASS' => $arrCssClasses['contact_company'], 'CHECKOUT_CONTACT_STREET_CLASS' => $arrCssClasses['contact_street'], 'CHECKOUT_CONTACT_POSTCODE_CLASS' => $arrCssClasses['contact_postcode'], 'CHECKOUT_CONTACT_PLACE_CLASS' => $arrCssClasses['contact_place'], 'CHECKOUT_CONTACT_COUNTRY_CLASS' => $arrCssClasses['contact_country'], 'CHECKOUT_CONTACT_PHONE_CLASS' => $arrCssClasses['contact_phone'], 'CHECKOUT_CONTACT_EMAIL_CLASS' => $arrCssClasses['contact_email'], 'TXT_CORE_SUBMIT' => $_CORELANG['TXT_CORE_SUBMIT'], 'TXT_CORE_RESET' => $_CORELANG['TXT_CORE_RESET']));
     $this->objTemplate->hideBlock('redirect');
     $this->objTemplate->parse('form');
 }
Example #6
0
 /**
  * Display a section of settings present in the $arrSettings class array
  *
  * See the description of {@see show()} for details.
  * @param   \Cx\Core\Html\Sigma $objTemplateLocal   The Template object,
  *                                                  by reference
  * @param   string              $section      The optional section header
  *                                            text to add
  * @param   string              $prefix       The optional prefix for
  *                                            language variables.
  *                                            Defaults to 'TXT_'
  * @return  boolean                           True on success, false otherwise
  */
 static function show_section(&$objTemplateLocal, $section = '', $prefix = 'TXT_', $readOnly = false)
 {
     global $_ARRAYLANG, $_CORELANG;
     $arrSettings = self::getCurrentSettings();
     self::verify_template($objTemplateLocal);
     // This is set to multipart if necessary
     $enctype = '';
     $i = 0;
     if ($objTemplateLocal->blockExists('core_setting_row')) {
         $objTemplateLocal->setCurrentBlock('core_setting_row');
     }
     foreach ($arrSettings as $name => $arrSetting) {
         // Determine HTML element for type and apply values and selected
         $element = '';
         $value = $arrSetting['value'];
         $values = self::splitValues($arrSetting['values']);
         $type = $arrSetting['type'];
         // Not implemented yet:
         // Warn if some mandatory value is empty
         if (empty($value) && preg_match('/_mandatory$/', $type)) {
             \Message::warning(sprintf($_CORELANG['TXT_CORE_SETTING_WARNING_EMPTY'], $_ARRAYLANG[$prefix . strtoupper($name)], $name));
         }
         // Warn if some language variable is not defined
         if (empty($_ARRAYLANG[$prefix . strtoupper($name)])) {
             \Message::warning(sprintf($_CORELANG['TXT_CORE_SETTING_WARNING_MISSING_LANGUAGE'], $prefix . strtoupper($name), $name));
         }
         //DBG::log("Value: $value -> align $value_align");
         $isMultiSelect = false;
         switch ($type) {
             //Multiselect dropdown/Dropdown menu
             case self::TYPE_DROPDOWN_MULTISELECT:
                 $isMultiSelect = true;
             case self::TYPE_DROPDOWN:
                 $matches = null;
                 $arrValues = $arrSetting['values'];
                 if (preg_match('/^\\{src:([a-z0-9_\\\\:]+)\\(\\)\\}$/i', $arrSetting['values'], $matches)) {
                     $arrValues = call_user_func($matches[1]);
                 }
                 if (is_string($arrValues)) {
                     $arrValues = self::splitValues($arrValues);
                 }
                 $elementName = $isMultiSelect ? $name . '[]' : $name;
                 $value = $isMultiSelect ? self::splitValues($value) : $value;
                 $elementValue = is_array($value) ? array_flip($value) : $value;
                 $elementAttr = $isMultiSelect ? ' multiple class="chzn-select"' : '';
                 $element = \Html::getSelect($elementName, $arrValues, $elementValue, '', '', 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;' . (!$isMultiSelect && isset($arrValues[$value]) && is_numeric($arrValues[$value]) ? 'text-align: right;' : '') . '"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : '') . $elementAttr);
                 break;
             case self::TYPE_DROPDOWN_USER_CUSTOM_ATTRIBUTE:
                 $element = \Html::getSelect($name, User_Profile_Attribute::getCustomAttributeNameArray(), $arrSetting['value'], '', '', 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
                 break;
             case self::TYPE_DROPDOWN_USERGROUP:
                 $element = \Html::getSelect($name, UserGroup::getNameArray(), $arrSetting['value'], '', '', 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
                 break;
             case self::TYPE_WYSIWYG:
                 // These must be treated differently, as wysiwyg editors
                 // claim the full width
                 if ($readOnly) {
                     // TODO: this might be dangerous! should be rewritten probably
                     $element = $value;
                 } else {
                     $element = new \Cx\Core\Wysiwyg\Wysiwyg($name, $value);
                 }
                 $objTemplateLocal->setVariable(array('CORE_SETTING_ROW' => $_ARRAYLANG[$prefix . strtoupper($name)], 'CORE_SETTING_ROWCLASS1' => ++$i % 2 ? '1' : '2'));
                 $objTemplateLocal->parseCurrentBlock();
                 $objTemplateLocal->setVariable(array('CORE_SETTING_ROW' => $element . '<br /><br />', 'CORE_SETTING_ROWCLASS1' => ++$i % 2 ? '1' : '2'));
                 $objTemplateLocal->parseCurrentBlock();
                 // Skip the part below, all is done already
                 continue 2;
             case self::TYPE_FILEUPLOAD:
                 //echo("\Cx\Core\Setting\Controller\Setting::show_section(): Setting up upload for $name, $value<br />");
                 $element = \Html::getInputFileupload($name, $value ? $name : false, Filetype::MAXIMUM_UPLOAD_FILE_SIZE, $arrSetting['values'], 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''), true, $value ? $value : 'media/' . (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'other'));
                 // File uploads must be multipart encoded
                 $enctype = 'enctype="multipart/form-data"';
                 break;
             case self::TYPE_BUTTON:
                 // The button is only available to trigger some event.
                 $event = 'onclick=\'' . 'if (confirm("' . $_ARRAYLANG[$prefix . strtoupper($name) . '_CONFIRM'] . '")) {' . 'document.getElementById("' . $name . '").value=1;' . 'document.formSettings_' . self::$tab_index . '.submit();' . '}\'';
                 //DBG::log("\Cx\Core\Setting\Controller\Setting::show_section(): Event: $event");
                 $element = \Html::getInputButton('__' . $name, $_ARRAYLANG[strtoupper($prefix . $name) . '_LABEL'], 'button', false, $event . ($readOnly ? \Html::ATTRIBUTE_DISABLED : '')) . \Html::getHidden($name, 0, '');
                 //DBG::log("\Cx\Core\Setting\Controller\Setting::show_section(): Element: $element");
                 break;
             case self::TYPE_TEXTAREA:
                 $element = \Html::getTextarea($name, $value, 80, 8, $readOnly ? \Html::ATTRIBUTE_DISABLED : '');
                 //                        'style="width: '.self::DEFAULT_INPUT_WIDTH.'px;'.$value_align.'"');
                 break;
             case self::TYPE_CHECKBOX:
                 $arrValues = self::splitValues($arrSetting['values']);
                 $value_true = current($arrValues);
                 $element = \Html::getCheckbox($name, $value_true, false, in_array($value, $arrValues), '', $readOnly ? \Html::ATTRIBUTE_DISABLED : '');
                 break;
             case self::TYPE_CHECKBOXGROUP:
                 $checked = self::splitValues($value);
                 $element = \Html::getCheckboxGroup($name, $values, $values, $checked, '', '', '<br />', $readOnly ? \Html::ATTRIBUTE_DISABLED : '', '');
                 break;
                 // 20120508 UNTESTED!
             // 20120508 UNTESTED!
             case self::TYPE_RADIO:
                 $checked = $value;
                 $element = \Html::getRadioGroup($name, $values, $checked, '', $readOnly ? \Html::ATTRIBUTE_DISABLED : '');
                 break;
             case self::TYPE_PASSWORD:
                 $element = \Html::getInputPassword($name, $value, 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
                 break;
                 //datepicker
             //datepicker
             case self::TYPE_DATE:
                 $element = \Html::getDatepicker($name, array('defaultDate' => $value), 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"');
                 break;
                 //datetimepicker
             //datetimepicker
             case self::TYPE_DATETIME:
                 $element = \Html::getDatetimepicker($name, array('defaultDate' => $value), 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;"');
                 break;
             case self::TYPE_IMAGE:
                 $cx = \Cx\Core\Core\Controller\Cx::instanciate();
                 if (!empty($arrSetting['value']) && \Cx\Lib\FileSystem\FileSystem::exists($cx->getWebsitePath() . '/' . $arrSetting['value'])) {
                     $element .= \Html::getImageByPath($cx->getWebsitePath() . '/' . $arrSetting['value'], 'id="' . $name . 'Image" ') . '&nbsp;&nbsp;';
                 }
                 $element .= \Html::getHidden($name, $arrSetting['value'], $name);
                 $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
                 $mediaBrowser->setCallback($name . 'Callback');
                 $mediaBrowser->setOptions(array('type' => 'button', 'data-cx-mb-views' => 'filebrowser'));
                 $element .= $mediaBrowser->getXHtml($_ARRAYLANG['TXT_BROWSE']);
                 \JS::registerCode('
                     function ' . $name . 'Callback(data) {
                         if (data.type === "file" && data.data[0]) {
                             var filePath = data.data[0].datainfo.filepath;
                             jQuery("#' . $name . '").val(filePath);
                             jQuery("#' . $name . 'Image").attr("src", filePath);
                         }
                     }
                     jQuery(document).ready(function(){
                         var imgSrc = jQuery("#' . $name . 'Image").attr("src");
                         jQuery("#' . $name . 'Image").attr("src", imgSrc + "?t=" + new Date().getTime());
                     });
                 ');
                 break;
                 // Default to text input fields
             // Default to text input fields
             case self::TYPE_TEXT:
             case self::TYPE_EMAIL:
             default:
                 $element = \Html::getInputText($name, $value, false, 'style="width: ' . self::DEFAULT_INPUT_WIDTH . 'px;' . (is_numeric($value) ? 'text-align: right;' : '') . '"' . ($readOnly ? \Html::ATTRIBUTE_DISABLED : ''));
         }
         //add Tooltip
         $toolTips = '';
         $toolTipsHelp = '';
         if (isset($_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP'])) {
             // generate tooltip for configuration option
             $toolTips = '  <span class="icon-info tooltip-trigger"></span><span class="tooltip-message">' . $_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP'] . '</span>';
         }
         if (isset($_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP_HELP'])) {
             // generate tooltip for configuration option
             $toolTipsHelp = '  <span class="icon-info tooltip-trigger"></span><span class="tooltip-message">' . $_ARRAYLANG[$prefix . strtoupper($name) . '_TOOLTIP_HELP'] . '</span>';
         }
         $objTemplateLocal->setVariable(array('CORE_SETTING_NAME' => (isset($_ARRAYLANG[$prefix . strtoupper($name)]) ? $_ARRAYLANG[$prefix . strtoupper($name)] : $name) . $toolTips, 'CORE_SETTING_VALUE' => $element . $toolTipsHelp, 'CORE_SETTING_ROWCLASS2' => ++$i % 2 ? '1' : '2'));
         $objTemplateLocal->parseCurrentBlock();
         //echo("\Cx\Core\Setting\Controller\Setting::show(objTemplateLocal, $prefix): shown $name => $value<br />");
     }
     // Set form encoding to multipart if necessary
     if (!empty($enctype)) {
         $objTemplateLocal->setVariable('CORE_SETTING_ENCTYPE', $enctype);
     }
     if (!empty($section) && $objTemplateLocal->blockExists('core_setting_section')) {
         //echo("\Cx\Core\Setting\Controller\Setting::show(objTemplateLocal, $header, $prefix): creating section $header<br />");
         $objTemplateLocal->setVariable(array('CORE_SETTING_SECTION' => $section));
         //$objTemplateLocal->parse('core_setting_section');
     }
     return true;
 }
Example #7
0
 /**
  * Get the html source code for the wysiwyg editor
  *
  * @return string
  */
 public function getSourceCode()
 {
     $mediaBrowserCkeditor = new MediaBrowser();
     $mediaBrowserCkeditor->setOptions(array('type' => 'button', 'style' => 'display:none'));
     $mediaBrowserCkeditor->setCallback('ckeditor_image_callback');
     $mediaBrowserCkeditor->setOptions(array('id' => 'ckeditor_image_button'));
     \JS::activate('ckeditor');
     \JS::activate('jquery');
     $configPath = ASCMS_PATH_OFFSET . substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT));
     $options = array("customConfig: CKEDITOR.getUrl('" . $configPath . "?langId=" . $this->langId . "')", "width: '" . $this->types[$this->type]['width'] . "'", "height: '" . $this->types[$this->type]['height'] . "'", "toolbar: '" . $this->types[$this->type]['toolbar'] . "'", "fullPage: " . $this->types[$this->type]['fullPage']);
     $extraPlugins = array_merge($this->extraPlugins, $this->types[$this->type]['extraPlugins']);
     if (!empty($extraPlugins)) {
         $options[] = "extraPlugins: '" . implode(',', $extraPlugins) . "'";
     }
     $onReady = "CKEDITOR.replace('" . $this->name . "', { %s });";
     \JS::registerCode('
         $J(function(){
             ' . sprintf($onReady, implode(",\r\n", $options)) . '
         });
     ');
     return $mediaBrowserCkeditor->getXHtml('mediabrowser') . '<textarea name="' . $this->name . '" style="width: 100%; height: ' . $this->types[$this->type]['height'] . 'px">' . $this->value . '</textarea>';
 }
Example #8
0
    public function getCode($tabIndex = null)
    {
        $tabIndexAttr = '';
        if (isset($tabIndex)) {
            $tabIndexAttr = "tabindex=\"{$tabIndex}\"";
        }
        $widget = <<<HTML
<div id="recaptcha_widget" style="display:none">

    <div id="recaptcha_image"></div>
    <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>

    <span class="recaptcha_only_if_image">Enter the words above:</span>
    <span class="recaptcha_only_if_audio">Enter the numbers you hear:</span>

    <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" {$tabIndexAttr} />

    <div>
        <div>
            <a title="Get a new challenge" href="javascript:Recaptcha.reload()" id="recaptcha_reload_btn">
                <img src="http://www.google.com/recaptcha/api/img/clean/refresh.png" id="recaptcha_reload" alt="Get a new challenge" height="18" width="25">
            </a>
        </div>
        <div class="recaptcha_only_if_image">
            <a title="Get an audio challenge" href="javascript:Recaptcha.switch_type('audio');" id="recaptcha_switch_audio_btn" class="recaptcha_only_if_image">
                <img src="http://www.google.com/recaptcha/api/img/clean/audio.png" id="recaptcha_switch_audio" alt="Get an audio challenge" height="15" width="25">
            </a>
        </div>
        <div class="recaptcha_only_if_audio">
            <a title="Get a visual challenge" href="javascript:Recaptcha.switch_type('image');" id="recaptcha_switch_img_btn" class="recaptcha_only_if_audio">
                <img src="http://www.google.com/recaptcha/api/img/clean/text.png" id="recaptcha_switch_img" alt="Get a visual challenge" height="15" width="25">
            </a>
        </div>
        <div>
            <a href="javascript:Recaptcha.showhelp()"title="Help" target="_blank" id="recaptcha_whatsthis_btn">
                <img alt="Help" src="http://www.google.com/recaptcha/api/img/clean/help.png" id="recaptcha_whatsthis" height="16" width="25">
            </a>
        </div>
    </div>

</div>

<script type="text/javascript" src= "http://www.google.com/recaptcha/api/challenge?k=%1\$s"></script>
<noscript>
    <iframe src="http://www.google.com/recaptcha/api/noscript?k=%1\$s" height="300" width="500" frameborder="0"></iframe><br />
    <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
    <input type="hidden" name="recaptcha_response_field" value="manual_challenge">
</noscript>
HTML;
        $lang = \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID);
        //\JS::registerCode("var RecaptchaOptions = { lang : '$lang', theme : 'clean' }");
        \JS::registerCode("var RecaptchaOptions = { lang : '{$lang}', theme : 'custom', custom_theme_widget: 'recaptcha_widget' }");
        //\JS::registerCSS("lib/reCAPTCHA/recaptcha.widget.clean.css");
        $code = sprintf($widget, $this->public_key);
        //$code = recaptcha_get_html($this->public_key, $this->error);
        return $code;
    }
Example #9
0
 /**
  * Returns the HTML for the frontend language selection dropdown menu
  *
  * Backend use only.
  * @internal    Note to Shop (and other newish module) programmers:
  *  Registers javascript for handling the currently active tab.
  *  Set the _active_tab global index variable in your onchange handler
  *  whenever the user switches the tab.  This value is posted in the
  *  active_tab parameter when the language is changed.
  *  See {@see getJavascript_activetab()} for details, and
  *  {@see \Cx\Core\Setting\Controller\Setting::show()} and {@see \Cx\Core\Setting\Controller\Setting::show_external()}
  *  for implementations.
  * @return  string            The HTML language dropdown menu code
  */
 function getUserFrontendLangMenu()
 {
     global $_ARRAYLANG;
     $arrLanguageName = FWLanguage::getNameArray();
     // No dropdown at all if there is a single active frontend language
     if (count($arrLanguageName) == 1) {
         return '';
     }
     $action = CONTREXX_DIRECTORY_INDEX;
     $command = isset($_REQUEST['cmd']) ? contrexx_input2raw($_REQUEST['cmd']) : '';
     switch ($command) {
         /*case 'xyzzy':
           // Variant 1:  Use selected GET parameters only
           // Currently unused, but this could be extended by a few required
           // parameters and might prove useful for some modules.
           $query_string = '';
           // Add more as needed
           $arrParameter = array('cmd', 'act', 'tpl', 'key', );
           foreach ($arrParameter as $parameter) {
               $value = (isset($_GET[$parameter])
                 ? $_GET[$parameter] : null);
               if (isset($value)) {
                   $query_string .= "&$parameter=".contrexx_input2raw($value);
               }
           }
           Html::replaceUriParameter($action, $query_string);
           // The dropdown is built below
           break;*/
         case 'Shop':
         case 'country':
             // Variant 2:  Use any (GET) request parameters
             // Note that this is generally unsafe, as most modules/methods do
             // not rely on posted data only!
             $arrParameter = null;
             $uri = $_SERVER['QUERY_STRING'];
             Html::stripUriParam($uri, 'userFrontendLangId');
             parse_str($uri, $arrParameter);
             $first = true;
             foreach ($arrParameter as $name => $value) {
                 $action .= ($first ? '?' : '&amp;') . $name . '=' . urlencode(contrexx_input2raw($value));
                 $first = false;
             }
             // The dropdown is built below
             break;
             // TODO: Add your case here if variant 1 is enabled, too
             //case 'foobar':
         // TODO: Add your case here if variant 1 is enabled, too
         //case 'foobar':
         case 'DocSys':
         case 'Recommend':
         case 'Jobs':
         case 'alias':
             // The old way
             $i = 0;
             $arrVars = array();
             if (isset($_SERVER['QUERY_STRING'])) {
                 parse_str($_SERVER['QUERY_STRING'], $arrVars);
             }
             $query = isset($arrVars['cmd']) ? "?cmd=" . $arrVars['cmd'] : "";
             $return = "\n<form action='index.php" . $query . "' method='post' name='userFrontendLangIdForm'>\n";
             $return .= "<select name='userFrontendLangId' size='1' class='chzn-select' onchange=\"document.forms['userFrontendLangIdForm'].submit()\">\n";
             foreach ($this->arrLang as $id => $value) {
                 if ($this->arrLang[$id]['frontend'] == 1) {
                     $i++;
                     if ($id == $this->userFrontendLangId) {
                         $return .= "<option value='" . $id . "' selected='selected'>Frontend [" . htmlentities($value['name'], ENT_QUOTES, CONTREXX_CHARSET) . "]</option>\n";
                     } else {
                         $return .= "<option value='" . $id . "'>Frontend [" . htmlentities($value['name'], ENT_QUOTES, CONTREXX_CHARSET) . "]</option>\n";
                     }
                 }
             }
             $return .= "</select>\n</form>\n";
             return $i > 1 ? $return : "";
         default:
             return '';
             break;
     }
     // For those views that support it, update the selected tab index
     JS::registerCode('function submitUserFrontendLanguage() {' . ' $J("[name=active_tab]").val(_active_tab);' . ' document.forms.userFrontendLangIdForm.submit(); ' . '}');
     // For variants 1 and 2:  Build the dropdown
     return "\n" . '<form id="userFrontendLangIdForm" name="userFrontendLangIdForm"' . ' action="' . $action . '"' . ' method="post">' . "\n" . Html::getHidden_activetab() . "\n" . Html::getSelectCustom('userFrontendLangId', FWLanguage::getMenuoptions($this->userFrontendLangId), false, 'submitUserFrontendLanguage();', 'size="1" class="chzn-select"') . "\n</form>\n";
 }
    /**
     * Creates and returns the HTML Form for requesting the payment service.
     *
     * @access  public     
     * @return  string                      The HTML form code
     */
    static function getForm($arrOrder, $landingPage = null)
    {
        global $_ARRAYLANG;
        if (gettype($landingPage) != 'object' || get_class($landingPage) != 'Cx\\Core\\ContentManager\\Model\\Entity\\Page') {
            self::$arrError[] = 'No landing page passed.';
        }
        if (($sectionName = $landingPage->getModule()) && !empty($sectionName)) {
            self::$sectionName = $sectionName;
        } else {
            self::$arrError[] = 'Passed landing page is not an application.';
        }
        JS::registerCSS('modules/shop/payments/paymill/css/paymill_styles.css');
        JS::registerJS('modules/shop/payments/paymill/js/creditcardBrandDetection.js');
        JS::registerJS(self::$paymillJsBridge);
        $testMode = intval(\Cx\Core\Setting\Controller\Setting::getValue('paymill_use_test_account', 'Shop')) == 0;
        $apiKey = $testMode ? \Cx\Core\Setting\Controller\Setting::getValue('paymill_test_public_key', 'Shop') : \Cx\Core\Setting\Controller\Setting::getValue('paymill_live_public_key', 'Shop');
        $mode = $testMode ? 'true' : 'false';
        $code = <<<APISETTING
                var PAYMILL_PUBLIC_KEY = '{$apiKey}';
                var PAYMILL_TEST_MODE  = {$mode};
                var VALIDATE_CVC       = true;
APISETTING;
        JS::registerCode($code);
        JS::registerCode(self::$formScript);
        \ContrexxJavascript::getInstance()->setVariable(array('invalid-card-holdername' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_HOLDER'], 'invalid-card-cvc' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_CVC'], 'invalid-card-number' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_NUMBER'], 'invalid-card-expiry-date' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_EXPIRY_DATE']), 'shop');
        $formContent = self::getElement('div', 'class="paymill-error-text"');
        $formContent .= self::fieldset('');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_CREDIT_CARD_NUMBER']);
        $formContent .= Html::getInputText('', '', '', 'class="card-number" size="20"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::openElement('label');
        $formContent .= $_ARRAYLANG['TXT_SHOP_CVC'] . '&nbsp;';
        $formContent .= self::getElement('span', 'class="tooltip-trigger icon-info"');
        $formContent .= self::getElement('span', 'class="tooltip-message"', $_ARRAYLANG['TXT_SHOP_CVC_TOOLTIP']);
        $formContent .= self::closeElement('label');
        $formContent .= Html::getInputText('', '', '', 'class ="card-cvc" size="4" maxlength="4"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_CARD_HOLDER']);
        $formContent .= Html::getInputText('', '', '', 'class="card-holdername" size="20"');
        $formContent .= self::closeElement('div');
        $arrMonths = array();
        for ($i = 1; $i <= 12; $i++) {
            $month = str_pad($i, 2, '0', STR_PAD_LEFT);
            $arrMonths[$month] = $month;
        }
        $arrYears = array();
        $currentYear = date('Y');
        for ($i = $currentYear; $i <= $currentYear + 6; $i++) {
            $arrYears[$i] = $i;
        }
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_CARD_EXPIRY']);
        $formContent .= Html::getSelect('card-expiry-month', $arrMonths, '', false, '', 'class="card-expiry-month"');
        $formContent .= Html::getSelect('card-expiry-year', $arrYears, '', false, '', 'class="card-expiry-year"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', '&nbsp;');
        $formContent .= Html::getInputButton('', $_ARRAYLANG['TXT_SHOP_BUY_NOW'], 'submit', '', 'class="submit-button"');
        $formContent .= self::closeElement('div');
        $formContent .= Html::getHidden('handler', 'paymill_cc');
        $formContent .= self::closeElement('fieldset');
        $form = Html::getForm('', Cx\Core\Routing\Url::fromPage($landingPage)->toString(), $formContent, 'card-tds-form', 'post');
        return $form;
    }
Example #11
0
    /**
     * Builds a raty element
     *
     * This element lets you display a customizable star rating.
     * Uses and activates jQuery.
     * The selector will be passed to jQuery to select the element(s) to
     * which the rating is applied (some <div> or similar will do, but that
     * element must exist).
     * The options array may contain any keys that are valid raty
     * options, and their respective values.
     * See {@see http://plugins.jquery.com/project/raty} for details.
     * As of writing this (20110228), valid options and their respective
     * defaults are:
     *  cancelHint:   'cancel this rating!'
     *  cancelOff:    'cancel-off.png'
     *  cancelOn:     'cancel-on.png'
     *  cancelPlace:  'left'
     *  click:        null
     *  half:         false
     *  hintList:     ['bad', 'poor', 'regular', 'good', 'gorgeous']
     *  iconRange:    []
     *  noRatedMsg:   'not rated yet'
     *  number:       5
     *  path:         'img/'
     *  readOnly:     false
     *  scoreName:    'score'
     *  showCancel:   false
     *  starHalf:     'star-half.png'
     *  starOff:      'star-off.png'
     *  starOn:       'star-on.png'
     *  start:        0
     * Note that you *MUST* specify boolean option values as true or false,
     * *NOT* as string literals "true" or "false".  The latter will not work.
     * @link    http://plugins.jquery.com/project/raty
     * @param   string    $selector   The element selector
     * @param   array     $options    The optional raty options
     * @return  boolean               True on success, false otherwise
     */
    static function makeRating($selector, $options = null)
    {
        // TODO: This loop is always the same for all jQuery stuff; create a method
        $strOptions = '';
        foreach ($options as $option => $value) {
            //DBG::log("Html::makeRating(): Option $option => value $value");
            $strOptions .= "\n    " . $option . ': ' . (is_numeric($value) ? $value : (is_bool($value) ? $value ? 'true' : 'false' : (preg_match('/^[\\[\\{].*[\\]\\{]$/', $value) || preg_match('/^\\(?function/', $value) ? $value : '"' . $value . '"'))) . ",";
        }
        //DBG::log("Html::makeRating($selector, [options]): Options: $strOptions");
        JS::activate('raty');
        JS::registerCode('
cx.jQuery(document).ready(function($) {
  $("' . $selector . '").raty({' . $strOptions . "\n  });\n});");
        return true;
    }
Example #12
0
 /**
  * Load the html code template of the different attribute types
  *
  * @global array
  */
 private function loadAttributeTypeTemplates()
 {
     global $_CORELANG;
     \JS::activate('jqueryui');
     \JS::registerCode("\n            cx.ready(function() {\n                cx.jQuery('.access_date').datepicker({dateFormat: 'dd.mm.yy'});\n            });\n        ");
     $this->arrAttributeTypeTemplates = array('textarea' => '<textarea name="[NAME]" rows="1" cols="1">[VALUE]</textarea>', 'text' => '<input type="text" name="[NAME]" value="[VALUE]" />', 'password' => '<input type="password" name="[NAME]" value="" autocomplete="off" />', 'checkbox' => '<input type="hidden" name="[NAME]" /><input type="checkbox" name="[NAME]" value="1" [CHECKED] />', 'menu' => '<select name="[NAME]"[STYLE]>[VALUE]</select>', 'menu_option' => '<option value="[VALUE]"[SELECTED][STYLE]>[VALUE_TXT]</option>', 'url' => '<input type="hidden" name="[NAME]" value="[VALUE]" /><em>[VALUE_TXT]</em> <a href="javascript:void(0);" onclick="elLink=null;elDiv=null;elInput=null;pntEl=this.previousSibling;while ((typeof(elInput)==\'undefined\'||typeof(elDiv)!=\'undefined\')&& pntEl!=null) {switch(pntEl.nodeName) {case\'INPUT\':elInput=pntEl;break;case\'EM\':elDiv=pntEl;if (elDiv.getElementsByTagName(\'a\').length>0) {elLink=elDiv.getElementsByTagName(\'a\')[0];}break;}pntEl=pntEl.previousSibling;}accessSetWebsite(elInput,elDiv,elLink)" title="' . $_CORELANG['TXT_ACCESS_CHANGE_WEBSITE'] . '"><img align="middle" src="' . ASCMS_CORE_MODULE_WEB_PATH . '/Access/View/Media/edit.gif" width="16" height="16" border="0" alt="' . $_CORELANG['TXT_ACCESS_CHANGE_WEBSITE'] . '" /></a>', 'date' => '<input type="text" name="[NAME]" class="access_date" value="[VALUE]" />');
 }
Example #13
0
    /**
     * Gets the themes pages file content
     * @access   public
     * @param    string   $filePath
     * @param    string   $relativeFilePath
     * 
     * @return   string   $fileContent
     */
    function getFilesContent($filePath, $relativeFilePath)
    {
        global $objTemplate, $_ARRAYLANG;
        if (file_exists($filePath)) {
            $objImageManager = new \ImageManager();
            $fileIsImage = $objImageManager->_isImage($filePath);
            $contenthtml = '';
            if (!$fileIsImage) {
                $contenthtml = file_get_contents($filePath);
                $contenthtml = preg_replace('/\\{([A-Z0-9_]*?)\\}/', '[[\\1]]', $contenthtml);
                $contenthtml = htmlspecialchars($contenthtml);
            }
            $objTemplate->setVariable(array('CONTENT_HTML' => $contenthtml));
            if ($fileIsImage) {
                $objTemplate->setVariable(array('THEMES_CONTENT_IMAGE_PATH' => $relativeFilePath));
                $objTemplate->touchBlock('template_image');
                $objTemplate->hideBlock('template_content');
                $objTemplate->hideBlock('file_actions_bottom');
                $objTemplate->hideBlock('file_editor_fullscreen');
            } else {
                \JS::activate('ace');
                $pathInfo = pathinfo($filePath, PATHINFO_EXTENSION);
                $mode = 'html';
                switch ($pathInfo) {
                    case 'html':
                    case 'css':
                        $mode = $pathInfo;
                        break;
                    case 'js':
                        $mode = 'javascript';
                        break;
                    case 'yml':
                    case 'yaml':
                        $mode = 'yaml';
                        break;
                }
                $jsCode = <<<CODE
var editor;                        
\$J(function(){         
if (\$J("#editor").length) {
    editor = ace.edit("editor");
    editor.getSession().setMode("ace/mode/{$mode}");
    editor.setShowPrintMargin(false);
    editor.commands.addCommand({
            name: "fullscreen",
            bindKey: "F11",
            exec: function(editor) {
                    if (\$J('body').hasClass('fullScreen')) {
                        \$J('body').removeClass('fullScreen');
                        \$J(editor.container).removeClass('fullScreen-editor');
                        cx.tools.StatusMessage.removeAllDialogs();
                    } else {
                        \$J('body').addClass('fullScreen');
                        \$J(editor.container).addClass('fullScreen-editor');
                        cx.tools.StatusMessage.showMessage(
                            "<div style='text-align: center;'><span style='cursor: pointer;' onClick=\\"editor.execCommand('fullscreen');\\">{$_ARRAYLANG['TXT_THEME_EXIT_FULLSCREEN']}</span></div>",
                            null,
                            null,
                            null,
                            {closeOnEscape: false}
                        );
                    }
                    editor.resize();
                    editor.focus();
            }
    });
    editor.focus();
    editor.gotoLine(1);

    \$J('.fullscreen').click(function(){
        editor.execCommand('fullscreen');
    });
}

\$J('#theme_content').submit(function(){
    \$J('#editorContent').val(editor.getSession().getValue());
});

\$J('.select_all').click(function() {
    editor.selectAll();
});

\$J('input:reset').click(function() {
    editor.setValue(\$J('#editorContent').val(), -1);
});

});
CODE;
                \JS::registerCode($jsCode);
                $objTemplate->touchBlock('file_editor_fullscreen');
                $objTemplate->touchBlock('file_actions_bottom');
                $objTemplate->touchBlock('template_content');
                $objTemplate->hideBlock('template_image');
            }
        } else {
            //TO-DO :
        }
    }
 /**
  * Show the selected mail template for editing
  *
  * Stores the MailTemplate if the 'bsubmit' parameter has been posted.
  * If the $key argument is empty, tries to pick the value from
  * $_REQUEST['key'].
  * @param   mixed     $section      The section of the mail template
  *                                  to be edited
  * @param   string    $key          The optional key of the mail template
  *                                  to be edited
  * @param   string    $act          The action of the mail template
  * @return  \Cx\Core\Html\Sigma     The template object
  */
 static function edit($section, $key = '', $useDefaultActs = true, $act = 'mailtemplate_overview')
 {
     global $_CORELANG;
     // If the $key parameter is empty, check the request
     if (empty($key) && isset($_REQUEST['key'])) {
         $key = $_REQUEST['key'];
     }
     // Try to load an existing template for any non-empty key
     $arrTemplate = null;
     if ($key != '') {
         $arrTemplate = self::get($section, $key, FRONTEND_LANG_ID);
     }
     // If there is none, get an empty template
     $new = false;
     if (!$arrTemplate) {
         $new = true;
         $arrTemplate = self::getEmpty($key);
     }
     // Copy the template?
     if (isset($_REQUEST['copy'])) {
         $arrTemplate['key'] = '';
         $new = true;
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $objTemplate = new \Cx\Core\Html\Sigma($cx->getCodeBaseCorePath() . '/MailTemplate/View/Template/Generic');
     $objTemplate->setErrorHandling(PEAR_ERROR_DIE);
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($objTemplate);
     if (!$objTemplate->loadTemplateFile('Edit.html')) {
         die("Failed to load template Edit.html");
     }
     $uri = \Html::getRelativeUri_entities();
     \Html::stripUriParam($uri, 'key');
     $uriAppendix = '';
     if ($useDefaultActs) {
         \Html::stripUriParam($uri, 'act');
         $uriAppendix = '&amp;act=' . $act;
     }
     $tab_index = \Cx\Core\Setting\Controller\Setting::tab_index();
     \Html::replaceUriParameter($uri, 'active_tab=' . $tab_index);
     \Html::replaceUriParameter($uri, 'userFrontendLangId=' . FRONTEND_LANG_ID);
     $objTemplate->setGlobalVariable($_CORELANG + array('CORE_MAILTEMPLATE_EDIT_TITLE' => $new ? $_CORELANG['TXT_CORE_MAILTEMPLATE_ADD'] : $_CORELANG['TXT_CORE_MAILTEMPLATE_EDIT'], 'CORE_MAILTEMPLATE_CMD' => isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : '', 'CORE_MAILTEMPLATE_ACTIVE_TAB' => $tab_index, 'URI_BASE' => $uri . $uriAppendix));
     $i = 0;
     foreach ($arrTemplate as $name => $value) {
         // See if there is a posted parameter value
         if (isset($_POST[$name])) {
             $value = $_POST[$name];
         }
         // IDs are set up as hidden fields.
         // They *MUST NOT* be edited!
         if (preg_match('/(?:_id)$/', $name)) {
             // For copies, IDs *MUST NOT* be reused!
             if (isset($_REQUEST['copy'])) {
                 $value = 0;
             }
             $objTemplate->setVariable('MAILTEMPLATE_HIDDEN', \Html::getHidden($name, $value));
             $objTemplate->parse('core_mailtemplate_hidden');
             continue;
         }
         // Regular inputs of various kinds
         $input = '';
         $attribute = '';
         //            $arrMimetype = '';
         switch ($name) {
             case 'available':
                 continue 2;
                 /*
                  TODO: WARNING: FCKEditor v2.x f***s up the blocks in the mail template!
                  Use plain text areas instead.  See below.
                 */
             /*
              TODO: WARNING: FCKEditor v2.x f***s up the blocks in the mail template!
              Use plain text areas instead.  See below.
             */
             case 'message_html':
                 // Show WYSIWYG only if HTML is enabled
                 if (empty($arrTemplate['html'])) {
                     continue 2;
                 }
                 $objTemplate->setVariable(array('MAILTEMPLATE_ROWCLASS' => ++$i % 2 + 1, 'MAILTEMPLATE_SPECIAL' => $_CORELANG['TXT_CORE_MAILTEMPLATE_' . strtoupper($name)]));
                 $objTemplate->touchBlock('core_mailtemplate_special');
                 $objTemplate->parse('core_mailtemplate_special');
                 $objTemplate->setVariable(array('MAILTEMPLATE_ROWCLASS' => ++$i % 2 + 1, 'MAILTEMPLATE_SPECIAL' => new \Cx\Core\Wysiwyg\Wysiwyg($name, $value, 'fullpage')));
                 $objTemplate->touchBlock('core_mailtemplate_special');
                 $objTemplate->parse('core_mailtemplate_special');
                 continue 2;
                 //$objTemplate->replaceBlock('core_mailtemplate_special', '', true);
                 //              case 'message_html':
             //$objTemplate->replaceBlock('core_mailtemplate_special', '', true);
             //              case 'message_html':
             case 'message':
                 $input = \Html::getTextarea($name, $value, '', 10, 'style="width: 600px;"');
                 break;
             case 'protected':
                 $input = \Html::getCheckbox($name, 1, '', $value, '', \Html::ATTRIBUTE_DISABLED);
                 break;
             case 'attach_pdf':
                 \JS::registerCode('
                     jQuery(document).ready(function() {
                         showOrHidePdfTpl();
                     });
                     function showOrHidePdfTpl() {
                         var that = jQuery("select[name=pdf_template]")
                             .closest("tr");
                         that.hide();
                         if (jQuery("input[name=attach_pdf]").is(":checked")) {
                             that.show();
                         }
                     }
                 ');
                 $input = \Html::getCheckbox($name, 1, '', $value, 'showOrHidePdfTpl();', $attribute);
                 break;
             case 'pdf_template':
                 $arrOptions = $cx->getComponent('Pdf')->getPdfTemplates();
                 $input = \Html::getSelect($name, $arrOptions, $value, false, '', 'style="width:300px;"');
                 break;
             case 'html':
                 $input = \Html::getCheckbox($name, 1, '', $value, '', $attribute) . '&nbsp;' . $_CORELANG['TXT_CORE_MAILTEMPLATE_STORE_TO_SWITCH_EDITOR'];
                 break;
             case 'inline':
             case 'attachments':
                 continue 2;
                 // TODO: These do not work properly yet
                 /*
                  // These are identical except for the MIME types
                  case 'inline':
                  $arrMimetype = \Filetype::getImageMimetypes();
                  case 'attachments':
                  $arrAttachments = self::attachmentsToArray($arrTemplate[$name]);
                  // Show at least one empty attachment/inline row
                  if (empty($arrAttachments))
                  $arrAttachments = array(array('path' => '', ), );
                  $i = 0;
                  foreach ($arrAttachments as $arrAttachment) {
                  $div_id = $name.'-'.(++$i);
                  $element_name = $name.'['.$i.']';
                  $input .=
                  '<div id="'.$div_id.'">'.
                  \Html::getHidden(
                  $element_name.'[old]', $arrAttachment['path'],
                  $name.'-hidden-'.$i).
                  $arrAttachment['path'].'&nbsp;'.
                  $_CORELANG['TXT_CORE_MAILTEMPLATE_ATTACHMENT_UPLOAD'].
                  \Html::getInputFileupload(
                  $element_name.'[new]', $name.'-file-'.$i,
                  \Filetype::MAXIMUM_UPLOAD_FILE_SIZE,
                  $arrMimetype).
                  // Links for adding/removing inputs
                  \Html::getRemoveAddLinks($div_id).
                  '</div>';
                  }
                  //echo("$name => ".htmlentities($input)."<hr />");
                  break;
                 */
                 // Once the key is defined, it cannot be changed.
                 // To fix a wrong key, copy the old template and enter a new key,
                 // then delete the old one.
             // TODO: These do not work properly yet
             /*
              // These are identical except for the MIME types
              case 'inline':
              $arrMimetype = \Filetype::getImageMimetypes();
              case 'attachments':
              $arrAttachments = self::attachmentsToArray($arrTemplate[$name]);
              // Show at least one empty attachment/inline row
              if (empty($arrAttachments))
              $arrAttachments = array(array('path' => '', ), );
              $i = 0;
              foreach ($arrAttachments as $arrAttachment) {
              $div_id = $name.'-'.(++$i);
              $element_name = $name.'['.$i.']';
              $input .=
              '<div id="'.$div_id.'">'.
              \Html::getHidden(
              $element_name.'[old]', $arrAttachment['path'],
              $name.'-hidden-'.$i).
              $arrAttachment['path'].'&nbsp;'.
              $_CORELANG['TXT_CORE_MAILTEMPLATE_ATTACHMENT_UPLOAD'].
              \Html::getInputFileupload(
              $element_name.'[new]', $name.'-file-'.$i,
              \Filetype::MAXIMUM_UPLOAD_FILE_SIZE,
              $arrMimetype).
              // Links for adding/removing inputs
              \Html::getRemoveAddLinks($div_id).
              '</div>';
              }
              //echo("$name => ".htmlentities($input)."<hr />");
              break;
             */
             // Once the key is defined, it cannot be changed.
             // To fix a wrong key, copy the old template and enter a new key,
             // then delete the old one.
             case 'key':
                 $input = $arrTemplate['key'] ? $value . \Html::getHidden($name, $value) : \Html::getInputText($name, $value, '', 'style="width: 300px;"');
                 //echo("Key /$key/ -> attr $attribute<br />");
                 break;
             default:
                 $input = \Html::getInputText($name, $value, '', 'style="width: 300px;"');
         }
         $name_upper = strtoupper($name);
         $objTemplate->setVariable(array('MAILTEMPLATE_ROWCLASS' => ++$i % 2 + 1, 'MAILTEMPLATE_NAME' => $_CORELANG['TXT_CORE_MAILTEMPLATE_' . $name_upper], 'MAILTEMPLATE_VALUE' => $input));
         // Add note with helpful hints, if available
         if (isset($_CORELANG['TXT_CORE_MAILTEMPLATE_NOTE_' . $name_upper])) {
             $objTemplate->setVariable('MAILTEMPLATE_VALUE_NOTE', $_CORELANG['TXT_CORE_MAILTEMPLATE_NOTE_' . $name_upper]);
         }
         $objTemplate->parse('core_mailtemplate_row');
     }
     // Send the (possibly edited and now stored) mail, if requested
     if (empty($_POST['to_test'])) {
         return $objTemplate;
     }
     if (empty($key)) {
         \Message::error($_CORELANG['TXT_CORE_MAILTEMPLATE_ERROR_NO_KEY']);
         return $objTemplate;
     }
     $to_test = contrexx_input2raw($_POST['to_test']);
     $objTemplate->setVariable('CORE_MAILTEMPLATE_TO_TEST', $to_test);
     self::sendTestMail($section, $key, $to_test);
     return $objTemplate;
 }
    function JSedituser()
    {
        global $_ARRAYLANG;
        \JS::registerCode('
function DeleteUser(UserID, email) {
  strConfirmMsg = "' . $_ARRAYLANG['TXT_NEWSLETTER_CONFIRM_DELETE_RECIPIENT_OF_ADDRESS'] . '";
  if (confirm(strConfirmMsg.replace("%s", email)+"\\n' . $_ARRAYLANG['TXT_NEWSLETTER_CANNOT_UNDO_OPERATION'] . '")) {
    document.location.href = "index.php?cmd=Newsletter&' . \Cx\Core\Csrf\Controller\Csrf::param() . '&act=users&delete=1&id="+UserID;
  }
}

function MultiAction() {
  with (document.userlist) {
    switch (userlist_MultiAction.value) {
      case "delete":
        if (confirm(\'' . $_ARRAYLANG['TXT_NEWSLETTER_CONFIRM_DELETE_SELECTED_RECIPIENTS'] . '\\n' . $_ARRAYLANG['TXT_NEWSLETTER_CANNOT_UNDO_OPERATION'] . '\')) {
          submit();
        }
        break;
    }
  }
}
');
    }
Example #16
0
    private function showSubmitForm($data, $display)
    {
        global $_ARRAYLANG, $_CORELANG;
        if (!$display) {
            if ($this->_objTpl->blockExists('news_submit_form')) {
                $this->_objTpl->hideBlock('news_submit_form');
            }
            return;
        }
        $newsTagId = 'newsTags';
        if (!empty($this->arrSettings['news_use_tags'])) {
            \JS::registerJS('lib/javascript/tag-it/js/tag-it.min.js');
            \JS::registerCss('lib/javascript/tag-it/css/tag-it.css');
            $this->registerTagJsCode();
            if ($this->_objTpl->blockExists('newsTags') && !empty($data['newsTags'])) {
                foreach ($data['newsTags'] as $newsTag) {
                    $this->_objTpl->setVariable(array('NEWS_TAGS' => contrexx_raw2xhtml($newsTag)));
                    $this->_objTpl->parse('newsTags');
                }
            }
            $this->_objTpl->touchBlock('newsTagsBlock');
        } else {
            $this->_objTpl->hideBlock('newsTagsBlock');
        }
        \JS::activate('chosen');
        $jsCodeCategoryChosen = <<<EOF
\$J(document).ready(function() {
                \$J('#newsCat').chosen();
});
EOF;
        \JS::registerCode($jsCodeCategoryChosen);
        if (!empty($this->arrSettings['use_related_news'])) {
            $objCx = \ContrexxJavascript::getInstance();
            $objCx->setVariable(array('noResultsMsg' => $_ARRAYLANG['TXT_NEWS_NOT_FOUND'], 'langId' => FRONTEND_LANG_ID), 'news/news-live-search');
            \JS::registerJS('core_modules/News/View/Script/news-live-search.js');
            if (!empty($data['relatedNews'])) {
                $this->parseRelatedNewsTags($this->_objTpl, $data['relatedNews'], FRONTEND_LANG_ID);
            }
            $this->_objTpl->touchBlock('relatedNewsBlock');
        } else {
            $this->_objTpl->hideBlock('relatedNewsBlock');
        }
        $this->_objTpl->setVariable(array('TXT_NEWS_MESSAGE' => $_ARRAYLANG['TXT_NEWS_MESSAGE'], 'TXT_TITLE' => $_ARRAYLANG['TXT_TITLE'], 'TXT_CATEGORY' => $_ARRAYLANG['TXT_CATEGORY'], 'TXT_TYPE' => $this->arrSettings['news_use_types'] == 1 ? $_ARRAYLANG['TXT_TYPE'] : '', 'TXT_HYPERLINKS' => $_ARRAYLANG['TXT_HYPERLINKS'], 'TXT_EXTERNAL_SOURCE' => $_ARRAYLANG['TXT_EXTERNAL_SOURCE'], 'TXT_LINK' => $_ARRAYLANG['TXT_LINK'], 'TXT_NEWS_REDIRECT_LABEL' => $_ARRAYLANG['TXT_NEWS_REDIRECT_LABEL'], 'TXT_NEWS_NEWS_CONTENT' => $_ARRAYLANG['TXT_NEWS_NEWS_CONTENT'], 'TXT_NEWS_TEASER_TEXT' => $_ARRAYLANG['TXT_NEWS_TEASER_TEXT'], 'TXT_SUBMIT_NEWS' => $_ARRAYLANG['TXT_SUBMIT_NEWS'], 'TXT_NEWS_REDIRECT' => $_ARRAYLANG['TXT_NEWS_REDIRECT'], 'TXT_NEWS_NEWS_URL' => $_ARRAYLANG['TXT_NEWS_NEWS_URL'], 'TXT_TYPE' => $_ARRAYLANG['TXT_TYPE'], 'TXT_NEWS_INCLUDE_NEWS' => $_ARRAYLANG['TXT_NEWS_INCLUDE_NEWS'], 'TXT_NEWS_INCLUDE_RELATED_NEWS_DESC' => $_ARRAYLANG['TXT_NEWS_INCLUDE_RELATED_NEWS_DESC'], 'TXT_NEWS_SEARCH_INFO' => $_ARRAYLANG['TXT_NEWS_SEARCH_INFO'], 'TXT_NEWS_SEARCH_PLACEHOLDER' => $_ARRAYLANG['TXT_NEWS_SEARCH_PLACEHOLDER'], 'TXT_NEWS_TAGS' => $_ARRAYLANG['TXT_NEWS_TAGS'], 'NEWS_TEXT' => new \Cx\Core\Wysiwyg\Wysiwyg('newsText', $data['newsText'], 'bbcode'), 'NEWS_CAT_MENU' => $this->getCategoryMenu($this->nestedSetRootId, array($data['newsCat'])), 'NEWS_TYPE_MENU' => $this->arrSettings['news_use_types'] == 1 ? $this->getTypeMenu($data['newsType']) : '', 'NEWS_TITLE' => contrexx_raw2xhtml($data['newsTitle']), 'NEWS_SOURCE' => contrexx_raw2xhtml($data['newsSource']), 'NEWS_URL1' => contrexx_raw2xhtml($data['newsUrl1']), 'NEWS_URL2' => contrexx_raw2xhtml($data['newsUrl2']), 'NEWS_TEASER_TEXT' => contrexx_raw2xhtml($data['newsTeaserText']), 'NEWS_REDIRECT' => contrexx_raw2xhtml($data['newsRedirect']), 'NEWS_TAG_ID' => $newsTagId));
        if ($this->arrSettings['news_use_teaser_text'] != '1' && $this->_objTpl->blockExists('news_use_teaser_text')) {
            $this->_objTpl->hideBlock('news_use_teaser_text');
        }
        if (\FWUser::getFWUserObject()->objUser->login()) {
            if ($this->_objTpl->blockExists('news_submit_form_captcha')) {
                $this->_objTpl->hideBlock('news_submit_form_captcha');
            }
        } else {
            $this->_objTpl->setVariable(array('TXT_NEWS_CAPTCHA' => $_CORELANG['TXT_CORE_CAPTCHA'], 'NEWS_CAPTCHA_CODE' => \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode()));
            if ($this->_objTpl->blockExists('news_submit_form_captcha')) {
                $this->_objTpl->parse('news_submit_form_captcha');
            }
        }
        $this->parseCategoryMenu();
        $this->parseNewsTypeMenu();
        if ($this->_objTpl->blockExists('news_submit_form')) {
            $this->_objTpl->parse('news_submit_form');
        }
    }
    /**
     * Creates and returns the HTML Form for requesting the payment service.
     *
     * @access  public     
     * @return  string                      The HTML form code
     */
    static function getForm($arrOrder, $landingPage = null)
    {
        global $_ARRAYLANG;
        if (gettype($landingPage) != 'object' || get_class($landingPage) != 'Cx\\Core\\ContentManager\\Model\\Entity\\Page') {
            self::$arrError[] = 'No landing page passed.';
        }
        if (($sectionName = $landingPage->getModule()) && !empty($sectionName)) {
            self::$sectionName = $sectionName;
        } else {
            self::$arrError[] = 'Passed landing page is not an application.';
        }
        JS::registerJS(self::$paymillJsBridge);
        \ContrexxJavascript::getInstance()->setVariable(array('invalid-card-holder' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVAILD_CARD_HOLDER'], 'invalid-account-number' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVALID_ACC_NUMBER'], 'invalid-bank-code' => $_ARRAYLANG['TXT_SHOP_PAYMILL_INVALID_BANK_CODE']), 'shop');
        $testMode = intval(\Cx\Core\Setting\Controller\Setting::getValue('paymill_use_test_account', 'Shop')) == 0;
        $apiKey = $testMode ? \Cx\Core\Setting\Controller\Setting::getValue('paymill_test_public_key', 'Shop') : \Cx\Core\Setting\Controller\Setting::getValue('paymill_live_public_key', 'Shop');
        $mode = $testMode ? 'true' : 'false';
        $code = <<<APISETTING
                var PAYMILL_PUBLIC_KEY = '{$apiKey}';
                var PAYMILL_TEST_MODE  = {$mode};
APISETTING;
        JS::registerCode($code);
        JS::registerCode(self::$formScript);
        $formContent = self::getElement('div', 'class="paymill-error-text"');
        $formContent .= self::fieldset('');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_PAYMILL_ELV_ACCOUNT_NUMBER']);
        $formContent .= Html::getInputText('', '', '', 'class="elv-account"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_PAYMILL_ELV_BANK_CODE']);
        $formContent .= Html::getInputText('', '', '', 'class ="elv-bankcode"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', $_ARRAYLANG['TXT_SHOP_PAYMILL_ACCOUNT_HOLDER']);
        $formContent .= Html::getInputText('', '', '', 'class="elv-holdername"');
        $formContent .= self::closeElement('div');
        $formContent .= self::openElement('div', 'class="row"');
        $formContent .= self::getElement('label', '', '&nbsp;');
        $formContent .= Html::getInputButton('', $_ARRAYLANG['TXT_SHOP_BUY_NOW'], 'submit', '', 'class="submit-button"');
        $formContent .= self::closeElement('div');
        $formContent .= Html::getHidden('handler', 'paymill_elv');
        $formContent .= self::closeElement('fieldset');
        $form = Html::getForm('', Cx\Core\Routing\Url::fromPage($landingPage)->toString(), $formContent, 'payment-form', 'post');
        return $form;
    }
Example #18
0
 /**
  * Show archive
  *
  * Show the livecam archive from a specified date
  *
  * @access private
  * @param string $date
  */
 function _showArchive($date)
 {
     global $_ARRAYLANG;
     \JS::activate("shadowbox", array('players' => array('img')));
     \JS::activate('jqueryui');
     \JS::registerCode("\n            cx.ready(function() {\n                cx.jQuery('input[name=date]').datepicker({dateFormat: 'yy-mm-dd'});\n            });\n        ");
     $this->camSettings = $this->getCamSettings($this->cam);
     $this->_getThumbs();
     if (count($this->_arrArchiveThumbs) > 0) {
         $countPerRow;
         $picNr = 1;
         usort($this->_arrArchiveThumbs, array($this, '_sort_thumbs'));
         foreach ($this->_arrArchiveThumbs as $arrThumbnail) {
             if (!isset($countPerRow)) {
                 if (!$this->_objTpl->blockExists($this->_pictureTemplatePlaceholder . $picNr)) {
                     $this->_objTpl->parse('livecamArchiveRow');
                     $countPerRow = $picNr - 1;
                     $picNr = 1;
                 }
             }
             $this->_objTpl->setVariable(array('LIVECAM_PICTURE_URL' => $arrThumbnail['link_url'], 'LIVECAM_PICTURE_TIME' => $arrThumbnail['time'], 'LIVECAM_THUMBNAIL_URL' => $arrThumbnail['image_url'], 'LIVECAM_THUMBNAIL_SIZE' => $this->camSettings['thumbMaxSize'], 'LIVECAM_IMAGE_SHADOWBOX' => $this->camSettings['shadowboxActivate'] == 1 ? 'shadowbox[gallery]' : ''));
             $this->_objTpl->parse($this->_pictureTemplatePlaceholder . $picNr);
             if (isset($countPerRow) && $picNr == $countPerRow) {
                 $picNr = 0;
                 $this->_objTpl->parse('livecamArchiveRow');
             }
             $picNr++;
         }
         $this->_objTpl->parse('livecamArchive');
     } else {
         $this->statusMessage = $_ARRAYLANG['TXT_LIVECAM_NO_PICTURES_OF_SELECTED_DAY'];
     }
 }
    public function getDataElement($name, $type, $length, $value, $options)
    {
        global $_ARRAYLANG;
        if (isset($options['formfield']) && is_callable($options['formfield'])) {
            $formFieldGenerator = $options['formfield'];
            $formField = $formFieldGenerator($name, $type, $length, $value, $options);
            if (is_a($formField, 'Cx\\Core\\Html\\Model\\Entity\\HtmlElement')) {
                return $formField;
            } else {
                $value = $formField;
            }
        }
        if (isset($options['showDetail']) && $options['showDetail'] === false) {
            return '';
        }
        switch ($type) {
            case 'bool':
            case 'boolean':
                // yes/no checkboxes
                $fieldset = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                $inputYes = new \Cx\Core\Html\Model\Entity\DataElement($name, 'yes');
                $inputYes->setAttribute('type', 'radio');
                $inputYes->setAttribute('value', '1');
                $inputYes->setAttribute('id', 'form-' . $this->formId . '-' . $name . '_yes');
                if (isset($options['attributes'])) {
                    $inputYes->setAttributes($options['attributes']);
                }
                $fieldset->addChild($inputYes);
                $labelYes = new \Cx\Core\Html\Model\Entity\HtmlElement('label');
                $labelYes->setAttribute('for', 'form-' . $this->formId . '-' . $name . '_yes');
                $labelYes->addChild(new \Cx\Core\Html\Model\Entity\TextElement($_ARRAYLANG['TXT_YES']));
                $fieldset->addChild($labelYes);
                $inputNo = new \Cx\Core\Html\Model\Entity\DataElement($name, 'no');
                $inputNo->setAttribute('id', 'form-' . $this->formId . '-' . $name . '_no');
                $inputNo->setAttribute('type', 'radio');
                $inputNo->setAttribute('value', '0');
                if (isset($options['attributes'])) {
                    $inputNo->setAttributes($options['attributes']);
                }
                $fieldset->addChild($inputNo);
                $labelNo = new \Cx\Core\Html\Model\Entity\HtmlElement('label');
                $labelNo->setAttribute('for', 'form-' . $this->formId . '-' . $name . '_no');
                $labelNo->addChild(new \Cx\Core\Html\Model\Entity\TextElement($_ARRAYLANG['TXT_NO']));
                $fieldset->addChild($labelNo);
                if ($value) {
                    $inputYes->setAttribute('checked');
                } else {
                    $inputNo->setAttribute('checked');
                }
                return $fieldset;
                break;
            case 'int':
            case 'integer':
                // input field with type number
                $inputNumber = new \Cx\Core\Html\Model\Entity\DataElement($name, $value, \Cx\Core\Html\Model\Entity\DataElement::TYPE_INPUT, new \Cx\Core\Validate\Model\Entity\RegexValidator('/-?[0-9]*/'));
                if (isset($options['attributes'])) {
                    $inputNumber->setAttributes($options['attributes']);
                }
                $inputNumber->setAttribute('type', 'number');
                return $inputNumber;
                break;
            case 'Cx\\Model\\Base\\EntityBase':
                $entityClass = get_class($value);
                $entities = \Env::get('em')->getRepository($entityClass)->findAll();
                $foreignMetaData = \Env::get('em')->getClassMetadata($entityClass);
                $primaryKeyName = $foreignMetaData->getSingleIdentifierFieldName();
                $selected = $foreignMetaData->getFieldValue($value, $primaryKeyName);
                $arrEntities = array();
                $closeMetaData = \Env::get('em')->getClassMetadata($this->entityClass);
                $assocMapping = $closeMetaData->getAssociationMapping($name);
                if (!isset($assocMapping['joinColumns'][0]['nullable']) || $assocMapping['joinColumns'][0]['nullable']) {
                    $arrEntities['NULL'] = $_ARRAYLANG['TXT_CORE_NONE'];
                }
                foreach ($entities as $entity) {
                    $arrEntities[\Env::get('em')->getClassMetadata($entityClass)->getFieldValue($entity, $primaryKeyName)] = $entity;
                }
                $select = new \Cx\Core\Html\Model\Entity\DataElement($name, \Html::getOptions($arrEntities, $selected), \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT);
                if (isset($options['attributes'])) {
                    $select->setAttributes($options['attributes']);
                }
                return $select;
                break;
            case 'Country':
                // this is for customizing only:
                $data = \Cx\Core\Country\Controller\Country::getNameById($value);
                if (empty($data)) {
                    $value = 204;
                }
                $options = \Cx\Core\Country\Controller\Country::getMenuoptions($value);
                $select = new \Cx\Core\Html\Model\Entity\DataElement($name, $options, \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT);
                if (isset($options['attributes'])) {
                    $select->setAttributes($options['attributes']);
                }
                return $select;
                break;
            case 'DateTime':
            case 'datetime':
            case 'date':
                // input field with type text and class datepicker
                if ($value instanceof \DateTime) {
                    $value = $value->format(ASCMS_DATE_FORMAT);
                }
                if (is_null($value)) {
                    $value = '';
                }
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                $input->setAttribute('type', 'text');
                $input->setAttribute('class', 'datepicker');
                if (isset($options['readonly']) && $options['readonly']) {
                    $input->setAttribute('disabled');
                }
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                \DateTimeTools::addDatepickerJs();
                \JS::registerCode('
                        cx.jQuery(function() {
                          cx.jQuery(".datepicker").datetimepicker();
                        });
                        ');
                return $input;
                break;
            case 'multiselect':
            case 'select':
                $values = array();
                if (isset($options['validValues'])) {
                    if (is_array($options['validValues'])) {
                        $values = $options['validValues'];
                    } else {
                        $values = explode(',', $options['validValues']);
                        $values = array_combine($values, $values);
                    }
                }
                if ($type == 'multiselect') {
                    $value = explode(',', $value);
                    $value = array_combine($value, $value);
                }
                $selectOptions = \Html::getOptions($values, $value);
                $select = new \Cx\Core\Html\Model\Entity\DataElement($name, $selectOptions, \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT);
                if ($type == 'multiselect') {
                    $select->setAttribute('multiple');
                }
                if (isset($options['attributes'])) {
                    $select->setAttributes($options['attributes']);
                }
                return $select;
                break;
            case 'slider':
                // this code should not be here
                // create sorrounding div
                $element = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                // create div for slider
                $slider = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                $slider->setAttribute('class', 'slider');
                $element->addChild($slider);
                // create hidden input for slider value
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value + 0, \Cx\Core\Html\Model\Entity\DataElement::TYPE_INPUT);
                $input->setAttribute('type', 'hidden');
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                $element->addChild($input);
                // add javascript to update input value
                $min = 0;
                $max = 10;
                if (isset($options['validValues'])) {
                    $values = explode(',', $options['validValues']);
                    $min = $values[0];
                    if (isset($values[1])) {
                        $max = $values[1];
                    }
                }
                if (!isset($value)) {
                    $value = 0;
                }
                $script = new \Cx\Core\Html\Model\Entity\HtmlElement('script');
                $script->addChild(new \Cx\Core\Html\Model\Entity\TextElement('
                    cx.jQuery("#form-' . $this->formId . '-' . $name . ' .slider").slider({
                        value: ' . ($value + 0) . ',
                        min: ' . ($min + 0) . ',
                        max: ' . ($max + 0) . ',
                        slide: function( event, ui ) {
                            cx.jQuery("input[name=' . $name . ']").val(ui.value);
                            cx.jQuery("input[name=' . $name . ']").change();
                        }
                    });
                '));
                $element->addChild($script);
                return $element;
                break;
            case 'checkboxes':
                $dataElementGroupType = \Cx\Core\Html\Model\Entity\DataElementGroup::TYPE_CHECKBOX;
            case 'radio':
                $values = array();
                if (isset($options['validValues'])) {
                    $values = explode(',', $options['validValues']);
                    $values = array_combine($values, $values);
                }
                if (!isset($dataElementGroupType)) {
                    $dataElementGroupType = \Cx\Core\Html\Model\Entity\DataElementGroup::TYPE_RADIO;
                }
                $radio = new \Cx\Core\Html\Model\Entity\DataElementGroup($name, $values, $value, $dataElementGroupType);
                if (isset($options['attributes'])) {
                    $radio->setAttributes($options['attributes']);
                }
                return $radio;
                break;
            case 'text':
                // textarea
                $textarea = new \Cx\Core\Html\Model\Entity\HtmlElement('textarea');
                $textarea->setAttribute('name', $name);
                if (isset($options['readonly']) && $options['readonly']) {
                    $textarea->setAttribute('disabled');
                }
                $textarea->addChild(new \Cx\Core\Html\Model\Entity\TextElement($value));
                if (isset($options['attributes'])) {
                    $textarea->setAttributes($options['attributes']);
                }
                return $textarea;
                break;
            case 'phone':
                // input field with type phone
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                $input->setAttribute('type', 'phone');
                if (isset($options['readonly']) && $options['readonly']) {
                    $input->setAttribute('disabled');
                }
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                return $input;
                break;
            case 'mail':
                // input field with type mail
                $emailValidator = new \Cx\Core\Validate\Model\Entity\EmailValidator();
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value, 'input', $emailValidator);
                $input->setAttribute('onkeyup', $emailValidator->getJavaScriptCode());
                $input->setAttribute('type', 'mail');
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                if (isset($options['readonly']) && $options['readonly']) {
                    $input->setAttribute('disabled');
                }
                return $input;
                break;
            case 'uploader':
                \JS::registerCode('
                    function javascript_callback_function(data) {
                        if(data.type=="file") {
                                cx.jQuery("#' . $name . '").val(data.data[0].datainfo.filepath);
                        }
                    }

                ');
                $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
                $mediaBrowser->setOptions(array('type' => 'button'));
                $mediaBrowser->setCallback('javascript_callback_function');
                $mediaBrowser->setOptions(array('data-cx-mb-views' => 'filebrowser,uploader', 'id' => 'page_target_browse', 'cxMbStartview' => 'MediaBrowserList'));
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                $input->setAttribute('type', 'text');
                $input->setAttribute('id', $name);
                $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                $div->addChild($input);
                $div->addChild(new \Cx\Core\Html\Model\Entity\TextElement($mb = $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
                return $div;
                break;
            case 'image':
                \JS::registerCode('
                    function javascript_callback_function(data) {
                        if ( data.data[0].datainfo.extension=="Jpg"
                            || data.data[0].datainfo.extension=="Gif"
                            || data.data[0].datainfo.extension=="Png"
                        ) {
                            cx.jQuery("#' . $name . '").attr(\'value\', data.data[0].datainfo.filepath);
                            cx.jQuery("#' . $name . '").prevAll(\'.deletePreviewImage\').first().css(\'display\', \'inline-block\');
                            cx.jQuery("#' . $name . '").prevAll(\'.previewImage\').first().attr(\'src\', data.data[0].datainfo.filepath);
                        }
                    }

                    jQuery(document).ready(function(){
                        jQuery(\'.deletePreviewImage\').click(function(){
                            cx.jQuery("#' . $name . '").attr(\'value\', \'\');
                            cx.jQuery(this).prev(\'img\').attr(\'src\', \'/images/Downloads/no_picture.gif\');
                            cx.jQuery(this).css(\'display\', \'none\');
                            cx.jQuery(this).nextAll(\'input\').first().attr(\'value\', \'\');
                        });
                    });

                ');
                $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
                $mediaBrowser->setOptions(array('type' => 'button'));
                $mediaBrowser->setCallback('javascript_callback_function');
                $defaultOptions = array('data-cx-mb-views' => 'filebrowser,uploader', 'id' => 'page_target_browse', 'cxMbStartview' => 'MediaBrowserList');
                $mediaBrowser->setOptions(is_array($options['options']) ? array_merge($defaultOptions, $options['options']) : $defaultOptions);
                // create hidden input to save image
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                $input->setAttribute('type', 'hidden');
                $input->setAttribute('id', $name);
                $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                if (isset($value) && in_array(pathinfo($value, PATHINFO_EXTENSION), array('gif', 'jpg', 'png')) || $name == 'imagePath') {
                    // this image is meant to be a preview of the selected image
                    $previewImage = new \Cx\Core\Html\Model\Entity\HtmlElement('img');
                    $previewImage->setAttribute('class', 'previewImage');
                    $previewImage->setAttribute('src', $value != '' ? $value : '/images/Downloads/no_picture.gif');
                    // this image is uesd as delete function for the selected image over javascript
                    $deleteImage = new \Cx\Core\Html\Model\Entity\HtmlElement('img');
                    $deleteImage->setAttribute('class', 'deletePreviewImage');
                    $deleteImage->setAttribute('src', '/core/Core/View/Media/icons/delete.gif');
                    $div->addChild($previewImage);
                    $div->addChild($deleteImage);
                    $div->addChild(new \Cx\Core\Html\Model\Entity\HtmlElement('br'));
                }
                $div->addChild($input);
                $div->addChild(new \Cx\Core\Html\Model\Entity\TextElement($mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
                return $div;
                break;
            case 'sourcecode':
                //set mode
                $mode = 'html';
                if (isset($options['options']['mode'])) {
                    switch ($options['options']['mode']) {
                        case 'js':
                            $mode = 'javascript';
                            break;
                        case 'yml':
                        case 'yaml':
                            $mode = 'yaml';
                            break;
                    }
                }
                //define textarea
                $textarea = new \Cx\Core\Html\Model\Entity\HtmlElement('textarea');
                $textarea->setAttribute('name', $name);
                $textarea->setAttribute('id', $name);
                $textarea->setAttribute('style', 'display:none;');
                $textarea->addChild(new \Cx\Core\Html\Model\Entity\TextElement($value));
                //define pre
                $pre = new \Cx\Core\Html\Model\Entity\HtmlElement('pre');
                $pre->setAttribute('id', 'editor-' . $name);
                $pre->addChild(new \Cx\Core\Html\Model\Entity\TextElement(contrexx_raw2xhtml($value)));
                //set readonly if necessary
                $readonly = '';
                if (isset($options['readonly']) && $options['readonly']) {
                    $readonly = 'editor.setReadOnly(true);';
                    $textarea->setAttribute('disabled');
                }
                //create div and add all stuff
                $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                $div->addChild($textarea);
                $div->addChild($pre);
                //register js
                $jsCode = <<<CODE
var editor;                        
\$J(function(){
if (\$J("#editor-{$name}").length) {
    editor = ace.edit("editor-{$name}");
    editor.getSession().setMode("ace/mode/{$mode}");
    editor.setShowPrintMargin(false);
    editor.focus();
    editor.gotoLine(1);
    {$readonly}
}

\$J('form').submit(function(){
    \$J('#{$name}').val(editor.getSession().getValue());
});

});
CODE;
                \JS::activate('ace');
                \JS::registerCode($jsCode);
                return $div;
                break;
            case 'string':
            case 'hidden':
            default:
                // convert NULL to empty string
                if (is_null($value)) {
                    $value = '';
                }
                // input field with type text
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                if (isset($options['validValues'])) {
                    $input->setValidator(new \Cx\Core\Validate\Model\Entity\RegexValidator('/^' . $options['validValues'] . '$/'));
                }
                if ($type == 'hidden') {
                    $input->setAttribute('type', 'hidden');
                } else {
                    $input->setAttribute('type', 'text');
                    $input->setClass('form-control');
                }
                if (isset($options['readonly']) && $options['readonly']) {
                    $input->setAttribute('disabled');
                }
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                return $input;
                break;
        }
    }
    /**
     * This function returns the DataElement
     *
     * @param string $name name of the DataElement
     * @param string $type type of the DataElement
     * @param int $length length of the DataElement
     * @param mixed $value value of the DataElement
     * @param array $options options for the DataElement
     * @param int $entityId id of the DataElement
     * @return \Cx\Core\Html\Model\Entity\DataElement
     */
    public function getDataElement($name, $type, $length, $value, &$options, $entityId)
    {
        global $_ARRAYLANG, $_CORELANG;
        if (isset($options['formfield'])) {
            $formFieldGenerator = $options['formfield'];
            $formField = '';
            /* We use json to do the callback. The 'else if' is for backwards compatibility so you can declare
             * the function directly without using json. This is not recommended and not working over session */
            if (is_array($formFieldGenerator) && isset($formFieldGenerator['adapter']) && isset($formFieldGenerator['method'])) {
                $json = new \Cx\Core\Json\JsonData();
                $jsonResult = $json->data($formFieldGenerator['adapter'], $formFieldGenerator['method'], array('name' => $name, 'type' => $type, 'length' => $length, 'value' => $value, 'options' => $options));
                if ($jsonResult['status'] == 'success') {
                    $formField = $jsonResult["data"];
                }
            } else {
                if (is_callable($formFieldGenerator)) {
                    $formField = $formFieldGenerator($name, $type, $length, $value, $options);
                }
            }
            if (is_a($formField, 'Cx\\Core\\Html\\Model\\Entity\\HtmlElement')) {
                return $formField;
            } else {
                $value = $formField;
            }
        }
        if (isset($options['showDetail']) && $options['showDetail'] === false) {
            return '';
        }
        switch ($type) {
            case 'bool':
            case 'boolean':
                // yes/no checkboxes
                $fieldset = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                $inputYes = new \Cx\Core\Html\Model\Entity\DataElement($name, 'yes');
                $inputYes->setAttribute('type', 'radio');
                $inputYes->setAttribute('value', '1');
                $inputYes->setAttribute('id', 'form-' . $this->formId . '-' . $name . '_yes');
                if (isset($options['attributes'])) {
                    $inputYes->setAttributes($options['attributes']);
                }
                $fieldset->addChild($inputYes);
                $labelYes = new \Cx\Core\Html\Model\Entity\HtmlElement('label');
                $labelYes->setAttribute('for', 'form-' . $this->formId . '-' . $name . '_yes');
                $labelYes->addChild(new \Cx\Core\Html\Model\Entity\TextElement($_ARRAYLANG['TXT_YES']));
                $fieldset->addChild($labelYes);
                $inputNo = new \Cx\Core\Html\Model\Entity\DataElement($name, 'no');
                $inputNo->setAttribute('id', 'form-' . $this->formId . '-' . $name . '_no');
                $inputNo->setAttribute('type', 'radio');
                $inputNo->setAttribute('value', '0');
                if (isset($options['attributes'])) {
                    $inputNo->setAttributes($options['attributes']);
                }
                $fieldset->addChild($inputNo);
                $labelNo = new \Cx\Core\Html\Model\Entity\HtmlElement('label');
                $labelNo->setAttribute('for', 'form-' . $this->formId . '-' . $name . '_no');
                $labelNo->addChild(new \Cx\Core\Html\Model\Entity\TextElement($_ARRAYLANG['TXT_NO']));
                $fieldset->addChild($labelNo);
                if ($value) {
                    $inputYes->setAttribute('checked');
                } else {
                    $inputNo->setAttribute('checked');
                }
                return $fieldset;
                break;
            case 'int':
            case 'integer':
                // input field with type number
                $inputNumber = new \Cx\Core\Html\Model\Entity\DataElement($name, $value, \Cx\Core\Html\Model\Entity\DataElement::TYPE_INPUT, new \Cx\Core\Validate\Model\Entity\RegexValidator('/-?[0-9]*/'));
                if (isset($options['attributes'])) {
                    $inputNumber->setAttributes($options['attributes']);
                }
                $inputNumber->setAttribute('type', 'number');
                return $inputNumber;
                break;
            case 'Cx\\Model\\Base\\EntityBase':
                $associatedClass = get_class($value);
                \JS::registerJS('core/Html/View/Script/Backend.js');
                \ContrexxJavascript::getInstance()->setVariable('Form/Error', $_ARRAYLANG['TXT_CORE_HTML_FORM_VALIDATION_ERROR'], 'core/Html/lang');
                if (\Env::get('em')->getClassMetadata($this->entityClass)->isSingleValuedAssociation($name)) {
                    // this case is used to create a select field for 1 to 1 associations
                    $entities = \Env::get('em')->getRepository($associatedClass)->findAll();
                    $foreignMetaData = \Env::get('em')->getClassMetadata($associatedClass);
                    $primaryKeyName = $foreignMetaData->getSingleIdentifierFieldName();
                    $selected = $foreignMetaData->getFieldValue($value, $primaryKeyName);
                    $arrEntities = array();
                    $closeMetaData = \Env::get('em')->getClassMetadata($this->entityClass);
                    $assocMapping = $closeMetaData->getAssociationMapping($name);
                    $validator = null;
                    if (!isset($assocMapping['joinColumns'][0]['nullable']) || $assocMapping['joinColumns'][0]['nullable']) {
                        $arrEntities['NULL'] = $_ARRAYLANG['TXT_CORE_NONE'];
                    } else {
                        $validator = new \Cx\Core\Validate\Model\Entity\RegexValidator('/^(?!null$|$)/');
                    }
                    foreach ($entities as $entity) {
                        $arrEntities[\Env::get('em')->getClassMetadata($associatedClass)->getFieldValue($entity, $primaryKeyName)] = $entity;
                    }
                    $select = new \Cx\Core\Html\Model\Entity\DataElement($name, \Html::getOptions($arrEntities, $selected), \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT, $validator);
                    if (isset($options['attributes'])) {
                        $select->setAttributes($options['attributes']);
                    }
                    return $select;
                } else {
                    // this case is used to list all existing values and show an add button for 1 to many associations
                    $closeMetaData = \Env::get('em')->getClassMetadata($this->entityClass);
                    $assocMapping = $closeMetaData->getAssociationMapping($name);
                    $mainDiv = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                    $mainDiv->setAttribute('class', 'entityList');
                    $addButton = new \Cx\Core\Html\Model\Entity\HtmlElement('input');
                    $addButton->setAttribute('type', 'button');
                    $addButton->setClass(array('form-control', 'add_' . $this->createCssClassNameFromEntity($associatedClass), 'mappedAssocciationButton'));
                    $addButton->setAttribute('value', $_CORELANG['TXT_ADD']);
                    $addButton->setAttribute('data-params', 'entityClass:' . $associatedClass . ';' . 'mappedBy:' . $assocMapping['mappedBy'] . ';' . 'cssName:' . $this->createCssClassNameFromEntity($associatedClass) . ';' . 'sessionKey:' . $this->entityClass);
                    if (!isset($_SESSION['vgOptions'])) {
                        $_SESSION['vgOptions'] = array();
                    }
                    $_SESSION['vgOptions'][$this->entityClass] = $this->componentOptions;
                    if ($entityId != 0) {
                        // if we edit the main form, we also want to show the existing associated values we already have
                        $existingValues = $this->getIdentifyingDisplayValue($assocMapping, $associatedClass, $entityId);
                    }
                    if (!empty($existingValues)) {
                        foreach ($existingValues as $existingValue) {
                            $mainDiv->addChild($existingValue);
                        }
                    }
                    $mainDiv->addChild($addButton);
                    // if standard tooltip is not disabled, we load the one to n association text
                    if (!isset($options['showstanardtooltip']) || $options['showstanardtooltip']) {
                        if (!empty($options['tooltip'])) {
                            $options['tooltip'] = $options['tooltip'] . '<br /><br /> ' . $_ARRAYLANG['TXT_CORE_RECORD_ONE_TO_N_ASSOCIATION'];
                        } else {
                            $options['tooltip'] = $_ARRAYLANG['TXT_CORE_RECORD_ONE_TO_N_ASSOCIATION'];
                        }
                    }
                    $cxjs = \ContrexxJavascript::getInstance();
                    $cxjs->setVariable('TXT_CANCEL', $_CORELANG['TXT_CANCEL'], 'Html/lang');
                    $cxjs->setVariable('TXT_SUBMIT', $_CORELANG['TXT_SUBMIT'], 'Html/lang');
                    $cxjs->setVariable('TXT_EDIT', $_CORELANG['TXT_EDIT'], 'Html/lang');
                    $cxjs->setVariable('TXT_DELETE', $_CORELANG['TXT_DELETE'], 'Html/lang');
                    return $mainDiv;
                }
                break;
            case 'Country':
                // this is for customizing only:
                $data = \Cx\Core\Country\Controller\Country::getNameById($value);
                if (empty($data)) {
                    $value = 204;
                }
                $options = \Cx\Core\Country\Controller\Country::getMenuoptions($value);
                $select = new \Cx\Core\Html\Model\Entity\DataElement($name, $options, \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT);
                if (isset($options['attributes'])) {
                    $select->setAttributes($options['attributes']);
                }
                return $select;
                break;
            case 'DateTime':
            case 'datetime':
            case 'date':
                // input field with type text and class datepicker
                if ($value instanceof \DateTime) {
                    $value = $value->format(ASCMS_DATE_FORMAT);
                }
                if (is_null($value)) {
                    $value = '';
                }
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                $input->setAttribute('type', 'text');
                $input->setAttribute('class', 'datepicker');
                if (isset($options['readonly']) && $options['readonly']) {
                    $input->setAttribute('disabled');
                }
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                \DateTimeTools::addDatepickerJs();
                \JS::registerCode('
                        cx.jQuery(function() {
                          cx.jQuery(".datepicker").datetimepicker();
                        });
                        ');
                return $input;
                break;
            case 'multiselect':
            case 'select':
                $values = array();
                if (isset($options['validValues'])) {
                    if (is_array($options['validValues'])) {
                        $values = $options['validValues'];
                    } else {
                        $values = explode(',', $options['validValues']);
                        $values = array_combine($values, $values);
                    }
                }
                if ($type == 'multiselect') {
                    $value = explode(',', $value);
                    $value = array_combine($value, $value);
                }
                $selectOptions = \Html::getOptions($values, $value);
                $select = new \Cx\Core\Html\Model\Entity\DataElement($name, $selectOptions, \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT);
                if ($type == 'multiselect') {
                    $select->setAttribute('multiple');
                }
                if (isset($options['attributes'])) {
                    $select->setAttributes($options['attributes']);
                }
                return $select;
                break;
            case 'slider':
                // this code should not be here
                // create sorrounding div
                $element = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                // create div for slider
                $slider = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                $slider->setAttribute('class', 'slider');
                $element->addChild($slider);
                // create hidden input for slider value
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value + 0, \Cx\Core\Html\Model\Entity\DataElement::TYPE_INPUT);
                $input->setAttribute('type', 'hidden');
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                $element->addChild($input);
                // add javascript to update input value
                $min = 0;
                $max = 10;
                if (isset($options['validValues'])) {
                    $values = explode(',', $options['validValues']);
                    $min = $values[0];
                    if (isset($values[1])) {
                        $max = $values[1];
                    }
                }
                if (!isset($value)) {
                    $value = 0;
                }
                $script = new \Cx\Core\Html\Model\Entity\HtmlElement('script');
                $script->addChild(new \Cx\Core\Html\Model\Entity\TextElement('
                    cx.jQuery("#form-' . $this->formId . '-' . $name . ' .slider").slider({
                        value: ' . ($value + 0) . ',
                        min: ' . ($min + 0) . ',
                        max: ' . ($max + 0) . ',
                        slide: function( event, ui ) {
                            cx.jQuery("input[name=' . $name . ']").val(ui.value);
                            cx.jQuery("input[name=' . $name . ']").change();
                        }
                    });
                '));
                $element->addChild($script);
                return $element;
                break;
            case 'checkboxes':
                $dataElementGroupType = \Cx\Core\Html\Model\Entity\DataElementGroup::TYPE_CHECKBOX;
            case 'radio':
                $values = array();
                if (isset($options['validValues'])) {
                    $values = explode(',', $options['validValues']);
                    $values = array_combine($values, $values);
                }
                if (!isset($dataElementGroupType)) {
                    $dataElementGroupType = \Cx\Core\Html\Model\Entity\DataElementGroup::TYPE_RADIO;
                }
                $radio = new \Cx\Core\Html\Model\Entity\DataElementGroup($name, $values, $value, $dataElementGroupType);
                if (isset($options['attributes'])) {
                    $radio->setAttributes($options['attributes']);
                }
                return $radio;
                break;
            case 'text':
                // textarea
                $textarea = new \Cx\Core\Html\Model\Entity\HtmlElement('textarea');
                $textarea->setAttribute('name', $name);
                if (isset($options['readonly']) && $options['readonly']) {
                    $textarea->setAttribute('disabled');
                }
                $textarea->addChild(new \Cx\Core\Html\Model\Entity\TextElement($value));
                if (isset($options['attributes'])) {
                    $textarea->setAttributes($options['attributes']);
                }
                return $textarea;
                break;
            case 'phone':
                // input field with type phone
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                $input->setAttribute('type', 'phone');
                if (isset($options['readonly']) && $options['readonly']) {
                    $input->setAttribute('disabled');
                }
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                return $input;
                break;
            case 'mail':
                // input field with type mail
                $emailValidator = new \Cx\Core\Validate\Model\Entity\EmailValidator();
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value, 'input', $emailValidator);
                $input->setAttribute('onkeyup', $emailValidator->getJavaScriptCode());
                $input->setAttribute('type', 'mail');
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                if (isset($options['readonly']) && $options['readonly']) {
                    $input->setAttribute('disabled');
                }
                return $input;
                break;
            case 'uploader':
                \JS::registerCode('
                    function javascript_callback_function(data) {
                        if(data.type=="file") {
                                cx.jQuery("#' . $name . '").val(data.data[0].datainfo.filepath);
                        }
                    }

                ');
                $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
                $mediaBrowser->setOptions(array('type' => 'button'));
                $mediaBrowser->setCallback('javascript_callback_function');
                $mediaBrowser->setOptions(array('data-cx-mb-views' => 'filebrowser,uploader', 'id' => 'page_target_browse', 'cxMbStartview' => 'MediaBrowserList'));
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                $input->setAttribute('type', 'text');
                $input->setAttribute('id', $name);
                $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                $div->addChild($input);
                $div->addChild(new \Cx\Core\Html\Model\Entity\TextElement($mb = $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
                return $div;
                break;
            case 'image':
                \JS::registerCode('
                    function javascript_callback_function(data) {
                        if ( data.data[0].datainfo.extension=="Jpg"
                            || data.data[0].datainfo.extension=="Gif"
                            || data.data[0].datainfo.extension=="Png"
                        ) {
                            cx.jQuery("#' . $name . '").attr(\'value\', data.data[0].datainfo.filepath);
                            cx.jQuery("#' . $name . '").prevAll(\'.deletePreviewImage\').first().css(\'display\', \'inline-block\');
                            cx.jQuery("#' . $name . '").prevAll(\'.previewImage\').first().attr(\'src\', data.data[0].datainfo.filepath);
                        }
                    }

                    jQuery(document).ready(function(){
                        jQuery(\'.deletePreviewImage\').click(function(){
                            cx.jQuery("#' . $name . '").attr(\'value\', \'\');
                            cx.jQuery(this).prev(\'img\').attr(\'src\', \'/images/Downloads/no_picture.gif\');
                            cx.jQuery(this).css(\'display\', \'none\');
                            cx.jQuery(this).nextAll(\'input\').first().attr(\'value\', \'\');
                        });
                    });

                ');
                $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser();
                $mediaBrowser->setOptions(array('type' => 'button'));
                $mediaBrowser->setCallback('javascript_callback_function');
                $defaultOptions = array('data-cx-mb-views' => 'filebrowser,uploader', 'id' => 'page_target_browse', 'cxMbStartview' => 'MediaBrowserList');
                $mediaBrowser->setOptions(is_array($options['options']) ? array_merge($defaultOptions, $options['options']) : $defaultOptions);
                // create hidden input to save image
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                $input->setAttribute('type', 'hidden');
                $input->setAttribute('id', $name);
                $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                if (isset($value) && in_array(pathinfo($value, PATHINFO_EXTENSION), array('gif', 'jpg', 'png')) || $name == 'imagePath') {
                    // this image is meant to be a preview of the selected image
                    $previewImage = new \Cx\Core\Html\Model\Entity\HtmlElement('img');
                    $previewImage->setAttribute('class', 'previewImage');
                    $previewImage->setAttribute('src', $value != '' ? $value : '/images/Downloads/no_picture.gif');
                    // this image is uesd as delete function for the selected image over javascript
                    $deleteImage = new \Cx\Core\Html\Model\Entity\HtmlElement('img');
                    $deleteImage->setAttribute('class', 'deletePreviewImage');
                    $deleteImage->setAttribute('src', '/core/Core/View/Media/icons/delete.gif');
                    $div->addChild($previewImage);
                    $div->addChild($deleteImage);
                    $div->addChild(new \Cx\Core\Html\Model\Entity\HtmlElement('br'));
                }
                $div->addChild($input);
                $div->addChild(new \Cx\Core\Html\Model\Entity\TextElement($mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE'])));
                return $div;
                break;
            case 'sourcecode':
                //set mode
                $mode = 'html';
                if (isset($options['options']['mode'])) {
                    switch ($options['options']['mode']) {
                        case 'js':
                            $mode = 'javascript';
                            break;
                        case 'yml':
                        case 'yaml':
                            $mode = 'yaml';
                            break;
                    }
                }
                //define textarea
                $textarea = new \Cx\Core\Html\Model\Entity\HtmlElement('textarea');
                $textarea->setAttribute('name', $name);
                $textarea->setAttribute('id', $name);
                $textarea->setAttribute('style', 'display:none;');
                $textarea->addChild(new \Cx\Core\Html\Model\Entity\TextElement($value));
                //define pre
                $pre = new \Cx\Core\Html\Model\Entity\HtmlElement('pre');
                $pre->setAttribute('id', 'editor-' . $name);
                $pre->addChild(new \Cx\Core\Html\Model\Entity\TextElement(contrexx_raw2xhtml($value)));
                //set readonly if necessary
                $readonly = '';
                if (isset($options['readonly']) && $options['readonly']) {
                    $readonly = 'editor.setReadOnly(true);';
                    $textarea->setAttribute('disabled');
                }
                //create div and add all stuff
                $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div');
                //     required for the Ace editor to work. Otherwise
                //     it won't be visible as the DIV does have a width of 0px.
                $div->setAttribute('style', 'display:block;');
                $div->addChild($textarea);
                $div->addChild($pre);
                //register js
                $jsCode = <<<CODE
var editor;
\$J(function(){
if (\$J("#editor-{$name}").length) {
    editor = ace.edit("editor-{$name}");
    editor.getSession().setMode("ace/mode/{$mode}");
    editor.setShowPrintMargin(false);
    editor.focus();
    editor.gotoLine(1);
    {$readonly}
}

\$J('form').submit(function(){
    \$J('#{$name}').val(editor.getSession().getValue());
});

});
CODE;
                \JS::activate('ace');
                \JS::registerCode($jsCode);
                return $div;
                break;
            case 'string':
            case 'hidden':
            default:
                // convert NULL to empty string
                if (is_null($value)) {
                    $value = '';
                }
                // input field with type text
                $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value);
                if (isset($options['validValues'])) {
                    $input->setValidator(new \Cx\Core\Validate\Model\Entity\RegexValidator('/^' . $options['validValues'] . '$/'));
                }
                if ($type == 'hidden') {
                    $input->setAttribute('type', 'hidden');
                } else {
                    $input->setAttribute('type', 'text');
                    $input->setClass('form-control');
                }
                if (isset($options['readonly']) && $options['readonly']) {
                    $input->setAttribute('disabled');
                }
                if (isset($options['attributes'])) {
                    $input->setAttributes($options['attributes']);
                }
                return $input;
                break;
        }
    }
    /**
     * Registers the javascript code to update a license
     * @param array $_CORELANG Core language array
     * @param array $_CONFIG The configuration array
     * @param boolean $autoexec (optional) Wheter to perform update check automaticly or on form submit
     */
    public function addJsUpdateCode(&$_CORELANG, $license, $intern = false, $autoexec = true)
    {
        $v = preg_split('#\\.#', $this->coreCmsVersion);
        $version = current($v);
        unset($v[key($v)]);
        foreach ($v as $part) {
            $version *= 100;
            $version += $part;
        }
        $userAgentRequestArguments = array('data=' . urlencode(json_encode(array('installationId' => $license->getInstallationId(), 'licenseKey' => $license->getLicenseKey(), 'edition' => $license->getEditionName(), 'version' => $this->coreCmsVersion, 'versionstate' => $this->coreCmsStatus, 'domainName' => $this->domainUrl, 'remoteAddr' => $_SERVER['REMOTE_ADDR'], 'sendTemplate' => false))), 'v=' . $version, 'userAgentRequest=true');
        if (!$autoexec || $this->isTimeToUpdate()) {
            if (self::$javascriptRegistered) {
                return;
            }
            self::$javascriptRegistered = true;
            \JS::activate('jquery');
            $objJs = \ContrexxJavascript::getInstance();
            $objJs->setVariable("statusmessage_success", $_CORELANG['TXT_LICENSE_UPDATED'], "core_module/license");
            $jsCode = '
                cx.jQuery(document).ready(function() {
                    var licenseMessage      = cx.jQuery("#license_message");
                    var cloneLicenseMessage = cx.jQuery("#license_message").clone();
                    var reloadManager       = true;
                    
                    var revertMessage = function(setClass, setHref, setTarget, setText) {
                        setTimeout(function() {
                            newLicenseMessage = cloneLicenseMessage.clone();
                            if (setClass) {
                                newLicenseMessage.attr("class", "upgrade " + setClass);
                            }
                            if (setHref) {
                                licenseMessage.children("a:first").attr("href", setHref);
                            }
                            if (setTarget) {
                                licenseMessage.children("a:first").attr("target", setTarget);
                            }
                            if (setText) {
                                licenseMessage.children("a:first").html(setText);
                            }
                            licenseMessage.replaceWith(newLicenseMessage);
                            licenseMessage = newLicenseMessage;
                        }, 1000);
                    }
                    
                    //var versionCheckUrl = "../core_modules/License/versioncheck.php?force=true";
                    var versionCheckUrl = "../api/licup?force=true";
                    var versionCheckResponseHandler = function(data, allowUserAgent) {';
            $sm = new \Cx\Core\Config\Controller\Config();
            if (\FWUser::getFWUserObject()->objUser->getAdminStatus()) {
                $jsCode .= '
                        if (data == "false" && allowUserAgent && ' . ($sm->isWritable() ? 'true' : 'false') . ') {
                            reloadManager = false;
                            cx.jQuery.getScript("http://updatesrv1.contrexx.com/?' . implode('&', $userAgentRequestArguments) . '", function() {
                                cx.jQuery.post(
                                    versionCheckUrl,
                                    {"response": JSON.stringify(licenseUpdateUserAgentRequestResponse)}
                                ).success(function(data) {
                                    reloadManager = true;
                                    versionCheckResponseHandler(data, false)
                                }).error(function(data) {
                                    revertMessage();
                                });
                            }).fail(function(){
                                revertMessage();
                            });
                        }';
            }
            $jsCode .= '
                        var data = cx.jQuery.parseJSON(data);
                        if (!data) {
                            revertMessage();
                            return;
                        }
                        revertMessage(data[\'class\'], data.link, data.target, data.text);
                        cx.jQuery("#jsstatemessage").html(cx.variables.get("statusmessage_success", "core_module/license"));
                        cx.jQuery("#jsstatemessage").addClass("okbox");
                        cx.jQuery("#jsstatemessage").show();
                        if (reloadManager && ' . ($sm->isWritable() ? 'true' : 'false') . ' && data.status != "ERROR") {
                            setTimeout(function() {
                                window.location.href = window.location.href;
                            }, 1500);
                        }
                    }
                    
                    var performRequest = function() {
                        licenseMessage.attr("class", "infobox");
                        licenseMessage.text("' . $_CORELANG['TXT_LICENSE_UPDATING'] . '");
                        licenseMessage.show();

                        cx.jQuery.get(
                            versionCheckUrl
                        ).success(function(data) {
                            versionCheckResponseHandler(data, true);
                        }).error(function(data) {
                            revertMessage();
                        });
                        return false;
                    }' . ($autoexec ? '()' : '') . ';
                    
                    ' . ($intern ? 'cx.jQuery("input[name=update]").click(performRequest);' : '') . '
                });
            ';
            \JS::registerCode($jsCode);
        }
    }