function _getNewsPage()
 {
     global $objDatabase, $objInit, $_ARRAYLANG;
     \JS::activate('cx');
     // TODO: Unused
     //        $objFWUser = \FWUser::getFWUserObject();
     $newsdate = time() - 86400 * 30;
     if (!empty($_POST['newsDate'])) {
         $newsdate = $this->dateFromInput($_POST['newsDate']);
     }
     $this->_pageTitle = $_ARRAYLANG['TXT_NEWSLETTER_NEWS_IMPORT'];
     $this->_objTpl->loadTemplateFile('newsletter_news.html');
     $this->_objTpl->setVariable(array('TXT_NEWS_IMPORT' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_IMPORT'], 'TXT_DATE_SINCE' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_DATE_SINCE'], 'TXT_SELECTED_MESSAGES' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_SELECTED_MESSAGES'], 'TXT_NEXT' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_NEXT'], 'NEWS_CREATE_DATE' => $this->valueFromDate($newsdate)));
     $query = "SELECT n.id, n.date, nl.title, nl.text, n.catid, cl.name as catname, n.userid, nl.teaser_text,\n            n.teaser_image_path, n.teaser_image_thumbnail_path, tl.name as typename FROM " . DBPREFIX . "module_news n\n            LEFT JOIN " . DBPREFIX . "module_news_locale nl ON n.id = nl.news_id AND nl.lang_id=" . $objInit->userFrontendLangId . "\n            LEFT JOIN " . DBPREFIX . "module_news_categories_locale cl ON n.catid = cl.category_id AND cl.lang_id=" . $objInit->userFrontendLangId . "\n            LEFT JOIN " . DBPREFIX . "module_news_types_locale tl ON n.typeid = tl.type_id AND tl.lang_id=" . $objInit->userFrontendLangId . "\n            WHERE n.date > " . $newsdate . " AND n.status = 1 AND n.validated = '1'\n            ORDER BY cl.name ASC, n.date DESC";
     /*AND (n.startdate <> '0000-00-00 00:00:00' OR n.enddate <> '0000-00-00 00:00:00')*/
     $objNews = $objDatabase->Execute($query);
     $current_category = '';
     if ($objNews !== false) {
         while (!$objNews->EOF) {
             $this->_objTpl->setVariable(array('NEWS_CATEGORY_NAME' => contrexx_raw2xhtml($objNews->fields['catname']), 'NEWS_CATEGORY_ID' => $objNews->fields['catid']));
             if ($current_category == $objNews->fields['catid']) {
                 $this->_objTpl->hideBlock("news_category");
             }
             $current_category = $objNews->fields['catid'];
             // TODO: Unused
             //                $newstext = ltrim(strip_tags($objNews->fields['text']));
             $newsteasertext = ltrim(strip_tags($objNews->fields['teaser_text']));
             //$newslink = $this->newsletterUri.ASCMS_PROTOCOL."://".$_SERVER['HTTP_HOST'].ASCMS_PATH_OFFSET."/index.php?section=News&cmd=details&newsid=".$objNews->fields['id'];
             /*if ($objNews->fields['userid'] && ($objUser = $objFWUser->objUser->getUser($objNews->fields['userid']))) {
                   $author = htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET);
               } else {
                   $author = $_ARRAYLANG['TXT_ANONYMOUS'];
               }*/
             $image = $objNews->fields['teaser_image_path'];
             $thumbnail = $objNews->fields['teaser_image_thumbnail_path'];
             if (!empty($thumbnail)) {
                 $imageSrc = $thumbnail;
             } elseif (!empty($image) && file_exists(\ImageManager::getThumbnailFilename(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $image))) {
                 $imageSrc = \ImageManager::getThumbnailFilename($image);
             } elseif (!empty($image)) {
                 $imageSrc = $image;
             } else {
                 $imageSrc = '';
             }
             $this->_objTpl->setVariable(array('NEWS_ID' => $objNews->fields['id'], 'NEWS_CATEGORY_ID' => $objNews->fields['catid'], 'NEWS_TITLE' => contrexx_raw2xhtml($objNews->fields['title']), 'NEWS_IMAGE_PATH' => contrexx_raw2encodedUrl($imageSrc), 'NEWS_TEASER_TEXT' => contrexx_raw2xhtml($newsteasertext)));
             $this->_objTpl->parse("news_list");
             $objNews->MoveNext();
         }
     } else {
         $this->_objTpl->setVariable('NEWS_EMPTY_LIST', $_ARRAYLANG['TXT_NEWSLETTER_NEWS_EMPTY_LIST']);
     }
 }
Пример #2
0
 /**
  * Get the thumbnail image
  *
  * @param integer $id             entry id
  * @param string  $titleImage     title image
  * @param string  $thumbnailImage thumbnail image
  * @param string  $thumbType      thumbnail type
  *
  * @return string
  */
 function getThumbnailImage($id, $titleImage, $thumbnailImage, $thumbType)
 {
     global $_LANGID;
     $image = '';
     if (empty($id)) {
         return $image;
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $websitePath = $cx->getWebsitePath();
     if (!empty($thumbnailImage)) {
         $thumbnailImagePath = \ImageManager::getThumbnailFilename($thumbnailImage);
         if ($thumbType == 'original') {
             $image = $thumbnailImage;
         } elseif (file_exists($websitePath . $thumbnailImagePath)) {
             $image = $thumbnailImagePath;
         } else {
             $image = $thumbnailImage;
         }
     } else {
         $path = \ImageManager::getThumbnailFilename($cx->getWebsiteImagesDataWebPath() . '/' . $id . '_' . $_LANGID . '_' . basename($titleImage));
         if (file_exists($websitePath . '/' . $path)) {
             $image = $path;
         } elseif (file_exists($websitePath . \ImageManager::getThumbnailFilename($titleImage))) {
             $image = \ImageManager::getThumbnailFilename($titleImage);
         } else {
             $image = $titleImage;
         }
     }
     return !empty($image) && file_exists($websitePath . '/' . $image) ? '<img src="' . $image . '" alt= "" />' : '';
 }
Пример #3
0
 private function parseRelatedDownloads($objDownload, $currentCategoryId)
 {
     global $_LANGID, $_ARRAYLANG;
     if (!$this->objTemplate->blockExists('downloads_related_file_list')) {
         return;
     }
     $sortOrder = $this->downloadsSortingOptions[$this->arrConfig['downloads_sorting_order']];
     $objRelatedDownload = $objDownload->getDownloads(array('download_id' => $objDownload->getId()), null, $sortOrder);
     if ($objRelatedDownload) {
         $row = 1;
         while (!$objRelatedDownload->EOF) {
             $description = $objRelatedDownload->getDescription($_LANGID);
             if (strlen($description) > 100) {
                 $shortDescription = substr($description, 0, 97) . '...';
             } else {
                 $shortDescription = $description;
             }
             $imageSrc = $objRelatedDownload->getImage();
             if (!empty($imageSrc) && file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . $imageSrc)) {
                 $thumb_name = \ImageManager::getThumbnailFilename($imageSrc);
                 if (file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . $thumb_name)) {
                     $thumbnailSrc = $thumb_name;
                 } else {
                     $thumbnailSrc = \ImageManager::getThumbnailFilename($this->defaultCategoryImage['src']);
                 }
                 $image = $this->getHtmlImageTag($imageSrc, htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET));
                 $thumbnail = $this->getHtmlImageTag($thumbnailSrc, htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET));
             } else {
                 $imageSrc = $this->defaultCategoryImage['src'];
                 $thumbnailSrc = \ImageManager::getThumbnailFilename($this->defaultCategoryImage['src']);
                 $image = '';
                 $thumbnail = '';
             }
             $arrAssociatedCategories = $objRelatedDownload->getAssociatedCategoryIds();
             if (in_array($currentCategoryId, $arrAssociatedCategories)) {
                 $categoryId = $currentCategoryId;
             } else {
                 $arrPublicCategories = array();
                 $arrProtectedCategories = array();
                 foreach ($arrAssociatedCategories as $categoryId) {
                     $objCategory = Category::getCategory($categoryId);
                     if (!$objCategory->EOF) {
                         if ($objCategory->getVisibility() || \Permission::checkAccess($objCategory->getReadAccessId(), 'dynamic', true) || $objCategory->getOwnerId() == $this->userId) {
                             $arrPublicCategories[] = $categoryId;
                             break;
                         } else {
                             $arrProtectedCategories[] = $categoryId;
                         }
                     }
                 }
                 if (count($arrPublicCategories)) {
                     $categoryId = $arrPublicCategories[0];
                 } elseif (count($arrProtectedCategories)) {
                     $categoryId = $arrProtectedCategories[0];
                 } else {
                     $objRelatedDownload->next();
                     continue;
                 }
             }
             $this->objTemplate->setVariable(array('DOWNLOADS_RELATED_FILE_ID' => $objRelatedDownload->getId(), 'DOWNLOADS_RELATED_FILE_DETAIL_SRC' => CONTREXX_SCRIPT_PATH . $this->moduleParamsHtml . '&amp;category=' . $categoryId . '&amp;id=' . $objRelatedDownload->getId(), 'DOWNLOADS_RELATED_FILE_NAME' => htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_RELATED_FILE_DESCRIPTION' => nl2br(htmlentities($description, ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_RELATED_FILE_SHORT_DESCRIPTION' => htmlentities($shortDescription, ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_RELATED_FILE_IMAGE' => $image, 'DOWNLOADS_RELATED_FILE_IMAGE_SRC' => $imageSrc, 'DOWNLOADS_RELATED_FILE_THUMBNAIL' => $thumbnail, 'DOWNLOADS_RELATED_FILE_THUMBNAIL_SRC' => $thumbnailSrc, 'DOWNLOADS_RELATED_FILE_ICON' => $this->getHtmlImageTag($objRelatedDownload->getIcon(), htmlentities($objRelatedDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_RELATED_FILE_ROW_CLASS' => 'row' . ($row++ % 2 + 1)));
             $this->objTemplate->parse('downloads_related_file');
             $objRelatedDownload->next();
         }
         $this->objTemplate->setVariable('TXT_DOWNLOADS_RELATED_DOWNLOADS', $_ARRAYLANG['TXT_DOWNLOADS_RELATED_DOWNLOADS']);
         $this->objTemplate->parse('downloads_related_file_list');
     } else {
         $this->objTemplate->hideBlock('downloads_related_file_list');
     }
 }
