/**
  * Parse the newsletter
  * @author      Cloudrexx AG
  * @author      Stefan Heinemann <*****@*****.**>
  * @param       string $userType Which type the user has (newsletter or access)
  */
 function ParseNewsletter($subject, $content_text, $TemplateSource, $format, $TargetEmail, $userData, $NewsletterID, $testDelivery = false)
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     $NewsletterBody = '';
     $codeResult = $objDatabase->Execute('SELECT `code` FROM `' . DBPREFIX . 'module_newsletter_tmp_sending` WHERE `newsletter` = ' . $NewsletterID . ' AND `email` = "' . $userData['email'] . '"');
     $code = $codeResult->fields['code'];
     // TODO: replace with new methode $this->GetBrowserViewURL()
     $browserViewUrl = ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . '/' . \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID) . '/index.php?section=Newsletter&cmd=displayInBrowser&standalone=true&code=' . $code . '&email=' . $userData['email'] . '&id=' . $NewsletterID;
     if ($format == 'text') {
         $NewsletterBody = $_ARRAYLANG['TXT_NEWSLETTER_BROWSER_VIEW'] . "\n" . $browserViewUrl;
         return $NewsletterBody;
     }
     $country = empty($userData['country_id']) ? '' : htmlentities(\FWUser::getFWUserObject()->objUser->objAttribute->getById('country_' . $userData['country_id'])->getName(), ENT_QUOTES, CONTREXX_CHARSET);
     switch ($userData['sex']) {
         case 'm':
             $sex = $_ARRAYLANG['TXT_NEWSLETTER_MALE'];
             break;
         case 'f':
             $sex = $_ARRAYLANG['TXT_NEWSLETTER_FEMALE'];
             break;
         default:
             $sex = '';
             break;
     }
     switch ($userData['type']) {
         case self::USER_TYPE_ACCESS:
         case self::USER_TYPE_CORE:
             $realUser = true;
             break;
         case self::USER_TYPE_NEWSLETTER:
         default:
             $realUser = false;
             break;
     }
     // lets prepare all links for tracker before we replace placeholders
     // TODO: migrate tracker to new URL-format
     $content_text = self::prepareNewsletterLinksForSend($NewsletterID, $content_text, $userData['id'], $realUser);
     $search = array('[[email]]', '[[sex]]', '[[salutation]]', '[[title]]', '[[firstname]]', '[[lastname]]', '[[position]]', '[[company]]', '[[industry_sector]]', '[[address]]', '[[city]]', '[[zip]]', '[[country]]', '[[phone_office]]', '[[phone_private]]', '[[phone_mobile]]', '[[fax]]', '[[birthday]]', '[[website]]');
     $replace = array($userData['email'], $sex, $userData['salutation'], $userData['title'], $userData['firstname'], $userData['lastname'], $userData['position'], $userData['company'], $userData['industry_sector'], $userData['address'], $userData['city'], $userData['zip'], $country, $userData['phone_office'], $userData['phone_private'], $userData['phone_mobile'], $userData['fax'], $userData['birthday'], $userData['website']);
     if ($testDelivery) {
         $replace = $search;
     }
     // do the replacement
     $content_text = str_replace($search, $replace, $content_text);
     $TemplateSource = str_replace($search, $replace, $TemplateSource);
     $search = array('[[display_in_browser_url]]', '[[profile_setup]]', '[[unsubscribe]]', '[[date]]', '[[subject]]');
     $replace = array($browserViewUrl, $this->GetProfileURL($userData['code'], $TargetEmail, $userData['type']), $this->GetUnsubscribeURL($userData['code'], $TargetEmail, $userData['type']), date(ASCMS_DATE_FORMAT_DATE), $subject);
     // Replace the links in the content
     $content_text = str_replace($search, $replace, $content_text);
     // replace the links in the template
     $TemplateSource = str_replace($search, $replace, $TemplateSource);
     // i believe this replaces image paths...
     $allImg = array();
     preg_match_all('/src="([^"]*)"/', $content_text, $allImg, PREG_PATTERN_ORDER);
     $size = sizeof($allImg[1]);
     $i = 0;
     while ($i < $size) {
         $URLforReplace = $allImg[1][$i];
         $replaceUrl = new \Cx\Core\Routing\Url($URLforReplace, true);
         if ($replaceUrl->isInternal()) {
             $ReplaceWith = $replaceUrl->toString();
         } else {
             $ReplaceWith = $URLforReplace;
         }
         $content_text = str_replace('"' . $URLforReplace . '"', '"' . $ReplaceWith . '"', $content_text);
         $i++;
     }
     // Set HTML height and width attributes for img-tags
     $allImgsWithHeightOrWidth = array();
     preg_match_all('/<img[^>]*style=(["\'])[^\\1]*(?:width|height):\\s*[^;\\1]+;?\\s*[^\\1]*\\1[^>]*>/', $content_text, $allImgsWithHeightOrWidth);
     foreach ($allImgsWithHeightOrWidth as $img) {
         $htmlHeight = $this->getAttributeOfTag($img, 'img', 'height');
         $htmlWidth = $this->getAttributeOfTag($img, 'img', 'width');
         // no need to proceed if attributes are already set
         if (!empty($htmlHeight) && !empty($htmlWidth)) {
             continue;
         }
         $cssHeight = $this->getCssAttributeOfTag($img, 'img', 'height');
         $cssWidth = $this->getCssAttributeOfTag($img, 'img', 'width');
         // no need to proceed if we have no values to set
         if (empty($cssHeight) && empty($cssWidth)) {
             continue;
         }
         $imgOrig = $img;
         // set height and width attributes (if not yet set)
         if (empty($htmlHeight) && !empty($cssHeight)) {
             $img = $this->setAttributeOfTag($img, 'img', 'height', $cssHeight);
         }
         if (empty($htmlWidth) && !empty($cssWidth)) {
             $img = $this->setAttributeOfTag($img, 'img', 'width', $cssWidth);
         }
         $content_text = str_replace($imgOrig, $img, $content_text);
     }
     $NewsletterBody = str_replace("[[content]]", $content_text, $TemplateSource);
     return $NewsletterBody;
 }
