From 052f48a635fdf22f2ef0b741622a0aa04379baf0 Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 18 Oct 2016 16:13:27 +0200 Subject: [PATCH] 3.0.0 RC3 --- config.xml | 292 ++++++++++-- controller.php | 4 +- controllers/phocacartcart.php | 2 +- controllers/phocacartcategory.php | 12 +- controllers/phocacarteditstatus.php | 2 +- controllers/phocacartformfields.php | 31 +- controllers/phocacartitem.php | 8 +- controllers/phocacartitems.php | 23 +- controllers/phocacartquestion.php | 12 + controllers/phocacartquestions.php | 18 + controllers/phocacartupload.php | 24 +- controllers/phocacartuser.json.php | 2 +- controllers/phocacartwishlist.php | 12 + controllers/phocacartwishlists.php | 18 + help/en-GB/screen.phocacart.html | 2 +- help/screen.phocacart.html | 2 +- helpers/phocacartquestions.php | 15 + helpers/phocacartwishlists.php | 15 + install/script.php | 24 +- install/sql/mysql/install.utf8.sql | 126 ++++- install/sql/mysql/uninstall.utf8.sql | 5 +- language/en-GB/en-GB.com_phocacart.ini | 176 ++++++- language/en-GB/en-GB.com_phocacart.sys.ini | 30 +- libraries/loader.php | 8 +- libraries/phocacart/attribute/attribute.php | 26 +- libraries/phocacart/captcha/index.html | 1 + libraries/phocacart/captcha/recaptcha.php | 58 +++ libraries/phocacart/cart/cart.php | 48 +- libraries/phocacart/cart/cartdb.php | 2 +- libraries/phocacart/cart/rendercart.php | 2 +- libraries/phocacart/cart/rendercheckout.php | 10 +- libraries/phocacart/category/category.php | 2 +- libraries/phocacart/compare/compare.php | 2 +- libraries/phocacart/currency/currency.php | 2 +- libraries/phocacart/email/email.php | 276 ++++++++++- libraries/phocacart/file/file.php | 5 +- libraries/phocacart/file/filethumbnail.php | 16 +- libraries/phocacart/file/fileupload.php | 45 +- .../phocacart/file/fileuploadmultiple.php | 2 - libraries/phocacart/filter/filter.php | 32 +- libraries/phocacart/form/formuser.php | 2 +- libraries/phocacart/html/batch.php | 2 +- libraries/phocacart/html/grid.php | 2 +- libraries/phocacart/html/jgrid.php | 2 +- libraries/phocacart/order/order.php | 20 +- libraries/phocacart/order/orderrender.php | 146 ++++-- libraries/phocacart/order/orderstatus.php | 107 ++++- libraries/phocacart/path/path.php | 13 +- libraries/phocacart/path/route.php | 323 +++++-------- libraries/phocacart/price/price.php | 26 +- libraries/phocacart/product/product.php | 106 +++-- .../phocacart/render/renderadminview.php | 306 ++++++++++-- .../phocacart/render/renderadminviews.php | 4 +- libraries/phocacart/render/renderfront.php | 61 ++- libraries/phocacart/render/renderjs.php | 437 +++++++++++++++-- libraries/phocacart/render/rendermedia.php | 31 +- libraries/phocacart/security/index.html | 1 + libraries/phocacart/security/security.php | 53 +++ .../phocacart/specification/specification.php | 4 + libraries/phocacart/statistics/statistics.php | 125 +++-- libraries/phocacart/stock/stock.php | 7 +- libraries/phocacart/utils/extension.php | 71 +++ libraries/phocacart/utils/log.php | 4 + libraries/phocacart/utils/utils.php | 66 ++- libraries/phocacart/wishlist/index.html | 1 + libraries/phocacart/wishlist/wishlist.php | 295 ++++++++++++ .../fonts/glyphicons-halflings-regular.woff2 | Bin 0 -> 18028 bytes media/css/administrator/phocacart.css | 219 ++++++++- media/css/icomoon/fonts/icomoon.eot | Bin 2912 -> 0 bytes media/css/icomoon/fonts/icomoon.svg | 16 - media/css/icomoon/fonts/icomoon.ttf | Bin 2748 -> 0 bytes media/css/icomoon/fonts/icomoon.woff | Bin 2240 -> 0 bytes media/css/icomoon/fonts/index.html | 1 - media/css/icomoon/icomoon-license.txt | 2 - media/css/icomoon/icomoon.css | 58 --- media/css/icomoon/index.html | 1 - media/css/main-product-hover.css | 120 +++++ media/css/main-product-image-move.css | 33 ++ media/css/main.css | 177 ++++++- media/js/chartjs/Chart.min.js | 46 +- media/js/jquery.equalminheights.min.js | 11 + media/js/phoca/index.html | 1 + media/js/phoca/jquery.phocaattribute.js | 106 +++++ media/js/phoca/jquery.phocaswapimage.js | 79 ++++ media/js/windowpopup.js | 19 + models/fields/phocacartcategory.php | 10 +- models/fields/phocacartfeed.php | 2 +- models/fields/phocapaymentmethod.php | 2 +- models/fields/phocaselectfilename.php | 82 +++- models/fields/phocaselectfilenameimage.php | 51 +- models/fields/phocaselectitem.php | 1 + models/forms/phocacartcountry.xml | 2 + models/forms/phocacartcurrency.xml | 2 + models/forms/phocacartitem.xml | 1 + models/forms/phocacartquestion.xml | 47 ++ models/forms/phocacartregion.xml | 2 + models/forms/phocacartwishlist.xml | 38 ++ models/phocacartcategories.php | 2 +- models/phocacartcategory.php | 19 +- models/phocacartcountries.php | 2 +- models/phocacartcountry.php | 3 +- models/phocacartcoupon.php | 7 + models/phocacartcoupons.php | 4 +- models/phocacartcurrencies.php | 2 +- models/phocacartdownloads.php | 2 +- models/phocacarteditstatus.php | 2 + models/phocacartfeeds.php | 2 +- models/phocacartformfield.php | 2 +- models/phocacartformfields.php | 2 +- models/phocacartitem.php | 33 +- models/phocacartitems.php | 2 +- models/phocacartlogs.php | 2 +- models/phocacartmanager.php | 23 +- models/phocacartmanufacturers.php | 2 +- models/phocacartorder.php | 2 +- models/phocacartorders.php | 4 +- models/phocacartparama.php | 6 +- models/phocacartpayments.php | 2 +- models/phocacartquestion.php | 105 +++++ models/phocacartquestions.php | 151 ++++++ models/phocacartregion.php | 2 +- models/phocacartregions.php | 2 +- models/phocacartreviews.php | 2 +- models/phocacartshippings.php | 2 +- models/phocacartspecifications.php | 2 +- models/phocacartstatistics.php | 2 +- models/phocacartstatuses.php | 2 +- models/phocacartstockstatuses.php | 2 +- models/phocacarttags.php | 4 +- models/phocacarttax.php | 7 + models/phocacartusers.php | 2 +- models/phocacartwishlist.php | 105 +++++ models/phocacartwishlists.php | 148 ++++++ other/index.html | 1 + other/install_xml.php | 111 +++++ phocacart.php | 5 +- phocacart.xml | 6 +- site/controller.php | 2 +- site/controllers/account.php | 4 +- site/controllers/checkout.json.php | 8 +- site/controllers/checkout.php | 28 +- site/controllers/comparison.json.php | 5 +- site/controllers/comparison.php | 6 +- site/controllers/download.php | 2 +- site/controllers/item.php | 4 +- site/controllers/question.php | 314 +++++++++++++ site/controllers/response.php | 4 +- site/controllers/wishlist.json.php | 160 +++++++ site/controllers/wishlist.php | 54 +++ site/helpers/route.php | 2 +- site/layouts/button_add_to_cart_item.php | 10 +- site/layouts/button_add_to_cart_list.php | 16 +- site/layouts/button_ask_question.php | 24 + site/layouts/button_buy_now_paddle.php | 2 +- site/layouts/button_category_view.php | 24 + site/layouts/button_product_view.php | 11 +- site/layouts/button_quickview.php | 24 + site/layouts/button_wishlist.php | 29 ++ site/layouts/form_filter_checkbox.php | 2 +- site/layouts/form_filter_color.php | 54 +++ site/layouts/form_filter_image.php | 59 +++ site/layouts/form_filter_text.php | 1 - site/layouts/form_question.php | 34 ++ site/layouts/list_compare.php | 6 +- site/layouts/list_wishlist.php | 46 ++ site/layouts/popup_add_to_wishlist.php | 44 ++ site/layouts/popup_quickview.php | 25 + site/layouts/popup_remove_from_wishlist.php | 45 ++ site/models/category.php | 18 +- site/models/fields/phocacaptcha.php | 37 ++ site/models/forms/question.xml | 61 +++ site/models/item.php | 2 +- site/models/items.php | 17 +- site/models/orders.php | 4 +- site/models/question.php | 144 ++++++ site/models/rules/phocacartcaptcha.php | 39 ++ site/models/rules/phocacartemail.php | 39 ++ site/models/rules/phocacarthidden.php | 28 ++ site/models/wishlist.php | 19 + site/phocacart.php | 18 +- site/router.php | 158 ++++--- site/views/account/tmpl/default.php | 11 +- site/views/account/tmpl/default_profile.php | 4 +- site/views/account/view.html.php | 4 +- site/views/categories/tmpl/default.php | 32 +- site/views/categories/tmpl/default.xml | 8 +- site/views/categories/view.html.php | 5 +- site/views/category/tmpl/default.php | 155 +++++-- site/views/category/tmpl/default.xml | 8 +- .../category/tmpl/default_pagination.php | 1 - site/views/category/view.html.php | 44 +- site/views/checkout/tmpl/default.php | 9 +- site/views/checkout/tmpl/default_address.php | 4 +- site/views/checkout/tmpl/default_confirm.php | 26 +- site/views/checkout/tmpl/default_payment.php | 4 +- .../checkout/tmpl/default_proceedpayment.php | 4 +- site/views/checkout/tmpl/default_shipping.php | 4 +- site/views/checkout/view.html.php | 10 +- site/views/comparison/tmpl/default.php | 24 +- site/views/comparison/view.html.php | 8 +- site/views/download/tmpl/default.php | 11 +- site/views/download/view.html.php | 2 +- site/views/feed/view.xml.php | 8 +- site/views/info/tmpl/default.php | 9 +- site/views/info/view.html.php | 2 +- site/views/item/tmpl/default.php | 157 +++++-- site/views/item/view.html.php | 31 +- site/views/item/view.json.php | 438 ++++++++++++++++++ site/views/items/tmpl/default.php | 165 +++++-- site/views/items/tmpl/default_pagination.php | 1 + site/views/items/view.html.php | 34 ++ site/views/order/view.html.php | 4 +- site/views/order/view.pdf.php | 60 +++ site/views/orders/tmpl/default.php | 31 +- site/views/orders/view.html.php | 7 +- site/views/payment/tmpl/default.php | 11 +- site/views/payment/view.html.php | 2 +- site/views/question/index.html | 1 + site/views/question/metadata.xml | 7 + site/views/question/tmpl/default.php | 114 +++++ site/views/question/tmpl/default.xml | 19 + site/views/question/tmpl/index.html | 1 + site/views/question/view.html.php | 126 +++++ site/views/response/tmpl/default.php | 11 +- site/views/terms/metadata.xml | 4 +- site/views/terms/tmpl/default.php | 10 + site/views/terms/view.html.php | 7 +- site/views/wishlist/index.html | 1 + site/views/wishlist/metadata.xml | 6 + site/views/wishlist/tmpl/default.php | 137 ++++++ site/views/wishlist/tmpl/default.xml | 20 + site/views/wishlist/tmpl/index.html | 1 + site/views/wishlist/view.html.php | 92 ++++ tables/phocacartcart.php | 2 +- tables/phocacartcategory.php | 2 +- tables/phocacartcountry.php | 2 +- tables/phocacartcoupon.php | 2 +- tables/phocacartcurrency.php | 2 +- tables/phocacartfeed.php | 2 +- tables/phocacartformfield.php | 3 +- tables/phocacartitem.php | 2 +- tables/phocacartlog.php | 2 +- tables/phocacartmanufacturer.php | 2 +- tables/phocacartorder.php | 2 +- tables/phocacartorderattributes.php | 2 +- tables/phocacartordercoupons.php | 2 +- tables/phocacartorderdownloads.php | 2 +- tables/phocacartorderhistory.php | 2 +- tables/phocacartorderproducts.php | 2 +- tables/phocacartpayment.php | 2 +- tables/phocacartproductcategories.php | 2 +- tables/phocacartquestion.php | 27 ++ tables/phocacartregion.php | 2 +- tables/phocacartreview.php | 2 +- tables/phocacartshipping.php | 2 +- tables/phocacartspecification.php | 2 +- tables/phocacartstatus.php | 2 +- tables/phocacartstockstatus.php | 2 +- tables/phocacarttag.php | 2 +- tables/phocacarttax.php | 2 +- tables/phocacartuser.php | 2 +- tables/phocacartwishlist.php | 27 ++ views/phocacartcart/tmpl/default.php | 2 +- views/phocacartcategories/tmpl/default.php | 14 +- views/phocacartcategory/tmpl/edit.php | 2 +- views/phocacartcategory/view.html.php | 2 +- views/phocacartcountries/tmpl/default.php | 12 +- views/phocacartcountries/view.html.php | 2 +- views/phocacartcountry/tmpl/edit.php | 4 +- views/phocacartcountry/view.html.php | 2 +- views/phocacartcoupon/tmpl/edit.php | 2 +- views/phocacartcoupon/view.html.php | 2 +- views/phocacartcoupons/tmpl/default.php | 18 +- views/phocacartcoupons/view.html.php | 2 +- views/phocacartcp/tmpl/default.php | 33 +- views/phocacartcp/view.html.php | 6 +- views/phocacartcurrencies/tmpl/default.php | 14 +- views/phocacartcurrencies/view.html.php | 2 +- views/phocacartcurrency/tmpl/edit.php | 4 +- views/phocacartcurrency/view.html.php | 2 +- views/phocacartdownload/tmpl/edit.php | 2 +- views/phocacartdownload/view.html.php | 2 +- views/phocacartdownloads/tmpl/default.php | 22 +- views/phocacartdownloads/view.html.php | 2 +- views/phocacarteditstatus/tmpl/default.php | 12 +- views/phocacartfeed/tmpl/edit.php | 4 +- views/phocacartfeed/view.html.php | 2 +- views/phocacartfeeds/tmpl/default.php | 8 +- views/phocacartfeeds/view.html.php | 2 +- views/phocacartformfield/tmpl/edit.php | 2 +- views/phocacartformfield/view.html.php | 2 +- views/phocacartformfields/tmpl/default.php | 18 +- views/phocacartformfields/view.html.php | 2 +- views/phocacartitem/tmpl/edit.php | 53 ++- views/phocacartitem/tmpl/edit_metadata.php | 2 +- views/phocacartitem/view.html.php | 2 +- views/phocacartitema/view.json.php | 2 +- views/phocacartitems/tmpl/default.php | 20 +- views/phocacartlogs/tmpl/default.php | 16 +- views/phocacartlogs/view.html.php | 2 +- views/phocacartmanager/tmpl/default.php | 2 +- views/phocacartmanager/tmpl/default_file.php | 3 +- views/phocacartmanager/view.html.php | 14 +- views/phocacartmanufacturer/tmpl/edit.php | 2 +- views/phocacartmanufacturer/view.html.php | 2 +- views/phocacartmanufacturers/tmpl/default.php | 8 +- views/phocacartmanufacturers/view.html.php | 2 +- views/phocacartorder/tmpl/edit.php | 16 +- views/phocacartorder/view.html.php | 2 +- views/phocacartorders/tmpl/default.php | 61 ++- views/phocacartorders/view.html.php | 5 +- views/phocacartorderview/view.html.php | 2 +- views/phocacartorderview/view.pdf.php | 58 +++ views/phocacartparama/view.json.php | 2 +- views/phocacartpayment/tmpl/edit.php | 5 +- views/phocacartpayment/view.html.php | 2 +- views/phocacartpayments/tmpl/default.php | 12 +- views/phocacartpayments/view.html.php | 2 +- views/phocacartquestion/index.html | 1 + views/phocacartquestion/tmpl/edit.php | 62 +++ views/phocacartquestion/tmpl/index.html | 1 + views/phocacartquestion/view.html.php | 63 +++ views/phocacartquestions/index.html | 1 + views/phocacartquestions/tmpl/default.php | 153 ++++++ views/phocacartquestions/tmpl/index.html | 1 + views/phocacartquestions/view.html.php | 87 ++++ views/phocacartregion/tmpl/edit.php | 4 +- views/phocacartregion/view.html.php | 2 +- views/phocacartregions/tmpl/default.php | 12 +- views/phocacartregions/view.html.php | 2 +- views/phocacartreview/tmpl/edit.php | 2 +- views/phocacartreview/view.html.php | 2 +- views/phocacartreviews/tmpl/default.php | 14 +- views/phocacartreviews/view.html.php | 2 +- views/phocacartshipping/tmpl/edit.php | 2 +- views/phocacartshipping/view.html.php | 2 +- views/phocacartshippings/tmpl/default.php | 10 +- views/phocacartshippings/view.html.php | 2 +- views/phocacartspecification/tmpl/edit.php | 2 +- views/phocacartspecification/view.html.php | 2 +- .../phocacartspecifications/tmpl/default.php | 8 +- views/phocacartspecifications/view.html.php | 2 +- views/phocacartstatistics/tmpl/default.php | 92 +++- views/phocacartstatistics/view.html.php | 57 +-- views/phocacartstatus/tmpl/edit.php | 2 +- views/phocacartstatus/view.html.php | 2 +- views/phocacartstatuses/tmpl/default.php | 16 +- views/phocacartstatuses/view.html.php | 2 +- views/phocacartstockstatus/tmpl/edit.php | 2 +- views/phocacartstockstatus/view.html.php | 2 +- views/phocacartstockstatuses/tmpl/default.php | 8 +- views/phocacartstockstatuses/view.html.php | 2 +- views/phocacarttag/tmpl/edit.php | 2 +- views/phocacarttag/view.html.php | 2 +- views/phocacarttags/tmpl/default.php | 8 +- views/phocacarttags/view.html.php | 2 +- views/phocacarttax/tmpl/edit.php | 2 +- views/phocacarttax/view.html.php | 2 +- views/phocacarttaxes/tmpl/default.php | 12 +- views/phocacarttaxes/view.html.php | 2 +- views/phocacartthumba/view.json.php | 7 +- views/phocacartuser/tmpl/edit.php | 2 +- views/phocacartuser/view.html.php | 2 +- views/phocacartusers/tmpl/default.php | 24 +- views/phocacartusers/view.html.php | 2 +- views/phocacartwishlist/index.html | 1 + views/phocacartwishlist/tmpl/edit.php | 62 +++ views/phocacartwishlist/tmpl/index.html | 1 + views/phocacartwishlist/view.html.php | 63 +++ views/phocacartwishlists/index.html | 1 + views/phocacartwishlists/tmpl/default.php | 149 ++++++ views/phocacartwishlists/tmpl/index.html | 1 + views/phocacartwishlists/view.html.php | 86 ++++ 373 files changed, 9200 insertions(+), 1518 deletions(-) create mode 100644 controllers/phocacartquestion.php create mode 100644 controllers/phocacartquestions.php create mode 100644 controllers/phocacartwishlist.php create mode 100644 controllers/phocacartwishlists.php create mode 100644 helpers/phocacartquestions.php create mode 100644 helpers/phocacartwishlists.php create mode 100644 libraries/phocacart/captcha/index.html create mode 100644 libraries/phocacart/captcha/recaptcha.php create mode 100644 libraries/phocacart/security/index.html create mode 100644 libraries/phocacart/security/security.php create mode 100644 libraries/phocacart/utils/extension.php create mode 100644 libraries/phocacart/wishlist/index.html create mode 100644 libraries/phocacart/wishlist/wishlist.php create mode 100644 media/bootstrap/fonts/glyphicons-halflings-regular.woff2 delete mode 100644 media/css/icomoon/fonts/icomoon.eot delete mode 100644 media/css/icomoon/fonts/icomoon.svg delete mode 100644 media/css/icomoon/fonts/icomoon.ttf delete mode 100644 media/css/icomoon/fonts/icomoon.woff delete mode 100644 media/css/icomoon/fonts/index.html delete mode 100644 media/css/icomoon/icomoon-license.txt delete mode 100644 media/css/icomoon/icomoon.css delete mode 100644 media/css/icomoon/index.html create mode 100644 media/css/main-product-hover.css create mode 100644 media/css/main-product-image-move.css create mode 100644 media/js/jquery.equalminheights.min.js create mode 100644 media/js/phoca/index.html create mode 100644 media/js/phoca/jquery.phocaattribute.js create mode 100644 media/js/phoca/jquery.phocaswapimage.js create mode 100644 media/js/windowpopup.js create mode 100644 models/forms/phocacartquestion.xml create mode 100644 models/forms/phocacartwishlist.xml create mode 100644 models/phocacartquestion.php create mode 100644 models/phocacartquestions.php create mode 100644 models/phocacartwishlist.php create mode 100644 models/phocacartwishlists.php create mode 100644 other/index.html create mode 100644 other/install_xml.php create mode 100644 site/controllers/question.php create mode 100644 site/controllers/wishlist.json.php create mode 100644 site/controllers/wishlist.php create mode 100644 site/layouts/button_ask_question.php create mode 100644 site/layouts/button_category_view.php create mode 100644 site/layouts/button_quickview.php create mode 100644 site/layouts/button_wishlist.php create mode 100644 site/layouts/form_filter_color.php create mode 100644 site/layouts/form_filter_image.php create mode 100644 site/layouts/form_question.php create mode 100644 site/layouts/list_wishlist.php create mode 100644 site/layouts/popup_add_to_wishlist.php create mode 100644 site/layouts/popup_quickview.php create mode 100644 site/layouts/popup_remove_from_wishlist.php create mode 100644 site/models/fields/phocacaptcha.php create mode 100644 site/models/forms/question.xml create mode 100644 site/models/question.php create mode 100644 site/models/rules/phocacartcaptcha.php create mode 100644 site/models/rules/phocacartemail.php create mode 100644 site/models/rules/phocacarthidden.php create mode 100644 site/models/wishlist.php create mode 100644 site/views/item/view.json.php create mode 100644 site/views/order/view.pdf.php create mode 100644 site/views/question/index.html create mode 100644 site/views/question/metadata.xml create mode 100644 site/views/question/tmpl/default.php create mode 100644 site/views/question/tmpl/default.xml create mode 100644 site/views/question/tmpl/index.html create mode 100644 site/views/question/view.html.php create mode 100644 site/views/wishlist/index.html create mode 100644 site/views/wishlist/metadata.xml create mode 100644 site/views/wishlist/tmpl/default.php create mode 100644 site/views/wishlist/tmpl/default.xml create mode 100644 site/views/wishlist/tmpl/index.html create mode 100644 site/views/wishlist/view.html.php create mode 100644 tables/phocacartquestion.php create mode 100644 tables/phocacartwishlist.php create mode 100644 views/phocacartorderview/view.pdf.php create mode 100644 views/phocacartquestion/index.html create mode 100644 views/phocacartquestion/tmpl/edit.php create mode 100644 views/phocacartquestion/tmpl/index.html create mode 100644 views/phocacartquestion/view.html.php create mode 100644 views/phocacartquestions/index.html create mode 100644 views/phocacartquestions/tmpl/default.php create mode 100644 views/phocacartquestions/tmpl/index.html create mode 100644 views/phocacartquestions/view.html.php create mode 100644 views/phocacartwishlist/index.html create mode 100644 views/phocacartwishlist/tmpl/edit.php create mode 100644 views/phocacartwishlist/tmpl/index.html create mode 100644 views/phocacartwishlist/view.html.php create mode 100644 views/phocacartwishlists/index.html create mode 100644 views/phocacartwishlists/tmpl/default.php create mode 100644 views/phocacartwishlists/tmpl/index.html create mode 100644 views/phocacartwishlists/view.html.php diff --git a/config.xml b/config.xml index 6125eac3..07e12c58 100644 --- a/config.xml +++ b/config.xml @@ -9,7 +9,9 @@ - + + + @@ -23,7 +25,6 @@ - @@ -33,15 +34,26 @@ + + + + + + + + + + + - + @@ -84,35 +96,59 @@ - - - - - - - + + + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -139,7 +175,21 @@ - + + + + + + + + + + + + + + + @@ -155,11 +205,28 @@ + + + + + + + + + + + + + + + + + @@ -171,6 +238,10 @@ + + + + @@ -192,7 +263,6 @@ - @@ -212,7 +282,10 @@ - + + + + @@ -226,15 +299,19 @@ - - + + + + + - +
+ - + @@ -246,7 +323,7 @@ - + @@ -258,7 +335,7 @@ - + @@ -271,39 +348,39 @@ + - - - + + - - + + - - + + - - + + - - + + - + @@ -337,38 +414,40 @@
+ - + - - + + - + - + - + - + - + + @@ -379,38 +458,156 @@
- - + + - - + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ - + @@ -418,6 +615,7 @@
+
diff --git a/controller.php b/controller.php index cb363673..cf1f6f0b 100644 --- a/controller.php +++ b/controller.php @@ -6,7 +6,7 @@ * @copyright Copyright (C) Jan Pavelka www.phoca.cz * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL */ -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; jimport('joomla.application.component.controller'); $app = JFactory::getApplication(); @@ -34,6 +34,8 @@ $l['do'] = array('COM_PHOCACART_DOWNLOADS', 'phocacartdownloads'); $l['tg'] = array('COM_PHOCACART_TAGS', 'phocacarttags'); $l['fd'] = array('COM_PHOCACART_XML_FEEDS', 'phocacartfeeds'); +$l['wl'] = array('COM_PHOCACART_WISH_LISTS', 'phocacartwishlists'); +$l['qu'] = array('COM_PHOCACART_QUESTIONS', 'phocacartquestions'); $l['sc'] = array('COM_PHOCACART_STATISTICS', 'phocacartstatistics'); $l['lo'] = array('COM_PHOCACART_SYSTEM_LOG', 'phocacartlogs'); $l['in'] = array('COM_PHOCACART_INFO', 'phocacartinfo'); diff --git a/controllers/phocacartcart.php b/controllers/phocacartcart.php index 19fdf6fc..ffb054d9 100644 --- a/controllers/phocacartcart.php +++ b/controllers/phocacartcart.php @@ -16,7 +16,7 @@ public function &getModel($name = 'PhocaCartCart', $prefix = 'PhocaCartCpModel', } function emptycart() { - if (!JRequest::checkToken('request')) { + if (!JSession::checkToken('request')) { $app->enqueueMessage('Invalid Token', 'message'); return false; } diff --git a/controllers/phocacartcategory.php b/controllers/phocacartcategory.php index 22f2cdd0..2a2a51dc 100644 --- a/controllers/phocacartcategory.php +++ b/controllers/phocacartcategory.php @@ -11,7 +11,7 @@ class PhocaCartCpControllerPhocaCartCategory extends PhocaCartCpControllerPhocaCartCommon { public function batch($model = null) { - JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $model = $this->getModel('phocacartcategory', '', array()); $this->setRedirect(JRoute::_('index.php?option=com_phocacart&view=phocacartcategories'.$this->getRedirectToListAppend(), false)); return parent::batch($model); @@ -19,13 +19,17 @@ public function batch($model = null) { function recreate() { $app = JFactory::getApplication(); - $cid = JRequest::getVar( 'cid', array(), '', 'array' ); + $cid = JFactory::getApplication()->input->get( 'cid', array(), '', 'array' ); JArrayHelper::toInteger($cid); + $message = ''; + if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'COM_PHOCACART_SELECT_ITEM_RECREATE' ) ); + $message = JText::_( 'COM_PHOCACART_SELECT_ITEM_RECREATE' ); + $app->enqueueMessage($message, 'error'); + $app->redirect('index.php?option=com_phocacart&view=phocacartcategories'); } - $message = ''; + $model = $this->getModel( 'phocacartcategory' ); if(!$model->recreate($cid, $message)) { $message = PhocaCartUtils::setMessage($message, JText::_( 'COM_PHOCACART_ERROR_THUMBS_REGENERATING' )); diff --git a/controllers/phocacarteditstatus.php b/controllers/phocacarteditstatus.php index d453ba85..9614baba 100644 --- a/controllers/phocacarteditstatus.php +++ b/controllers/phocacarteditstatus.php @@ -17,7 +17,7 @@ public function &getModel($name = 'PhocaCartEditStatus', $prefix = 'PhocaCartCpM function editstatus() { - if (!JRequest::checkToken('request')) { + if (!JSession::checkToken('request')) { $app->enqueueMessage('Invalid Token', 'message'); return false; } diff --git a/controllers/phocacartformfields.php b/controllers/phocacartformfields.php index a8489fc2..9b91875b 100644 --- a/controllers/phocacartformfields.php +++ b/controllers/phocacartformfields.php @@ -26,20 +26,23 @@ public function &getModel($name = 'PhocaCartFormfield', $prefix = 'PhocaCartCpMo } function displaybilling() { - JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); - - $cid = JRequest::getVar('cid', array(), '', 'array'); + JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); + + $app = JFactory::getApplication(); + $cid = $app->input->get('cid', array(), '', 'array'); $data = array('displaybilling' => 1, 'hidebilling' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); + + if (empty($cid)) { - JError::raiseWarning(500, JText::_($this->text_prefix.'_NO_ITEM_SELECTED')); + $app->enqueueMessage(JText::_($this->text_prefix.'_NO_ITEM_SELECTED'), 'error'); } else { $model = $this->getModel(); JArrayHelper::toInteger($cid); if (!$model->displayItem($cid, $value, 'display_billing')) { - JError::raiseWarning(500, $model->getError()); + $app->enqueueMessage($model->getError(), 'error'); } else { if ($value == 1) { $ntext = $this->text_prefix.'_N_ITEMS_DISPLAYED'; @@ -53,20 +56,21 @@ function displaybilling() { } function displayshipping() { - JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); + JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - $cid = JRequest::getVar('cid', array(), '', 'array'); + $app = JFactory::getApplication(); + $cid = $app->input->get('cid', array(), '', 'array'); $data = array('displayshipping' => 1, 'hideshipping' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { - JError::raiseWarning(500, JText::_($this->text_prefix.'_NO_ITEM_SELECTED')); + $app->enqueueMessage(JText::_($this->text_prefix.'_NO_ITEM_SELECTED'), 'error'); } else { $model = $this->getModel(); JArrayHelper::toInteger($cid); if (!$model->displayItem($cid, $value, 'display_shipping')) { - JError::raiseWarning(500, $model->getError()); + $app->enqueueMessage($model->getError(), 'error'); } else { if ($value == 1) { $ntext = $this->text_prefix.'_N_ITEMS_DISPLAYED'; @@ -80,20 +84,21 @@ function displayshipping() { } function displayaccount() { - JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); + JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - $cid = JRequest::getVar('cid', array(), '', 'array'); + $app = JFactory::getApplication(); + $cid = $app->input->get('cid', array(), '', 'array'); $data = array('displayaccount' => 1, 'hideaccount' => 0); $task = $this->getTask(); $value = JArrayHelper::getValue($data, $task, 0, 'int'); if (empty($cid)) { - JError::raiseWarning(500, JText::_($this->text_prefix.'_NO_ITEM_SELECTED')); + $app->enqueueMessage(JText::_($this->text_prefix.'_NO_ITEM_SELECTED'), 'error'); } else { $model = $this->getModel(); JArrayHelper::toInteger($cid); if (!$model->displayItem($cid, $value, 'display_account')) { - JError::raiseWarning(500, $model->getError()); + $app->enqueueMessage($model->getError(), 'error'); } else { if ($value == 1) { $ntext = $this->text_prefix.'_N_ITEMS_DISPLAYED'; diff --git a/controllers/phocacartitem.php b/controllers/phocacartitem.php index 1c6814f0..f97c16c5 100644 --- a/controllers/phocacartitem.php +++ b/controllers/phocacartitem.php @@ -11,7 +11,7 @@ class PhocaCartCpControllerPhocaCartItem extends PhocaCartCpControllerPhocaCartCommon { public function batch($model = null) { - JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); $model = $this->getModel('phocacartitem', '', array()); $this->setRedirect(JRoute::_('index.php?option=com_phocacart&view=phocacartitems'.$this->getRedirectToListAppend(), false)); @@ -21,11 +21,13 @@ public function batch($model = null) { function recreate() { $app = JFactory::getApplication(); - $cid = JRequest::getVar( 'cid', array(), '', 'array' ); + $cid = JFactory::getApplication()->input->get( 'cid', array(), '', 'array' ); JArrayHelper::toInteger($cid); if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'COM_PHOCACART_SELECT_ITEM_RECREATE' ) ); + $message = JText::_( 'COM_PHOCACART_SELECT_ITEM_RECREATE' ); + $app->enqueueMessage($message, 'error'); + $app->redirect('index.php?option=com_phocacart&view=phocacartcategories'); } $message = ''; $model = $this->getModel( 'phocacartitem' ); diff --git a/controllers/phocacartitems.php b/controllers/phocacartitems.php index 4416c5bb..d54cd9c6 100644 --- a/controllers/phocacartitems.php +++ b/controllers/phocacartitems.php @@ -25,6 +25,7 @@ public function featured() // Check for request forgeries JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + $app = JFactory::getApplication(); $user = JFactory::getUser(); $ids = $this->input->get('cid', array(), 'array'); $values = array('featured' => 1, 'unfeatured' => 0); @@ -38,26 +39,20 @@ public function featured() { // Prune items that you can't change. unset($ids[$i]); - JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); + $this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); + $this->setMessage($this->getError(), 'error'); } } - if (empty($ids)) - { - JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED')); - } - else - { - // Get the model. - $model = $this->getModel(); + if (empty($ids)) { + $app->enqueueMessage(JText::_('COM_PHOCACART_ERROR_NO_ITEMS_SELECTED'), 'error'); + } else { - // Publish the items. - if (!$model->featured($ids, $value)) - { - JError::raiseWarning(500, $model->getError()); + $model = $this->getModel(); + if (!$model->featured($ids, $value)) { + $app->enqueueMessage($model->getError(), 'error'); } } - $this->setRedirect('index.php?option=com_phocacart&view=phocacartitems'); } } diff --git a/controllers/phocacartquestion.php b/controllers/phocacartquestion.php new file mode 100644 index 00000000..81c13e9c --- /dev/null +++ b/controllers/phocacartquestion.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/controllers/phocacartquestions.php b/controllers/phocacartquestions.php new file mode 100644 index 00000000..3eaab36a --- /dev/null +++ b/controllers/phocacartquestions.php @@ -0,0 +1,18 @@ + true)); + return $model; + } +} +?> \ No newline at end of file diff --git a/controllers/phocacartupload.php b/controllers/phocacartupload.php index 2c502fbe..e8899842 100644 --- a/controllers/phocacartupload.php +++ b/controllers/phocacartupload.php @@ -18,7 +18,7 @@ function __construct() { } function createfolder() { - JRequest::checkToken() or jexit( 'COM_PHOCADOWNLOAD_INVALID_TOKEN' ); + JSession::checkToken() or jexit( 'COM_PHOCADOWNLOAD_INVALID_TOKEN' ); $app = JFactory::getApplication(); // Set FTP credentials, if given @@ -29,13 +29,13 @@ function createfolder() { $folder_permissions = $paramsC->get( 'folder_permissions', 0755 ); //$folder_permissions = octdec((int)$folder_permissions); - $folderNew = JRequest::getCmd( 'foldername', ''); - $folderCheck = JRequest::getVar( 'foldername', null, '', 'string', JREQUEST_ALLOWRAW); - $parent = JRequest::getVar( 'folderbase', '', '', 'path' ); - $tab = JRequest::getVar( 'tab', 0, '', 'string' ); - $field = JRequest::getVar( 'field'); - $viewBack = JRequest::getVar( 'viewback', '', '', 'phocacartmanager' ); - $manager = JRequest::getVar( 'manager', 'file', '', 'string' ); + $folderNew = $app->input->get( 'foldername', ''); + $folderCheck = $app->input->get( 'foldername', null, 'raw'); + $parent = $app->input->get( 'folderbase', '', 'path' ); + $tab = $app->input->get( 'tab', 0, 'string' ); + $field = $app->input->get( 'field'); + $viewBack = $app->input->get( 'viewback', 'phocacartmanager' ); + $manager = $app->input->get( 'manager', 'file', 'string' ); $link = ''; @@ -49,14 +49,14 @@ function createfolder() { exit; } - JRequest::setVar('folder', $parent); + JFactory::getApplication()->input->set('folder', $parent); if (($folderCheck !== null) && ($folderNew !== $folderCheck)) { $app->redirect($link, JText::_('COM_PHOCACART_WARNING_DIRNAME')); } if (strlen($folderNew) > 0) { - $folder = JPath::clean($path['orig_abs_ds'].$parent.DS.$folderNew); + $folder = JPath::clean($path['orig_abs_ds'].$parent.'/'.$folderNew); if (!JFolder::exists($folder) && !JFile::exists($folder)) { //JFolder::create($path, $folder_permissions ); @@ -81,7 +81,7 @@ function createfolder() { } if (isset($folder)) { $data = "\n\n\n"; - JFile::write($folder.DS."index.html", $data); + JFile::write($folder."/index.html", $data); } else { $app->redirect($link, JText::_('COM_PHOCACART_ERROR_FOLDER_CREATING')); } @@ -90,7 +90,7 @@ function createfolder() { } else { $app->redirect($link, JText::_('COM_PHOCACART_ERROR_FOLDER_CREATING_EXISTS')); } - //JRequest::setVar('folder', ($parent) ? $parent.'/'.$folder : $folder); + //JFactory::getApplication()->input->set('folder', ($parent) ? $parent.'/'.$folder : $folder); } $app->redirect($link); } diff --git a/controllers/phocacartuser.json.php b/controllers/phocacartuser.json.php index 21d78e38..23162fbb 100644 --- a/controllers/phocacartuser.json.php +++ b/controllers/phocacartuser.json.php @@ -12,7 +12,7 @@ class PhocaCartCpControllerPhocaCartUser extends JControllerForm { public function setregion() { - if (!JRequest::checkToken('request')) { + if (!JSession::checkToken('request')) { $response = array( 'status' => '0', 'error' => '
' . JText::_('JINVALID_TOKEN') . '
'); diff --git a/controllers/phocacartwishlist.php b/controllers/phocacartwishlist.php new file mode 100644 index 00000000..f912778c --- /dev/null +++ b/controllers/phocacartwishlist.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/controllers/phocacartwishlists.php b/controllers/phocacartwishlists.php new file mode 100644 index 00000000..da92f853 --- /dev/null +++ b/controllers/phocacartwishlists.php @@ -0,0 +1,18 @@ + true)); + return $model; + } +} +?> \ No newline at end of file diff --git a/help/en-GB/screen.phocacart.html b/help/en-GB/screen.phocacart.html index 3ad8b748..be5b381f 100644 --- a/help/en-GB/screen.phocacart.html +++ b/help/en-GB/screen.phocacart.html @@ -1,4 +1,4 @@ - + diff --git a/help/screen.phocacart.html b/help/screen.phocacart.html index 3ad8b748..be5b381f 100644 --- a/help/screen.phocacart.html +++ b/help/screen.phocacart.html @@ -1,4 +1,4 @@ - + diff --git a/helpers/phocacartquestions.php b/helpers/phocacartquestions.php new file mode 100644 index 00000000..b0a24658 --- /dev/null +++ b/helpers/phocacartquestions.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/helpers/phocacartwishlists.php b/helpers/phocacartwishlists.php new file mode 100644 index 00000000..10bfd6d5 --- /dev/null +++ b/helpers/phocacartwishlists.php @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/install/script.php b/install/script.php index bec6f56f..8f2442f7 100644 --- a/install/script.php +++ b/install/script.php @@ -18,14 +18,14 @@ function install($parent) { //echo '

' . JText::_('COM_PHOCAGALLLERY_INSTALL_TEXT') . '

'; - $folder[0][0] = 'images' . DS . 'phocacartcategories' ; - $folder[0][1] = JPATH_ROOT . DS . $folder[0][0]; + $folder[0][0] = 'images' . '/phocacartcategories' ; + $folder[0][1] = JPATH_ROOT . '/' . $folder[0][0]; - $folder[1][0] = 'images' . DS . 'phocacartproducts' ; - $folder[1][1] = JPATH_ROOT . DS . $folder[1][0]; + $folder[1][0] = 'images' . '/phocacartproducts' ; + $folder[1][1] = JPATH_ROOT . '/' . $folder[1][0]; $folder[2][0] = 'phocacartdownload' ; - $folder[2][1] = JPATH_ROOT . DS . $folder[2][0]; + $folder[2][1] = JPATH_ROOT . '/' . $folder[2][0]; $message = ''; @@ -38,7 +38,7 @@ function install($parent) { { $data = "\n\n\n"; - JFile::write($value[1].DS."index.html", $data); + JFile::write($value[1]."/index.html", $data); $message .= '
Folder ' . $value[0] .' created!
'; $error[] = 0; @@ -85,14 +85,14 @@ function uninstall($parent) { function update($parent) { //echo '

' . JText::sprintf('COM_PHOCACART_UPDATE_TEXT', $parent->get('manifest')->version) . '

'; - $folder[0][0] = 'images' . DS . 'phocacartcategories' ; - $folder[0][1] = JPATH_ROOT . DS . $folder[0][0]; + $folder[0][0] = 'images/phocacartcategories' ; + $folder[0][1] = JPATH_ROOT . '/' . $folder[0][0]; - $folder[1][0] = 'images' . DS . 'phocacartproducts' ; - $folder[1][1] = JPATH_ROOT . DS . $folder[1][0]; + $folder[1][0] = 'images/phocacartproducts' ; + $folder[1][1] = JPATH_ROOT . '/' . $folder[1][0]; $folder[2][0] = 'phocacartdownload' ; - $folder[2][1] = JPATH_ROOT . DS . $folder[2][0]; + $folder[2][1] = JPATH_ROOT . '/' . $folder[2][0]; $message = ''; $error = array(); @@ -104,7 +104,7 @@ function update($parent) { { $data = "\n\n\n"; - JFile::write($value[1].DS."index.html", $data); + JFile::write($value[1]."/index.html", $data); $message .= '
Folder ' . $value[0] .' created!
'; $error[] = 0; diff --git a/install/sql/mysql/install.utf8.sql b/install/sql/mysql/install.utf8.sql index bc6fa6f6..09be80ff 100644 --- a/install/sql/mysql/install.utf8.sql +++ b/install/sql/mysql/install.utf8.sql @@ -63,6 +63,7 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_products` ( `unit_amount` DECIMAL( 15, 4 ) NOT NULL DEFAULT '0', `unit_unit` varchar(64) NOT NULL DEFAULT '', `min_quantity` int(11) NOT NULL DEFAULT '0', + `min_multiple_quantity` int(11) NOT NULL DEFAULT '0', `stockstatus_a_id` int(11) NOT NULL DEFAULT '0', `stockstatus_n_id` int(11) NOT NULL DEFAULT '0', `availability` text, @@ -168,8 +169,13 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_attribute_values` ( `volume` DECIMAL( 10, 4 ) NOT NULL DEFAULT '0', `operator_volume` char(1) NOT NULL DEFAULT '0', `image` varchar(255) NOT NULL DEFAULT '', + `image_small` varchar(255) NOT NULL DEFAULT '', + `image_medium` varchar(255) NOT NULL DEFAULT '', `ordering` int(11) NOT NULL DEFAULT '0', `language` char(7) NOT NULL DEFAULT '', + `color` varchar(50) NOT NULL DEFAULT '', + `type` tinyint(1) NOT NULL DEFAULT '0', + `params` text, PRIMARY KEY (`id`), KEY `idx_attribute` (`attribute_id`) , KEY `idx_alias` (`alias`), @@ -269,6 +275,7 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_countries` ( `type` int(11) NOT NULL DEFAULT '0', `code2` varchar(20) NOT NULL DEFAULT '', `code3` varchar(20) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', `published` tinyint(1) NOT NULL DEFAULT '0', `checked_out` int(11) unsigned NOT NULL DEFAULT '0', `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -286,6 +293,7 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_regions` ( `type` int(11) NOT NULL DEFAULT '0', `code2` varchar(20) NOT NULL DEFAULT '', `code3` varchar(20) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', `published` tinyint(1) NOT NULL DEFAULT '0', `checked_out` int(11) unsigned NOT NULL DEFAULT '0', `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', @@ -348,6 +356,7 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_tags` ( `id` int(11) NOT NULL auto_increment, `title` varchar(255) NOT NULL DEFAULT '', `alias` varchar(255) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', `link_ext` varchar(255) NOT NULL DEFAULT '', `link_cat` int(11) unsigned NOT NULL DEFAULT '0', `description` text, @@ -372,6 +381,7 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_taxes` ( `id` int(11) NOT NULL auto_increment, `title` varchar(255) NOT NULL DEFAULT '', `alias` varchar(255) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', `tax_rate` DECIMAL( 10, 4 ) NOT NULL DEFAULT '0', `calculation_type` tinyint(1) NOT NULL DEFAULT '0', `published` tinyint(1) NOT NULL DEFAULT '0', @@ -388,6 +398,7 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_currencies` ( `title` varchar(255) NOT NULL DEFAULT '', `alias` varchar(255) NOT NULL DEFAULT '', `code` varchar(5) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', `exchange_rate` DECIMAL( 10, 4 ) NOT NULL DEFAULT '0', `price_format` tinyint(1) NOT NULL DEFAULT '0', `price_currency_symbol` varchar(10) NOT NULL DEFAULT '', @@ -562,6 +573,7 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_users` ( `newsletter` tinyint(1) NOT NULL DEFAULT '0', `title` varchar(255) NOT NULL DEFAULT '', `alias` varchar(255) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', `name_first` varchar(100) NOT NULL DEFAULT '', `name_middle` varchar(100) NOT NULL DEFAULT '', @@ -606,6 +618,7 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_order_statuses` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL DEFAULT '', `alias` varchar(255) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', `description` text, `stock_movements` char(1) NOT NULL DEFAULT '', `email_customer` tinyint(1) NOT NULL DEFAULT '0', @@ -815,6 +828,7 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_feeds` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL DEFAULT '', `alias` varchar(255) NOT NULL DEFAULT '', + `image` varchar(255) NOT NULL DEFAULT '', `description` text, `header` text, `footer` text, @@ -834,6 +848,52 @@ CREATE TABLE IF NOT EXISTS `#__phocacart_feeds` ( KEY (`type`) ) DEFAULT CHARSET=utf8; +CREATE TABLE IF NOT EXISTS `#__phocacart_wishlists` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `product_id` int(11) NOT NULL DEFAULT '0', + `category_id` int(11) NOT NULL DEFAULT '0', + `user_id` int(11) NOT NULL DEFAULT '0', + `title` varchar(255) NOT NULL DEFAULT '', + `alias` varchar(255) NOT NULL DEFAULT '', + `ip` varchar(40) NOT NULL DEFAULT '', + `user_agent` varchar(255) NOT NULL DEFAULT '', + `quantity` int(11) NOT NULL DEFAULT '0', + `type` tinyint(1) NOT NULL DEFAULT '0', + `priority` tinyint(1) NOT NULL DEFAULT '0', + `published` tinyint(1) NOT NULL DEFAULT '0', + `checked_out` int(11) unsigned NOT NULL DEFAULT '0', + `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `ordering` int(11) NOT NULL DEFAULT '0', + `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `params` text, + PRIMARY KEY (`id`) +) DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `#__phocacart_questions` ( + `id` int(11) unsigned NOT NULL auto_increment, + `product_id` int(11) NOT NULL default '0', + `category_id` int(11) NOT NULL default '0', + `user_id` int(11) NOT NULL default '0', + `question_id` int(11) NOT NULL default '0', + `name` varchar(100) NOT NULL default '', + `email` varchar(50) NOT NULL default '', + `phone` varchar(20) NOT NULL default '', + `phone_mobile` varchar(20) NOT NULL default '', + `ip` varchar(20) NOT NULL default '', + `title` varchar(200) NOT NULL default '', + `alias` varchar(255) NOT NULL default '', + `message` text NOT NULL, + `date` datetime NOT NULL default '0000-00-00 00:00:00', + `published` tinyint(1) NOT NULL default '0', + `checked_out` int(11) NOT NULL default '0', + `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00', + `ordering` int(11) NOT NULL DEFAULT '0', + `params` text NOT NULL, + `language` char(7) NOT NULL default '', + PRIMARY KEY (`id`), + KEY `published` (`published`) +) DEFAULT CHARSET=utf8; + -- Data @@ -1055,10 +1115,72 @@ INSERT INTO `#__phocacart_form_fields` ( `title`, `label`, `description`, `type` -- ALTER TABLE `#__phocacart_order_total` CHANGE `amount` `amount` DECIMAL( 15, 4 ) NOT NULL DEFAULT '0'; +-- --------- +-- RC2 -> RC3 +-- --------- +-- ALTER TABLE `#__phocacart_countries` ADD `image` varchar(255) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_regions` ADD `image` varchar(255) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_currencies` ADD `image` varchar(255) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_users` ADD `image` varchar(255) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_order_statuses` ADD `image` varchar(255) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_taxes` ADD `image` varchar(255) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_feeds` ADD `image` varchar(255) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_tags` ADD `image` varchar(255) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_products` ADD `min_multiple_quantity` int(11) NOT NULL DEFAULT '0'; +-- ALTER TABLE `#__phocacart_attribute_values` ADD `color` varchar(50) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_attribute_values` ADD `type` tinyint(1) NOT NULL DEFAULT '0'; +-- ALTER TABLE `#__phocacart_attribute_values` ADD `params` text; +-- ALTER TABLE `#__phocacart_attribute_values` ADD `image_small` varchar(255) NOT NULL DEFAULT ''; +-- ALTER TABLE `#__phocacart_attribute_values` ADD `image_medium` varchar(255) NOT NULL DEFAULT ''; - - +-- New table added +-- --------------- +--CREATE TABLE IF NOT EXISTS `#__phocacart_wishlists` ( +-- `id` int(11) NOT NULL AUTO_INCREMENT, +-- `product_id` int(11) NOT NULL DEFAULT '0', +-- `category_id` int(11) NOT NULL DEFAULT '0', +-- `user_id` int(11) NOT NULL DEFAULT '0', +-- `title` varchar(255) NOT NULL DEFAULT '', +-- `alias` varchar(255) NOT NULL DEFAULT '', +-- `ip` varchar(40) NOT NULL DEFAULT '', +-- `user_agent` varchar(255) NOT NULL DEFAULT '', +-- `quantity` int(11) NOT NULL DEFAULT '0', +-- `type` tinyint(1) NOT NULL DEFAULT '0', +-- `priority` tinyint(1) NOT NULL DEFAULT '0', +-- `published` tinyint(1) NOT NULL DEFAULT '0', +-- `checked_out` int(11) unsigned NOT NULL DEFAULT '0', +-- `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', +-- `ordering` int(11) NOT NULL DEFAULT '0', +-- `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', +-- `params` text, +-- PRIMARY KEY (`id`) +--) DEFAULT CHARSET=utf8; + +--CREATE TABLE IF NOT EXISTS `#__phocacart_questions` ( +-- `id` int(11) unsigned NOT NULL auto_increment, +-- `product_id` int(11) NOT NULL default '0', +-- `category_id` int(11) NOT NULL default '0', +-- `user_id` int(11) NOT NULL default '0', +-- `question_id` int(11) NOT NULL default '0', +-- `name` varchar(100) NOT NULL default '', +-- `email` varchar(50) NOT NULL default '', +-- `phone` varchar(20) NOT NULL default '', +-- `phone_mobile` varchar(20) NOT NULL default '', +-- `ip` varchar(20) NOT NULL default '', +-- `title` varchar(200) NOT NULL default '', +-- `alias` varchar(255) NOT NULL default '', +-- `message` text NOT NULL, +-- `date` datetime NOT NULL default '0000-00-00 00:00:00', +-- `published` tinyint(1) NOT NULL default '0', +-- `checked_out` int(11) NOT NULL default '0', +-- `checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00', +-- `ordering` int(11) NOT NULL DEFAULT '0', +-- `params` text NOT NULL, +-- `language` char(7) NOT NULL default '', +-- PRIMARY KEY (`id`), +-- KEY `published` (`published`) +--) DEFAULT CHARSET=utf8; diff --git a/install/sql/mysql/uninstall.utf8.sql b/install/sql/mysql/uninstall.utf8.sql index e54a508e..5c0ef57f 100644 --- a/install/sql/mysql/uninstall.utf8.sql +++ b/install/sql/mysql/uninstall.utf8.sql @@ -41,4 +41,7 @@ DROP TABLE IF EXISTS `#__phocacart_order_coupons`; DROP TABLE IF EXISTS `#__phocacart_order_total`; DROP TABLE IF EXISTS `#__phocacart_order_history`; DROP TABLE IF EXISTS `#__phocacart_order_downloads`; -DROP TABLE IF EXISTS `#__phocacart_logs`; \ No newline at end of file +DROP TABLE IF EXISTS `#__phocacart_logs`; +DROP TABLE IF EXISTS `#__phocacart_feeds`; +DROP TABLE IF EXISTS `#__phocacart_wishlists`; +DROP TABLE IF EXISTS `#__phocacart_questions`; \ No newline at end of file diff --git a/language/en-GB/en-GB.com_phocacart.ini b/language/en-GB/en-GB.com_phocacart.ini index de10eced..387a81fd 100644 --- a/language/en-GB/en-GB.com_phocacart.ini +++ b/language/en-GB/en-GB.com_phocacart.ini @@ -15,7 +15,179 @@ COM_PHOCACART_ORDER_PROCESSED_DOWNLOADABLE_ITEMS_ADDITIONAL_INFO="" COM_PHOCACART_ORDER_PAYMENT_PROCESSED_ADDITIONAL_INFO="" COM_PHOCACART_ORDER_PAYMENT_PROCESSED_DOWNLOADABLE_ITEMS_ADDITIONAL_INFO="" COM_PHOCACART_ORDER_PAYMENT_CANCELED_ADDITIONAL_INFO="" +COM_PHOCACART_FIELD_IP_BAN_DESC="Add the IP(s) you want to block, to the IP(s) Ban list. Separate each IP with a comma (,)" +COM_PHOCACART_FIELD_IP_BAN_LABEL="IP Ban" +;[3.0.0 RC3] +COM_PHOCACART_ITEMS="Items" +COM_PHOCACART_FIELD_FADE_IN_ACTION_ICONS_LABEL="Fade In Action Icons" +COM_PHOCACART_FIELD_FADE_IN_ACTION_ICONS_DESC="Display action icons with javascript effect (fade in)" +COM_PHOCACART_FIELD_DISPLAY_QUICK_VIEW_ICON_LABEL="Display Quick View Icon" +COM_PHOCACART_FIELD_DISPLAY_QUICK_VIEW_ICON_DESC="Display or hide Quick View icon" +COM_PHOCACART_QUICK_VIEW="Quick View" +COM_PHOCACART_PROCEED_TO_WISH_LIST="Proceed to wish list" +COM_PHOCACART_PRODUCT_REMOVED_FROM_WISH_LIST="Product removed from wish list" +COM_PHOCACART_PRODUCT_NOT_REMOVED_FROM_WISH_LIST="Product not removed from wishl list" +COM_PHOCACART_THERE_ARE_NO_PRODUCTS_IN_YOUR_WISH_LIST="There are no products in your wish list" +COM_PHOCACART_VIEW_WISH_LIST="View Wish list" +COM_PHOCACART_REMOVE_FROM_WISH_LIST="Remove from wish list" +COM_PHOCACART_REMOVE_FROM_COMPARISON_LIST="Remove from comparison list" +COM_PHOCACART_PRODUCT_NOT_ADDED_TO_WISH_LIST="Product not added to wish list" +COM_PHOCACART_PRODUCT_NOT_REMOVED_FROM_WISH_LIST="Product not removed from wish list" +COM_PHOCACART_PRODUCT_ADDED_TO_WISH_LIST="Product added to wish list" +COM_PHOCACART_PRODUCT_INCLUDED_IN_WISH_LIST="Product is included in wish list" +COM_PHOCACART_NOT_LOGGED_IN_PLEASE_LOGIN="You are not logged in. Please login." +COM_PHOCACART_COUNT_OF_PRODUCTS_IN_WISH_LIST_IS_LIMITED="Count of products in wish list is limited" +COM_PHOCACART_FIELD_DISPLAY_WISH_LIST_ICON_LABEL="Display Wish List Icon" +COM_PHOCACART_FIELD_DISPLAY_WISH_LIST_ICON_DESC="Display or hide Wish List icon" +COM_PHOCACART_ADD_TO_WISH_LIST="Add to Wish List" +COM_PHOCACART_FIELD_ADD_TO_WISH_LIST_METHOD_LABEL="Add To Wish List Method" +COM_PHOCACART_FIELD_ADD_TO_WISH_LIST_METHOD_DESC="Select method of how the products will be added to the wish list." +COM_PHOCACART_WISH_LISTS="Wish Lists" +COM_PHOCACART_WISH_LIST="Wish List" +COM_PHOCACART_FIELD_SWITCH_IMAGE_CATEGORY_ITEMS_VIEW_LABEL="Switch Image" +COM_PHOCACART_FIELD_SWITCH_IMAGE_CATEGORY_ITEMS_VIEW_DESC="Enable or disable switch image effect for Category or Items View. Products must include at least two images" +COM_PHOCACART_QUESTION="Question" +COM_PHOCACART_FIELD_CATEGORY_ID_LABEL="Category ID" +COM_PHOCACART_FIELD_CATEGORY_ID_DESC="Set category ID" +COM_PHOCACART_FIELD_EMAIL_LABEL="Email" +COM_PHOCACART_FIELD_EMAIL_LABEL="Set email" +COM_PHOCACART_FIELD_IP_LABEL="IP" +COM_PHOCACART_FIELD_IP_LABEL="Set IP" +COM_PHOCACART_FIELD_MESSAGE_LABEL="Message" +COM_PHOCACART_FIELD_MESSAGE_LABEL="Set message" +COM_PHOCACART_FIELD_ASK_A_QUESTON_BUTTON_ITEM_VIEW_LABEL="Ask A Question Button" +COM_PHOCACART_FIELD_ASK_A_QUESTON_BUTTON_ITEM_VIEW_DESC="Display or hide Ask A Question button in Product view. Ask A Question function needs to be enabled in Ask Question/Feedback/Report Options" +COM_PHOCACART_FIELD_ASK_A_QUESTON_POPUP_ITEM_VIEW_LABEL="Ask A Question Popup" +COM_PHOCACART_FIELD_ASK_A_QUESTON_POPUP_ITEM_VIEW_DESC="Display Ask A Question form in Popup window or on standard page" +COM_PHOCACART_ASK_A_QUESTION="Ask a Question" +COM_PHOCACART_FIELD_ENABLE_TIME_CHECK_QUESTION_LABEL="Enable Time Check" +COM_PHOCACART_FIELD_ENABLE_TIME_CHECK_QUESTION_DESC="If time check is enabled, user cannot post the message after a few seconds. Define time in seconds. If zero, this parameter will be disabled." +COM_PHOCACART_BAD_EMAIL="Please enter valid email address" +COM_PHOCACART_REGARDS="Regards" +COM_PHOCACART_CLICK_LINK_READ_FULL_POST="Click the link to read full post" +COM_PHOCACART_FIELD_DISPLAY_NAME_FORM_LABEL="Display Name In Form" +COM_PHOCACART_FIELD_DISPLAY_NAME_FORM_DESC="Display or hide name in Ask Question form" +COM_PHOCACART_FIELD_DISPLAY_EMAIL_FORM_LABEL="Display Email In Form" +COM_PHOCACART_FIELD_DISPLAY_EMAIL_FORM_DESC="Display or hide email in Ask Question form" +COM_PHOCACART_FIELD_DISPLAY_PHONE_FORM_LABEL="Display Phone In Form" +COM_PHOCACART_FIELD_DISPLAY_PHONE_FORM_DESC="Display or hide phone in Ask Question form" +COM_PHOCACART_FIELD_DISPLAY_MESSAGE_FORM_LABEL="Display Message In Form" +COM_PHOCACART_FIELD_DISPLAY_MESSAGE_FORM_DESC="Display or hide message in Ask Question form" +COM_PHOCACART_FIELD_ENABLE_CAPTCHA_FORM_LABEL="Enable Captcha In Form" +COM_PHOCACART_FIELD_ENABLE_CAPTCHA_FORM_DESC="Enable or disable captcha in Ask Question form" +COM_PHOCACART_YES_REQUIRED="Yes (Required)" +COM_PHOCACART_POSSIBLE_SPAM_DETECTED="Possible Spam Detected" +COM_PHOCACART_SESSION_INVALID="Invalid session" +COM_PHOCACART_SUBMIT_TOO_FAST="Possible spam detected. Form entered too fast." +COM_PHOCACART_THANK_YOU_FOR_LEAVING_INFORMATION_ASKING_QUESTION="Thank you for leaving your information and asking your question. We will contact you as soon as possible" +COM_PHOCACART_FIELD_MAXIMUM_CHARACTERS_MESSAGE_LABEL="Maximum Characters" +COM_PHOCACART_FIELD_MAXIMUM_CHARACTERS_MESSAGE_DESC="Set maximum number of characters in Message field, they can be saved in database" +COM_PHOCACART_FIELD_MAXIMUM_CHARACTERS_MESSAGE_EMAIL_LABEL="Maximum Characters (Email)" +COM_PHOCACART_FIELD_MAXIMUM_CHARACTERS_MESSAGE_EMAIL_DESC="Set maximum number of characters in Message field, they can be sent in email" +COM_PHOCACART_FIELD_SEND_EMAIL_QUESTION_DESC="Send Email to selected user" +COM_PHOCACART_FIELD_SEND_EMAIL_QUESTION_LABEL="Send Email" +COM_PHOCACART_NEW_QUESTION="New Question" +COM_PHOCACART_NEW_POST_ADDED="New Post Added" +COM_PHOCACART_FROM="From" +COM_PHOCACART_SUBJECT="Subject" +COM_PHOCACART_FIELD_ENABLE_HIDDEN_FIELD_QUESTION_LABEL="Enable Hidden Field" +COM_PHOCACART_FIELD_ENABLE_HIDDEN_FIELD_QUESTION_DESC="Enable or disable hidden field. Some spam bots try to fill all the fields on the site, if they fill this hidden field, which human does not see, the entry will be not added into the Ask Question form." +COM_PHOCACART_FIELD_FORBIDDEN_WHOLE_WORD_FILTER_QUESTION_LABEL="Forbidden Whole Word Filter" +COM_PHOCACART_FIELD_FORBIDDEN_WHOLE_WORD_FILTER_QUESTION_DESC="Set whole forbidden words. If some will be included in Ask Question form then form will be not stored and sent. Separate each word with a comma (,)" +COM_PHOCACART_FIELD_FORBIDDEN_WORD_FILTER_QUESTION_LABEL="Forbidden Word Filter" +COM_PHOCACART_FIELD_FORBIDDEN_WORD_FILTER_QUESTION_DESC="Set forbidden words. If some will be included in Ask Question form then form will be not stored and sent. Separate each word with a comma (,)" +COM_PHOCACART_FIELD_SESSION_SUFFIX_LABEL="Session Suffix" +COM_PHOCACART_FIELD_SESSION_SUFFIX_DESC="Set session suffix (It is a security feature to change the name of session, set unique suffix, for example: a100b20c3)" +COM_PHOCACART_FIELD_RECAPTCHA_SITEKEY_LABEL="reCAPTCHA Site Key" +COM_PHOCACART_FIELD_RECAPTCHA_SITEKEY_DESC="Set reCAPTCHA Site Key which is needed to display reCAPTCHA code" +COM_PHOCACART_FIELD_RECAPTCHA_PRIVATEKEY_LABEL="reCAPTCHA Private Key" +COM_PHOCACART_FIELD_RECAPTCHA_PRIVATEKEY_DESC="Set reCAPTCHA Private Key which is needed to communicate reCAPTCHA server" +COM_PHOCACART_SECURITY_OPTIONS_LABEL="Security Options" +COM_PHOCACART_WRONG_CAPTCHA="The Captcha code you have entered is wrong. Please, try it again" +COM_PHOCACART_FIELD_ENABLE_ASK_QUESTION_LABEL="Enable Ask Question" +COM_PHOCACART_FIELD_ENABLE_ASK_QUESTION_DESC="Enable or disable Ask Question/Feedback/Report function. If Ask Question/Feedback/Report is not used on your site, disable this parameter (because of possible spam attempts)" +COM_PHOCACART_ASK_QUESTION_DISABLED="Ask Question function is disabled" +COM_PHOCACART_YES_ONLY_IF_ADD_TO_CART_NOT_DISPLAYED="Yes (Only if Add To Cart button is not displayed)" +COM_PHOCACART_PLEASE_PROVE_THAT_YOU_ARE_HUMAN="Please prove that you are human" +COM_PHOCACART_SECURITY_CHECK="Security Check" +COM_PHOCACART_FIELD_F_NAME_LABEL="Name" +COM_PHOCACART_FIELD_F_NAME_DESC="Please fill in your name" +COM_PHOCACART_FIELD_F_EMAIL_LABEL="Email" +COM_PHOCACART_FIELD_F_EMAIL_DESC="Please fill in your email address" +COM_PHOCACART_FIELD_F_PHONE_LABEL="Phone" +COM_PHOCACART_FIELD_F_PHONE_DESC="Please fill in your phone" +COM_PHOCACART_FIELD_F_MOBILE_PHONE_LABEL="Mobile Phone" +COM_PHOCACART_FIELD_F_MOBILE_PHONE_DESC="Please fill in your mobile phone" +COM_PHOCACART_FIELD_F_MESSAGE_LABEL="Message" +COM_PHOCACART_FIELD_F_MESSAGE_DESC="Please fill in the message" +COM_PHOCACART_NO_ERROR="No (Error)" +COM_PHOCACART_CHART="Chart" +COM_PHOCACART_TOP_5="Top 5" +COM_PHOCACART_ALL_PRODUCTS="All products" +COM_PHOCACART_CATEGORY_VIEW="Category View" +COM_PHOCACART_FIELD_MIN_MULTIPLE_ORDER_QUANTITY_DESC="Set minimum multiple of ordered quantity of the current product. For example: If you set 6, then customers will be able to order 6 or 12 or 18, etc. products but not e.g. 15." +COM_PHOCACART_FIELD_MIN_MULTIPLE_ORDER_QUANTITY_LABEL="Minimum Multiple Order Quantity" +COM_PHOCACART_MINIMUM_MULTIPLE_ORDER_QUANTITY="Minumum multiple order quantity" +COM_PHOCACART_MINIMUM_MULTIPLE_ORDER_QUANTITY_FOR_PRODUCT="Minimum multiple of order quantity for product" +COM_PHOCACART_MINIMUM_MULTIPLE_ORDER_QUANTITY_OF_ONE_OR_MORE_PRODUCTS_NOT_MET_UPDATE_QUANTITY_BEFORE_ORDERING="Requirement of minimum multiple of ordered quantity of one or more products not met. Please update the quantity before finishing the order." +COM_PHOCACART_FIELD_ZERO_PRICE_TEXT_LABEL="Zero Price Text" +COM_PHOCACART_FIELD_ZERO_PRICE_TEXT_DESC="Set text which will be displayed instead of zero (0) in case the price is zero (0)" +COM_PHOCACART_FIELD_ZERO_PRICE_LABEL_LABEL="Zero Price Label" +COM_PHOCACART_FIELD_ZERO_PRICE_LABEL_DESC="Set text which will be displayed instead of price label in case the price is zero (0). If empty (no text set) then standard text 'Price' will be displayed. If '0' is set then no label will be displayed. If some text is set then this text will be displayed as price label. See documentation for examples." +COM_PHOCACART_ERROR_NO_ITEMS_SELECTED="Error - no items selected" +COM_PHOCACART_ERROR_LOADFILE_FAILED="Error loading form file" +COM_PHOCACART_ERROR_FILE_NOT_FOUND="File not found" +COM_PHOCACART_ERROR_ALERTNOAUTHOR="You are not authorised to view this resource." +COM_PHOCACART_PDF="PDF" +COM_PHOCACART_INVOICE_NR="Invoice Nr." +COM_PHOCACART_FIELD_EMAIL_ATTACHMENT_LABEL="Email Attachment" +COM_PHOCACART_FIELD_EMAIL_ATTACHMENT_TYPE_LABEL="Email Attachment Type" +COM_PHOCACART_FIELD_EMAIL_ATTACHMENT_TYPE_DESC="Set which type of document format will be sent as email attachment. in case document attachment ((Purchase Order, Invoice/Receipt, Delivery Note) is selected when sending email." +COM_PHOCACART_HTML="HTML" +COM_PHOCACART_PDF="PDF" +COM_PHOCACART_BOTH="Both" +COM_PHOCACART_CATALOG_OPTIONS_LABEL="Catalog Options" +COM_PHOCACART_FIELD_HIDE_PRICES_LABEL="Hide Product Prices" +COM_PHOCACART_FIELD_HIDE_PRICES_DESC="Display or hide product prices" +COM_PHOCACART_FIELD_HIDE_ADD_TO_CART_LABEL="Hide Add To Cart Button" +COM_PHOCACART_FIELD_HIDE_ADD_TO_CART_DESC="Display or hide Add To Cart button. With this parameter you can hide all the Add To Cart buttons in component. To hide the button for selected view only, see Display tab in Options." +COM_PHOCACART_FIELD_HIDE_ATTRIBUTES_LABEL="Hide Product Attributes" +COM_PHOCACART_FIELD_HIDE_ATTRIBUTES_DESC="Display or hide product attributes" +COM_PHOCACART_FIELD_DISPLAY_VIEW_CATEGORY_BUTTON_LABEL="Display View Category Button" +COM_PHOCACART_FIELD_DISPLAY_VIEW_CATEGORY_BUTTON_DESC="Display or hide View Category button" +COM_PHOCACART_CATEGORY_AND_ITEMS_VIEW_LABEL="Category and Items View (Products View)" +COM_PHOCACART_FIELD_CATEGORY_NAME_AS_LINK_LABEL="Category Name As Link" +COM_PHOCACART_FIELD_CATEGORY_NAME_AS_LINK_DESC="Display category name as link to category view" +COM_PHOCACART_FIELD_DISPLAY_VIEW_PRODUCT_BUTTON_LABEL="Display View Product Button" +COM_PHOCACART_FIELD_DISPLAY_VIEW_PRODUCT_BUTTON_DESC="Display or hide View Product button" +COM_PHOCACART_FIELD_PRODUCT_NAME_AS_LINK_LABEL="Product Name As Link" +COM_PHOCACART_FIELD_PRODUCT_NAME_AS_LINK_DESC="Display product name as link to product view" +COM_PHOCACART_YES_ICON_ONLY="Yes (Icon Only)" +COM_PHOCACART_YES_STANDARD_ICON_ONLY="Yes (Standard - Icon Only)" +COM_PHOCACART_FORM_SELECT_COLOR="Select Color" +COM_PHOCACART_COLOR="Color" +COM_PHOCACART_ATTR_TYPE_COLOR="Color" +COM_PHOCACART_IMAGES="Images" +COM_PHOCACART_LARGE_IMAGE="Large Image" +COM_PHOCACART_SMALL_IMAGE="Small Image" +COM_PHOCACART_LARGE="Large" +COM_PHOCACART_SMALL="Small" +COM_PHOCACART_ATTR_TYPE_IMAGE="Image" +COM_PHOCACART_FIELD_CROP_THUMBNAIL_DESC="Set which thumbnails should be cropped" +COM_PHOCACART_FIELD_CROP_THUMBNAIL_LABEL="Crop Thumbnails" +COM_PHOCACART_ONLY_LARGE_THUMBNAIL="Only large thumbnails" +COM_PHOCACART_ONLY_MEDIUM_THUMBNAIL="Only medium thumbnails" +COM_PHOCACART_ONLY_SMALL_THUMBNAIL="Only small thumbnails" +COM_PHOCACART_LARGE_AND_MEDIUM_THUMBNAIL="Large and medium thumbnails" +COM_PHOCACART_SMALL_AND_LARGE_THUMBNAIL="Small and large thumbnails" +COM_PHOCACART_MEDIUM_AND_SMALL_THUMBNAIL="Medium and small thumbnails" +COM_PHOCACART_NONE="None" +COM_PHOCACART_QUESTIONS="Questions" +COM_PHOCACART_EMAIL="Email" +COM_PHOCACART_ASK_QUESTION_FEEDBACK_REPORT_OPTIONS_LABEL="Ask Question/Feedback/Report Options" +COM_PHOCACART_FIELD_ASK_QUESTION_DESCRIPTION_LABEL="Ask Question Description" +COM_PHOCACART_FIELD_ASK_QUESTION_DESCRIPTION_DESC="Set description for Ask Question form" ;[3.0.0 RC2] COM_PHOCACART_FOR_THE_WHOLE_PERIOD="for the whole period" @@ -199,12 +371,12 @@ COM_PHOCACART_BUY_NOW="Buy Now" COM_PHOCACART_YES_BUY_NOW_PADDLE="Yes - Buy Now (Paddle)" COM_PHOCACART_YES_STANDARD="Yes (Standard)" COM_PHOCACART_FIELD_ADD_TO_CART_ITEMS_VIEW_LABEL="Add To Cart (Items View)" -COM_PHOCACART_FIELD_ADD_TO_CART_ITEMS_VIEW_DESC="Display or hide Add To Cart button in Items View. If displayed, set which type of button will be displayed." +COM_PHOCACART_FIELD_ADD_TO_CART_ITEMS_VIEW_DESC="Display or hide Add To Cart button in Items View (Products View). If displayed, set which type of button will be displayed." COM_PHOCACART_FIELD_ADD_TO_CART_ITEM_VIEW_LABEL="Add To Cart (Item View)" COM_PHOCACART_FIELD_ADD_TO_CART_ITEM_VIEW_DESC="Display or hide Add To Cart button in Item View. If displayed, set which type of button will be displayed." COM_PHOCACART_FIELD_ADD_TO_CART_CATEGORY_VIEW_LABEL="Add To Cart (Category View)" COM_PHOCACART_FIELD_ADD_TO_CART_CATEGORY_VIEW_DESC="Display or hide Add To Cart button in Category View. If displayed, set which type of button will be displayed." -COM_PHOCACART_ITEMS_VIEW_LABEL="Items View" +COM_PHOCACART_ITEMS_VIEW_LABEL="Items View (Products View)" COM_PHOCACART_SEARCH_ALL_PRODUCTS="All products" COM_PHOCACART_SEARCH_FILTERED_PRODUCTS="Filtered products" COM_PHOCACART_SEARCH="Search" diff --git a/language/en-GB/en-GB.com_phocacart.sys.ini b/language/en-GB/en-GB.com_phocacart.sys.ini index 364d7038..9b73fc3e 100644 --- a/language/en-GB/en-GB.com_phocacart.sys.ini +++ b/language/en-GB/en-GB.com_phocacart.sys.ini @@ -10,22 +10,30 @@ ; - +;[3.0.0 RC3] +COM_PHOCACART_ASK_QUESTION_LAYOUT="Ask Question (Feedback, Report) View" +COM_PHOCACART_ASK_QUESTION_LAYOUT_DESC="This view displays Ask Question (Feedback, Report) form" +COM_PHOCACART_TERMS_LAYOUT="Terms And Conditions View" +COM_PHOCACART_TERMS_LAYOUT_DESC="This view displays Terms And Conditions" +COM_PHOCACART_QUESTIONS="Questions" +COM_PHOCACART_WISH_LISTS="Wish Lists" +COM_PHOCACART_WISH_LIST_LAYOUT="Wish List View" +COM_PHOCACART_WISH_LIST_LAYOUT_DESC="This view displays Wish List View" ;[3.0.0 RC] COM_PHOCACART_XML_FEEDS="XML Feeds" -COM_PHOCACART_XML_FEED_LAYOUT="XML Feed Layout" +COM_PHOCACART_XML_FEED_LAYOUT="XML Feed View" COM_PHOCACART_XML_FEED_LAYOUT_DESC="This view displays XML feed" ;[3.0.0 Beta2] -COM_PHOCACART_ITEM_LIST_LAYOUT="Product List Layout" -COM_PHOCACART_ITEM_LIST_LAYOUT_DESC="This view displays list of products" +COM_PHOCACART_ITEM_LIST_LAYOUT="Products View (Product list layout)" +COM_PHOCACART_ITEM_LIST_LAYOUT_DESC="This view displays list of products (items) in Products View" ;[3.0.0 Beta1] COM_PHOCACART_STATISTICS="Statistics" COM_PHOCACART_SYSTEM_LOG="System Log" -COM_PHOCACART_CATEGORY_LIST_LAYOUT="Category List Layout" -COM_PHOCACART_CATEGORY_LIST_LAYOUT_DESC="This view displays list of products" -COM_PHOCACART_ITEM_LAYOUT="Product Layout" -COM_PHOCACART_ITEM_LAYOUT_DESC="This view displays product view" +COM_PHOCACART_CATEGORY_LAYOUT="Category View (Product list layout)" +COM_PHOCACART_CATEGORY_LAYOUT_DESC="This view displays list of products (items) in Category View" +COM_PHOCACART_ITEM_LAYOUT="Product View (Product layout)" +COM_PHOCACART_ITEM_LAYOUT_DESC="This view displays Product View - product details" ;[3.0.0 Alpha2] COM_PHOCACART_PAYMENT="Payment" @@ -34,7 +42,7 @@ COM_PHOCACART_UPDATE_TEXT="Phoca Cart Updated" COM_PHOCACART_VERSION="Version" PHOCACART="Phoca Cart" COM_PHOCACART="Phoca Cart" -COM_PHOCACART_XML_DESCRIPTION="Phoca Cart is a Joomla! component. Eshop for Joomla! CMS." +COM_PHOCACART_XML_DESCRIPTION="Phoca Cart is a Joomla! component. E-commerce solution for Joomla! CMS." COM_PHOCACART_UPGRADE="Upgrade" COM_PHOCACART_INSTALL="Install" COM_PHOCACART_CONTROLPANEL="Control Panel" @@ -58,8 +66,8 @@ COM_PHOCACART_DOWNLOADS="Downloads" COM_PHOCACART_TAGS="Tags" COM_PHOCACART_INFO="Info" -COM_PHOCACART_CATEGORIES_LIST_LAYOUT="Categories List Layout" -COM_PHOCACART_CATEGORIES_LIST_LAYOUT_DESC="This view displays list of categories" +COM_PHOCACART_CATEGORIES_LAYOUT="Categories View (Category list layout - default view)" +COM_PHOCACART_CATEGORIES_LAYOUT_DESC="This view displays list of categories" COM_PHOCACART_ORDERS_LAYOUT="Orders Layout" COM_PHOCACART_ORDERS_LAYOUT_DESC="This view displays list of user's orders" COM_PHOCACART_COMPARISON_LAYOUT="Comparison Layout" diff --git a/libraries/loader.php b/libraries/loader.php index 8a23fdba..dce805ad 100644 --- a/libraries/loader.php +++ b/libraries/loader.php @@ -22,7 +22,7 @@ public static function import($filePath, $base = null, $key = 'libraries.') { if (!isset($paths[$keyPath])) { if ( !$base ) { - $base = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocacart'.DS.'libraries'; + $base = JPATH_ADMINISTRATOR.'/components/com_phocacart/libraries'; } $parts = explode( '.', $filePath ); @@ -40,18 +40,18 @@ public static function import($filePath, $base = null, $key = 'libraries.') { break; } - $path = str_replace( '.', DS, $filePath ); + $path = str_replace( '.', '/', $filePath ); if (strpos($filePath, 'phocacart') === 0) { $className = 'PhocaCart'.$className; - $classes = JLoader::register($className, $base.DS.$path.'.php'); + $classes = JLoader::register($className, $base.'/'.$path.'.php'); $rs = isset($classes[strtolower($className)]); } else { // If it is not in the joomla namespace then we have no idea if // it uses our pattern for class names/files so just include // if the file exists or set it to false if not - $filename = $base.DS.$path.'.php'; + $filename = $base.'/'.$path.'.php'; if (is_file($filename)) { $rs = (bool) include $filename; } else { diff --git a/libraries/phocacart/attribute/attribute.php b/libraries/phocacart/attribute/attribute.php index 34592963..af63d1d1 100644 --- a/libraries/phocacart/attribute/attribute.php +++ b/libraries/phocacart/attribute/attribute.php @@ -32,7 +32,7 @@ public static function getOptionsById($attributeId, $returnArray = 0) { $db =JFactory::getDBO(); - $query = 'SELECT a.id, a.title, a.alias, a.amount, a.operator, a.stock, a.operator_weight, a.weight, a.image'; + $query = 'SELECT a.id, a.title, a.alias, a.amount, a.operator, a.stock, a.operator_weight, a.weight, a.image, a.image_small, a.color'; $query .= ' FROM #__phocacart_attribute_values AS a' .' WHERE a.attribute_id = '.(int) $attributeId .' ORDER BY a.id'; @@ -47,7 +47,11 @@ public static function getOptionsById($attributeId, $returnArray = 0) { } public static function getTypeArray() { - $o = array('1' => JText::_('COM_PHOCACART_ATTR_TYPE_SELECT')); + $o = array( + '1' => JText::_('COM_PHOCACART_ATTR_TYPE_SELECT'), + '2' => JText::_('COM_PHOCACART_ATTR_TYPE_COLOR'), + '3' => JText::_('COM_PHOCACART_ATTR_TYPE_IMAGE'), + ); return $o; } @@ -123,12 +127,12 @@ public static function storeAttributesById($productId, $attributesArray) { } $v2['alias'] = PhocaCartUtils::getAliasName($v2['alias']); - $options[] = '('.(int)$newId.', '.$db->quote($v2['title']).', '.$db->quote($v2['alias']).', '.$db->quote($v2['operator']).', '.$db->quote($v2['amount']).', '.(int)$v2['stock'].', '.$db->quote($v2['operator_weight']).', '.$db->quote($v2['weight']).', '.$db->quote($v2['image']).')'; + $options[] = '('.(int)$newId.', '.$db->quote($v2['title']).', '.$db->quote($v2['alias']).', '.$db->quote($v2['operator']).', '.$db->quote($v2['amount']).', '.(int)$v2['stock'].', '.$db->quote($v2['operator_weight']).', '.$db->quote($v2['weight']).', '.$db->quote($v2['image']).', '.$db->quote($v2['image_small']).', '.$db->quote($v2['color']).')'; if (!empty($options)) { $valuesString2 = implode($options, ','); } } - $query = ' INSERT INTO #__phocacart_attribute_values (attribute_id, title, alias, operator, amount, stock, operator_weight, weight, image)' + $query = ' INSERT INTO #__phocacart_attribute_values (attribute_id, title, alias, operator, amount, stock, operator_weight, weight, image, image_small, color)' .' VALUES '.(string)$valuesString2; $db->setQuery($query); @@ -161,7 +165,7 @@ public static function getAllAttributesAndOptions() { $db = JFactory::getDBO(); - $query = 'SELECT v.id, v.title, v.alias, at.id AS attrid, at.title AS attrtitle, at.alias AS attralias' + $query = 'SELECT v.id, v.title, v.alias, v.image, v.image_small, v.color, at.id AS attrid, at.title AS attrtitle, at.alias AS attralias, at.type as attrtype' .' FROM #__phocacart_attribute_values AS v' .' LEFT JOIN #__phocacart_attributes AS at ON at.id = v.attribute_id' .' GROUP BY v.alias, attralias' @@ -178,13 +182,17 @@ public static function getAllAttributesAndOptions() { $a[$v->attralias]['title'] = $v->attrtitle; $a[$v->attralias]['id'] = $v->attrid; $a[$v->attralias]['alias'] = $v->attralias; + $a[$v->attralias]['type'] = $v->attrtype; if (isset($v->title) && $v->title != '' && isset($v->id) && $v->id != '' && isset($v->alias) && $v->alias != '') { $a[$v->attralias]['option'][$v->alias] = new stdClass(); - $a[$v->attralias]['option'][$v->alias]->title = $v->title; - $a[$v->attralias]['option'][$v->alias]->id = $v->id; - $a[$v->attralias]['option'][$v->alias]->alias = $v->alias; + $a[$v->attralias]['option'][$v->alias]->title = $v->title; + $a[$v->attralias]['option'][$v->alias]->id = $v->id; + $a[$v->attralias]['option'][$v->alias]->alias = $v->alias; + $a[$v->attralias]['option'][$v->alias]->image = $v->image; + $a[$v->attralias]['option'][$v->alias]->image_small = $v->image_small; + $a[$v->attralias]['option'][$v->alias]->color = $v->color; } else { $a[$v->attralias]['option'] = array(); } @@ -198,7 +206,7 @@ public static function getAllAttributesAndOptions() { public static function getAttributeValue($id, $attributeId) { $db =JFactory::getDBO(); - $query = ' SELECT a.id, a.title, a.alias, a.amount, a.operator, a.weight, a.operator_weight, a.stock, a.image,' + $query = ' SELECT a.id, a.title, a.alias, a.amount, a.operator, a.weight, a.operator_weight, a.stock, a.image, a.image_small, a.color,' .' aa.id as aid, aa.title as atitle' .' FROM #__phocacart_attribute_values AS a' .' LEFT JOIN #__phocacart_attributes AS aa ON a.attribute_id = aa.id' diff --git a/libraries/phocacart/captcha/index.html b/libraries/phocacart/captcha/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/libraries/phocacart/captcha/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/phocacart/captcha/recaptcha.php b/libraries/phocacart/captcha/recaptcha.php new file mode 100644 index 00000000..0907d06e --- /dev/null +++ b/libraries/phocacart/captcha/recaptcha.php @@ -0,0 +1,58 @@ +get( 'recaptcha_sitekey', '' ))); + + $document->addScript('https://www.google.com/recaptcha/api.js'); + return '
'; + } + public static function isValid() { + + $app = JFactory::getApplication(); + $pC = JComponentHelper::getParams('com_phocacart') ; + $secretKey = strip_tags(trim($pC->get( 'recaptcha_privatekey', '' ))); + //$response = $app->input->post->get('g-recaptcha-response', '', 'string'); + //$response = $_POST['g-recaptcha-response']; + $response = $app->input->post->get('g-recaptcha-response', '', 'string'); + $remoteIp = $_SERVER['REMOTE_ADDR']; + + try { + + $url = 'https://www.google.com/recaptcha/api/siteverify'; + $data = ['secret' => $secretKey, + 'response' => $response, + 'remoteip' => $remoteIp]; + + $options = [ + 'http' => [ + 'header' => "Content-type: application/x-www-form-urlencoded\r\n", + 'method' => 'POST', + 'content' => http_build_query($data) + ] + ]; + + $context = stream_context_create($options); + $result = file_get_contents($url, false, $context); + + //$resultString = print_r($result, true); + //PhocaCartLog::add(1, 'Ask a Question - Captcha Result', 0, $resultString); + return json_decode($result)->success; + } + catch (Exception $e) { + return null; + } + } +} +?> diff --git a/libraries/phocacart/cart/cart.php b/libraries/phocacart/cart/cart.php index 92ba4e80..68ddbc6d 100644 --- a/libraries/phocacart/cart/cart.php +++ b/libraries/phocacart/cart/cart.php @@ -32,6 +32,7 @@ class PhocaCartCart protected $couponvalid = 0;// is the coupon valid - all three tests - basic, advanced, total protected $stockvalid = 1;// check stock - products, attributes (no matter if stock checking is disabled or enabled) protected $minqtyvalid = 1;// check minimum order quantity + protected $minmltpqtyvalid = 1;// check minimum multiple order quantity public function __construct() { $session = JFactory::getSession(); @@ -322,14 +323,15 @@ public function setFullItems() { $this->fullitems[$k]['stock'] = 0; // database value set in product settings $this->fullitems[$k]['stockvalid'] = 1; // variable to inform if stock validity is ok $this->fullitems[$k]['minqty'] = 0; // database value set in product settings + $this->fullitems[$k]['minmltpqty'] = 0; $this->fullitems[$k]['minqtyvalid'] = 1; // varible to inform if minimum order is ok + $this->fullitems[$k]['minmltpqtyvalid'] = 1; // Group $this->fullitemsgroup[$itemId]['id'] = (int)$itemId; $this->fullitemsgroup[$itemId]['title'] = ''; - $attribs = array(); if (!empty($item[1])) { $attribs = unserialize(base64_decode($item[1])); @@ -363,10 +365,12 @@ public function setFullItems() { $this->fullitems[$k]['volume'] = $item2->volume; $this->fullitems[$k]['stock'] = $item2->stock; $this->fullitems[$k]['minqty'] = $item2->min_quantity; + $this->fullitems[$k]['minmltpqty'] = $item2->min_multiple_quantity; // Group - $this->fullitemsgroup[$itemId]['minqty'] = $item2->min_quantity; - $this->fullitemsgroup[$itemId]['title'] = $item2->title; + $this->fullitemsgroup[$itemId]['minqty'] = $item2->min_quantity; + $this->fullitemsgroup[$itemId]['minmltpqty'] = $item2->min_multiple_quantity; + $this->fullitemsgroup[$itemId]['title'] = $item2->title; //$this->fullitems[$k]['netto'] *= $fQ; $this->total['netto'] += ($this->fullitems[$k]['netto'] * $fQ); @@ -395,9 +399,10 @@ public function setFullItems() { $taxSuffix = ''; if ($item2->taxcalctype == 1) { - $taxSuffix = ' ('.$item2->taxrate.'%)'; + $taxSuffix = ' ('.($price->getTaxFormat($item2->taxrate, $item2->taxcalctype, 0)).')'; } - $this->total['tax'][$item2->taxid]['title'] = $item2->taxtitle . $taxSuffix ; + + $this->total['tax'][$item2->taxid]['title'] = $item2->taxtitle . $taxSuffix; $this->total['tax'][$item2->taxid]['type'] = $item2->taxcalctype; $this->total['tax'][$item2->taxid]['rate'] = $item2->taxrate; @@ -588,7 +593,7 @@ public function setFullItems() { } } - + // Last place to influence $k // STOCK VALID CHECK @@ -623,7 +628,15 @@ public function setFullItems() { $this->fullitemsgroup[$itemId]['minqtyvalid'] = 1; } - if (((int)$this->fullitemsgroup[$itemId]['quantity']) < (int)$this->fullitemsgroup[$itemId]['minqty']) { + if (!isset($this->fullitemsgroup[$itemId]['minmltpqtyvalid'])) { + $this->fullitemsgroup[$itemId]['minmltpqtyvalid'] = 1; + } + + if (empty($this->fullitemsgroup[$itemId]['minqty'])) { + $this->minqtyvalid = 1; + $this->fullitemsgroup[$itemId]['minqtyvalid'] = 1; + + } else if ((int)$this->fullitemsgroup[$itemId]['quantity'] < (int)$this->fullitemsgroup[$itemId]['minqty']) { $this->minqtyvalid = 0; $this->fullitemsgroup[$itemId]['minqtyvalid'] = 0; } else { @@ -632,6 +645,23 @@ public function setFullItems() { $this->fullitemsgroup[$itemId]['minqtyvalid'] = 1; } + if (empty($this->fullitemsgroup[$itemId]['minmltpqty'])) { + $this->minmltpqtyvalid = 1; + $this->fullitemsgroup[$itemId]['minmltpqtyvalid'] = 1; + } else if ($this->fullitemsgroup[$itemId]['minmltpqty'] == 0) { + // Do not modulo by zere + // Set it back because we are in foreach + $this->minmltpqtyvalid = 1; + $this->fullitemsgroup[$itemId]['minmltpqtyvalid'] = 1; + } else if (((int)$this->fullitemsgroup[$itemId]['quantity']) % (int)$this->fullitemsgroup[$itemId]['minmltpqty'] != 0) { + $this->minmltpqtyvalid = 0; + $this->fullitemsgroup[$itemId]['minmltpqtyvalid'] = 0; + } else { + // Set it back because we are in foreach + $this->minmltpqtyvalid = 1; + $this->fullitemsgroup[$itemId]['minmltpqtyvalid'] = 1; + } + } // COUPON total check @@ -815,6 +845,10 @@ public function getMinimumQuantityValid() { return $this->minqtyvalid; } + public function getMinimumMultipleQuantityValid() { + return $this->minmltpqtyvalid; + } + public function addShippingCosts($shippingId = 0) { if ($shippingId == 0) { diff --git a/libraries/phocacart/cart/cartdb.php b/libraries/phocacart/cart/cartdb.php index 6284d8c5..695a0681 100644 --- a/libraries/phocacart/cart/cartdb.php +++ b/libraries/phocacart/cart/cartdb.php @@ -60,7 +60,7 @@ public static function emptyCartDb($userId) { } public final function __clone() { - JError::raiseWarning(500, 'Function Error: Cannot clone instance of Singleton pattern');// No JText - for developers only + throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500); return false; } } diff --git a/libraries/phocacart/cart/rendercart.php b/libraries/phocacart/cart/rendercart.php index 01420aec..e7328393 100644 --- a/libraries/phocacart/cart/rendercart.php +++ b/libraries/phocacart/cart/rendercart.php @@ -28,7 +28,7 @@ public function render() { $this->fullitems = $this->getFullItems();// get them from parent } - + if (!empty($this->fullitems)) { $o[] = ''; /*echo ''; diff --git a/libraries/phocacart/cart/rendercheckout.php b/libraries/phocacart/cart/rendercheckout.php index 5daba61a..4fb161ff 100644 --- a/libraries/phocacart/cart/rendercheckout.php +++ b/libraries/phocacart/cart/rendercheckout.php @@ -45,6 +45,11 @@ public function render() { $o[] = '
'.JText::_('COM_PHOCACART_MINIMUM_ORDER_QUANTITY_FOR_PRODUCT'). ' '.$v['title']. ' '.JText::_('COM_PHOCACART_IS').': '.$v['minqty'].'
'; } + + if (isset($v['minmltpqtyvalid']) && $v['minmltpqtyvalid'] == 0) { + $o[] = '
'.JText::_('COM_PHOCACART_MINIMUM_MULTIPLE_ORDER_QUANTITY_FOR_PRODUCT'). ' '.$v['title']. ' '.JText::_('COM_PHOCACART_IS').': '.$v['minmltpqty'].'
'; + + } } } @@ -75,6 +80,7 @@ public function render() { $o[] = ''; + foreach($this->fullitems as $k => $v) { $link = PhocaCartRoute::getItemRoute((int)$v['id'], (int)$v['catid'], $v['alias']); @@ -120,9 +126,9 @@ public function render() { $o[] = ''; $o[] = ''; //UPDATE - $o[] = ' '; + $o[] = ' '; //DELETE - $o[] = ' '; + $o[] = ' '; $o[] = JHtml::_('form.token'); $o[] = ''; $o[] = ''; diff --git a/libraries/phocacart/category/category.php b/libraries/phocacart/category/category.php index 4029e334..7a011e48 100644 --- a/libraries/phocacart/category/category.php +++ b/libraries/phocacart/category/category.php @@ -341,7 +341,7 @@ public static function getActiveCategoryId() { public final function __clone() { - JError::raiseWarning(500, 'Function Error: Cannot clone instance of Singleton pattern');// No JText - for developers only + throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500); return false; } } diff --git a/libraries/phocacart/compare/compare.php b/libraries/phocacart/compare/compare.php index 8a09b88f..1c6fe68f 100644 --- a/libraries/phocacart/compare/compare.php +++ b/libraries/phocacart/compare/compare.php @@ -95,7 +95,7 @@ public function getQueryList($items, $full = 0){ ' SELECT a.id as id, a.title as title, a.alias as alias, a.description, a.price, a.image,' .' c.id as catid, c.alias as catalias, c.title as cattitle, count(pc.category_id) AS count_categories,' .' a.length, a.width, a.height, a.weight, a.volume,' - .' a.stock, a.min_quantity, a.stockstatus_a_id, a.stockstatus_n_id, a.availability,' + .' a.stock, a.min_quantity, a.min_multiple_quantity, a.stockstatus_a_id, a.stockstatus_n_id, a.availability,' .' m.title as manufacturer_title' .' FROM #__phocacart_products AS a' .' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = a.id' diff --git a/libraries/phocacart/currency/currency.php b/libraries/phocacart/currency/currency.php index 9ec7add6..063cc033 100644 --- a/libraries/phocacart/currency/currency.php +++ b/libraries/phocacart/currency/currency.php @@ -179,7 +179,7 @@ public static function getCurrenciesListBox() { public final function __clone() { - JError::raiseWarning(500, 'Function Error: Cannot clone instance of Singleton pattern');// No JText - for developers only + throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500); return false; } } diff --git a/libraries/phocacart/email/email.php b/libraries/phocacart/email/email.php index a94c7172..b9c6a168 100644 --- a/libraries/phocacart/email/email.php +++ b/libraries/phocacart/email/email.php @@ -8,11 +8,180 @@ */ defined('_JEXEC') or die(); +class PhocaCartEmailMail extends JMail{ + + + public static function getInstance($id = 'Joomla', $exceptions = true) + { + if (empty(self::$instances[$id])) + { + self::$instances[$id] = new PhocaCartEmailMail($exceptions); + } + + return self::$instances[$id]; + } + + // PHOCAEDIT + //public function sendMail($from, $fromName, $recipient, $subject, $body, $mode = false, $cc = null, $bcc = null, $attachment = null, + // $replyTo = null, $replyToName = null) + public function sendMailA($from, $fromName, $recipient, $subject, $body, $mode = false, $cc = null, $bcc = null, $attachmentString = '', $attachmentFileName = '', $replyTo = null, $replyToName = null) + { + + + $this->setSubject($subject); + $this->setBody($body); + + // Are we sending the email as HTML? + $this->isHtml($mode); + + /* + * Do not send the message if adding any of the below items fails + */ + + if ($this->addRecipient($recipient) === false) + { + return false; + } + + if ($this->addCc($cc) === false) + { + return false; + } + + if ($this->addBcc($bcc) === false) + { + return false; + } + + // PHOCAEDIT + if ($attachmentString != '' && $attachmentFileName != '') { + if ($this->addStringAttachment($attachmentString, $attachmentFileName) === false) + { + return false; + } + } + + // Take care of reply email addresses + if (is_array($replyTo)) + { + $numReplyTo = count($replyTo); + + for ($i = 0; $i < $numReplyTo; $i++) + { + if ($this->addReplyTo($replyTo[$i], $replyToName[$i]) === false) + { + return false; + } + } + } + elseif (isset($replyTo)) + { + if ($this->addReplyTo($replyTo, $replyToName) === false) + { + return false; + } + } + + // Add sender to replyTo only if no replyTo received + $autoReplyTo = (empty($this->ReplyTo)) ? true : false; + + if ($this->setSender(array($from, $fromName, $autoReplyTo)) === false) + { + return false; + } + + return $this->Send(); + } + +} + + + +class PhocaCartEmailFactory extends JFactory{ + + public static $mailer = null; + + public static function getMailer() + { + if (!self::$mailer) + { + self::$mailer = self::createMailer(); + } + + $copy = clone self::$mailer; + + return $copy; + } + + protected static function createMailer() + { + $conf = self::getConfig(); + + $smtpauth = ($conf->get('smtpauth') == 0) ? null : 1; + $smtpuser = $conf->get('smtpuser'); + $smtppass = $conf->get('smtppass'); + $smtphost = $conf->get('smtphost'); + $smtpsecure = $conf->get('smtpsecure'); + $smtpport = $conf->get('smtpport'); + $mailfrom = $conf->get('mailfrom'); + $fromname = $conf->get('fromname'); + $mailer = $conf->get('mailer'); + + // Create a JMail object + $mail = PhocaCartEmailMail::getInstance(); + + // Clean the email address + $mailfrom = JMailHelper::cleanLine($mailfrom); + + // Set default sender without Reply-to if the mailfrom is a valid address + if (JMailHelper::isEmailAddress($mailfrom)) + { + // Wrap in try/catch to catch phpmailerExceptions if it is throwing them + try + { + // Check for a false return value if exception throwing is disabled + if ($mail->setFrom($mailfrom, JMailHelper::cleanLine($fromname), false) === false) + { + PhocaCartLog::add(1, 'Error sending email', 0, __METHOD__ . '() could not set the sender data. Warning: ' . JLog::WARNING, 'Mail From: '.$mailfrom ); + JLog::add(__METHOD__ . '() could not set the sender data.', JLog::WARNING, 'mail'); + } + } + catch (phpmailerException $e) + { + PhocaCartLog::add(1, 'Error sending email', 0, __METHOD__ . '() could not set the sender data. Warning: ' . JLog::WARNING, 'Mail From: '.$mailfrom ); + JLog::add(__METHOD__ . '() could not set the sender data.', JLog::WARNING, 'mail'); + } + } + + // Default mailer is to use PHP's mail function + switch ($mailer) + { + case 'smtp': + $mail->useSmtp($smtpauth, $smtphost, $smtpuser, $smtppass, $smtpsecure, $smtpport); + break; + + case 'sendmail': + $mail->isSendmail(); + break; + + default: + $mail->isMail(); + break; + } + + return $mail; + } +} + + + class PhocaCartEmail { - public static function sendEmail($from = '', $fromName = '', $recipient, $subject, $body, $mode = false, $cc = null, $bcc = null, $attachment = null, $replyTo = null, $replyToName = null) { + public static function sendEmail($from = '', $fromName = '', $recipient, $subject, $body, $mode = false, $cc = array(), $bcc = array(), $attachmentString = '', $attachmentFilename = '', $replyTo = null, $replyToName = null) { + + //public static function sendEmail($from = '', $fromName = '', $recipient, $subject, $body, $mode = false, $cc = array(), $bcc = array(), $attachment = null, $replyTo = null, $replyToName = null) { $config = JFactory::getConfig(); @@ -23,7 +192,19 @@ public static function sendEmail($from = '', $fromName = '', $recipient, $subjec $fromName = $config->get('fromname'); } + if ($replyTo == '') { + $replyTo = $from; + } + if ($replyToName == '') { + $replyToName = $fromName; + } + if ($cc == '') { + $cc = array(); + } + if ($bcc == '') { + $bcc = array(); + } // Attachment /*if (!empty($tmpl['attachment'])) { $i = 0; @@ -38,13 +219,27 @@ public static function sendEmail($from = '', $fromName = '', $recipient, $subjec $i++; } }*/ + $subject = html_entity_decode($subject, ENT_QUOTES); + $body = html_entity_decode($body, ENT_QUOTES); - $subject = html_entity_decode($subject, ENT_QUOTES); - $body = html_entity_decode($body, ENT_QUOTES); + $mail = PhocaCartEmailFactory::getMailer(); + + + $body = $body . PhocaCartUtils::getInfo($mode); + + $sendMail = $mail->sendMailA($from, $fromName, $recipient, $subject, $body, $mode, $cc, $bcc, $attachmentString, $attachmentFilename, $replyTo, $replyToName); + + + if (isset($sendMail->message)) { + PhocaCartLog::add(1, 'Error sending email', 0, $sendMail->message . ', Mail From: '.$mailfrom ); + return false; + } else if ($sendMail == 1) { + return true; + } else { + PhocaCartLog::add(1, 'Error sending email', 0, 'No error data set, Mail From: '.$mailfrom ); + return false; + } - $mail = JFactory::getMailer(); - return $mail->sendMail($from, $fromName, $recipient, $subject, $body, $mode, $cc, $bcc, $attachment, - $replyTo, $replyToName); } public static function completeMail($body, $replace) { @@ -66,5 +261,74 @@ public static function completeMail($body, $replace) { return $body; } + + public static function sendQuestionMail ($id, $data, $url, $tmpl) { + + $app = JFactory::getApplication(); + $db = JFactory::getDBO(); + $sitename = $app->getCfg( 'sitename' ); + $paramsC = JComponentHelper::getParams('com_phocacart') ; + $numCharEmail = $paramsC->get( 'max_char_question_email', 1000 ); + + //get all selected users + $query = 'SELECT name, email, sendEmail' . + ' FROM #__users' . + ' WHERE id = '.(int)$id; + $db->setQuery( $query ); + $rows = $db->loadObjectList(); + + $subject = $sitename .' - '.JText::_( 'COM_PHOCACART_NEW_QUESTION' ); + if (isset($data['product']->title) && $data['product']->title != '') { + $subject .= ', '.JText::_('COM_PHOCACART_PRODUCT'). ': '. $data['product']->title; + } + if (isset($data['category']->title) && $data['category']->title != '') { + $subject .= ', '.JText::_('COM_PHOCACART_CATEGORY'). ': '. $data['category']->title; + } + + + + if (isset($data['name']) && $data['name'] != '') { + $fromname = $data['name']; + } else { + $fromname = 'Unknown'; + } + + if (isset($data['email']) && $data['email'] != '') { + $mailfrom = $data['email']; + } else { + $mailfrom = $rows[0]->email; + } + + if (isset($data['message']) && $data['message'] != '') { + $message = $data['message']; + } else { + $message = "..."; + } + + $email = $rows[0]->email; + + $message = str_replace("

", "\n", $message ); + $message = strip_tags($message); + + $message = JText::_( 'COM_PHOCACART_NEW_POST_ADDED' ) . "\n\n" + . JText::_( 'COM_PHOCACART_FROM' ) . ': '. $fromname . "\n" + . JText::_( 'COM_PHOCACART_DATE' ) . ': '. JHTML::_('date', gmdate('Y-m-d H:i:s'), JText::_( 'DATE_FORMAT_LC2' )) . "\n\n" + . JText::_( 'COM_PHOCACART_SUBJECT' ) . ': '.$subject."\n" + . JText::_( 'COM_PHOCACART_MESSAGE' ) . ': '."\n" + . "\n\n" + .PhocaCartUtils::wordDelete($message, $numCharEmail, '...')."\n\n" + . "\n\n" + //. JText::_( 'COM_PHOCACART_CLICK_LINK_READ_FULL_POST' ) ."\n" + . $url."\n\n" + . JText::_( 'COM_PHOCACART_REGARDS' ) .", \n" + . $sitename ."\n"; + + $subject = html_entity_decode($subject, ENT_QUOTES); + $message = html_entity_decode($message, ENT_QUOTES); + + $notify = PhocaCartEmail::sendEmail($mailfrom, $fromname, $email, $subject, $message, false, null, null, '', '', $mailfrom, $fromname); + + return $notify; + } } ?> \ No newline at end of file diff --git a/libraries/phocacart/file/file.php b/libraries/phocacart/file/file.php index 7d52c254..1d48830f 100644 --- a/libraries/phocacart/file/file.php +++ b/libraries/phocacart/file/file.php @@ -40,7 +40,7 @@ public static function getFileSizeReadable ($size, $retstring = null, $onlyMB = public static function getFileSize($manager, $filename, $readable = 1) { $path = PhocaCartPath::getPath($manager); - $fileNameAbs = JPath::clean($path['orig_abs'] . DS . $filename); + $fileNameAbs = JPath::clean($path['orig_abs'] . '/' . $filename); if ($readable == 1) { return self::getFileSizeReadable(filesize($fileNameAbs)); @@ -52,7 +52,7 @@ public static function getFileSize($manager, $filename, $readable = 1) { public static function getFileTime($manager, $filename, $function, $format = "d. M Y") { $path = PhocaDownloadPath::getPath($manager); - $fileNameAbs = JPath::clean($path['orig_abs'] . DS . $filename); + $fileNameAbs = JPath::clean($path['orig_abs'] . '/' . $filename); if (JFile::exists($fileNameAbs)) { switch($function) { case 2: @@ -99,7 +99,6 @@ public static function getMimeType($extension, $params) { preg_match($regex_one,$phocaDownload,$phocaDownloadParts); $values_replace = array ("/^'/", "/'$/", "/^'/", "/'$/", "/
/"); $values = explode("=", $phocaDownloadParts[2], 2); - foreach ($values_replace as $key2 => $values2) { $values = preg_replace($values2, '', $values); } diff --git a/libraries/phocacart/file/filethumbnail.php b/libraries/phocacart/file/filethumbnail.php index c501948a..c2c6640b 100644 --- a/libraries/phocacart/file/filethumbnail.php +++ b/libraries/phocacart/file/filethumbnail.php @@ -27,20 +27,20 @@ public static function getThumbnailName($filename, $size, $manager) { switch ($size) { case 'large': $fileNameThumb = 'phoca_thumb_l_'. $title; - $thumbName->abs = JPath::clean(str_replace($title, 'thumbs'. DS . $fileNameThumb, $path['orig_abs_ds'] . $filename)); + $thumbName->abs = JPath::clean(str_replace($title, 'thumbs/' . $fileNameThumb, $path['orig_abs_ds'] . $filename)); $thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path['orig_rel_ds'] . $filename); break; case 'medium': $fileNameThumb = 'phoca_thumb_m_'. $title; - $thumbName->abs = JPath::clean(str_replace($title, 'thumbs'. DS . $fileNameThumb, $path['orig_abs_ds'] . $filename)); + $thumbName->abs = JPath::clean(str_replace($title, 'thumbs/' . $fileNameThumb, $path['orig_abs_ds'] . $filename)); $thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path['orig_rel_ds'] . $filename); break; default: case 'small': $fileNameThumb = 'phoca_thumb_s_'. $title; - $thumbName->abs = JPath::clean(str_replace($title, 'thumbs' . DS . $fileNameThumb, $path['orig_abs_ds'] . $filename)); + $thumbName->abs = JPath::clean(str_replace($title, 'thumbs/' . $fileNameThumb, $path['orig_abs_ds'] . $filename)); $thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path['orig_rel_ds'] . $filename); break; } @@ -98,20 +98,20 @@ public static function getOrCreateThumbnail($fileNo, $refreshUrl, $small = 0, $m //$additional_thumbnails = $paramsC->get( 'additional_thumbnails',0 ); $path = PhocaCartPath::getPath($manager); - $origPathServer = str_replace(DS, '/', $path['orig_abs_ds']); + $origPathServer = str_replace('\\', '/', $path['orig_abs_ds']); $file['name'] = PhocaCartFile::getTitleFromFilenameWithExt($fileNo); $file['name_no'] = ltrim($fileNo, '/'); $file['name_original_abs'] = PhocaCartFile::getFileOriginal($fileNo, 0, $manager); $file['name_original_rel'] = PhocaCartFile::getFileOriginal($fileNo, 1, $manager); $file['path_without_file_name_original']= str_replace($file['name'], '', $file['name_original_abs']); - $file['path_without_file_name_thumb'] = str_replace($file['name'], '', $file['name_original_abs'] . 'thumbs' . DS); - //$file['path_without_name'] = str_replace(DS, '/', JPath::clean($origPathServer)); + $file['path_without_file_name_thumb'] = str_replace($file['name'], '', $file['name_original_abs'] . 'thumbs' . '/'); + //$file['path_without_name'] = str_replace('\\', '/', JPath::clean($origPathServer)); //$file['path_with_name_relative_no'] = str_replace($origPathServer, '', $file['name_original']); /* $file['path_with_name_relative'] = $path['orig_rel_ds'] . str_replace($origPathServer, '', $file['name_original']); $file['path_with_name_relative_no'] = str_replace($origPathServer, '', $file['name_original']); - $file['path_without_name'] = str_replace(DS, '/', JPath::clean($origPath.DS)); + $file['path_without_name'] = str_replace('\\', '/', JPath::clean($origPath.'/')); $file['path_without_name_relative'] = $path['orig_rel_ds'] . str_replace($origPathServer, '', $file['path_without_name']); $file['path_without_name_relative_no'] = str_replace($origPathServer, '', $file['path_without_name']); $file['path_without_name_thumbs'] = $file['path_without_name'] .'thumbs'; @@ -301,7 +301,7 @@ public static function createThumbnailFolder($folderOriginal, $folderThumbnail, //JFolder::create($folderThumbnail, $folder_permissions ); if (isset($folderThumbnail)) { $data = "\n\n\n"; - JFile::write($folderThumbnail.DS."index.html", $data); + JFile::write($folderThumbnail."/index.html", $data); } // folder was not created if (!JFolder::exists($folderThumbnail)) { diff --git a/libraries/phocacart/file/fileupload.php b/libraries/phocacart/file/fileupload.php index bfde1e1c..e46d3bf4 100644 --- a/libraries/phocacart/file/fileupload.php +++ b/libraries/phocacart/file/fileupload.php @@ -32,7 +32,7 @@ public static function realMultipleUpload( $frontEnd = 0) { header("Pragma: no-cache"); // Invalid Token - JRequest::checkToken( 'request' ) or jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 100, + JSession::checkToken('request') or jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 100, 'message' => JText::_('COM_PHOCACART_ERROR').': ', 'details' => JTEXT::_('COM_PHOCACART_INVALID_TOKEN')))); @@ -40,11 +40,12 @@ public static function realMultipleUpload( $frontEnd = 0) { $ftp = JClientHelper::setCredentialsFromRequest('ftp'); - $file = JRequest::getVar( 'file', '', 'files', 'array' ); - $chunk = JRequest::getVar( 'chunk', 0, '', 'int' ); - $chunks = JRequest::getVar( 'chunks', 0, '', 'int' ); - $folder = JRequest::getVar( 'folder', '', '', 'path' ); - $manager = JRequest::getVar( 'manager', 'file', '', 'string' ); + //$file = JFactory::getApplication()->input->get( 'file', '', 'files', 'array' ); + $file = JFactory::getApplication()->input->files->get( 'file', null, 'raw'); + $chunk = JFactory::getApplication()->input->get( 'chunk', 0, '', 'int' ); + $chunks = JFactory::getApplication()->input->get( 'chunks', 0, '', 'int' ); + $folder = JFactory::getApplication()->input->get( 'folder', '', '', 'path' ); + $manager = JFactory::getApplication()->input->get( 'manager', 'file', '', 'string' ); $path = PhocaCartPath::getPath($manager);// we use viewback to get right path @@ -56,7 +57,7 @@ public static function realMultipleUpload( $frontEnd = 0) { $file['name'] = JFile::makeSafe($file['name']); } if (isset($folder) && $folder != '') { - $folder = $folder . DS; + $folder = $folder . '/'; } $chunkEnabled = 0; @@ -93,7 +94,7 @@ public static function realMultipleUpload( $frontEnd = 0) { // and we recognize there is one - ok don't upload it BUT the file will be damaged by // parts uploaded by the new file - so this is why we are using temp file in Chunk method $stream = JFactory::getStream();// Chunk Files - $tempFolder = 'pcpluploadtmpfolder'.DS; + $tempFolder = 'pcpluploadtmpfolder'.'/'; $filepathImgFinal = JPath::clean($path['orig_abs_ds'].$folder.strtolower($file['name'])); $filepathImgTemp = JPath::clean($path['orig_abs_ds'].$folder.$tempFolder.strtolower($file['name'])); $filepathFolderFinal = JPath::clean($path['orig_abs_ds'].$folder); @@ -301,6 +302,7 @@ public static function realMultipleUpload( $frontEnd = 0) { if(!JFile::upload($file['tmp_name'], $filepathImgFinal, false, true)) { + PhocaCartLog::add(1, 'Error uploading file - JFile upload Ajax', 0, 'File: '.$file['name'].', File Path: '.$filepathImgFinal ); jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 109, 'message' => JText::_('COM_PHOCACART_ERROR').': ', 'details' => JTEXT::_('COM_PHOCACART_ERROR_UNABLE_TO_UPLOAD_FILE') .'
' @@ -319,6 +321,7 @@ public static function realMultipleUpload( $frontEnd = 0) { } } else { // No isset $file['name'] + PhocaCartLog::add(1, 'Error uploading file - Filename does not exist', 0, 'File: File does not exist - Multiple Upload ' ); jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 104, 'message' => JText::_('COM_PHOCACART_ERROR').': ', @@ -337,22 +340,23 @@ public static function realSingleUpload( $frontEnd = 0 ) { $overwriteExistingFiles = $paramsC->get( 'overwrite_existing_files', 0 ); $app = JFactory::getApplication(); - JRequest::checkToken( 'request' ) or jexit( 'ERROR: '. JTEXT::_('COM_PHOCACART_INVALID_TOKEN')); + JSession::checkToken('request') or jexit( 'ERROR: '. JTEXT::_('COM_PHOCACART_INVALID_TOKEN')); JResponse::allowCache(false); - $file = JRequest::getVar( 'Filedata', '', 'files', 'array' ); - $folder = JRequest::getVar( 'folder', '', '', 'path' ); - $format = JRequest::getVar( 'format', 'html', '', 'cmd'); - $return = JRequest::getVar( 'return-url', null, 'post', 'base64' );//includes field - $viewBack = JRequest::getVar( 'viewback', '', '', '' ); - $manager = JRequest::getVar( 'manager', 'file', '', 'string' ); - $tab = JRequest::getVar( 'tab', '', '', 'string' ); - $field = JRequest::getVar( 'field' ); + $file = JFactory::getApplication()->input->files->get( 'Filedata', null, 'raw'); + //$file = JRequest::getVar( 'Filedata', '', 'files', 'array' ); + $folder = JFactory::getApplication()->input->get( 'folder', '', '', 'path' ); + $format = JFactory::getApplication()->input->get( 'format', 'html', '', 'cmd'); + $return = JFactory::getApplication()->input->get( 'return-url', null, 'post', 'base64' );//includes field + $viewBack = JFactory::getApplication()->input->get( 'viewback', '', '', '' ); + $manager = JFactory::getApplication()->input->get( 'manager', 'file', '', 'string' ); + $tab = JFactory::getApplication()->input->get( 'tab', '', '', 'string' ); + $field = JFactory::getApplication()->input->get( 'field' ); $errUploadMsg = ''; $folderUrl = $folder; $tabUrl = ''; - $component = JRequest::getVar( 'option', '', '', 'string' ); + $component = JFactory::getApplication()->input->get( 'option', '', '', 'string' ); $path = PhocaCartPath::getPath($manager);// we use viewback to get right path @@ -376,7 +380,7 @@ public static function realSingleUpload( $frontEnd = 0 ) { if (isset($folder) && $folder != '') { - $folder = $folder . DS; + $folder = $folder . '/'; } @@ -420,6 +424,8 @@ public static function realSingleUpload( $frontEnd = 0 ) { } if (!JFile::upload($file['tmp_name'], $filepath, false, true)) { + + PhocaCartLog::add(1, 'Error uploading file - JFile upload', 0, 'File: '.$file['name'].', File Path: '.$filepath ); if ($return) { $app->enqueueMessage( JText::_('COM_PHOCACART_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error'); $app->redirect(base64_decode($return).'&manager='.(string)$manager.'&folder='.$folderUrl); @@ -448,6 +454,7 @@ public static function realSingleUpload( $frontEnd = 0 ) { } } } else { + PhocaCartLog::add(1, 'Error uploading file - Filename does not exist', 0, 'File: File does not exist (Single Upload)' ); $msg = JText::_('COM_PHOCACART_ERROR_UNABLE_TO_UPLOAD_FILE'); if ($return) { $app->enqueueMessage($msg); diff --git a/libraries/phocacart/file/fileuploadmultiple.php b/libraries/phocacart/file/fileuploadmultiple.php index d20c9d57..abc67581 100644 --- a/libraries/phocacart/file/fileuploadmultiple.php +++ b/libraries/phocacart/file/fileuploadmultiple.php @@ -73,9 +73,7 @@ static public function renderMultipleUploadLibraries() { static public function getMultipleUploadSizeFormat($size) { $readableSize = PhocaCartFile::getFileSizeReadable($size, '%01.0f %s', 1); - $readableSize = str_replace(' ', '', $readableSize); - $readableSize = strtolower($readableSize); return $readableSize; } diff --git a/libraries/phocacart/filter/filter.php b/libraries/phocacart/filter/filter.php index 31fed793..d8b8cd5f 100644 --- a/libraries/phocacart/filter/filter.php +++ b/libraries/phocacart/filter/filter.php @@ -11,9 +11,15 @@ class PhocaCartFilter { public $taglist = false; + public $tag = false; public $manufacturer = false; public $price = false; public $attributes = false; + public $specifications = false; + + public $enable_color_filter = false; + public $enable_image_filter = false; + public $image_style_image_filter = false; public function __construct() {} @@ -26,6 +32,11 @@ public function renderList() { $layout = new JLayoutFile('form_filter_checkbox', $basePath = JPATH_ROOT .'/components/com_phocacart/layouts'); $layout2 = new JLayoutFile('form_filter_text', $basePath = JPATH_ROOT .'/components/com_phocacart/layouts'); $layout3 = new JLayoutFile('form_filter_checkbox_categories', $basePath = JPATH_ROOT .'/components/com_phocacart/layouts'); + $layout4 = new JLayoutFile('form_filter_color', $basePath = JPATH_ROOT .'/components/com_phocacart/layouts'); + $layout5 = new JLayoutFile('form_filter_image', $basePath = JPATH_ROOT .'/components/com_phocacart/layouts'); + + + $pathProductImage = PhocaCartPath::getPath('productimage'); // =FILTER= $data['getparams'] = array(); @@ -69,8 +80,6 @@ public function renderList() { } } - - // -PRICE- $data['param'] = 'price_from'; $data['param2'] = 'price_to'; @@ -127,6 +136,7 @@ public function renderList() { if ($this->attributes) { phocacartimport('phocacart.attribute.attribute'); $attributes = PhocaCartAttribute::getAllAttributesAndOptions(); + if (!empty($attributes)) { foreach($attributes as $k => $v) { $data = array(); @@ -134,11 +144,25 @@ public function renderList() { $data['title'] = $v['title']; $data['items'] = $v['option']; $data['getparams'] = $this->getArrayParamValues($data['param'], 'array'); - $data['formtype'] = 'checked'; $data['uniquevalue']= 0; + $data['pathitem'] = $pathProductImage; if (!empty($data['items'])) { - $o[] = $layout->render($data); + + if ($this->enable_color_filter && isset($v['type']) && ($v['type'] == 2)) { + // Color + $data['formtype'] = 'text'; + $o[] = $layout4->render($data); + } else if ($this->enable_image_filter && isset($v['type']) && ($v['type'] == 3)) { + // Image + $data['formtype'] = 'text'; + $data['style'] = strip_tags($this->image_style_image_filter); + $o[] = $layout5->render($data); + } else { + // Select + $data['formtype'] = 'checked'; + $o[] = $layout->render($data); + } } } } diff --git a/libraries/phocacart/form/formuser.php b/libraries/phocacart/form/formuser.php index db60ebb7..dc57f35f 100644 --- a/libraries/phocacart/form/formuser.php +++ b/libraries/phocacart/form/formuser.php @@ -148,7 +148,7 @@ public static function getFormXml($billingSuffix = '', $shippingSuffix = '_phs', } public final function __clone() { - JError::raiseWarning(500, 'Function Error: Cannot clone instance of Singleton pattern');// No JText - for developers only + throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500); return false; } } diff --git a/libraries/phocacart/html/batch.php b/libraries/phocacart/html/batch.php index 2d3ac679..92602485 100644 --- a/libraries/phocacart/html/batch.php +++ b/libraries/phocacart/html/batch.php @@ -24,7 +24,7 @@ public static function item($published, $category = 0) //build the list of categories $query = 'SELECT a.title AS text, a.id AS value, a.parent_id as parentid' . ' FROM #__phocacart_categories AS a' - // TODO. ' WHERE a.published = '.(int)$published + // TO DO. ' WHERE a.published = '.(int)$published . ' ORDER BY a.ordering'; $db->setQuery( $query ); $data = $db->loadObjectList(); diff --git a/libraries/phocacart/html/grid.php b/libraries/phocacart/html/grid.php index 95f7fe7d..a2704863 100644 --- a/libraries/phocacart/html/grid.php +++ b/libraries/phocacart/html/grid.php @@ -8,7 +8,7 @@ */ defined('_JEXEC') or die(); if (! class_exists('JHtmlGrid')) { - require_once( JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'html'.DS.'html'.DS.'grid.php' ); + require_once( JPATH_SITE.'/libraries/joomla/html/html/grid.php' ); } //jimport('joomla.html.html.jgrid'); class PhocaCartGrid extends JHtmlJGrid diff --git a/libraries/phocacart/html/jgrid.php b/libraries/phocacart/html/jgrid.php index 58cf5d27..f515fb46 100644 --- a/libraries/phocacart/html/jgrid.php +++ b/libraries/phocacart/html/jgrid.php @@ -14,7 +14,7 @@ */ if (! class_exists('JHtmlJGrid')) { - require_once( JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'html'.DS.'html'.DS.'jgrid.php' ); + require_once( JPATH_SITE.'/libraries/joomla/html/html/jgrid.php' ); } class PhocaCartJGrid extends JHtmlJGrid diff --git a/libraries/phocacart/order/order.php b/libraries/phocacart/order/order.php index 3f669caa..966ae98e 100644 --- a/libraries/phocacart/order/order.php +++ b/libraries/phocacart/order/order.php @@ -110,6 +110,17 @@ public function saveOrder($comment) { exit; } + // -------------------- + // CHECK MIN MULTIPLE QUANTITY + // -------------------- + $minMultipleQuantityValid = $cart->getMinimumMultipleQuantityValid(); + if($minMultipleQuantityValid == 0) { + $msg = JText::_('COM_PHOCACART_MINIMUM_MULTIPLE_ORDER_QUANTITY_OF_ONE_OR_MORE_PRODUCTS_NOT_MET_UPDATE_QUANTITY_BEFORE_ORDERING'); + $app->enqueueMessage($msg.$msgSuffix, 'error'); + $app->redirect($action); + exit; + } + $db = JFactory::getDBO(); @@ -538,12 +549,14 @@ public function saveOrderProducts($d, $orderId) { - if ($row->id > 0 && !empty($d['attributes'])) { + if ((int)$row->id > 0 && !empty($d['attributes'])) { //$this->cleanTable('phocacart_order_attributes', $orderId); NOT HERE, we are in foreach foreach ($d['attributes'] as $k => $v) { $checkA = PhocaCartAttribute::checkIfRequired($v['aid'], $v['oid']); + + if (!$checkA) { return false; } @@ -576,8 +589,9 @@ public function saveOrderProducts($d, $orderId) { throw new Exception($row2->getError()); return false; } + } - } else if ($row->id > 0){ + } else if ((int)$row->id > 0){ // Empty attributes - check if product include some required attribute $checkA = PhocaCartAttribute::checkIfExistsAndRequired($d['product_id']); if (!$checkA) { @@ -808,7 +822,7 @@ public static function getOrderNumber($orderId) { return str_pad($orderId, '10', '0', STR_PAD_LEFT); } - public static function getInvoiceNumber($orderId, $invoicePrefix) { + public static function getInvoiceNumber($orderId, $invoicePrefix = '') { $l = strlen($invoicePrefix); $n = 10 - $l; if ($n < 0) {$n = 0;} diff --git a/libraries/phocacart/order/orderrender.php b/libraries/phocacart/order/orderrender.php index e34cff64..ae0f2991 100644 --- a/libraries/phocacart/order/orderrender.php +++ b/libraries/phocacart/order/orderrender.php @@ -12,7 +12,7 @@ class PhocaCartOrderRender { public function __construct() {} - public function render($id, $type = 1, $format = 1, $token = '') { + public function render($id, $type = 1, $format = 'html', $token = '') { if ($id < 1) { @@ -35,7 +35,7 @@ public function render($id, $type = 1, $format = 1, $token = '') { $order = new PhocaCartOrderView(); $common = $order->getItemCommon($id); - + $app = JFactory::getApplication(); // Not for admin @@ -66,21 +66,21 @@ public function render($id, $type = 1, $format = 1, $token = '') { // FORMAT - HTML $box = 'class="ph-idnr-box"'; $table = 'class="ph-idnr-box-in"'; - $pho1 = 'class="pho1"'; - $pho2 = 'class="pho2"'; - $pho3 = 'class="pho3"'; - $pho4 = 'class="pho4"'; - $pho5 = 'class="pho5"'; - $pho6 = 'class="pho6"'; - $pho7 = 'class="pho7"'; - $pho6Sep = 'class="pho6 ph-idnr-sep"'; - $pho7Sep = 'class="pho7 ph-idnr-sep"'; - $pho8 = 'class="pho8"'; - $pho9 = 'class="pho9"'; - $pho10 = 'class="pho10"'; - $pho11 = 'class="pho11"'; - $pho12 = 'class="pho12"'; - $sep = 'class="ph-idnr-sep"'; + $pho1 = $pho12 = 'class="pho1"'; + $pho2 = $pho22 = 'class="pho2"'; + $pho3 = $pho32 = 'class="pho3"'; + $pho4 = $pho42 = 'class="pho4"'; + $pho5 = $pho52 = 'class="pho5"'; + $pho6 = $pho62 = 'class="pho6"'; + $pho7 = $pho72 = 'class="pho7"'; + $pho6Sep = $pho6Sep2 = 'class="pho6 ph-idnr-sep"'; + $pho7Sep = $pho7Sep2 = 'class="pho7 ph-idnr-sep"'; + $pho8 = $pho82 = 'class="pho8"'; + $pho9 = $pho92 = 'class="pho9"'; + $pho10 = $pho102 = 'class="pho10"'; + $pho11 = $pho112 = 'class="pho11"'; + $pho12 = $pho122 = 'class="pho12"'; + $sep = $sep2 = 'class="ph-idnr-sep"'; $bBox = 'class="ph-idnr-billing-box"'; $bBoxIn = 'class="ph-idnr-billing-box-in"'; $sBox = 'class="ph-idnr-shipping-box"'; @@ -90,9 +90,61 @@ public function render($id, $type = 1, $format = 1, $token = '') { $bProduct = 'class="ph-idnr-body-product"'; $sepH = 'class="ph-idnr-sep-horizontal"'; $totalF = 'class="ph-idnr-total"'; - $toPay = 'class="ph-idnr-to-pay"'; + $toPayS = 'class="ph-idnr-to-pay"'; + $toPaySV = 'class="ph-idnr-to-pay-value"'; + $firstRow = ''; + + if ($format == 'pdf') { + $box = ''; + $table = 'style="width: 100%; font-family: sans-serif, arial; font-size: 80%;padding:3px;margin-top:-200px"'; + $pho1 = 'style="width: 8.3333%;"'; + $pho2 = 'style="width: 8.3333%;"'; + $pho3 = 'style="width: 8.3333%;"'; + $pho4 = 'style="width: 8.3333%;"'; + $pho5 = 'style="width: 8.3333%;"'; + $pho6 = 'style="width: 8.3333%;"'; + $pho7 = 'style="width: 8.3333%;"'; + $pho6Sep = 'style="width: 3%;"'; + $pho7Sep = 'style="width: 3%;"'; + $pho8 = 'style="width: 8.3333%;"'; + $pho9 = 'style="width: 8.3333%;"'; + $pho10 = 'style="width: 8.3333%;"'; + $pho11 = 'style="width: 8.3333%;"'; + $pho12 = 'style="width: 8.3333%;"'; + $sep = 'style="width: 3%;"'; + + $pho12 = 'style="width: 9%;"'; + $pho22 = 'style="width: 9%;"'; + $pho32 = 'style="width: 9%;"'; + $pho42 = 'style="width: 9%;"'; + $pho52 = 'style="width: 9%;"'; + $pho62 = 'style="width: 9%;"'; + $pho72 = 'style="width: 9%;"'; + $pho6Sep2 = 'style="width: 5%;"'; + $pho7Sep2 = 'style="width: 5%;"'; + $pho82 = 'style="width: 9%;"'; + $pho92 = 'style="width: 9%;"'; + $pho102 = 'style="width: 9%;"'; + $pho112 = 'style="width: 9%;"'; + $pho122 = 'style="width: 9%;"'; + $seps2 = 'style="width: 10%;"'; + + + $bBox = 'style="border: 1pt solid #dddddd;"'; + $bBoxIn = 'style=""'; + $sBox = 'style="border: 1pt solid #dddddd;"'; + $sBoxIn = 'style=""'; + $boxIn = 'style="width: 100%; font-family: sans-serif, arial; font-size: 60%;padding:3px 1px;"'; + $hProduct = 'style="white-space:nowrap;font-weight: bold;background-color: #dddddd;"'; + $bProduct = 'style="white-space:nowrap;"'; + $sepH = 'style="border-top: 1pt solid #dddddd;"'; + $totalF = 'style=""'; + $toPayS = 'style="background-color: #eeeeee;padding: 20px;"'; + $toPaySV = 'style="background-color: #eeeeee;padding: 20px;text-align:right;"'; + $firstRow = 'style="font-size:0pt;"'; - if ($format == 2) { + } else if ($format == 'mail') { + $box = ''; $table = 'style="width: 100%; font-family: sans-serif, arial; font-size: 90%;"'; $pho1 = 'style="width: 8.3333%;"'; @@ -110,6 +162,23 @@ public function render($id, $type = 1, $format = 1, $token = '') { $pho11 = 'style="width: 8.3333%;"'; $pho12 = 'style="width: 8.3333%;"'; $sep = 'style="width: 3%;"'; + + $pho12 = 'style="width: 9%;"'; + $pho22 = 'style="width: 9%;"'; + $pho32 = 'style="width: 9%;"'; + $pho42 = 'style="width: 9%;"'; + $pho52 = 'style="width: 9%;"'; + $pho62 = 'style="width: 9%;"'; + $pho72 = 'style="width: 9%;"'; + $pho6Sep2 = 'style="width: 5%;"'; + $pho7Sep2 = 'style="width: 5%;"'; + $pho82 = 'style="width: 9%;"'; + $pho92 = 'style="width: 9%;"'; + $pho102 = 'style="width: 9%;"'; + $pho112 = 'style="width: 9%;"'; + $pho122 = 'style="width: 9%;"'; + $seps2 = 'style="width: 10%;"'; + $bBox = 'style="border: 1px solid #ddd;padding: 10px;"'; $bBoxIn = 'style=""'; $sBox = 'style="border: 1px solid #ddd;padding: 10px;"'; @@ -119,8 +188,10 @@ public function render($id, $type = 1, $format = 1, $token = '') { $bProduct = 'style="white-space:nowrap;padding: 5px;"'; $sepH = 'style="border-top: 1px solid #ddd;"'; $totalF = 'style=""'; - $toPay = 'style="background: #ddd;padding: 20px;"'; - + $toPayS = 'style="background-color: #eeeeee;padding: 20px;"'; + $toPaySV = 'style="background-color: #eeeeee;padding: 20px;text-align:right;"'; + $firstRow = ''; + } @@ -128,10 +199,10 @@ public function render($id, $type = 1, $format = 1, $token = '') { $o[] = '
'; $o[] = '
'; - $o[] = ''; - $o[] = ''; - $o[] = ''; - $o[] = ''; + $o[] = ''; + $o[] = ''; + $o[] = ''; + $o[] = ''; $o[] = ''; // -------- @@ -148,27 +219,27 @@ public function render($id, $type = 1, $format = 1, $token = '') { } $o[] = ''; - $o[] = ''; + $o[] = ''; // -------- // HEADER RIGHT $o[] = ''; + $t = array(); $toPay = 0; if (!empty($total)) { foreach($total as $k => $v) { @@ -414,13 +486,13 @@ public function render($id, $type = 1, $format = 1, $token = '') { if ($toPay > 0) { $o[] = ''; $o[] = ''; - $o[] = ''; - $o[] = ''; + $o[] = ''; + $o[] = ''; $o[] = ''; } - $o[] = '
            
            
'; if ($type == 1) { $o[] = '

'.JText::_('COM_PHOCACART_ORDER').'

'; - $o[] = '
'.JText::_('COM_PHOCACART_ORDER_NUMBER').': '.PhocaCartOrder::getOrderNumber($common->id).'
'; + $o[] = '
'.JText::_('COM_PHOCACART_ORDER_NR').': '.PhocaCartOrder::getOrderNumber($common->id).'
'; $o[] = '
'.JText::_('COM_PHOCACART_ORDER_DATE').': '.JHtml::date($common->date, 'd. m. Y').'
'; } else if ($type == 2) { $o[] = '

'.JText::_('COM_PHOCACART_INVOICE').'

'; - $o[] = '
'.JText::_('COM_PHOCACART_INVOICE_NUMBER').': '.PhocaCartOrder::getInvoiceNumber($common->id, $invoice_prefix).'
'; + $o[] = '
'.JText::_('COM_PHOCACART_INVOICE_NR').': '.PhocaCartOrder::getInvoiceNumber($common->id, $invoice_prefix).'
'; $o[] = '
'.JText::_('COM_PHOCACART_ORDER_DATE').': '.JHtml::date($common->date, 'd. m. Y').'
'; } else if ($type == 3) { $o[] = '

'.JText::_('COM_PHOCACART_DELIVERY_NOTE').'

'; - $o[] = '
'.JText::_('COM_PHOCACART_ORDER_NUMBER').': '.PhocaCartOrder::getOrderNumber($common->id).'
'; - $o[] = '
'.JText::_('COM_PHOCACART_ORDER_DATE').': '.JHtml::date($common->date, 'd. m. Y').'
'; + $o[] = '
'.JText::_('COM_PHOCACART_ORDER_NR').': '.PhocaCartOrder::getOrderNumber($common->id).'
'; + $o[] = '
'.JText::_('COM_PHOCACART_ORDER_DATE').': '.JHtml::date($common->date, 'd. m. Y').'
'; } $o[] = '
 
'; @@ -214,10 +285,10 @@ public function render($id, $type = 1, $format = 1, $token = '') { if ($v['zip'] != '') { $city[] = $v['zip'];} if ($v['city'] != '') { $city[] = $v['city'];} if (!empty($city)) {$o[] = implode("\n", $city).'
';} - echo '
'; + //echo '
'; if (!empty($v['regiontitle'])) {$o[] = $v['regiontitle'].'
';} if (!empty($v['countrytitle'])) {$o[] = $v['countrytitle'].'
';} - echo '
'; + //echo '
'; if ($v['vat_1'] != '') { $o[] = '
'.JText::_('COM_PHOCACART_VAT1').': '. $v['vat_1'].'
';} if ($v['vat_2'] != '') { $o[] = JText::_('COM_PHOCACART_VAT2').': '.$v['vat_2'].'
';} } @@ -245,10 +316,10 @@ public function render($id, $type = 1, $format = 1, $token = '') { if ($v['zip'] != '') { $city[] = $v['zip'];} if ($v['city'] != '') { $city[] = $v['city'];} if (!empty($city)) {$o[] = implode("\n", $city).'
';} - echo '
'; + //echo '
'; if (!empty($v['regiontitle'])) {$o[] = $v['regiontitle'].'
';} if (!empty($v['countrytitle'])) {$o[] = $v['countrytitle'].'
';} - echo '
'; + //echo '
'; if ($v['vat_1'] != '') { $o[] = '
'.JText::_('COM_PHOCACART_VAT1').': '. $v['vat_1'].'
';} if ($v['vat_2'] != '') { $o[] = JText::_('COM_PHOCACART_VAT2').': '.$v['vat_2'].'
';} } @@ -374,6 +445,7 @@ public function render($id, $type = 1, $format = 1, $token = '') { $o[] = '
 
 '.JText::_('COM_PHOCACART_TO_PAY').''.$price->getPriceFormat($toPay).''.JText::_('COM_PHOCACART_TO_PAY').''.$price->getPriceFormat($toPay).'
';// End box in + $o[] = '
';// End box in $o[] = '';// End box diff --git a/libraries/phocacart/order/orderstatus.php b/libraries/phocacart/order/orderstatus.php index dc29a5d9..2ddbfce2 100644 --- a/libraries/phocacart/order/orderstatus.php +++ b/libraries/phocacart/order/orderstatus.php @@ -61,7 +61,7 @@ public static function getStatus( $id = 0) { } public final function __clone() { - JError::raiseWarning(500, 'Function Error: Cannot clone instance of Singleton pattern');// No JText - for developers only + throw new Exception('Function Error: Cannot clone instance of Singleton pattern', 500); return false; } @@ -86,6 +86,10 @@ public static function changeStatus( $orderId, $statusId, $orderToken = '', $not $config = JFactory::getConfig(); + $paramsC = JComponentHelper::getParams('com_phocacart'); + $invoice_prefix = $paramsC->get('invoice_prefix', ''); + $attachment_format = $paramsC->get('attachment_format', 0 ); + // FIND THE RIGHT VALUES FOR VARIBALES - different if we are in frontend or backend $notifyUserV = false; $notifyOthersV = false; @@ -103,6 +107,7 @@ public static function changeStatus( $orderId, $statusId, $orderToken = '', $not } } + // 2) NOTIFY OTHERS if ($notifyOthers == 0) { $notifyOthersV = false; @@ -212,6 +217,7 @@ public static function changeStatus( $orderId, $statusId, $orderToken = '', $not // Status ID will be ignored as we know the Stock Movement PhocaCartStock::handleStockProduct((int)$v->product_id, $statusId, (int)$v->quantity, $stockMovementsV); } + if (!empty($v->attributes)) { foreach($v->attributes as $k2 => $v2) { if ((int)$v2->option_id > 0 && (int)$v2->productquantity > 0) { @@ -295,23 +301,95 @@ public static function changeStatus( $orderId, $statusId, $orderToken = '', $not $body = PhocaCartEmail::completeMail($body, $r); + + // PDF + $pdfV = array(); + $attachmentContent = ''; + $attachmentName = ''; + $pdfV['plugin-pdf'] = PhocaCartExtension::getExtensionInfo('phocacart', 'plugin', 'phocapdf'); + $pdfV['component-pdf'] = PhocaCartExtension::getExtensionInfo('com_phocapdf'); + $pdfV['pdf'] = 0; + + if ($pdfV['plugin-pdf'] == 1 && $pdfV['component-pdf'] == 1) { + if (JFile::exists(JPATH_ADMINISTRATOR.'/components/com_phocapdf/helpers/phocapdfrender.php')) { + require_once(JPATH_ADMINISTRATOR.'/components/com_phocapdf/helpers/phocapdfrender.php'); + } else { + throw new Exception('Error - Phoca PDF Helper - Render PDF file could not be found in system', 500); + return false; + } + $pdfV['pdf'] = 1; + } switch ($emailSendV) { case 1: $orderRender = new PhocaCartOrderRender(); - $body .= "

"; - $body .= $orderRender->render($orderId, 1, 2, $orderToken); + + if ($attachment_format == 0 || $attachment_format == 2) { + $body .= "

"; + $body .= $orderRender->render($orderId, 1, 'mail', $orderToken); + } + + if ($pdfV['pdf'] == 1 && ($attachment_format == 1 || $attachment_format == 2)) { + $staticData = array(); + $orderNumber = PhocaCartOrder::getOrderNumber($orderId); + $staticData['option'] = 'com_phocacart'; + $staticData['title'] = JText::_('COM_PHOCACART_ORDER_NR'). ': '. $orderNumber; + $staticData['file'] = '';// Must be empty to not save the pdf to server + $staticData['filename'] = strip_tags(JText::_('COM_PHOCACART_ORDER'). '_'. $orderNumber).'.pdf'; + $staticData['subject'] = ''; + $staticData['keywords'] = ''; + $staticData['output'] = $orderRender->render($orderId, 1, 'pdf', $orderToken); + $attachmentContent = PhocaPDFRender::renderPDF('', $staticData); + $attachmentName = $staticData['filename']; + } + break; case 2: $orderRender = new PhocaCartOrderRender(); - $body .= "

"; - $body .= $orderRender->render($orderId, 2, 2, $orderToken); + + if ($attachment_format == 0 || $attachment_format == 2) { + $body .= "

"; + $body .= $orderRender->render($orderId, 2, 'mail', $orderToken); + } + + if ($pdfV['pdf'] == 1 && ($attachment_format == 1 || $attachment_format == 2)) { + $staticData = array(); + $invoiceNumber = PhocaCartOrder::getInvoiceNumber($orderId, $invoice_prefix); + $staticData['option'] = 'com_phocacart'; + $staticData['title'] = JText::_('COM_PHOCACART_INVOICE_NR'). ': '. $invoiceNumber; + $staticData['file'] = '';// Must be empty to not save the pdf to server + $staticData['filename'] = strip_tags(JText::_('COM_PHOCACART_INVOICE'). '_'. $invoiceNumber).'.pdf'; + $staticData['subject'] = ''; + $staticData['keywords'] = ''; + $staticData['output'] = $orderRender->render($orderId, 2, 'pdf', $orderToken); + $attachmentContent = PhocaPDFRender::renderPDF('', $staticData); + $attachmentName = $staticData['filename']; + } + break; case 3: $orderRender = new PhocaCartOrderRender(); - $body .= "

"; - $body .= $orderRender->render($orderId, 3, 2, $orderToken); + + if ($attachment_format == 0 || $attachment_format == 2) { + $body .= "

"; + $body .= $orderRender->render($orderId, 3, 'mail', $orderToken); + } + + if ($pdfV['pdf'] == 1 && ($attachment_format == 1 || $attachment_format == 2)) { + $staticData = array(); + $orderNumber = PhocaCartOrder::getOrderNumber($orderId); + $staticData['option'] = 'com_phocacart'; + $staticData['title'] = JText::_('COM_PHOCACART_ORDER_NR'). ': '. $orderNumber; + $staticData['file'] = '';// Must be empty to not save the pdf to server + $staticData['filename'] = strip_tags(JText::_('COM_PHOCACART_ORDER'). '_'. $orderNumber).'.pdf'; + $staticData['subject'] = ''; + $staticData['keywords'] = ''; + $staticData['output'] = $orderRender->render($orderId, 3, 'pdf', $orderToken); + $attachmentContent = PhocaPDFRender::renderPDF('', $staticData); + $attachmentName = $staticData['filename']; + } + break; } @@ -337,16 +415,23 @@ public static function changeStatus( $orderId, $statusId, $orderToken = '', $not } - - $notify = PhocaCartEmail::sendEmail('', '', $recipient, $subject, $body, true, null, $bcc); + + // Notify + // 1 ... sent + // 0 ... not sent + // -1 ... not sent (error) + $notify = PhocaCartEmail::sendEmail('', '', $recipient, $subject, $body, true, null, $bcc, $attachmentContent, $attachmentName); if ($notify) { if ($app->isAdmin()){ $app->enqueueMessage(JText::_('COM_PHOCACART_EMAIL_IF_NO_ERROR_EMAIL_SENT')); } + return $notify;// 1 + } else { + return -1; } - return $notify; + } - return false; + return false;// 0 } /* Usually diff --git a/libraries/phocacart/path/path.php b/libraries/phocacart/path/path.php index d11da70f..bd780ff0 100644 --- a/libraries/phocacart/path/path.php +++ b/libraries/phocacart/path/path.php @@ -23,8 +23,8 @@ public static function getPath( $manager = '') { // Path of preview and play //$downloadFolderPap = JPath::clean($downloadFolderPap); - //$path['orig_abs_pap'] = JPATH_ROOT . DS . $downloadFolderPap; - //$path['orig_abs_pap_ds'] = $path['orig_abs_pap'] . DS ; + //$path['orig_abs_pap'] = JPATH_ROOT . '/' . $downloadFolderPap; + //$path['orig_abs_pap_ds'] = $path['orig_abs_pap'] . '/' ; $path['media_abs_front_ds'] = JPATH_ROOT . '/media/com_phocacart/images/' ; @@ -64,13 +64,13 @@ public static function getPath( $manager = '') { public static function getPathMedia() { - //TODO create a singleton + // TO DO - create a singleton $option = 'com_phocacart'; $instance = new StdClass(); $baseFront = JURI::root(true); - $instance->media_css_abs = JPATH_ROOT . DS . 'media'. DS . $option . DS . 'css' . DS; - $instance->media_img_abs = JPATH_ROOT . DS . 'media'. DS . $option . DS . 'images' . DS; - $instance->media_js_abs = JPATH_ROOT . DS . 'media'. DS . $option . DS . 'js' . DS; + $instance->media_css_abs = JPATH_ROOT . '/' . 'media'. '/' . $option . '/' . 'css' . '/'; + $instance->media_img_abs = JPATH_ROOT . '/' . 'media'. '/' . $option . '/' . 'images' . '/'; + $instance->media_js_abs = JPATH_ROOT . '/' . 'media'. '/' . $option . '/' . 'js' . '/'; $instance->media_css_rel = 'media/'. $option .'/css/'; $instance->media_img_rel = 'media/'. $option .'/images/'; $instance->media_js_rel = 'components/'. $option .'/assets/'; @@ -90,7 +90,6 @@ public static function getRightPathLink($link) { $pos = strpos($uriS, 'administrator'); if ($pos === false) { - $uriL = str_replace(JURI::root(true), '', $uriS); $uriL = ltrim($uriL, '/'); $formatLink = JURI::root(false). $uriL; diff --git a/libraries/phocacart/path/route.php b/libraries/phocacart/path/route.php index 9d4cfdab..e9bafa7b 100644 --- a/libraries/phocacart/path/route.php +++ b/libraries/phocacart/path/route.php @@ -11,19 +11,19 @@ * source software licenses. See COPYRIGHT.php for copyright notices and * details. */ -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; jimport('joomla.application.component.helper'); class PhocaCartRoute { - public static function getCategoriesRoute() - { - // TEST SOLUTION + public static function getCategoriesRoute() { + $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); - + $option = $app->input->get( 'option', '', 'string' ); + $view = $app->input->get( 'view', '', 'string' ); $activeId = 0; if (isset($active->id)){ @@ -31,14 +31,9 @@ public static function getCategoriesRoute() } $itemId = 0; - - $option = $app->input->get( 'option', '', 'string' ); - $view = $app->input->get( 'view', '', 'string' ); - if ($option == 'com_phocacart' && $view == 'category') { - if ((int)$activeId > 0) { - // 2) if there are two menu links, try to select the one active - $itemId = $activeId; - } + if ((int)$activeId > 0 &&$option == 'com_phocacart' && $view == 'category') { + // 2) if there are two menu links, try to select the one active + $itemId = $activeId; } $needles = array( @@ -52,7 +47,6 @@ public static function getCategoriesRoute() if(isset($item->query['layout'])) { $link .= '&layout='.$item->query['layout']; } - // $item->id should be a "categories view" and it should have preference to category view // so first we check item->id then itemId if (isset($item->id) && ((int)$item->id > 0)) { @@ -64,9 +58,8 @@ public static function getCategoriesRoute() return $link; } - public static function getCategoryRoute($catid, $catidAlias = '') - { - // TEST SOLUTION + public static function getCategoryRoute($catid, $catidAlias = '') { + $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); @@ -79,7 +72,6 @@ public static function getCategoryRoute($catid, $catidAlias = '') } if ((int)$activeId > 0 && $option == 'com_phocacart' && $view == 'category') { - $needles = array( 'category' => (int)$catid, 'categories' => (int)$activeId @@ -95,24 +87,13 @@ public static function getCategoryRoute($catid, $catidAlias = '') $catid = $catid . ':' . $catidAlias; } - //Create the link $link = 'index.php?option=com_phocacart&view=category&id='.$catid; - - if($item = PhocaCartRoute::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if (isset($item->id) && ((int)$item->id > 0)) { - $link .= '&Itemid='.$item->id; - } - }; - - return $link; + return self::_buildLink($link, $needles); } - public static function getCategoryRouteByTag($tagId) - { - // TEST SOLUTION + + public static function getCategoryRouteByTag($tagId) { + $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); @@ -123,7 +104,6 @@ public static function getCategoryRouteByTag($tagId) $activeId = $active->id; } if ((int)$activeId > 0 && $option == 'com_phocacart') { - $needles = array( 'category' => '', 'categories' => (int)$activeId @@ -135,8 +115,6 @@ public static function getCategoryRouteByTag($tagId) ); } - - $db = JFactory::getDBO(); $query = 'SELECT a.id, a.title, a.link_ext, a.link_cat' @@ -147,33 +125,20 @@ public static function getCategoryRouteByTag($tagId) $db->setQuery($query, 0, 1); $tag = $db->loadObject(); - - //Create the link if (isset($tag->id)) { $link = 'index.php?option=com_phocacart&view=category&id=tag&tagid='.(int)$tag->id; } else { $link = 'index.php?option=com_phocacart&view=category&id=tag&tagid=0'; } - - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if (isset($item->id) && ((int)$item->id > 0)) { - $link .= '&Itemid='.$item->id; - } - }; - - return $link; + return self::_buildLink($link, $needles); } /* Items route can be without id or with id, if id, then it is a category id */ - public static function getItemsRoute($catid = '', $catidAlias = '') - { - // TEST SOLUTION + public static function getItemsRoute($catid = '', $catidAlias = '') { + $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); @@ -217,36 +182,20 @@ public static function getItemsRoute($catid = '', $catidAlias = '') } } - - - if ($catidAlias != '') { $catid = $catid . ':' . $catidAlias; } - //Create the link if ($catid != '') { $link = 'index.php?option=com_phocacart&view=items&id='.$catid; } else { $link = 'index.php?option=com_phocacart&view=items'; } - - - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if (isset($item->id) && ((int)$item->id > 0)) { - $link .= '&Itemid='.$item->id; - } - } - - return $link; + return self::_buildLink($link, $needles); } - public static function getItemRoute($id, $catid = 0, $idAlias = '', $catidAlias = '') - { - // TEST SOLUTION + public static function getItemRoute($id, $catid = 0, $idAlias = '', $catidAlias = '') { + $app = JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); @@ -264,15 +213,14 @@ public static function getItemRoute($id, $catid = 0, $idAlias = '', $catidAlias } if ((int)$activeId > 0 && $option == 'com_phocacart' && $view == 'item') { - $needles = array( - 'detail' => (int) $id, + 'item' => (int) $id, 'category' => (int) $catid, 'categories' => (int)$activeId ); } else { $needles = array( - 'detail' => (int) $id, + 'item' => (int) $id, 'category' => (int) $catid, 'categories' => '' ); @@ -286,183 +234,113 @@ public static function getItemRoute($id, $catid = 0, $idAlias = '', $catidAlias } $link = 'index.php?option=com_phocacart&view=item&id='. $id.'&catid='.$catid; - - - if($item = self::_findItem($needles)) { - if (isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - } - - return $link; + return self::_buildLink($link, $needles); } - public static function getCheckoutRoute($id = 0, $catid = 0) - { + public static function getCheckoutRoute($id = 0, $catid = 0) { $needles = array( + 'checkout' => '', 'item' => (int) $id, 'category' => (int) $catid, - 'checkout' => '', 'categories' => '' ); - //Create the link $link = 'index.php?option=com_phocacart&view=checkout'; - - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if(isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - }; - return $link; + return self::_buildLink($link, $needles); } - public static function getAccountRoute($id = 0, $catid = 0) - { + public static function getAccountRoute($id = 0, $catid = 0) { $needles = array( + 'account' => '', 'item' => (int) $id, 'category' => (int) $catid, - 'account' => '', 'categories' => '' ); - //Create the link $link = 'index.php?option=com_phocacart&view=account'; - - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if(isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - }; - return $link; + return self::_buildLink($link, $needles); } - public static function getComparisonRoute($id = 0, $catid = 0) - { + public static function getComparisonRoute($id = 0, $catid = 0) { $needles = array( + 'comparison' => '', 'item' => (int) $id, 'category' => (int) $catid, - 'comparison' => '', 'categories' => '' ); - //Create the link $link = 'index.php?option=com_phocacart&view=comparison'; - - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if(isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - }; - return $link; + return self::_buildLink($link, $needles); } - public static function getPaymentRoute($id = 0, $catid = 0) - { + public static function getWishListRoute($id = 0, $catid = 0) { $needles = array( + 'wishlist' => '', 'item' => (int) $id, 'category' => (int) $catid, + 'categories' => '' + ); + + $link = 'index.php?option=com_phocacart&view=wishlist'; + return self::_buildLink($link, $needles); + } + + public static function getPaymentRoute($id = 0, $catid = 0) { + $needles = array( //'payment' => '', + 'item' => (int) $id, + 'category' => (int) $catid, 'categories' => '' ); - //Create the link $link = 'index.php?option=com_phocacart&view=payment'; - - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if(isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - }; - return $link; + return self::_buildLink($link, $needles); } - public static function getDownloadRoute($id = 0, $catid = 0) - { + public static function getDownloadRoute($id = 0, $catid = 0) { $needles = array( + 'download' => '', 'item' => (int) $id, 'category' => (int) $catid, - 'download' => '', 'categories' => '' ); - //Create the link $link = 'index.php?option=com_phocacart&view=download'; - - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if(isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - }; - - return $link; + return self::_buildLink($link, $needles); } - public static function getOrdersRoute($id = 0, $catid = 0) - { + public static function getOrdersRoute($id = 0, $catid = 0) { $needles = array( + 'orders' => '', 'item' => (int) $id, 'category' => (int) $catid, - 'orders' => '', 'categories' => '' ); - //Create the link $link = 'index.php?option=com_phocacart&view=orders'; - - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if(isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - }; - return $link; + return self::_buildLink($link, $needles); } - public static function getTermsRoute($id = 0, $catid = 0) - { + public static function getTermsRoute($id = 0, $catid = 0, $suffix = '') { $needles = array( + 'terms' => '', 'item' => (int) $id, 'category' => (int) $catid, 'categories' => '' ); - //Create the link $link = 'index.php?option=com_phocacart&view=terms'; + if ($suffix != '') { + $link .= '&'.$suffix; + } - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if(isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - }; - return $link; + return self::_buildLink($link, $needles); } - public static function getInfoRoute($id = 0, $catid = 0) - { + public static function getInfoRoute($id = 0, $catid = 0) { $needles = array( //'info' => '', 'item' => (int) $id, @@ -470,23 +348,11 @@ public static function getInfoRoute($id = 0, $catid = 0) 'categories' => '' ); - //Create the link $link = 'index.php?option=com_phocacart&view=info'; - - if($item = self::_findItem($needles)) { - if(isset($item->query['layout'])) { - $link .= '&layout='.$item->query['layout']; - } - if (isset($item->id)) { - $link .= '&Itemid='.$item->id; - } - } - - return $link; + return self::_buildLink($link, $needles); } - public static function getFeedRoute($id = 0, $idAlias = '', $noSEF = 0) - { + public static function getFeedRoute($id = 0, $idAlias = '', $noSEF = 0) { $needles = array( 'feed' => (int) $id, 'categories' => '' @@ -500,20 +366,77 @@ public static function getFeedRoute($id = 0, $idAlias = '', $noSEF = 0) if ($noSEF == 1) { return $link; } + return self::_buildLink($link, $needles); + } + + + public static function getQuestionRoute($id = 0, $catid = 0, $idAlias = '', $catidAlias = '', $suffix = '') { + + $app = JFactory::getApplication(); + $menu = $app->getMenu(); + $active = $menu->getActive(); + $option = $app->input->get( 'option', '', 'string' ); + $view = $app->input->get( 'view', '', 'string' ); + + $activeId = 0; + if (isset($active->id)){ + $activeId = $active->id; + } + + if ((int)$activeId > 0 && $option == 'com_phocacart' && $view == 'question') { + + $needles = array( + 'question' => '', + 'item' => (int) $id, + 'category' => (int) $catid, + 'categories' => (int)$activeId + ); + } else { + $needles = array( + 'question' => '', + 'item' => (int) $id, + 'category' => (int) $catid, + 'categories' => '' + ); + } + + if ($idAlias != '') { + $id = (int)$id . ':' . $idAlias; + } + if ($catidAlias != '') { + $catid = (int)$catid . ':' . $catidAlias; + } + + $link = 'index.php?option=com_phocacart&view=question'; + if ($id != 0) { + $link .= '&id='. $id; + } + if ($catid != 0) { + $link .= '&catid='. $catid; + } + if ($suffix != '') { + $link .= '&'.$suffix; + } + + return self::_buildLink($link, $needles); + } + + + + protected static function _buildLink($link, $needles) { + if($item = self::_findItem($needles)) { if(isset($item->query['layout'])) { $link .= '&layout='.$item->query['layout']; } - if(isset($item->id)) { + if (isset($item->id) && ((int)$item->id > 0)) { $link .= '&Itemid='.$item->id; } - }; + } return $link; } - - protected static function _findItem($needles, $notCheckId = 0) { @@ -521,6 +444,7 @@ protected static function _findItem($needles, $notCheckId = 0) $menus = $app->getMenu('site', array()); $items = $menus->getItems('component', 'com_phocacart'); + if(!$items) { return $app->input->get('Itemid', 0, '', 'int'); //return null; @@ -607,6 +531,7 @@ public static function getJsItemsRoute($activeCategory = 0) { $urlItemsView = JRoute::_(PhocaCartRoute::getItemsRoute($a['id'], $a['alias'])); } + $urlItemsView = str_replace('&', '&', $urlItemsView); // Cause URL problems diff --git a/libraries/phocacart/price/price.php b/libraries/phocacart/price/price.php index 73fb5aa5..7402c1f2 100644 --- a/libraries/phocacart/price/price.php +++ b/libraries/phocacart/price/price.php @@ -103,9 +103,9 @@ public function getTaxFormat($tax, $taxCalculationType, $format = 1) { if ($format == 0) { // IS USED FOR PERCENTAGE IN VAT TITLE ... e.g. VAT(10%) if ($taxCalculationType == 2) { // FIX - $tax = $tax; + $tax = $tax + 0; } else { // Percentage - $tax = $tax.'%'; + $tax = ($tax + 0) .'%'; } } else { // IS USED FOR PERCENTAGE in CALCUTATION: ... VAT(10%) --> 10,00 % if ($taxCalculationType == 2) { // FIX @@ -123,12 +123,15 @@ public function getTaxFormat($tax, $taxCalculationType, $format = 1) { * param format - format the price or not (add currency symbol, price decimals thousands separator, ...) */ - public function getPriceItems($price, $tax, $taxCalculationType, $taxTitle = '', $baseAmount = 0, $baseUnit = '') { + public function getPriceItems($price, $tax, $taxCalculationType, $taxTitle = '', $baseAmount = 0, $baseUnit = '', $zeroPrice = 0) { $priceO = array(); $paramsC = JComponentHelper::getParams('com_phocacart'); $tax_calculation = $paramsC->get( 'tax_calculation', 0 ); $display_unit_price = $paramsC->get( 'display_unit_price', 1 ); + $zero_price_text = $paramsC->get( 'zero_price_text', '' ); + $zero_price_label = $paramsC->get( 'zero_price_label', '' ); + $priceO['taxtxt'] = $taxTitle; $priceO['taxcalc'] = $tax_calculation; @@ -154,6 +157,7 @@ public function getPriceItems($price, $tax, $taxCalculationType, $taxTitle = '', $priceO['taxtxt'] = $taxTitle . ' (' . $this->getTaxFormat($tax, $taxCalculationType, 0) . ')'; } + $priceO['bruttotxt'] = JText::_('COM_PHOCACART_PRICE_INCL_TAX'); $priceO['nettotxt'] = JText::_('COM_PHOCACART_PRICE_EXCL_TAX'); @@ -200,6 +204,19 @@ public function getPriceItems($price, $tax, $taxCalculationType, $taxTitle = '', $priceO['baseformat'] = $this->getPriceFormat($priceO['base']).'/'.$baseUnit; } + if ($price == 0 && $zeroPrice == 1) { + if ($zero_price_text != '') { + $priceO['nettoformat'] = $priceO['bruttoformat'] = $priceO['taxformat'] = JText::_($zero_price_text); + } + + if ($zero_price_label == '0') { + $priceO['nettotxt'] = $priceO['bruttotxt'] = $priceO['taxtxt'] = ''; + } else if ($zero_price_label != '') { + $priceO['nettotxt'] = $priceO['bruttotxt'] = $priceO['taxtxt'] = JText::_($zero_price_label); + } + + } + return $priceO; } @@ -405,4 +422,7 @@ public static function convertPriceCurrentToDefaultCurrency($price, $rate = 1) { $price /= $rate; return $price; } + public static function cleanPrice($price) { + return $price + 0; + } } \ No newline at end of file diff --git a/libraries/phocacart/product/product.php b/libraries/phocacart/product/product.php index e541b2aa..e9e5a238 100644 --- a/libraries/phocacart/product/product.php +++ b/libraries/phocacart/product/product.php @@ -16,7 +16,7 @@ public static function getProduct($productId, $prioritizeCatid = 0) { $db = JFactory::getDBO(); $query = ' SELECT a.id, c.id as catid, a.alias, a.title, a.sku, a.price, a.price_original, a.tax_id as taxid, a.image, a.weight, a.volume, a.unit_amount, a.unit_unit,' - .' a.download_token, a.download_folder, a.download_file, a.download_hits, a.stock, a.min_quantity,' + .' a.download_token, a.download_folder, a.download_file, a.download_hits, a.stock, a.min_quantity, a.min_multiple_quantity,' .' t.title as taxtitle, t.tax_rate as taxrate, t.calculation_type as taxcalctype' .' FROM #__phocacart_products AS a' .' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = a.id' @@ -38,7 +38,11 @@ public static function getProduct($productId, $prioritizeCatid = 0) { //$product->catid is $product->catid } else { // Recheck the category id of product - $checkCategory = PhocaCartProduct::checkIfAccessPossible((int)$product->id, (int)$prioritizeCatid); + $checkCategory = false; + if (isset($product->id)) { + $checkCategory = PhocaCartProduct::checkIfAccessPossible((int)$product->id, (int)$prioritizeCatid); + } + if ($checkCategory) { $product->catid = (int)$prioritizeCatid; } @@ -139,7 +143,7 @@ public static function getProductByProductId($id) { * checkPrice - check if the product has price or not ( > 0 ) */ - public static function getProducts($limit = 1, $orderingItem = 1, $orderingCat = 0, $checkPublished = false, $checkStock = false, $checkPrice = false, $categoriesList = 0) { + public static function getProducts($limit = 1, $orderingItem = 1, $orderingCat = 0, $checkPublished = false, $checkStock = false, $checkPrice = false, $categoriesList = 0, $categoryIds = array()) { phocacartimport('phocacart.ordering.ordering'); @@ -166,7 +170,13 @@ public static function getProducts($limit = 1, $orderingItem = 1, $orderingCat = $wheres[] = " a.price > 0"; } - $q = ' SELECT a.id, a.title, a.image, a.video, a.alias, a.description, a.description_long, a.sku, a.stockstatus_a_id, a.stockstatus_n_id, a.min_quantity, a.stock, a.unit_amount, a.unit_unit, c.id AS catid, c.title AS cattitle, c.alias AS catalias, c.title_feed AS cattitlefeed, a.price, a.price_original, t.tax_rate AS taxrate, t.calculation_type AS taxcalculationtype, t.title AS taxtitle, a.date, a.sales, a.featured, a.external_id, m.title AS manufacturertitle,' + if (!empty($categoryIds)) { + + $catIdsS = implode (',', $categoryIds); + $wheres[] = 'pc.category_id IN ('.$catIdsS.')'; + } + + $q = ' SELECT a.id, a.title, a.image, a.video, a.alias, a.description, a.description_long, a.sku, a.stockstatus_a_id, a.stockstatus_n_id, a.min_quantity, a.min_multiple_quantity, a.stock, a.unit_amount, a.unit_unit, c.id AS catid, c.title AS cattitle, c.alias AS catalias, c.title_feed AS cattitlefeed, a.price, a.price_original, t.tax_rate AS taxrate, t.calculation_type AS taxcalculationtype, t.title AS taxtitle, a.date, a.sales, a.featured, a.external_id, m.title AS manufacturertitle,' . ' AVG(r.rating) AS rating,' . ' at.required AS attribute_required'; @@ -211,13 +221,14 @@ public static function getCategoryByProductId($id) { . ' LIMIT 1'; $db->setQuery( $query ); $category = $db->loadRow(); + if (isset($category[0]) && $category[0] > 0) { return $category[0]; } return 0; } - public static function getMostViewedProducts($limit = 5, $checkPublished = false, $checkAccess = false) { + public static function getMostViewedProducts($limit = 5, $checkPublished = false, $checkAccess = false, $count = false) { $db = JFactory::getDBO(); $wheres = array(); @@ -234,26 +245,46 @@ public static function getMostViewedProducts($limit = 5, $checkPublished = false $wheres[] = " a.hits > 0"; $where = ( count( $wheres ) ? ' WHERE '. implode( ' AND ', $wheres ) : '' ); - $query = 'SELECT a.id, a.title, a.alias, a.hits, c.id as catid, c.alias as catalias, c.title as cattitle' - . ' FROM #__phocacart_products AS a' - . ' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = a.id' - . ' LEFT JOIN #__phocacart_categories AS c ON c.id = pc.category_id' - . $where - . ' GROUP BY a.id' - . ' ORDER BY a.hits DESC' - . ' LIMIT '.(int)$limit; - $db->setQuery( $query ); + if ($count) { + $q = 'SELECT SUM(a.hits)' + . ' FROM #__phocacart_products AS a' + . ' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = a.id' + . ' LEFT JOIN #__phocacart_categories AS c ON c.id = pc.category_id' + . $where; + if ((int)$limit > 0) { + $q .= ' LIMIT '.(int)$limit; + } + + $db->setQuery( $q ); + $products = $db->loadResult(); + + } else { + + $q = 'SELECT a.id, a.title, a.alias, a.hits, c.id as catid, c.alias as catalias, c.title as cattitle' + . ' FROM #__phocacart_products AS a' + . ' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = a.id' + . ' LEFT JOIN #__phocacart_categories AS c ON c.id = pc.category_id' + . $where + . ' GROUP BY a.id' + . ' ORDER BY a.hits DESC'; + if ((int)$limit > 0) { + $q .= ' LIMIT '.(int)$limit; + } + + $db->setQuery( $q ); + $products = $db->loadObjectList(); + } + - $products = $db->loadObjectList(); return $products; } - public static function getBestSellingProducts($limit = 5, $dateFrom = '', $dateTo = '') { + public static function getBestSellingProducts($limit = 5, $dateFrom = '', $dateTo = '', $count = false) { $db = JFactory::getDBO(); $wheres = array(); - $wheres[] = " a.id > 0"; + $wheres[] = " o.id > 0"; if ($dateTo != '' && $dateFrom != '') { $dateFrom = $db->Quote($dateFrom); @@ -263,26 +294,47 @@ public static function getBestSellingProducts($limit = 5, $dateFrom = '', $dateT $where = ( count( $wheres ) ? ' WHERE '. implode( ' AND ', $wheres ) : '' ); - - $q = ' SELECT a.id, a.title, a.alias, COUNT( o.id ) AS count_products' + if ($count) { + $q = ' SELECT count(o.id)' . ' FROM #__phocacart_order_products AS o' . ' LEFT JOIN #__phocacart_products AS a ON a.id = o.product_id'; - if ($dateTo != '' && $dateFrom != '') { - $q .= ' LEFT JOIN #__phocacart_orders AS od ON od.id = o.order_id'; - } + if ($dateTo != '' && $dateFrom != '') { + $q .= ' LEFT JOIN #__phocacart_orders AS od ON od.id = o.order_id'; + } + $q .= $where; + if ((int)$limit > 0) { + $q .= ' LIMIT '.(int)$limit; + } + + + $db->setQuery($q); + $products = $db->loadResult(); + + } else { + $q = ' SELECT o.product_id AS id, o.title, o.alias, COUNT( o.id ) AS count_products' + . ' FROM #__phocacart_order_products AS o'; + //. ' LEFT JOIN #__phocacart_products AS a ON a.id = o.product_id'; + if ($dateTo != '' && $dateFrom != '') { + $q .= ' LEFT JOIN #__phocacart_orders AS od ON od.id = o.order_id'; + } $q .= $where - . ' GROUP BY a.id' - . ' ORDER BY count_products DESC' - . ' LIMIT '.(int)$limit; + . ' GROUP BY o.id' + . ' ORDER BY count_products DESC'; + if ((int)$limit > 0) { + $q .= ' LIMIT '.(int)$limit; + } + + $db->setQuery($q); + $products = $db->loadObjectList(); + } - $db->setQuery($q); /* For now we don't need SEF url, if SEF url is needed, we need to get category alias and category id * This cannot be done in sql as then because of table jos_phocacart_product_categories will count count duplicities */ - $products = $db->loadObjectList(); + /* $productsA = array(); diff --git a/libraries/phocacart/render/renderadminview.php b/libraries/phocacart/render/renderadminview.php index c5237707..d83878b0 100644 --- a/libraries/phocacart/render/renderadminview.php +++ b/libraries/phocacart/render/renderadminview.php @@ -31,7 +31,7 @@ public function navigation($tabs) { $o = '"),b.join("")},legend:{labels:{generateLabels:function(a){var c=a.data;return c.labels.length&&c.datasets.length?c.labels.map(function(d,e){var f=a.getDatasetMeta(0),g=c.datasets[0],h=f.data[e],i=h&&h.custom||{},j=b.getValueAtIndexOrDefault,k=a.options.elements.arc,l=i.backgroundColor?i.backgroundColor:j(g.backgroundColor,e,k.backgroundColor),m=i.borderColor?i.borderColor:j(g.borderColor,e,k.borderColor),n=i.borderWidth?i.borderWidth:j(g.borderWidth,e,k.borderWidth);return{text:d,fillStyle:l,strokeStyle:m,lineWidth:n,hidden:isNaN(g.data[e])||f.data[e].hidden,index:e}}):[]}},onClick:function(a,b){var e,f,g,c=b.index,d=this.chart;for(e=0,f=(d.data.datasets||[]).length;e=Math.PI?-1:o<-Math.PI?1:0);var p=o+n,q={x:Math.cos(o),y:Math.sin(o)},r={x:Math.cos(p),y:Math.sin(p)},s=o<=0&&0<=p||o<=2*Math.PI&&2*Math.PI<=p,t=o<=.5*Math.PI&&.5*Math.PI<=p||o<=2.5*Math.PI&&2.5*Math.PI<=p,u=o<=-Math.PI&&-Math.PI<=p||o<=Math.PI&&Math.PI<=p,v=o<=.5*-Math.PI&&.5*-Math.PI<=p||o<=1.5*Math.PI&&1.5*Math.PI<=p,w=m/100,x={x:u?-1:Math.min(q.x*(q.x<0?1:w),r.x*(r.x<0?1:w)),y:v?-1:Math.min(q.y*(q.y<0?1:w),r.y*(r.y<0?1:w))},y={x:s?1:Math.max(q.x*(q.x>0?1:w),r.x*(r.x>0?1:w)),y:t?1:Math.max(q.y*(q.y>0?1:w),r.y*(r.y>0?1:w))},z={width:.5*(y.x-x.x),height:.5*(y.y-x.y)};j=Math.min(h/z.width,i/z.height),k={x:(y.x+x.x)*-.5,y:(y.y+x.y)*-.5}}d.borderWidth=c.getMaxBorderWidth(l.data),d.outerRadius=Math.max((j-d.borderWidth)/2,0),d.innerRadius=Math.max(m?d.outerRadius/100*m:1,0),d.radiusLength=(d.outerRadius-d.innerRadius)/d.getVisibleDatasetCount(),d.offsetX=k.x*d.outerRadius,d.offsetY=k.y*d.outerRadius,l.total=c.calculateTotal(),c.outerRadius=d.outerRadius-d.radiusLength*c.getRingIndex(c.index),c.innerRadius=c.outerRadius-d.radiusLength,b.each(l.data,function(b,d){c.updateElement(b,d,a)})},updateElement:function(a,c,d){var e=this,f=e.chart,g=f.chartArea,h=f.options,i=h.animation,j=(g.left+g.right)/2,k=(g.top+g.bottom)/2,l=h.rotation,m=h.rotation,n=e.getDataset(),o=d&&i.animateRotate?0:a.hidden?0:e.calculateCircumference(n.data[c])*(h.circumference/(2*Math.PI)),p=d&&i.animateScale?0:e.innerRadius,q=d&&i.animateScale?0:e.outerRadius,r=b.getValueAtIndexOrDefault;b.extend(a,{_datasetIndex:e.index,_index:c,_model:{x:j+f.offsetX,y:k+f.offsetY,startAngle:l,endAngle:m,circumference:o,outerRadius:q,innerRadius:p,label:r(n.label,c,f.data.labels[c])}});var s=a._model;this.removeHoverStyle(a),d&&i.animateRotate||(0===c?s.startAngle=h.rotation:s.startAngle=e.getMeta().data[c-1]._model.endAngle,s.endAngle=s.startAngle+s.circumference),a.pivot()},removeHoverStyle:function(b){a.DatasetController.prototype.removeHoverStyle.call(this,b,this.chart.options.elements.arc)},calculateTotal:function(){var e,a=this.getDataset(),c=this.getMeta(),d=0;return b.each(c.data,function(b,c){e=a.data[c],isNaN(e)||b.hidden||(d+=Math.abs(e))}),d},calculateCircumference:function(a){var b=this.getMeta().total;return b>0&&!isNaN(a)?2*Math.PI*(a/b):0},getMaxBorderWidth:function(a){for(var e,f,b=0,c=this.index,d=a.length,g=0;gb?e:b,b=f>b?f:b;return b}})}},{}],18:[function(a,b,c){"use strict";b.exports=function(a){function c(a,c){return b.getValueOrDefault(a.showLine,c.showLines)}var b=a.helpers;a.defaults.line={showLines:!0,spanGaps:!1,hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},a.controllers.line=a.DatasetController.extend({datasetElementType:a.elements.Line,dataElementType:a.elements.Point,addElementAndReset:function(b){var d=this,e=d.chart.options,f=d.getMeta();a.DatasetController.prototype.addElementAndReset.call(d,b),c(d.getDataset(),e)&&0!==f.dataset._model.tension&&d.updateBezierControlPoints()},update:function(a){var k,l,m,d=this,e=d.getMeta(),f=e.dataset,g=e.data||[],h=d.chart.options,i=h.elements.line,j=d.getScaleForId(e.yAxisID),n=d.getDataset(),o=c(n,h);for(o&&(m=f.custom||{},void 0!==n.tension&&void 0===n.lineTension&&(n.lineTension=n.tension),f._scale=j,f._datasetIndex=d.index,f._children=g,f._model={spanGaps:n.spanGaps?n.spanGaps:h.spanGaps,tension:m.tension?m.tension:b.getValueOrDefault(n.lineTension,i.tension),backgroundColor:m.backgroundColor?m.backgroundColor:n.backgroundColor||i.backgroundColor,borderWidth:m.borderWidth?m.borderWidth:n.borderWidth||i.borderWidth,borderColor:m.borderColor?m.borderColor:n.borderColor||i.borderColor,borderCapStyle:m.borderCapStyle?m.borderCapStyle:n.borderCapStyle||i.borderCapStyle,borderDash:m.borderDash?m.borderDash:n.borderDash||i.borderDash,borderDashOffset:m.borderDashOffset?m.borderDashOffset:n.borderDashOffset||i.borderDashOffset,borderJoinStyle:m.borderJoinStyle?m.borderJoinStyle:n.borderJoinStyle||i.borderJoinStyle,fill:m.fill?m.fill:void 0!==n.fill?n.fill:i.fill,steppedLine:m.steppedLine?m.steppedLine:b.getValueOrDefault(n.steppedLine,i.stepped),scaleTop:j.top,scaleBottom:j.bottom,scaleZero:j.getBasePixel()},f.pivot()),k=0,l=g.length;k');var c=a.data,d=c.datasets,e=c.labels;if(d.length)for(var f=0;f'),e[f]&&b.push(e[f]),b.push("");return b.push(""),b.join("")},legend:{labels:{generateLabels:function(a){var c=a.data;return c.labels.length&&c.datasets.length?c.labels.map(function(d,e){var f=a.getDatasetMeta(0),g=c.datasets[0],h=f.data[e],i=h.custom||{},j=b.getValueAtIndexOrDefault,k=a.options.elements.arc,l=i.backgroundColor?i.backgroundColor:j(g.backgroundColor,e,k.backgroundColor),m=i.borderColor?i.borderColor:j(g.borderColor,e,k.borderColor),n=i.borderWidth?i.borderWidth:j(g.borderWidth,e,k.borderWidth);return{text:d,fillStyle:l,strokeStyle:m,lineWidth:n,hidden:isNaN(g.data[e])||f.data[e].hidden,index:e}}):[]}},onClick:function(a,b){var e,f,g,c=b.index,d=this.chart;for(e=0,f=(d.data.datasets||[]).length;e0&&!isNaN(a)?2*Math.PI/b:0}})}},{}],20:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers;a.defaults.radar={scale:{type:"radialLinear"},elements:{line:{tension:0}}},a.controllers.radar=a.DatasetController.extend({datasetElementType:a.elements.Line,dataElementType:a.elements.Point,linkScales:b.noop,addElementAndReset:function(b){a.DatasetController.prototype.addElementAndReset.call(this,b),this.updateBezierControlPoints()},update:function(a){var c=this,d=c.getMeta(),e=d.dataset,f=d.data,g=e.custom||{},h=c.getDataset(),i=c.chart.options.elements.line,j=c.chart.scale;void 0!==h.tension&&void 0===h.lineTension&&(h.lineTension=h.tension),b.extend(d.dataset,{_datasetIndex:c.index,_children:f,_loop:!0,_model:{tension:g.tension?g.tension:b.getValueOrDefault(h.lineTension,i.tension),backgroundColor:g.backgroundColor?g.backgroundColor:h.backgroundColor||i.backgroundColor,borderWidth:g.borderWidth?g.borderWidth:h.borderWidth||i.borderWidth,borderColor:g.borderColor?g.borderColor:h.borderColor||i.borderColor,fill:g.fill?g.fill:void 0!==h.fill?h.fill:i.fill,borderCapStyle:g.borderCapStyle?g.borderCapStyle:h.borderCapStyle||i.borderCapStyle,borderDash:g.borderDash?g.borderDash:h.borderDash||i.borderDash,borderDashOffset:g.borderDashOffset?g.borderDashOffset:h.borderDashOffset||i.borderDashOffset,borderJoinStyle:g.borderJoinStyle?g.borderJoinStyle:h.borderJoinStyle||i.borderJoinStyle,scaleTop:j.top,scaleBottom:j.bottom,scaleZero:j.getBasePosition()}}),d.dataset.pivot(),b.each(f,function(b,d){c.updateElement(b,d,a)},c),c.updateBezierControlPoints()},updateElement:function(a,c,d){var e=this,f=a.custom||{},g=e.getDataset(),h=e.chart.scale,i=e.chart.options.elements.point,j=h.getPointPositionForValue(c,g.data[c]);b.extend(a,{_datasetIndex:e.index,_index:c,_scale:h,_model:{x:d?h.xCenter:j.x,y:d?h.yCenter:j.y,tension:f.tension?f.tension:b.getValueOrDefault(g.tension,e.chart.options.elements.line.tension),radius:f.radius?f.radius:b.getValueAtIndexOrDefault(g.pointRadius,c,i.radius),backgroundColor:f.backgroundColor?f.backgroundColor:b.getValueAtIndexOrDefault(g.pointBackgroundColor,c,i.backgroundColor),borderColor:f.borderColor?f.borderColor:b.getValueAtIndexOrDefault(g.pointBorderColor,c,i.borderColor),borderWidth:f.borderWidth?f.borderWidth:b.getValueAtIndexOrDefault(g.pointBorderWidth,c,i.borderWidth),pointStyle:f.pointStyle?f.pointStyle:b.getValueAtIndexOrDefault(g.pointStyle,c,i.pointStyle),hitRadius:f.hitRadius?f.hitRadius:b.getValueAtIndexOrDefault(g.hitRadius,c,i.hitRadius)}}),a._model.skip=f.skip?f.skip:isNaN(a._model.x)||isNaN(a._model.y)},updateBezierControlPoints:function(){var a=this.chart.chartArea,c=this.getMeta();b.each(c.data,function(d,e){var f=d._model,g=b.splineCurve(b.previousItem(c.data,e,!0)._model,f,b.nextItem(c.data,e,!0)._model,f.tension);f.controlPointPreviousX=Math.max(Math.min(g.previous.x,a.right),a.left),f.controlPointPreviousY=Math.max(Math.min(g.previous.y,a.bottom),a.top),f.controlPointNextX=Math.max(Math.min(g.next.x,a.right),a.left),f.controlPointNextY=Math.max(Math.min(g.next.y,a.bottom),a.top),d.pivot()})},draw:function(a){var c=this.getMeta(),d=a||1;b.each(c.data,function(a){a.transition(d)}),c.dataset.transition(d).draw(),b.each(c.data,function(a){a.draw()})},setHoverStyle:function(a){var c=this.chart.data.datasets[a._datasetIndex],d=a.custom||{},e=a._index,f=a._model;f.radius=d.hoverRadius?d.hoverRadius:b.getValueAtIndexOrDefault(c.pointHoverRadius,e,this.chart.options.elements.point.hoverRadius),f.backgroundColor=d.hoverBackgroundColor?d.hoverBackgroundColor:b.getValueAtIndexOrDefault(c.pointHoverBackgroundColor,e,b.getHoverColor(f.backgroundColor)),f.borderColor=d.hoverBorderColor?d.hoverBorderColor:b.getValueAtIndexOrDefault(c.pointHoverBorderColor,e,b.getHoverColor(f.borderColor)),f.borderWidth=d.hoverBorderWidth?d.hoverBorderWidth:b.getValueAtIndexOrDefault(c.pointHoverBorderWidth,e,f.borderWidth)},removeHoverStyle:function(a){var c=this.chart.data.datasets[a._datasetIndex],d=a.custom||{},e=a._index,f=a._model,g=this.chart.options.elements.point;f.radius=d.radius?d.radius:b.getValueAtIndexOrDefault(c.radius,e,g.radius),f.backgroundColor=d.backgroundColor?d.backgroundColor:b.getValueAtIndexOrDefault(c.pointBackgroundColor,e,g.backgroundColor),f.borderColor=d.borderColor?d.borderColor:b.getValueAtIndexOrDefault(c.pointBorderColor,e,g.borderColor),f.borderWidth=d.borderWidth?d.borderWidth:b.getValueAtIndexOrDefault(c.pointBorderWidth,e,g.borderWidth)}})}},{}],21:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers;a.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:b.noop,onComplete:b.noop},a.Animation=a.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),a.animationService={frameDuration:17,animations:[],dropFrames:0,request:null,addAnimation:function(a,b,c,d){var e=this;d||(a.animating=!0);for(var f=0;f1&&(c=Math.floor(a.dropFrames),a.dropFrames=a.dropFrames%1);for(var d=0;da.animations[d].animationObject.numSteps&&(a.animations[d].animationObject.currentStep=a.animations[d].animationObject.numSteps),a.animations[d].animationObject.render(a.animations[d].chartInstance,a.animations[d].animationObject),a.animations[d].animationObject.onAnimationProgress&&a.animations[d].animationObject.onAnimationProgress.call&&a.animations[d].animationObject.onAnimationProgress.call(a.animations[d].chartInstance,a.animations[d]),a.animations[d].animationObject.currentStep===a.animations[d].animationObject.numSteps?(a.animations[d].animationObject.onAnimationComplete&&a.animations[d].animationObject.onAnimationComplete.call&&a.animations[d].animationObject.onAnimationComplete.call(a.animations[d].chartInstance,a.animations[d]),a.animations[d].chartInstance.animating=!1,a.animations.splice(d,1)):++d;var e=Date.now(),f=(e-b)/a.frameDuration;a.dropFrames+=f,a.animations.length>0&&a.requestAnimationFrame()}}}},{}],22:[function(a,b,c){"use strict";b.exports=function(a){var b=a.canvasHelpers={};b.drawPoint=function(a,b,c,d,e){var f,g,h,i,j,k;if("object"==typeof b&&(f=b.toString(),"[object HTMLImageElement]"===f||"[object HTMLCanvasElement]"===f))return void a.drawImage(b,d-b.width/2,e-b.height/2);if(!(isNaN(c)||c<=0)){switch(b){default:a.beginPath(),a.arc(d,e,c,0,2*Math.PI),a.closePath(),a.fill();break;case"triangle":a.beginPath(),g=3*c/Math.sqrt(3),j=g*Math.sqrt(3)/2,a.moveTo(d-g/2,e+j/3),a.lineTo(d+g/2,e+j/3),a.lineTo(d,e-2*j/3),a.closePath(),a.fill();break;case"rect":k=1/Math.SQRT2*c,a.beginPath(),a.fillRect(d-k,e-k,2*k,2*k),a.strokeRect(d-k,e-k,2*k,2*k);break;case"rectRot":k=1/Math.SQRT2*c,a.beginPath(),a.moveTo(d-k,e),a.lineTo(d,e+k),a.lineTo(d+k,e),a.lineTo(d,e-k),a.closePath(),a.fill();break;case"cross":a.beginPath(),a.moveTo(d,e+c),a.lineTo(d,e-c),a.moveTo(d-c,e),a.lineTo(d+c,e),a.closePath();break;case"crossRot":a.beginPath(),h=Math.cos(Math.PI/4)*c,i=Math.sin(Math.PI/4)*c,a.moveTo(d-h,e-i),a.lineTo(d+h,e+i),a.moveTo(d-h,e+i),a.lineTo(d+h,e-i),a.closePath();break;case"star":a.beginPath(),a.moveTo(d,e+c),a.lineTo(d,e-c),a.moveTo(d-c,e),a.lineTo(d+c,e),h=Math.cos(Math.PI/4)*c,i=Math.sin(Math.PI/4)*c,a.moveTo(d-h,e-i),a.lineTo(d+h,e+i),a.moveTo(d-h,e+i),a.lineTo(d+h,e-i),a.closePath();break;case"line":a.beginPath(),a.moveTo(d-c,e),a.lineTo(d+c,e),a.closePath();break;case"dash":a.beginPath(),a.moveTo(d,e),a.lineTo(d+c,e),a.closePath()}a.stroke()}}}},{}],23:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers;a.types={},a.instances={},a.controllers={},a.Controller=function(c){return this.chart=c,this.config=c.config,this.options=this.config.options=b.configMerge(a.defaults.global,a.defaults[this.config.type],this.config.options||{}),this.id=b.uid(),Object.defineProperty(this,"data",{get:function(){return this.config.data}}),a.instances[this.id]=this,this.options.responsive&&this.resize(!0),this.initialize(),this},b.extend(a.Controller.prototype,{initialize:function(){var b=this;return a.plugins.notify("beforeInit",[b]),b.bindEvents(),b.ensureScalesHaveIDs(),b.buildOrUpdateControllers(),b.buildScales(),b.updateLayout(),b.resetElements(),b.initToolTip(),b.update(),a.plugins.notify("afterInit",[b]),b},clear:function(){return b.clear(this.chart),this},stop:function(){return a.animationService.cancelAnimation(this),this},resize:function(d){var e=this,f=e.chart,g=f.canvas,h=b.getMaximumWidth(g),i=f.aspectRatio,j=e.options.maintainAspectRatio&&isNaN(i)===!1&&isFinite(i)&&0!==i?h/i:b.getMaximumHeight(g),k=f.width!==h||f.height!==j;if(!k)return e;g.width=f.width=h,g.height=f.height=j,b.retinaScale(f);var l={width:h,height:j};return a.plugins.notify("resize",[e,l]),e.options.onResize&&e.options.onResize(e,l),d||(e.stop(),e.update(e.options.responsiveAnimationDuration)),e},ensureScalesHaveIDs:function(){var a=this.options,c=a.scales||{},d=a.scale;b.each(c.xAxes,function(a,b){a.id=a.id||"x-axis-"+b}),b.each(c.yAxes,function(a,b){a.id=a.id||"y-axis-"+b}),d&&(d.id=d.id||"scale")},buildScales:function(){var c=this,d=c.options,e=c.scales={},f=[];d.scales&&(f=f.concat((d.scales.xAxes||[]).map(function(a){return{options:a,dtype:"category"}}),(d.scales.yAxes||[]).map(function(a){return{options:a,dtype:"linear"}}))),d.scale&&f.push({options:d.scale,dtype:"radialLinear",isDefault:!0}),b.each(f,function(d){var f=d.options,g=b.getValueOrDefault(f.type,d.dtype),h=a.scaleService.getScaleConstructor(g);if(h){var i=new h({id:f.id,options:f,ctx:c.chart.ctx,chart:c});e[i.id]=i,d.isDefault&&(c.scale=i)}}),a.scaleService.addScalesToLayout(this)},updateLayout:function(){a.layoutService.update(this,this.chart.width,this.chart.height)},buildOrUpdateControllers:function(){var c=this,d=[],e=[];if(b.each(c.data.datasets,function(b,f){var g=c.getDatasetMeta(f);g.type||(g.type=b.type||c.config.type),d.push(g.type),g.controller?g.controller.updateIndex(f):(g.controller=new a.controllers[g.type](c,f),e.push(g.controller))},c),d.length>1)for(var f=1;f0&&(b=this.getDatasetMeta(b[0]._datasetIndex).data),b},getDatasetMeta:function(a){var b=this,c=b.data.datasets[a];c._meta||(c._meta={});var d=c._meta[b.id];return d||(d=c._meta[b.id]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null}),d},getVisibleDatasetCount:function(){for(var a=0,b=0,c=this.data.datasets.length;bd)for(var e=d;e=0;f--)c.call(d,a[f],f);else for(f=0;f=e[d].length||!e[d][f].type?e[d].push(b.configMerge(h,c)):c.type&&c.type!==e[d][f].type?e[d][f]=b.configMerge(e[d][f],h,c):e[d][f]=b.configMerge(e[d][f],c)}):(e[d]=[],b.each(c,function(c){var f=b.getValueOrDefault(c.type,"xAxes"===d?"category":"linear");e[d].push(b.configMerge(a.scaleService.getScaleDefaults(f),c))})):e.hasOwnProperty(d)&&"object"==typeof e[d]&&null!==e[d]&&"object"==typeof c?e[d]=b.configMerge(e[d],c):e[d]=c}),e},b.getValueAtIndexOrDefault=function(a,c,d){return void 0===a||null===a?d:b.isArray(a)?c=0;d--){var e=a[d];if(b(e))return e}},b.inherits=function(a){var c=this,d=a&&a.hasOwnProperty("constructor")?a.constructor:function(){return c.apply(this,arguments)},e=function(){this.constructor=d};return e.prototype=c.prototype,d.prototype=new e,d.extend=b.inherits,a&&b.extend(d.prototype,a),d.__super__=c.prototype,d},b.noop=function(){},b.uid=function(){var a=0;return function(){return a++}}(),b.isNumber=function(a){return!isNaN(parseFloat(a))&&isFinite(a)},b.almostEquals=function(a,b,c){return Math.abs(a-b)0?1:-1},b.log10=Math.log10?function(a){return Math.log10(a)}:function(a){return Math.log(a)/Math.LN10},b.toRadians=function(a){return a*(Math.PI/180)},b.toDegrees=function(a){return a*(180/Math.PI)},b.getAngleFromPoint=function(a,b){var c=b.x-a.x,d=b.y-a.y,e=Math.sqrt(c*c+d*d),f=Math.atan2(d,c);return f<-.5*Math.PI&&(f+=2*Math.PI),{angle:f,distance:e}},b.aliasPixel=function(a){return a%2===0?0:.5},b.splineCurve=function(a,b,c,d){var e=a.skip?b:a,f=b,g=c.skip?b:c,h=Math.sqrt(Math.pow(f.x-e.x,2)+Math.pow(f.y-e.y,2)),i=Math.sqrt(Math.pow(g.x-f.x,2)+Math.pow(g.y-f.y,2)),j=h/(h+i),k=i/(h+i);j=isNaN(j)?0:j,k=isNaN(k)?0:k;var l=d*j,m=d*k;return{previous:{x:f.x-l*(g.x-e.x),y:f.y-l*(g.y-e.y)},next:{x:f.x+m*(g.x-e.x),y:f.y+m*(g.y-e.y)}}},b.nextItem=function(a,b,c){return c?b>=a.length-1?a[0]:a[b+1]:b>=a.length-1?a[a.length-1]:a[b+1]},b.previousItem=function(a,b,c){return c?b<=0?a[a.length-1]:a[b-1]:b<=0?a[0]:a[b-1]},b.niceNum=function(a,c){var f,d=Math.floor(b.log10(a)),e=a/Math.pow(10,d);return f=c?e<1.5?1:e<3?2:e<7?5:10:e<=1?1:e<=2?2:e<=5?5:10,f*Math.pow(10,d)};var c=b.easingEffects={linear:function(a){return a},easeInQuad:function(a){return a*a},easeOutQuad:function(a){return-1*a*(a-2)},easeInOutQuad:function(a){return(a/=.5)<1?.5*a*a:-.5*(--a*(a-2)-1)},easeInCubic:function(a){return a*a*a},easeOutCubic:function(a){return 1*((a=a/1-1)*a*a+1)},easeInOutCubic:function(a){return(a/=.5)<1?.5*a*a*a:.5*((a-=2)*a*a+2)},easeInQuart:function(a){return a*a*a*a},easeOutQuart:function(a){return-1*((a=a/1-1)*a*a*a-1)},easeInOutQuart:function(a){return(a/=.5)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)},easeInQuint:function(a){return 1*(a/=1)*a*a*a*a},easeOutQuint:function(a){return 1*((a=a/1-1)*a*a*a*a+1)},easeInOutQuint:function(a){return(a/=.5)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)},easeInSine:function(a){return-1*Math.cos(a/1*(Math.PI/2))+1},easeOutSine:function(a){return 1*Math.sin(a/1*(Math.PI/2))},easeInOutSine:function(a){return-.5*(Math.cos(Math.PI*a/1)-1)},easeInExpo:function(a){return 0===a?1:1*Math.pow(2,10*(a/1-1))},easeOutExpo:function(a){return 1===a?1:1*(-Math.pow(2,-10*a/1)+1)},easeInOutExpo:function(a){return 0===a?0:1===a?1:(a/=.5)<1?.5*Math.pow(2,10*(a-1)):.5*(-Math.pow(2,-10*--a)+2)},easeInCirc:function(a){return a>=1?a:-1*(Math.sqrt(1-(a/=1)*a)-1)},easeOutCirc:function(a){return 1*Math.sqrt(1-(a=a/1-1)*a)},easeInOutCirc:function(a){return(a/=.5)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},easeInElastic:function(a){var b=1.70158,c=0,d=1;return 0===a?0:1===(a/=1)?1:(c||(c=.3),d0?(d=i[0].clientX,e=i[0].clientY):(d=f.clientX,e=f.clientY);var j=parseFloat(b.getStyle(g,"padding-left")),k=parseFloat(b.getStyle(g,"padding-top")),l=parseFloat(b.getStyle(g,"padding-right")),m=parseFloat(b.getStyle(g,"padding-bottom")),n=h.right-h.left-j-l,o=h.bottom-h.top-k-m;return d=Math.round((d-h.left-j)/n*g.width/c.currentDevicePixelRatio),e=Math.round((e-h.top-k)/o*g.height/c.currentDevicePixelRatio),{x:d,y:e}},b.addEvent=function(a,b,c){a.addEventListener?a.addEventListener(b,c):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c},b.removeEvent=function(a,c,d){a.removeEventListener?a.removeEventListener(c,d,!1):a.detachEvent?a.detachEvent("on"+c,d):a["on"+c]=b.noop},b.bindEvents=function(a,c,d){var e=a.events=a.events||{};b.each(c,function(c){e[c]=function(){d.apply(a,arguments)},b.addEvent(a.chart.canvas,c,e[c])})},b.unbindEvents=function(a,c){var d=a.chart.canvas;b.each(c,function(a,c){b.removeEvent(d,c,a)})},b.getConstraintWidth=function(a){return g(a,"max-width","clientWidth")},b.getConstraintHeight=function(a){return g(a,"max-height","clientHeight")},b.getMaximumWidth=function(a){var c=a.parentNode,d=parseInt(b.getStyle(c,"padding-left"))+parseInt(b.getStyle(c,"padding-right")),e=c.clientWidth-d,f=b.getConstraintWidth(a);return isNaN(f)?e:Math.min(e,f)},b.getMaximumHeight=function(a){var c=a.parentNode,d=parseInt(b.getStyle(c,"padding-top"))+parseInt(b.getStyle(c,"padding-bottom")),e=c.clientHeight-d,f=b.getConstraintHeight(a);return isNaN(f)?e:Math.min(e,f)},b.getStyle=function(a,b){return a.currentStyle?a.currentStyle[b]:document.defaultView.getComputedStyle(a,null).getPropertyValue(b)},b.retinaScale=function(a){var b=a.ctx,c=a.canvas,d=c.width,e=c.height,f=a.currentDevicePixelRatio=window.devicePixelRatio||1;1!==f&&(c.height=e*f,c.width=d*f,b.scale(f,f),a.originalDevicePixelRatio=a.originalDevicePixelRatio||f),c.style.width=d+"px", +c.style.height=e+"px"},b.clear=function(a){a.ctx.clearRect(0,0,a.width,a.height)},b.fontString=function(a,b,c){return b+" "+a+"px "+c},b.longestText=function(a,c,d,e){e=e||{};var f=e.data=e.data||{},g=e.garbageCollect=e.garbageCollect||[];e.font!==c&&(f=e.data={},g=e.garbageCollect=[],e.font=c),a.font=c;var h=0;b.each(d,function(c){void 0!==c&&null!==c&&b.isArray(c)!==!0?h=b.measureText(a,f,g,h,c):b.isArray(c)&&b.each(c,function(c){void 0===c||null===c||b.isArray(c)||(h=b.measureText(a,f,g,h,c))})});var i=g.length/2;if(i>d.length){for(var j=0;jd&&(d=f),d},b.numberOfLabelLines=function(a){var c=1;return b.each(a,function(a){b.isArray(a)&&a.length>c&&(c=a.length)}),c},b.drawRoundedRectangle=function(a,b,c,d,e,f){a.beginPath(),a.moveTo(b+f,c),a.lineTo(b+d-f,c),a.quadraticCurveTo(b+d,c,b+d,c+f),a.lineTo(b+d,c+e-f),a.quadraticCurveTo(b+d,c+e,b+d-f,c+e),a.lineTo(b+f,c+e),a.quadraticCurveTo(b,c+e,b,c+e-f),a.lineTo(b,c+f),a.quadraticCurveTo(b,c,b+f,c),a.closePath()},b.color=function(b){return d?d(b instanceof CanvasGradient?a.defaults.global.defaultColor:b):(console.log("Color.js not found!"),b)},b.addResizeListener=function(a,b){var c=document.createElement("iframe"),d="chartjs-hidden-iframe";c.classlist?c.classlist.add(d):c.setAttribute("class",d);var e=c.style;e.width="100%",e.display="block",e.border=0,e.height=0,e.margin=0,e.position="absolute",e.left=0,e.right=0,e.top=0,e.bottom=0,a.insertBefore(c,a.firstChild),(c.contentWindow||c).onresize=function(){b&&b()}},b.removeResizeListener=function(a){var b=a.querySelector(".chartjs-hidden-iframe");b&&b.parentNode.removeChild(b)},b.isArray=Array.isArray?function(a){return Array.isArray(a)}:function(a){return"[object Array]"===Object.prototype.toString.call(a)},b.arrayEquals=function(a,c){var d,e,f,g;if(!a||!c||a.length!=c.length)return!1;for(d=0,e=a.length;d');for(var c=0;c'),a.data.datasets[c].label&&b.push(a.data.datasets[c].label),b.push("");return b.push(""),b.join("")}}},a.Chart=a,a}},{}],28:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers;a.layoutService={defaults:{},addBox:function(a,b){a.boxes||(a.boxes=[]),a.boxes.push(b)},removeBox:function(a,b){a.boxes&&a.boxes.splice(a.boxes.indexOf(b),1)},update:function(a,c,d){function u(a){var b,c=a.isHorizontal();c?(b=a.update(a.options.fullWidth?l:r,q),s-=b.height):(b=a.update(p,o),r-=b.width),t.push({horizontal:c,minSize:b,box:a})}function z(a){var c=b.findNextWhere(t,function(b){return b.box===a});if(c)if(a.isHorizontal()){var d={left:v,right:w,top:0,bottom:0};a.update(a.options.fullWidth?l:r,m/2,d)}else a.update(c.minSize.width,s)}function A(a){var c=b.findNextWhere(t,function(b){return b.box===a}),d={left:0,right:0,top:x,bottom:y};c&&a.update(c.minSize.width,s,d)}function F(a){a.isHorizontal()?(a.left=a.options.fullWidth?e:v,a.right=a.options.fullWidth?c-e:v+r,a.top=E,a.bottom=E+a.height,E=a.bottom):(a.left=D,a.right=D+a.width,a.top=x,a.bottom=x+s,D=a.right)}if(a){var e=0,f=0,g=b.where(a.boxes,function(a){return"left"===a.options.position}),h=b.where(a.boxes,function(a){return"right"===a.options.position}),i=b.where(a.boxes,function(a){return"top"===a.options.position}),j=b.where(a.boxes,function(a){return"bottom"===a.options.position}),k=b.where(a.boxes,function(a){return"chartArea"===a.options.position});i.sort(function(a,b){return(b.options.fullWidth?1:0)-(a.options.fullWidth?1:0)}),j.sort(function(a,b){return(a.options.fullWidth?1:0)-(b.options.fullWidth?1:0)});var l=c-2*e,m=d-2*f,n=l/2,o=m/2,p=(c-n)/(g.length+h.length),q=(d-o)/(i.length+j.length),r=l,s=m,t=[];b.each(g.concat(h,i,j),u);var v=e,w=e,x=f,y=f;b.each(g.concat(h),z),b.each(g,function(a){v+=a.width}),b.each(h,function(a){w+=a.width}),b.each(i.concat(j),z),b.each(i,function(a){x+=a.height}),b.each(j,function(a){y+=a.height}),b.each(g.concat(h),A),v=e,w=e,x=f,y=f,b.each(g,function(a){v+=a.width}),b.each(h,function(a){w+=a.width}),b.each(i,function(a){x+=a.height}),b.each(j,function(a){y+=a.height});var B=d-x-y,C=c-v-w;C===r&&B===s||(b.each(g,function(a){a.height=B}),b.each(h,function(a){a.height=B}),b.each(i,function(a){a.options.fullWidth||(a.width=C)}),b.each(j,function(a){a.options.fullWidth||(a.width=C)}),s=B,r=C);var D=e,E=f;b.each(g.concat(i),F),D+=r,E+=s,b.each(h,F),b.each(j,F),a.chartArea={left:v,top:x,right:v+r,bottom:x+s},b.each(k,function(b){b.left=a.chartArea.left,b.top=a.chartArea.top,b.right=a.chartArea.right,b.bottom=a.chartArea.bottom,b.update(r,s)})}}}}},{}],29:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers,c=b.noop;a.defaults.global.legend={display:!0,position:"top",fullWidth:!0,reverse:!1,onClick:function(a,b){var c=b.datasetIndex,d=this.chart,e=d.getDatasetMeta(c);e.hidden=null===e.hidden?!d.data.datasets[c].hidden:null,d.update()},labels:{boxWidth:40,padding:10,generateLabels:function(a){var c=a.data;return b.isArray(c.datasets)?c.datasets.map(function(c,d){return{text:c.label,fillStyle:b.isArray(c.backgroundColor)?c.backgroundColor[0]:c.backgroundColor,hidden:!a.isDatasetVisible(d),lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,pointStyle:c.pointStyle,datasetIndex:d}},this):[]}}},a.Legend=a.Element.extend({initialize:function(a){b.extend(this,a),this.legendHitBoxes=[],this.doughnutMode=!1},beforeUpdate:c,update:function(a,b,c){var d=this;return d.beforeUpdate(),d.maxWidth=a,d.maxHeight=b,d.margins=c,d.beforeSetDimensions(),d.setDimensions(),d.afterSetDimensions(),d.beforeBuildLabels(),d.buildLabels(),d.afterBuildLabels(),d.beforeFit(),d.fit(),d.afterFit(),d.afterUpdate(),d.minSize},afterUpdate:c,beforeSetDimensions:c,setDimensions:function(){var a=this;a.isHorizontal()?(a.width=a.maxWidth,a.left=0,a.right=a.width):(a.height=a.maxHeight,a.top=0,a.bottom=a.height),a.paddingLeft=0,a.paddingTop=0,a.paddingRight=0,a.paddingBottom=0,a.minSize={width:0,height:0}},afterSetDimensions:c,beforeBuildLabels:c,buildLabels:function(){var a=this;a.legendItems=a.options.labels.generateLabels.call(a,a.chart),a.options.reverse&&a.legendItems.reverse()},afterBuildLabels:c,beforeFit:c,fit:function(){var c=this,d=c.options,e=d.labels,f=d.display,g=c.ctx,h=a.defaults.global,i=b.getValueOrDefault,j=i(e.fontSize,h.defaultFontSize),k=i(e.fontStyle,h.defaultFontStyle),l=i(e.fontFamily,h.defaultFontFamily),m=b.fontString(j,k,l),n=c.legendHitBoxes=[],o=c.minSize,p=c.isHorizontal();if(p?(o.width=c.maxWidth,o.height=f?10:0):(o.width=f?10:0,o.height=c.maxHeight),f)if(g.font=m,p){var q=c.lineWidths=[0],r=c.legendItems.length?j+e.padding:0;g.textAlign="left",g.textBaseline="top",b.each(c.legendItems,function(a,b){var d=e.usePointStyle?j*Math.sqrt(2):e.boxWidth,f=d+j/2+g.measureText(a.text).width;q[q.length-1]+f+e.padding>=c.width&&(r+=j+e.padding,q[q.length]=c.left),n[b]={left:0,top:0,width:f,height:j},q[q.length-1]+=f+e.padding}),o.height+=r}else{var s=e.padding,t=c.columnWidths=[],u=e.padding,v=0,w=0,x=j+s;b.each(c.legendItems,function(a,b){var c=e.usePointStyle?2*e.boxWidth:e.boxWidth,d=c+j/2+g.measureText(a.text).width;w+x>o.height&&(u+=v+e.padding,t.push(v),v=0,w=0),v=Math.max(v,d),w+=x,n[b]={left:0,top:0,width:d,height:j}}),u+=v,t.push(v),o.width+=u}c.width=o.width,c.height=o.height},afterFit:c,isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},draw:function(){var c=this,d=c.options,e=d.labels,f=a.defaults.global,g=f.elements.line,h=c.width,i=c.lineWidths;if(d.display){var k,j=c.ctx,l=b.getValueOrDefault,m=l(e.fontColor,f.defaultFontColor),n=l(e.fontSize,f.defaultFontSize),o=l(e.fontStyle,f.defaultFontStyle),p=l(e.fontFamily,f.defaultFontFamily),q=b.fontString(n,o,p);j.textAlign="left",j.textBaseline="top",j.lineWidth=.5,j.strokeStyle=m,j.fillStyle=m,j.font=q;var r=e.boxWidth,s=c.legendHitBoxes,t=function(b,c,e){if(!(isNaN(r)||r<=0)){if(j.save(),j.fillStyle=l(e.fillStyle,f.defaultColor),j.lineCap=l(e.lineCap,g.borderCapStyle),j.lineDashOffset=l(e.lineDashOffset,g.borderDashOffset),j.lineJoin=l(e.lineJoin,g.borderJoinStyle),j.lineWidth=l(e.lineWidth,g.borderWidth),j.strokeStyle=l(e.strokeStyle,f.defaultColor),j.setLineDash&&j.setLineDash(l(e.lineDash,g.borderDash)),d.labels&&d.labels.usePointStyle){var h=n*Math.SQRT2/2,i=h/Math.SQRT2,k=b+i,m=c+i;a.canvasHelpers.drawPoint(j,e.pointStyle,h,k,m)}else j.strokeRect(b,c,r,n),j.fillRect(b,c,r,n);j.restore()}},u=function(a,b,c,d){j.fillText(c.text,r+n/2+a,b),c.hidden&&(j.beginPath(),j.lineWidth=2,j.moveTo(r+n/2+a,b+n/2),j.lineTo(r+n/2+a+d,b+n/2),j.stroke())},v=c.isHorizontal();k=v?{x:c.left+(h-i[0])/2,y:c.top+e.padding,line:0}:{x:c.left+e.padding,y:c.top+e.padding,line:0};var w=n+e.padding;b.each(c.legendItems,function(a,b){var d=j.measureText(a.text).width,f=e.usePointStyle?n+n/2+d:r+n/2+d,g=k.x,l=k.y;v?g+f>=h&&(l=k.y+=w,k.line++,g=k.x=c.left+(h-i[k.line])/2):l+w>c.bottom&&(g=k.x=g+c.columnWidths[k.line]+e.padding,l=k.y=c.top,k.line++),t(g,l,a),s[b].left=g,s[b].top=l,u(g,l,a,d),v?k.x+=f+e.padding:k.y+=w})}},handleEvent:function(a){var c=this,d=b.getRelativePosition(a,c.chart.chart),e=d.x,f=d.y,g=c.options;if(e>=c.left&&e<=c.right&&f>=c.top&&f<=c.bottom)for(var h=c.legendHitBoxes,i=0;i=j.left&&e<=j.left+j.width&&f>=j.top&&f<=j.top+j.height){g.onClick&&g.onClick.call(c,a,c.legendItems[i]);break}}}}),a.plugins.register({beforeInit:function(b){var c=b.options,d=c.legend;d&&(b.legend=new a.Legend({ctx:b.chart.ctx,options:d,chart:b}),a.layoutService.addBox(b,b.legend))}})}},{}],30:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers.noop;a.plugins={_plugins:[],register:function(a){var b=this._plugins;[].concat(a).forEach(function(a){b.indexOf(a)===-1&&b.push(a)})},unregister:function(a){var b=this._plugins;[].concat(a).forEach(function(a){var c=b.indexOf(a);c!==-1&&b.splice(c,1)})},clear:function(){this._plugins=[]},count:function(){return this._plugins.length},getAll:function(){return this._plugins},notify:function(a,b){var e,f,c=this._plugins,d=c.length;for(e=0;er&&c.labelRotationc.yLabelWidth&&(c.paddingLeft=m+g/2),c.paddingRight=g/2,q*n>c.maxHeight){c.labelRotation--;break}c.labelRotation++,o=p*n}}c.margins&&(c.paddingLeft=Math.max(c.paddingLeft-c.margins.left,0),c.paddingRight=Math.max(c.paddingRight-c.margins.right,0))},afterCalculateTickRotation:function(){b.callCallback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){b.callCallback(this.options.beforeFit,[this])},fit:function(){var c=this,d=c.minSize={width:0,height:0},e=c.options,f=a.defaults.global,g=e.ticks,h=e.scaleLabel,i=e.display,j=c.isHorizontal(),k=b.getValueOrDefault(g.fontSize,f.defaultFontSize),l=b.getValueOrDefault(g.fontStyle,f.defaultFontStyle),m=b.getValueOrDefault(g.fontFamily,f.defaultFontFamily),n=b.fontString(k,l,m),o=b.getValueOrDefault(h.fontSize,f.defaultFontSize),p=e.gridLines.tickMarkLength;if(j?d.width=c.isFullWidth()?c.maxWidth-c.margins.left-c.margins.right:c.maxWidth:d.width=i?p:0,j?d.height=i?p:0:d.height=c.maxHeight,h.display&&i&&(j?d.height+=1.5*o:d.width+=1.5*o),g.display&&i){c.longestTextCache||(c.longestTextCache={});var q=b.longestText(c.ctx,n,c.ticks,c.longestTextCache),r=b.numberOfLabelLines(c.ticks),s=.5*k;if(j){c.longestLabelWidth=q;var t=Math.sin(b.toRadians(c.labelRotation))*c.longestLabelWidth+k*r+s*r;d.height=Math.min(c.maxHeight,d.height+t),c.ctx.font=n;var u=c.ctx.measureText(c.ticks[0]).width,v=c.ctx.measureText(c.ticks[c.ticks.length-1]).width,w=Math.cos(b.toRadians(c.labelRotation)),x=Math.sin(b.toRadians(c.labelRotation));c.paddingLeft=0!==c.labelRotation?w*u+3:u/2+3,c.paddingRight=0!==c.labelRotation?x*(k/2)+3:v/2+3}else{var y=c.maxWidth-d.width,z=g.mirror;z?q=0:q+=c.options.ticks.padding,q0&&c>0?b:0)},draw:function(c){var d=this,e=d.options;if(e.display){var l,o,f=d.ctx,g=a.defaults.global,h=e.ticks,i=e.gridLines,j=e.scaleLabel,k=0!==d.labelRotation,m=h.autoSkip,n=d.isHorizontal();h.maxTicksLimit&&(o=h.maxTicksLimit);var p=b.getValueOrDefault(h.fontColor,g.defaultFontColor),q=b.getValueOrDefault(h.fontSize,g.defaultFontSize),r=b.getValueOrDefault(h.fontStyle,g.defaultFontStyle),s=b.getValueOrDefault(h.fontFamily,g.defaultFontFamily),t=b.fontString(q,r,s),u=i.tickMarkLength,v=b.getValueOrDefault(j.fontColor,g.defaultFontColor),w=b.getValueOrDefault(j.fontSize,g.defaultFontSize),x=b.getValueOrDefault(j.fontStyle,g.defaultFontStyle),y=b.getValueOrDefault(j.fontFamily,g.defaultFontFamily),z=b.fontString(w,x,y),A=b.toRadians(d.labelRotation),B=Math.cos(A),C=d.longestLabelWidth*B;f.fillStyle=p;var D=[];if(n){if(l=!1,k&&(C/=2),(C+h.autoSkipPadding)*d.ticks.length>d.width-(d.paddingLeft+d.paddingRight)&&(l=1+Math.floor((C+h.autoSkipPadding)*d.ticks.length/(d.width-(d.paddingLeft+d.paddingRight)))),o&&d.ticks.length>o)for(;!l||d.ticks.length/(l||1)>o;)l||(l=1),l+=1;m||(l=!1)}var E="right"===e.position?d.left:d.right-u,F="right"===e.position?d.left+u:d.right,G="bottom"===e.position?d.top:d.bottom-u,H="bottom"===e.position?d.top+u:d.bottom;if(b.each(d.ticks,function(a,f){if(void 0!==a&&null!==a){var g=d.ticks.length===f+1,j=l>1&&f%l>0||f%l===0&&f+l>=d.ticks.length;if((!j||g)&&void 0!==a&&null!==a){var m,o;f===("undefined"!=typeof d.zeroLineIndex?d.zeroLineIndex:0)?(m=i.zeroLineWidth,o=i.zeroLineColor):(m=b.getValueAtIndexOrDefault(i.lineWidth,f),o=b.getValueAtIndexOrDefault(i.color,f));var p,q,r,s,t,v,w,x,y,z,B,C="middle";if(n){k||(C="top"===e.position?"bottom":"top"),B=k?"right":"center";var I=d.getPixelForTick(f)+b.aliasPixel(m);y=d.getPixelForTick(f,i.offsetGridLines)+h.labelOffset,z=k?d.top+12:"top"===e.position?d.bottom-u:d.top+u,p=r=t=w=I,q=G,s=H,v=c.top,x=c.bottom}else{"left"===e.position?h.mirror?(y=d.right+h.padding,B="left"):(y=d.right-h.padding,B="right"):h.mirror?(y=d.left-h.padding,B="right"):(y=d.left+h.padding,B="left");var J=d.getPixelForTick(f);J+=b.aliasPixel(m),z=d.getPixelForTick(f,i.offsetGridLines),p=E,r=F,t=c.left,w=c.right,q=s=v=x=J}D.push({tx1:p,ty1:q,tx2:r,ty2:s,x1:t,y1:v,x2:w,y2:x,labelX:y,labelY:z,glWidth:m,glColor:o,rotation:-1*A,label:a,textBaseline:C,textAlign:B})}}}),b.each(D,function(a){if(i.display&&(f.lineWidth=a.glWidth,f.strokeStyle=a.glColor,f.beginPath(),i.drawTicks&&(f.moveTo(a.tx1,a.ty1),f.lineTo(a.tx2,a.ty2)),i.drawOnChartArea&&(f.moveTo(a.x1,a.y1),f.lineTo(a.x2,a.y2)),f.stroke()),h.display){f.save(),f.translate(a.labelX,a.labelY),f.rotate(a.rotation),f.font=t,f.textBaseline=a.textBaseline,f.textAlign=a.textAlign;var c=a.label;if(b.isArray(c))for(var d=0,e=0;d0){var f=a[0];f.xLabel?c=f.xLabel:e>0&&f.index1&&b.each(o,function(a){m.push(f.callbacks.labelColor.call(c,a,j))}),b.extend(g,{title:c.getTitle(o,i),beforeBody:c.getBeforeBody(o,i),body:c.getBody(o,i),afterBody:c.getAfterBody(o,i),footer:c.getFooter(o,i),x:Math.round(n.x),y:Math.round(n.y),caretPadding:b.getValueOrDefault(n.padding,2),labelColors:m});var p=c.getTooltipSize(g);c.determineAlignment(p),b.extend(g,c.getBackgroundPoint(g,p))}else c._model.opacity=0;return a&&f.custom&&f.custom.call(c,g),c},getTooltipSize:function(a){var c=this._chart.ctx,d={height:2*a.yPadding,width:0},e=a.body,f=e.reduce(function(a,b){return a+b.before.length+b.lines.length+b.after.length},0);f+=a.beforeBody.length+a.afterBody.length;var g=a.title.length,h=a.footer.length,i=a.titleFontSize,j=a.bodyFontSize,k=a.footerFontSize;d.height+=g*i,d.height+=(g-1)*a.titleSpacing,d.height+=g?a.titleMarginBottom:0,d.height+=f*j,d.height+=f?(f-1)*a.bodySpacing:0,d.height+=h?a.footerMarginTop:0,d.height+=h*k,d.height+=h?(h-1)*a.footerSpacing:0;var l=0,m=function(a){d.width=Math.max(d.width,c.measureText(a).width+l)};return c.font=b.fontString(i,a._titleFontStyle,a._titleFontFamily),b.each(a.title,m),c.font=b.fontString(j,a._bodyFontStyle,a._bodyFontFamily),b.each(a.beforeBody.concat(a.afterBody),m),l=e.length>1?j+2:0,b.each(e,function(a){b.each(a.before,m),b.each(a.lines,m),b.each(a.after,m)}),l=0,c.font=b.fontString(k,a._footerFontStyle,a._footerFontFamily),b.each(a.footer,m),d.width+=2*a.xPadding,d},determineAlignment:function(a){var b=this,c=b._model,d=b._chart,e=b._chartInstance.chartArea;c.yd.height-a.height&&(c.yAlign="bottom");var f,g,h,i,j,k=(e.left+e.right)/2,l=(e.top+e.bottom)/2;"center"===c.yAlign?(f=function(a){return a<=k},g=function(a){return a>k}):(f=function(b){return b<=a.width/2},g=function(b){return b>=d.width-a.width/2}),h=function(b){return b+a.width>d.width},i=function(b){return b-a.width<0},j=function(a){return a<=l?"top":"bottom"},f(c.x)?(c.xAlign="left",h(c.x)&&(c.xAlign="center",c.yAlign=j(c.y))):g(c.x)&&(c.xAlign="right",i(c.x)&&(c.xAlign="center",c.yAlign=j(c.y)))},getBackgroundPoint:function(a,b){var c={x:a.x,y:a.y},d=a.caretSize,e=a.caretPadding,f=a.cornerRadius,g=a.xAlign,h=a.yAlign,i=d+e,j=f+e;return"right"===g?c.x-=b.width:"center"===g&&(c.x-=b.width/2),"top"===h?c.y+=i:"bottom"===h?c.y-=b.height+i:c.y-=b.height/2,"center"===h?"left"===g?c.x+=i:"right"===g&&(c.x-=i):"left"===g?c.x-=j:"right"===g&&(c.x+=j),c},drawCaret:function(a,c,d){var g,h,i,j,k,l,e=this._view,f=this._chart.ctx,m=e.caretSize,n=e.cornerRadius,o=e.xAlign,p=e.yAlign,q=a.x,r=a.y,s=c.width,t=c.height;"center"===p?("left"===o?(g=q,h=g-m,i=g):(g=q+s,h=g+m,i=g),k=r+t/2,j=k-m,l=k+m):("left"===o?(g=q+n,h=g+m,i=h+m):"right"===o?(g=q+s-n,h=g-m,i=h-m):(h=q+s/2,g=h-m,i=h+m),"top"===p?(j=r,k=j-m,l=j):(j=r+t,k=j+m,l=j));var u=b.color(e.backgroundColor);f.fillStyle=u.alpha(d*u.alpha()).rgbString(), +f.beginPath(),f.moveTo(g,j),f.lineTo(h,k),f.lineTo(i,l),f.closePath(),f.fill()},drawTitle:function(a,c,d,e){var f=c.title;if(f.length){d.textAlign=c._titleAlign,d.textBaseline="top";var g=c.titleFontSize,h=c.titleSpacing,i=b.color(c.titleFontColor);d.fillStyle=i.alpha(e*i.alpha()).rgbString(),d.font=b.fontString(g,c._titleFontStyle,c._titleFontFamily);var j,k;for(j=0,k=f.length;j1;k=m?f+2:0,b.each(h,function(g,h){b.each(g.before,l),b.each(g.lines,function(g){m&&(d.fillStyle=b.color(c.legendColorBackground).alpha(e).rgbaString(),d.fillRect(a.x,a.y,f,f),d.strokeStyle=b.color(c.labelColors[h].borderColor).alpha(e).rgbaString(),d.strokeRect(a.x,a.y,f,f),d.fillStyle=b.color(c.labelColors[h].backgroundColor).alpha(e).rgbaString(),d.fillRect(a.x+1,a.y+1,f-2,f-2),d.fillStyle=j),l(g)}),b.each(g.after,l)}),k=0,b.each(c.afterBody,l),a.y-=g},drawFooter:function(a,c,d,e){var f=c.footer;if(f.length){a.y+=c.footerMarginTop,d.textAlign=c._footerAlign,d.textBaseline="top";var g=b.color(c.footerFontColor);d.fillStyle=g.alpha(e*g.alpha()).rgbString(),d.font=b.fontString(c.footerFontSize,c._footerFontStyle,c._footerFontFamily),b.each(f,function(b){d.fillText(b,a.x,a.y),a.y+=c.footerFontSize+c.footerSpacing})}},draw:function(){var a=this._chart.ctx,c=this._view;if(0!==c.opacity){var d=this.getTooltipSize(c),e={x:c.x,y:c.y},f=Math.abs(c.opacity<.001)?0:c.opacity;if(this._options.enabled){var g=b.color(c.backgroundColor);a.fillStyle=g.alpha(f*g.alpha()).rgbString(),b.drawRoundedRectangle(a,e.x,e.y,d.width,d.height,c.cornerRadius),a.fill(),this.drawCaret(e,d,f),e.x+=c.xPadding,e.y+=c.yPadding,this.drawTitle(e,c,a,f),this.drawBody(e,c,a,f),this.drawFooter(e,c,a,f)}}}})}},{}],35:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers,c=a.defaults.global;c.elements.arc={backgroundColor:c.defaultColor,borderColor:"#fff",borderWidth:2},a.elements.Arc=a.Element.extend({inLabelRange:function(a){var b=this._view;return!!b&&Math.pow(a-b.x,2)i;)f-=2*Math.PI;for(;f=h&&f<=i,k=g>=d.innerRadius&&g<=d.outerRadius;return j&&k}return!1},tooltipPosition:function(){var a=this._view,b=a.startAngle+(a.endAngle-a.startAngle)/2,c=(a.outerRadius-a.innerRadius)/2+a.innerRadius;return{x:a.x+Math.cos(b)*c,y:a.y+Math.sin(b)*c}},draw:function(){var a=this._chart.ctx,b=this._view,c=b.startAngle,d=b.endAngle;a.beginPath(),a.arc(b.x,b.y,b.outerRadius,c,d),a.arc(b.x,b.y,b.innerRadius,d,c,!0),a.closePath(),a.strokeStyle=b.borderColor,a.lineWidth=b.borderWidth,a.fillStyle=b.backgroundColor,a.fill(),a.lineJoin="bevel",b.borderWidth&&a.stroke()}})}},{}],36:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers,c=a.defaults.global;a.defaults.global.elements.line={tension:.4,backgroundColor:c.defaultColor,borderWidth:3,borderColor:c.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",capBezierPoints:!0,fill:!0},a.elements.Line=a.Element.extend({draw:function(){function i(a,b){var c=b._view;b._view.steppedLine===!0?(h.lineTo(b._view.x,a._view.y),h.lineTo(b._view.x,b._view.y)):0===b._view.tension?h.lineTo(c.x,c.y):h.bezierCurveTo(a._view.controlPointNextX,a._view.controlPointNextY,c.controlPointPreviousX,c.controlPointPreviousY,c.x,c.y)}var a=this,d=a._view,e=d.spanGaps,f=d.scaleZero,g=a._loop,h=a._chart.ctx;h.save();var j=a._children.slice(),k=-1;g&&j.length&&j.push(j[0]);var l,m,n,o;if(j.length&&d.fill){for(h.beginPath(),l=0;l=c.x-c.width/2&&a<=c.x+c.width/2&&b>=c.y&&b<=c.base:a>=c.x-c.width/2&&a<=c.x+c.width/2&&b>=c.base&&b<=c.y)},inLabelRange:function(a){var b=this._view;return!!b&&(a>=b.x-b.width/2&&a<=b.x+b.width/2)},tooltipPosition:function(){var a=this._view;return{x:a.x,y:a.y}}})}},{}],39:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers,c={position:"bottom"},d=a.Scale.extend({getLabels:function(){var a=this.chart.data;return(this.isHorizontal()?a.xLabels:a.yLabels)||a.labels},determineDataLimits:function(){var a=this,c=a.getLabels();a.minIndex=0,a.maxIndex=c.length-1;var d;void 0!==a.options.ticks.min&&(d=b.indexOf(c,a.options.ticks.min),a.minIndex=d!==-1?d:a.minIndex),void 0!==a.options.ticks.max&&(d=b.indexOf(c,a.options.ticks.max),a.maxIndex=d!==-1?d:a.maxIndex),a.min=c[a.minIndex],a.max=c[a.maxIndex]},buildTicks:function(){var a=this,b=a.getLabels();a.ticks=0===a.minIndex&&a.maxIndex===b.length-1?b:b.slice(a.minIndex,a.maxIndex+1)},getLabelForIndex:function(a){return this.ticks[a]},getPixelForValue:function(a,b,c,d){var e=this,f=Math.max(e.maxIndex+1-e.minIndex-(e.options.gridLines.offsetGridLines?0:1),1);if(void 0!==a){var g=e.getLabels(),h=g.indexOf(a);b=h!==-1?h:b}if(e.isHorizontal()){var i=e.width-(e.paddingLeft+e.paddingRight),j=i/f,k=j*(b-e.minIndex)+e.paddingLeft;return e.options.gridLines.offsetGridLines&&d&&(k+=j/2),e.left+Math.round(k)}var l=e.height-(e.paddingTop+e.paddingBottom),m=l/f,n=m*(b-e.minIndex)+e.paddingTop;return e.options.gridLines.offsetGridLines&&d&&(n+=m/2),e.top+Math.round(n)},getPixelForTick:function(a,b){return this.getPixelForValue(this.ticks[a],a+this.minIndex,null,b)},getValueForPixel:function(a){var c,b=this,d=Math.max(b.ticks.length-(b.options.gridLines.offsetGridLines?0:1),1),e=b.isHorizontal(),f=e?b.width-(b.paddingLeft+b.paddingRight):b.height-(b.paddingTop+b.paddingBottom),g=f/d;return a-=e?b.left:b.top,b.options.gridLines.offsetGridLines&&(a-=g/2),a-=e?b.paddingLeft:b.paddingTop,c=a<=0?0:Math.round(a/g)},getBasePixel:function(){return this.bottom}});a.scaleService.registerScaleType("category",d,c)}},{}],40:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers,c={position:"left",ticks:{callback:function(a,c,d){var e=d.length>3?d[2]-d[1]:d[1]-d[0];Math.abs(e)>1&&a!==Math.floor(a)&&(e=a-Math.floor(a));var f=b.log10(Math.abs(e)),g="";if(0!==a){var h=-1*Math.floor(f);h=Math.max(Math.min(h,20),0),g=a.toFixed(h)}else g="0";return g}}},d=a.LinearScaleBase.extend({determineDataLimits:function(){function h(b){return g?b.xAxisID===a.id:b.yAxisID===a.id}var a=this,c=a.options,d=a.chart,e=d.data,f=e.datasets,g=a.isHorizontal();if(a.min=null,a.max=null,c.stacked){var i={},j=!1,k=!1;b.each(f,function(e,f){var g=d.getDatasetMeta(f);void 0===i[g.type]&&(i[g.type]={positiveValues:[],negativeValues:[]});var l=i[g.type].positiveValues,m=i[g.type].negativeValues;d.isDatasetVisible(f)&&h(g)&&b.each(e.data,function(b,d){var e=+a.getRightValue(b);isNaN(e)||g.data[d].hidden||(l[d]=l[d]||0,m[d]=m[d]||0,c.relativePoints?l[d]=100:e<0?(k=!0,m[d]+=e):(j=!0,l[d]+=e))})}),b.each(i,function(c){var d=c.positiveValues.concat(c.negativeValues),e=b.min(d),f=b.max(d);a.min=null===a.min?e:Math.min(a.min,e),a.max=null===a.max?f:Math.max(a.max,f)})}else b.each(f,function(c,e){var f=d.getDatasetMeta(e);d.isDatasetVisible(e)&&h(f)&&b.each(c.data,function(b,c){var d=+a.getRightValue(b);isNaN(d)||f.data[c].hidden||(null===a.min?a.min=d:da.max&&(a.max=d))})});this.handleTickRangeOptions()},getTickLimit:function(){var c,d=this,e=d.options.ticks;if(d.isHorizontal())c=Math.min(e.maxTicksLimit?e.maxTicksLimit:11,Math.ceil(d.width/50));else{var f=b.getValueOrDefault(e.fontSize,a.defaults.global.defaultFontSize);c=Math.min(e.maxTicksLimit?e.maxTicksLimit:11,Math.ceil(d.height/(2*f)))}return c},handleDirectionalChanges:function(){this.isHorizontal()||this.ticks.reverse()},getLabelForIndex:function(a,b){return+this.getRightValue(this.chart.data.datasets[b].data[a])},getPixelForValue:function(a){var g,h,b=this,c=b.paddingLeft,d=b.paddingBottom,e=b.start,f=+b.getRightValue(a),i=b.end-e;return b.isHorizontal()?(h=b.width-(c+b.paddingRight),g=b.left+h/i*(f-e),Math.round(g+c)):(h=b.height-(b.paddingTop+d),g=b.bottom-d-h/i*(f-e),Math.round(g))},getValueForPixel:function(a){var b=this,c=b.isHorizontal(),d=b.paddingLeft,e=b.paddingBottom,f=c?b.width-(d+b.paddingRight):b.height-(b.paddingTop+e),g=(c?a-b.left-d:b.bottom-e-a)/f;return b.start+(b.end-b.start)*g},getPixelForTick:function(a){return this.getPixelForValue(this.ticksAsNumbers[a])}});a.scaleService.registerScaleType("linear",d,c)}},{}],41:[function(a,b,c){"use strict";b.exports=function(a){var b=a.helpers,c=b.noop;a.LinearScaleBase=a.Scale.extend({handleTickRangeOptions:function(){var a=this,c=a.options,d=c.ticks;if(d.beginAtZero){var e=b.sign(a.min),f=b.sign(a.max);e<0&&f<0?a.max=0:e>0&&f>0&&(a.min=0)}void 0!==d.min?a.min=d.min:void 0!==d.suggestedMin&&(a.min=Math.min(a.min,d.suggestedMin)),void 0!==d.max?a.max=d.max:void 0!==d.suggestedMax&&(a.max=Math.max(a.max,d.suggestedMax)),a.min===a.max&&(a.max++,d.beginAtZero||a.min--)},getTickLimit:c,handleDirectionalChanges:c,buildTicks:function(){var a=this,c=a.options,d=a.ticks=[],e=c.ticks,f=b.getValueOrDefault,g=a.getTickLimit();g=Math.max(2,g);var h,i=e.fixedStepSize&&e.fixedStepSize>0||e.stepSize&&e.stepSize>0;if(i)h=f(e.fixedStepSize,e.stepSize);else{var j=b.niceNum(a.max-a.min,!1);h=b.niceNum(j/(g-1),!0)}var k=Math.floor(a.min/h)*h,l=Math.ceil(a.max/h)*h,m=(l-k)/h;m=b.almostEquals(m,Math.round(m),h/1e3)?Math.round(m):Math.ceil(m),d.push(void 0!==e.min?e.min:k);for(var n=1;na.max&&(a.max=d))})});a.min=h(d.min,a.min),a.max=h(d.max,a.max),a.min===a.max&&(0!==a.min&&null!==a.min?(a.min=Math.pow(10,Math.floor(b.log10(a.min))-1),a.max=Math.pow(10,Math.floor(b.log10(a.max))+1)):(a.min=1,a.max=10))},buildTicks:function(){for(var a=this,c=a.options,d=c.ticks,e=b.getValueOrDefault,f=a.ticks=[],g=e(d.min,Math.pow(10,Math.floor(b.log10(a.min))));ga.max&&(a.max=d))})}}),a.handleTickRangeOptions()},getTickLimit:function(){var a=this.options.ticks,d=b.getValueOrDefault(a.fontSize,c.defaultFontSize);return Math.min(a.maxTicksLimit?a.maxTicksLimit:11,Math.ceil(this.drawingArea/(1.5*d)))},convertTicksToLabels:function(){var b=this;a.LinearScaleBase.prototype.convertTicksToLabels.call(b),b.pointLabels=b.chart.data.labels.map(b.options.pointLabels.callback,b)},getLabelForIndex:function(a,b){return+this.getRightValue(this.chart.data.datasets[b].data[a])},fit:function(){var i,j,k,l,n,o,q,r,s,t,u,v,a=this.options.pointLabels,d=b.getValueOrDefault(a.fontSize,c.defaultFontSize),e=b.getValueOrDefault(a.fontStyle,c.defaultFontStyle),f=b.getValueOrDefault(a.fontFamily,c.defaultFontFamily),g=b.fontString(d,e,f),h=b.min([this.height/2-d-5,this.width/2]),m=this.width,p=0;for(this.ctx.font=g,j=0;jm&&(m=i.x+l,n=j),i.x-lm&&(m=i.x+k,n=j):i.x-k0&&c>0?b:0)},draw:function(){var a=this,d=a.options,e=d.gridLines,f=d.ticks,g=d.angleLines,h=d.pointLabels,i=b.getValueOrDefault;if(d.display){var j=a.ctx,k=i(f.fontSize,c.defaultFontSize),l=i(f.fontStyle,c.defaultFontStyle),m=i(f.fontFamily,c.defaultFontFamily),n=b.fontString(k,l,m);if(b.each(a.ticks,function(g,h){if(h>0||d.reverse){var l=a.getDistanceFromCenterForValue(a.ticksAsNumbers[h]),m=a.yCenter-l;if(e.display&&0!==h)if(j.strokeStyle=b.getValueAtIndexOrDefault(e.color,h-1),j.lineWidth=b.getValueAtIndexOrDefault(e.lineWidth,h-1),d.lineArc)j.beginPath(),j.arc(a.xCenter,a.yCenter,l,0,2*Math.PI),j.closePath(),j.stroke();else{j.beginPath();for(var o=0;o=0;t--){if(g.display){var u=a.getPointPosition(t,o);j.beginPath(),j.moveTo(a.xCenter,a.yCenter),j.lineTo(u.x,u.y),j.stroke(),j.closePath()}var v=a.getPointPosition(t,o+5),w=i(h.fontColor,c.defaultFontColor);j.font=s,j.fillStyle=w;var x=a.pointLabels,y=this.getIndexAngle(t)+Math.PI/2,z=360*y/(2*Math.PI)%360;0===z||180===z?j.textAlign="center":z<180?j.textAlign="left":j.textAlign="right",90===z||270===z?j.textBaseline="middle":z>270||z<90?j.textBaseline="bottom":j.textBaseline="top",j.fillText(x[t]?x[t]:"",v.x,v.y)}}}}});a.scaleService.registerScaleType("radialLinear",e,d)}},{}],44:[function(a,b,c){"use strict";var d=a(6);d="function"==typeof d?d:window.moment,b.exports=function(a){var b=a.helpers,c={units:[{name:"millisecond",steps:[1,2,5,10,20,50,100,250,500]},{name:"second",steps:[1,2,5,10,30]},{name:"minute",steps:[1,2,5,10,30]},{name:"hour",steps:[1,2,3,6,12]},{name:"day",steps:[1,2,5]},{name:"week",maxStep:4},{name:"month",maxStep:3},{name:"quarter",maxStep:4},{name:"year",maxStep:!1}]},e={position:"bottom",time:{parser:!1,format:!1,unit:!1,round:!1,displayFormat:!1,isoWeekday:!1,displayFormats:{millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm:ss a",hour:"MMM D, hA",day:"ll",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:"YYYY"}},ticks:{autoSkip:!1}},f=a.Scale.extend({initialize:function(){if(!d)throw new Error("Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com");a.Scale.prototype.initialize.call(this)},getLabelMoment:function(a,b){return"undefined"!=typeof this.labelMoments[a]?this.labelMoments[a][b]:null},getMomentStartOf:function(a){var b=this;return"week"===b.options.time.unit&&b.options.time.isoWeekday!==!1?a.clone().startOf("isoWeek").isoWeekday(b.options.time.isoWeekday):a.clone().startOf(b.tickUnit)},determineDataLimits:function(){var a=this;a.labelMoments=[];var c=[];a.chart.data.labels&&a.chart.data.labels.length>0?(b.each(a.chart.data.labels,function(b){var d=a.parseTime(b);d.isValid()&&(a.options.time.round&&d.startOf(a.options.time.round),c.push(d))},a),a.firstTick=d.min.call(a,c),a.lastTick=d.max.call(a,c)):(a.firstTick=null,a.lastTick=null),b.each(a.chart.data.datasets,function(e,f){var g=[],h=a.chart.isDatasetVisible(f);"object"==typeof e.data[0]&&null!==e.data[0]?b.each(e.data,function(b){var c=a.parseTime(a.getRightValue(b));c.isValid()&&(a.options.time.round&&c.startOf(a.options.time.round),g.push(c),h&&(a.firstTick=null!==a.firstTick?d.min(a.firstTick,c):c,a.lastTick=null!==a.lastTick?d.max(a.lastTick,c):c))},a):g=c,a.labelMoments.push(g)},a),a.options.time.min&&(a.firstTick=a.parseTime(a.options.time.min)),a.options.time.max&&(a.lastTick=a.parseTime(a.options.time.max)),a.firstTick=(a.firstTick||d()).clone(),a.lastTick=(a.lastTick||d()).clone()},buildTicks:function(){var d=this;d.ctx.save();var e=b.getValueOrDefault(d.options.ticks.fontSize,a.defaults.global.defaultFontSize),f=b.getValueOrDefault(d.options.ticks.fontStyle,a.defaults.global.defaultFontStyle),g=b.getValueOrDefault(d.options.ticks.fontFamily,a.defaults.global.defaultFontFamily),h=b.fontString(e,f,g);if(d.ctx.font=h,d.ticks=[],d.unitScale=1,d.scaleSizeInUnits=0,d.options.time.unit)d.tickUnit=d.options.time.unit||"day",d.displayFormat=d.options.time.displayFormats[d.tickUnit],d.scaleSizeInUnits=d.lastTick.diff(d.firstTick,d.tickUnit,!0),d.unitScale=b.getValueOrDefault(d.options.time.unitStepSize,1);else{var i=d.isHorizontal()?d.width-(d.paddingLeft+d.paddingRight):d.height-(d.paddingTop+d.paddingBottom),j=d.tickFormatFunction(d.firstTick,0,[]),k=d.ctx.measureText(j).width,l=Math.cos(b.toRadians(d.options.ticks.maxRotation)),m=Math.sin(b.toRadians(d.options.ticks.maxRotation));k=k*l+e*m;var n=i/k;d.tickUnit="millisecond",d.scaleSizeInUnits=d.lastTick.diff(d.firstTick,d.tickUnit,!0),d.displayFormat=d.options.time.displayFormats[d.tickUnit];for(var o=0,p=c.units[o];o=Math.ceil(d.scaleSizeInUnits/n)){d.unitScale=b.getValueOrDefault(d.options.time.unitStepSize,p.steps[q]);break}break}if(p.maxStep===!1||Math.ceil(d.scaleSizeInUnits/n)=0&&(d.lastTick=u),d.scaleSizeInUnits=d.lastTick.diff(d.firstTick,d.tickUnit,!0)}d.smallestLabelSeparation=d.width,b.each(d.chart.data.datasets,function(a,b){for(var c=1;c=0)break;w%d.unitScale===0&&d.ticks.push(x)}var y=d.ticks[d.ticks.length-1].diff(d.lastTick,d.tickUnit);0===y&&0!==d.scaleSizeInUnits||(d.options.time.max?(d.ticks.push(d.lastTick.clone()),d.scaleSizeInUnits=d.lastTick.diff(d.ticks[0],d.tickUnit,!0)):(d.ticks.push(d.lastTick.clone()),d.scaleSizeInUnits=d.lastTick.diff(d.firstTick,d.tickUnit,!0))),d.ctx.restore()},getLabelForIndex:function(a,b){var c=this,d=c.chart.data.labels&&ab&&(b=c)}),c.css("min-height",b)},a("[data-equal]").each(function(){var b=a(this),c=b.data("equal");b.find(c).equalHeights()})}(jQuery); \ No newline at end of file diff --git a/media/js/phoca/index.html b/media/js/phoca/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/media/js/phoca/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/media/js/phoca/jquery.phocaattribute.js b/media/js/phoca/jquery.phocaattribute.js new file mode 100644 index 00000000..8e4715a4 --- /dev/null +++ b/media/js/phoca/jquery.phocaattribute.js @@ -0,0 +1,106 @@ +/* + * jQuery Phoca Attribute + * http://www.phoca.cz + * + * Copyright (C) 2016 Jan Pavelka www.phoca.cz + * + * Licensed under the MIT license + */ +var phAttribute = function() { + + var phO = { + + + phSelectNameId : '', /* ID Select Box */ + phSelectNameIdT : '', /* ID BOX for Color Buttons */ + phSelectNameIdB : '', /* ID of BOX for Select Box */ + phSelectNameIdC : '', /* ID of Select Box (Chosen) */ + phType : '', + phClass : '', + phClassId : '', + + Init: function(id, type) { + + phO.phSelectNameId = '#phItemAttribute' + id; + phO.phSelectNameIdT = '#phItemHiddenAttribute' + id; + phO.phSelectNameIdB = '#phItemBoxAttribute' + id; + phO.phSelectNameIdC = '#phItemAttribute' + id; + phO.phType = type; + if (phO.phType == 3) { + // Image + phO.phClass = 'phSelectBoxImage'; + } else { + // Color + phO.phClass = 'phSelectBoxButton'; + } + phO.phClassId = phO.phSelectNameIdT +' .'+ phO.phClass; + + }, + + Display: function() { + + var phSelectName = jQuery(phO.phSelectNameId).attr('name'); + var phHiddenEl = jQuery(''); + phHiddenEl.val(jQuery(phO.phSelectNameId).val()); + phHiddenEl.insertAfter(jQuery(phO.phSelectNameId)); + + + // ON START DISPLAY OR HIDE + // jQuery(phO.phSelectNameId).hide(); + // jQuery(phO.phSelectNameIdB).hide(); + // Cannot be hidden because of html5 required field and its message + // Hide select box even its chosen alternative + jQuery(phO.phSelectNameIdT).css( "display", "block"); + jQuery(phO.phSelectNameIdB).css( {"display": "visible", 'position': 'absolute', 'clip': 'rect(0,0,0,0)' }); + + // ON START TRANSFORM + jQuery(phO.phSelectNameId + ' option').each(function() { + + /* Do not display default value (empty value), can be set by clicking back from other value */ + if (jQuery(this).val() != '') { + + if(phO.phType == 3) { + // Image + var phSBtn = jQuery('
'+ jQuery(this).text() +'
'); + } else { + // Color + var phSBtn = jQuery('
'+ ' ' +'
'); + } + + + if(jQuery(this).is(':selected')) { + phSBtn.addClass('on'); + } + + jQuery(phO.phSelectNameIdT).append(phSBtn); + + } + + }); + + // ON CLICK + //jQuery(document).on('click', phO.phClassId, function(e) { + jQuery(phO.phClassId).on('click', function(e) { + + e.preventDefault();// Bootstrap modal (close and open again duplicates events) + + var isActive = jQuery(this).hasClass('on'); + + if (isActive) { + jQuery(this).removeClass('on'); + jQuery('input[name="'+ phSelectName +'"]').val(''); + jQuery(phO.phSelectNameId).val('').change();// Because of required field + } else { + jQuery(phO.phClassId).removeClass('on');//Remove when multiple + jQuery(this).addClass('on'); + jQuery('input[name="'+ phSelectName +'"]').val(jQuery(this).data('value')); + jQuery(phO.phSelectNameId).val(jQuery(this).data('value')).change();// Because of required field + } + + }); + + + } + } + return phO; +} \ No newline at end of file diff --git a/media/js/phoca/jquery.phocaswapimage.js b/media/js/phoca/jquery.phocaswapimage.js new file mode 100644 index 00000000..ac00055c --- /dev/null +++ b/media/js/phoca/jquery.phocaswapimage.js @@ -0,0 +1,79 @@ +/* + * jQuery Phoca SwapImage + * http://www.phoca.cz + * + * Copyright (C) 2016 Jan Pavelka www.phoca.cz + * + * Licensed under the MIT license + */ + var phSwapImage = function() { + + var phO = { + + phDefaultA : '', + phDefaultImg : '', + phDefaultHref : '', + phDefaultSrc : '', + phAttributesBox : '', + phCustomHref : 0, + + + Init: function(imgBox, form, select, customHref) { + + phO.phDefaultA = jQuery(imgBox +' a'); + phO.phDefaultImg = jQuery(imgBox +' a img'); + phO.phDefaultHref = phO.phDefaultA.attr('href'); + phO.phDefaultSrc = phO.phDefaultImg.attr('src'); + phO.phAttributesBox = jQuery(form +' '+ select); + phO.phCustomHref = customHref; + + }, + + Display: function() { + + + //jQuery(document).on('change', phO.phAttributesBox, function(){ + phO.phAttributesBox.on('change', function(){ + + // Set image from current selectbox (selectbox which was changed) + var phNewSrc = jQuery(this).find(':selected').data('image-option'); + // Find selected image from all attributes select boxes + var phSelectedSrc = false; + phO.phAttributesBox.each(function( index ) { + var phFoundSrc = jQuery(this).find(':selected').data('image-option'); + if(phFoundSrc) { + + phSelectedSrc = phFoundSrc; + } + }); + + var phNewHref = phNewSrc; + var phSelectedHref = phSelectedSrc; + var phDefaultHref = phO.phDefaultSrc; + + if (phO.phCustomHref) { + phNewHref = phO.phDefaultHref; + phSelectedHref = phO.phDefaultHref; + phDefaultHref = phO.phDefaultHref; + } + + if (phNewSrc) { + // New image found - change to new image + phO.phDefaultA.attr('href', phNewHref); + phO.phDefaultImg.attr('src', phNewSrc); + } else if (!phNewSrc && phSelectedSrc) { + // New image not found but there is some selected image yet (e.g. selected previously in other select box) + phO.phDefaultA.attr('href', phSelectedHref); + phO.phDefaultImg.attr('src', phSelectedSrc); + } else { + // Return back to default image (no new image, no selected image by other select box) + phO.phDefaultA.attr('href', phO.phDefaultHref); + phO.phDefaultImg.attr('src', phO.phDefaultSrc); + } + }); + + + } + } + return phO; +} \ No newline at end of file diff --git a/media/js/windowpopup.js b/media/js/windowpopup.js new file mode 100644 index 00000000..7b97b185 --- /dev/null +++ b/media/js/windowpopup.js @@ -0,0 +1,19 @@ +/* + * jQuery Phoca WindowPopup + * http://www.phoca.cz + * + * Copyright (C) 2016 Jan Pavelka www.phoca.cz + * + * Licensed under the MIT license + */ +function phWindowPopup(url, name, rW, rH) { + var w = screen.width / rW; + var h = screen.height / rH; + var params = 'width='+w+', height='+h+', resizable=yes, scrollbars=yes, menubar=no, status=no, location=no, toolbar=no'; + phWindow = window.open(url, name, params); + + if(window.focus) { + phWindow.focus(); + } + return false; +} \ No newline at end of file diff --git a/models/fields/phocacartcategory.php b/models/fields/phocacartcategory.php index 9ba475ca..ba5165d1 100644 --- a/models/fields/phocacartcategory.php +++ b/models/fields/phocacartcategory.php @@ -11,6 +11,12 @@ if (! class_exists('PhocaCartCategory')) { require_once( JPATH_ADMINISTRATOR.'/components/com_phocacart/libraries/phocacart/category/category.php'); } +if (! class_exists('PhocaCartCategoryMultiple')) { + require_once( JPATH_ADMINISTRATOR.'/components/com_phocacart/libraries/phocacart/category/categorymultiple.php'); +} + +$lang = JFactory::getLanguage(); +$lang->load('com_phocacart'); class JFormFieldPhocaCartCategory extends JFormField { @@ -52,8 +58,8 @@ protected function getInput() { $db->setQuery( $query ); $data = $db->loadObjectList(); - // TODO - check for other views than category edit - $view = JRequest::getVar( 'view' ); + // TO DO - check for other views than category edit + $view = JFactory::getApplication()->input->get( 'view' ); $catId = -1; if ($view == 'phocacartcategory') { $id = $this->form->getValue('id'); // id of current category diff --git a/models/fields/phocacartfeed.php b/models/fields/phocacartfeed.php index 0563d3df..6caa45a8 100644 --- a/models/fields/phocacartfeed.php +++ b/models/fields/phocacartfeed.php @@ -26,7 +26,7 @@ protected function getInput() { $data = $db->loadObjectList(); - // $view = JRequest::getVar( 'view' ); + // $view = JFactory::getApplication()->input->get( 'view' ); //$required = ((string) $this->element['required'] == 'true') ? TRUE : FALSE; diff --git a/models/fields/phocapaymentmethod.php b/models/fields/phocapaymentmethod.php index b73037ae..ade623d9 100644 --- a/models/fields/phocapaymentmethod.php +++ b/models/fields/phocapaymentmethod.php @@ -25,7 +25,7 @@ protected function getInput() { $s[] = 'function phLoadParams(value) {'; $s[] = ' var url = \''.$url.'\''; - $s[] = ' var phAjax = \'
'. JHtml::_( 'image', 'media/com_phocacart/images/administrator/icon-loading5.gif', ''). '   \' + \''. htmlspecialchars($text).'\' + \'
\';'; + $s[] = ' var phAjax = \'
\' + \''. htmlspecialchars($text).'\' + \'
\';'; $s[] = ' jQuery("#ph-extended-params-msg").html(phAjax);'; $s[] = ' jQuery("#ph-extended-params-msg").show();'; $s[] = ' jQuery("#ph-extended-params").show();'; diff --git a/models/fields/phocaselectfilename.php b/models/fields/phocaselectfilename.php index 860c0aec..8e968699 100644 --- a/models/fields/phocaselectfilename.php +++ b/models/fields/phocaselectfilename.php @@ -20,14 +20,84 @@ protected function getInput() { $textButton = 'COM_PHOCACART_FORM_SELECT_'.strtoupper($group['t']); $link = 'index.php?option=com_phocacart&view=phocacartmanager'.$group['c'].$managerOutput.'&field='.$this->id; - $attr = $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : ''; - $attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : ''; - $onchange = (string) $this->element['onchange']; + $onchange = (string) $this->element['onchange']; + $size = ($v = $this->element['size']) ? ' size="' . $v . '"' : ''; + $class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"'; + $required = ($v = $this->element['required']) ? ' required="required"' : ''; + $idA = 'phFileNameModal'; + $w = 700; + $h = 400; + + + JHtml::_('jquery.framework'); + + if ($this->element['manager'] == 'productfile') { + + // This function selects the right folder when clicking on selecting e.g. download file + // Set by the folder stored in download tab in product edit + $s = array(); + //$s[] = 'var phDownloadFolderModal'.$this->id.' = \'\';'; + $s[] = 'jQuery(document).ready(function() {'; + // Mootools + //$s[] = ' var phDownloadFolder = jQuery(\'#jform_download_folder\').val();'; + //$s[] = ' phDownloadFolderModal'.$this->id.' = "&folder=" + phDownloadFolder + "&downloadfolder=" + phDownloadFolder;'; + //$s[] = ' stringToSend = "&folder=" + phDownloadFolder + "&downloadfolder=" + phDownloadFolder;'; + //$s[] = ' alert(stringToSend);var newUri = jQuery(\'.modal_jform_download_file\').attr(\'href\') + stringToSend;'; + //$s[] = ' jQuery(\'.modal_jform_download_file\').attr("href", newUri);'; + + $s[] = ' jQuery(\'a.'.$idA.'ModalButton\').on(\'click\', function(e) {'; + $s[] = ' var src = jQuery(this).attr(\'data-src\');'; + $s[] = ' var phDownloadFolder = jQuery(\'#jform_download_folder\').val();'; + $s[] = ' src = src + "&folder=" + phDownloadFolder + "&downloadfolder=" + phDownloadFolder;'; + $s[] = ' var height = jQuery(this).attr(\'data-height\') || '.$w.';'; + $s[] = ' var width = jQuery(this).attr(\'data-width\') || '.$h.';'; + $s[] = ' jQuery("#'.$idA.' iframe").attr({\'src\':src, \'height\': height, \'width\': width});'; + $s[] = ' });'; + + $s[] = '})'; + JFactory::getDocument()->addScriptDeclaration(implode("\n", $s)); + + + $s = array(); + $s[] = ' function phocaSelectFileName_'.$this->id.'(title) {'; + $s[] = ' document.getElementById("'.$this->id.'").value = title;'; + $s[] = ' '.$onchange; + $s[] = ' jQuery(\'.modal\').modal(\'hide\');'; + //$s[] = ' SqueezeBox.close();'; + $s[] = ' }'; + JFactory::getDocument()->addScriptDeclaration(implode("\n", $s)); + } + + + + $html[] = ''; + $html[] = ' ' + . ' ' + . JText::_($textButton) . ''; + $html[] = JHtml::_( + 'bootstrap.renderModal', + $idA, + array( + //'url' => $link . '\' + (phDownloadFolderModal'.$this->id.') + \'', + 'title' => JText::_($textButton), + 'width' => $w.'px', + 'height' => $h.'px', + 'modalWidth' => '80', + 'bodyHeight' => '70', + 'footer' => '' + ), + '' + ); - JHtml::_('behavior.modal', 'a.modal_'.$this->id); + return implode("\n", $html); + + + /*JHtml::_('behavior.modal', 'a.modal_'.$this->id); if ($this->element['manager'] == 'productfile') { - PhocaCartRenderJs::renderJsAppendValueToUrl(/* TODO*/); + PhocaCartRenderJs::renderJsAppendValueToUrl(/* TO DO*//*); $s = array(); $s[] = ' function phocaSelectFileName_'.$this->id.'(title) {'; $s[] = ' document.getElementById("'.$this->id.'").value = title;'; @@ -46,7 +116,7 @@ protected function getInput() { $html[] = ''. "\n"; - return implode("\n", $html); + return implode("\n", $html);*/ } } ?> \ No newline at end of file diff --git a/models/fields/phocaselectfilenameimage.php b/models/fields/phocaselectfilenameimage.php index 94720122..0d916d58 100644 --- a/models/fields/phocaselectfilenameimage.php +++ b/models/fields/phocaselectfilenameimage.php @@ -14,17 +14,58 @@ class JFormFieldPhocaSelectFilenameImage extends JFormField public $type = 'PhocaSelectFileNameImage'; protected function getInput() { + $html = array(); $managerOutput = $this->element['manager'] ? '&manager='.(string) $this->element['manager'] : ''; $group = PhocaCartSettings::getManagerGroup((string) $this->element['manager']); $textButton = 'COM_PHOCACART_FORM_SELECT_'.strtoupper($group['t']); + $link = 'index.php?option=com_phocacart&view=phocacartmanager'.$group['c'].$managerOutput.'&field='.$this->id; + + $onchange = (string) $this->element['onchange']; + $size = ($v = $this->element['size']) ? ' size="' . $v . '"' : ''; + $class = ($v = $this->element['class']) ? ' class="' . $v . '"' : 'class="text_area"'; + $required = ($v = $this->element['required']) ? ' required="required"' : ''; + $idA = 'phFileImageNameModal'; + + JHtml::_('jquery.framework'); + + $html[] = ''; + $html[] = '' + . ' ' + . JText::_($textButton) . ''; + $html[] = JHtml::_( + 'bootstrap.renderModal', + $idA, + array( + 'url' => $link, + 'title' => JText::_($textButton), + 'width' => '700px', + 'height' => '400px', + 'modalWidth' => '80', + 'bodyHeight' => '70', + 'footer' => '' + ) + ); - $attr = $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : ''; - $attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : ''; - $onchange = (string) $this->element['onchange']; + return implode("\n", $html); + + // HIDDEN FIELDS + //readonly="readonly" + // We don't use hidden field name, we can edit it the filename form field, there are three ways of adding filename: + // - manually typed + // - selected by image select box + // - added per YouTube import + // + // The name="' . $this->name . '" is used above in standard input form + // + //$html[] = ''; - JHtml::_('behavior.modal', 'a.modal_'.$this->id); + // MOOTOOLS + /*JHtml::_('behavior.modal', 'a.modal_'.$this->id); $html[] = '
'; $html[] = ''; @@ -34,7 +75,7 @@ protected function getInput() { . JText::_($textButton).''; $html[] = '
'. "\n"; - return implode("\n", $html); + return implode("\n", $html);*/ } } ?> \ No newline at end of file diff --git a/models/fields/phocaselectitem.php b/models/fields/phocaselectitem.php index dce62c77..448bd4fd 100644 --- a/models/fields/phocaselectitem.php +++ b/models/fields/phocaselectitem.php @@ -57,6 +57,7 @@ protected function getInput() { if ((int)$id > 0) { $relatedOption = PhocaCartRelated::getRelatedItemsById((int)$id); + if(!empty($relatedOption)) { $i = 0; foreach($relatedOption as $k => $v) { diff --git a/models/forms/phocacartcountry.xml b/models/forms/phocacartcountry.xml index 08e29bab..8893d33a 100644 --- a/models/forms/phocacartcountry.xml +++ b/models/forms/phocacartcountry.xml @@ -12,6 +12,8 @@ + + diff --git a/models/forms/phocacartcurrency.xml b/models/forms/phocacartcurrency.xml index f3f248cc..0b975a3d 100644 --- a/models/forms/phocacartcurrency.xml +++ b/models/forms/phocacartcurrency.xml @@ -28,6 +28,8 @@ + + diff --git a/models/forms/phocacartitem.xml b/models/forms/phocacartitem.xml index 87f5251f..aa4c5f40 100644 --- a/models/forms/phocacartitem.xml +++ b/models/forms/phocacartitem.xml @@ -52,6 +52,7 @@ + diff --git a/models/forms/phocacartquestion.xml b/models/forms/phocacartquestion.xml new file mode 100644 index 00000000..e33f8401 --- /dev/null +++ b/models/forms/phocacartquestion.xml @@ -0,0 +1,47 @@ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
+ + +
diff --git a/models/forms/phocacartregion.xml b/models/forms/phocacartregion.xml index ed650850..b6ba1b3c 100644 --- a/models/forms/phocacartregion.xml +++ b/models/forms/phocacartregion.xml @@ -14,6 +14,8 @@ + + diff --git a/models/forms/phocacartwishlist.xml b/models/forms/phocacartwishlist.xml new file mode 100644 index 00000000..28097adf --- /dev/null +++ b/models/forms/phocacartwishlist.xml @@ -0,0 +1,38 @@ + +
+ +
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
+ + +
diff --git a/models/phocacartcategories.php b/models/phocacartcategories.php index 9503548e..b52980e5 100644 --- a/models/phocacartcategories.php +++ b/models/phocacartcategories.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartCategories extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; protected $total = 0; public function __construct($config = array()) { diff --git a/models/phocacartcategory.php b/models/phocacartcategory.php index 165b6441..648bff1e 100644 --- a/models/phocacartcategory.php +++ b/models/phocacartcategory.php @@ -131,10 +131,10 @@ public function delete(&$cid = array()) { if (!$this->canDelete($table)){ $error = $this->getError(); if ($error){ - JLog::add($error, JLog::WARNING, 'jerror'); + JLog::add($error, JLog::WARNING); return false; } else { - JLog::add(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), JLog::WARNING, 'jerror'); + JLog::add(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), JLog::WARNING); return false; } } @@ -149,7 +149,7 @@ public function delete(&$cid = array()) { $db->setQuery( $query ); if (!($rows2 = $db->loadObjectList())) { - JError::raiseError( 500, $db->stderr('Load Data Problem') ); + throw new Exception( $db->stderr('Load Data Problem'), 500 ); return false; } @@ -165,13 +165,13 @@ public function delete(&$cid = array()) { } // - - - - - - - - - - - - - - - - // Images with new cid - - - - - + // Product with new cid - - - - - if (count( $cid )) { JArrayHelper::toInteger($cid); $cids = implode( ',', $cid ); // Select id's from product table, if there are some items, don't delete it. - $query = 'SELECT c.id, c.title, COUNT( s.category_id ) AS numcat' + $query = 'SELECT c.id, c.title, COUNT( s.category_id ) AS numproduct' . ' FROM #__phocacart_categories AS c' . ' LEFT JOIN #__phocacart_product_categories AS s ON s.category_id = c.id' . ' WHERE c.id IN ( '.$cids.' )' @@ -180,14 +180,15 @@ public function delete(&$cid = array()) { $db->setQuery( $query ); if (!($rows = $db->loadObjectList())) { - JError::raiseError( 500, $db->stderr('Load Data Problem') ); + throw new Exception( $db->stderr('Load Data Problem'), 500 ); return false; } + $err_img = array(); $cid = array(); foreach ($rows as $row) { - if ($row->numcat == 0) { + if ($row->numproduct == 0) { $cid[] = (int) $row->id; } else { $err_img[] = $row->title; @@ -273,7 +274,7 @@ protected function batchCopy($value, $pks, $contexts) } // Check that the user has create permission for the component - $extension = JRequest::getCmd('option'); + $extension = JFactory::getApplication()->input->get('option'); $user = JFactory::getUser(); if (!$user->authorise('core.create', $extension)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE')); @@ -376,7 +377,7 @@ protected function batchMove($value, $pks, $contexts) } // Check that user has create and edit permission for the component - $extension = JRequest::getCmd('option'); + $extension = JFactory::getApplication()->input->get('option'); $user = JFactory::getUser(); if (!$user->authorise('core.create', $extension)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE')); diff --git a/models/phocacartcountries.php b/models/phocacartcountries.php index 62569749..a0cdec8b 100644 --- a/models/phocacartcountries.php +++ b/models/phocacartcountries.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartCountries extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { diff --git a/models/phocacartcountry.php b/models/phocacartcountry.php index 7f0cf302..9fbcfde3 100644 --- a/models/phocacartcountry.php +++ b/models/phocacartcountry.php @@ -118,7 +118,8 @@ public function importcountries() { if ($query != '' && $query{0} != '#'){ $db->setQuery($query); if (!$db->execute()){ - JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), JLog::WARNING, 'jerror'); + $app->enqueueMessage(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), 'error'); + JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), JLog::WARNING); return false; } } diff --git a/models/phocacartcoupon.php b/models/phocacartcoupon.php index 688723e2..2d1fbc76 100644 --- a/models/phocacartcoupon.php +++ b/models/phocacartcoupon.php @@ -43,6 +43,13 @@ protected function loadFormData() { return $data; } + public function getItem($pk = null) { + if ($item = parent::getItem($pk)) { + $item->discount = PhocaCartPrice::cleanPrice($item->discount); + } + return $item; + } + protected function prepareTable($table) { jimport('joomla.filter.output'); $date = JFactory::getDate(); diff --git a/models/phocacartcoupons.php b/models/phocacartcoupons.php index 7f48cddd..6b0d14b0 100644 --- a/models/phocacartcoupons.php +++ b/models/phocacartcoupons.php @@ -10,8 +10,8 @@ jimport('joomla.application.component.modellist'); class PhocaCartCpModelPhocaCartCoupons extends JModelList -{ - protected $option = 'com_phocacart'; +{ + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacartcurrencies.php b/models/phocacartcurrencies.php index 9e884ac5..0940087c 100644 --- a/models/phocacartcurrencies.php +++ b/models/phocacartcurrencies.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartCurrencies extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacartdownloads.php b/models/phocacartdownloads.php index eb81a624..aeced430 100644 --- a/models/phocacartdownloads.php +++ b/models/phocacartdownloads.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartDownloads extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacarteditstatus.php b/models/phocacarteditstatus.php index c87d11d0..b031dcda 100644 --- a/models/phocacarteditstatus.php +++ b/models/phocacarteditstatus.php @@ -103,6 +103,8 @@ public function editStatus($data) { $notifyOther = 1; } + + $notify = PhocaCartOrderStatus::changeStatus((int)$data['id'], (int)$data['status_id'], '', $notifyUser, $notifyOther, (int)$data['email_send'], $data['stock_movements']); PhocaCartOrderStatus::setHistory((int)$data['id'], (int)$data['status_id'], (int)$notify, $data['comment']); diff --git a/models/phocacartfeeds.php b/models/phocacartfeeds.php index 649ceacc..9e35e348 100644 --- a/models/phocacartfeeds.php +++ b/models/phocacartfeeds.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartFeeds extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacartformfield.php b/models/phocacartformfield.php index 023c7cf6..0de661ac 100644 --- a/models/phocacartformfield.php +++ b/models/phocacartformfield.php @@ -97,7 +97,7 @@ function displayItem(&$pks, $value = 1, $column = 'display_billing') { if ($table->load($pk)) { if (!$this->canEditState($table)) { unset($pks[$i]); - JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDIT_STATE_NOT_PERMITTED')); + $this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); } } } diff --git a/models/phocacartformfields.php b/models/phocacartformfields.php index b586bce3..c1b17d55 100644 --- a/models/phocacartformfields.php +++ b/models/phocacartformfields.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartFormfields extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { diff --git a/models/phocacartitem.php b/models/phocacartitem.php index 96e10f80..86cc1a5b 100644 --- a/models/phocacartitem.php +++ b/models/phocacartitem.php @@ -70,6 +70,18 @@ public function getItem($pk = null) { $registry = new JRegistry; $registry->loadString($item->metadata); $item->metadata = $registry->toArray(); + + // Make the numbers more readable + // it has no influence on saving it to db + $item->price = PhocaCartPrice::cleanPrice($item->price); + $item->price_original = PhocaCartPrice::cleanPrice($item->price_original); + $item->length = PhocaCartPrice::cleanPrice($item->length); + $item->width = PhocaCartPrice::cleanPrice($item->width); + $item->height = PhocaCartPrice::cleanPrice($item->height); + $item->weight = PhocaCartPrice::cleanPrice($item->weight); + $item->volume = PhocaCartPrice::cleanPrice($item->volume); + $item->unit_amount = PhocaCartPrice::cleanPrice($item->unit_amount); + } return $item; @@ -82,6 +94,8 @@ protected function prepareTable($table) { $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); $table->alias = JApplication::stringURLSafe($table->alias); + + if (empty($table->alias)) { $table->alias = JApplication::stringURLSafe($table->title); @@ -254,10 +268,10 @@ public function delete(&$cid = array()) { if (!$this->canDelete($table)){ $error = $this->getError(); if ($error){ - JLog::add($error, JLog::WARNING, 'jerror'); + JLog::add($error, JLog::WARNING); return false; } else { - JLog::add(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), JLog::WARNING, 'jerror'); + JLog::add(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), JLog::WARNING); return false; } } @@ -325,6 +339,12 @@ public function delete(&$cid = array()) { $this->_db->setQuery( $query ); $this->_db->execute(); + // 8. DELETE SPECIFICATIONS + $query = 'DELETE FROM #__phocacart_specifications' + . ' WHERE product_id IN ( '.$cids.' )'; + $this->_db->setQuery( $query ); + $this->_db->execute(); + } return true; } @@ -363,7 +383,7 @@ protected function batchCopy($value, $pks, $contexts) } // Check that the user has create permission for the component - $extension = JRequest::getCmd('option'); + $extension = JFactory::getApplication()->input->get('option'); $user = JFactory::getUser(); if (!$user->authorise('core.create', $extension)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE')); @@ -492,7 +512,7 @@ protected function batchMove($value, $pks, $contexts) } // Check that user has create and edit permission for the component - $extension = JRequest::getCmd('option'); + $extension = JFactory::getApplication()->input->get('option'); $user = JFactory::getUser(); if (!$user->authorise('core.create', $extension)) { $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE')); @@ -736,7 +756,8 @@ public function saveorder($pks = null, $order = null) if (empty($pks)) { - return JError::raiseWarning(500, JText::_($this->text_prefix . '_ERROR_NO_ITEMS_SELECTED')); + return $app->enqueueMessage(JText::_($this->text_prefix.'_ERROR_NO_ITEMS_SELECTED'), 'error'); + } // Update ordering values @@ -751,7 +772,7 @@ public function saveorder($pks = null, $order = null) { // Prune items that you can't change. unset($pks[$i]); - JLog::add(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), JLog::WARNING, 'jerror'); + JLog::add(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), JLog::WARNING); } elseif ($table->ordering != $order[$i]) { diff --git a/models/phocacartitems.php b/models/phocacartitems.php index a214b5fe..e698c0bd 100644 --- a/models/phocacartitems.php +++ b/models/phocacartitems.php @@ -13,7 +13,7 @@ class PhocaCartCpModelPhocaCartItems extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { diff --git a/models/phocacartlogs.php b/models/phocacartlogs.php index d33149f8..b5716a98 100644 --- a/models/phocacartlogs.php +++ b/models/phocacartlogs.php @@ -13,7 +13,7 @@ class PhocaCartCpModelPhocaCartLogs extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { diff --git a/models/phocacartmanager.php b/models/phocacartmanager.php index 845d92f3..8e5c34cc 100644 --- a/models/phocacartmanager.php +++ b/models/phocacartmanager.php @@ -13,7 +13,7 @@ class PhocaCartCpModelPhocaCartManager extends JModelAdmin { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; protected $text_prefix = 'com_phocacart'; public function getTable($type = 'PhocaCartCategory', $prefix = 'Table', $config = array()) { @@ -42,9 +42,10 @@ function getFolderState($property = null) { static $set; if (!$set) { - $folder = JRequest::getVar( 'folder', '', '', 'path' ); - $upload = JRequest::getVar( 'upload', '', '', 'int' ); - $manager = JRequest::getVar( 'manager', '', '', 'path' ); + $app = JFactory::getApplication(); + $folder = $app->input->get( 'folder', '', 'path' ); + $upload = $app->input->get( 'upload', '', 'int' ); + $manager = $app->input->get( 'manager', '', 'path' ); $this->setState('folder', $folder); $this->setState('manager', $manager); @@ -99,15 +100,15 @@ function getList() { } else { $orig_path = $path['orig_abs_ds']; } - $orig_path_server = str_replace(DS, '/', $path['orig_abs'] .'/'); + $orig_path_server = str_replace('\\', '/', $path['orig_abs'] .'/'); // Absolute Path defined by user $absolutePath = $params->get('absolute_path', ''); - $absolutePath = str_replace(DS, '/', $absolutePath); + $absolutePath = str_replace('\\', '/', $absolutePath); // Be aware - absolute path is not set for images folder and for preview and play folder - see documentation if ($absolutePath != '' && $group['f'] == 1) { - $orig_path_server = str_replace(DS, '/', JPath::clean($absolutePath .'/') );//$absolutePath ; + $orig_path_server = str_replace('\\', '/', JPath::clean($absolutePath .'/') );//$absolutePath ; } $files = array (); @@ -125,13 +126,13 @@ function getList() { //file - abc.img, file_no - folder/abc.img if ($file_list !== false) { foreach ($file_list as $file) { - if (is_file($orig_path.DS.$file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') { + if (is_file($orig_path.'/'.$file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') { $tmp = new JObject(); $tmp->name = basename($file); - $tmp->path_with_name = str_replace(DS, '/', JPath::clean($orig_path . DS . $file)); + $tmp->path_with_name = str_replace('\\', '/', JPath::clean($orig_path . '/' . $file)); $tmp->path_without_name_relative= $path['orig_rel_ds'] . str_replace($orig_path_server, '', $tmp->path_with_name); - $tmp->path_with_name = str_replace(DS, '/', JPath::clean($orig_path . DS . $file)); + $tmp->path_with_name = str_replace('\\', '/', JPath::clean($orig_path . '/' . $file)); $tmp->path_with_name_relative_no= str_replace($orig_path_server, '', $tmp->path_with_name); $files[] = $tmp; @@ -146,7 +147,7 @@ function getList() { { $tmp = new JObject(); $tmp->name = basename($folder); - $tmp->path_with_name = str_replace(DS, '/', JPath::clean($orig_path . DS . $folder)); + $tmp->path_with_name = str_replace('\\', '/', JPath::clean($orig_path . '/' . $folder)); $tmp->path_without_name_relative= $path['orig_rel_ds'] . str_replace($orig_path_server, '', $tmp->path_with_name); $tmp->path_with_name_relative_no= str_replace($orig_path_server, '', $tmp->path_with_name); diff --git a/models/phocacartmanufacturers.php b/models/phocacartmanufacturers.php index c5ce0305..be530404 100644 --- a/models/phocacartmanufacturers.php +++ b/models/phocacartmanufacturers.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartManufacturers extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacartorder.php b/models/phocacartorder.php index f7aa6165..2ab483b6 100644 --- a/models/phocacartorder.php +++ b/models/phocacartorder.php @@ -86,7 +86,7 @@ protected function prepareTable($table) {} public function save($data) { $app = JFactory::getApplication(); - if (!JRequest::checkToken('request')) { + if (!JSession::checkToken('request')) { $app->enqueueMessage('Invalid Token', 'message'); return false; } diff --git a/models/phocacartorders.php b/models/phocacartorders.php index f811d090..488f65d5 100644 --- a/models/phocacartorders.php +++ b/models/phocacartorders.php @@ -3,7 +3,7 @@ * @package Joomla.Framework * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt - * + * * @component Phoca Component * @copyright Copyright (C) Jan Pavelka www.phoca.cz * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License version 2 or later; @@ -13,7 +13,7 @@ class PhocaCartCpModelPhocaCartOrders extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { diff --git a/models/phocacartparama.php b/models/phocacartparama.php index 6328e081..e473526f 100644 --- a/models/phocacartparama.php +++ b/models/phocacartparama.php @@ -81,7 +81,7 @@ protected function preprocessForm(JForm $form, $data, $group = 'pcp') { // Try 1.5 format: /plugins/folder/element/element.xml $formFile = JPath::clean($client->path.'/plugins/'.$folder.'/'.$element.'.xml'); if (!file_exists($formFile)) { - throw new Exception(JText::sprintf('JError_File_not_found', $element.'.xml')); + throw new Exception(JText::sprintf('COM_PHOCACART_ERROR_FILE_NOT_FOUND', $element.'.xml')); return false; } } @@ -95,13 +95,13 @@ protected function preprocessForm(JForm $form, $data, $group = 'pcp') { if (file_exists($formFile)) { // Get the plugin form. if (!$form->loadFile($formFile, false, '//form')) { - throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); + throw new Exception(JText::_('COM_PHOCACART_ERROR_LOADFILE_FAILED')); } } // Attempt to load the xml file. if (!$xml = simplexml_load_file($formFile)) { - throw new Exception(JText::_('JERROR_LOADFILE_FAILED')); + throw new Exception(JText::_('COM_PHOCACART_ERROR_LOADFILE_FAILED')); } // Get the help data from the XML file if present. diff --git a/models/phocacartpayments.php b/models/phocacartpayments.php index 73280a10..e7bea0e9 100644 --- a/models/phocacartpayments.php +++ b/models/phocacartpayments.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartPayments extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacartquestion.php b/models/phocacartquestion.php new file mode 100644 index 00000000..68dea519 --- /dev/null +++ b/models/phocacartquestion.php @@ -0,0 +1,105 @@ +loadForm('com_phocacart.phocacartquestion', 'phocacartquestion', array('control' => 'jform', 'load_data' => $loadData)); + if (empty($form)) { + return false; + } + return $form; + } + + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_phocacart.edit.phocacartquestion.data', array()); + + if (empty($data)) { + $data = $this->getItem(); + } + + return $data; + } + + protected function prepareTable($table) + { + jimport('joomla.filter.output'); + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); + $table->alias = JApplication::stringURLSafe($table->alias); + + if (empty($table->alias)) { + $table->alias = JApplication::stringURLSafe($table->title); + } + + if (empty($table->id)) { + // Set the values + //$table->created = $date->toSql(); + + // Set ordering to the last item if not set + if (empty($table->ordering)) { + $db = JFactory::getDbo(); + $db->setQuery('SELECT MAX(ordering) FROM #__phocacart_questions WHERE product_id = '. (int) $table->product_id); + $max = $db->loadResult(); + + $table->ordering = $max+1; + } + } + else { + // Set the values + //$table->modified = $date->toSql(); + //$table->modified_by = $user->get('id'); + } + } + + protected function getReorderConditions($table = null) + { + $condition = array(); + $condition[] = 'product_id = '. (int) $table->product_id; + return $condition; + } + /* + public function increaseOrdering($productId) { + + $ordering = 1; + $this->_db->setQuery('SELECT MAX(ordering) FROM #__phocacart_reviews WHERE product_id='.(int)$productId); + $max = $this->_db->loadResult(); + $ordering = $max + 1; + return $ordering; + }*/ +} +?> \ No newline at end of file diff --git a/models/phocacartquestions.php b/models/phocacartquestions.php new file mode 100644 index 00000000..af372e76 --- /dev/null +++ b/models/phocacartquestions.php @@ -0,0 +1,151 @@ +getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + +/* $accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int'); + $this->setState('filter.access', $accessId);*/ + + + + $state = $app->getUserStateFromRequest($this->context.'.filter.state', 'filter_published', '', 'string'); + $this->setState('filter.state', $state); + + //$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', ''); + //$this->setState('filter.language', $language); + + // Load the parameters. + $params = JComponentHelper::getParams('com_phocacart'); + $this->setState('params', $params); + + // List state information. + parent::populateState('a.name', 'asc'); + } + + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':'.$this->getState('filter.search'); + //$id .= ':'.$this->getState('filter.access'); + $id .= ':'.$this->getState('filter.state'); + $id .= ':'.$this->getState('filter.question_id'); + + + return parent::getStoreId($id); + } + + protected function getListQuery() { + + $db = $this->getDbo(); + $query = $db->getQuery(true); + + // Select the required fields from the table. + $query->select( + $this->getState( + 'list.select', + 'a.*' + ) + ); + $query->from('`#__phocacart_questions` AS a'); + + $query->select('p.title AS productname'); + $query->join('LEFT', '#__phocacart_products AS p ON p.id=a.product_id'); + + $query->select('c.title AS cattitle, c.id AS catid'); + $query->join('LEFT', '#__phocacart_categories AS c ON c.id=a.category_id'); + + // Join over the language + //$query->select('l.title AS language_title'); + //$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language'); + + $query->select('ua.id AS questionuserid, ua.username AS questionusername, ua.name AS questionname'); + $query->join('LEFT', '#__users AS ua ON ua.id=a.user_id'); + + // Join over the users for the checked out user. + $query->select('uc.name AS editor'); + $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); + + + // Filter by access level. +/* if ($access = $this->getState('filter.access')) { + $query->where('a.access = '.(int) $access); + }*/ + + + + // Filter by published state. + $published = $this->getState('filter.state'); + if (is_numeric($published)) { + $query->where('a.published = '.(int) $published); + } + else if ($published === '') { + $query->where('(a.published IN (0, 1))'); + } + + + // Filter by search in title + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) { + $query->where('a.id = '.(int) substr($search, 3)); + } + else + { + $search = $db->Quote('%'.$db->escape($search, true).'%'); + $query->where('( a.name LIKE '.$search.' OR a.message LIKE '.$search.' OR productname LIKE '.$search.')'); + } + } + + $orderCol = $this->state->get('list.ordering', 'productname'); + $orderDirn = $this->state->get('list.direction', 'asc'); + $query->order($db->escape($orderCol.' '.$orderDirn)); + + //echo nl2br(str_replace('#__', 'jos_', $query->__toString())); + + return $query; + } +} +?> \ No newline at end of file diff --git a/models/phocacartregion.php b/models/phocacartregion.php index 192eb05c..24546222 100644 --- a/models/phocacartregion.php +++ b/models/phocacartregion.php @@ -127,7 +127,7 @@ public function importregions() { if ($query != '' && $query{0} != '#'){ $db->setQuery($query); if (!$db->execute()){ - JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), JLog::WARNING, 'jerror'); + JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), JLog::WARNING); return false; } } diff --git a/models/phocacartregions.php b/models/phocacartregions.php index 77a3cbdf..b39e9456 100644 --- a/models/phocacartregions.php +++ b/models/phocacartregions.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartRegions extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { diff --git a/models/phocacartreviews.php b/models/phocacartreviews.php index 6e630de7..efb993c3 100644 --- a/models/phocacartreviews.php +++ b/models/phocacartreviews.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartReviews extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { diff --git a/models/phocacartshippings.php b/models/phocacartshippings.php index ab9fdecd..09a5031c 100644 --- a/models/phocacartshippings.php +++ b/models/phocacartshippings.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartShippings extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacartspecifications.php b/models/phocacartspecifications.php index 009c8a3d..94523c80 100644 --- a/models/phocacartspecifications.php +++ b/models/phocacartspecifications.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartSpecifications extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { diff --git a/models/phocacartstatistics.php b/models/phocacartstatistics.php index df4fb863..b98abd30 100644 --- a/models/phocacartstatistics.php +++ b/models/phocacartstatistics.php @@ -13,7 +13,7 @@ class PhocaCartCpModelPhocaCartStatistics extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { diff --git a/models/phocacartstatuses.php b/models/phocacartstatuses.php index 0efca971..26a39219 100644 --- a/models/phocacartstatuses.php +++ b/models/phocacartstatuses.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartStatuses extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacartstockstatuses.php b/models/phocacartstockstatuses.php index f5b72bec..38b679a6 100644 --- a/models/phocacartstockstatuses.php +++ b/models/phocacartstockstatuses.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartStockStatuses extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacarttags.php b/models/phocacarttags.php index d464f882..1759e554 100644 --- a/models/phocacarttags.php +++ b/models/phocacarttags.php @@ -11,8 +11,8 @@ class PhocaCartCpModelPhocaCartTags extends JModelList { - protected $option = 'com_phocacart'; - + protected $option = 'com_phocacart'; + public function __construct($config = array()) { if (empty($config['filter_fields'])) { $config['filter_fields'] = array( diff --git a/models/phocacarttax.php b/models/phocacarttax.php index 7ffcf874..14f96a06 100644 --- a/models/phocacarttax.php +++ b/models/phocacarttax.php @@ -53,6 +53,13 @@ protected function loadFormData() return $data; } + public function getItem($pk = null) { + if ($item = parent::getItem($pk)) { + $item->tax_rate = PhocaCartPrice::cleanPrice($item->tax_rate); + } + return $item; + } + protected function prepareTable($table) { jimport('joomla.filter.output'); diff --git a/models/phocacartusers.php b/models/phocacartusers.php index bf3e9adf..2d1d3d3b 100644 --- a/models/phocacartusers.php +++ b/models/phocacartusers.php @@ -11,7 +11,7 @@ class PhocaCartCpModelPhocaCartUsers extends JModelList { - protected $option = 'com_phocacart'; + protected $option = 'com_phocacart'; public function __construct($config = array()) { if (empty($config['filter_fields'])) { diff --git a/models/phocacartwishlist.php b/models/phocacartwishlist.php new file mode 100644 index 00000000..2d7ea5ed --- /dev/null +++ b/models/phocacartwishlist.php @@ -0,0 +1,105 @@ +loadForm('com_phocacart.phocacartwishlist', 'phocacartwishlist', array('control' => 'jform', 'load_data' => $loadData)); + if (empty($form)) { + return false; + } + return $form; + } + + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_phocacart.edit.phocacartwishlist.data', array()); + + if (empty($data)) { + $data = $this->getItem(); + } + + return $data; + } + + protected function prepareTable($table) + { + jimport('joomla.filter.output'); + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + $table->title = htmlspecialchars_decode($table->title, ENT_QUOTES); + $table->alias = JApplication::stringURLSafe($table->alias); + + if (empty($table->alias)) { + $table->alias = JApplication::stringURLSafe($table->title); + } + + if (empty($table->id)) { + // Set the values + //$table->created = $date->toSql(); + + // Set ordering to the last item if not set + if (empty($table->ordering)) { + $db = JFactory::getDbo(); + $db->setQuery('SELECT MAX(ordering) FROM #__phocacart_wishlists WHERE user_id = '. (int) $table->user_id); + $max = $db->loadResult(); + + $table->ordering = $max+1; + } + } + else { + // Set the values + //$table->modified = $date->toSql(); + //$table->modified_by = $user->get('id'); + } + } + + protected function getReorderConditions($table = null) + { + $condition = array(); + $condition[] = 'user_id = '. (int) $table->user_id; + return $condition; + } + /* + public function increaseOrdering($productId) { + + $ordering = 1; + $this->_db->setQuery('SELECT MAX(ordering) FROM #__phocacart_reviews WHERE product_id='.(int)$productId); + $max = $this->_db->loadResult(); + $ordering = $max + 1; + return $ordering; + }*/ +} +?> \ No newline at end of file diff --git a/models/phocacartwishlists.php b/models/phocacartwishlists.php new file mode 100644 index 00000000..e3af7df5 --- /dev/null +++ b/models/phocacartwishlists.php @@ -0,0 +1,148 @@ +getUserStateFromRequest($this->context.'.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + +/* $accessId = $app->getUserStateFromRequest($this->context.'.filter.access', 'filter_access', null, 'int'); + $this->setState('filter.access', $accessId);*/ + + + + $state = $app->getUserStateFromRequest($this->context.'.filter.state', 'filter_published', '', 'string'); + $this->setState('filter.state', $state); + + //$language = $app->getUserStateFromRequest($this->context.'.filter.language', 'filter_language', ''); + //$this->setState('filter.language', $language); + + // Load the parameters. + $params = JComponentHelper::getParams('com_phocacart'); + $this->setState('params', $params); + + // List state information. + parent::populateState('name', 'asc'); + } + + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':'.$this->getState('filter.search'); + //$id .= ':'.$this->getState('filter.access'); + $id .= ':'.$this->getState('filter.state'); + $id .= ':'.$this->getState('filter.wishlist_id'); + + + return parent::getStoreId($id); + } + + protected function getListQuery() { + + $db = $this->getDbo(); + $query = $db->getQuery(true); + + // Select the required fields from the table. + $query->select( + $this->getState( + 'list.select', + 'a.*' + ) + ); + $query->from('`#__phocacart_wishlists` AS a'); + + $query->select('p.title AS productname'); + $query->join('LEFT', '#__phocacart_products AS p ON p.id=a.product_id'); + + $query->select('c.title AS cattitle, c.id AS catid'); + $query->join('LEFT', '#__phocacart_categories AS c ON c.id=a.category_id'); + + // Join over the language + //$query->select('l.title AS language_title'); + //$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.language'); + + $query->select('ua.id AS userid, ua.username AS username, ua.name AS name'); + $query->join('LEFT', '#__users AS ua ON ua.id=a.user_id'); + + // Join over the users for the checked out user. + $query->select('uc.name AS editor'); + $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out'); + + + // Filter by access level. +/* if ($access = $this->getState('filter.access')) { + $query->where('a.access = '.(int) $access); + }*/ + + + + // Filter by published state. + $published = $this->getState('filter.state'); + if (is_numeric($published)) { + $query->where('a.published = '.(int) $published); + } + else if ($published === '') { + $query->where('(a.published IN (0, 1))'); + } + + + // Filter by search in title + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) { + $query->where('a.id = '.(int) substr($search, 3)); + } + else + { + $search = $db->Quote('%'.$db->escape($search, true).'%'); + $query->where('( name LIKE '.$search.' OR username LIKE '.$search.' OR productname LIKE '.$search.')'); + } + } + + $orderCol = $this->state->get('list.ordering', 'username'); + $orderDirn = $this->state->get('list.direction', 'asc'); + $query->order($db->escape($orderCol.' '.$orderDirn)); + + //echo nl2br(str_replace('#__', 'jos_', $query->__toString())); + + return $query; + } +} +?> \ No newline at end of file diff --git a/other/index.html b/other/index.html new file mode 100644 index 00000000..ea9e94c1 --- /dev/null +++ b/other/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/other/install_xml.php b/other/install_xml.php new file mode 100644 index 00000000..84edfb19 --- /dev/null +++ b/other/install_xml.php @@ -0,0 +1,111 @@ + "COM_PHOCACART", 1 => "option=com_phocacart", 2 => "media/com_phocacart/images/administrator/images/icon-16-cart-menu.png"); + +$t = 'COM_PHOCACART_CONTROLPANEL'; +$xml_submenu[] = array (0 => $t, 1 => "option=com_phocacart", 2 => $iP.'icon-16-pc-menu-cp.png', 3 => $t, 4 => 'phocacartcp'); + +$t = 'COM_PHOCACART_PRODUCTS';$v = 'phocacartitems'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-item.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_CATEGORIES';$v = 'phocacartcategories'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-category.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_SPECIFICATIONS';$v = 'phocacartspecifications'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-specification.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_MANUFACTURERS';$v = 'phocacartmanufacturers'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-manufacturer.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_ORDERS';$v = 'phocacartorders'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-order.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_ORDER_STATUSES';$v = 'phocacartstatuses'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-orderstatus.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_STOCK_STATUSES';$v = 'phocacartstockstatuses'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-stockstatus.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_SHIPPING';$v = 'phocacartshippings'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-shipping.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_COUNTRIES';$v = 'phocacartcountries'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-country.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_REGIONS';$v = 'phocacartregions'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-region.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_PAYMENT';$v = 'phocacartpayments'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-payment.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_CURRENCIES';$v = 'phocacartcurrencies'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-currency.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_TAXES';$v = 'phocacarttaxes'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-tax.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_USERS';$v = 'phocacartusers'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-user.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_FORM_FIELDS';$v = 'phocacartformfields'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-user.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_REVIEWS';$v = 'phocacartreviews'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-review.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_COUPONS';$v = 'phocacartcoupons'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-coupon.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_DOWNLOADS';$v = 'phocacartdownloads'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-download.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_TAGS';$v = 'phocacarttags'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-tag.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_XML_FEEDS';$v = 'phocacartfeeds'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-feeds.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_WISH_LISTS';$v = 'phocacartwishlists'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-wishlists.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_QUESTIONS';$v = 'phocacartquestions'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-questions.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_STATISTICS';$v = 'phocacartstatistics'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-statistics.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_SYSTEM_LOG';$v = 'phocacartlogs'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-log.png', 3 => $t, 4 => $v); + +$t = 'COM_PHOCACART_INFO';$v = 'phocacartinfo'; +$xml_submenu[] = array (0 => $t, 1 => 'option=com_phocacart&view='.$v, 2 => $iP.'icon-16-pc-menu-info.png', 3 => $t, 4 => $v); + +$xml_install_file = ''; +$xml_uninstall_file = ''; +/*********** XML PARAMETERS AND VALUES ************/ +?> \ No newline at end of file diff --git a/phocacart.php b/phocacart.php index ec2eb748..5e37923e 100644 --- a/phocacart.php +++ b/phocacart.php @@ -9,11 +9,11 @@ defined('_JEXEC') or die(); if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); if (!JFactory::getUser()->authorise('core.manage', 'com_phocacart')) { - return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); + throw new Exception(JText::_('COM_PHOCACART_ERROR_ALERTNOAUTHOR'), 404); } if (! class_exists('PhocaCartLoader')) { - require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_phocacart'.DS.'libraries'.DS.'loader.php'); + require_once( JPATH_ADMINISTRATOR.'/components/com_phocacart/libraries/loader.php'); } jimport('joomla.filesystem.folder'); @@ -24,6 +24,7 @@ phocacartimport('phocacart.utils.exception'); phocacartimport('phocacart.utils.log'); phocacartimport('phocacart.utils.batchhelper'); +phocacartimport('phocacart.utils.extension'); phocacartimport('phocacart.date.date'); phocacartimport('phocacart.path.path'); phocacartimport('phocacart.file.file'); diff --git a/phocacart.xml b/phocacart.xml index 74830bb1..ecae3e38 100644 --- a/phocacart.xml +++ b/phocacart.xml @@ -2,12 +2,12 @@ Phoca Cart Jan Pavelka (www.phoca.cz) - 26/04/2016 + 17/10/2016 www.phoca.cz Jan Pavelka GNU/GPL - 3.0.0 RC2 + 3.0.0 RC3 Phoca Cart install/script.php @@ -77,6 +77,8 @@ COM_PHOCACART_DOWNLOADS COM_PHOCACART_TAGS COM_PHOCACART_XML_FEEDS + COM_PHOCACART_WISH_LISTS + COM_PHOCACART_QUESTIONS COM_PHOCACART_STATISTICS COM_PHOCACART_SYSTEM_LOG COM_PHOCACART_INFO diff --git a/site/controller.php b/site/controller.php index 96abd1b3..9a223292 100644 --- a/site/controller.php +++ b/site/controller.php @@ -16,7 +16,7 @@ public function display($cachable = false, $urlparams = false) { if ( ! JFactory::getApplication()->input->get('view') ) { - JRequest::setVar('view', 'categories' ); + JFactory::getApplication()->input->set('view', 'categories' ); } /*if (JFactory::getApplication()->input->get('view') && JFactory::getApplication()->input->get('view') == 'feed') { // Default view for Feed is XML diff --git a/site/controllers/account.php b/site/controllers/account.php index 43a7813b..2e24e89b 100644 --- a/site/controllers/account.php +++ b/site/controllers/account.php @@ -32,7 +32,7 @@ public function saveprofile() // PHOCAEDIT jimport('joomla.application.component.model'); - //JLoader::import('user',JPATH_SITE.DS.'components'.DS.'com_users'.DS .'models'); + //JLoader::import('user',JPATH_SITE.'/components/com_users/models'); JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_users/models'); $model = JModelLegacy::getInstance( 'Profile', 'UsersModel' ); $this->data = $model->getData(); @@ -50,7 +50,7 @@ public function saveprofile() if (!$form) { - JError::raiseError(500, $model->getError()); + throw new Exception($model->getError(), 500); return false; } diff --git a/site/controllers/checkout.json.php b/site/controllers/checkout.json.php index bbe49f1b..ec25a7e4 100644 --- a/site/controllers/checkout.json.php +++ b/site/controllers/checkout.json.php @@ -13,7 +13,7 @@ class PhocaCartControllerCheckout extends JControllerForm // Set Region public function setregion() { - if (!JRequest::checkToken('request')) { + if (!JSession::checkToken('request')) { $response = array( 'status' => '0', 'error' => '
' . JText::_('JINVALID_TOKEN') . '
'); @@ -46,7 +46,7 @@ public function setregion() { // Change pricebox function changepricebox($tpl = null){ - if (!JRequest::checkToken('request')) { + if (!JSession::checkToken('request')) { $response = array( 'status' => '0', 'error' => '' . JText::_('JINVALID_TOKEN') . ''); @@ -126,7 +126,7 @@ function changepricebox($tpl = null){ $d['class'] = $class; // Original Price $d['priceitemsorig']['bruttoformat'] = ''; - if (isset($item->price_original) && $item->price_original != '') { + if (isset($item->price_original) && $item->price_original != '' && (int)$item->price_original >0) { $d['priceitemsorig']['bruttoformat'] = $price->getPriceFormat($item->price_original); } @@ -173,7 +173,7 @@ function changepricebox($tpl = null){ // Add item to cart function add($tpl = null){ - if (!JRequest::checkToken('request')) { + if (!JSession::checkToken('request')) { $response = array( 'status' => '0', 'error' => '' . JText::_('JINVALID_TOKEN') . ''); diff --git a/site/controllers/checkout.php b/site/controllers/checkout.php index c9a1a497..a2e2129c 100644 --- a/site/controllers/checkout.php +++ b/site/controllers/checkout.php @@ -11,11 +11,11 @@ class PhocaCartControllerCheckout extends JControllerForm { /* - * Add product to cart + * Add product to cart */ public function add() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); @@ -41,7 +41,7 @@ public function add() { * Change currency */ public function currency() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); @@ -61,7 +61,7 @@ public function currency() { public function saveaddress() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['return'] = $this->input->get( 'return', '', 'string' ); @@ -195,7 +195,7 @@ public function saveaddress() { public function saveshipping() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['return'] = $this->input->get( 'return', '', 'string' ); @@ -241,7 +241,7 @@ public function saveshipping() { public function savepayment() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['return'] = $this->input->get( 'return', '', 'string' ); @@ -309,7 +309,7 @@ public function savepayment() { */ public function update() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); @@ -345,7 +345,7 @@ public function update() { /* public function saveshipping() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['return'] = $this->input->get( 'return', '', 'string' ); @@ -375,7 +375,7 @@ public function saveshipping() { public function order() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['return'] = $this->input->get( 'return', '', 'string' ); @@ -412,7 +412,7 @@ public function order() { if ($action == 4 || $action == 3) { // Ordered OK, but now we proceed to payment $session->set('infomessage', $action, 'phocaCart'); - $app->redirect(JRoute::_(PhocaCartRoute::getPaymentRoute())); + $app->redirect(JRoute::_(PhocaCartRoute::getPaymentRoute(), false)); return true; // This message should stay // when order - the message is created @@ -426,7 +426,7 @@ public function order() { //$app->enqueueMessage($msg, 'message'); $session->set('infomessage', $action, 'phocaCart'); - $app->redirect(JRoute::_(PhocaCartRoute::getInfoRoute())); + $app->redirect(JRoute::_(PhocaCartRoute::getInfoRoute(), false)); return true; } } @@ -436,7 +436,7 @@ public function order() { public function setguest() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); @@ -465,7 +465,7 @@ public function setguest() { /* public function compareadd() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); @@ -484,7 +484,7 @@ public function compareadd() { public function compareremove() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); diff --git a/site/controllers/comparison.json.php b/site/controllers/comparison.json.php index f06546b4..3d1b3b0a 100644 --- a/site/controllers/comparison.json.php +++ b/site/controllers/comparison.json.php @@ -13,7 +13,7 @@ class PhocaCartControllerComparison extends JControllerForm public function add() { - if (!JRequest::checkToken('request')) { + if (!JSession::checkToken('request')) { $response = array( 'status' => '0', 'error' => '' . JText::_('JINVALID_TOKEN') . ''); @@ -21,7 +21,6 @@ public function add() { return; } - $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); @@ -85,7 +84,7 @@ public function add() { public function remove() { - if (!JRequest::checkToken('request')) { + if (!JSession::checkToken('request')) { $response = array( 'status' => '0', 'error' => '' . JText::_('JINVALID_TOKEN') . ''); diff --git a/site/controllers/comparison.php b/site/controllers/comparison.php index 747b51a4..531ec53a 100644 --- a/site/controllers/comparison.php +++ b/site/controllers/comparison.php @@ -11,9 +11,9 @@ class PhocaCartControllerComparison extends JControllerForm { - public function add() { + public function add() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); @@ -33,7 +33,7 @@ public function add() { public function remove() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); diff --git a/site/controllers/download.php b/site/controllers/download.php index b18fa026..b8d0de26 100644 --- a/site/controllers/download.php +++ b/site/controllers/download.php @@ -12,7 +12,7 @@ class PhocaCartControllerDownload extends JControllerForm { public function download() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $app = JFactory::getApplication(); $item = array(); $item['id'] = $this->input->get( 'id', 0, 'int' ); diff --git a/site/controllers/item.php b/site/controllers/item.php index b797a55c..9c81b0d0 100644 --- a/site/controllers/item.php +++ b/site/controllers/item.php @@ -10,9 +10,9 @@ class PhocaCartControllerItem extends JControllerForm { - public function review() { + public function review() { - JRequest::checkToken() or jexit( 'Invalid Token' ); + JSession::checkToken() or jexit( 'Invalid Token' ); $paramsC = JComponentHelper::getParams('com_phocacart'); $approve_review = $paramsC->get( 'approve_review',0 ); $app = JFactory::getApplication(); diff --git a/site/controllers/question.php b/site/controllers/question.php new file mode 100644 index 00000000..7e8ce32b --- /dev/null +++ b/site/controllers/question.php @@ -0,0 +1,314 @@ +get('enable_ask_question', 0); + + if ($enable_ask_question == 0) { + throw new Exception(JText::_('COM_PHOCACART_ASK_QUESTION_DISABLED'), 500); + return false; + } + + $namespace = 'phccrt' . $params->get('session_suffix'); + $data = $this->input->post->get('jform', array(), 'array'); + + // Additional data + if(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) { + $data['ip'] = $_SERVER['REMOTE_ADDR']; + } else { + $data['ip'] = getenv('HTTP_X_FORWARDED_FOR'); + } + if (!$data['ip']) { + $data['ip'] = $_SERVER['REMOTE_ADDR']; + } + + // Only because of information in LOG + $productId = ''; + if (isset($data['product_id']) && (int)$data['product_id'] > 0) { + $productId = (int)$data['product_id']; + } + + // *** SECURITY + // Default session test always enabled! + $valid = $session->get('form_id', NULL, 'phocacart'); + $session->clear('form_id', 'phocacart'); + if (!$valid){ + $app->setUserState('com_phocacart.question.data', ''); + $session->clear('time', 'phccrt'.$params->get('session_suffix')); + + PhocaCartLog::add(1, 'Ask a Question - Not valid session', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername); + //jexit(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED')); + throw new Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500); + return false; + } + + $model = $this->getModel('question'); + + // *** SECURITY + // Hidden Field + if ($params->get('enable_hidden_field_question', 0) == 1) { + $params->set('hidden_field_id', $session->get('hidden_field_id', 'fieldnotvalid', $namespace)); + $params->set('hidden_field_name', $session->get('hidden_field_name', 'fieldnotvalid', $namespace)); + $hiddenField = $session->get('hidden_field_name', 'fieldnotvalid', $namespace); + + $session->clear('hidden_field_id', $namespace); + $session->clear('hidden_field_name', $namespace); + $session->clear('hidden_field_class', $namespace); + + if ($params->get('hidden_field_id') == 'fieldnotvalid') { + $app->setUserState('com_phocacart.question.data', ''); + $session->clear('time', 'phccrt'.$params->get('session_suffix')); + + PhocaCartLog::add(1, 'Ask a Question - Hidden Field Error', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername); + throw new Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500); + return false; + } + + // Hidden field was filled + if (isset($data[$hiddenField]) && $data[$hiddenField] != '') { + $app->setUserState('com_phocacart.question.data', ''); + $session->clear('time', 'phccrt'.$params->get('session_suffix')); + + PhocaCartLog::add(1, 'Ask a Question - Hidden Field Filled', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername); + throw new Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500); + return false; + } + + } + + // *** SECURITY + // Check for a valid session cookie + if($session->getState() != 'active'){ + // Save the data in the session. + $app->setUserState('com_phocacart_cart.data', $data); + $message = JText::_( 'COM_PHOCACART_SESSION_INVALID' ); + $app->enqueueMessage($message, 'error'); + + PhocaCartLog::add(1, 'Ask a Question - Session not active', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername.', Message: '.$message); + $app->redirect(JRoute::_($uri)); + return false; + } + + // *** SECURITY + // Task + $task = $this->input->get('task'); + + if ($task == 'phocacart.submit') { + $task = 'submit'; + } + if (($this->input->get('view') != 'question') || ($this->input->get('option') != 'com_phocacart') || ($task != 'submit')) { + $app->setUserState('com_phocacart.question.data', ''); + $session->clear('time', 'phccrt'.$params->get('session_suffix')); + + PhocaCartLog::add(1, 'Ask a Question - No Phoca Cart part', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername); + throw new Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500); + return false; + } + + // *** SECURITY + // Check Time + if((int)$params->get('enable_time_check_question', 0) > 0) { + $time = $session->get('time', null, 'phccrt'.$params->get('session_suffix')); + $delta = time() - $time; + + if($params->get('enable_time_check_question', 0) && $delta <= (int)$params->get('enable_time_check_question', 0)) { + + $app->setUserState('com_phocacart.question.data', $data); + $message = JText::_( 'COM_PHOCACART_SUBMIT_TOO_FAST' ); + $app->enqueueMessage($message, 'error'); + + PhocaCartLog::add(1, 'Ask a Question - Submit too fast', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername.', Message: '.$message . ', Time: '. $delta . ' sec.'); + $app->redirect(JRoute::_($uri)); + return false; + } + } + + // ***SECURITY + // IP Ban + if ($params->get('ip_ban', '') != '') { + + $isSpam = PhocaCartSecurity::checkIpAddress($data['ip'], $params->get('ip_ban')); + + if ($isSpam) { + //$app->setUserState('com_phocacart.question.data', $data); // Save the data in the session. + //$message = JText::_( 'COM_PHOCACART_POSSIBLE_SPAM_DETECTED' ); + //$app->enqueueMessage($message, 'error'); + //$app->redirect(JRoute::_($uri)); + + $app->setUserState('com_phocacart.question.data', ''); + $session->clear('time', 'phccrt'.$params->get('session_suffix')); + + PhocaCartLog::add(1, 'Ask a Question - IP Ban', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername); + throw new Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500); + return false; + } + } + + // *** SECURITY + // Validate the posted data. + $form = $model->getForm(); + if (!$form) { + $app->setUserState('com_phocacart.question.data', ''); + $session->clear('time', 'phccrt'.$params->get('session_suffix')); + + PhocaCartLog::add(1, 'Ask a Question - Model not loaded', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername.', Message: '.$model->getError()); + throw new Exception($model->getError(), 500); + return false; + } + + // *** SECURITY + // VALIDATE - continue with validation in case of problem + $continueValidate = true; + + // SECURITY + // Captcha - is validated in RULES of FORM FIELD - Exception for validate fields + $captchaId = 1;//Possible parameters in Options for different captchas (reCaptcha = 1) + switch ($captchaId) { + case 1: // reCaptcha uses virtual field, so we cannot check the field set in form + $data['phq_captcha'] = 'OK'; + break; + } + + $validate = $model->validate($form, $data); + + if ($validate === false) { + $errors = $model->getErrors(); + + + // Get (possible) attack issues + for ($i = 0, $n = count($errors); $i < $n && $i < 5; $i++) { + if (($errors[$i] instanceof JException) && ($errors[$i]->get('Level') == E_ERROR)) { + $app->setUserState('com_phocacart.question.data', ''); + $session->clear('time', 'phccrt'.$params->get('session_suffix')); + + PhocaCartLog::add(1, 'Ask a Question - Validate errors', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername); + throw new Exception(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED'), 500); + return false; + } else { + + $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); + $continueValidate = false; + } + } + } + + // *** SECURITY + // Forbidden Word Filter + $fwfa = explode( ',', trim( $params->get('forbidden_word_filter', '') ) ); + $fwwfa = explode( ',', trim( $params->get('forbidden_whole_word_filter', '') ) ); + + foreach ($fwfa as $item) { + if (trim($item) != '') { + + if (isset($data['message']) && stripos($data['message'], trim($item)) !== false) { + $continueValidate = false; + PhocaCartLog::add(1, 'Ask a Question - Forbidden Word Filder - Message', $productId, 'Word: '.$item.', IP: '. $data['ip'].', User ID: '.$user->id); + $app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED' ), 'warning'); + } + if (isset($data['name']) && stripos($data['name'], trim($item)) !== false) { + $continueValidate = false; + PhocaCartLog::add(1, 'Ask a Question - Forbidden Word Filder - Name', $productId, 'Word: '.$item.', IP: '. $data['ip'].', User ID: '.$user->id); + $app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED' ), 'warning'); + } + if (isset($data['phone']) && stripos($data['phone'], trim($item)) !== false) { + $continueValidate = false; + PhocaCartLog::add(1, 'Ask a Question - Forbidden Word Filder - Phone', $productId, 'Word: '.$item.', IP: '. $data['ip'].', User ID: '.$user->id); + $app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED' ), 'warning'); + } + if (isset($data['email']) && stripos($data['email'], trim($item)) !== false) { + $continueValidate = false; + PhocaCartLog::add(1, 'Ask a Question - Forbidden Word Filder - Email', $productId, 'Word: '.$item.', IP: '. $data['ip'].', User ID: '.$user->id); + $app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED' ), 'warning'); + } + } + } + + foreach ($fwwfa as $item) { + if ($item != '') { + $itemBase = trim($item); + $item = "/(^|[^a-zA-Z0-9_]){1}(".preg_quote(($item),"/").")($|[^a-zA-Z0-9_]){1}/i"; + + + if (isset($data['message']) && preg_match( $item, $data['message']) == 1) { + $continueValidate = false; + PhocaCartLog::add(1, 'Ask a Question - Forbidden Whole Word Filder - Message', $productId, 'Word: '.$itemBase.', IP: '. $data['ip'].', User ID: '.$user->id); + $app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED' ), 'warning'); + } + if (isset($data['name']) && preg_match( $item, $data['name']) == 1) { + $continueValidate = false; + PhocaCartLog::add(1, 'Ask a Question - Forbidden Whole Word Filder - Name', $productId, 'Word: '.$itemBase.', IP: '. $data['ip'].', User ID: '.$user->id); + $app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED' ), 'warning'); + } + if (isset($data['phone']) && preg_match( $item, $data['phone']) == 1) { + $continueValidate = false; + PhocaCartLog::add(1, 'Ask a Question - Forbidden Whole Word Filder - Phone', $productId, 'Word: '.$itemBase.', IP: '. $data['ip'].', User ID: '.$user->id); + $app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED' ), 'warning'); + } + if (isset($data['email']) && preg_match( $item, $data['email']) == 1) { + $continueValidate = false; + PhocaCartLog::add(1, 'Ask a Question - Forbidden Whole Word Filder - Email', $productId, 'Word: '.$itemBase.', IP: '. $data['ip'].', User ID: '.$user->id); + $app->enqueueMessage(JText::_('COM_PHOCACART_POSSIBLE_SPAM_DETECTED' ), 'warning'); + } + } + } + + + // remove captcha from data after check + $data['phq_captcha'] = ''; + + if ($continueValidate == false) { + // Save the data in the session. + $app->setUserState('com_phocacart.question.data', $data); + // Log added before + $app->redirect(JRoute::_($uri)); + return false; + } + + + // CHECKS DONE - store entry + $msg = ''; + if ($model->store($data)) { + + $msg = JText::_( 'COM_PHOCACART_THANK_YOU_FOR_LEAVING_INFORMATION_ASKING_QUESTION' ); + } else { + $app->setUserState('com_phocacart.question.data', ''); + $session->clear('time', 'phccrt'.$params->get('session_suffix')); + + PhocaCartLog::add(1, 'Ask a Question - Model store error', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id . ', User Name: '.$user->unsername.', Message: '.$model->getError()); + + throw new Exception($model->getError(), 500); + return false; + } + + + + // Flush the data from the session + $app->setUserState('com_phocacart.question.data', ''); + //$session->clear('time', 'phccrt'.$params->get('session_suffix')); + $app->setUserState('com_phocacart.question.data', 'success_post_saved'); + $app->enqueueMessage($msg, 'success'); + $this->setRedirect($uri->toString()); + + return true; + } +} +?> diff --git a/site/controllers/response.php b/site/controllers/response.php index 76f39539..12ad8c9c 100644 --- a/site/controllers/response.php +++ b/site/controllers/response.php @@ -20,7 +20,7 @@ public function paymentrecieve() { $session = JFactory::getSession(); $session->set('proceedpayment', array(), 'phocaCart'); - //JRequest::checkToken() or jexit( 'Invalid Token' ); + //JSession::checkToken() or jexit( 'Invalid Token' ); $return = PhocaCartRoute::getInfoRoute(); //$app->enqueueMessage(JText::_('COM_PHOCACART_PAYMENT_RECIEVED'), 'message'); //$session->set('infomessage', 3, 'phocaCart'); @@ -36,7 +36,7 @@ public function paymentcancel() { $app = JFactory::getApplication(); $session = JFactory::getSession(); $session->set('proceedpayment', array(), 'phocaCart'); - //JRequest::checkToken() or jexit( 'Invalid Token' ); + //JSession::checkToken() or jexit( 'Invalid Token' ); $return = PhocaCartRoute::getInfoRoute(); $session->set('infomessage', 5, 'phocaCart'); //$app->enqueueMessage(JText::_('COM_PHOCACART_PAYMENT_CANCELED'), 'info'); diff --git a/site/controllers/wishlist.json.php b/site/controllers/wishlist.json.php new file mode 100644 index 00000000..d75eaf49 --- /dev/null +++ b/site/controllers/wishlist.json.php @@ -0,0 +1,160 @@ + '0', + 'error' => '' . JText::_('JINVALID_TOKEN') . ''); + echo json_encode($response); + return; + } + + + $app = JFactory::getApplication(); + $item = array(); + $item['id'] = $this->input->get( 'id', 0, 'int' ); + $item['catid'] = $this->input->get( 'catid', 0, 'int' ); + $item['return'] = $this->input->get( 'return', '', 'string' ); + $item['wishlistview'] = $this->input->get( 'wishlistview', 0, 'int' ); + + $wishlist = new PhocaCartWishList(); + $added = $wishlist->addItem((int)$item['id'], (int)$item['catid']); + //$catid = PhocaCartProduct::getCategoryByProductId((int)$item['id']); + + $o = $o2 = ''; + // Content of the wishlist list + ob_start(); + echo $wishlist->renderList(); + $o = ob_get_contents(); + ob_end_clean(); + + // Render the layout + $d = ''; + $layoutW = new JLayoutFile('popup_add_to_wishlist', $basePath = JPATH_ROOT .'/components/com_phocacart/layouts'); + + $d['link_wishlist'] = JRoute::_(PhocaCartRoute::getWishListRoute((int)$item['id']), (int)$item['catid']); + $d['link_continue'] = ''; + // We need to know if module is displayed on wishlist site + // If yes and one item will be deleted per AJAX, we need to refresh wishlist site + // If now and one item will be deleted per AJAX, everything is OK, nothing needs to be refreshed + $d['wishlist_view'] = (int)$item['wishlistview']; + + if ($added) { + $d['info_msg'] = JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_WISH_LIST'); + } else { + $d['info_msg'] = JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_WISH_LIST'); + + $m = $app->getMessageQueue(); + $mO = ''; + if (!empty($m)) { + $mO .= '
    '; + foreach($m as $k => $v) { + $mO .= '
  • ' . $v['message'] . '
  • '; + } + $mO .= '
'; + } + $d['info_msg_additional'] = $mO; + } + + // Popup with info - Continue,Proceed to wishlist list + ob_start(); + echo $layoutW->render($d); + $o2 = ob_get_contents(); + ob_end_clean(); + + $response = array( + 'status' => '1', + 'item' => $o, + 'popup' => $o2); + + echo json_encode($response); + return; + } + + public function remove() { + + if (!JSession::checkToken('request')) { + $response = array( + 'status' => '0', + 'error' => '' . JText::_('JINVALID_TOKEN') . ''); + echo json_encode($response); + return; + } + + $app = JFactory::getApplication(); + $item = array(); + $item['id'] = $this->input->get( 'id', 0, 'int' ); + $item['catid'] = $this->input->get( 'catid', 0, 'int' ); + $item['return'] = $this->input->get( 'return', '', 'string' ); + $item['wishlistview'] = $this->input->get( 'wishlistview', 0, 'int' ); + + $wishlist = new PhocaCartWishlist(); + $added = $wishlist->removeItem((int)$item['id']); + //$catid = PhocaCartProduct::getCategoryByProductId((int)$item['id']); + + $o = $o2 = ''; + // Content of the wishlist list + ob_start(); + echo $wishlist->renderList(); + $o = ob_get_contents(); + ob_end_clean(); + + // Render the layout + $d = ''; + $layoutW = new JLayoutFile('popup_remove_from_wishlist', $basePath = JPATH_ROOT .'/components/com_phocacart/layouts'); + + $d['link_wishlist'] = JRoute::_(PhocaCartRoute::getWishListRoute((int)$item['id']), (int)$item['catid']); + $d['link_continue'] = ''; + // We need to know if module is displayed on wishlist site + // If yes and one item will be deleted per AJAX, we need to refresh wishlist site + // If now and one item will be deleted per AJAX, everything is OK, nothing needs to be refreshed + $d['wishlist_view'] = (int)$item['wishlistview']; + + + + if ($added) { + $d['info_msg'] = JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_WISH_LIST'); + } else { + $d['info_msg'] = JText::_('COM_PHOCACART_PRODUCT_NOT_REMOVED_FROM_WISH_LIST'); + + $m = $app->getMessageQueue(); + $mO = ''; + if (!empty($m)) { + $mO .= '
    '; + foreach($m as $k => $v) { + $mO .= '
  • ' . $v['message'] . '
  • '; + } + $mO .= '
'; + } + $d['info_msg_additional'] = $mO; + } + + // Popup with info - Continue,Proceed to wishlist list + ob_start(); + echo $layoutW->render($d); + $o2 = ob_get_contents(); + ob_end_clean(); + + $response = array( + 'status' => '1', + 'item' => $o, + 'popup' => $o2); + + echo json_encode($response); + return; + } + +} +?> \ No newline at end of file diff --git a/site/controllers/wishlist.php b/site/controllers/wishlist.php new file mode 100644 index 00000000..2f63e453 --- /dev/null +++ b/site/controllers/wishlist.php @@ -0,0 +1,54 @@ +input->get( 'id', 0, 'int' ); + $item['catid'] = $this->input->get( 'catid', 0, 'int' ); + $item['return'] = $this->input->get( 'return', '', 'string' ); + + $wishlist = new PhocaCartWishList(); + $added = $wishlist->addItem((int)$item['id'], (int)$item['catid']); + if ($added) { + $app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_ADDED_TO_WISH_LIST'), 'message'); + } else { + $app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_ADDED_TO_WISH_LIST'), 'error'); + } + //$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout')); + $app->redirect(base64_decode($item['return'])); + } + + public function remove() { + + JSession::checkToken() or jexit( 'Invalid Token' ); + $app = JFactory::getApplication(); + $item = array(); + $item['id'] = $this->input->get( 'id', 0, 'int' ); + $item['return'] = $this->input->get( 'return', '', 'string' ); + + $wishlist = new PhocaCartWishList(); + $added = $wishlist->removeItem((int)$item['id']); + if ($added) { + $app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_REMOVED_FROM_WISH_LIST'), 'message'); + } else { + $app->enqueueMessage(JText::_('COM_PHOCACART_PRODUCT_NOT_REMOVED_FROM_WISH_LIST'), 'error'); + } + //$app->redirect(JRoute::_('index.php?option=com_phocacart&view=checkout')); + $app->redirect(base64_decode($item['return'])); + } + +} +?> \ No newline at end of file diff --git a/site/helpers/route.php b/site/helpers/route.php index 9a849746..9df50e52 100644 --- a/site/helpers/route.php +++ b/site/helpers/route.php @@ -6,7 +6,7 @@ * @copyright Copyright (C) Jan Pavelka www.phoca.cz * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL */ -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; jimport('joomla.application.component.helper'); class PhocaMapsHelperRoute diff --git a/site/layouts/button_add_to_cart_item.php b/site/layouts/button_add_to_cart_item.php index eab2f9ef..231e1df5 100644 --- a/site/layouts/button_add_to_cart_item.php +++ b/site/layouts/button_add_to_cart_item.php @@ -20,9 +20,13 @@ -
- - */ ?> +
+ */ ?>
\ No newline at end of file diff --git a/site/layouts/button_add_to_cart_list.php b/site/layouts/button_add_to_cart_list.php index 30a008c4..91518442 100644 --- a/site/layouts/button_add_to_cart_list.php +++ b/site/layouts/button_add_to_cart_list.php @@ -10,8 +10,12 @@ $d = $displayData; // One of the attributes is required, cannot add to cart if ($d['attrrequired'] == 1) { ?> -
- +
@@ -22,8 +26,12 @@ -
- +
diff --git a/site/layouts/button_ask_question.php b/site/layouts/button_ask_question.php new file mode 100644 index 00000000..61fd2487 --- /dev/null +++ b/site/layouts/button_ask_question.php @@ -0,0 +1,24 @@ + + +
+ +
+ + +
+ +
+ + diff --git a/site/layouts/button_buy_now_paddle.php b/site/layouts/button_buy_now_paddle.php index de47a7da..6514d4d3 100644 --- a/site/layouts/button_buy_now_paddle.php +++ b/site/layouts/button_buy_now_paddle.php @@ -13,5 +13,5 @@ ?>
- +
diff --git a/site/layouts/button_category_view.php b/site/layouts/button_category_view.php new file mode 100644 index 00000000..9dba0c12 --- /dev/null +++ b/site/layouts/button_category_view.php @@ -0,0 +1,24 @@ + +
+ +
\ No newline at end of file diff --git a/site/layouts/button_product_view.php b/site/layouts/button_product_view.php index 0b7d6ac3..43732719 100644 --- a/site/layouts/button_product_view.php +++ b/site/layouts/button_product_view.php @@ -10,5 +10,14 @@ $d = $displayData; ?>
- +
\ No newline at end of file diff --git a/site/layouts/button_quickview.php b/site/layouts/button_quickview.php new file mode 100644 index 00000000..6ac4c5a6 --- /dev/null +++ b/site/layouts/button_quickview.php @@ -0,0 +1,24 @@ + +
+ + + + + +
+
+ +
+
+ +
\ No newline at end of file diff --git a/site/layouts/button_wishlist.php b/site/layouts/button_wishlist.php new file mode 100644 index 00000000..a0e1b1a8 --- /dev/null +++ b/site/layouts/button_wishlist.php @@ -0,0 +1,29 @@ + +
+ + + + + + +
+
+ 0) { ?> + + + + +
+
+ +
\ No newline at end of file diff --git a/site/layouts/form_filter_checkbox.php b/site/layouts/form_filter_checkbox.php index e5025ce2..2bd8a01a 100644 --- a/site/layouts/form_filter_checkbox.php +++ b/site/layouts/form_filter_checkbox.php @@ -23,7 +23,7 @@
$v) { - + $checked = ''; $value = htmlspecialchars($v->alias); if (isset($d['nrinalias']) && $d['nrinalias'] == 1) { diff --git a/site/layouts/form_filter_color.php b/site/layouts/form_filter_color.php new file mode 100644 index 00000000..acbe664b --- /dev/null +++ b/site/layouts/form_filter_color.php @@ -0,0 +1,54 @@ + +
+ + +
+
+ $v) { + + $checked = ''; + $checkedInt = 0; + $value = htmlspecialchars($v->alias); + if (isset($d['nrinalias']) && $d['nrinalias'] == 1) { + $value = (int)$v->id .'-'. htmlspecialchars($v->alias); + } + + if (in_array($value, $d['getparams'])) { + $checked = 'checked'; + $checkedInt = 0; + } else { + $checkedInt = 1; + } + + $class = ''; + if ($checked) { + $class = 'on'; + } + + if (isset($v->color) && $v->color != '') { + echo ' '; + } + } + ?> +
+
+
\ No newline at end of file diff --git a/site/layouts/form_filter_image.php b/site/layouts/form_filter_image.php new file mode 100644 index 00000000..7689b2bf --- /dev/null +++ b/site/layouts/form_filter_image.php @@ -0,0 +1,59 @@ + +
+ + +
+
+ $v) { + + $checked = ''; + $checkedInt = 0; + $value = htmlspecialchars($v->alias); + if (isset($d['nrinalias']) && $d['nrinalias'] == 1) { + $value = (int)$v->id .'-'. htmlspecialchars($v->alias); + } + + if (in_array($value, $d['getparams'])) { + $checked = 'checked'; + $checkedInt = 0; + } else { + $checkedInt = 1; + } + + $class = ''; + if ($checked) { + $class = 'on'; + } + + if (isset($v->image_small) && $v->image_small != '') { + + $linkI = JURI::base(true).'/'.$d['pathitem']['orig_rel'].'/'.$v->image_small; + + echo '' + .''.$v->title.'' + .''; + } + } + ?> +
+
+
\ No newline at end of file diff --git a/site/layouts/form_filter_text.php b/site/layouts/form_filter_text.php index 7efaad0f..79a8e2e7 100644 --- a/site/layouts/form_filter_text.php +++ b/site/layouts/form_filter_text.php @@ -14,7 +14,6 @@ $d['param2name'] = str_replace('-', '', $d['param2']); } - if (isset($d['param2']) && $d['param2'] != '') { // We have second parameter, so in first we define that the javascript should wait with redirect $jsSet = 'phChangeFilter(\''.$d['param'].'\', jQuery(\'#'. $d['id'].' input[name="'.$d['paramname'].'"]\').val(), 1, \'text\', 1, 1);'; diff --git a/site/layouts/form_question.php b/site/layouts/form_question.php new file mode 100644 index 00000000..bf4bd99f --- /dev/null +++ b/site/layouts/form_question.php @@ -0,0 +1,34 @@ + +
+ +
+
+ +
+ +
+
+ + + +
+
+
+ + +
+
\ No newline at end of file diff --git a/site/layouts/list_compare.php b/site/layouts/list_compare.php index 3a6c06e4..083127c7 100644 --- a/site/layouts/list_compare.php +++ b/site/layouts/list_compare.php @@ -30,9 +30,9 @@
0) { ?> -
+
-
+
@@ -43,4 +43,4 @@ } } ?> - + diff --git a/site/layouts/list_wishlist.php b/site/layouts/list_wishlist.php new file mode 100644 index 00000000..7973ec7b --- /dev/null +++ b/site/layouts/list_wishlist.php @@ -0,0 +1,46 @@ + $v) { + // Try to find the best menu link + if (isset($v->catid2) && (int)$v->catid2 > 0 && isset($v->catalias2) && $v->catalias2 != '') { + $linkProduct = JRoute::_(PhocaCartRoute::getItemRoute($v->id, $v->catid2, $v->alias, $v->catalias2)); + } else { + $linkProduct = JRoute::_(PhocaCartRoute::getItemRoute($v->id, $v->catid, $v->alias, $v->catalias)); + } + +?> +
+ +
+
+ + + + + +
+ 0) { ?> +
+ +
+ +
+ +
+
+
+ + diff --git a/site/layouts/popup_add_to_wishlist.php b/site/layouts/popup_add_to_wishlist.php new file mode 100644 index 00000000..a5a8c8ba --- /dev/null +++ b/site/layouts/popup_add_to_wishlist.php @@ -0,0 +1,44 @@ + + + + + \ No newline at end of file diff --git a/site/layouts/popup_quickview.php b/site/layouts/popup_quickview.php new file mode 100644 index 00000000..d37912f6 --- /dev/null +++ b/site/layouts/popup_quickview.php @@ -0,0 +1,25 @@ + + +
\ No newline at end of file diff --git a/site/layouts/popup_remove_from_wishlist.php b/site/layouts/popup_remove_from_wishlist.php new file mode 100644 index 00000000..a2523f76 --- /dev/null +++ b/site/layouts/popup_remove_from_wishlist.php @@ -0,0 +1,45 @@ + + + + + \ No newline at end of file diff --git a/site/models/category.php b/site/models/category.php index 4cd6fd7a..5c93d61b 100644 --- a/site/models/category.php +++ b/site/models/category.php @@ -11,6 +11,7 @@ class PhocaCartModelCategory extends JModelLegacy { + protected $item = null; protected $item_ordering = null; protected $category = null; @@ -33,8 +34,8 @@ public function __construct() { $this->setState('limitstart', $app->input->get('limitstart', 0, 'int')); $this->setState('limitstart', ($this->getState('limit') != 0 ? (floor($this->getState('limitstart') / $this->getState('limit')) * $this->getState('limit')) : 0)); $this->setState('filter.language',$app->getLanguageFilter()); - $this->setState('filter_order', JRequest::getCmd('filter_order', 'ordering')); - $this->setState('filter_order_dir', JRequest::getCmd('filter_order_Dir', 'ASC')); + $this->setState('filter_order', JFactory::getApplication()->input->get('filter_order', 'ordering')); + $this->setState('filter_order_dir', JFactory::getApplication()->input->get('filter_order_Dir', 'ASC')); $this->setState('itemordering', $app->getUserStateFromRequest('com_phocacart.itemordering', 'itemordering', $item_ordering, 'int')); } @@ -91,6 +92,16 @@ protected function getItemListQuery($categoryId, $count = 0) { $user = JFactory::getUser(); $userLevels = implode (',', $user->getAuthorisedViewLevels()); $params = $app->getParams(); + + $p['switch_image_category_items'] = $params->get( 'switch_image_category_items', 0 ); + $leftImages = ''; + $selImages = ''; + if ($p['switch_image_category_items'] == 1) { + $leftImages = ' LEFT JOIN #__phocacart_product_images AS im ON a.id = im.product_id'; + $selImages = ' im.image as additional_image,'; + } + + $wheres = array(); if ((int)$categoryId > 0) { $wheres[] = " c.id = ".(int)$categoryId; @@ -118,7 +129,7 @@ protected function getItemListQuery($categoryId, $count = 0) { . ' GROUP BY a.id'; } else { - $q = ' SELECT a.id, a.title, a.image, a.alias, a.description, a.catid, c.id AS categoryid, c.title AS categorytitle, c.alias AS categoryalias, a.price, a.price_original, t.tax_rate as taxrate, t.calculation_type as taxcalculationtype, t.title as taxtitle, a.date, a.sales, a.featured, a.external_id, a.unit_amount, a.unit_unit, a.external_link, a.external_text, ' + $q = ' SELECT a.id, a.title, a.image, a.alias, a.description, c.id AS catid, c.title AS cattitle, c.alias AS catalias, a.price, a.price_original, t.tax_rate as taxrate, t.calculation_type as taxcalculationtype, t.title as taxtitle, a.date, a.sales, a.featured, a.external_id, a.unit_amount, a.unit_unit, a.external_link, a.external_text,'. $selImages . ' AVG(r.rating) AS rating,' . ' at.required AS attribute_required' . ' FROM #__phocacart_products AS a' @@ -128,6 +139,7 @@ protected function getItemListQuery($categoryId, $count = 0) { . ' LEFT JOIN #__phocacart_taxes AS t ON t.id = a.tax_id' . ' LEFT JOIN #__phocacart_reviews AS r ON a.id = r.product_id AND r.id > 0' . ' LEFT JOIN #__phocacart_attributes AS at ON a.id = at.product_id AND at.id > 0 AND at.required = 1' + . $leftImages . ' WHERE ' . implode( ' AND ', $wheres ) . ' GROUP BY a.id' . ' ORDER BY '.$itemOrdering; diff --git a/site/models/fields/phocacaptcha.php b/site/models/fields/phocacaptcha.php new file mode 100644 index 00000000..c95a6785 --- /dev/null +++ b/site/models/fields/phocacaptcha.php @@ -0,0 +1,37 @@ +get('session_suffix', $string); + $captchaCnt = $session->get('captcha_cnt', 0, $namespace) + 1; + + $id = $session->get('captcha_id', '', $namespace); + + switch ($id){ + default: + case 1: + $retval = PhocaCartRecaptcha::render(); + break; + } + + return $retval; + } + + +} +?> diff --git a/site/models/forms/question.xml b/site/models/forms/question.xml new file mode 100644 index 00000000..d14b0091 --- /dev/null +++ b/site/models/forms/question.xml @@ -0,0 +1,61 @@ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
+ +
+ +
+ +
diff --git a/site/models/item.php b/site/models/item.php index 5a06ccc9..bb8bb503 100644 --- a/site/models/item.php +++ b/site/models/item.php @@ -109,7 +109,7 @@ private function getItemQuery( $itemId, $catId ) { $wheres[] = ' cc.language IN ('.$this->_db->Quote(JFactory::getLanguage()->getTag()).','.$this->_db->Quote('*').')'; } - $query = ' SELECT i.id, i.title, i.alias, i.description, i.ordering, i.metadesc, i.metakey, i.image, i.description, i.description_long, i.price, i.price_original, i.stockstatus_a_id, i.stockstatus_n_id, i.min_quantity, i.stock, i.date, i.sales, i.featured, i.external_id, i.unit_amount, i.unit_unit, i.video, i.external_link, i.external_text, cc.id AS catid, cc.title AS cattitle, cc.alias AS catalias, t.tax_rate as taxrate, t.title as taxtitle, t.calculation_type as taxcalculationtype, m.id as manufacturerid, m.title as manufacturertitle' + $query = ' SELECT i.id, i.title, i.alias, i.description, i.ordering, i.metadesc, i.metakey, i.image, i.description, i.description_long, i.price, i.price_original, i.stockstatus_a_id, i.stockstatus_n_id, i.min_quantity, i.min_multiple_quantity, i.stock, i.date, i.sales, i.featured, i.external_id, i.unit_amount, i.unit_unit, i.video, i.external_link, i.external_text, cc.id AS catid, cc.title AS cattitle, cc.alias AS catalias, t.tax_rate as taxrate, t.title as taxtitle, t.calculation_type as taxcalculationtype, m.id as manufacturerid, m.title as manufacturertitle' .' FROM #__phocacart_products AS i' .' LEFT JOIN #__phocacart_product_categories AS pc ON pc.product_id = i.id' .' LEFT JOIN #__phocacart_categories AS cc ON cc.id = pc.category_id' diff --git a/site/models/items.php b/site/models/items.php index aa383685..e0a78767 100644 --- a/site/models/items.php +++ b/site/models/items.php @@ -33,8 +33,8 @@ public function __construct() { $this->setState('limitstart', $app->input->get('limitstart', 0, 'int')); $this->setState('limitstart', ($this->getState('limit') != 0 ? (floor($this->getState('limitstart') / $this->getState('limit')) * $this->getState('limit')) : 0)); $this->setState('filter.language',$app->getLanguageFilter()); - $this->setState('filter_order', JRequest::getCmd('filter_order', 'ordering')); - $this->setState('filter_order_dir', JRequest::getCmd('filter_order_Dir', 'ASC')); + $this->setState('filter_order', $app->input->get('filter_order', 'ordering')); + $this->setState('filter_order_dir', $app->input->get('filter_order_Dir', 'ASC')); $this->setState('itemordering', $app->getUserStateFromRequest('com_phocacart.itemordering', 'itemordering', $item_ordering, 'int')); @@ -111,6 +111,8 @@ protected function getItemListQuery($count = 0) { $wheres = array(); $lefts = array(); + $p['switch_image_category_items'] = $params->get( 'switch_image_category_items', 0 ); + $wheres[] = ' a.published = 1'; $wheres[] = ' c.published = 1'; if ($this->getState('filter.language')) { @@ -184,6 +186,14 @@ protected function getItemListQuery($count = 0) { $lefts[] = $s['left']; } + // Additional Images + $leftImages = ''; + $selImages = ''; + if ($p['switch_image_category_items'] == 1) { + $leftImages = ' LEFT JOIN #__phocacart_product_images AS im ON a.id = im.product_id'; + $selImages = ' im.image as additional_image,'; + } + // Remove empty values: $wheres = array_filter($wheres); @@ -212,11 +222,12 @@ protected function getItemListQuery($count = 0) { //$lefts[] = ' LEFT JOIN #__phocacart_attributes AS at ON a.id = at.product_id AND at.id > 0 AND at.required = 1'; $lefts[] = ' LEFT JOIN #__phocacart_attributes AS at ON a.id = at.product_id AND at.id > 0'; - $q = ' SELECT a.id, a.title, a.image, a.alias, a.unit_amount, a.unit_unit, a.description, c.id AS catid, c.title AS cattitle, c.alias AS catalias, a.price, a.price_original, t.tax_rate as taxrate, t.calculation_type as taxcalculationtype, t.title as taxtitle, a.date, a.sales, a.featured, a.external_id, a.external_link, a.external_text, ' + $q = ' SELECT a.id, a.title, a.image, a.alias, a.unit_amount, a.unit_unit, a.description, c.id AS catid, c.title AS cattitle, c.alias AS catalias, a.price, a.price_original, t.tax_rate as taxrate, t.calculation_type as taxcalculationtype, t.title as taxtitle, a.date, a.sales, a.featured, a.external_id, a.external_link, a.external_text,'. $selImages . ' AVG(r.rating) AS rating,' . ' at.required AS attribute_required' . ' FROM #__phocacart_products AS a' . implode( ' ', $lefts ) + . $leftImages . ' WHERE ' . implode( ' AND ', $wheres ) . ' GROUP BY a.id' . ' ORDER BY '.$itemOrdering; diff --git a/site/models/orders.php b/site/models/orders.php index e666d972..d2cca8d1 100644 --- a/site/models/orders.php +++ b/site/models/orders.php @@ -28,8 +28,8 @@ public function __construct() { $this->setState('limitstart', $app->input->get('limitstart', 0, 'int')); $this->setState('limitstart', ($this->getState('limit') != 0 ? (floor($this->getState('limitstart') / $this->getState('limit')) * $this->getState('limit')) : 0)); $this->setState('filter.language',$app->getLanguageFilter()); - $this->setState('filter_order', JRequest::getCmd('filter_order', 'ordering')); - $this->setState('filter_order_dir', JRequest::getCmd('filter_order_Dir', 'ASC')); + $this->setState('filter_order', JFactory::getApplication()->input->get('filter_order', 'ordering')); + $this->setState('filter_order_dir', JFactory::getApplication()->input->get('filter_order_Dir', 'ASC')); } diff --git a/site/models/question.php b/site/models/question.php new file mode 100644 index 00000000..fecb4671 --- /dev/null +++ b/site/models/question.php @@ -0,0 +1,144 @@ +setState('filter.language',$app->getLanguageFilter()); + } + + public function getForm($data = array(), $loadData = true) + { + // Get the form. + $form = $this->loadForm('com_phocacart.question', 'question', array('control' => 'jform', 'load_data' => true)); + if (empty($form)) { + return false; + } + + $app = JFactory::getApplication(); + $params = $app->getParams(); + + // Set required or not && disable if not available + if(!$params->get('display_name_form', 2)){ + $form->removeField('name'); + } else if ($params->get('display_name_form', 2) == 2){ + $form->setFieldAttribute('name', 'required', 'true'); + } + + if(!$params->get('display_email_form', 2)){ + $form->removeField('email'); + } else if ($params->get('display_email_form', 2) == 2){ + $form->setFieldAttribute('email', 'required', 'true'); + } + + if(!$params->get('display_phone_form', 2)){ + $form->removeField('phone'); + } else if ($params->get('display_phone_form', 2) == 2){ + $form->setFieldAttribute('phone', 'required', 'true'); + } + + if(!$params->get('display_message_form', 2)){ + $form->removeField('message'); + } else if ($params->get('display_message_form', 2) == 2){ + $form->setFieldAttribute('message', 'required', 'true'); + } + + if (!$params->get('enable_hidden_field_question', 0)){ + $form->removeField('hidden_field'); + } else { + + $form->setFieldAttribute('hidden_field', 'id', $params->get('hidden_field_id')); + $form->setFieldAttribute('hidden_field', 'class', $params->get('hidden_field_class')); + $form->setFieldAttribute('hidden_field', 'name', $params->get('hidden_field_name')); + + } + + if (!$params->get('enable_captcha_question', 2)) { + $form->removeField('phq_captcha'); + } else { + $form->setFieldAttribute('phq_captcha', 'type', 'phocacaptcha'); + $form->setFieldAttribute('phq_captcha', 'captcha_id', $params->get('captcha_id')); + $form->setFieldAttribute('phq_captcha', 'validate', 'phocacartcaptcha'); + } + + return $form; + } + + protected function loadFormData() { + $data = (array) JFactory::getApplication()->getUserState('com_phocacart.question.data', array()); + return $data; + } + + function store(&$data) { + + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + $uri = JFactory::getURI(); + $app = JFactory::getApplication(); + $params = JComponentHelper::getParams('com_phocacart') ; + + // Maximum of character, they will be saved in database + $data['message'] = substr($data['message'], 0, $params->get('max_char_question', 3000)); + $data['date'] = gmdate('Y-m-d H:i:s'); // Create the timestamp for the date + + $row = $this->getTable('PhocaCartQuestion'); + + // Bind the form fields to the table + if (!$row->bind($data)) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + // Make sure the table is valid + if (!$row->check()) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + // Store the Phoca guestbook table to the database + if (!$row->store()) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + // Everything OK - send email + if ($params->get('send_email_question', 0) > 0) { + + $data['product'] = array(); + $data['category'] = array(); + $productId = 0; + if(isset($data['product_id']) && (int)$data['product_id'] > 0) { + if(isset($data['category_id']) && (int)$data['category_id'] > 0) { + $data['product'] = PhocaCartProduct::getProduct($data['product_id'], $data['category_id']); + $data['category'] = PhocaCartCategory::getCategoryById($data['category_id']); + } else { + $data['product'] = PhocaCartProduct::getProduct($data['product_id']); + } + $productId = $data['product']; + } + + + $send = PhocaCartEmail::sendQuestionMail($params->get('send_email_question'), $data, JFactory::getURI()->toString(), $params); + + if (!$send) { + $user = JFactory::getUser(); + PhocaCartLog::add(1, 'Ask a Question - Problems with sending email', $productId, 'IP: '. $data['ip'].', User ID: '.$user->id); + } + } + + $data['id'] = $row->id; + + return true; + } +} +?> \ No newline at end of file diff --git a/site/models/rules/phocacartcaptcha.php b/site/models/rules/phocacartcaptcha.php new file mode 100644 index 00000000..1ea238a6 --- /dev/null +++ b/site/models/rules/phocacartcaptcha.php @@ -0,0 +1,39 @@ +get('session_suffix'); + + // Possible parameters in Options for different captchas + $captchaId = 1; + + switch($captchaId) { + case 1: + default: + if (!PhocaCartRecaptcha::isValid()) { + + // What happens when the CAPTCHA was entered incorrectly + return new JException(JText::_('COM_PHOCACART_WRONG_CAPTCHA' ), "105", E_USER_ERROR, $info, false); + } + + return true; + break; + } + return false; + } +} diff --git a/site/models/rules/phocacartemail.php b/site/models/rules/phocacartemail.php new file mode 100644 index 00000000..bbace303 --- /dev/null +++ b/site/models/rules/phocacartemail.php @@ -0,0 +1,39 @@ +get('banned_email'); + foreach(explode(';', $banned) as $item){ + if (trim($item) != '') + if (JString::stristr($item, $value) !== false){ + return new JException(JText::_('COM_PHOCACART_BAD_EMAIL' ), "105", E_USER_ERROR, $info, false); + } + } + + return true; + } +} diff --git a/site/models/rules/phocacarthidden.php b/site/models/rules/phocacarthidden.php new file mode 100644 index 00000000..94304869 --- /dev/null +++ b/site/models/rules/phocacarthidden.php @@ -0,0 +1,28 @@ + diff --git a/site/phocacart.php b/site/phocacart.php index 6ff754dd..6be58cb4 100644 --- a/site/phocacart.php +++ b/site/phocacart.php @@ -18,6 +18,8 @@ phocacartimport('phocacart.utils.settings'); phocacartimport('phocacart.utils.utils'); phocacartimport('phocacart.utils.log'); +phocacartimport('phocacart.security.security'); +phocacartimport('phocacart.utils.extension'); phocacartimport('phocacart.category.category'); phocacartimport('phocacart.category.categorymultiple'); phocacartimport('phocacart.date.date'); @@ -56,26 +58,16 @@ phocacartimport('phocacart.order.orderview'); phocacartimport('phocacart.order.orderrender'); phocacartimport('phocacart.compare.compare'); +phocacartimport('phocacart.wishlist.wishlist'); phocacartimport('phocacart.download.download'); phocacartimport('phocacart.render.renderfront'); phocacartimport('phocacart.email.email'); phocacartimport('phocacart.search.search'); phocacartimport('phocacart.feed.feed'); phocacartimport('phocacart.render.rendermedia'); +phocacartimport('phocacart.captcha.recaptcha'); + -/* -if($controller = JRequest::getWord('controller')) { - $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php'; - if (file_exists($path)) { - require_once $path; - } else { - $controller = ''; - } -} -$classname = 'PhocaCartController'.ucfirst($controller); -$controller = new $classname( ); -$controller->execute( JFactory::getApplication()->input->get('task') ); -$controller->redirect();*/ $controller = JControllerLegacy::getInstance('PhocaCart'); $controller->execute(JFactory::getApplication()->input->get('task')); diff --git a/site/router.php b/site/router.php index 6374a6af..cea80eab 100644 --- a/site/router.php +++ b/site/router.php @@ -8,7 +8,6 @@ */ defined('_JEXEC') or die; - if (! class_exists('PhocaCartLoader')) { require_once( JPATH_ADMINISTRATOR.'/components/com_phocacart/libraries/loader.php'); } @@ -18,9 +17,10 @@ class PhocaCartRouter extends JComponentRouterBase { public function build(&$query) { - $viewsNoId = array('categories', 'checkout', 'comparison', 'download', 'terms', 'account', 'orders', 'payment', 'info', 'items'); - $viewsId = array('category', 'item', 'items', 'feed'); - $viewsAll = array_merge($viewsNoId, $viewsId); + $viewsNoId = array('categories', 'checkout', 'comparison', 'download', 'terms', 'account', 'orders', 'payment', 'info', 'items', 'wishlist'); + $viewsId = array('category', 'item', 'items', 'feed'); + $viewsNotOwnId = array('question'); + $viewsAll = array_merge($viewsNoId, $viewsId, $viewsNotOwnId); $segments = array(); @@ -75,19 +75,15 @@ public function build(&$query) { if (($menuItem instanceof stdClass) && $menuItem->query['view'] == $query['view'] && isset($query['view']) && in_array($query['view'], $viewsNoId) - ) - { - + ) { unset($query['view']); - if (isset($query['catid'])) - { + if (isset($query['catid'])){ unset($query['catid']); } - if (isset($query['layout'])) - { + if (isset($query['layout'])){ unset($query['layout']); } @@ -95,15 +91,16 @@ public function build(&$query) { return $segments; } - - if ($view == 'category' || $view == 'item') - { - if (!$menuItemGiven) - { + + if ($view == 'category' || $view == 'item'){ + if (!$menuItemGiven){ $segments[] = $view; } + unset($query['view']); + + if ($view == 'item') { @@ -127,11 +124,10 @@ public function build(&$query) { else { // We should have these two set for this view. If we don't, it is an error + return $segments; } - } - else - { + } else { if (isset($query['id'])) { $catid = $query['id']; @@ -156,6 +152,7 @@ public function build(&$query) { //$category = $categories->get($catid); $category = PhocaCartCategory::getCategoryById($catid); + if (!$category) { // We couldn't find the category we were given. Bail. @@ -207,6 +204,24 @@ public function build(&$query) { unset($query['id']); unset($query['catid']); } + + if ($view == 'question') { + if (!$menuItemGiven){ + $segments[] = $view; + } + if (isset($query['view'])) { + $segments[] = $query['view']; + unset($query['view']); + } + if (isset($query['catid'])) { + $segments[] = $query['catid']; + unset($query['catid']); + } + if (isset($query['id'])) { + $segments[] = $query['id']; + unset($query['id']); + } + } if (!isset($query['id'])) { // Check if a id was specified. if (isset($query['view']) && in_array($query['view'], $viewsNoId)) { @@ -227,8 +242,6 @@ public function build(&$query) { - - /* * If the layout is specified and it is the same as the layout in the menu item, we * unset it so it doesn't go into the query string. @@ -263,8 +276,12 @@ public function build(&$query) { public function parse(&$segments) { - $viewsNoId = array('categories', 'checkout', 'comparison', 'download', 'terms', 'account', 'orders', 'payment', 'info', 'items'); - $viewsId = array('category', 'item', 'items', 'feed'); + $viewsNoId = array('categories', 'checkout', 'comparison', 'download', 'terms', 'account', 'orders', 'payment', 'info', 'items', 'wishlist'); + $viewsId = array('category', 'item', 'items', 'feed'); + $viewsNotOwnId = array('question'); + $viewsAll = array_merge($viewsNoId, $viewsId, $viewsNotOwnId); + + // question - can be an ID page (id of product) but without ID page - direct link $total = count($segments); $vars = array(); @@ -287,8 +304,7 @@ public function parse(&$segments) { * Standard routing for items. If we don't pick up an Itemid then we get the view from the segments * the first segment is the view and the last segment is the id of the item or category. */ - if (!isset($item)) - { + if (!isset($item)) { $vars['view'] = $segments[0]; // Called if no menu item created @@ -303,6 +319,12 @@ public function parse(&$segments) { $vars['view'] = $segments[0]; return $vars; } + + // Question can include ID/CATID but can be without ID/CATID + if(isset($segments[0]) && in_array($segments[0], $viewsNotOwnId)) { + $vars['view'] = $segments[0]; + return $vars; + } } /* @@ -311,8 +333,7 @@ public function parse(&$segments) { * then we assume it is a category. If they don't we assume it is an item */ - if ($count == 1) - { + if ($count == 1) { // We check to see if an alias is given. If not, we assume it is an item if (strpos($segments[0], ':') === false) { @@ -337,20 +358,21 @@ public function parse(&$segments) { } else { - // TODO specify catid - load from libraries + // TO DO specify catid - load from libraries $query = $db->getQuery(true) ->select($db->quoteName(array('alias', 'catid'))) ->from($db->quoteName('#__phocacart_products')) ->where($db->quoteName('id') . ' = ' . (int) $id); $db->setQuery($query); - $item = $db->loadObject(); + $item1 = $db->loadObject(); - if ($item) + + if ($item1) { - if ($item->alias == $alias) + if ($item1->alias == $alias) { $vars['view'] = 'item'; - $vars['catid'] = (int) $item->catid; + $vars['catid'] = (int) $item1->catid; $vars['id'] = (int) $id; return $vars; @@ -365,21 +387,34 @@ public function parse(&$segments) { * last segment has a number prepended, it is an item, otherwise, it is a category. */ - if (!$advanced) - { - $cat_id = (int) $segments[0]; - - $item_id = (int) $segments[$count - 1]; - + if (!$advanced) { + + if ($count == 3) { + // Question + $view = $segments[0]; + $cat_id = (int)$segments[$count - 2]; + $item_id = (int)$segments[$count - 1]; + } else { + // Item + $view = ''; + $cat_id = (int)$segments[0]; + $item_id = (int)$segments[$count - 1]; + } + + if ($cat_id > 0) { - if ($item_id > 0) - { - $vars['view'] = 'item'; + if ($item_id > 0) { + if ($view != '') { + $vars['view'] = $view; + } else { + $vars['view'] = 'item'; + } + $vars['catid'] = $cat_id; $vars['id'] = $item_id; - } - else - { + + + } else { $vars['view'] = 'category'; $vars['id'] = $cat_id; } @@ -393,17 +428,34 @@ public function parse(&$segments) { } } + return $vars; } - +/* // We get the category id from the menu item and search from there - $id = $item->query['id']; + if (isset($item->query['id'])) { + $id = $item->query['id']; + } else { + + if ($count == 3) { + // Question + + $id = (int)$segments[$count - 2]; + + } else { + // Item + $id = (int)$segments[0]; + } + } + + + + $category = PhocaCartCategory::getCategoryById($id); if (!$category) { - JError::raiseError(404, JText::_('COM_PHOCACART_ERROR_PARENT_CATEGORY_NOT_FOUND')); - + throw new Exception(JText::_('COM_PHOCACART_ERROR_PARENT_CATEGORY_NOT_FOUND'), 404); return $vars; } @@ -411,9 +463,8 @@ public function parse(&$segments) { $vars['catid'] = $id; $vars['id'] = $id; $found = 0; - - foreach ($segments as $segment) - { + + foreach ($segments as $segment) { $segment = str_replace(':', '-', $segment); foreach ($categories as $category) @@ -425,6 +476,7 @@ public function parse(&$segments) { $vars['view'] = 'category'; $categories = PhocaCartCategory::getChildren($category->id); $found = 1; + break; } } @@ -446,13 +498,13 @@ public function parse(&$segments) { { $cid = $segment; } - + $vars['id'] = $cid; $vars['view'] = 'item'; } $found = 0; - } + }*/ diff --git a/site/views/account/tmpl/default.php b/site/views/account/tmpl/default.php index cf91df4a..32196cfe 100644 --- a/site/views/account/tmpl/default.php +++ b/site/views/account/tmpl/default.php @@ -9,11 +9,10 @@ defined('_JEXEC') or die(); echo '