Пример #4
0
 public function parseImageThumbnail($imageSource, $thumbnailSource, $altText, $newsUrl)
 {
     $image = '';
     $imageLink = '';
     $source = '';
     if (!empty($thumbnailSource)) {
         $source = $thumbnailSource;
     } elseif (!empty($imageSource) && file_exists(ASCMS_PATH . \ImageManager::getThumbnailFilename($imageSource))) {
         $source = \ImageManager::getThumbnailFilename($imageSource);
     } elseif (!empty($imageSource)) {
         $source = $imageSource;
     }
     if (!empty($source)) {
         $image = self::getHtmlImageTag($source, $altText);
         $imageLink = self::parseLink($newsUrl, $altText, $image);
     }
     return array($image, $imageLink, $source);
 }
Пример #5
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) {
             $category_id = $objProduct->category_id();
         }
         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;
     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\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . self::$defaultImage);
                     self::scaleImageSizeToThumbnail($arrDefaultImageSize);
                 }
                 $arrSize = $arrDefaultImageSize;
             } else {
                 $thumbnailPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/' . \ImageManager::getThumbnailFilename($image['img']);
                 if ($image['width'] && $image['height']) {
                     $pictureLink = contrexx_raw2encodedUrl(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/' . $image['img']) . '" rel="shadowbox[' . ($formId + 1) . ']';
                     // Thumbnail display size
                     $arrSize = array($image['width'], $image['height']);
                 } else {
                     $pictureLink = '#';
                     if (!file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $thumbnailPath)) {
                         continue;
                     }
                     $arrSize = getimagesize(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $thumbnailPath);
                 }
                 self::scaleImageSizeToThumbnail($arrSize);
                 // Use the first available picture in microdata, if any
                 if (!$havePicture) {
                     $picture_url = \Cx\Core\Routing\Url::fromCapturedRequest(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/' . $image['img'], \Cx\Core\Core\Controller\Cx::instanciate()->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()));
             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;
 }
Пример #6
0
 public function parseImageThumbnail($imageSource, $thumbnailSource, $altText, $newsUrl)
 {
     $image = '';
     $imageLink = '';
     $source = '';
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     if (!empty($thumbnailSource)) {
         $source = $thumbnailSource;
     } elseif (!empty($imageSource) && file_exists(\ImageManager::getThumbnailFilename($cx->getWebsitePath() . '/' . $imageSource))) {
         $source = \ImageManager::getThumbnailFilename($imageSource);
     } elseif (!empty($imageSource)) {
         $source = $imageSource;
     }
     if (!empty($source)) {
         $image = self::getHtmlImageTag($source, $altText);
         $imageLink = self::parseLink($newsUrl, $altText, $image);
     }
     return array($image, $imageLink, $source);
 }
Пример #7
0
 /**
  * Create thumbnails and update the corresponding Product records
  *
  * Scans the Products with the given IDs.  If a non-empty picture string
  * with a reasonable extension is encountered, determines whether
  * the corresponding thumbnail is available and up to date or not.
  * If not, tries to load the file and to create a thumbnail.
  * If it succeeds, it also updates the picture field with the base64
  * encoded entry containing the image width and height.
  * Note that only single file names are supported!
  * Also note that this method returns a string with information about
  * problems that were encountered.
  * It skips records which contain no or invalid image
  * names, thumbnails that cannot be created, and records which refuse
  * to be updated!
  * The reasoning behind this is that this method is currently only called
  * from within some {@link _import()} methods.  The focus lies on importing
  * Products; whether or not thumbnails can be created is secondary, as the
  * process can be repeated if there is a problem.
  * @param   integer     $arrId      The array of Product IDs
  * @return  boolean                 True on success, false on any error
  * @global  ADONewConnection  $objDatabase    Database connection object
  * @global  array
  * @static
  * @author  Reto Kohli <*****@*****.**>
  */
 static function makeThumbnailsById($arrId)
 {
     global $_ARRAYLANG;
     if (!is_array($arrId)) {
         return false;
     }
     $error = false;
     $objImageManager = new \ImageManager();
     foreach ($arrId as $product_id) {
         if ($product_id <= 0) {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_INVALID_PRODUCT_ID'], $product_id));
             $error = true;
             continue;
         }
         $objProduct = Product::getById($product_id);
         if (!$objProduct) {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_INVALID_PRODUCT_ID'], $product_id));
             $error = true;
             continue;
         }
         $imageName = $objProduct->pictures();
         $imagePath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopPath() . '/' . $imageName;
         // only try to create thumbs from entries that contain a
         // plain text file name (i.e. from an import)
         if ($imageName == '' || !preg_match('/\\.(?:jpg|jpeg|gif|png)$/i', $imageName)) {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_UNSUPPORTED_IMAGE_FORMAT'], $product_id, $imageName));
             $error = true;
             continue;
         }
         // if the picture is missing, skip it.
         if (!file_exists($imagePath)) {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_MISSING_PRODUCT_IMAGE'], $product_id, $imageName));
             $error = true;
             continue;
         }
         $thumbResult = true;
         $width = 0;
         $height = 0;
         // If the thumbnail exists and is newer than the picture,
         // don't create it again.
         $thumb_name = \ImageManager::getThumbnailFilename($imagePath);
         if (file_exists($thumb_name) && filemtime($thumb_name) > filemtime($imagePath)) {
             //$this->addMessage("Hinweis: Thumbnail fuer Produkt ID '$product_id' existiert bereits");
             // Need the original size to update the record, though
             list($width, $height) = $objImageManager->_getImageSize($imagePath);
         } else {
             // Create thumbnail, get the original size.
             // Deleting the old thumb beforehand is integrated into
             // _createThumbWhq().
             $thumbResult = $objImageManager->_createThumbWhq(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopPath() . '/', \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/', $imageName, \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_width', 'Shop'), \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_height', 'Shop'), \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_quality', 'Shop'));
             $width = $objImageManager->orgImageWidth;
             $height = $objImageManager->orgImageHeight;
         }
         // The database needs to be updated, however, as all Products
         // have been imported.
         if ($thumbResult) {
             $shopPicture = base64_encode($imageName) . '?' . base64_encode($width) . '?' . base64_encode($height) . ':??:??';
             $objProduct->pictures($shopPicture);
             $objProduct->store();
         } else {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_ERROR_CREATING_PRODUCT_THUMBNAIL'], $product_id, $imageName));
             $error = true;
         }
     }
     return $error;
 }
Пример #8
0
 function _createThumbnail($file, $overwrite = false)
 {
     global $_ARRAYLANG;
     $tmpSize = getimagesize($file);
     $thumbWidth = $this->thumbHeight / $tmpSize[1] * $tmpSize[0];
     $thumb_name = \ImageManager::getThumbnailFilename($file);
     $tmp = new \ImageManager();
     $tmp->loadImage($file);
     $tmp->resizeImage($thumbWidth, $this->thumbHeight, $this->thumbQuality);
     $tmp->saveNewImage($thumb_name, $overwrite);
     if (!file_exists($thumb_name)) {
         $img = imagecreate(100, 50);
         $colBody = imagecolorallocate($img, 255, 255, 255);
         ImageFilledRectangle($img, 0, 0, 100, 50, $colBody);
         $colFont = imagecolorallocate($img, 0, 0, 0);
         imagettftext($img, 10, 0, 18, 29, $colFont, self::_getIconPath() . 'arial.ttf', 'no preview');
         imagerectangle($img, 0, 0, 99, 49, $colFont);
         imagejpeg($img, $thumb_name, $this->thumbQuality);
     }
 }
Пример #9
0
 function _deleteMedia2($file)
 {
     global $_ARRAYLANG;
     if (self::isIllegalFileName($file)) {
         return $_ARRAYLANG['TXT_MEDIA_FILE_DONT_DELETE'];
     }
     $obj_file = new \File();
     if (is_dir($this->path . $file)) {
         $this->dirLog = $obj_file->delDir($this->path, $this->webPath, $file);
         if ($this->dirLog != "error") {
             $status = $_ARRAYLANG['TXT_MEDIA_MSG_DIR_DELETE'];
         } else {
             $status = $_ARRAYLANG['TXT_MEDIA_MSG_ERROR_DIR'];
         }
     } else {
         if ($this->_isImage($this->path . $file)) {
             $thumb_name = basename(\ImageManager::getThumbnailFilename($this->path . $file));
             if (file_exists($this->path . $thumb_name)) {
                 $this->dirLog = $obj_file->delFile($this->path, $this->webPath, $thumb_name);
             }
         }
         $this->dirLog = $obj_file->delFile($this->path, $this->webPath, $file);
         if ($this->dirLog != "error") {
             $status = $_ARRAYLANG['TXT_MEDIA_MSG_FILE_DELETE'];
         } else {
             $status = $_ARRAYLANG['TXT_MEDIA_MSG_ERROR_FILE'];
         }
     }
     return $status;
 }
