/** * Obtiene la ruta completa de la categor?a basada en nombres */ function path() { if ($this->getVar('parent') == 0) { return $this->getVar('shortname', 'n') . '/'; } $parent = new ShopCategory($this->getVar('parent', 'n')); return $parent->path() . $this->getVar('shortname') . '/'; }
/** * Example for jstree */ public function actionAjaxRoot($id) { header('Content-type: application/json; charset=UTF-8'); $d = ShopCategoryNode::fromArray(ShopCategory::model()->findAllByPk($id)); echo CJSON::encode($this->createHtmlTree($d)); die; }
public function run() { // Yii::import('mod.shop.models.ShopCategory'); $items = ShopCategory::model()->cache(Yii::app()->controller->cacheTime)->active()->findByPk(1)->menuArray(); //$items = ShopCategory::model()->active()->findByPk(1); $this->render('render', array('model' => $items)); }
protected function getMyItems() { $model = ShopCategory::model()->findByPk(1); if ($model) { $result = $model->menuArray(); return $result['items']; } }
public function run() { $items = ShopCategory::model()->language(Yii::app()->language->active)->findByPk($this->id)->menuArray(); if (isset($items)) { $this->render('default', array('items' => $items['items'])); } else { die("ParentCategoriesWidget: не могу найти root category."); } }
/** * Get all categories from database arranged by parents * * @param mixed $categories * @param mixed $parent * @param mixed $indent * @param mixed $include_subs * @param mixed $exclude * @param mixed $order */ public function categos_list(&$categories, $parent = 0, $indent = 0, $include_subs = true, $exclude = 0, $order = "id_cat DESC") { $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("shop_categories") . " WHERE parent='{$parent}' ORDER BY {$order}"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { if ($row['id_cat'] == $exclude) { continue; } $row['indent'] = $indent; $cat = new ShopCategory(); $cat->assignVars($row); $row['link'] = $cat->permalink(); $categories[] = $row; if ($include_subs) { ShopFunctions::categos_list($categories, $row['id_cat'], $indent + 1, $include_subs, $exclude); } } }
public function run() { Yii::import('mod.shop.models.ShopCategory'); $model = ShopCategory::model()->findByPk(1); if (!$model) { Yii::app()->tpl->alert('danger', 'Необходимо добавать категорию'); } else { $result = $model->menuArray(); $this->render($this->skin, array('result' => $result)); } }
/** * Display start page */ public function _loadModel($id) { // Find category if (Yii::app()->hasModule('shop')) { $model = ShopCategory::model()->excludeRoot()->findByPk($id); if (!$model) { throw new CHttpException(404, Yii::t('ShopModule.default', 'NOFIND_CATEGORY')); } return $model; } }
public function run() { Yii::import('mod.shop.models.ShopCategory'); $model = ShopCategory::model()->findByPk(1); if (!$model) { throw new CHttpException(500, 'Error CategoriesWidget'); } else { $result = $model->menuArray(); } $this->render($this->skin, array('result' => $result)); }
public function testLanguageLoad() { Yii::app()->languageManager->setActive('en'); $model = ShopCategory::model()->findByPk(1); $name = 'root_' . time(); $model->name = $name; $model->saveNode(); $this->assertTrue($model instanceof ShopCategory); $this->assertEquals($model->name, $name); Yii::app()->languageManager->setActive('ru'); $model = ShopCategory::model()->findByPk(1); $this->assertEquals($model->name, 'root'); }
public function afterUninstall() { Yii::app()->settings->clear('shop'); Yii::app()->unintallComponent('currency'); $db = Yii::app()->db; $tablesArray = array(ShopTypeAttribute::model()->tableName(), ShopAttribute::model()->tableName(), ShopAttributeOption::model()->tableName(), ShopAttributeOptionTranslate::model()->tableName(), ShopAttributeTranslate::model()->tableName(), ShopCategory::model()->tableName(), ShopCategoryTranslate::model()->tableName(), ShopCurrency::model()->tableName(), ShopManufacturer::model()->tableName(), ShopManufacturerTranslate::model()->tableName(), ShopProduct::model()->tableName(), ShopProductCategoryRef::model()->tableName(), ShopProductImage::model()->tableName(), ShopProductTranslate::model()->tableName(), ShopProductType::model()->tableName(), ShopProductVariant::model()->tableName(), ShopRelatedProduct::model()->tableName(), ShopSuppliers::model()->tableName(), $db->tablePrefix . 'shop_product_attribute_eav', $db->tablePrefix . 'shop_product_configurable_attributes', $db->tablePrefix . 'shop_product_configurations'); foreach ($tablesArray as $table) { $db->createCommand()->dropTable($table); } CFileHelper::removeDirectory(Yii::getPathOfAlias('webroot.uploads.product'), array('traverseSymlinks' => true)); CFileHelper::removeDirectory(Yii::getPathOfAlias('webroot.uploads.categories'), array('traverseSymlinks' => true)); CFileHelper::removeDirectory(Yii::getPathOfAlias('webroot.uploads.manufacturer'), array('traverseSymlinks' => true)); return parent::afterUninstall(); }
/** * @static * @param $type * @param $externalId * @param bool $loadModel */ public static function getObject($type, $externalId, $loadModel = true) { $query = Yii::app()->db->createCommand()->select("*")->from('{{exchange1c}}')->where('object_type=:type AND external_id=:externalId', array(':type' => $type, ':externalId' => $externalId))->limit(1)->queryRow(); if ($query === false) { return false; } if ($loadModel === true && $query['object_id']) { switch ($type) { case self::OBJECT_TYPE_CATEGORY: return ShopCategory::model()->findByPk($query['object_id']); break; case self::OBJECT_TYPE_ATTRIBUTE: return ShopAttribute::model()->findByPk($query['object_id']); break; case self::OBJECT_TYPE_PRODUCT: return ShopProduct::model()->findByPk($query['object_id']); break; } } return $query['object_id']; }
/** * @return ShopCategory */ public function getRootCategory() { if ($this->_rootCategory) { return $this->_rootCategory; } $this->_rootCategory = ShopCategory::model()->findByPk(1); return $this->_rootCategory; }
/** * 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;" /> ' . '<select name="catId" style="width:150px;">' . '<option value="0">' . $_ARRAYLANG['TXT_ALL_PRODUCT_GROUPS'] . '</option>' . ShopCategories::getMenuoptions($category_id) . '</select> ' . 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('"', '"', $objCategory->name()))); } } $pagingCmd = !empty($_REQUEST['cmd']) ? '&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 = "&catId={$category_id}"; } if ($manufacturer_id > 0) { $flagSpecialoffer = false; $pagingManId = "&manufacturer_id={$manufacturer_id}"; } if ($term != '') { $flagSpecialoffer = false; $pagingTerm = '&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 = '&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; }
/** * @param $id * @throws CHttpException */ public function actionDelete($id) { if (Yii::app()->request->isPostRequest) { $model = ShopCategory::model()->findByPk($id); //Delete if not root node if ($model && $model->id != 1) { foreach (array_reverse($model->descendants()->findAll()) as $subCategory) { $subCategory->deleteNode(); } $model->deleteNode(); } if (!Yii::app()->request->isAjaxRequest) { $this->redirect('create'); } } }
/** * Apply the flags to all Products matching the given Product code * * Any Product and ShopCategory carrying one or more of the names * of any ShopCategory marked as "__VIRTUAL__" is cloned and added * to that category. Those having any such flags removed are deleted * from the respective category. Identical copies of the same Products * are recognized by their "product_id" (the Product code). * * Note that in this current version, only the flags of Products are * tested and applied. Products are cloned and added together with * their immediate parent ShopCategories (aka "Article"). * * Thus, all Products within the same "Article" ShopCategory carry the * same flags, as does the containing ShopCategory itself. * @param integer $productCode The Product code (*NOT* the ID). * This must be non-empty! * @param string $strNewFlags The new flags for the Product * @static * @author Reto Kohli <*****@*****.**> */ static function changeFlagsByProductCode($productCode, $strNewFlags) { if (empty($productCode)) { return false; } // Get all available flags. These are represented by the names // of virtual root ShopCategories. $arrVirtual = ShopCategories::getVirtualCategoryNameArray(); // Get the affected identical Products $arrProduct = Products::getByCustomId($productCode); // No way we can do anything useful without them. if (count($arrProduct) == 0) { return false; } // Get the Product flags. As they're all the same, we'll use the // first one here. // Note that this object is used for reference only and is never stored. // Its database entry will be updated along the way, however. $_objProduct = $arrProduct[0]; $strOldFlags = $_objProduct->getFlags(); // Flag indicating whether the article has been cloned already // for all new flags set. $flagCloned = false; // Now apply the changes to all those identical Products, their parent // ShopCategories, and all sibling Products within them. foreach ($arrProduct as $objProduct) { // Get the containing article ShopCategory. $category_id = $objProduct->category_id(); $objArticleCategory = ShopCategory::getById($category_id); if (!$objArticleCategory) { continue; } // Get parent (subgroup) $objSubGroupCategory = ShopCategory::getById($objArticleCategory->parent_id()); // This should not happen! if (!$objSubGroupCategory) { continue; } $subgroupName = $objSubGroupCategory->name(); // Get grandparent (group, root ShopCategory) $objRootCategory = ShopCategory::getById($objSubGroupCategory->parent_id()); if (!$objRootCategory) { continue; } // Apply the new flags to all Products and Article ShopCategories. // Update the flags of the original Article ShopCategory first $objArticleCategory->flags($strNewFlags); $objArticleCategory->store(); // Get all sibling Products affected by the same flags $arrSiblingProducts = Products::getByShopCategory($objArticleCategory->id()); // Set the new flag set for all Products within the Article // ShopCategory. foreach ($arrSiblingProducts as $objProduct) { $objProduct->flags($strNewFlags); $objProduct->store(); } // Check whether this group is affected by the changes. // If its name matches one of the flags, the Article and subgroup // may have to be removed. $strFlag = $objRootCategory->name(); if (preg_match("/{$strFlag}/", $strNewFlags)) { // The flag is still there, don't bother. continue; } // Also check whether this is a virtual root ShopCategory. if (in_array($strFlag, $arrVirtual)) { // It is one of the virtual roots, and the flag is missing. // So the Article has to be removed from this group. $objArticleCategory->delete(); $objArticleCategory = false; // And if the subgroup happens to contain no more // "Article", delete it as well. $arrChildren = $objSubGroupCategory->getChildrenIdArray(); if (count($arrChildren) == 0) { $objSubGroupCategory->delete(); } continue; } // Here, the virtual ShopCategory groups have been processed, // the only ones left are the "normal" ShopCategories. // Clone one of the Article ShopCategories for each of the // new flags set. // Already did that? if ($flagCloned) { continue; } // Find out what flags have been added. foreach ($arrVirtual as $strFlag) { // That flag is not present in the new flag set. if (!preg_match("/{$strFlag}/", $strNewFlags)) { continue; } // But it has been before. The respective branch has // been truncated above already. if (preg_match("/{$strFlag}/", $strOldFlags)) { continue; } // That is a new flag for which we have to clone the Article. // Get the affected grandparent (group, root ShopCategory) $objTargetRootCategory = ShopCategories::getChildNamed($strFlag, 0, false); if (!$objTargetRootCategory) { continue; } // Check whether the subgroup exists already $objTargetSubGroupCategory = ShopCategories::getChildNamed($subgroupName, $objTargetRootCategory->id(), false); if (!$objTargetSubGroupCategory) { // Nope, add the subgroup. $objSubGroupCategory->makeClone(); $objSubGroupCategory->parent_id($objTargetRootCategory->id()); $objSubGroupCategory->store(); $objTargetSubGroupCategory = $objSubGroupCategory; } // Check whether the Article ShopCategory exists already $objTargetArticleCategory = ShopCategories::getChildNamed($objArticleCategory->name(), $objTargetSubGroupCategory->id(), false); if ($objTargetArticleCategory) { // The Article Category already exists. } else { // Nope, clone the "Article" ShopCategory and add it to the // subgroup. Note that the flags have been set already // and don't need to be changed again here. // Also note that the cloning process includes all content // of the Article ShopCategory, but the flags will remain // unchanged. That's why the flags have already been // changed right at the beginning of the process. $objArticleCategory->makeClone(true, true); $objArticleCategory->parent_id($objTargetSubGroupCategory->id()); $objArticleCategory->store(); $objTargetArticleCategory = $objArticleCategory; } } // foreach $arrVirtual } // foreach $arrProduct // And we're done! return true; }
/** * Set product categories and main category * @param array $categories ids. * @param integer $main_category Main category id. */ public function setCategories(array $categories, $main_category) { $dontDelete = array(); if (!ShopCategory::model()->countByAttributes(array('id' => $main_category))) { $main_category = 1; } if (!in_array($main_category, $categories)) { array_push($categories, $main_category); } foreach ($categories as $c) { $count = ShopProductCategoryRef::model()->countByAttributes(array('category' => $c, 'product' => $this->id)); if ($count == 0) { $record = new ShopProductCategoryRef(); $record->category = (int) $c; $record->product = $this->id; $record->switch = $this->switch; // new param $record->save(false, false, false); } $dontDelete[] = $c; } // Clear main category ShopProductCategoryRef::model()->updateAll(array('is_main' => 0, 'switch' => $this->switch), 'product=:p', array(':p' => $this->id)); // Set main category ShopProductCategoryRef::model()->updateAll(array('is_main' => 1, 'switch' => $this->switch), 'product=:p AND category=:c', array(':p' => $this->id, ':c' => $main_category)); // Delete not used relations if (sizeof($dontDelete) > 0) { $cr = new CDbCriteria(); $cr->addNotInCondition('category', $dontDelete); ShopProductCategoryRef::model()->deleteAllByAttributes(array('product' => $this->id), $cr); } else { // Delete all relations ShopProductCategoryRef::model()->deleteAllByAttributes(array('product' => $this->id)); } }
/** * Create/update product * @param bool $new * @throws CHttpException */ public function actionUpdate($new = false) { $this->topButtons = false; $config = Yii::app()->settings->get('shop'); if ($new === true) { $model = new ShopProduct(); } else { $model = ShopProduct::model()->language(Yii::app()->language->active)->findByPk($_GET['id']); } if (!$model) { throw new CHttpException(404, Yii::t('ShopModule.admin', 'NO_FOUND_PRODUCT')); } $oldImage = $model->image; if (!$model->isNewRecord) { $this->topButtons = array(array('label' => Yii::t('ShopModule.admin', 'VIEW_PRODUCT'), 'url' => $model->getAbsoluteUrl(), 'htmlOptions' => array('class' => 'btn btn-info', 'target' => '_blank'))); } // Apply use_configurations, configurable_attributes, type_id if (isset($_GET['ShopProduct'])) { $model->attributes = $_GET['ShopProduct']; } $title = $model->isNewRecord ? Yii::t('ShopModule.admin', 'CREATE_PRODUCT') : Yii::t('ShopModule.admin', 'UPDATE_PRODUCT'); if ($model->type) { $title .= ' "' . Html::encode($model->type->name) . '"'; } $this->pageName = $title; $this->breadcrumbs = array(Yii::t('ShopModule.default', 'MODULE_NAME') => array('/admin/shop'), Yii::t('ShopModule.admin', 'PRODUCTS') => $this->createUrl('index'), $this->pageName); // On create new product first display "Choose type" form first. if ($model->isNewRecord && isset($_GET['ShopProduct']['type_id'])) { if (ShopProductType::model()->countByAttributes(array('id' => $model->type_id)) === '0') { throw new CHttpException(404, Yii::t('ShopModule.admin', 'ERR_PRODUCT_TYPE')); } } // Set main category id to have categories drop-down selected value if ($model->mainCategory) { $model->main_category_id = $model->mainCategory->id; } // Or set selected category from type pre-set. if ($model->type && !Yii::app()->request->isPostRequest && $model->isNewRecord) { $model->main_category_id = $model->type->main_category; } // Set configurable attributes on new record if ($model->isNewRecord) { if ($model->use_configurations && isset($_GET['ShopProduct']['configurable_attributes'])) { $model->configurable_attributes = $_GET['ShopProduct']['configurable_attributes']; } } $form = new TabForm($model->getForm(), $model); // $form->positionTabs = 'vertical'; // Set additional tabs $form->additionalTabs[$model->t('TAB_CAT')] = array('content' => $this->renderPartial('_tree', array('model' => $model), true)); $form->additionalTabs[$model->t('TAB_IMG')] = array('content' => $this->renderPartial('_images', array('model' => $model, 'uploadModel' => $uploadModel), true)); $form->additionalTabs[$model->t('TAB_ATTR')] = array('content' => $this->renderPartial('_attributes', array('model' => $model), true)); $form->additionalTabs[$model->t('TAB_REL')] = array('content' => $this->renderPartial('_relatedProducts', array('exclude' => $model->id, 'product' => $model), true)); //if (Yii::app()->getModule('shop')->variations) $form->additionalTabs[Yii::t('ShopModule.admin', 'UPDATE_PRODUCT_TAB_VARIANTS')] = array('content' => $this->renderPartial('_variations', array('model' => $model), true)); // if($this->isInstallModule('comments')){ // $form->additionalTabs['icon-comment'] = array( // 'content' => $this->renderPartial('_comments', array('model' => $model), true) // ); // } /* $form->additionalTabs = array( 'icon-folder-open' => array( 'content' => $this->renderPartial('_tree', array('model' => $model), true) ), 'icon-copy-3' => array( 'content' => $this->renderPartial('_relatedProducts', array('exclude' => $model->id, 'product' => $model), true) ), 'icon-images' => array( 'content' => $this->renderPartial('_images', array('model' => $model, 'uploadModel' => $uploadModel), true) ), 'icon-paragraph-justify' => array( 'content' => $this->renderPartial('_attributes', array('model' => $model), true), 'visible'=>false ), Yii::t('ShopModule.admin', 'Варианты') => array( 'content' => $this->renderPartial('_variations', array('model' => $model), true) ), 'icon-comment' => array( 'content' => $this->renderPartial('_comments', array('model' => $model), true) ), ); */ if ($model->use_configurations) { $form->additionalTabs[Yii::t('ShopModule.admin', 'UPDATE_PRODUCT_TAB_CONF')] = array('content' => $this->renderPartial('_configurations', array('product' => $model), true)); } if (isset($_GET['ShopProduct']['main_category_id'])) { $model->main_category_id = $_GET['ShopProduct']['main_category_id']; } if (Yii::app()->request->isPostRequest) { $model->attributes = $_POST['ShopProduct']; // Handle related products $model->setRelatedProducts(Yii::app()->getRequest()->getPost('RelatedProductId', array())); if ($config['auto_gen_url']) { $model->name = ShopCategory::model()->findByPk($model->main_category_id)->name . ' ' . ShopManufacturer::model()->findByPk($model->manufacturer_id)->name . ' ' . $model->sku; $model->seo_alias = CMS::translit($model->name); // die($model->name.$model->seo_alias); } /* if($model->currency_id){ $currency = ShopCurrency::model()->findByPk($model->currency_id); $convertPrice = $model->price*$currency->rate/$currency->rate_old; $model->price=$convertPrice; } */ if ($model->validate() && $this->validateAttributes($model)) { $model->uploadFile('image', 'webroot.uploads.product', $oldImage); $model->save(); // Process categories $mainCategoryId = 1; if (isset($_POST['ShopProduct']['main_category_id'])) { $mainCategoryId = $_POST['ShopProduct']['main_category_id']; } $model->setCategories(Yii::app()->request->getPost('categories', array()), $mainCategoryId); // Process attributes $this->processAttributes($model); // Process variants $this->processVariants($model); // Process configurations $this->processConfigurations($model); // Handle images $this->handleUploadedImages($model); // Set main image $this->updateMainImage($model); // Update image titles $this->updateImageTitles(); $model->save(false, false); $this->redirect(array('index')); } else { $this->setFlashMessage(Yii::t('ShopModule.admin', 'ERR_PRODUCT_TYPE')); } } $this->render('update', array('model' => $model, 'form' => $form)); }
/** * Cloudrexx * * @link http://www.cloudrexx.com * @copyright Cloudrexx AG 2007-2015 * * According to our dual licensing model, this program can be used either * under the terms of the GNU Affero General Public License, version 3, * or under a proprietary license. * * The texts of the GNU Affero General Public License with an additional * permission and of our proprietary license can be found at and * in the LICENSE file you have received along with this program. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * "Cloudrexx" is a registered trademark of Cloudrexx AG. * The licensing of the program under the AGPLv3 does not imply a * trademark license. Therefore any rights, title and interest in * our trademarks remain entirely with us. */ function _shopUpdate() { global $objDatabase, $_ARRAYLANG, $objUpdate; if (!defined('MODULE_INDEX')) { define('MODULE_INDEX', ''); } try { $table_name = DBPREFIX . 'module_shop_config'; // Mind that this table does no longer exist from version 3 if (Cx\Lib\UpdateUtil::table_exist($table_name)) { // Shop settings // Shop thumbnail default settings: shop_thumbnail_max_width $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE name='shop_thumbnail_max_width'"; $objResult = $objDatabase->Execute($query); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `{$table_name}` (\n name, value\n ) VALUES (\n 'shop_thumbnail_max_width', '120'\n )"; $objResult = $objDatabase->Execute($query); if ($objResult) { } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } // Shop thumbnail default settings: shop_thumbnail_max_height $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE name='shop_thumbnail_max_height'"; $objResult = $objDatabase->Execute($query); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `{$table_name}` (\n name, value\n ) VALUES (\n 'shop_thumbnail_max_height', '90'\n )"; $objResult = $objDatabase->Execute($query); if ($objResult) { } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } // Shop thumbnail default settings: shop_thumbnail_quality $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE name='shop_thumbnail_quality'"; $objResult = $objDatabase->Execute($query); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `{$table_name}` (\n name, value\n ) VALUES (\n 'shop_thumbnail_quality', '80'\n )"; $objResult = $objDatabase->Execute($query); if ($objResult) { } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } // Add Yellowpay payment methods default settings: // Accepted payment methods $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE name='yellowpay_accepted_payment_methods'"; $objResult = $objDatabase->Execute($query); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `{$table_name}` (\n `id`, `name`, `value`, `status`\n ) VALUES (\n NULL, 'yellowpay_accepted_payment_methods', '', '1'\n )"; $objResult = $objDatabase->Execute($query); if ($objResult) { } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } // Change old yellowpay_delivery_payment_type setting // to new yellowpay_authorization_type $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE `name`='yellowpay_delivery_payment_type'"; $objResult = $objDatabase->Execute($query); if ($objResult) { if ($objResult->RecordCount() == 1) { $query = "\n UPDATE `{$table_name}`\n SET `name`='yellowpay_authorization_type'\n WHERE `name`='yellowpay_delivery_payment_type'"; $objResult = $objDatabase->Execute($query); if ($objResult) { } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } // Add yellowpay test server flag setting $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE `name`='yellowpay_use_testserver'"; $objResult = $objDatabase->Execute($query); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `{$table_name}` (\n `id`, `name`, `value`, `status`\n ) VALUES (\n NULL, 'yellowpay_use_testserver', '1', '1'\n )"; $objResult = $objDatabase->Execute($query); if ($objResult) { } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } // Add weight enable flag setting $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE `name`='shop_weight_enable'"; $objResult = $objDatabase->Execute($query); if ($objResult) { if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `{$table_name}` (\n `id`, `name`, `value`, `status`\n ) VALUES (\n NULL, 'shop_weight_enable', '1', '1'\n )"; $objResult = $objDatabase->Execute($query); if ($objResult) { } else { return _databaseError($query, $objDatabase->ErrorMsg()); } } } else { return _databaseError($query, $objDatabase->ErrorMsg()); } // Add shop_show_products_default: // Which products are shown on the first shop page? $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE `name`='shop_show_products_default'"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `{$table_name}` (\n `name`, `value`\n ) VALUES (\n 'shop_show_products_default', '1'\n )"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // Update VAT settings $query = "\n SELECT `value` FROM `{$table_name}`\n WHERE `name`='tax_enabled'"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } if ($objResult->RecordCount()) { $flagVatEnabled = $objResult->fields['value']; $arrVatEnabled = array('vat_enabled_foreign_customer', 'vat_enabled_foreign_reseller', 'vat_enabled_home_customer', 'vat_enabled_home_reseller'); foreach ($arrVatEnabled as $strSetting) { $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE `name`='{$strSetting}'"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `{$table_name}` (\n `name`, `value`\n ) VALUES (\n '{$strSetting}', '{$flagVatEnabled}'\n )"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } } $query = "\n SELECT `value` FROM `{$table_name}`\n WHERE `name`='tax_included'"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } if ($objResult->RecordCount()) { $flagVatIncluded = $objResult->fields['value']; $arrVatIncluded = array('vat_included_foreign_customer', 'vat_included_foreign_reseller', 'vat_included_home_customer', 'vat_included_home_reseller'); foreach ($arrVatIncluded as $strSetting) { $query = "\n SELECT 1 FROM `{$table_name}`\n WHERE `name`='{$strSetting}'"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } if ($objResult->RecordCount() == 0) { $query = "\n INSERT INTO `{$table_name}` (\n `name`, `value`\n ) VALUES (\n '{$strSetting}', '{$flagVatIncluded}'\n )"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } } } $query = "\n DELETE FROM `{$table_name}`\n WHERE `name`='tax_enabled' OR `name`='tax_included'"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // Update Attribute price to signed. // price_prefix is removed for version 3. See Attribute::errorHandler() $table_name = DBPREFIX . 'module_shop_products_attributes_value'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'price_prefix') && Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'module_shop_order_items_attributes') && Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_shop_order_items_attributes', 'price_prefix')) { $query = "\n UPDATE `{$table_name}`\n SET `price`=-`price`,\n `price_prefix`='+'\n WHERE `price`>0\n AND `price_prefix`='-'"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } $query = "\n UPDATE `" . DBPREFIX . "module_shop_order_items_attributes`\n SET `product_option_values_price`=-`product_option_values_price`\n WHERE `product_option_values_price`>0\n AND `price_prefix`='-'"; $objResult = $objDatabase->Execute($query); if (!$objResult) { return _databaseError($query, $objDatabase->ErrorMsg()); } } // Update tables' field types and indices $table_name = DBPREFIX . 'module_shop_article_group'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'renamefrom' => 'name'))); } $table_name = DBPREFIX . 'module_shop_customer_group'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''))); } $table_name = DBPREFIX . 'module_shop_discountgroup_count_name'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'unit' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''))); } $table_name = DBPREFIX . 'module_shop_discountgroup_count_rate'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('group_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'default' => 0), 'count' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'default' => '1'), 'rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.0'))); } $table_name = DBPREFIX . 'module_shop_rel_discount_group'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('customer_group_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'default' => '0'), 'article_group_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'default' => '0'), 'rate' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.0'))); } $table_name = DBPREFIX . 'module_shop_lsv'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'order_id'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'holder' => array('type' => 'TINYTEXT'), 'bank' => array('type' => 'TINYTEXT'), 'blz' => array('type' => 'TINYTEXT')), array('order_id' => array('fields' => array('order_id'), 'type' => 'UNIQUE'))); } $table_name = DBPREFIX . 'module_shop_shipment_cost'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'price_free')) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'shipper_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'max_weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'cost' => array('type' => 'DECIMAL(10,2)', 'unsigned' => true, 'notnull' => false), 'price_free' => array('type' => 'DECIMAL(10,2)', 'unsigned' => true, 'notnull' => false))); } $table_name = DBPREFIX . 'module_shop_shipper'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'TINYTEXT'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); } // Note that countries are migrated to the core_countries table // for version 3, and this table is then dropped. // See Country::errorHandler() $table_name = DBPREFIX . 'module_shop_countries'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('countries_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'countries_name' => array('type' => 'VARCHAR(64)', 'notnull' => true, 'default' => ''), 'countries_iso_code_2' => array('type' => 'CHAR(2)', 'notnull' => true, 'default' => ''), 'countries_iso_code_3' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'activation_status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1')), array('countries_name' => array('fields' => array('countries_name')))); } // Add Category description to old table version with "catid" // primary key only! Fulltext indices are added when migrating // to core_text anyway, so don't bother with text fields here. $table_name = DBPREFIX . 'module_shop_categories'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'catid')) { Cx\Lib\UpdateUtil::table($table_name, array('catid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'parentid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'catname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'catdesc' => array('type' => 'TEXT', 'notnull' => true, 'default' => ''), 'catsorting' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '100'), 'catstatus' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'picture' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'flags' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '')), array('flags' => array('fields' => array('flags'), 'type' => 'FULLTEXT'))); } // Settings table fields -- this is supposed to exist; see above /* $table_name = DBPREFIX.'module_shop_config'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array( 'id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'name' => array('type' => 'VARCHAR(64)', 'notnull' => true, 'default' => ''), 'value' => array('type' => 'VARCHAR(255)', 'notnull', 'default' => ''), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), ) ); }*/ $table_name = DBPREFIX . 'module_shop_currencies'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { $query = "\n UPDATE `{$table_name}`\n SET sort_order = 0 WHERE sort_order IS NULL"; Cx\Lib\UpdateUtil::sql($query); // Currencies table fields Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'code' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'symbol' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'name' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'rate' => array('type' => 'DECIMAL(10,4)', 'unsigned' => true, 'notnull' => true, 'default' => '1.0000'), 'sort_order' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'is_default' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); } // Note that this table is migrated to access_users for version 3, // then dropped. $table_name = DBPREFIX . 'module_shop_customers'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('customerid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'username' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'password' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'prefix' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'company' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'firstname' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'lastname' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'address' => array('type' => 'VARCHAR(40)', 'notnull' => true, 'default' => ''), 'city' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'zip' => array('type' => 'VARCHAR(10)', 'notnull' => false), 'country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'phone' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'fax' => array('type' => 'VARCHAR(25)', 'notnull' => true, 'default' => ''), 'email' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'ccnumber' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'ccdate' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => ''), 'ccname' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'cvc_code' => array('type' => 'VARCHAR(5)', 'notnull' => true, 'default' => ''), 'company_note' => array('type' => 'TEXT', 'notnull' => true), 'is_reseller' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'register_date' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'customer_status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false))); } $table_name = DBPREFIX . 'module_shop_importimg'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('img_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'img_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'img_cats' => array('type' => 'TEXT', 'notnull' => true, 'default' => ''), 'img_fields_file' => array('type' => 'TEXT', 'notnull' => true, 'default' => ''), 'img_fields_db' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''))); } // Note that the following two tables are migrated to MailTemplate // for version 3, then dropped. $table_name = DBPREFIX . 'module_shop_mail'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'tplname' => array('type' => 'VARCHAR(60)', 'notnull' => true, 'default' => ''), 'protected' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); } $table_name = DBPREFIX . 'module_shop_mail_content'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'tpl_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'from_mail' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'xsender' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'subject' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'message' => array('type' => 'TEXT', 'notnull' => true))); } // Note: No changes necessary; the manufacturer table will be // completely modified in Manufacturer::errorHandler() below. /* $table_name = DBPREFIX.'module_shop_manufacturer'; if ( Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { Cx\Lib\UpdateUtil::table($table_name, DBPREFIX.'', array( 'id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'url' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), ) ); }*/ $table_name = DBPREFIX . 'module_shop_order_items'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'order_items_id')) { Cx\Lib\UpdateUtil::table($table_name, array('order_items_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'orderid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'productid' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'product_name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'quantity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'vat_percent' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => false), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false))); } // Note: Removed field price_prefix for version 2.2; no changes since $table_name = DBPREFIX . 'module_shop_order_items_attributes'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'price_prefix')) { Cx\Lib\UpdateUtil::table($table_name, array('orders_items_attributes_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'order_items_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'product_option_name' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'product_option_value' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'product_option_values_price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'))); } $table_name = DBPREFIX . 'module_shop_orders'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'orderid')) { Cx\Lib\UpdateUtil::table($table_name, array('orderid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'customerid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'selected_currency_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'order_sum' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'currency_order_sum' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'order_date' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'order_status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'ship_prefix' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'ship_company' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'ship_firstname' => array('type' => 'VARCHAR(40)', 'notnull' => true, 'default' => ''), 'ship_lastname' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'ship_address' => array('type' => 'VARCHAR(40)', 'notnull' => true, 'default' => ''), 'ship_city' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'ship_zip' => array('type' => 'VARCHAR(10)', 'notnull' => false), 'ship_country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'ship_phone' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => ''), 'tax_price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'currency_ship_price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'shipping_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'currency_payment_price' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'customer_ip' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => ''), 'customer_host' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'customer_lang' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'customer_browser' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'customer_note' => array('type' => 'TEXT'), 'last_modified' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'modified_by' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '')), array('order_status' => array('fields' => array('order_status')))); } $table_name = DBPREFIX . 'module_shop_payment'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(50)', 'notnull' => false), 'processor_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'costs' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'costs_free_sum' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'sort_order' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => false, 'default' => '0'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => false, 'default' => '1'))); } // Note: No changes (still single language in version 3) $table_name = DBPREFIX . 'module_shop_payment_processors'; Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'ENUM(\'internal\',\'external\')', 'notnull' => true, 'default' => 'internal'), 'name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''), 'description' => array('type' => 'TEXT'), 'company_url' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => false, 'default' => '1'), 'picture' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => ''))); Cx\Lib\UpdateUtil::sql(' INSERT IGNORE INTO `' . DBPREFIX . 'module_shop_payment_processors` (`id`, `type`, `name`, `description`, `company_url`, `status`, `picture`) VALUES (12,"external","paymill_cc","","https://www.paymill.com",1,""), (13,"external","paymill_elv","","https://www.paymill.com",1,""), (14,"external","paymill_iban","","https://www.paymill.com",1,"") '); // Note: No changes (still single language in version 3) $table_name = DBPREFIX . 'module_shop_pricelists'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(25)', 'notnull' => true, 'default' => ''), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'border_on' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'header_on' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'header_left' => array('type' => 'TEXT', 'notnull' => false), 'header_right' => array('type' => 'TEXT', 'notnull' => false), 'footer_on' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'footer_left' => array('type' => 'TEXT', 'notnull' => false), 'footer_right' => array('type' => 'TEXT', 'notnull' => false), 'categories' => array('type' => 'TEXT'))); } $table_name = DBPREFIX . 'module_shop_products'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'title')) { $query = "\n UPDATE `{$table_name}`\n SET `description`=''\n WHERE `description` IS NULL"; if ($objDatabase->Execute($query) == false) { return _databaseError($query, $objDatabase->ErrorMsg()); } Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'product_id' => array('type' => 'VARCHAR(100)'), 'picture' => array('type' => 'TEXT'), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'catid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'handler' => array('type' => 'ENUM(\'none\',\'delivery\',\'download\')', 'notnull' => true, 'default' => 'delivery'), 'normalprice' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'resellerprice' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'shortdesc' => array('type' => 'TEXT'), 'description' => array('type' => 'TEXT'), 'stock' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '10'), 'stock_visibility' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'discountprice' => array('type' => 'DECIMAL(9,2)', 'notnull' => true, 'default' => '0.00'), 'is_special_offer' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'property1' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => ''), 'property2' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => ''), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'b2b' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'b2c' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'), 'startdate' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'enddate' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'thumbnail_percent' => array('type' => 'TINYINT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'thumbnail_quality' => array('type' => 'TINYINT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'manufacturer' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'manufacturer_url' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'external_link' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'sort_order' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'vat_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'flags' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'usergroups' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'article_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false), 'keywords' => array('type' => 'TEXT')), array('group_id' => array('fields' => array('group_id')), 'article_id' => array('fields' => array('article_id')), 'shopindex' => array('fields' => array('title', 'description'), 'type' => 'FULLTEXT'), 'flags' => array('fields' => array('flags'), 'type' => 'FULLTEXT'), 'keywords' => array('fields' => array('keywords'), 'type' => 'FULLTEXT'))); } // Note: The following three tables are renamed for version 3. // See Attribute::errorHandler() $table_name = DBPREFIX . 'module_shop_products_attributes'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'attributes_name_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'attributes_value_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'sort_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); } $table_name = DBPREFIX . 'module_shop_products_attributes_name'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'display_type' => array('type' => 'TINYINT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); } $table_name = DBPREFIX . 'module_shop_products_attributes_value'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'value' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'price' => array('type' => 'DECIMAL(9,2)', 'notnull' => false, 'default' => '0.00'))); } // Note: Obsolete for a while already $table_name = DBPREFIX . 'module_shop_products_downloads'; if (Cx\Lib\UpdateUtil::table_exist($table_name)) { Cx\Lib\UpdateUtil::drop_table($table_name); } // Note: The id field is removed for version 3 from the following // three tables $table_name = DBPREFIX . 'module_shop_rel_countries'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'id')) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'zones_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'countries_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); } $table_name = DBPREFIX . 'module_shop_rel_payment'; Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'zones_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); Cx\Lib\UpdateUtil::sql(' INSERT IGNORE INTO `' . DBPREFIX . 'module_shop_rel_payment` (`zones_id`, `payment_id`) VALUES (1,16), (1,17), (1,18) '); // Note: This is renamed to module_shop_rel_shipper for version 3.0 $table_name = DBPREFIX . 'module_shop_rel_shipment'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'id')) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'zones_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'shipment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'))); } $table_name = DBPREFIX . 'module_shop_vat'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'class')) { Cx\Lib\UpdateUtil::table($table_name, array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'class' => array('type' => 'TINYTEXT'), 'percent' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => true, 'default' => '0.00'))); } $table_name = DBPREFIX . 'module_shop_zones'; if (Cx\Lib\UpdateUtil::table_exist($table_name) && Cx\Lib\UpdateUtil::column_exist($table_name, 'zones_id')) { Cx\Lib\UpdateUtil::table($table_name, array('zones_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'zones_name' => array('type' => 'VARCHAR(64)', 'notnull' => true, 'default' => ''), 'activation_status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1'))); } // Contrexx 3.0.0 updates from here. // NOTE: All of these methods return false. Attribute::errorHandler(); Coupon::errorHandler(); // Prerequisites: // ShopSettings::errorHandler(); //ShopSettings::errorHandler(); // Called by Coupon::errorHandler();Customer::errorHandler();Order::errorHandler();ShopCategory::errorHandler(); // Prerequisites: // \Cx\Core\Setting\Controller\Setting::errorHandler(); Currency::errorHandler(); // Prerequisites: // Text::errorHandler(); //Text::errorHandler(); // Called by Currency::errorHandler();Product::errorHandler();Payment::errorHandler();ShopCategory::errorHandler(); Product::errorHandler(); // Prerequisites: // Text::errorHandler(); // Discount::errorHandler(); // Called by Customer::errorHandler(); // Manufacturer::errorHandler(); // Postrequisites: // Customer::errorHandler(); //Discount::errorHandler(); // Called by Customer::errorHandler(); //Manufacturer::errorHandler(); // Called by Product::errorHandler(); // Prerequisites: // Text::errorHandler(); //Customer::errorHandler(); // Called by Product::errorHandler(); // Prerequisites: // ShopSettings::errorHandler(); // Country::errorHandler(); // Called by Order::errorHandler(); // Order::errorHandler(); // Calls required Country::errorHandler(); // Discount::errorHandler(); // Called by Product::errorHandler(); //Order::errorHandler(); // Called by Customer::errorHandler(); // Prerequisites: // ShopSettings::errorHandler(); // Country::errorHandler(); ShopMail::errorHandler(); // Prerequisites: // MailTemplate::errorHandler(); Payment::errorHandler(); // Prerequisites: // Text::errorHandler(); // Zones::errorHandler(); // Yellowpay::errorHandler(); //Zones::errorHandler(); // Called by Payment::errorHandler();Shipment::errorHandler(); // Prerequisites: // Text::errorHandler(); //Yellowpay::errorHandler(); // Called by Payment::errorHandler(); // Prerequisites: // \Cx\Core\Setting\Controller\Setting::errorHandler(); PaymentProcessing::errorHandler(); Shipment::errorHandler(); // Prerequisites: // Zones::errorHandler(); // TODO: Check for and resolve recursion! ShopCategory::errorHandler(); // Prerequisites: // Text::errorHandler(); // ShopSettings::errorHandler(); Vat::errorHandler(); // Update page templates // Remove // [[SHOP_JAVASCRIPT_CODE]] Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop'), '/{SHOP_JAVASCRIPT_CODE}[\\r\\n]*/', '', array('content'), '3.0.0'); // Replace // In <!-- BEGIN subCategoriesRow -->...<!-- END subCategoriesRow --> // [[SHOP_PRODUCT_DETAILLINK_IMAGE]] => // index.php?section=shop[[MODULE_INDEX]]&catId=[[SHOP_CATEGORY_ID]] Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop'), '/(<!-- *BEGIN *subCategoriesRow *-->.+?)' . '{SHOP_PRODUCT_DETAILLINK_IMAGE}' . '(.+?<!-- *END *subCategoriesRow *-->)/s', '$1index.php?section=shop{MODULE_INDEX}&catId={SHOP_CATEGORY_ID}$2', array('content'), '3.0.0'); // [[TXT_SEE_LARGE_PICTURE]] => [[TXT_SHOP_GO_TO_CATEGORY]] Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop'), '/(<!-- *BEGIN *subCategoriesRow *-->.+?)' . '{TXT_SEE_LARGE_PICTURE}' . '(.+?<!-- *END *subCategoriesRow *-->)/s', '$1{TXT_SHOP_GO_TO_CATEGORY}$2', array('content'), '3.0.0'); // [[SHOP_PRODUCT_...]] => [[SHOP_CATEGORY_...]] // There may be up to nine different such placeholders! $subject = NULL; Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'shop'), '/(<!-- *BEGIN *subCategoriesRow *-->.+?)' . '{SHOP_PRODUCT_(.*?)}' . '(.+?<!-- *END *subCategoriesRow *-->)/s', function ($subject) { preg_replace('/{SHOP_PRODUCT_(.*?)}/', '{SHOP_CATEGORY_$1}', $subject); }, array('content'), '3.0.0'); // shop/account // Needs to be replaced completely Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop', 'cmd' => 'account'), '/^.+$/s', <<<EOF <div id="shop"><!-- BEGIN core_message --> <span class="{MESSAGE_CLASS}">{MESSAGE_TEXT}</span><!-- END core_message --> <div id="shop_acc_data"> <form name="account" action="{SHOP_ACCOUNT_ACTION}" method="post" onsubmit="copy_address()" onreset="return shopReset()"> <div class="customer_address"> <h2>{TXT_CUSTOMER_ADDRESS}</h2> <div class="shop_text"> <p><label>{TXT_COMPANY}</label> <input type="text" tabindex="1" name="company" value="{SHOP_ACCOUNT_COMPANY}" /> </p> <p><label>{TXT_GREETING}<font color="#ff0000"> *</font></label> <select tabindex="2" name="gender">{SHOP_ACCOUNT_PREFIX}</select> </p> <p><label>{TXT_SURNAME}<font color="#ff0000"> *</font></label> <input type="text" tabindex="3" name="lastname" value="{SHOP_ACCOUNT_LASTNAME}" /> </p> <p><label>{TXT_FIRSTNAME}<font color="#ff0000"> *</font></label> <input type="text" tabindex="4" name="firstname" value="{SHOP_ACCOUNT_FIRSTNAME}" /> </p> <p><label>{TXT_ADDRESS}<font color="#ff0000"> *</font></label> <input type="text" tabindex="5" name="address" value="{SHOP_ACCOUNT_ADDRESS}" /> </p> <p><label>{TXT_POSTALE_CODE}<font color="#ff0000"> *</font></label> <input type="text" tabindex="6" name="zip" value="{SHOP_ACCOUNT_ZIP}" /> </p> <p><label>{TXT_CITY}<font color="#ff0000"> *</font></label> <input type="text" tabindex="7" name="city" value="{SHOP_ACCOUNT_CITY}" /> </p> <p><label>{TXT_COUNTRY}</label> <select name="countryId" id="countryId" tabindex="8"> {SHOP_ACCOUNT_COUNTRY_MENUOPTIONS} </select> </p> <p><label>{TXT_PHONE_NUMBER}<font color="#ff0000"> *</font></label> <input type="text" tabindex="9" name="phone" value="{SHOP_ACCOUNT_PHONE}" /> </p> <p><label>{TXT_FAX_NUMBER}</label> <input type="text" tabindex="10" name="fax" value="{SHOP_ACCOUNT_FAX}" /> </p> </div> </div><!-- BEGIN shipping_address --> <div class="shipping_address"> <h2>{TXT_SHIPPING_ADDRESS}</h2> <p><input type="checkbox" tabindex="21" value="1" onclick="copy_address();" id="equal_address" name="equal_address" {SHOP_EQUAL_ADDRESS_CHECKED} /> <label class="description" for="equal_address">{TXT_SAME_BILLING_ADDRESS}</label> </p> </div> <div id="shipping_address" style="display: {SHOP_EQUAL_ADDRESS_DISPLAY};"> <div class="shop_text"> <p><label>{TXT_COMPANY}</label> <input type="text" tabindex="31" name="company2" value="{SHOP_ACCOUNT_COMPANY2}" /> </p> <p><label>{TXT_GREETING}<font color="#ff0000"> *</font></label> <select tabindex="32" name="gender2">{SHOP_ACCOUNT_PREFIX2}</select> </p> <p><label>{TXT_SURNAME}<font color="#ff0000"> *</font></label> <input type="text" tabindex="33" name="lastname2" value="{SHOP_ACCOUNT_LASTNAME2}" /> </p> <p><label>{TXT_FIRSTNAME}<font color="#ff0000"> *</font></label> <input type="text" tabindex="34" name="firstname2" value="{SHOP_ACCOUNT_FIRSTNAME2}" /> </p> <p><label>{TXT_ADDRESS}<font color="#ff0000"> *</font></label> <input type="text" tabindex="35" name="address2" value="{SHOP_ACCOUNT_ADDRESS2}" /> </p> <p><label>{TXT_POSTALE_CODE}<font color="#ff0000"> *</font></label> <input type="text" tabindex="36" name="zip2" value="{SHOP_ACCOUNT_ZIP2}" size="6" /> </p> <p><label>{TXT_CITY}<font color="#ff0000"> *</font></label> <input type="text" tabindex="37" name="city2" value="{SHOP_ACCOUNT_CITY2}" /> </p> <p><label>{TXT_COUNTRY}</label> <input type="hidden" name="countryId2" id="countryId2" value="{SHOP_ACCOUNT_COUNTRY2_ID}" />{SHOP_ACCOUNT_COUNTRY2} </p> <p><label>{TXT_PHONE_NUMBER}<font color="#ff0000"> *</font></label> <input type="text" tabindex="38" name="phone2" value="{SHOP_ACCOUNT_PHONE2}" /> </p> </div> </div><!-- END shipping_address --><!-- BEGIN account_details --> <div class="account_details"> <h2>{TXT_YOUR_ACCOUNT_DETAILS}</h2><!-- BEGIN dont_register --> <p> <input type="checkbox" tabindex="61" value="1" id="dont_register" name="dont_register" {SHOP_DONT_REGISTER_CHECKED} onClick="document.getElementById('account_password').style.display = (this.checked ? 'none' : 'block');" /> <label class="description" for="dont_register">{TXT_SHOP_ACCOUNT_DONT_REGISTER}</label> <br /> {TXT_SHOP_ACCOUNT_DONT_REGISTER_NOTE} </p><!-- END dont_register --> <div class="shop_text"> <p> <label>{TXT_EMAIL}<font color="#ff0000"> *</font></label> <input type="text" tabindex="51" name="email" value="{SHOP_ACCOUNT_EMAIL}" /> </p> <div id="account_password" style="{SHOP_ACCOUNT_PASSWORD_DISPLAY};"> <p> <label>{TXT_PASSWORD}<font color="#ff0000"> *</font></label> <input type="password" tabindex="52" name="password" value="" /> </p> <p>{TXT_SHOP_ACCOUNT_PASSWORD_HINT}</p> </div> </div> </div><!-- END account_details --> <p> <input type="reset" value="{TXT_RESET}" name="reset" tabindex="71" /> <input type="submit" value="{TXT_SHOP_CONTINUE_ARROW}" name="bsubmit" tabindex="72" /> </p> </form> </div> </div> <script type="text/javascript">//<![CDATA[ function copy_address() { with (document.account) { if (jQuery("#equal_address:checked").length) { gender2.value = gender.value; company2.value = company.value; lastname2.value = lastname.value; firstname2.value = firstname.value; address2.value = address.value; zip2.value = zip.value; city2.value = city.value; phone2.value = phone.value; countryId2.value = countryId.value; jQuery("#shipping_address").hide(); } else { jQuery("#shipping_address").show(); // Optionally clear the shipment address // gender2.value = ""; // company2.value = ""; // lastname2.value = ""; // firstname2.value = ""; // address2.value = ""; // zip2.value = ""; // city2.value = ""; // phone2.value = ""; } } } jQuery(function () { jQuery(".customer_address").delegate("input", "blur", function() { if (jQuery("#equal_address:checked").length) { copy_address(); } }); }); // Redisplay the shipping address after the reset button has been clicked function shopReset() { if (!confirm("{TXT_SHOP_FORM_RESET_CONFIRM}")) { return false; } jQuery("#shipping_address").show(); return true; } copy_address(); //}></script> EOF , array('content'), '3.0.0'); // shop/login // Needs to be replaced completely Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'shop', 'cmd' => 'login'), '/^.+$/s', <<<EOF <div id="shop"> <!-- BEGIN core_message --> <span class="{MESSAGE_CLASS}">{MESSAGE_TEXT}</span> <!-- END core_message --> <div class="customer_old"> <form name="shop_login" action="index.php?section=login" method="post"> <input name="redirect" type="hidden" value="{SHOP_LOGIN_REDIRECT}" /> <h2>{TXT_SHOP_ACCOUNT_EXISTING_CUSTOMER}</h2> <p> <label for="username">{TXT_SHOP_EMAIL_ADDRESS}</label> <input type="text" maxlength="250" value="{SHOP_LOGIN_EMAIL}" id="username" name="USERNAME" /> </p> <p> <label for="password">{TXT_SHOP_PASSWORD}</label> <input type="password" maxlength="50" id="password" name="PASSWORD" /> </p> <p> <input type="submit" value="{TXT_SHOP_ACCOUNT_LOGIN}" name="login" /> </p> <p> <a class="lostpw" href="index.php?section=login&cmd=lostpw" title="{TXT_SHOP_ACCOUNT_LOST_PASSWORD}"> {TXT_SHOP_ACCOUNT_LOST_PASSWORD} </a> </p> </form> </div> <div class="customer_new"> <form name="shop_register" action="index.php?section=shop&cmd=login" method="post"> <h2>{TXT_SHOP_ACCOUNT_NEW_CUSTOMER}</h2> {TXT_SHOP_ACCOUNT_NOTE}<br /> <br /> <!-- BEGIN register --> <input type="submit" value="{TXT_SHOP_BUTTON_REGISTRATION}" name="baccount" /> <!-- END register --> <!-- BEGIN dont_register --> <input type="submit" value="{TXT_SHOP_BUTTON_NO_REGISTRATION}" name="bnoaccount" /> <!-- END dont_register --> </form> </div> </div> EOF , array('content'), '3.0.0'); // Note: Other templates may contain new placeholders and/or blocks, // however, these need to be added manually for version 3.0.0 features // to work. } catch (Cx\Lib\UpdateException $e) { return Cx\Lib\UpdateUtil::DefaultActionHandler($e); } //update settingsDB for missing values if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) { try { \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`) VALUES (\'shop\', \'orderitems_amount_min\', \'config\', \'text\', \'0\')'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } // add access id 4 for user groups which had access to 13 or 161 if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) { try { $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 13 OR access_id = 161 GROUP BY `group_id`"); if ($result !== false) { while (!$result->EOF) { \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n VALUES (4, " . intval($result->fields['group_id']) . ")"); $result->MoveNext(); } } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } } try { // add some necessary buttons to the confirmation page // fix of http://bugs.contrexx.com/contrexx/ticket/2015 Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'shop', 'cmd' => 'confirm'), '/.*/s', function ($content) { $content .= '<a href="{NODE_SHOP_ACCOUNT}">{TXT_ORDER_BACK_TO_ACCOUNT}</a><br /> <a href="{NODE_SHOP_CART}">{TXT_ORDER_BACK_TO_CART}</a>'; }, array('content'), '3.2.0'); } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } try { $queries = array('INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","payment_lsv_active","config","text","1","",18)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_active","config","text","1","",3)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_live_private_key","config","text","","",0)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_live_public_key","config","text","","",0)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_live_public_key","config","text","","",0)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_test_private_key","config","text","","",2)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_test_public_key","config","text","","",16)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ("shop","paymill_use_test_account","config","text","0","",15)', 'INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES (\'shop\',\'orderitems_amount_min\',\'config\',\'text\',\'0\',\'\',0);'); foreach ($queries as $query) { \Cx\Lib\UpdateUtil::sql($query); } } catch (\Cx\Lib\UpdateException $e) { return \Cx\Lib\UpdateUtil::DefaultActionHandler($e); } return true; }
/** * @return array */ public static function flatTree() { $result = array(); $categories = ShopCategory::model()->cache(Yii::app()->controller->cacheTime)->active()->language(Yii::app()->languageManager->active->code)->findAll(array('order' => 'lft')); array_shift($categories); foreach ($categories as $c) { if ($c->level > 2) { $result[$c->id] = str_repeat('--', $c->level - 1) . ' ' . $c->name; } else { $result[$c->id] = ' ' . $c->name; } } return $result; }
<?php if ($this->isAjax) { $this->renderPartial('mod.admin.views.layouts._content-top'); echo Html::openTag('div', array('class' => 'wrapper')); } $this->widget('ext.fancybox.Fancybox', array('target' => 'a.overview-image', 'config' => array())); $checkRoot = ShopCategory::model()->findByPk(1); if (!$checkRoot) { // throw new CHttpException(404,'no root'); Yii::app()->tpl->alert('warning', 'Необходимо создать root категорию. <a href="/admin/shop/category/createRoot">создать</a>', false); } else { ?> <div class="row"> <div class="col-lg-8"> <?php Yii::app()->tpl->openWidget(array('title' => $this->pageName, 'htmlOptions' => array('class' => ''))); echo $model->getForm()->tabs(); Yii::app()->tpl->closeWidget(); ?> </div> <div class="col-lg-4"> <?php $this->renderPartial('_categories', array('model' => $model)); ?> </div> </div> <script type="text/javascript">init_translitter('ShopCategory','<?php echo $model->primaryKey;
/** * Write categories to xm file */ public function renderCategories() { $categories = ShopCategory::model()->excludeRoot()->findAll(); $this->write('<categories>'); foreach ($categories as $c) { $parentId = null; $parent = $c->parent(); //getparent() if ($parent && $parent->id != 1) { $parentId = 'parentId="' . $parent->id . '"'; } $this->write('<category id="' . $c->id . '" ' . $parentId . '>' . CHtml::encode($c->name) . '</category>'); } $this->write('</categories>'); }
/** * Insert a new ShopCategory into the database. * * @static * @param string $catName The new ShopCategory name * @param integer $catParent The parent ShopCategory ID * @return integer The ID of the new ShopCategory, * or 0 on failure. * @author Unknown <*****@*****.**> (Original author) * @author Reto Kohli <*****@*****.**> (Made static) */ static function InsertNewCat($catName, $catParent) { $objCategory = new ShopCategory($catName, '', $catParent); if ($objCategory->store()) { return $objCategory->id(); } return 0; }
echo CHtml::textField('search', '', array('onkeyup' => '$("#ShopCategoryTreeFilter").jstree("search", $(this).val())')); ?> </div> <?php $this->beginWidget('zii.widgets.jui.CJuiButton', array('buttonType' => 'buttonset', 'name' => 'tree-set', 'htmlOptions' => array('style' => 'padding-top:2px;'))); $this->endWidget(); ?> <div class="clear"></div> <?php // Create jstree to filter products $this->widget('ext.jstree.SJsTree', array('id' => 'ShopCategoryTreeFilter', 'data' => ShopCategoryNode::fromArray(ShopCategory::model()->findAllByPk(1), array('displayCount' => true)), 'options' => array('core' => array('initially_open' => 'ShopCategoryTreeFilterNode_1'), 'plugins' => array('themes', 'html_data', 'ui', 'crrm', 'search'), 'cookies' => array('save_selected' => false)))); // Category id to select in sidebar. $activeCategoryId = Yii::app()->request->getQuery('category', 0); if (is_array($activeCategoryId)) { $activeCategoryId = 0; } Yii::app()->getClientScript()->registerScript('insertAllCategory', ' $("#ShopCategoryTreeFilter").bind("loaded.jstree", function (event, data) { $(this).jstree("create",-1,false,{attr:{id:"ShopCategoryTreeFilterNode_0"}, data:{title:"' . Yii::t('ShopModule.admin', 'Все категории') . '"}},false,true); $(this).jstree("select_node","#ShopCategoryTreeFilterNode_' . $activeCategoryId . '"); }); '); Yii::app()->getClientScript()->registerCss("ShopCategoryTreeStyles", "\n\t#ShopCategoryTree { width:90% }\n\t#ShopCategoryTreeFilter {width: 255px}\n"); ?>
/** * Elimina una categoría de la base de datos. * Las subcategorías pertenecientes a esta categoría no son eliminadas, * sino que son asignadas a la categoría superior. */ function shop_delete_category() { global $xoopsSecurity, $xoopsModule; $cats = rmc_server_var($_POST, 'cats', array()); if (empty($cats)) { redirectMsg('categories.php', __('You must select one category at least!', 'shop'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('categories.php', __("Session token expired!", 'mw_categories'), 1); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("shop_categories") . " WHERE id_cat IN (" . implode(",", $cats) . ")"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $cat = new ShopCategory(); $cat->assignVars($row); if (!$cat->delete()) { showMessage(__('Category "%s" could not be deleted', 'shop'), 1); } } redirectMsg('categories.php', __('Database updated!', 'shop'), 0); }
<?php if (Yii::app()->hasModule('cart')) { $this->widget('cart.widgets.cart.CartWidget'); } ?> <div class="clr"></div> </div> </div> <div id="header-nav"> <div class="indent"> <div id="cssmenu"> <?php //Yii::import('mod.shop.models.ShopCategory'); $items = ShopCategory::model()->language(Yii::app()->language->active)->findByPk(1); if (isset($items)) { $menuArray = $items->menuArray(); } else { die("не могу найти root category."); } if (isset($menuArray['items'])) { $this->widget('ext.mbmenu.MbMenu', array('cssFile' => Yii::app()->theme->baseUrl . '/assets/css/menu.css', 'htmlOptions' => array('class' => '', 'id' => ''), 'items' => $menuArray['items'])); } ?> </div> <div class="clr"></div> </div>
/** * 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 ''; }
public function getForm() { Yii::app()->controller->widget('ext.tinymce.TinymceWidget'); $tab = new TabForm(array('attributes' => array('id' => __CLASS__, 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal'), 'showErrorSummary' => true, 'elements' => array('content' => array('type' => 'form', 'title' => $this->t('TAB_GENERAL_INFO'), 'elements' => array('name' => array('type' => 'text', 'id' => 'title'), 'seo_alias' => array('type' => 'text', 'id' => 'alias', 'visible' => Yii::app()->settings->get('core', 'translate_object_url') ? false : true), 'image' => array('type' => 'file', 'hint' => $this->getImageView()), 'cat_id' => array('type' => 'dropdownlist', 'items' => ShopCategory::flatTree(), 'empty' => '---'), 'description' => array('type' => 'textarea', 'class' => 'editor'))), 'seo' => array('type' => 'form', 'title' => $this->t('TAB_META'), 'elements' => array('seo_title' => array('type' => 'text'), 'seo_keywords' => array('type' => 'textarea'), 'seo_description' => array('type' => 'textarea')))), 'buttons' => array('submit' => array('type' => 'submit', 'class' => 'btn btn-success', 'label' => $this->isNewRecord ? Yii::t('app', 'CREATE', 0) : Yii::t('app', 'SAVE')))), $this); return $tab; }
<div class="grid2"> <?php echo Yii::t('ShopModule.admin', 'Поиск:'); ?> </div> <div class="grid10"> <input type="text" onkeyup='$("#ShopCategoryTree").jstree("search", $(this).val());' /> </div> <div class="clear"></div> </div> <?php // Register scripts Yii::app()->clientScript->registerScriptFile($this->module->assetsUrl . '/admin/products.js', CClientScript::POS_END); // Create jstree $this->widget('mod.shop.widgets.jstree.JsTree', array('id' => 'ShopCategoryTree', 'data' => ShopCategoryNode::fromArray(ShopCategory::model()->active()->findAllByPk(1)), 'options' => array('core' => array('initially_open' => 'ShopCategoryTreeNode_1'), 'plugins' => array('themes', 'html_data', 'ui', 'crrm', 'search', 'checkbox', 'cookies'), 'checkbox' => array('two_state' => true), 'cookies' => array('save_selected' => false)))); // Get categories preset if ($model->type) { $presetCategories = unserialize($model->type->categories_preset); if (!is_array($presetCategories)) { $presetCategories = array(); } } if (isset($_POST['categories']) && !empty($_POST['categories'])) { foreach ($_POST['categories'] as $id) { Yii::app()->getClientScript()->registerScript("checkNode{$id}", "\n\t\t\t\$('#ShopCategoryTree').checkNode({$id});\n\t\t"); } } elseif ($model->isNewRecord && empty($_POST['categories']) && isset($presetCategories)) { foreach ($presetCategories as $id) { if ($model->type && $id === $model->type->main_category) { continue;
/** * Builds the ShopCategory menu recursively. * * Do not call this directly, use {@link getShopCategoryMenuHierarchic()} * instead. * @static * @param integer $parent_id The parent ShopCategory ID. * @param integer $level The nesting level. * Should start at 0 (zero). * @param integer $selected The optional selected ShopCategory ID. * @return string The HTML code with all <option> tags, * or the empty string on failure. */ static function getShopCategoryMenuHierarchicRecurse($parent_id, $level, $selected = 0) { $arrChildShopCategories = ShopCategory::getChildCategoriesById($parent_id); if (!is_array($arrChildShopCategories || empty($arrChildShopCategories))) { return ''; } $result = ''; foreach ($arrChildShopCategories as $objCategory) { $id = $objCategory->id(); $name = $objCategory->name(); $result .= "<option value='{$id}'" . ($selected == $id ? \Html::ATTRIBUTE_SELECTED : '') . '>' . str_repeat('.', $level * 3) . htmlentities($name) . "</option>\n"; if ($id != $parent_id) { $result .= ShopCategory::getShopCategoryMenuHierarchicRecurse($id, $level + 1, $selected); } } return $result; }