示例#2
0
 /**
  * Returs a string representing the complete paging HTML code for the
  * current page
  * @author  Reto Kohli <*****@*****.**> (Rewritten statically)
  * @access  public
  * @global  array     $_CONFIG        Configuration
  * @global  array     $_CORELANG      Core language
  * @param   string    $uri_parameter  Optional additional URI parameters,
  *                                    *MUST* start with an URI encoded
  *                                    ampersand (&amp;).  By reference
  * @param   string    $paging_text    The text to be put in front of the
  *                                    paging
  * @param   integer   $numof_rows     The number of rows available
  * @param   integer   $results_per_page   The optional maximum number of
  *                                    rows to be shown on a single page.
  *                                    Defaults to the corePagingLimit
  *                                    setting.
  * @param   boolean   $showeverytime  If true, the paging is shown even if
  *                                    $numof_rows is less than
  *                                    $results_per_page
  * @param   integer   $position       The optional starting position
  *                                    offset.  Defaults to null
  * @param   string    $parameter_name The optional name for the URI
  *                                    parameter.  Will be determined
  *                                    automatically if empty.
  * @return  string                    HTML code for the paging
  */
 static function get(&$uri_parameter, $paging_text, $numof_rows, $results_per_page = 0, $showeverytime = false, $position = null, $parameter_name = null)
 {
     global $_CONFIG, $_CORELANG;
     if (empty($results_per_page)) {
         $results_per_page = intval($_CONFIG['corePagingLimit']);
     }
     if ($numof_rows <= $results_per_page && !$showeverytime) {
         return '';
     }
     $parameter_name = self::getParametername($parameter_name);
     if (!isset($position)) {
         $position = self::getPosition($parameter_name);
     }
     // Fix illegal values:
     // The position must be in the range [0 .. numof_rows - 1].
     // If it's outside this range, reset it
     if ($position < 0 || $position >= $numof_rows) {
         $position = 0;
     }
     // Total number of pages: [1 .. n]
     $numof_pages = ceil($numof_rows / $results_per_page);
     // Current page number: [1 .. numof_pages]
     $page_number = 1 + intval($position / $results_per_page);
     $corr_value = $results_per_page;
     if ($numof_rows % $results_per_page) {
         $corr_value = $numof_rows % $results_per_page;
     }
     // remove all parameters otherwise the url object has parameters like &act=add
     $requestUrl = clone \Env::get('Resolver')->getUrl();
     $currentParams = $requestUrl->getParamArray();
     $requestUrl->removeAllParams();
     if (isset($currentParams['section'])) {
         $requestUrl->setParam('section', $currentParams['section']);
     }
     $requestUrl->setParams($uri_parameter);
     $firstUrl = clone $requestUrl;
     $firstUrl->setParam($parameter_name, 0);
     $lastUrl = clone $requestUrl;
     $lastUrl->setParam($parameter_name, $numof_rows - $corr_value);
     // Set up the base navigation entries
     $array_paging = array('first' => '<a class="pagingFirst" href="' . Cx\Core\Routing\Url::encode_amp($firstUrl) . '">', 'last' => '<a class="pagingLast" href="' . Cx\Core\Routing\Url::encode_amp($lastUrl) . '">', 'total' => $numof_rows, 'lower' => $numof_rows ? $position + 1 : 0, 'upper' => $numof_rows);
     if ($position + $results_per_page < $numof_rows) {
         $array_paging['upper'] = $position + $results_per_page;
     }
     // Note:  previous/next link are currently unused.
     if ($position != 0) {
         $previousUrl = clone $requestUrl;
         $previousUrl->setParam($parameter_name, $position - $results_per_page);
         $array_paging['previous_link'] = '<a href="' . Cx\Core\Routing\Url::encode_amp($previousUrl) . '">';
     }
     if ($numof_rows - $position > $results_per_page) {
         $int_new_position = $position + $results_per_page;
         $nextUrl = clone $requestUrl;
         $nextUrl->setParam($parameter_name, $int_new_position);
         $array_paging['next_link'] = '<a href="' . Cx\Core\Routing\Url::encode_amp($nextUrl) . '">';
     }
     // Add single pages, indexed by page numbers [1 .. numof_pages]
     for ($i = 1; $i <= $numof_pages; ++$i) {
         if ($i == $page_number) {
             $array_paging[$i] = '<b class="pagingPage' . $i . '">' . $i . '</b>';
         } else {
             $pageUrl = clone $requestUrl;
             $pageUrl->setParam($parameter_name, ($i - 1) * $results_per_page);
             $array_paging[$i] = '<a class="pagingPage' . $i . '" href="' . Cx\Core\Routing\Url::encode_amp($pageUrl) . '">' . $i . '</a>';
         }
     }
     $paging = $paging_text . '&nbsp;<span class="pagingLower">' . $array_paging['lower'] . '</span>&nbsp;' . $_CORELANG['TXT_TO'] . '&nbsp;<span class="pagingUpper">' . $array_paging['upper'] . '</span>&nbsp;' . $_CORELANG['TXT_FROM'] . '&nbsp;<span class="pagingTotal">' . $array_paging['total'] . '</span>';
     if ($numof_pages) {
         $paging .= '&nbsp;&nbsp;[&nbsp;' . $array_paging['first'] . '&lt;&lt;</a>&nbsp;&nbsp;' . '<span class="pagingPages">';
     }
     if ($page_number > 3) {
         $paging .= $array_paging[$page_number - 3] . '&nbsp;';
     }
     if ($page_number > 2) {
         $paging .= $array_paging[$page_number - 2] . '&nbsp;';
     }
     if ($page_number > 1) {
         $paging .= $array_paging[$page_number - 1] . '&nbsp;';
     }
     if ($numof_pages) {
         $paging .= $array_paging[$page_number] . '&nbsp;';
     }
     if ($page_number < $numof_pages - 0) {
         $paging .= $array_paging[$page_number + 1] . '&nbsp;';
     }
     if ($page_number < $numof_pages - 1) {
         $paging .= $array_paging[$page_number + 2] . '&nbsp;';
     }
     if ($page_number < $numof_pages - 2) {
         $paging .= $array_paging[$page_number + 3] . '&nbsp;';
     }
     if ($numof_pages) {
         $paging .= '</span>&nbsp;' . $array_paging['last'] . '&gt;&gt;</a>&nbsp;]';
     }
     return $paging;
 }
 /**
  * Creates and returns the HTML form for initialising the
  * Postfinance Mobile payment.
  *
  * Fields:
  *  - Mandatory:
  *      currency    ISO 4217 currency code (only CHF for the time being)
  *      amount      Amount in cents (2.50 CHF = 250)
  *      orderid     Unique order ID
  *      webuser     The Mobilesolutions webuser name
  *      sign        SHA-1 Signature
  *      urlsuccess  Target URL after successful payment
  *      urlerror    Target URL after failed payment
  *  - Optional:
  *      customparam     Parameters to be appended to the success or error URL
  *      ijustwanttotest Enables the test mode if present
  * @param   integer   $amount           The order amount in cents
  * @param   integer   $order_id         The order ID
  * @param   string    $customparam      The optional custom parameter(s)
  * @param   boolean   $ijustwanttotest  Enable test mode if true
  * @return  mixed                       The HTML form on success, false
  *                                      otherwise
  * @static
  */
 static function getForm($amount, $order_id, $customparam = '', $ijustwanttotest = null)
 {
     global $_ARRAYLANG, $_CONFIG;
     if (!isset($ijustwanttotest)) {
         $ijustwanttotest = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_ijustwanttotest', 'Shop');
     }
     if (empty($amount)) {
         self::$arrError[] = sprintf($_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_INVALID_AMOUNT'], $amount);
         return false;
     }
     if (empty($order_id)) {
         self::$arrError[] = sprintf($_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_INVALID_ORDER_ID'], $order_id);
         return false;
     }
     $currency = \Cx\Modules\Shop\Controller\Currency::getActiveCurrencyCode();
     if (empty($currency)) {
         self::$arrError[] = $_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_FAILED_TO_DETERMINE_ACTIVE_CURRENCY'];
         return false;
     }
     $webuser = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_webuser', 'Shop');
     if (empty($webuser)) {
         self::$arrError[] = $_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_FAILED_TO_DETERMINE_WEBUSER'];
         return false;
     }
     $sign = \Cx\Core\Setting\Controller\Setting::getValue('postfinance_mobile_sign', 'Shop');
     if (empty($sign)) {
         self::$arrError[] = $_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_ERROR_FAILED_TO_DETERMINE_SIGNATURE'];
         return false;
     }
     $signature = hash_hmac('sha1', $amount . $currency . $order_id . $webuser, pack('H*', $sign));
     $urlsuccess = Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success')->toString() . '?handler=mobilesolutions&amp;result=1' . '&amp;order_id=' . $order_id;
     $urlerror = Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'success')->toString() . '?handler=mobilesolutions&amp;result=0' . '&amp;order_id=' . $order_id;
     /*
     Live URIs:
     https://postfinance.mobilesolutions.ch/webshop/handyzahlung
     http://api.smsserv.ch/webshop/handyzahlung
     
     Test URIs:
     https://postfinance.mobilesolutions.ch/shoptest/handyzahlung
     http://api.smsserv.ch/shoptest/handyzahlung
     
     On the testing environment, use the flag "ijustwanttotest", the mobile
     phone number 079 999 99 99, and the security code 12345678 to enforce
     a successful payment.  Any other numbers will produce a failed transaction.
     */
     return $_ARRAYLANG['TXT_ORDER_LINK_PREPARED'] . "<br/><br/>\n" . '<form name="postfinancemobile" method="post" ' . 'action="' . ($ijustwanttotest ? 'https://postfinance.mobilesolutions.ch/shoptest/handyzahlung' : 'https://postfinance.mobilesolutions.ch/webshop/handyzahlung') . '">' . "\n" . '<input type="hidden" name="currency" value="' . $currency . '" />' . "\n" . '<input type="hidden" name="amount" value="' . $amount . '" />' . "\n" . '<input type="hidden" name="orderid" value="' . $order_id . '" />' . "\n" . '<input type="hidden" name="webuser" value="' . $webuser . '" />' . "\n" . '<input type="hidden" name="sign" value="' . $signature . '" />' . "\n" . '<input type="hidden" name="urlsuccess" value="' . $urlsuccess . '" />' . "\n" . '<input type="hidden" name="urlerror" value="' . $urlerror . '" />' . "\n" . ($customparam ? '<input type="hidden" name="customparam" value="' . urlencode($customparam) . '" />' . "\n" : '') . ($ijustwanttotest ? '<input type="hidden" name="ijustwanttotest" value="1" />' . "\n" : '') . '<input type="submit" name="bsubmit" value="' . $_ARRAYLANG['TXT_SHOP_POSTFINANCE_MOBILE_SUBMIT'] . '" />' . "\n" . '</form>' . "\n";
 }
 /**
  * Check if the page is module or content page
  * 
  * @param string $url requested url
  * 
  * @return boolean|object
  */
 public function isModulePage($url)
 {
     try {
         $url = new \Cx\Core\Routing\Url($url);
         $path = $url->getSuggestedTargetPath();
     } catch (\Exception $e) {
         $path = '';
     }
     $result = $this->pageRepo->getPagesAtPath($this->langName . '/' . $path, null, $this->langId, false, \Cx\Core\ContentManager\Model\Repository\PageRepository::SEARCH_MODE_PAGES_ONLY);
     if ($result['page']) {
         return $result['page'];
     }
     return false;
 }
    /**
     * 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;
    }
 /**
  * Get the page object by url
  * 
  * @param string $url requested url
  *
  * @return boolean|object
  */
 public function getPageByUrl($url)
 {
     $objUrl = new \Cx\Core\Routing\Url($url);
     $result = $this->pageRepo->getPagesAtPath($this->langName . '/' . $objUrl->getSuggestedTargetPath(), null, $this->langId, false);
     if ($result['page']) {
         return $result['page'];
     }
     return false;
 }
示例#7
0
 /**
  * Sets the base URI
  * @param   string    $uri      The URI
  */
 function setUri($uri)
 {
     // Remove the order parameter name argument from the base URI
     Html::stripUriParam($uri, $this->orderUriParameter);
     $this->baseUri = Cx\Core\Routing\Url::encode_amp($uri);
 }
示例#8
0
 /**
  * Returs a string representing the complete paging HTML code for the
  * current page
  * @author  Reto Kohli <*****@*****.**> (Rewritten statically)
  * @access  public
  * @global  array     $_CONFIG        Configuration
  * @global  array     $_CORELANG      Core language
  * @param   string    $uri_parameter  Optional additional URI parameters,
  *                                    *MUST* start with an URI encoded
  *                                    ampersand (&amp;).  By reference
  * @param   string    $paging_text    The text to be put in front of the
  *                                    paging
  * @param   integer   $numof_rows     The number of rows available
  * @param   integer   $results_per_page   The optional maximum number of
  *                                    rows to be shown on a single page.
  *                                    Defaults to the corePagingLimit
  *                                    setting.
  * @param   boolean   $showeverytime  If true, the paging is shown even if
  *                                    $numof_rows is less than
  *                                    $results_per_page
  * @param   integer   $position       The optional starting position
  *                                    offset.  Defaults to null
  * @param   string    $parameter_name The optional name for the URI
  *                                    parameter.  Will be determined
  *                                    automatically if empty.
  * @return  string                    HTML code for the paging
  */
 static function get(&$uri_parameter, $paging_text, $numof_rows, $results_per_page = 0, $showeverytime = false, $position = null, $parameter_name = null)
 {
     global $_CONFIG, $_CORELANG;
     $headIncludes = array();
     if (empty($results_per_page)) {
         $results_per_page = intval($_CONFIG['corePagingLimit']);
     }
     if ($numof_rows <= $results_per_page && !$showeverytime) {
         return '';
     }
     $parameter_name = self::getParametername($parameter_name);
     if (!isset($position)) {
         $position = self::getPosition($parameter_name);
     }
     // Fix illegal values:
     // The position must be in the range [0 .. numof_rows - 1].
     // If it's outside this range, reset it
     if ($position < 0 || $position >= $numof_rows) {
         $position = 0;
     }
     // Total number of pages: [1 .. n]
     $numof_pages = ceil($numof_rows / $results_per_page);
     // Current page number: [1 .. numof_pages]
     $page_number = 1 + intval($position / $results_per_page);
     $corr_value = $results_per_page;
     if ($numof_rows % $results_per_page) {
         $corr_value = $numof_rows % $results_per_page;
     }
     // remove all parameters otherwise the url object has parameters like &act=add
     $requestUrl = clone \Env::get('Resolver')->getUrl();
     $currentParams = $requestUrl->getParamArray();
     $requestUrl->removeAllParams();
     if (isset($currentParams['section'])) {
         $requestUrl->setParam('section', $currentParams['section']);
     }
     $requestUrl->setParams($uri_parameter);
     $firstUrl = clone $requestUrl;
     $firstUrl->setParam($parameter_name, 0);
     $lastUrl = clone $requestUrl;
     $lastUrl->setParam($parameter_name, $numof_rows - $corr_value);
     // Set up the base navigation entries
     $array_paging = array('first' => '<a class="pagingFirst" href="' . Cx\Core\Routing\Url::encode_amp($firstUrl) . '" rel="nofollow">', 'last' => '<a class="pagingLast" href="' . Cx\Core\Routing\Url::encode_amp($lastUrl) . '" rel="nofollow">', 'total' => $numof_rows, 'lower' => $numof_rows ? $position + 1 : 0, 'upper' => $numof_rows);
     if ($position + $results_per_page < $numof_rows) {
         $array_paging['upper'] = $position + $results_per_page;
     }
     // Note:  previous/next link are currently unused.
     if ($position != 0) {
         $previousUrl = clone $requestUrl;
         $previousUrl->setParam($parameter_name, $position - $results_per_page);
         $array_paging['previous_link'] = '<a href="' . Cx\Core\Routing\Url::encode_amp($previousUrl) . '">';
         $link = new \Cx\Core\Html\Model\Entity\HtmlElement('link');
         $link->setAttribute('href', $previousUrl->toString());
         $link->setAttribute('rel', 'prev');
         $headIncludes[] = $link;
     }
     if ($numof_rows - $position > $results_per_page) {
         $int_new_position = $position + $results_per_page;
         $nextUrl = clone $requestUrl;
         $nextUrl->setParam($parameter_name, $int_new_position);
         $array_paging['next_link'] = '<a href="' . Cx\Core\Routing\Url::encode_amp($nextUrl) . '">';
         $link = new \Cx\Core\Html\Model\Entity\HtmlElement('link');
         $link->setAttribute('href', $nextUrl->toString());
         $link->setAttribute('rel', 'next');
         $headIncludes[] = $link;
     }
     // TODO: This is a temporary solution for setting HEAD_INCLUDES.
     //       The proper and correct way will by handled by the
     //       upcoming implementation of the response object.
     if ($headIncludes) {
         \Cx\Core\Core\Controller\Cx::instanciate()->getTemplate()->setVariable('HEAD_INCLUDES', join("\n", $headIncludes));
     }
     // Add single pages, indexed by page numbers [1 .. numof_pages]
     for ($i = 1; $i <= $numof_pages; ++$i) {
         if ($i == $page_number) {
             $array_paging[$i] = '<b class="pagingPage' . $i . '">' . $i . '</b>';
         } else {
             $pageUrl = clone $requestUrl;
             $pageUrl->setParam($parameter_name, ($i - 1) * $results_per_page);
             $array_paging[$i] = '<a class="pagingPage' . $i . '" href="' . Cx\Core\Routing\Url::encode_amp($pageUrl) . '">' . $i . '</a>';
         }
     }
     $paging = $paging_text . '&nbsp;<span class="pagingLower">' . $array_paging['lower'] . '</span>&nbsp;' . $_CORELANG['TXT_TO'] . '&nbsp;<span class="pagingUpper">' . $array_paging['upper'] . '</span>&nbsp;' . $_CORELANG['TXT_FROM'] . '&nbsp;<span class="pagingTotal">' . $array_paging['total'] . '</span>';
     if ($numof_pages) {
         $paging .= '&nbsp;&nbsp;[&nbsp;' . $array_paging['first'] . '&lt;&lt;</a>&nbsp;&nbsp;' . '<span class="pagingPages">';
     }
     if ($page_number > 3) {
         $paging .= $array_paging[$page_number - 3] . '&nbsp;';
     }
     if ($page_number > 2) {
         $paging .= $array_paging[$page_number - 2] . '&nbsp;';
     }
     if ($page_number > 1) {
         $paging .= $array_paging[$page_number - 1] . '&nbsp;';
     }
     if ($numof_pages) {
         $paging .= $array_paging[$page_number] . '&nbsp;';
     }
     if ($page_number < $numof_pages - 0) {
         $paging .= $array_paging[$page_number + 1] . '&nbsp;';
     }
     if ($page_number < $numof_pages - 1) {
         $paging .= $array_paging[$page_number + 2] . '&nbsp;';
     }
     if ($page_number < $numof_pages - 2) {
         $paging .= $array_paging[$page_number + 3] . '&nbsp;';
     }
     if ($numof_pages) {
         $paging .= '</span>&nbsp;' . $array_paging['last'] . '&gt;&gt;</a>&nbsp;]';
     }
     return $paging;
 }
    /**
     * 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;
    }
示例#10
0
 /**
  * Creates and returns the HTML Form for requesting the payment service.
  *
  * The parameters in $uriparam are appended to the base index URI.
  * If empty, this defaults to "section=Shop&cmd=success".
  *
  * @access  public
  * @global  array       $_ARRAYLANG
  * @param   array       $arrFields      The parameter array
  * @param   string      $submitValue    The optional label for the submit button
  * @param   boolean     $autopost       If true, the form is automatically submitted. Defaults to false.
  * @param   array       $arrSettings    Settings from \Cx\Core\Setting
  * @param   object      $landingPage    The optional URI parameter string
  * @return  string                      The HTML form code
  */
 static function getForm($arrFields, $submitValue = 'Send', $autopost = false, $arrSettings = null, $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.';
     }
     if (empty($arrSettings)) {
         $settingDb = \Cx\Core\Setting\Controller\Setting::getArray(self::$sectionName, 'config');
         if (!empty($settingDb) && $settingDb['postfinance_active']['value']) {
             $arrSettings = $settingDb;
         } else {
             self::$arrError[] = "Could not load settings.";
         }
     }
     if (empty($arrFields['PSPID'])) {
         $arrFields['PSPID'] = $arrSettings['postfinance_shop_id']['value'];
     }
     if (empty($arrFields['OPERATION'])) {
         $arrFields['OPERATION'] = $arrSettings['postfinance_authorization_type']['value'];
     }
     if (empty($arrFields['LANGUAGE'])) {
         $arrFields['LANGUAGE'] = strtolower(FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID)) . '_' . strtoupper(FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID));
     }
     $baseUri = Cx\Core\Routing\Url::fromPage($landingPage)->toString() . '?result=';
     if (empty($arrFields['ACCEPTURL'])) {
         $arrFields['ACCEPTURL'] = $baseUri . '1';
     }
     if (empty($arrFields['DECLINEURL'])) {
         $arrFields['DECLINEURL'] = $baseUri . '2';
     }
     if (empty($arrFields['EXCEPTIONURL'])) {
         $arrFields['EXCEPTIONURL'] = $baseUri . '2';
     }
     if (empty($arrFields['CANCELURL'])) {
         $arrFields['CANCELURL'] = $baseUri . '0';
     }
     if (empty($arrFields['BACKURL'])) {
         $arrFields['BACKURL'] = $baseUri . '2';
     }
     if (!self::setFields($arrFields)) {
         self::$arrError[] = 'Failed to verify keys.';
         return false;
     }
     $arrFields['SHASIGN'] = self::signature($arrFields, $arrSettings['postfinance_hash_signature_in']['value']);
     $server = $arrSettings['postfinance_use_testserver']['value'] ? 'test' : 'prod';
     $charset = CONTREXX_CHARSET == 'UTF-8' ? '_utf8' : '';
     $hiddenFields = '';
     foreach ($arrFields as $name => $value) {
         $hiddenFields .= Html::getHidden($name, $value);
     }
     $autoSubmit = !$autopost ? '' : '
         <script type="text/javascript">
         /* <![CDATA[ */
             document.yellowpay.submit();
         /* ]]> */
         </script>
     ';
     $form = $_ARRAYLANG['TXT_ORDER_LINK_PREPARED'] . '<br/><br/>' . '<form name="yellowpay" method="post" action="https://e-payment.postfinance.ch/ncol/' . $server . '/orderstandard' . $charset . '.asp">' . $hiddenFields . '<input type="submit" name="go" value="' . $submitValue . '" />' . '</form>' . $autoSubmit;
     return $form;
 }