Пример #10
0
 /**
  * The Cart view
  *
  * Mind that the Cart needs to be {@see update()}d before calling this
  * method.
  * @global  array $_ARRAYLANG   Language array
  * @param   \Cx\Core\Html\Sigma $objTemplate  The optional Template
  */
 static function view($objTemplate = null)
 {
     global $_ARRAYLANG;
     if (!$objTemplate) {
         // TODO: Handle missing or empty Template, load one
         die("Cart::view(): ERROR: No template");
         //            return false;
     }
     $objTemplate->setGlobalVariable($_ARRAYLANG);
     $i = 0;
     if (count(self::$products)) {
         foreach (self::$products as $arrProduct) {
             $groupCountId = $arrProduct['group_id'];
             $groupArticleId = $arrProduct['article_id'];
             $groupCustomerId = 0;
             if (Shop::customer()) {
                 $groupCustomerId = Shop::customer()->group_id();
             }
             Shop::showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, $arrProduct['quantity']);
             // product image
             $arrProductImg = Products::get_image_array_from_base64($arrProduct['product_images']);
             $shopImagesWebPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesWebPath() . '/Shop/';
             $thumbnailPath = $shopImagesWebPath . ShopLibrary::noPictureName;
             foreach ($arrProductImg as $productImg) {
                 if (!empty($productImg['img']) && $productImg['img'] != ShopLibrary::noPictureName) {
                     $thumbnailPath = $shopImagesWebPath . \ImageManager::getThumbnailFilename($productImg['img']);
                     break;
                 }
             }
             /* UNUSED (and possibly obsolete, too)
                             if (isset($arrProduct['discount_string'])) {
             //DBG::log("Shop::view_cart(): Product ID ".$arrProduct['id'].": ".$arrProduct['discount_string']);
                                 $objTemplate->setVariable(
                                     'SHOP_DISCOUNT_COUPON_STRING',
                                         $arrProduct['coupon_string']
                                 );
                             }*/
             // The fields that don't apply have been set to ''
             // (empty string) already -- see update().
             $objTemplate->setVariable(array('SHOP_PRODUCT_ROW' => 'row' . (++$i % 2 + 1), 'SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CODE' => $arrProduct['product_id'], 'SHOP_PRODUCT_THUMBNAIL' => $thumbnailPath, 'SHOP_PRODUCT_CART_ID' => $arrProduct['cart_id'], 'SHOP_PRODUCT_TITLE' => str_replace('"', '&quot;', contrexx_raw2xhtml($arrProduct['title'])), 'SHOP_PRODUCT_PRICE' => $arrProduct['price'], 'SHOP_PRODUCT_PRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => $arrProduct['itemprice'], 'SHOP_PRODUCT_ITEMPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_REMOVE_PRODUCT' => $_ARRAYLANG['TXT_SHOP_REMOVE_ITEM']));
             //DBG::log("Attributes String: {$arrProduct['options_long']}");
             if ($arrProduct['options_long']) {
                 $objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $arrProduct['options_long']);
             }
             if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($arrProduct['weight']), 'TXT_WEIGHT' => $_ARRAYLANG['TXT_TOTAL_WEIGHT']));
             }
             if (Vat::isEnabled()) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $arrProduct['vat_rate'] ? Vat::format($arrProduct['vat_rate']) : '', 'SHOP_PRODUCT_TAX_AMOUNT' => $arrProduct['vat_amount'] . '&nbsp;' . Currency::getActiveCurrencySymbol()));
             }
             if (intval($arrProduct['minimum_order_quantity']) > 0) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_MINIMUM_ORDER_QUANTITY' => $arrProduct['minimum_order_quantity']));
             } else {
                 if ($objTemplate->blockExists('orderQuantity')) {
                     $objTemplate->hideBlock('orderQuantity');
                 }
                 if ($objTemplate->blockExists('minimumOrderQuantity')) {
                     $objTemplate->hideBlock('minimumOrderQuantity');
                 }
             }
             $objTemplate->parse('shopCartRow');
         }
     } else {
         $objTemplate->hideBlock('shopCart');
         if ($objTemplate->blockExists('shopCartEmpty')) {
             $objTemplate->touchBlock('shopCartEmpty');
             $objTemplate->parse('shopCartEmpty');
         }
         if ($_SESSION['shop']['previous_product_ids']) {
             $ids = $_SESSION['shop']['previous_product_ids']->toArray();
             Shop::view_product_overview($ids);
         }
     }
     $objTemplate->setGlobalVariable(array('TXT_PRODUCT_ID' => $_ARRAYLANG['TXT_ID'], 'SHOP_PRODUCT_TOTALITEM' => self::get_item_count(), 'SHOP_PRODUCT_TOTALPRICE' => Currency::formatPrice(self::get_price()), 'SHOP_PRODUCT_TOTALPRICE_PLUS_VAT' => Currency::formatPrice(self::get_price() + (Vat::isEnabled() && !Vat::isIncluded() ? self::get_vat_amount() : 0)), 'SHOP_PRODUCT_TOTALPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTAL_WEIGHT' => Weight::getWeightString(self::get_weight()), 'SHOP_PRICE_UNIT' => Currency::getActiveCurrencySymbol()));
     // Show the Coupon code field only if there is at least one defined
     if (Coupon::count_available()) {
         //DBG::log("Coupons available");
         $objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_CODE' => isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : ''));
         if ($objTemplate->blockExists('shopCoupon')) {
             $objTemplate->parse('shopCoupon');
         }
         if (self::get_discount_amount()) {
             $total_discount_amount = self::get_discount_amount();
             //DBG::log("Shop::view_cart(): Total: Amount $total_discount_amount");
             $objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount)));
         }
     }
     if (Vat::isEnabled()) {
         $objTemplate->setVariable(array('TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'], 'SHOP_TOTAL_TAX_AMOUNT' => self::get_vat_amount() . '&nbsp;' . Currency::getActiveCurrencySymbol()));
         if (Vat::isIncluded()) {
             $objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice(self::get_price() - self::get_vat_amount()) . '&nbsp;' . Currency::getActiveCurrencySymbol()));
         }
     }
     if (self::needs_shipment()) {
         $objTemplate->setVariable(array('TXT_SHIP_COUNTRY' => $_ARRAYLANG['TXT_SHIP_COUNTRY'], 'SHOP_COUNTRIES_MENU' => \Cx\Core\Country\Controller\Country::getMenu('countryId2', $_SESSION['shop']['countryId2'], true, "document.forms['shopForm'].submit()"), 'SHOP_COUNTRIES_MENUOPTIONS' => \Cx\Core\Country\Controller\Country::getMenuoptions($_SESSION['shop']['countryId2'])));
     }
     if (\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop') > 0 && \Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop') > self::get_price()) {
         $objTemplate->setVariable('MESSAGE_TEXT', sprintf($_ARRAYLANG['TXT_SHOP_ORDERITEMS_AMOUNT_MIN'], Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop')), Currency::getActiveCurrencySymbol()));
     } elseif (\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop') > 0 && \Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop') < self::get_price()) {
         $objTemplate->setVariable('MESSAGE_TEXT', sprintf($_ARRAYLANG['TXT_SHOP_ORDERITEMS_AMOUNT_MAX'], Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop')), Currency::getActiveCurrencySymbol()));
     } else {
         $objTemplate->setVariable('TXT_NEXT', $_ARRAYLANG['TXT_NEXT']);
     }
 }
Пример #11
0
 private function download()
 {
     global $_ARRAYLANG, $_LANGID;
     $objFWUser = \FWUser::getFWUserObject();
     $objDownload = new Download();
     $objDownload->load(isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0);
     if ($objDownload->getId() && !\Permission::checkAccess(143, 'static', true) && (($objFWUser = \FWUser::getFWUserObject()) == false || !$objFWUser->objUser->login() || $objDownload->getOwnerId() != $objFWUser->objUser->getId())) {
         $this->arrStatusMsg['error'][] = $_ARRAYLANG['TXT_DOWNLOADS_MODIFY_DOWNLOAD_PROHIBITED'];
         return $this->downloads();
     }
     $arrAssociatedGroupOptions = array();
     $arrNotAssociatedGroupOptions = array();
     $arrAssociatedGroups = array();
     $arrAssociatedCategoryOptions = array();
     $arrNotAssociatedCategoryOptions = array();
     $arrAssociatedCategories = array();
     $arrAssociatedDownloadOptions = array();
     $arrNotAssociatedDownloadOptions = array();
     if (isset($_POST['downloads_download_save'])) {
         $objDownload->setNames(isset($_POST['downloads_download_name']) ? array_map('trim', array_map('contrexx_stripslashes', $_POST['downloads_download_name'])) : array());
         $objDownload->setDescriptions(isset($_POST['downloads_download_description']) ? array_map('trim', array_map('contrexx_stripslashes', $_POST['downloads_download_description'])) : array());
         $this->arrConfig['use_attr_metakeys'] ? $objDownload->setMetakeys(isset($_POST['downloads_download_metakeys']) ? array_map('trim', array_map('contrexx_stripslashes', $_POST['downloads_download_metakeys'])) : array()) : null;
         $objDownload->setType(isset($_POST['downloads_download_type']) ? contrexx_stripslashes($_POST['downloads_download_type']) : '');
         $objDownload->setSources(isset($_POST['downloads_download_' . $objDownload->getType() . '_source']) ? array_map('trim', array_map('contrexx_stripslashes', $_POST['downloads_download_' . $objDownload->getType() . '_source'])) : array());
         $objDownload->setActiveStatus(!empty($_POST['downloads_download_is_active']));
         $objDownload->setMimeType(isset($_POST['downloads_download_mime_type']) ? contrexx_stripslashes($_POST['downloads_download_mime_type']) : '');
         $this->arrConfig['use_attr_size'] ? $objDownload->setSize(isset($_POST['downloads_download_size']) ? intval($_POST['downloads_download_size']) : '') : null;
         $this->arrConfig['use_attr_license'] ? $objDownload->setLicense(isset($_POST['downloads_download_license']) ? contrexx_stripslashes($_POST['downloads_download_license']) : '') : null;
         $this->arrConfig['use_attr_version'] ? $objDownload->setVersion(isset($_POST['downloads_download_version']) ? contrexx_stripslashes($_POST['downloads_download_version']) : '') : null;
         $this->arrConfig['use_attr_author'] ? $objDownload->setAuthor(isset($_POST['downloads_download_author']) ? contrexx_stripslashes($_POST['downloads_download_author']) : '') : null;
         $this->arrConfig['use_attr_website'] ? $objDownload->setWebsite(isset($_POST['downloads_download_website']) ? contrexx_stripslashes($_POST['downloads_download_website']) : '') : null;
         $objDownload->setImage(isset($_POST['downloads_download_image']) ? contrexx_stripslashes($_POST['downloads_download_image']) : '');
         $objDownload->setValidityTimePeriod(!empty($_POST['downloads_download_validity']) ? intval($_POST['downloads_download_validity']) : 0);
         $objDownload->setVisibility(!empty($_POST['downloads_download_visibility']));
         $objDownload->setProtection(!empty($_POST['downloads_download_access']));
         $objDownload->setGroups($objDownload->getProtection() && !empty($_POST['downloads_download_access_associated_groups']) ? array_map('intval', $_POST['downloads_download_access_associated_groups']) : array());
         $objDownload->setCategories(!empty($_POST['downloads_download_associated_categories']) ? array_map('intval', $_POST['downloads_download_associated_categories']) : array(0));
         $objDownload->setDownloads(!empty($_POST['downloads_download_associated_downloads']) ? array_map('intval', $_POST['downloads_download_associated_downloads']) : array());
         $objDownload->updateMTime();
         if ($objDownload->store()) {
             if (!empty($this->parentCategoryId)) {
                 header('location: ' . \Cx\Core\Csrf\Controller\Csrf::enhanceURI('index.php?cmd=Downloads&act=categories&parent_id=' . $this->parentCategoryId));
             } else {
                 return $this->downloads();
             }
         } else {
             $this->arrStatusMsg['error'] = array_merge($this->arrStatusMsg['error'], $objDownload->getErrorMsg());
         }
     }
     $this->_pageTitle = $objDownload->getId() ? $_ARRAYLANG['TXT_DOWNLOADS_EDIT_DOWNLOAD'] : $_ARRAYLANG['TXT_DOWNLOADS_ADD_DOWNLOAD'];
     $this->objTemplate->addBlockFile('DOWNLOADS_DOWNLOAD_TEMPLATE', 'module_downloads_downloads', 'module_downloads_download_modify.html');
     $this->objTemplate->setVariable(array('TXT_DOWNLOADS_GENERAL' => $_ARRAYLANG['TXT_DOWNLOADS_GENERAL'], 'TXT_DOWNLOADS_PERMISSIONS' => $_ARRAYLANG['TXT_DOWNLOADS_PERMISSIONS'], 'TXT_DOWNLOADS_DOWNLOAD_VISIBILITY_DESC' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_VISIBILITY_DESC'], 'TXT_DOWNLOADS_NAME' => $_ARRAYLANG['TXT_DOWNLOADS_NAME'], 'TXT_DOWNLOADS_DESCRIPTION' => $_ARRAYLANG['TXT_DOWNLOADS_DESCRIPTION'], 'TXT_DOWNLOADS_SOURCE' => $_ARRAYLANG['TXT_DOWNLOADS_SOURCE'], 'TXT_DOWNLOADS_LOCAL_FILE' => $_ARRAYLANG['TXT_DOWNLOADS_LOCAL_FILE'], 'TXT_DOWNLOADS_URL' => $_ARRAYLANG['TXT_DOWNLOADS_URL'], 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'TXT_DOWNLOADS_STATUS' => $_ARRAYLANG['TXT_DOWNLOADS_STATUS'], 'TXT_DOWNLOADS_VALIDITY_EXPIRATION' => $_ARRAYLANG['TXT_DOWNLOADS_VALIDITY_EXPIRATION'], 'TXT_DOWNLOADS_ACTIVE' => $_ARRAYLANG['TXT_DOWNLOADS_ACTIVE'], 'TXT_DOWNLOADS_TYPE' => $_ARRAYLANG['TXT_DOWNLOADS_TYPE'], 'TXT_DOWNLOADS_METAKEYS' => $_ARRAYLANG['TXT_DOWNLOADS_METAKEYS'], 'TXT_DOWNLOADS_SIZE' => $_ARRAYLANG['TXT_DOWNLOADS_SIZE'], 'TXT_DOWNLOADS_LICENSE' => $_ARRAYLANG['TXT_DOWNLOADS_LICENSE'], 'TXT_DOWNLOADS_VERSION' => $_ARRAYLANG['TXT_DOWNLOADS_VERSION'], 'TXT_DOWNLOADS_AUTHOR' => $_ARRAYLANG['TXT_DOWNLOADS_AUTHOR'], 'TXT_DOWNLOADS_WEBSITE' => $_ARRAYLANG['TXT_DOWNLOADS_WEBSITE'], 'TXT_DOWNLOADS_IMAGE' => $_ARRAYLANG['TXT_DOWNLOADS_IMAGE'], 'TXT_DOWNLOADS_CATEGORIES' => $_ARRAYLANG['TXT_DOWNLOADS_CATEGORIES'], 'TXT_DOWNLOADS_AVAILABLE_CATEGORIES' => $_ARRAYLANG['TXT_DOWNLOADS_AVAILABLE_CATEGORIES'], 'TXT_DOWNLOADS_ASSIGNED_CATEGORIES' => $_ARRAYLANG['TXT_DOWNLOADS_ASSIGNED_CATEGORIES'], 'TXT_DOWNLOADS_RELATED_DOWNLOADS' => $_ARRAYLANG['TXT_DOWNLOADS_RELATED_DOWNLOADS'], 'TXT_DOWNLOADS_AVAILABLE_DOWNLOADS' => $_ARRAYLANG['TXT_DOWNLOADS_AVAILABLE_DOWNLOADS'], 'TXT_DOWNLOADS_ASSIGNED_DOWNLOADS' => $_ARRAYLANG['TXT_DOWNLOADS_ASSIGNED_DOWNLOADS'], 'TXT_DOWNLOADS_DOWNLOAD_ALL_ACCESS_DESC' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_ALL_ACCESS_DESC'], 'TXT_DOWNLOADS_DOWNLOAD_SELECTED_ACCESS_DESC' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD_SELECTED_ACCESS_DESC'], 'TXT_DOWNLOADS_AVAILABLE_USER_GROUPS' => $_ARRAYLANG['TXT_DOWNLOADS_AVAILABLE_USER_GROUPS'], 'TXT_DOWNLOADS_ASSIGNED_USER_GROUPS' => $_ARRAYLANG['TXT_DOWNLOADS_ASSIGNED_USER_GROUPS'], 'TXT_DOWNLOADS_CHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_CHECK_ALL'], 'TXT_DOWNLOADS_UNCHECK_ALL' => $_ARRAYLANG['TXT_DOWNLOADS_UNCHECK_ALL'], 'TXT_DOWNLOADS_CANCEL' => $_ARRAYLANG['TXT_DOWNLOADS_CANCEL'], 'TXT_DOWNLOADS_SAVE' => $_ARRAYLANG['TXT_DOWNLOADS_SAVE']));
     // parse sorting & paging of the categories overview section
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CATEGORY_SORT' => !empty($_GET['category_sort']) ? $_GET['category_sort'] : '', 'DOWNLOADS_DOWNLOAD_CATEGORY_SORT_BY' => !empty($_GET['category_by']) ? $_GET['category_by'] : '', 'DOWNLOADS_DOWNLOAD_DOWNLOAD_SORT' => !empty($_GET['download_sort']) ? $_GET['download_sort'] : '', 'DOWNLOADS_DOWNLOAD_DOWNLOAD_BY' => !empty($_GET['download_by']) ? $_GET['download_by'] : '', 'DOWNLOADS_DOWNLOAD_CATEGORY_OFFSET' => !empty($_GET['category_pos']) ? intval($_GET['category_pos']) : 0, 'DOWNLOADS_DOWNLOAD_DOWNLOAD_OFFSET' => !empty($_GET['download_pos']) ? intval($_GET['download_pos']) : 0));
     // parse id
     $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_ID', $objDownload->getId());
     // parse name and description attributres
     $arrLanguages = \FWLanguage::getLanguageArray();
     foreach ($arrLanguages as $langId => $arrLanguage) {
         if ($arrLanguage['frontend'] == 1) {
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_NAME' => htmlentities($objDownload->getName($langId), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_LANG_NAME' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET)));
             $this->objTemplate->parse('downloads_download_name_list');
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_DESCRIPTION' => htmlentities($objDownload->getDescription($langId), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_LANG_DESCRIPTION' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET)));
             $this->objTemplate->parse('downloads_download_description_list');
             if ($this->arrConfig['use_attr_metakeys']) {
                 $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_METAKEYS' => htmlentities($objDownload->getMetakeys($langId), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_LANG_METAKEYS' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET)));
                 $this->objTemplate->parse('downloads_download_metakeys_list');
             }
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_FILE_SOURCE' => $objDownload->getType() == 'file' ? htmlentities($objDownload->getSource($langId), ENT_QUOTES, CONTREXX_CHARSET) : '', 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'DOWNLOADS_DOWNLOAD_LANG_NAME' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET)));
             $this->objTemplate->parse('downloads_download_file_source_list');
             $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_LANG_ID' => $langId, 'DOWNLOADS_DOWNLOAD_URL_SOURCE' => $objDownload->getType() == 'url' ? htmlentities($objDownload->getSource($langId), ENT_QUOTES, CONTREXX_CHARSET) : 'http://', 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'DOWNLOADS_DOWNLOAD_LANG_NAME' => htmlentities($arrLanguage['name'], ENT_QUOTES, CONTREXX_CHARSET)));
             $this->objTemplate->parse('downloads_download_url_source_list');
         }
     }
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_NAME' => htmlentities($objDownload->getName(), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_DOWNLOADS_EXTENDED' => $_ARRAYLANG['TXT_DOWNLOADS_EXTENDED']));
     $this->objTemplate->parse('downloads_download_name');
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_DESCRIPTION' => htmlentities($objDownload->getDescription(), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_DOWNLOADS_EXTENDED' => $_ARRAYLANG['TXT_DOWNLOADS_EXTENDED']));
     $this->objTemplate->parse('downloads_download_description');
     // parse metakeys
     if ($this->arrConfig['use_attr_metakeys']) {
         $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_METAKEYS' => htmlentities($objDownload->getMetakeys(), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_DOWNLOADS_EXTENDED' => $_ARRAYLANG['TXT_DOWNLOADS_EXTENDED']));
         $this->objTemplate->parse('downloads_download_metakeys');
         $this->objTemplate->parse('downloads_download_attr_metakeys');
     } else {
         $this->objTemplate->hideBlock('downloads_download_attr_metakeys');
     }
     // parse type
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_TYPE_FILE_CHECKED' => $objDownload->getType() == 'file' ? 'checked="checked"' : '', 'DOWNLOADS_DOWNLOAD_TYPE_URL_CHECKED' => $objDownload->getType() == 'url' ? 'checked="checked"' : '', 'DOWNLOADS_DOWNLOAD_TYPE_FILE_CONFIG_DISPLAY' => $objDownload->getType() == 'file' ? 'block' : 'none', 'DOWNLOADS_DOWNLOAD_TYPE_URL_CONFIG_DISPLAY' => $objDownload->getType() == 'url' ? 'block' : 'none', 'DOWNLOADS_DOWNLOAD_FILE_SOURCE' => $objDownload->getType() == 'file' ? $objDownload->getSource() : '', 'DOWNLOADS_DOWNLOAD_URL_SOURCE' => $objDownload->getType() == 'url' ? $objDownload->getSource() : 'http://', 'TXT_DOWNLOADS_BROWSE' => $_ARRAYLANG['TXT_DOWNLOADS_BROWSE'], 'TXT_DOWNLOADS_EXTENDED' => $_ARRAYLANG['TXT_DOWNLOADS_EXTENDED']));
     foreach (Download::$arrMimeTypes as $mimeType => $arrMimeType) {
         if (!count($arrMimeType['extensions'])) {
             continue;
         }
         $this->objTemplate->setVariable(array('DOWNLOADS_MIME_TYPE' => $mimeType, 'DOWNLOADS_FILE_EXTENSION_REGEXP' => implode('|', $arrMimeType['extensions'])));
         $this->objTemplate->parse('downloads_download_file_ext_regexp');
     }
     // parse mime type
     $this->objTemplate->setVariable('DOWNLOADS_DOWNLOAD_MIME_TYPE_MENU', $this->getDownloadMimeTypeMenu($objDownload->getMimeType()));
     $attrRow = 0;
     // parse size
     if ($this->arrConfig['use_attr_size']) {
         $this->objTemplate->setVariable(array('TXT_DOWNLOADS_BYTES' => $_ARRAYLANG['TXT_DOWNLOADS_BYTES'], 'DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_SIZE' => $objDownload->getSize()));
         $this->objTemplate->parse('downloads_download_attr_size');
     } else {
         $this->objTemplate->hideBlock('downloads_download_attr_size');
     }
     // parse license
     if ($this->arrConfig['use_attr_license']) {
         $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADs_DOWNLOAD_LICENSE' => htmlentities($objDownload->getLicense(), ENT_QUOTES, CONTREXX_CHARSET)));
         $this->objTemplate->parse('downloads_download_attr_license');
     } else {
         $this->objTemplate->hideBlock('downloads_download_attr_license');
     }
     // parse version
     if ($this->arrConfig['use_attr_version']) {
         $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_VERSION' => htmlentities($objDownload->getVersion(), ENT_QUOTES, CONTREXX_CHARSET)));
         $this->objTemplate->parse('downloads_download_attr_version');
     } else {
         $this->objTemplate->hideBlock('downloads_download_attr_version');
     }
     // parse author
     if ($this->arrConfig['use_attr_author']) {
         $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_AUTHOR' => htmlentities($objDownload->getAuthor(), ENT_QUOTES, CONTREXX_CHARSET)));
         $this->objTemplate->parse('downloads_download_attr_author');
     } else {
         $this->objTemplate->hideBlock('downloads_download_attr_author');
     }
     // parse website
     if ($this->arrConfig['use_attr_website']) {
         $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_WEBSITE' => htmlentities($objDownload->getWebsite(), ENT_QUOTES, CONTREXX_CHARSET)));
         $this->objTemplate->parse('downloads_download_attr_website');
     } else {
         $this->objTemplate->hideBlock('downloads_download_attr_website');
     }
     // parse validity expiration menu
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ATTRIBUTE_ROW' => $attrRow++ % 2 + 1, 'DOWNLOADS_DOWNLOAD_VALIDITY_EXPIRATION_MENU' => $this->getValidityMenu($objDownload->getValidityTimePeriod(), $objDownload->getExpirationDate())));
     // parse active status
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_IS_ACTIVE_CHECKED' => $objDownload->getActiveStatus() ? 'checked="checked"' : ''));
     // parse image attribute
     $image = $objDownload->getImage();
     if (!empty($image) && file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . '/' . $image)) {
         $thumb_name = \ImageManager::getThumbnailFilename($image);
         if (file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . '/' . $thumb_name)) {
             $imageSrc = $thumb_name;
         } else {
             $imageSrc = $image;
         }
     } else {
         $image = '';
         $imageSrc = $this->defaultDownloadImage['src'];
     }
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_IMAGE' => $image, 'DOWNLOADS_DOWNLOAD_IMAGE_SRC' => $imageSrc, 'DOWNLOADS_DEFAULT_DOWNLOAD_IMAGE' => $this->defaultDownloadImage['src'], 'DOWNLOADS_DEFAULT_DOWNLOAD_IMAGE_WIDTH' => $this->defaultDownloadImage['width'] . 'px', 'DOWNLOADS_DEFAULT_DOWNLOAD_IMAGE_HEIGHT' => $this->defaultDownloadImage['height'] . 'px', 'DOWNLOADS_DOWNLOAD_IMAGE_REMOVE_DISPLAY' => empty($image) ? 'none' : ''));
     // parse associated categories
     $arrCategories = $this->getParsedCategoryListForDownloadAssociation();
     $arrAssociatedCategories = $objDownload->getAssociatedCategoryIds();
     $length = count($arrCategories);
     for ($i = 0; $i < $length; $i++) {
         if (\Permission::checkAccess(143, 'static', true) || !in_array($arrCategories[$i]['id'], $arrAssociatedCategories) && (!$arrCategories[$i]['add_files_access_id'] || \Permission::checkAccess($arrCategories[$i]['add_files_access_id'], 'dynamic', true)) || in_array($arrCategories[$i]['id'], $arrAssociatedCategories) && (!$arrCategories[$i]['manage_files_access_id'] || \Permission::checkAccess($arrCategories[$i]['manage_files_access_id'], 'dynamic', true)) || $objFWUser->objUser->login() && $arrCategories[$i]['owner_id'] == $objFWUser->objUser->getId()) {
             $disabled = false;
         } else {
             $disabled = true;
         }
         $option = '<option value="' . $arrCategories[$i]['id'] . '"' . ($disabled ? ' disabled="disabled"' : '') . '>' . htmlentities($arrCategories[$i]['name'], ENT_QUOTES, CONTREXX_CHARSET) . '</option>';
         if (in_array($arrCategories[$i]['id'], $arrAssociatedCategories) || !$objDownload->getId() && $arrCategories[$i]['id'] == $this->parentCategoryId) {
             $arrAssociatedCategoryOptions[] = $option;
         } else {
             $arrNotAssociatedCategoryOptions[] = $option;
         }
     }
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ASSOCIATED_CATEGORIES' => implode("\n", $arrAssociatedCategoryOptions), 'DOWNLOADS_DOWNLOAD_NOT_ASSOCIATED_CATEGORIES' => implode("\n", $arrNotAssociatedCategoryOptions)));
     // parse related downloads
     $arrRelatedDownloads = $objDownload->getRelatedDownloadIds();
     $objAvailableDownload = new Download();
     $sortOrder = $this->downloadsSortingOptions[$this->arrConfig['downloads_sorting_order']];
     $objAvailableDownload->loadDownloads(null, null, $sortOrder);
     while (!$objAvailableDownload->EOF) {
         if ($objAvailableDownload->getId() == $objDownload->getId()) {
             $objAvailableDownload->next();
             continue;
         }
         $option = '<option value="' . $objAvailableDownload->getId() . '">' . htmlentities($objAvailableDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET) . ' (' . htmlentities($objAvailableDownload->getDescription($_LANGID), ENT_QUOTES, CONTREXX_CHARSET) . ')</option>';
         if (in_array($objAvailableDownload->getId(), $arrRelatedDownloads)) {
             $arrAssociatedDownloadOptions[] = $option;
         } else {
             $arrNotAssociatedDownloadOptions[] = $option;
         }
         $objAvailableDownload->next();
     }
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ASSOCIATED_DOWNLOADS' => implode("\n", $arrAssociatedDownloadOptions), 'DOWNLOADS_DOWNLOAD_NOT_ASSOCIATED_DOWNLOADS' => implode("\n", $arrNotAssociatedDownloadOptions)));
     // parse access permissions
     if ($objDownload->getAccessId()) {
         $objGroup = $objFWUser->objGroup->getGroups(array('dynamic' => $objDownload->getAccessId()));
         $arrAssociatedGroups = $objGroup->getLoadedGroupIds();
     } elseif ($objDownload->getProtection()) {
         $arrAssociatedGroups = $objDownload->getAccessGroupIds();
     } else {
         //$arrAssociatedCategories = $objDownload->getAssociatedCategoryIds();
         if (count($arrAssociatedCategories)) {
             $objCategory = Category::getCategories(array('id' => $arrAssociatedCategories), null, null, array('id', 'read_access_id'));
             while (!$objCategory->EOF) {
                 if ($objCategory->getReadAccessId()) {
                     $objGroup = $objFWUser->objGroup->getGroups(array('dynamic' => $objCategory->getReadAccessId()));
                     $arrAssociatedGroups = array_merge($arrAssociatedGroups, $objGroup->getLoadedGroupIds());
                 }
                 $objCategory->next();
             }
         } else {
             // TODO: WHY THAT?
             $objGroup = $objFWUser->objGroup->getGroups();
             $arrAssociatedGroups = $objGroup->getLoadedGroupIds();
         }
     }
     $objGroup = $objFWUser->objGroup->getGroups();
     while (!$objGroup->EOF) {
         $option = '<option value="' . $objGroup->getId() . '">' . htmlentities($objGroup->getName(), ENT_QUOTES, CONTREXX_CHARSET) . ' [' . $objGroup->getType() . ']</option>';
         if (in_array($objGroup->getId(), $arrAssociatedGroups)) {
             $arrAssociatedGroupOptions[] = $option;
         } else {
             $arrNotAssociatedGroupOptions[] = $option;
         }
         $objGroup->next();
     }
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_ACCESS_ALL_CHECKED' => !$objDownload->getProtection() ? 'checked="checked"' : '', 'DOWNLOADS_DOWNLOAD_ACCESS_SELECTED_CHECKED' => $objDownload->getProtection() ? 'checked="checked"' : '', 'DOWNLOADS_DOWNLOAD_ACCESS_DISPLAY' => $objDownload->getProtection() ? '' : 'none', 'DOWNLOADS_DOWNLOAD_ACCESS_ASSOCIATED_GROUPS' => implode("\n", $arrAssociatedGroupOptions), 'DOWNLOADS_DOWNLOAD_ACCESS_NOT_ASSOCIATED_GROUPS' => implode("\n", $arrNotAssociatedGroupOptions), 'DOWNLOADS_DOWNLOAD_VISIBILITY_CHECKED' => $objDownload->getVisibility() ? 'checked="checked"' : ''));
     // parse cancel link
     $this->objTemplate->setVariable(array('DOWNLOADS_DOWNLOAD_CANCEL_LINK_SECITON' => $this->parentCategoryId ? 'categories' : 'downloads', 'DOWNLOADS_PARENT_CATEGORY_ID' => $this->parentCategoryId, 'DOWNLOADS_MEDIA_BROWSER_BUTTON' => self::getMediaBrowserButton('mediabrowser_button', 'filebrowser')));
     return true;
 }
