示例#1
0
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $moduleDependency = new \LightboxModuleDependency();
     if (!$moduleDependency->isInsideModule($renderApi, $unit, 'rz_lightbox')) {
         $renderApi->renderChildren($unit);
     } else {
         $i18n = new Translator($renderApi, $moduleInfo);
         $msg = $i18n->translate('error.noLightboxModuleInheritance');
         $errorTag = new HtmlTagBuilder('div', array('class' => 'RUKZUKmissingInputHint'), array(new HtmlTagBuilder('button', array('style' => 'cursor: default;'), array($msg))));
         echo $errorTag->toString();
     }
 }
示例#2
0
 /**
  * @param $renderApi
  * @param \Render\Unit $unit
  * @param \Render\ModuleInfo $moduleInfo
  */
 public function renderContent($renderApi, $unit, $moduleInfo)
 {
     $child = new ChildModuleDependency();
     if ($child->isInsideModule($renderApi, $unit, 'rz_form')) {
         $this->renderFormFieldContent($renderApi, $unit);
     } else {
         $i18n = new Translator($renderApi, $moduleInfo);
         $msg = $i18n->translate('error.moduleOnlyWorkingInForm');
         $errorTag = new HtmlTagBuilder('div', array('class' => 'RUKZUKmissingInputHint'), array(new HtmlTagBuilder('button', array('style' => 'cursor: default;'), array($msg))));
         echo $errorTag->toString();
     }
 }
示例#3
0
 public function testTranslateInput()
 {
     // prepare
     $api = $this->createRenderApi(array('interfaceLocale' => 'de'));
     $moduleInfo = $this->createModuleInfo();
     $translator = new Translator($api, $moduleInfo);
     // execute/verify
     // fallback to en
     $this->assertEquals('this is en', $translator->translateInput('{"en": "this is en", "ch": "test"}'));
     // current lang
     $this->assertEquals('test', $translator->translateInput('{"en": "this is en", "de": "test"}'));
     // fallback to string (malformed json)
     $this->assertEquals('{"en": "this is en", "de": "test}', $translator->translateInput('{"en": "this is en", "de": "test}'));
     // first key (if not current lang and not en) - NOTE: there is no order so we just check that the json is unwrapped
     $this->assertEquals('this', $translator->translateInput('{"pl": "this", "ch": "this"}'));
 }
示例#4
0
 /**
  * Creates an assoc array from countryList textarea value
  * <code>
  * LOCALE: en
  * SRC: 'DE:{"de":"Deutschland","en":"Germany"}\nAT:Austria\nCH:Switzerland';
  * RETURN: array(
  *     'DE' => 'Germany',
  *     'AT' => 'Austria',
  *     'CH' => 'Switzerland',
  * )
  * </code>
  *
  * @return array
  */
 public function getShippingCountries()
 {
     $countries = array();
     $rows = explode("\n", $this->getShopSetting('countryList'));
     foreach ($rows as $rowCount => $row) {
         $data = explode(':', $row, 2);
         if (count($data) > 1 && strlen($data[0]) == 2) {
             $countries[strtoupper($data[0])] = $this->i18n->translateInput($data[1]);
         }
     }
     return $countries;
 }
示例#5
0
 /**
  * Send email to buyer
  *
  * @param HtmlTagBuilder $confirmation
  * @param string         $buyerEmail
  * @param string         $shopOwnerNotificationAdr
  */
 protected function sendConfirmationMail($confirmation, $buyerEmail, $shopOwnerNotificationAdr)
 {
     $emailConfirmationText = $this->settings->getEmailConfirmationText();
     $htmlBody = $this->getEmailBody($confirmation, $emailConfirmationText);
     $subject = $this->translator->translate('email.confirmationSubjectBuyer');
     $mailer = $this->getMailer();
     $mailer->setHtmlBody($htmlBody);
     $mailer->setSubject($subject);
     $mailer->setFrom($shopOwnerNotificationAdr);
     $mailer->addReplyTo($shopOwnerNotificationAdr);
     $mailer->addTo($buyerEmail);
     $mailer->send();
 }