示例#11
0
 /**
  * Set up the shop page with products and discounts
  *
  * @param   array       $product_ids    The optional array of Product IDs.
  *                                      Overrides any URL parameters if set
  * @return  boolean                     True on success, false otherwise
  * @global  ADONewConnection  $objDatabase    Database connection object
  * @global  array       $_ARRAYLANG     Language array
  * @global  array       $_CONFIG        Core configuration array, see {@link /config/settings.php}
  * @global  string(?)   $themesPages    Themes pages(?)
  */
 static function view_product_overview($product_ids = null)
 {
     global $_ARRAYLANG;
     // activate javascript shadowbox
     \JS::activate('shadowbox');
     $flagSpecialoffer = intval(\Cx\Core\Setting\Controller\Setting::getValue('show_products_default', 'Shop'));
     if (isset($_REQUEST['cmd']) && $_REQUEST['cmd'] == 'discounts') {
         $flagSpecialoffer = Products::DEFAULT_VIEW_DISCOUNTS;
     }
     $flagLastFive = isset($_REQUEST['lastFive']);
     $product_id = isset($_REQUEST['productId']) ? intval($_REQUEST['productId']) : null;
     $cart_id = null;
     if (isset($_REQUEST['referer']) && $_REQUEST['referer'] == 'cart') {
         $cart_id = $product_id;
         $product_id = Cart::get_product_id($cart_id);
     }
     $manufacturer_id = isset($_REQUEST['manufacturerId']) ? intval($_REQUEST['manufacturerId']) : null;
     $term = isset($_REQUEST['term']) ? trim(contrexx_input2raw($_REQUEST['term'])) : null;
     $category_id = isset($_REQUEST['catId']) ? intval($_REQUEST['catId']) : null;
     if (!($product_id || $category_id || $manufacturer_id || $term || $cart_id)) {
         // NOTE: This is different from NULL
         // in that it enables listing the subcategories
         $category_id = 0;
     }
     // Validate parameters
     if ($product_id && empty($category_id)) {
         $objProduct = Product::getById($product_id);
         if ($objProduct && $objProduct->active()) {
             $category_id = $objProduct->category_id();
         } else {
             \CSRF::redirect(Cx\Core\Routing\Url::fromModuleAndCmd('shop', ''));
         }
         if (isset($_SESSION['shop']['previous_category_id'])) {
             $category_id_previous = $_SESSION['shop']['previous_category_id'];
             foreach (preg_split('/\\s*,\\s*/', $category_id) as $id) {
                 if ($category_id_previous == intval($id)) {
                     $category_id = $category_id_previous;
                 }
             }
         }
     }
     // Remember visited Products
     if ($product_id) {
         self::rememberVisitedProducts($product_id);
     }
     $objCategory = null;
     if ($category_id && empty($product_id)) {
         $objCategory = ShopCategory::getById($category_id);
         if (!$objCategory) {
             $category_id = null;
         }
     }
     $shopMenu = '<form method="post" action="' . \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '') . '">' . '<input type="text" name="term" value="' . htmlentities($term, ENT_QUOTES, CONTREXX_CHARSET) . '" style="width:150px;" />&nbsp;' . '<select name="catId" style="width:150px;">' . '<option value="0">' . $_ARRAYLANG['TXT_ALL_PRODUCT_GROUPS'] . '</option>' . ShopCategories::getMenuoptions($category_id) . '</select>&nbsp;' . Manufacturer::getMenu('manufacturerId', $manufacturer_id, true) . '<input type="submit" name="bsubmit" value="' . $_ARRAYLANG['TXT_SEARCH'] . '" style="width:66px;" />' . '</form>';
     self::$objTemplate->setGlobalVariable($_ARRAYLANG + array('SHOP_MENU' => $shopMenu, 'SHOP_SEARCH_TERM' => htmlentities($term, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_CATEGORIES_MENUOPTIONS' => ShopCategories::getMenuoptions($category_id, true, 0, true), 'SHOP_MANUFACTURER_MENUOPTIONS' => Manufacturer::getMenuoptions($manufacturer_id, true)));
     // Only show the cart info when the JS cart is not active!
     global $_CONFIGURATION;
     if (empty($_CONFIGURATION['custom']['shopJsCart'])) {
         self::$objTemplate->setVariable(array('SHOP_CART_INFO' => self::cart_info()));
     }
     // Exclude Category list from search results
     if ($term == '') {
         self::showCategories($category_id);
     }
     if (self::$objTemplate->blockExists('shopNextCategoryLink')) {
         $nextCat = ShopCategory::getNextShopCategoryId($category_id);
         $objCategory = ShopCategory::getById($nextCat);
         if ($objCategory) {
             self::$objTemplate->setVariable(array('SHOP_NEXT_CATEGORY_ID' => $nextCat, 'SHOP_NEXT_CATEGORY_TITLE' => str_replace('"', '&quot;', $objCategory->name())));
         }
     }
     $pagingCmd = !empty($_REQUEST['cmd']) ? '&amp;cmd=' . contrexx_input2raw($_REQUEST['cmd']) : '';
     $pagingCatId = '';
     $pagingManId = '';
     $pagingTerm = '';
     // TODO: This probably breaks paging in search results!
     // Should only reset the flag conditionally, but add the URL parameters in
     // any case, methinks!
     if ($category_id > 0 && $term == '') {
         $flagSpecialoffer = false;
         $pagingCatId = "&amp;catId={$category_id}";
     }
     if ($manufacturer_id > 0) {
         $flagSpecialoffer = false;
         $pagingManId = "&amp;manufacturer_id={$manufacturer_id}";
     }
     if ($term != '') {
         $flagSpecialoffer = false;
         $pagingTerm = '&amp;term=' . htmlentities($term, ENT_QUOTES, CONTREXX_CHARSET);
     }
     // The Product count is passed by reference and set to the total
     // number of records, though only as many as specified by the core
     // paging limit are returned in the array.
     $limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_products_per_page_frontend', 'Shop');
     //\DBG::activate(DBG_ERROR_FIREPHP);
     // Use Sorting class for the Product order
     $uri = \Html::getRelativeUri_entities();
     $arrOrder = array('product.ord' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_ORD'], 'name' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_TITLE'], 'code' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_CODE'], 'price' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_PRICE'], 'id' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_DATE'], 'bestseller' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_BESTSELLER']);
     $defaultOrder = \Sorting::getFieldindex(Products::$arrProductOrder[\Cx\Core\Setting\Controller\Setting::getValue('product_sorting', 'Shop')]);
     $objSorting = new \Sorting($uri, $arrOrder, true, 'shop_order_products', $defaultOrder);
     //\DBG::log("Sorting headers: ".var_export($objSorting->getHeaderArray(), true));
     $count = $limit;
     $arrProduct = array();
     if ($product_ids) {
         $arrProduct = self::getValidProducts($product_ids);
         $product_id = null;
         // Suppress meta title from single Product
     } elseif ($product_id) {
         $arrProduct = self::getValidProducts(array($product_id));
     } else {
         $arrProduct = Products::getByShopParams($count, \Paging::getPosition(), $product_id, $category_id, $manufacturer_id, $term, $flagSpecialoffer, $flagLastFive, $objSorting->getOrder(), self::$objCustomer && self::$objCustomer->is_reseller());
     }
     // Only show sorting when there's enough to be sorted
     if ($count > 1) {
         $objSorting->parseHeaders(self::$objTemplate, 'shop_product_order');
     }
     if ($count == 0 && !ShopCategories::getChildCategoryIdArray($category_id)) {
         //if ($term != '' || $manufacturer_id != 0 || $flagSpecialoffer) {
         if (self::$objTemplate->blockExists('no_product')) {
             self::$objTemplate->touchBlock('no_product');
         }
         return true;
     }
     if ($objCategory) {
         // Only indicate the category name when there are products
         if ($count) {
             self::$objTemplate->setVariable(array('SHOP_CATEGORY_CURRENT_NAME' => contrexx_raw2xhtml($objCategory->name()), 'SHOP_PRODUCTS_IN_CATEGORY' => sprintf($_ARRAYLANG['TXT_SHOP_PRODUCTS_IN_CATEGORY'], contrexx_raw2xhtml($objCategory->name()))));
         }
     } else {
         // TODO: There are other cases of flag combinations that are not indivuidually
         // handled here yet.
         if ($term == '') {
             if ($flagSpecialoffer == Products::DEFAULT_VIEW_DISCOUNTS) {
                 self::$objTemplate->setVariable('SHOP_PRODUCTS_IN_CATEGORY', $_ARRAYLANG['TXT_SHOP_PRODUCTS_SPECIAL_OFFER']);
             } else {
                 if (self::$objTemplate->blockExists('products_in_category')) {
                     self::$objTemplate->hideBlock('products_in_category');
                 }
             }
         } else {
             self::$objTemplate->setVariable('SHOP_PRODUCTS_IN_CATEGORY', sprintf($_ARRAYLANG['TXT_SHOP_PRODUCTS_SEARCH_RESULTS'], contrexx_raw2xhtml($term)));
         }
     }
     $uri = '&amp;section=Shop' . MODULE_INDEX . $pagingCmd . $pagingCatId . $pagingManId . $pagingTerm;
     self::$objTemplate->setVariable(array('SHOP_PRODUCT_PAGING' => \Paging::get($uri, '', $count, $limit, $count > 0), 'SHOP_PRODUCT_TOTAL' => $count));
     // Global microdata: Seller information
     $seller_url = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '')->toString();
     $seller_name = \Cx\Core\Setting\Controller\Setting::getValue('company', 'Shop');
     if (empty($seller_name)) {
         $seller_name = $seller_url;
     }
     self::$objTemplate->setVariable(array('SHOP_SELLER_NAME' => $seller_name, 'SHOP_SELLER_URL' => $seller_url));
     $formId = 0;
     $arrDefaultImageSize = $arrSize = null;
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     foreach ($arrProduct as $objProduct) {
         if (!empty($product_id)) {
             self::$pageTitle = $objProduct->name();
         }
         $id = $objProduct->id();
         $productSubmitFunction = '';
         $arrPictures = Products::get_image_array_from_base64($objProduct->pictures());
         $havePicture = false;
         $arrProductImages = array();
         foreach ($arrPictures as $index => $image) {
             $thumbnailPath = $pictureLink = '';
             if (empty($image['img']) || $image['img'] == ShopLibrary::noPictureName) {
                 // We have at least one picture on display already.
                 // No need to show "no picture" three times!
                 if ($havePicture) {
                     continue;
                 }
                 $thumbnailPath = self::$defaultImage;
                 $pictureLink = '#';
                 //"javascript:alert('".$_ARRAYLANG['TXT_NO_PICTURE_AVAILABLE']."');";
                 if (empty($arrDefaultImageSize)) {
                     $arrDefaultImageSize = getimagesize($cx->getWebsitePath() . self::$defaultImage);
                     self::scaleImageSizeToThumbnail($arrDefaultImageSize);
                 }
                 $arrSize = $arrDefaultImageSize;
             } else {
                 $thumbnailPath = \ImageManager::getThumbnailFilename($cx->getWebsiteImagesShopWebPath() . '/' . $image['img']);
                 if ($image['width'] && $image['height']) {
                     $pictureLink = contrexx_raw2encodedUrl($cx->getWebsiteImagesShopWebPath() . '/' . $image['img']) . '" rel="shadowbox[' . ($formId + 1) . ']';
                     // Thumbnail display size
                     $arrSize = array($image['width'], $image['height']);
                 } else {
                     $pictureLink = '#';
                     if (!file_exists($cx->getWebsitePath() . $thumbnailPath)) {
                         continue;
                     }
                     $arrSize = getimagesize($cx->getWebsitePath() . $thumbnailPath);
                 }
                 self::scaleImageSizeToThumbnail($arrSize);
                 // Use the first available picture in microdata, if any
                 if (!$havePicture) {
                     $picture_url = \Cx\Core\Routing\Url::fromCapturedRequest($cx->getWebsiteImagesShopWebPath() . '/' . $image['img'], $cx->getWebsiteOffsetPath(), array());
                     self::$objTemplate->setVariable('SHOP_PRODUCT_IMAGE', $picture_url->toString());
                     //\DBG::log("Set image to ".$picture_url->toString());
                 }
             }
             $arrProductImages[] = array('THUMBNAIL' => contrexx_raw2encodedUrl($thumbnailPath), 'THUMBNAIL_SIZE' => $arrSize[3], 'THUMBNAIL_LINK' => $pictureLink, 'POPUP_LINK' => $pictureLink, 'POPUP_LINK_NAME' => $_ARRAYLANG['TXT_SHOP_IMAGE'] . ' ' . $index);
             $havePicture = true;
         }
         $i = 1;
         foreach ($arrProductImages as $arrProductImage) {
             // TODO: Instead of several numbered image blocks, use a single one repeatedly
             self::$objTemplate->setVariable(array('SHOP_PRODUCT_THUMBNAIL_' . $i => $arrProductImage['THUMBNAIL'], 'SHOP_PRODUCT_THUMBNAIL_SIZE_' . $i => $arrProductImage['THUMBNAIL_SIZE']));
             if (!empty($arrProductImage['THUMBNAIL_LINK'])) {
                 self::$objTemplate->setVariable(array('SHOP_PRODUCT_THUMBNAIL_LINK_' . $i => $arrProductImage['THUMBNAIL_LINK'], 'TXT_SEE_LARGE_PICTURE' => $_ARRAYLANG['TXT_SEE_LARGE_PICTURE']));
             } else {
                 self::$objTemplate->setVariable('TXT_SEE_LARGE_PICTURE', contrexx_raw2xhtml($objProduct->name()));
             }
             if ($arrProductImage['POPUP_LINK']) {
                 self::$objTemplate->setVariable('SHOP_PRODUCT_POPUP_LINK_' . $i, $arrProductImage['POPUP_LINK']);
             }
             self::$objTemplate->setVariable('SHOP_PRODUCT_POPUP_LINK_NAME_' . $i, $arrProductImage['POPUP_LINK_NAME']);
             ++$i;
         }
         $stock = $objProduct->stock_visible() ? $_ARRAYLANG['TXT_STOCK'] . ': ' . intval($objProduct->stock()) : '';
         $price = $objProduct->get_custom_price(self::$objCustomer, 0, 1, true);
         // If there is a discountprice and it's enabled
         $discountPrice = '';
         if ($objProduct->discountprice() > 0 && $objProduct->discount_active()) {
             $price = '<s>' . $price . '</s>';
             $discountPrice = $objProduct->get_custom_price(self::$objCustomer, 0, 1, false);
         }
         $groupCountId = $objProduct->group_id();
         $groupArticleId = $objProduct->article_id();
         $groupCustomerId = 0;
         if (self::$objCustomer) {
             $groupCustomerId = self::$objCustomer->group_id();
         }
         self::showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, 1);
         /* OLD
                     $price = Currency::getCurrencyPrice(
                         $objProduct->getCustomerPrice(self::$objCustomer)
                     );
                     $discountPrice = '';
                     $discount_active = $objProduct->discount_active();
                     if ($discount_active) {
                         $discountPrice = $objProduct->discountprice();
                         if ($discountPrice > 0) {
                             $price = "<s>$price</s>";
                             $discountPrice =
                                 Currency::getCurrencyPrice($discountPrice);
                         }
                     }
         */
         $short = $objProduct->short();
         $longDescription = $objProduct->long();
         $detailLink = null;
         // Detaillink is required for microdata (even when longdesc
         // is empty)
         $detail_url = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'details', FRONTEND_LANG_ID, array('productId' => $objProduct->id()))->toString();
         self::$objTemplate->setVariable('SHOP_PRODUCT_DETAIL_URL', $detail_url);
         if (!$product_id && !empty($longDescription)) {
             $detailLink = '<a href="' . $detail_url . '"' . ' title="' . $_ARRAYLANG['TXT_MORE_INFORMATIONS'] . '">' . $_ARRAYLANG['TXT_MORE_INFORMATIONS'] . '</a>';
             self::$objTemplate->setVariable('SHOP_PRODUCT_DETAILLINK', $detailLink);
         }
         // Check Product flags.
         // Only the meter flag is currently implemented and in use.
         $flagMeter = $objProduct->testFlag('__METER__');
         // Submit button name and function.
         // Calling productOptions() also sets the $flagMultipart variable
         // to the appropriate encoding type for the form if
         // any upload fields are in use.
         $flagMultipart = false;
         $productSubmitName = $productSubmitFunction = '';
         if (isset($_GET['cmd']) && $_GET['cmd'] == 'details' && isset($_GET['referer']) && $_GET['referer'] == 'cart') {
             $productSubmitName = "updateProduct[{$cart_id}]";
             $productSubmitFunction = self::productOptions($id, $formId, $cart_id, $flagMultipart);
         } else {
             $productSubmitName = 'addProduct';
             $productSubmitFunction = self::productOptions($id, $formId, $cart_id, $flagMultipart);
         }
         $shopProductFormName = "shopProductForm{$formId}";
         $row = $formId % 2 + 1;
         self::$objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . $row, 'SHOP_PRODUCT_ID' => $objProduct->id(), 'SHOP_PRODUCT_TITLE' => contrexx_raw2xhtml($objProduct->name()), 'SHOP_PRODUCT_DESCRIPTION' => $short, 'SHOP_PRODUCT_DETAILDESCRIPTION' => $longDescription ? $longDescription : $short, 'SHOP_PRODUCT_FORM_NAME' => $shopProductFormName, 'SHOP_PRODUCT_SUBMIT_NAME' => $productSubmitName, 'SHOP_PRODUCT_SUBMIT_FUNCTION' => $productSubmitFunction, 'SHOP_FORM_ENCTYPE' => $flagMultipart ? ' enctype="multipart/form-data"' : '', 'TXT_SHOP_PRODUCT_COUNT' => $flagMeter ? $_ARRAYLANG['TXT_SHOP_PRODUCT_METER'] : $_ARRAYLANG['TXT_SHOP_PRODUCT_COUNT'], 'SHOP_CURRENCY_CODE' => Currency::getActiveCurrencyCode()));
         if ($objProduct->code()) {
             self::$objTemplate->setVariable('SHOP_PRODUCT_CUSTOM_ID', htmlentities($objProduct->code(), ENT_QUOTES, CONTREXX_CHARSET));
         }
         $manufacturer_name = $manufacturer_url = $manufacturer_link = '';
         $manufacturer_id = $objProduct->manufacturer_id();
         if ($manufacturer_id) {
             $manufacturer_name = Manufacturer::getNameById($manufacturer_id, FRONTEND_LANG_ID);
             $manufacturer_url = Manufacturer::getUrlById($manufacturer_id, FRONTEND_LANG_ID);
         }
         if (!empty($manufacturer_url) || !empty($manufacturer_name)) {
             if (empty($manufacturer_name)) {
                 $manufacturer_name = $manufacturer_url;
             }
             if (!empty($manufacturer_url)) {
                 $manufacturer_link = '<a href="' . $manufacturer_url . '">' . $manufacturer_name . '</a>';
             }
             // TODO: Test results for any combination of name and url
             self::$objTemplate->setVariable(array('SHOP_MANUFACTURER_NAME' => $manufacturer_name, 'SHOP_MANUFACTURER_URL' => $manufacturer_url, 'SHOP_MANUFACTURER_LINK' => $manufacturer_link, 'TXT_SHOP_MANUFACTURER_LINK' => $_ARRAYLANG['TXT_SHOP_MANUFACTURER_LINK']));
         }
         // This is the old Product field for the Manufacturer URI.
         // This is now extended by the Manufacturer table and should thus
         // get a new purpose.  As it is product specific, it could be
         // renamed and reused as a link to individual Products!
         $externalLink = $objProduct->uri();
         if (!empty($externalLink)) {
             self::$objTemplate->setVariable(array('SHOP_EXTERNAL_LINK' => '<a href="' . $externalLink . '" title="' . $_ARRAYLANG['TXT_SHOP_EXTERNAL_LINK'] . '" target="_blank">' . $_ARRAYLANG['TXT_SHOP_EXTERNAL_LINK'] . '</a>'));
         }
         if ($price) {
             self::$objTemplate->setGlobalVariable(array('SHOP_PRODUCT_PRICE' => $price, 'SHOP_PRODUCT_PRICE_UNIT' => Currency::getActiveCurrencySymbol()));
         }
         // Only show the discount price if it's actually in use,
         // avoid an "empty <font> tag" HTML warning
         if ($discountPrice) {
             self::$objTemplate->setGlobalVariable(array('SHOP_PRODUCT_DISCOUNTPRICE' => $discountPrice, 'SHOP_PRODUCT_DISCOUNTPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_PRODUCT_DISCOUNTPRICE_TEXTBLOCK_1' => $_ARRAYLANG['TXT_SHOP_PRODUCT_DISCOUNTPRICE_TEXTBLOCK_1'], 'SHOP_PRODUCT_DISCOUNTPRICE_TEXTBLOCK_2' => $_ARRAYLANG['TXT_SHOP_PRODUCT_DISCOUNTPRICE_TEXTBLOCK_2']));
             if (self::$objTemplate->blockExists('price_discount')) {
                 self::$objTemplate->touchBlock('price_discount');
             }
         } else {
             if (self::$objTemplate->blockExists('price')) {
                 self::$objTemplate->touchBlock('price');
             }
         }
         // Special outlet ShopCategory with discounts varying daily.
         // This should be implemented in a more generic way, in the
         // Discount class maybe.
         if ($objProduct->is_outlet()) {
             self::$objTemplate->setVariable(array('TXT_SHOP_DISCOUNT_TODAY' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_TODAY'], 'SHOP_DISCOUNT_TODAY' => $objProduct->getOutletDiscountRate() . '%', 'TXT_SHOP_PRICE_TODAY' => $_ARRAYLANG['TXT_SHOP_PRICE_TODAY'], 'SHOP_PRICE_TODAY' => Currency::getCurrencyPrice($objProduct->getDiscountedPrice()), 'SHOP_PRICE_TODAY_UNIT' => Currency::getActiveCurrencySymbol()));
         }
         if ($objProduct->stock_visible()) {
             self::$objTemplate->setVariable(array('SHOP_PRODUCT_STOCK' => $stock));
         }
         if ($detailLink) {
             self::$objTemplate->setVariable(array('SHOP_PRODUCT_DETAILLINK' => $detailLink));
         }
         $distribution = $objProduct->distribution();
         $weight = '';
         if ($distribution == 'delivery') {
             $weight = $objProduct->weight();
         }
         // Hide the weight if it is zero or disabled in the configuration
         if ($weight > 0 && \Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) {
             self::$objTemplate->setVariable(array('TXT_SHOP_PRODUCT_WEIGHT' => $_ARRAYLANG['TXT_SHOP_PRODUCT_WEIGHT'], 'SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($weight)));
         }
         if (Vat::isEnabled()) {
             self::$objTemplate->setVariable(array('SHOP_PRODUCT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'], 'SHOP_PRODUCT_TAX' => Vat::getShort($objProduct->vat_id())));
         }
         // Add flag images for flagged Products
         $strImage = '';
         $strFlags = $objProduct->flags();
         $arrVirtual = ShopCategories::getVirtualCategoryNameArray(FRONTEND_LANG_ID);
         foreach (explode(' ', $strFlags) as $strFlag) {
             if (in_array($strFlag, $arrVirtual)) {
                 $strImage .= '<img src="images/content/' . $strFlag . '.jpg" alt="' . $strFlag . '" />';
             }
         }
         if ($strImage) {
             self::$objTemplate->setVariable('SHOP_PRODUCT_FLAG_IMAGE', $strImage);
         }
         $minimum_order_quantity = $objProduct->minimum_order_quantity();
         //Activate Quantity-Inputfield when minimum_order_quantity exists
         if (self::$objTemplate->blockExists('orderQuantity') && $minimum_order_quantity > 0) {
             self::$objTemplate->setVariable('SHOP_PRODUCT_MINIMUM_ORDER_QUANTITY', contrexx_raw2xhtml($objProduct->minimum_order_quantity()));
         } elseif (self::$objTemplate->blockExists('orderQuantity') && !$minimum_order_quantity) {
             self::$objTemplate->hideBlock('orderQuantity');
         }
         if (self::$objTemplate->blockExists('shopProductRow')) {
             self::$objTemplate->parse('shopProductRow');
         }
         ++$formId;
     }
     return true;
 }