Пример #12
0
 protected function removeUselessImages()
 {
     global $objDatabase;
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     // Regex matching folders and files not to be deleted
     $noAvatarThumbSrc = \ImageManager::getThumbnailFilename($cx->getWebsiteImagesAccessProfileWebPath() . '/' . \User_Profile::$arrNoAvatar['src']);
     $noPictureThumbSrc = \ImageManager::getThumbnailFilename($cx->getWebsiteImagesAccessPhotoWebPath() . '/' . \User_Profile::$arrNoPicture['src']);
     $ignoreRe = '/(?:\\.(?:\\.?|svn)' . '|' . preg_quote(\User_Profile::$arrNoAvatar['src'], '/') . '|' . preg_quote($noAvatarThumbSrc, '/') . '|' . preg_quote(\User_Profile::$arrNoPicture['src'], '/') . '|' . preg_quote($noPictureThumbSrc, '/') . ')$/';
     $arrTrueFalse = array(true, false);
     foreach ($arrTrueFalse as $profilePics) {
         $imageWebPath = $profilePics ? $cx->getWebsiteImagesAccessProfileWebPath() : $cx->getWebsiteImagesAccessPhotoWebPath();
         $imagePath = $profilePics ? $cx->getWebsiteImagesAccessProfilePath() : $cx->getWebsiteImagesAccessPhotoPath();
         $arrImages = array();
         $offset = 0;
         $step = 50000;
         // TODO: Never used
         //            $removeImages = array();
         if (CONTREXX_PHP5) {
             $arrImages = scandir($imagePath);
         } else {
             // TODO: We're PHP5 *ONLY* now.  This is obsolete
             $dh = opendir($imagePath);
             $image = readdir($dh);
             while ($image !== false) {
                 $arrImages[] = $image;
                 $image = readdir($dh);
             }
             closedir($dh);
         }
         foreach ($arrImages as $index => $file) {
             if (preg_match($ignoreRe, $file)) {
                 unset($arrImages[$index]);
             }
         }
         if ($profilePics) {
             $query = "\n                    SELECT SUM(1) as entryCount\n                    FROM `" . DBPREFIX . "access_user_profile`\n                    WHERE `picture` != ''";
         } else {
             $query = "\n                    SELECT SUM(1) as entryCount\n                    FROM `" . DBPREFIX . "access_user_attribute` AS a\n                    INNER JOIN `" . DBPREFIX . "access_user_attribute_value` AS v ON v.`attribute_id` = a.`id`\n                    WHERE a.`type` = 'image' AND v.`value` != ''";
         }
         $objCount = $objDatabase->Execute($query);
         if ($objCount !== false) {
             $count = $objCount->fields['entryCount'];
         } else {
             return false;
         }
         if ($profilePics) {
             $query = "\n                    SELECT `picture`\n                    FROM `" . DBPREFIX . "access_user_profile`\n                    WHERE `picture` != ''";
         } else {
             $query = "\n                    SELECT v.`value` AS picture\n                    FROM `" . DBPREFIX . "access_user_attribute` AS a\n                    INNER JOIN `" . DBPREFIX . "access_user_attribute_value` AS v ON v.`attribute_id` = a.`id`\n                    WHERE a.`type` = 'image' AND v.`value` != ''";
         }
         while ($offset < $count) {
             $objImage = $objDatabase->SelectLimit($query, $step, $offset);
             if ($objImage !== false) {
                 $arrImagesDb = array();
                 while (!$objImage->EOF) {
                     $arrImagesDb[] = $objImage->fields['picture'];
                     $arrImagesDb[] = basename(\ImageManager::getThumbnailFilename($imageWebPath . '/' . $objImage->fields['picture']));
                     $objImage->MoveNext();
                 }
                 $offset += $step;
                 $arrImages = array_diff($arrImages, $arrImagesDb);
             }
         }
         array_walk($arrImages, create_function('$img', 'unlink("' . $imagePath . '/".$img);'));
     }
     return true;
 }
