/**
  * Load your component.
  * 
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page       The resolved page
  */
 public function load(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     global $subMenuTitle, $_ARRAYLANG;
     $subMenuTitle = $_ARRAYLANG['TXT_SYSTEM_SETTINGS'];
     $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html');
     $cachedRoot = $this->cx->getTemplate()->getRoot();
     $this->cx->getTemplate()->setRoot($this->getDirectory() . '/View/Template/Backend');
     \Permission::checkAccess(17, 'static');
     $objConfig = new \Cx\Core\Config\Controller\Config();
     $objConfig->getPage();
     $this->cx->getTemplate()->setRoot($cachedRoot);
 }
示例#2
0
 /**
  * Show settings for banner-modul
  *
  * @global    object        $objDatabase
  * @global     array        $_ARRAYLANG
  */
 function showSettings()
 {
     global $objDatabase, $_ARRAYLANG;
     if (isset($_POST['frmSettings_Active'])) {
         $intStatus = intval($_POST['frmSettings_Active']);
         if ($intStatus == 1 || $intStatus == 0) {
             $objDatabase->Execute('    UPDATE    ' . DBPREFIX . 'settings
                                     SET        setvalue="' . $intStatus . '"
                                     WHERE    setname="bannerStatus"
                                     LIMIT    1
                                 ');
             $objSettings = new \Cx\Core\Config\Controller\Config();
             $objSettings->writeSettingsFile();
         }
         $intNewsStatus = intval($_POST['frmSettings_News']);
         if ($intNewsStatus == 1 || $intNewsStatus == 0) {
             $objDatabase->Execute('    UPDATE    ' . DBPREFIX . 'module_banner_settings
                                     SET        value="' . $intNewsStatus . '"
                                     WHERE    name="news_banner"
                                     LIMIT    1
                                 ');
         }
         $intContentStatus = intval($_POST['frmSettings_Content']);
         if ($intContentStatus == 1 || $intContentStatus == 0) {
             $objDatabase->Execute('    UPDATE    ' . DBPREFIX . 'module_banner_settings
                                     SET        value="' . $intContentStatus . '"
                                     WHERE    name="content_banner"
                                     LIMIT    1
                                 ');
         }
         $intTeaserStatus = intval($_POST['frmSettings_Teaser']);
         if ($intTeaserStatus == 1 || $intTeaserStatus == 0) {
             $objDatabase->Execute('    UPDATE    ' . DBPREFIX . 'module_banner_settings
                                     SET        value="' . $intTeaserStatus . '"
                                     WHERE    name="teaser_banner"
                                     LIMIT    1
                                 ');
         }
         $this->strOkMessage = $_ARRAYLANG['TXT_BANNER_SETTINGS_SAVED'];
         $this->getSettings();
     }
     // initialize variables
     $this->_objTpl->loadTemplateFile('module_banner_settings.html', true, true);
     $this->pageTitle = $_ARRAYLANG['TXT_BANNER_MENU_SETTINGS'];
     $this->_objTpl->setVariable(array('TXT_BANNER_SETTINGS_TITLE' => $_ARRAYLANG['TXT_BANNER_MENU_SETTINGS'], 'TXT_BANNER_SETTINGS_ACTIVE' => $_ARRAYLANG['TXT_BANNER_SETTINGS_ACTIVE'], 'TXT_BANNER_SETTINGS_ON' => $_ARRAYLANG['TXT_BANNER_SETTINGS_ON'], 'TXT_BANNER_SETTINGS_OFF' => $_ARRAYLANG['TXT_BANNER_SETTINGS_OFF'], 'TXT_BANNER_SETTINGS_NEWS' => $_ARRAYLANG['TXT_BANNER_SETTINGS_NEWS'], 'TXT_BANNER_SETTINGS_CONTENT' => $_ARRAYLANG['TXT_BANNER_SETTINGS_CONTENT'], 'TXT_BANNER_SETTINGS_TEASER' => $_ARRAYLANG['TXT_BANNER_SETTINGS_TEASER'], 'TXT_BANNER_SETTINGS_SAVE' => $_ARRAYLANG['TXT_BANNER_ADD_RELATION_SAVE']));
     $objResult = $objDatabase->Execute('SELECT    setvalue
                                         FROM    ' . DBPREFIX . 'settings
                                         WHERE    setname="bannerStatus"
                                         LIMIT    1
                                     ');
     $this->_objTpl->setVariable(array('SETTINGS_ACTIVE_1' => $objResult->fields['setvalue'] == 1 ? 'checked' : '', 'SETTINGS_ACTIVE_0' => $objResult->fields['setvalue'] == 0 ? 'checked' : '', 'SETTINGS_NEWS_1' => $this->arrSettings['news_banner'] == 1 ? 'checked' : '', 'SETTINGS_NEWS_0' => $this->arrSettings['news_banner'] == 0 ? 'checked' : '', 'SETTINGS_CONTENT_1' => $this->arrSettings['content_banner'] == 1 ? 'checked' : '', 'SETTINGS_CONTENT_0' => $this->arrSettings['content_banner'] == 0 ? 'checked' : '', 'SETTINGS_TEASER_1' => $this->arrSettings['teaser_banner'] == 1 ? 'checked' : '', 'SETTINGS_TEASER_0' => $this->arrSettings['teaser_banner'] == 0 ? 'checked' : ''));
 }
    /**
     * 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);
        }
    }
 public function getPage($post, &$_CORELANG)
 {
     $lc = LicenseCommunicator::getInstance($this->config);
     $lc->addJsUpdateCode($this->lang, $this->license, true, false);
     $sm = new \Cx\Core\Config\Controller\Config();
     if (\FWUser::getFWUserObject()->objUser->getAdminStatus()) {
         if (isset($post['save']) && isset($post['licenseKey'])) {
             $license = License::getCached($this->config, $this->db);
             if ($license->checkSum(contrexx_input2db($post['licenseKey']))) {
                 $license->setLicenseKey(contrexx_input2db($post['licenseKey']));
                 // save it before we check it, so we only change the license key
                 $license->save($this->db);
                 $license->check();
                 $this->license = $license;
             }
         } else {
             if (isset($post['update'])) {
                 // This is only a backup if javascript is bogus
                 try {
                     $lc->update($this->license, $this->config, true, false, $this->lang);
                     $this->license->save($this->db);
                 } catch (\Exception $e) {
                 }
             }
         }
     }
     if (!file_exists(ASCMS_TEMP_PATH . '/licenseManager.html')) {
         try {
             $lc->update($this->license, $this->config, true, true, $this->lang);
             $this->license->save($this->db);
         } catch (\Exception $e) {
         }
     }
     if (file_exists(ASCMS_TEMP_PATH . '/licenseManager.html')) {
         \JS::activate('cx');
         $remoteTemplate = new \Cx\Core\Html\Sigma(ASCMS_TEMP_PATH);
         $remoteTemplate->loadTemplateFile('/licenseManager.html');
         if (isset($_POST['save']) && isset($_POST['licenseKey'])) {
             $remoteTemplate->setVariable('STATUS_TYPE', 'okbox');
             $remoteTemplate->setVariable('STATUS_MESSAGE', $this->lang['TXT_LICENSE_SAVED']);
         } else {
             if (isset($_POST['update'])) {
                 $remoteTemplate->setVariable('STATUS_TYPE', 'okbox');
                 $remoteTemplate->setVariable('STATUS_MESSAGE', $this->lang['TXT_LICENSE_UPDATED']);
             }
         }
         $remoteTemplate->setVariable($this->lang);
         $this->setLicensePlaceholders($remoteTemplate);
         if ($remoteTemplate->blockExists('legalComponents')) {
             foreach ($this->license->getLegalComponentsList() as $component) {
                 $remoteTemplate->setVariable('LICENSE_LEGAL_COMPONENT', contrexx_raw2xhtml($component));
                 $remoteTemplate->parse('legalComponents');
             }
         }
         if ($remoteTemplate->blockExists('licenseDomain')) {
             foreach ($this->license->getRegisteredDomains() as $domain) {
                 $remoteTemplate->setVariable('LICENSE_DOMAIN', contrexx_raw2xhtml($domain));
                 $remoteTemplate->parse('licenseDomain');
             }
         }
         $message = $this->license->getMessage(false, \FWLanguage::getLanguageCodeById(BACKEND_LANG_ID), $this->lang);
         if (!$sm->isWritable()) {
             $remoteTemplate->setVariable('MESSAGE_TITLE', preg_replace('/<br \\/>/', ' ', sprintf($_CORELANG['TXT_SETTINGS_ERROR_NO_WRITE_ACCESS'], \Cx\Core\Config\Controller\Config::getSettingsFile())));
             $remoteTemplate->setVariable('MESSAGE_LINK', '#');
             $remoteTemplate->setVariable('MESSAGE_LINK_TARGET', '_self');
             $remoteTemplate->setVariable('MESSAGE_TYPE', 'alertbox');
         } else {
             if ($message && strlen($message->getText())) {
                 $remoteTemplate->setVariable('MESSAGE_TITLE', contrexx_raw2xhtml($this->getReplacedMessageText($message)));
                 $remoteTemplate->setVariable('MESSAGE_LINK', contrexx_raw2xhtml($message->getLink()));
                 $remoteTemplate->setVariable('MESSAGE_LINK_TARGET', contrexx_raw2xhtml($message->getLinkTarget()));
                 $remoteTemplate->setVariable('MESSAGE_TYPE', contrexx_raw2xhtml($message->getType()));
             } else {
                 if ($remoteTemplate->blockExists('message')) {
                     $remoteTemplate->setVariable('MESSAGE_TYPE', '" style="display:none;');
                 }
             }
         }
         if (\FWUser::getFWUserObject()->objUser->getAdminStatus()) {
             $remoteTemplate->touchBlock('licenseAdmin');
             $remoteTemplate->hideBlock('licenseNotAdmin');
         } else {
             $remoteTemplate->hideBlock('licenseAdmin');
             $remoteTemplate->touchBlock('licenseNotAdmin');
             $remoteTemplate->setVariable('LICENSE_ADMIN_MAIL', contrexx_raw2xhtml($this->config['coreAdminEmail']));
         }
         $this->template->setVariable('ADMIN_CONTENT', $remoteTemplate->get());
     } else {
         $this->template->setVariable('ADMIN_CONTENT', $this->lang['TXT_LICENSE_NO_TEMPLATE']);
     }
 }