示例#6
0
文件: rz_root.php 项目: rukzuk/rukzuk
    /**
     * Root Modules Render Method (called by Backend Visitor)
     * @param \Render\APIs\RootAPIv1\RootRenderAPI $rootApi
     * @param \Render\Unit $rootUnit
     * @param \Render\ModuleInfo $moduleInfo
     */
    public function render($rootApi, $rootUnit, $moduleInfo)
    {
        // lang/locale
        $pageLang = $rootApi->getFormValue($rootUnit, 'lang', 'en-US');
        $pageLangLowDash = str_replace('-', '_', $pageLang);
        setlocale(LC_ALL, $pageLangLowDash . '.UTF8', $pageLang);
        $rootApi->setLocale($pageLangLowDash);
        // read custom data provided by module implementations (per module and per unit)
        $moduleData = $rootApi->getAllModuleData($rootUnit);
        $unitData = $rootApi->getAllUnitData($rootUnit);
        $nav = $rootApi->getNavigation();
        // http header redirect (only in live and preview mode)
        if ($rootApi->isLiveMode() || $rootApi->isPreviewMode()) {
            foreach ($unitData as $d) {
                $redirect = isset($d['redirect']) ? $d['redirect'] : null;
                if (is_array($redirect) && array_key_exists('url', $redirect)) {
                    header('Location: ' . $redirect['url'], true);
                    exit;
                }
            }
            $currentPage = $nav->getPage($nav->getCurrentPageId());
            $pageTitle = $currentPage->getTitle();
            $pageAttributes = $currentPage->getPageAttributes();
            $redirectFirstChild = false;
            if (array_key_exists('enableRedirect', $pageAttributes)) {
                if ($pageAttributes['enableRedirect'] == 1) {
                    if ($pageAttributes['redirectType'] == "firstChild") {
                        $redirectFirstChild = true;
                    } else {
                        if ($pageAttributes['redirectType'] == "page") {
                            if (array_key_exists('redirectPageId', $pageAttributes)) {
                                $redirectPageId = $pageAttributes['redirectPageId'];
                                if ($redirectPageId != '' && $redirectPageId != $nav->getCurrentPageId()) {
                                    $redirectUrl = $nav->getPage($redirectPageId)->getUrl();
                                    if ($redirectUrl != '') {
                                        header('Location: ' . $redirectUrl);
                                        exit;
                                    }
                                }
                            }
                        } else {
                            if (array_key_exists('redirectUrl', $pageAttributes)) {
                                $redirectUrl = $pageAttributes['redirectUrl'];
                                if (preg_match("/^[http]/", $redirectUrl)) {
                                    if ($rootApi->isLiveMode()) {
                                        header('Location: ' . $redirectUrl);
                                        exit;
                                    } else {
                                        $i18n = new Translator($rootApi, $moduleInfo);
                                        $msg1 = $i18n->translate('error.redirectLiveOnly1');
                                        $msg2 = $i18n->translate('error.redirectLiveOnly2');
                                        echo '<html><body style="margin:0;background-color: #454444;font-family:\'Trebuchet MS\',sans-serif;font-size:20px;color: #ffffff;">';
                                        echo '<div style="display:flex;height:100vh;width:80%;padding:0 10%;justify-content:center;align-items:center;text-align:center;">' . $msg1 . $redirectUrl . $msg2 . '</div>';
                                        echo '</body></html>';
                                        exit;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // redirect to first child page if page title equal [redirect]
            if (strtolower($pageTitle) == '[weiterleiten]' || strtolower($pageTitle) == '[redirect]' || $redirectFirstChild) {
                $childrenIds = $nav->getChildrenIds($nav->getCurrentPageId());
                if (count($childrenIds)) {
                    $currentPage = $nav->getPage($nav->getCurrentPageId());
                    $curUrl = $currentPage->getUrl();
                    $fstChild = $nav->getPage($childrenIds[0]);
                    $url = $fstChild->getUrl();
                    if (!empty($url) && $url != $curUrl) {
                        header('Location: ' . $url);
                        exit;
                    }
                }
            }
        }
        // protected pages
        $password_protection = $rootApi->getWebsiteSettings('password_protection');
        if ($password_protection['enableProtectedPage'] && $rootApi->isPage()) {
            if ($rootApi->isLiveMode() || $password_protection['inPreviewMode'] && $rootApi->isPreviewMode()) {
                $currentPageId = $nav->getCurrentPageId();
                $protectedPage = $password_protection['protectedPage'];
                $parentPages = $nav->getNavigatorIds($currentPageId);
                if (in_array($protectedPage, $parentPages) || $protectedPage == '') {
                    $validLogin = $this->authenticate($password_protection['loginPasswords']);
                    if (!$validLogin) {
                        exit;
                    }
                }
            }
        }
        // error reporting
        if ($rootApi->isEditMode() && $rootApi->getFormValue($rootUnit, 'debugShowPhpErrors')) {
            error_reporting(E_ALL);
            ini_set('display_errors', true);
        }
        // session TODO: remove?
        if (!$rootApi->isEditMode()) {
            if ($rootApi->getFormValue($rootUnit, 'enablePHPSession') && !isset($_SESSION)) {
                session_start();
            }
        }
        // start output
        echo '<!DOCTYPE html>';
        echo "<html lang='{$pageLang}'>";
        echo '<head>';
        // static meta tags
        echo '<meta charset="utf-8">';
        echo '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
        echo '<meta name="viewport" content="initial-scale=1">';
        // favicon and appleTouchIcon
        $this->insertFavicon($rootApi, $rootUnit);
        // title tag and meta description
        $this->insertTitleAndDescription($rootApi, $rootUnit);
        // JS API
        echo $rootApi->isEditMode() ? '<script src="' . $rootApi->getJsApiUrl() . '"></script>' : '';
        // srcset polyfill (load before modernizer because of the htmlshiv, load before CSS according to doc)
        // http://caniuse.com/#feat=srcset (Safari, Android 4.x, Firefox)
        echo <<<EOF
    <script>
    if(!window.HTMLPictureElement){
      document.createElement('picture');
      function loadJS(u){var r = document.getElementsByTagName( "script" )[ 0 ], s = document.createElement( "script" );s.src = u;r.parentNode.insertBefore( s, r );}
      loadJS('{$moduleInfo->getAssetUrl('js/respimage.js')}');
    }
    </script>
EOF;
        // CSS Assets (static css files via <link>)
        $this->insertCssAssets($moduleData);
        // Dynamic CSS (only in edit mode - see css for live mode)
        if ($rootApi->isEditMode()) {
            $dynCss = $this->getDynCSSLib($moduleInfo);
            $dynCss->generateCSS($rootApi, $rootUnit, true);
            // Selectors Data (TODO: this could be also accessed by CMS.getCustomData(moduleId).selectors ?)
            echo '<script type="text/x-text-json" id="available_selectors">';
            echo $this->insertSelectorsJson($moduleData);
            echo '</script>';
        } else {
            echo '<link rel="stylesheet" type="text/css" href="' . $rootApi->getCssUrl() . '">';
        }
        //
        // JS
        //
        // responsive images
        if (!$rootApi->isEditMode()) {
            echo "<script>window.lazySizesConfig = { preloadAfterLoad: !(/mobi/i.test(navigator.userAgent)) };</script>";
        }
        echo "<script src='{$moduleInfo->getAssetUrl('js/lazysizes.js')}' async=''></script>";
        echo "<script src='{$moduleInfo->getAssetUrl('js/ls.progressive.js')}' async=''></script>";
        // modernizer for feature detection (and htmlshiv)
        echo "<script src='{$moduleInfo->getAssetUrl('js/modernizer.js')}'></script>";
        // insert jquery here, so it's already available in body
        echo "<script src='{$moduleInfo->getAssetUrl('js/jquery-2.1.4.js')}'></script>";
        // HTML/CSS polyfills
        if (!$rootApi->isEditMode()) {
            // vw/vh css units (http://caniuse.com/#feat=viewport-units)
            // Polyfill "prefixfree.viewport-units": modified to support browser resize
            echo "<script>Modernizr.load({test: Modernizr.cssvwunit && Modernizr.cssvhunit, nope: ['{$moduleInfo->getAssetUrl('js/prefixfree.stylefix.js')}', '{$moduleInfo->getAssetUrl('js/prefixfree.viewport-units.js')}']});</script>";
        }
        // HTML HEAD HOOK (provided by children)
        $this->insertHtmlHead($moduleData, $unitData);
        echo '</head>';
        // Body
        $rootClasses = array();
        if ($rootApi->isTemplate()) {
            $rootClasses[] = 'isTemplate';
        }
        echo '<body id="' . $rootUnit->getId() . '" class="' . implode(' ', $rootClasses) . '">';
        // CONTENT (child modules of the root module)
        $rootApi->renderChildren($rootUnit);
        // JS Assets (load after DOM)
        $this->insertJsAssets($moduleData);
        $this->insertJsModules($moduleData, $moduleInfo, $rootApi->isEditMode());
        // HTML BOTTOM HOOK (provided by children)
        $this->insertHtmlBottom($moduleData);
        // CSS Error Console
        if (isset($dynCss) && $rootApi->isEditMode() && $rootApi->getFormValue($rootUnit, 'debugShowDynCssErrors')) {
            $this->insertCssErrorPanel($dynCss->getErrors());
        }
        echo '</body>';
        echo '</html>';
    }
示例#7
0
 /**
  * @param \Render\APIs\APIv1\RenderAPI $api
  * @param \Render\Unit $unit
  */
 protected function insertMissingInputHint($api, $unit)
 {
     // only available in edit mode
     if (!$api->isEditMode()) {
         return;
     }
     $isPage = $api->isPage();
     $isGhostContainer = $unit->isGhostContainer();
     $isEmpty = true;
     // check if this module contains any other module which is not a extension module
     // if we have children, search for non extension modules
     $children = $api->getChildren($unit);
     foreach ($children as $nextUnit) {
         if (!$api->getModuleInfo($nextUnit)->isExtension()) {
             $isEmpty = false;
             break;
         }
     }
     $html = '';
     // module has no children and we are not in page mode
     if ($isEmpty && !$isPage) {
         $html = '<div class="RUKZUKemptyBox"></div>';
     } else {
         if ($isPage && $isGhostContainer) {
             $id = $unit->getId();
             $i18n = new Translator($api, $api->getModuleInfo($unit));
             $title = $i18n->translate('button.missingInputHintTitle', 'Click to insert module');
             $html .= '<div class="' . ($isEmpty ? ' RUKZUKemptyBox' : 'RUKZUKaddModuleBox') . '">';
             $html .= '	<div class="RUKZUKmissingInputHint">';
             $html .= '	  <div>';
             $html .= '		<button class="add" onclick="javascript:CMS.openInsertWindow(\'' . $id . '\', 0);" title="' . $title . '"></button>';
             $html .= '	  </div>';
             $html .= '	</div>';
             $html .= '</div>';
         }
     }
     echo $html;
 }
 /**
  * @param \Render\APIs\APIv1\Page $page
  * @param Translator $i18n
  * @return mixed
  */
 private function getDescription($page, $i18n)
 {
     return $this->isTemplateId($page->getPageId()) ? $i18n->translate('placeholder.pageDescription') . ' - Lorem ipsum dolor sit amet, eos ea soleat causae.' : $page->getDescription();
 }
示例#9
0
 /**
  * @param Cart       $cart
  * @param Translator $i18n
  */
 protected function addTemplateFakeData($cart, $i18n)
 {
     $cart->add(new CartItem(array('name' => $i18n->translate('fake.cartItem1.name'), 'pageId' => null, 'price' => 100, 'tax' => 19, 'variant' => null)));
     $cart->add(new CartItem(array('name' => $i18n->translate('fake.cartItem2.name'), 'pageId' => null, 'price' => 150, 'tax' => 27, 'variant' => null)));
     $cart->add(new CartItem(array('name' => $i18n->translate('fake.cartItem3.name'), 'pageId' => null, 'price' => 200, 'tax' => 38, 'variant' => null)));
 }