Пример #13
0
 /**
  * Get a single entry view
  * @param int $id
  * @return string
  */
 function getDetail($id)
 {
     global $_LANGID;
     if ($this->entryArray === false) {
         $this->entryArray = $this->createEntryArray();
     }
     $entry = $this->entryArray[$id];
     $title = $entry['translation'][$_LANGID]['subject'];
     $content = $this->getIntroductionText($entry['translation'][$_LANGID]['content']);
     $this->_objTpl->setTemplate($this->adjustTemplatePlaceholders($this->_arrSettings['data_template_entry']));
     $translation = $entry['translation'][$_LANGID];
     $image = '';
     if (!empty($translation['thumbnail'])) {
         if ($translation['thumbnail_type'] == 'original') {
             $image = $translation['thumbnail'];
         } else {
             $image = \ImageManager::getThumbnailFilename($translation['thumbnail']);
         }
     } else {
         $path = \ImageManager::getThumbnailFilename($translation['image']);
         if (file_exists(ASCMS_PATH . $path)) {
             $image = $path;
         }
     }
     if (!empty($image)) {
         $image = '<img src=' . $image . ' alt=\\"\\" style=\\"float: left\\" />';
     } else {
         $image = '';
     }
     $lang = $_LANGID;
     $width = $this->_arrSettings['data_shadowbox_width'];
     $height = $this->_arrSettings['data_shadowbox_height'];
     if ($entry['mode'] == "normal") {
         if ($this->_arrSettings['data_entry_action'] == "content") {
             $cmd = $this->_arrSettings['data_target_cmd'];
             $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Data', $cmd, '', array('id' => $id));
         } else {
             $url = \Cx\Core\Routing\Url::fromModuleAndCmd('Data', '', '', array('height' => $height, 'width' => $width, 'id' => $id, 'lang' => $lang));
         }
     } else {
         $url = $entry['translation'][$_LANGID]['forward_url'] . '&amp;id=' . $id;
     }
     $templateVars = array("TITLE" => $title, "IMAGE" => $image, "CONTENT" => $content, "HREF" => $url, "CLASS" => $this->_arrSettings['data_entry_action'] == "overlaybox" && $entry['mode'] == "normal" ? "rel=\"shadowbox;width=" . $width . ";height=" . $height . "\"" : "", "TXT_MORE" => $this->langVars['TXT_DATA_MORE']);
     $this->_objTpl->setVariable($templateVars);
     $this->_objTpl->parse("datalist_entry");
     return $this->_objTpl->get();
 }
Пример #14
0
 /**
  * Create thumbnail and update the corresponding ShopCategory records
  *
  * Scans the ShopCategories with the given IDs.  If a non-empty picture
  * string with a reasonable extension is encountered, determines whether
  * the corresponding thumbnail is available and up to date or not.
  * If not, tries to load the file and to create a thumbnail.
  * Note that only single file names are supported!
  * Also note that this method returns a string with information about
  * problems that were encountered.
  * It skips records which contain no or invalid image
  * names, thumbnails that cannot be created, and records which refuse
  * to be updated!
  * The reasoning behind this is that this method is currently only called
  * from within some {@link _import()} methods.  The focus lies on importing;
  * whether or not thumbnails can be created is secondary, as the
  * process can be repeated if there is a problem.
  * @param   integer     $id         The ShopCategory ID
  * @param   integer     $maxWidth   The maximum thubnail width
  * @param   integer     $maxHeight  The maximum thubnail height
  * @param   integer     $quality    The thumbnail quality
  * @return  string                  Empty string on success, a string
  *                                  with error messages otherwise.
  * @global  array
  * @static
  * @author  Reto Kohli <*****@*****.**>
  */
 static function makeThumbnailById($id, $maxWidth = 120, $maxHeight = 80, $quality = 90)
 {
     /*
         Note: The size and quality parameters should be taken from the
               settings as follows:
         \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_width','Shop'),
         \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_height','Shop'),
         \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_quality','Shop')
     */
     global $_ARRAYLANG;
     if ($id <= 0) {
         return sprintf($_ARRAYLANG['TXT_SHOP_INVALID_CATEGORY_ID'], $id);
     }
     $objCategory = ShopCategory::getById($id, LANGID);
     if (!$objCategory) {
         return sprintf($_ARRAYLANG['TXT_SHOP_INVALID_CATEGORY_ID'], $id);
     }
     $imageName = $objCategory->picture();
     $imagePath = SHOP_CATEGORY_IMAGE_PATH . '/' . $imageName;
     // Only try to create thumbs from entries that contain a
     // plain text file name (i.e. from an import)
     if ($imageName == '' || !preg_match('/\\.(?:jpe?g|gif|png)$/', $imageName)) {
         return sprintf($_ARRAYLANG['TXT_SHOP_UNSUPPORTED_IMAGE_FORMAT'], $id, $imageName);
     }
     // If the picture is missing, skip it.
     if (!file_exists($imagePath)) {
         return sprintf($_ARRAYLANG['TXT_SHOP_MISSING_CATEGORY_IMAGES'], $id, $imageName);
     }
     // If the thumbnail exists and is newer than the picture,
     // don't create it again.
     $thumb_name = ImageManager::getThumbnailFilename($imagePath);
     if (file_exists($thumb_name) && filemtime($thumb_name) > filemtime($imagePath)) {
         return '';
     }
     // Already included by the Shop.
     $objImageManager = new \ImageManager();
     // Create thumbnail.
     // Deleting the old thumb beforehand is integrated into
     // _createThumbWhq().
     if (!$objImageManager->_createThumbWhq(SHOP_CATEGORY_IMAGE_PATH . '/', SHOP_CATEGORY_IMAGE_WEB_PATH . '/', $imageName, $maxWidth, $maxHeight, $quality)) {
         return sprintf($_ARRAYLANG['TXT_SHOP_ERROR_CREATING_CATEGORY_THUMBNAIL'], $id);
     }
     return '';
 }
Пример #15
0
 function initializeTeasers()
 {
     global $objDatabase, $_CORELANG;
     $this->arrTeasers = array();
     $this->getSettings();
     $objResult = $objDatabase->Execute("\n            SELECT tblN.id,\n                   tblN.date,\n                   tblN.userid,\n                   tblN.teaser_frames,\n                   tblN.redirect,\n                   tblN.teaser_show_link,\n                   tblN.teaser_image_path,\n                   tblN.teaser_image_thumbnail_path,\n                   tblL.title,\n                   tblL.text AS teaser_full_text,\n                   tblL.teaser_text\n              FROM " . DBPREFIX . "module_news AS tblN\n             INNER JOIN " . DBPREFIX . "module_news_locale AS tblL ON tblL.news_id=tblN.id\n             WHERE tblL.lang_id=" . FRONTEND_LANG_ID . ($this->administrate == false ? " AND tblN.validated='1'\n                    AND tblN.status='1'\n                    AND tblL.is_active=1\n                    AND (tblN.startdate<='" . date('Y-m-d H:i:s') . "' OR tblN.startdate='0000-00-00 00:00:00') AND (tblN.enddate>='" . date('Y-m-d H:i:s') . "' OR tblN.enddate='0000-00-00 00:00:00')" : "") . ($this->arrSettings['news_message_protection'] == '1' && !\Permission::hasAllAccess() ? ($objFWUser = \FWUser::getFWUserObject()) && $objFWUser->objUser->login() ? " AND (tblN.frontend_access_id IN (" . implode(',', array_merge(array(0), $objFWUser->objUser->getDynamicPermissionIds())) . ") OR userid = " . $objFWUser->objUser->getId() . ") " : " AND tblN.frontend_access_id=0 " : '') . "\n             ORDER BY date DESC");
     if ($objResult !== false) {
         while (!$objResult->EOF) {
             $arrFrames = explode(';', $objResult->fields['teaser_frames']);
             foreach ($arrFrames as $frameId) {
                 if (!isset($this->arrFrameTeaserIds[$frameId])) {
                     $this->arrFrameTeaserIds[$frameId] = array();
                 }
                 array_push($this->arrFrameTeaserIds[$frameId], $objResult->fields['id']);
             }
             if (!empty($objResult->fields['redirect'])) {
                 $extUrl = substr($objResult->fields['redirect'], 7);
                 $tmp = explode('/', $extUrl);
                 $extUrl = "(" . $tmp[0] . ")";
             } else {
                 $extUrl = "";
             }
             if ($this->administrate == false) {
                 $objFWUser = \FWUser::getFWUserObject();
                 $objUser = $objFWUser->objUser->getUser($objResult->fields['userid']);
                 if ($objUser) {
                     $firstname = $objUser->getProfileAttribute('firstname');
                     $lastname = $objUser->getProfileAttribute('lastname');
                     if (!empty($firstname) && !empty($lastname)) {
                         $author = contrexx_raw2xhtml($firstname . ' ' . $lastname);
                     } else {
                         $author = contrexx_raw2xhtml($objUser->getUsername());
                     }
                 } else {
                     $author = $_CORELANG['TXT_ANONYMOUS'];
                 }
             } else {
                 $author = '';
             }
             if (!empty($objResult->fields['teaser_image_thumbnail_path'])) {
                 $image = $objResult->fields['teaser_image_thumbnail_path'];
             } elseif (!empty($objResult->fields['teaser_image_path']) && file_exists(ASCMS_PATH . \ImageManager::getThumbnailFilename($objResult->fields['teaser_image_path']))) {
                 $image = \ImageManager::getThumbnailFilename($objResult->fields['teaser_image_path']);
             } elseif (!empty($objResult->fields['teaser_image_path'])) {
                 $image = $objResult->fields['teaser_image_path'];
             } else {
                 $image = ASCMS_CORE_MODULE_WEB_PATH . '/News/View/Media/pixel.gif';
             }
             $newsCategories = $this->getCategoriesByNewsId($objResult->fields['id']);
             $this->arrTeasers[$objResult->fields['id']] = array('id' => $objResult->fields['id'], 'date' => $objResult->fields['date'], 'title' => $objResult->fields['title'], 'teaser_frames' => $objResult->fields['teaser_frames'], 'redirect' => $objResult->fields['redirect'], 'ext_url' => $extUrl, 'category' => implode(', ', contrexx_raw2xhtml($newsCategories)), 'category_id' => array_keys($newsCategories), 'teaser_full_text' => $objResult->fields['teaser_full_text'], 'teaser_text' => $objResult->fields['teaser_text'], 'teaser_show_link' => $objResult->fields['teaser_show_link'], 'author' => $author, 'teaser_image_path' => $image);
             $objResult->MoveNext();
         }
     }
 }
Пример #16
0
 function showSearch($keyword)
 {
     global $objDatabase, $_LANGID, $_ARRAYLANG;
     if (!empty($keyword) && ($objResult = $objDatabase->Execute("\n                SELECT tblM.message_id, tblL.subject, tblL.content,\n                       tblL.image, tblL.thumbnail, tblL.mode,\n                       tblL.forward_url, tblL.forward_target\n                  FROM `" . DBPREFIX . "module_data_messages` AS tblM\n                 INNER JOIN `" . DBPREFIX . "module_data_messages_lang` AS tblL\n                 USING (message_id)\n                 WHERE tblM.active = '1'\n                   AND (tblM.release_time = 0 or tblM.release_time <= " . time() . ")\n                   AND (tblM.release_time_end = 0 or tblM.release_time_end >= " . time() . ")\n                   AND tblL.is_active = '1'\n                   AND tblL.lang_id = " . $_LANGID . "\n                   AND (tblL.subject LIKE '%" . addslashes($keyword) . "%'\n                    OR tblL.content LIKE '%" . addslashes($keyword) . "%'\n                    OR tblL.tags LIKE '%" . addslashes($keyword) . "%')")) && $objResult && $objResult->RecordCount()) {
         while (!$objResult->EOF) {
             $image = "";
             if ($objResult->fields['image']) {
                 if ($objResult->fields['thumbnail']) {
                     $thumb_name = \ImageManager::getThumbnailFilename($objResult->fields['thumbnail']);
                     if (file_exists(ASCMS_PATH . $thumb_name)) {
                         $image = "<img src=\"" . $thumb_name . "\" alt=\"\" border=\"1\" style=\"float: left; width:100px;\"/>";
                     } else {
                         $image = "<img src=\"" . $objResult->fields['thumbnail'] . "\" alt=\"\" border=\"1\" style=\"float: left; width: 80px;\" />";
                     }
                 } elseif (file_exists(ASCMS_DATA_IMAGES_PATH . '/' . $objResult->fields['message_id'] . '_' . $_LANGID . '_' . basename($objResult->fields['image']))) {
                     $image = "<img src=\"" . ASCMS_DATA_IMAGES_WEB_PATH . '/' . $objResult->fields['message_id'] . '_' . $_LANGID . '_' . basename($objResult->fields['image']) . "\" alt=\"\" border=\"1\" style=\"float: left; width:100px;\"/>";
                 } elseif (file_exists(ASCMS_PATH . \ImageManager::getThumbnailFilename($objResult->fields['image']))) {
                     $image = "<img src=\"" . \ImageManager::getThumbnailFilename($objResult->fields['image']) . "\" alt=\"\" border=\"1\" style=\"float: left; width:100px;\"/>";
                 } else {
                     $image = "<img src=\"" . $objResult->fields['image'] . "\" alt=\"\" border=\"1\" style=\"float: left; width: 80px;\" />";
                 }
             }
             $lang = $_LANGID;
             $width = $this->_arrSettings['data_shadowbox_width'];
             $height = $this->_arrSettings['data_shadowbox_height'];
             if ($objResult->fields['mode'] == "normal") {
                 if ($this->_arrSettings['data_entry_action'] == "content") {
                     $cmd = $this->_arrSettings['data_target_cmd'];
                     $url = "index.php?section=Data&amp;cmd=" . $cmd;
                 } else {
                     $url = "index.php?section=Data&amp;act=shadowbox&amp;height=" . $height . "&amp;width=" . $width . "&amp;lang=" . $lang;
                 }
             } else {
                 $url = $objResult->fields['forward_url'];
             }
             $this->_objTpl->setVariable(array('ENTRY_HREF' => $url . "&amp;id=" . $objResult->fields['message_id'], 'ENTRY_IMAGE' => $image, 'ENTRY_TITLE' => $objResult->fields['subject'], 'TXT_MORE' => $this->langVars['TXT_DATA_MORE']));
             $this->_objTpl->parse('single_entry');
             $objResult->MoveNext();
         }
         $this->_objTpl->parse('datalist_single_category');
     } else {
         $this->_objTpl->hideBlock('datalist_single_category');
     }
     $this->_objTpl->setVariable(array('DATA_SEARCH_TERM' => htmlentities($keyword, ENT_QUOTES, CONTREXX_CHARSET), 'TXT_DATA_SEARCH' => $_ARRAYLANG['TXT_DATA_SEARCH']));
 }
Пример #17
0
 /**
  * Manage products
  *
  * Add and edit products
  * @access  public
  * @return  string
  * @author  Reto Kohli <*****@*****.**> (parts)
  */
 function view_product_edit()
 {
     global $_ARRAYLANG;
     self::store_product();
     $product_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
     $objProduct = null;
     self::$objTemplate->addBlockfile('SHOP_PRODUCTS_FILE', 'shop_products_block', 'module_shop_product_manage.html');
     self::$objTemplate->setGlobalVariable($_ARRAYLANG);
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     self::$objTemplate->setVariable(array('SHOP_DELETE_ICON' => $cx->getCodeBaseCoreWebPath() . '/Core/View/Media/icons/delete.gif', 'SHOP_NO_PICTURE_ICON' => self::$defaultImage));
     if ($product_id > 0) {
         $objProduct = Product::getById($product_id);
     }
     if (!$objProduct) {
         $objProduct = new Product('', 0, '', '', 0, 1, 0, 0);
     }
     $this->viewpart_product_attributes($product_id);
     $arrImages = Products::get_image_array_from_base64($objProduct->pictures());
     // Virtual Categories are disabled FTTB
     //        $flagsSelection =
     //            ShopCategories::getVirtualCategoriesSelectionForFlags(
     //                $objProduct->flags()
     //            );
     //        if ($flagsSelection) {
     //            self::$objTemplate->setVariable(
     //                'SHOP_FLAGS_SELECTION', $flagsSelection);
     //        }
     //
     // media browser
     $mediaBrowserOptions = array('type' => 'button', 'data-cx-mb-startmediatype' => 'shop', 'data-cx-mb-views' => 'filebrowser', 'id' => 'media_browser_shop', 'style' => 'display:none');
     self::$objTemplate->setVariable(array('MEDIABROWSER_BUTTON' => self::getMediaBrowserButton($mediaBrowserOptions, 'setSelectedImage')));
     $distribution = $objProduct->distribution();
     // Available active frontend groups, and those assigned to the product
     $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('type' => 'frontend', 'is_active' => true), array('group_id' => 'asc'));
     $usergroup_ids = $objProduct->usergroup_ids();
     $arrAssignedFrontendGroupId = explode(',', $usergroup_ids);
     $strActiveFrontendGroupOptions = '';
     $strAssignedFrontendGroupOptions = '';
     while ($objGroup && !$objGroup->EOF) {
         $strOption = '<option value="' . $objGroup->getId() . '">' . htmlentities($objGroup->getName(), ENT_QUOTES, CONTREXX_CHARSET) . '</option>';
         if (in_array($objGroup->getId(), $arrAssignedFrontendGroupId)) {
             $strAssignedFrontendGroupOptions .= $strOption;
         } else {
             $strActiveFrontendGroupOptions .= $strOption;
         }
         $objGroup->next();
     }
     $discount_group_count_id = $objProduct->group_id();
     $discount_group_article_id = $objProduct->article_id();
     $keywords = $objProduct->keywords();
     //die($objProduct->category_id());
     // Product assigned to multiple Categories
     $arrAssignedCategories = ShopCategories::getAssignedShopCategoriesMenuoptions($objProduct->category_id());
     // Date format for Datepicker:
     // Clear the date if none is set; there's no point in displaying
     // "01/01/1970" instead
     $start_date = $end_date = '';
     $start_time = strtotime($objProduct->date_start());
     // Note that the check for ">0" is necessary, as some systems return
     // crazy values for empty dates (it may even fail like this)!
     if ($start_time > 0) {
         $start_date = date(ASCMS_DATE_FORMAT_DATE, $start_time);
     }
     $end_time = strtotime($objProduct->date_end());
     if ($end_time > 0) {
         $end_date = date(ASCMS_DATE_FORMAT_DATE, $end_time);
     }
     //DBG::log("Dates from ".$objProduct->date_start()." ($start_time, $start_date) to ".$objProduct->date_start()." ($end_time, $end_date)");
     $websiteImagesShopPath = $cx->getWebsiteImagesShopPath() . '/';
     $websiteImagesShopWebPath = $cx->getWebsiteImagesShopWebPath() . '/';
     self::$objTemplate->setVariable(array('SHOP_PRODUCT_ID' => isset($_REQUEST['new']) ? 0 : $objProduct->id(), 'SHOP_PRODUCT_CODE' => contrexx_raw2xhtml($objProduct->code()), 'SHOP_PRODUCT_NAME' => contrexx_raw2xhtml($objProduct->name()), 'SHOP_CATEGORIES_ASSIGNED' => $arrAssignedCategories['assigned'], 'SHOP_CATEGORIES_AVAILABLE' => $arrAssignedCategories['available'], 'SHOP_CUSTOMER_PRICE' => contrexx_raw2xhtml(Currency::formatPrice($objProduct->price())), 'SHOP_RESELLER_PRICE' => contrexx_raw2xhtml(Currency::formatPrice($objProduct->resellerprice())), 'SHOP_DISCOUNT' => contrexx_raw2xhtml(Currency::formatPrice($objProduct->discountprice())), 'SHOP_SPECIAL_OFFER' => $objProduct->discount_active() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_VAT_MENUOPTIONS' => Vat::getMenuoptions($objProduct->vat_id(), true), 'SHOP_SHORT_DESCRIPTION' => new \Cx\Core\Wysiwyg\Wysiwyg('short', $objProduct->short()), 'SHOP_DESCRIPTION' => new \Cx\Core\Wysiwyg\Wysiwyg('long', $objProduct->long(), 'full'), 'SHOP_STOCK' => $objProduct->stock(), 'SHOP_MIN_ORDER_QUANTITY' => $objProduct->minimum_order_quantity(), 'SHOP_MANUFACTURER_URL' => contrexx_raw2xhtml($objProduct->uri()), 'SHOP_DATE_START' => \Html::getDatepicker('date_start', array('defaultDate' => $start_date), ''), 'SHOP_DATE_END' => \Html::getDatepicker('date_end', array('defaultDate' => $end_date), ''), 'SHOP_ARTICLE_ACTIVE' => $objProduct->active() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_B2B' => $objProduct->b2b() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_B2C' => $objProduct->b2c() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_STOCK_VISIBILITY' => $objProduct->stock_visible() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_MANUFACTURER_MENUOPTIONS' => Manufacturer::getMenuoptions($objProduct->manufacturer_id()), 'SHOP_PICTURE1_IMG_SRC' => !empty($arrImages[1]['img']) && is_file(\ImageManager::getThumbnailFilename($websiteImagesShopPath . $arrImages[1]['img'])) ? contrexx_raw2encodedUrl(\ImageManager::getThumbnailFilename($websiteImagesShopWebPath . $arrImages[1]['img'])) : self::$defaultImage, 'SHOP_PICTURE2_IMG_SRC' => !empty($arrImages[2]['img']) && is_file(\ImageManager::getThumbnailFilename($websiteImagesShopPath . $arrImages[2]['img'])) ? contrexx_raw2encodedUrl(\ImageManager::getThumbnailFilename($websiteImagesShopWebPath . $arrImages[2]['img'])) : self::$defaultImage, 'SHOP_PICTURE3_IMG_SRC' => !empty($arrImages[3]['img']) && is_file(\ImageManager::getThumbnailFilename($websiteImagesShopPath . $arrImages[3]['img'])) ? contrexx_raw2encodedUrl(\ImageManager::getThumbnailFilename($websiteImagesShopWebPath . $arrImages[3]['img'])) : self::$defaultImage, 'SHOP_PICTURE1_IMG_SRC_NO_THUMB' => !empty($arrImages[1]['img']) && is_file($websiteImagesShopPath . $arrImages[1]['img']) ? $websiteImagesShopWebPath . $arrImages[1]['img'] : self::$defaultImage, 'SHOP_PICTURE2_IMG_SRC_NO_THUMB' => !empty($arrImages[2]['img']) && is_file($websiteImagesShopPath . $arrImages[2]['img']) ? $websiteImagesShopWebPath . $arrImages[2]['img'] : self::$defaultImage, 'SHOP_PICTURE3_IMG_SRC_NO_THUMB' => !empty($arrImages[3]['img']) && is_file($websiteImagesShopPath . $arrImages[3]['img']) ? $websiteImagesShopWebPath . $arrImages[3]['img'] : self::$defaultImage, 'SHOP_PICTURE1_IMG_WIDTH' => $arrImages[1]['width'], 'SHOP_PICTURE1_IMG_HEIGHT' => $arrImages[1]['height'], 'SHOP_PICTURE2_IMG_WIDTH' => $arrImages[2]['width'], 'SHOP_PICTURE2_IMG_HEIGHT' => $arrImages[2]['height'], 'SHOP_PICTURE3_IMG_WIDTH' => $arrImages[3]['width'], 'SHOP_PICTURE3_IMG_HEIGHT' => $arrImages[3]['height'], 'SHOP_DISTRIBUTION_MENU' => Distribution::getDistributionMenu($objProduct->distribution(), 'distribution', 'distributionChanged();', 'style="width: 220px"'), 'SHOP_WEIGHT' => $distribution == 'delivery' ? Weight::getWeightString($objProduct->weight()) : '0 g', 'SHOP_GROUPS_AVAILABLE' => $strActiveFrontendGroupOptions, 'SHOP_GROUPS_ASSIGNED' => $strAssignedFrontendGroupOptions, 'SHOP_ACCOUNT_VALIDITY_OPTIONS' => \FWUser::getValidityMenuOptions($distribution == 'download' ? $objProduct->weight() : 0), 'SHOP_CREATE_ACCOUNT_YES_CHECKED' => empty($usergroup_ids) ? '' : \Html::ATTRIBUTE_CHECKED, 'SHOP_CREATE_ACCOUNT_NO_CHECKED' => empty($usergroup_ids) ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_DISCOUNT_GROUP_COUNT_MENU_OPTIONS' => Discount::getMenuOptionsGroupCount($discount_group_count_id), 'SHOP_DISCOUNT_GROUP_ARTICLE_MENU_OPTIONS' => Discount::getMenuOptionsGroupArticle($discount_group_article_id), 'SHOP_KEYWORDS' => contrexx_raw2xhtml($keywords), 'SHOP_WEIGHT_ENABLED' => \Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop') ? 1 : 0));
     return true;
 }