From 872e0eb8337a09e94955c8f78ad90fd614587481 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 1 Oct 2024 02:00:00 +0900 Subject: [PATCH] Apply PHP_CS_FIXER_IGNORE_ENV=1 data/vendor/bin/php-cs-fixer fix --allow-risky=yes --- data/class/SC_AdminView.php | 6 +- data/class/SC_Batch.php | 3 +- data/class/SC_CartSession.php | 146 +- data/class/SC_CheckError.php | 203 +- data/class/SC_ClassAutoloader.php | 22 +- data/class/SC_Cookie.php | 2 +- data/class/SC_Customer.php | 56 +- data/class/SC_CustomerList.php | 195 +- data/class/SC_Date.php | 98 +- data/class/SC_Display.php | 14 +- data/class/SC_FormParam.php | 132 +- data/class/SC_Fpdf.php | 85 +- data/class/SC_Image.php | 103 +- data/class/SC_Initial.php | 281 ++- data/class/SC_MobileEmoji.php | 9 +- data/class/SC_MobileImage.php | 32 +- data/class/SC_MobileUserAgent.php | 22 +- data/class/SC_PageNavi.php | 21 +- data/class/SC_Product.php | 141 +- data/class/SC_Query.php | 234 ++- data/class/SC_Response.php | 70 +- data/class/SC_SelectSql.php | 77 +- data/class/SC_SendMail.php | 73 +- data/class/SC_Session.php | 7 +- data/class/SC_SessionFactory.php | 13 +- data/class/SC_SmartphoneUserAgent.php | 4 +- data/class/SC_UploadFile.php | 140 +- data/class/SC_View.php | 86 +- data/class/api/SC_Api_Abstract.php | 33 +- data/class/api/SC_Api_Operation.php | 143 +- data/class/api/SC_Api_Utils.php | 74 +- data/class/api/operations/AddrFromZip.php | 15 +- .../class/api/operations/BrowseNodeLookup.php | 29 +- data/class/api/operations/CartAdd.php | 7 +- data/class/api/operations/CartClear.php | 7 +- data/class/api/operations/CartCreate.php | 7 +- data/class/api/operations/CartGet.php | 7 +- data/class/api/operations/CartModify.php | 7 +- data/class/api/operations/Default.php | 7 +- data/class/api/operations/GetVersion.php | 7 +- data/class/api/operations/ItemLookup.php | 69 +- data/class/api/operations/ItemSearch.php | 89 +- data/class/batch/SC_Batch_Update.php | 75 +- data/class/db/SC_DB_DBFactory.php | 37 +- data/class/db/SC_DB_MasterData.php | 63 +- .../db/dbfactory/SC_DB_DBFactory_MYSQL.php | 61 +- .../db/dbfactory/SC_DB_DBFactory_PGSQL.php | 71 +- data/class/graph/SC_Graph_Bar.php | 15 +- data/class/graph/SC_Graph_Base.php | 150 +- data/class/graph/SC_Graph_Line.php | 36 +- data/class/graph/SC_Graph_Pie.php | 26 +- data/class/helper/SC_Helper_Address.php | 64 +- data/class/helper/SC_Helper_BestProducts.php | 53 +- data/class/helper/SC_Helper_Bloc.php | 47 +- data/class/helper/SC_Helper_CSV.php | 784 ++++---- data/class/helper/SC_Helper_Category.php | 48 +- data/class/helper/SC_Helper_Customer.php | 379 ++-- data/class/helper/SC_Helper_DB.php | 448 +++-- data/class/helper/SC_Helper_Delivery.php | 78 +- data/class/helper/SC_Helper_FPDI.php | 28 +- data/class/helper/SC_Helper_FileManager.php | 102 +- data/class/helper/SC_Helper_HandleError.php | 24 +- data/class/helper/SC_Helper_Holiday.php | 39 +- data/class/helper/SC_Helper_Kiyaku.php | 39 +- data/class/helper/SC_Helper_Mail.php | 115 +- data/class/helper/SC_Helper_Mailtemplate.php | 19 +- data/class/helper/SC_Helper_Maker.php | 33 +- data/class/helper/SC_Helper_Mobile.php | 112 +- data/class/helper/SC_Helper_News.php | 42 +- data/class/helper/SC_Helper_PageLayout.php | 151 +- data/class/helper/SC_Helper_Payment.php | 37 +- data/class/helper/SC_Helper_Plugin.php | 94 +- data/class/helper/SC_Helper_Purchase.php | 377 ++-- data/class/helper/SC_Helper_Session.php | 48 +- data/class/helper/SC_Helper_TaxRule.php | 114 +- data/class/helper/SC_Helper_Transform.php | 170 +- data/class/pages/LC_Page.php | 68 +- data/class/pages/LC_Page_Index.php | 5 +- data/class/pages/LC_Page_InputZip.php | 15 +- data/class/pages/LC_Page_ResizeImage.php | 37 +- data/class/pages/LC_Page_Sitemap.php | 63 +- data/class/pages/abouts/LC_Page_Abouts.php | 3 +- data/class/pages/admin/LC_Page_Admin.php | 31 +- data/class/pages/admin/LC_Page_Admin_Home.php | 51 +- .../class/pages/admin/LC_Page_Admin_Index.php | 42 +- .../pages/admin/LC_Page_Admin_Logout.php | 5 +- .../pages/admin/basis/LC_Page_Admin_Basis.php | 74 +- .../basis/LC_Page_Admin_Basis_Delivery.php | 8 +- .../LC_Page_Admin_Basis_DeliveryInput.php | 37 +- .../basis/LC_Page_Admin_Basis_Holiday.php | 23 +- .../basis/LC_Page_Admin_Basis_Kiyaku.php | 21 +- .../admin/basis/LC_Page_Admin_Basis_Mail.php | 52 +- .../basis/LC_Page_Admin_Basis_Payment.php | 7 +- .../LC_Page_Admin_Basis_PaymentInput.php | 65 +- .../admin/basis/LC_Page_Admin_Basis_Point.php | 7 +- .../admin/basis/LC_Page_Admin_Basis_Tax.php | 102 +- .../basis/LC_Page_Admin_Basis_Tradelaw.php | 53 +- .../basis/LC_Page_Admin_Basis_ZipInstall.php | 90 +- .../admin/contents/LC_Page_Admin_Contents.php | 68 +- .../contents/LC_Page_Admin_Contents_CSV.php | 75 +- .../LC_Page_Admin_Contents_CsvSql.php | 96 +- .../LC_Page_Admin_Contents_FileManager.php | 59 +- .../LC_Page_Admin_Contents_FileView.php | 18 +- .../LC_Page_Admin_Contents_Recommend.php | 66 +- ...LC_Page_Admin_Contents_RecommendSearch.php | 42 +- .../admin/customer/LC_Page_Admin_Customer.php | 34 +- .../customer/LC_Page_Admin_Customer_Edit.php | 50 +- .../LC_Page_Admin_Customer_SearchCustomer.php | 7 +- .../admin/design/LC_Page_Admin_Design.php | 84 +- .../design/LC_Page_Admin_Design_Bloc.php | 44 +- .../admin/design/LC_Page_Admin_Design_CSS.php | 55 +- .../design/LC_Page_Admin_Design_Header.php | 27 +- .../design/LC_Page_Admin_Design_MainEdit.php | 97 +- .../design/LC_Page_Admin_Design_Template.php | 81 +- .../design/LC_Page_Admin_Design_UpDown.php | 55 +- .../pages/admin/mail/LC_Page_Admin_Mail.php | 62 +- .../admin/mail/LC_Page_Admin_Mail_History.php | 29 +- .../admin/mail/LC_Page_Admin_Mail_Preview.php | 20 +- .../mail/LC_Page_Admin_Mail_Template.php | 15 +- .../mail/LC_Page_Admin_Mail_TemplateInput.php | 26 +- .../pages/admin/order/LC_Page_Admin_Order.php | 183 +- .../admin/order/LC_Page_Admin_Order_Disp.php | 164 +- .../admin/order/LC_Page_Admin_Order_Edit.php | 469 ++--- .../admin/order/LC_Page_Admin_Order_Mail.php | 44 +- .../order/LC_Page_Admin_Order_MailView.php | 7 +- .../order/LC_Page_Admin_Order_Multiple.php | 3 +- .../admin/order/LC_Page_Admin_Order_Pdf.php | 69 +- .../LC_Page_Admin_Order_ProductSelect.php | 67 +- .../order/LC_Page_Admin_Order_Status.php | 37 +- .../ownersstore/LC_Page_Admin_OwnersStore.php | 214 ++- .../LC_Page_Admin_OwnersStore_Log.php | 17 +- .../LC_Page_Admin_OwnersStore_Module.php | 7 +- ..._Admin_OwnersStore_PluginHookPointList.php | 20 +- .../LC_Page_Admin_OwnersStore_Settings.php | 28 +- .../admin/products/LC_Page_Admin_Products.php | 116 +- .../LC_Page_Admin_Products_Category.php | 133 +- .../products/LC_Page_Admin_Products_Class.php | 128 +- .../LC_Page_Admin_Products_ClassCategory.php | 84 +- .../products/LC_Page_Admin_Products_Maker.php | 30 +- .../LC_Page_Admin_Products_Product.php | 380 ++-- .../LC_Page_Admin_Products_ProductClass.php | 215 +-- .../LC_Page_Admin_Products_ProductRank.php | 19 +- .../LC_Page_Admin_Products_ProductSelect.php | 14 +- .../LC_Page_Admin_Products_Review.php | 108 +- .../LC_Page_Admin_Products_ReviewEdit.php | 40 +- .../LC_Page_Admin_Products_UploadCSV.php | 194 +- ..._Page_Admin_Products_UploadCSVCategory.php | 148 +- .../admin/system/LC_Page_Admin_System.php | 43 +- .../system/LC_Page_Admin_System_AdminArea.php | 77 +- .../system/LC_Page_Admin_System_Bkup.php | 148 +- .../system/LC_Page_Admin_System_Delete.php | 29 +- .../system/LC_Page_Admin_System_Editdb.php | 46 +- .../system/LC_Page_Admin_System_Input.php | 126 +- .../admin/system/LC_Page_Admin_System_Log.php | 42 +- .../LC_Page_Admin_System_Masterdata.php | 22 +- .../system/LC_Page_Admin_System_Parameter.php | 24 +- .../system/LC_Page_Admin_System_Rank.php | 25 +- .../system/LC_Page_Admin_System_System.php | 34 +- .../pages/admin/total/LC_Page_Admin_Total.php | 295 ++- data/class/pages/api/LC_Page_Api.php | 3 +- data/class/pages/api/LC_Page_Api_Json.php | 7 +- data/class/pages/api/LC_Page_Api_Php.php | 3 +- data/class/pages/api/LC_Page_Api_Xml.php | 3 +- data/class/pages/cart/LC_Page_Cart.php | 48 +- data/class/pages/contact/LC_Page_Contact.php | 43 +- .../contact/LC_Page_Contact_Complete.php | 3 +- data/class/pages/entry/LC_Page_Entry.php | 87 +- .../pages/entry/LC_Page_Entry_Complete.php | 3 +- .../pages/entry/LC_Page_Entry_EmailMobile.php | 26 +- .../pages/entry/LC_Page_Entry_Kiyaku.php | 23 +- data/class/pages/error/LC_Page_Error.php | 56 +- .../pages/error/LC_Page_Error_DispError.php | 18 +- .../pages/error/LC_Page_Error_SystemError.php | 24 +- data/class/pages/forgot/LC_Page_Forgot.php | 59 +- .../LC_Page_FrontParts_LoginCheck.php | 22 +- .../bloc/LC_Page_FrontParts_Bloc.php | 6 +- .../bloc/LC_Page_FrontParts_Bloc_Calendar.php | 27 +- .../bloc/LC_Page_FrontParts_Bloc_Cart.php | 10 +- .../bloc/LC_Page_FrontParts_Bloc_Category.php | 19 +- .../bloc/LC_Page_FrontParts_Bloc_Login.php | 7 +- .../LC_Page_FrontParts_Bloc_LoginFooter.php | 3 +- .../LC_Page_FrontParts_Bloc_LoginHeader.php | 3 +- .../LC_Page_FrontParts_Bloc_NaviFooter.php | 3 +- .../LC_Page_FrontParts_Bloc_NaviHeader.php | 22 +- .../bloc/LC_Page_FrontParts_Bloc_News.php | 30 +- .../LC_Page_FrontParts_Bloc_Recommend.php | 9 +- ...LC_Page_FrontParts_Bloc_SearchProducts.php | 11 +- data/class/pages/guide/LC_Page_Guide.php | 3 +- .../class/pages/guide/LC_Page_Guide_About.php | 7 +- .../pages/guide/LC_Page_Guide_Charge.php | 3 +- .../pages/guide/LC_Page_Guide_Kiyaku.php | 8 +- .../pages/guide/LC_Page_Guide_Privacy.php | 3 +- .../class/pages/guide/LC_Page_Guide_Usage.php | 3 +- .../pages/mypage/LC_Page_AbstractMypage.php | 17 +- data/class/pages/mypage/LC_Page_Mypage.php | 37 +- .../pages/mypage/LC_Page_Mypage_Change.php | 53 +- .../mypage/LC_Page_Mypage_ChangeComplete.php | 3 +- .../pages/mypage/LC_Page_Mypage_Delivery.php | 36 +- .../mypage/LC_Page_Mypage_DeliveryAddr.php | 46 +- .../pages/mypage/LC_Page_Mypage_DownLoad.php | 113 +- .../pages/mypage/LC_Page_Mypage_Favorite.php | 46 +- .../pages/mypage/LC_Page_Mypage_History.php | 75 +- .../pages/mypage/LC_Page_Mypage_Login.php | 5 +- .../pages/mypage/LC_Page_Mypage_MailView.php | 21 +- .../pages/mypage/LC_Page_Mypage_Order.php | 31 +- .../pages/mypage/LC_Page_Mypage_Refusal.php | 34 +- .../mypage/LC_Page_Mypage_RefusalComplete.php | 9 +- data/class/pages/order/LC_Page_Order.php | 3 +- data/class/pages/preview/LC_Page_Preview.php | 3 +- .../LC_Page_Products_CategoryList.php | 13 +- .../products/LC_Page_Products_Detail.php | 168 +- .../pages/products/LC_Page_Products_List.php | 197 +- .../products/LC_Page_Products_Review.php | 40 +- .../LC_Page_Products_ReviewComplete.php | 3 +- .../products/LC_Page_Products_Search.php | 3 +- data/class/pages/regist/LC_Page_Regist.php | 75 +- .../pages/regist/LC_Page_Regist_Complete.php | 3 +- data/class/pages/rss/LC_Page_Rss.php | 22 +- data/class/pages/rss/LC_Page_Rss_Products.php | 67 +- .../class/pages/shopping/LC_Page_Shopping.php | 77 +- .../shopping/LC_Page_Shopping_Complete.php | 5 +- .../shopping/LC_Page_Shopping_Confirm.php | 24 +- .../pages/shopping/LC_Page_Shopping_Deliv.php | 68 +- .../LC_Page_Shopping_LoadPaymentModule.php | 15 +- .../shopping/LC_Page_Shopping_Multiple.php | 110 +- .../shopping/LC_Page_Shopping_Payment.php | 85 +- .../pages/unsupported/LC_Page_Unsupported.php | 3 +- .../pages/upgrade/LC_Page_Upgrade_Base.php | 23 +- .../upgrade/LC_Page_Upgrade_Download.php | 184 +- .../upgrade/LC_Page_Upgrade_ProductsList.php | 38 +- .../upgrade/helper/LC_Upgrade_Helper_Json.php | 26 +- .../upgrade/helper/LC_Upgrade_Helper_Log.php | 5 +- data/class/plugin/SC_Plugin_Base.php | 14 +- data/class/plugin/SC_Plugin_Installer.php | 121 +- data/class/plugin/SC_Plugin_Util.php | 67 +- .../SC_SessionFactory_UseCookie.php | 11 +- .../SC_SessionFactory_UseRequest.php | 96 +- data/class/util/GC_Utils.php | 91 +- data/class/util/SC_Utils.php | 500 +++-- data/class_extends/SC_ClassAutoloader_Ex.php | 2 +- data/class_extends/SC_Query_Ex.php | 2 +- .../helper_extends/SC_Helper_Plugin_Ex.php | 4 +- .../class_extends/page_extends/LC_Page_Ex.php | 2 +- .../page_extends/admin/LC_Page_Admin_Ex.php | 2 +- .../mypage/LC_Page_AbstractMypage_Ex.php | 8 +- data/module/Calendar/Calendar.php | 357 ++-- data/module/Calendar/Day.php | 92 +- data/module/Calendar/Decorator.php | 254 +-- data/module/Calendar/Decorator/Textual.php | 69 +- data/module/Calendar/Decorator/Uri.php | 55 +- data/module/Calendar/Decorator/Weekday.php | 64 +- data/module/Calendar/Decorator/Wrapper.php | 24 +- data/module/Calendar/Engine/Interface.php | 119 +- data/module/Calendar/Engine/PearDate.php | 187 +- data/module/Calendar/Engine/UnixTS.php | 188 +- data/module/Calendar/Factory.php | 36 +- data/module/Calendar/Hour.php | 38 +- data/module/Calendar/Minute.php | 32 +- data/module/Calendar/Month.php | 27 +- data/module/Calendar/Month/Weekdays.php | 67 +- data/module/Calendar/Month/Weeks.php | 48 +- data/module/Calendar/Second.php | 28 +- data/module/Calendar/Table/Helper.php | 103 +- data/module/Calendar/Util/Textual.php | 111 +- data/module/Calendar/Util/Uri.php | 91 +- data/module/Calendar/Validator.php | 146 +- data/module/Calendar/Week.php | 128 +- data/module/Calendar/Year.php | 26 +- data/module/HTTP/Request.php | 1361 +++++++------- data/module/HTTP/Request/Listener.php | 209 ++- data/module/Net/SMTP.php | 264 ++- data/module/Net/Socket.php | 216 +-- data/module/Net/URL.php | 355 ++-- data/module/SOAP/Base.php | 422 +++-- data/module/SOAP/Client.php | 216 ++- data/module/SOAP/Disco.php | 175 +- data/module/SOAP/Fault.php | 32 +- data/module/SOAP/Parser.php | 113 +- data/module/SOAP/Server.php | 218 ++- data/module/SOAP/Server/Email.php | 50 +- data/module/SOAP/Server/Email_Gateway.php | 43 +- data/module/SOAP/Server/TCP.php | 52 +- data/module/SOAP/Server/TCP/Handler.php | 35 +- data/module/SOAP/Transport.php | 32 +- data/module/SOAP/Transport/HTTP.php | 172 +- data/module/SOAP/Transport/SMTP.php | 85 +- data/module/SOAP/Transport/TCP.php | 69 +- data/module/SOAP/Transport/TEST.php | 14 +- data/module/SOAP/Type/dateTime.php | 93 +- data/module/SOAP/Type/duration.php | 103 +- data/module/SOAP/Type/hexBinary.php | 20 +- data/module/SOAP/Value.php | 88 +- data/module/SOAP/WSDL.php | 1645 +++++++++-------- data/module/fpdi/japanese.php | 684 ++++--- data/module/gdthumb.php | 463 ++--- data/smarty_extends/block.marquee.php | 4 +- data/smarty_extends/function.from_to.php | 11 +- .../function.include_php_ex.php | 21 +- data/smarty_extends/modifier.h.php | 6 +- data/smarty_extends/modifier.n2s.php | 12 +- data/smarty_extends/modifier.nl2br_html.php | 12 +- .../smarty_extends/modifier.numeric_emoji.php | 7 +- .../smarty_extends/modifier.script_escape.php | 17 +- data/smarty_extends/modifier.u.php | 6 +- tests/class/Common_TestCase.php | 60 +- .../SC_CartSession/SC_CartSessionTest.php | 6 +- .../SC_CartSession_TestBase.php | 75 +- .../SC_CartSession_getAllCartListTest.php | 30 +- .../SC_CartSession_getCartListTest.php | 143 +- .../SC_CheckError_ALL_EXIST_CHECKTest.php | 18 +- .../SC_CheckError_ALNUM_CHECKTest.php | 11 +- .../SC_CheckError_ALPHA_CHECKTest.php | 18 +- .../SC_CheckError_AbstractTestCase.php | 2 +- .../SC_CheckError_CHECK_BIRTHDAYTest.php | 24 +- .../SC_CheckError_CHECK_DATE2Test.php | 24 +- .../SC_CheckError_CHECK_DATE3Test.php | 16 +- .../SC_CheckError_CHECK_DATETest.php | 18 +- ...kError_CHECK_REGIST_CUSTOMER_EMAILTest.php | 10 +- .../SC_CheckError_CHECK_SET_TERM2Test.php | 41 +- .../SC_CheckError_CHECK_SET_TERM3Test.php | 25 +- .../SC_CheckError_CHECK_SET_TERMTest.php | 29 +- .../SC_CheckError_DIFFERENT_CHECKTest.php | 14 +- .../SC_CheckError_DIR_CHECKTest.php | 8 +- .../SC_CheckError_DOMAIN_CHECKTest.php | 9 +- .../SC_CheckError_EMAIL_CHAR_CHECKTest.php | 10 +- .../SC_CheckError_EMAIL_CHECKTest.php | 18 +- .../SC_CheckError_EQUAL_CHECKTest.php | 14 +- .../SC_CheckError_EVAL_CHECKTest.php | 12 +- .../SC_CheckError_EXIST_CHECKTest.php | 28 +- .../SC_CheckError_EXIST_CHECK_REVERSETest.php | 9 +- .../SC_CheckError_FILE_EXIST_CHECKTest.php | 12 +- .../SC_CheckError_FILE_EXT_CHECKTest.php | 10 +- .../SC_CheckError_FILE_NAME_CHECKTest.php | 8 +- ...kError_FILE_NAME_CHECK_BY_NOUPLOADTest.php | 55 +- .../SC_CheckError_FILE_SIZE_CHECKTest.php | 12 +- .../SC_CheckError_FIND_FILETest.php | 10 +- .../SC_CheckError_FULL_EXIST_CHECKTest.php | 18 +- .../SC_CheckError_GRAPH_CHECKTest.php | 13 +- .../SC_CheckError_GREATER_CHECKTest.php | 26 +- .../SC_CheckError_HTML_TAG_CHECKTest.php | 13 +- .../SC_CheckError_IP_CHECKTest.php | 12 +- .../SC_CheckError_KANABLANK_CHECKTest.php | 20 +- .../SC_CheckError_KANA_CHECKTest.php | 18 +- .../SC_CheckError_MAX_CHECKTest.php | 12 +- .../SC_CheckError_MAX_LENGTH_CHECKTest.php | 10 +- .../SC_CheckError_MIN_CHECKTest.php | 12 +- .../SC_CheckError_MIN_LENGTH_CHECKTest.php | 10 +- .../SC_CheckError_MOBILE_EMAIL_CHECKTest.php | 9 +- .../SC_CheckError_NO_SPTABTest.php | 35 +- .../SC_CheckError_NUM_CHECKTest.php | 16 +- .../SC_CheckError_NUM_COUNT_CHECKTest.php | 14 +- .../SC_CheckError_NUM_POINT_CHECKTest.php | 16 +- .../SC_CheckError_NUM_RANGE_CHECKTest.php | 18 +- .../SC_CheckError_ONE_EXIST_CHECKTest.php | 18 +- .../SC_CheckError_PASSWORD_CHAR_CHECKTest.php | 17 +- .../SC_CheckError_PREF_CHECKTest.php | 11 +- ...SC_CheckError_PROHIBITED_STR_CHECKTest.php | 9 +- .../SC_CheckError_SELECT_CHECKTest.php | 6 +- .../SC_CheckError_SPTAB_CHECKTest.php | 31 +- .../SC_CheckError_TEL_CHECKTest.php | 24 +- .../SC_CheckError_TOP_EXIST_CHECKTest.php | 18 +- .../SC_CheckError_URL_CHECKTest.php | 8 +- .../SC_CheckError_ZERO_CHECKTest.php | 13 +- .../SC_CheckError_ZERO_STARTTest.php | 6 +- .../SC_CheckError_createParamTest.php | 20 +- tests/class/SC_CustomerListTest.php | 5 +- tests/class/SC_CustomerTest.php | 2 +- tests/class/SC_Date/SC_Date_AccessorTest.php | 28 +- tests/class/SC_Date/SC_Date_getDayTest.php | 29 +- tests/class/SC_Date/SC_Date_getHourTest.php | 20 +- .../SC_Date_getMinutesIntervalTest.php | 14 +- .../class/SC_Date/SC_Date_getMinutesTest.php | 20 +- tests/class/SC_Date/SC_Date_getMonthTest.php | 29 +- tests/class/SC_Date/SC_Date_getYearTest.php | 74 +- .../SC_Date/SC_Date_getZeroMonthTest.php | 22 +- .../class/SC_Date/SC_Date_getZeroYearTest.php | 48 +- tests/class/SC_Date/SC_Date_isHolidayTest.php | 59 +- tests/class/SC_DisplayTest.php | 2 +- tests/class/SC_FormParamTest.php | 103 +- tests/class/SC_FpdfTest.php | 10 +- .../class/SC_Product/SC_Product_TestBase.php | 79 +- .../SC_Product_findProductCountTest.php | 20 +- .../SC_Product_findProductIdsOrderTest.php | 26 +- .../SC_Product/SC_Product_getBuyLimitTest.php | 54 +- ..._Product_getDetailAndProductsClassTest.php | 107 +- .../SC_Product/SC_Product_getDetailTest.php | 85 +- .../SC_Product_getListByProductIdsTest.php | 62 +- .../SC_Product_getProductStatusTest.php | 25 +- ...oduct_getProductsClassByProductIdsTest.php | 133 +- ...SC_Product_getProductsClassByQueryTest.php | 48 +- .../SC_Product_getProductsClassTest.php | 44 +- .../class/SC_Product/SC_Product_listsTest.php | 33 +- .../SC_Product/SC_Product_reduceStockTest.php | 26 +- .../SC_Product_setProductStatusTest.php | 22 +- .../SC_Product_setProductsOrderTest.php | 19 +- tests/class/SC_Query_Test.php | 101 +- .../SC_ResponseSendRedirectWithHeaderTest.php | 36 +- tests/class/SC_Response/SC_ResponseTest.php | 5 - .../SC_Response/SC_ResponseWithHeaderTest.php | 2 +- .../SC_ResponseWithoutModeTest.php | 4 - tests/class/SC_SessionTest.php | 3 +- .../SC_SiteSession_checkUniqIdTest.php | 21 +- .../SC_SiteSession_getUniqIdTest.php | 11 +- .../SC_SiteSession_getValueTest.php | 12 +- .../SC_SiteSession_isPrepageTest.php | 30 +- .../SC_SiteSession_setNowPageTest.php | 12 +- .../SC_SiteSession_setRegistFlagTest.php | 11 +- .../SC_SiteSession_setUniqIdTest.php | 11 +- .../SC_SiteSession_unsetUniqIdTest.php | 11 +- ...C_SmartphoneUserAgent_isSmartphoneTest.php | 251 ++- tests/class/SC_UploadFileTest.php | 61 +- .../page_extends/LC_Page_Index_Ex.php | 1 + .../admin/LC_Page_Admin_Home_Ex.php | 1 + .../LC_Page_Admin_Customer_Edit_Ex.php | 1 + .../admin/total/LC_Page_Admin_Total_Ex.php | 1 + .../mypage/LC_Page_Mypage_Change_Ex.php | 1 + .../plugin/FixturePlugin/FixturePlugin.php | 9 +- .../PrefilterTransformPlugin.php | 43 +- .../PrefilterTransformPlugin/plugin_info.php | 20 +- tests/class/fixtures/server/common.php | 2 +- .../server/sc_response_sendRedirect.php | 7 +- .../SC_Helper_Address_TestBase.php | 30 +- .../SC_Helper_Address_deleteAddressTest.php | 23 +- .../SC_Helper_Address_getAddressTest.php | 30 +- .../SC_Helper_Address_getListTest.php | 47 +- .../SC_Helper_Address_registAddressTest.php | 51 +- .../SC_Helper_BestProducts_TestBase.php | 37 +- ...er_BestProducts_deleteBestProductsTest.php | 21 +- ...er_BestProducts_deleteByProductIDsTest.php | 18 +- ...elper_BestProducts_getBestProductsTest.php | 37 +- .../SC_Helper_BestProducts_getByRankTest.php | 37 +- .../SC_Helper_BestProducts_getListTest.php | 92 +- .../SC_Helper_BestProducts_rankDownTest.php | 12 +- .../SC_Helper_BestProducts_rankUpTest.php | 12 +- ...lper_BestProducts_saveBestProductsTest.php | 64 +- .../SC_Helper_DB/SC_Helper_DB_TestBase.php | 53 +- .../SC_Helper_DB_registerBasisDataTest.php | 2 + .../SC_Helper_DB_sfColumnAddTest.php | 8 +- .../SC_Helper_DB_sfColumnExistsTest.php | 11 +- .../SC_Helper_DB_sfCountCategoryTest.php | 4 +- ...C_Helper_DB_sfCreateBasisDataCacheTest.php | 18 +- .../SC_Helper_DB_sfDataExistsTest.php | 15 +- .../SC_Helper_DB_sfGetAddPointTest.php | 2 +- .../SC_Helper_DB_sfGetBasisCountTest.php | 14 +- .../SC_Helper_DB_sfGetBasisDataCacheTest.php | 16 +- .../SC_Helper_DB_sfGetBasisDataTest.php | 22 +- .../SC_Helper_DB_sfGetBasisExistsTest.php | 8 +- .../SC_Helper_DB_sfGetCategoryIdTest.php | 2 +- .../SC_Helper_DB_sfGetChildrenArrayTest.php | 3 +- .../SC_Helper_DB_sfGetIDValueListTest.php | 1 - .../SC_Helper_DB_sfGetLevelCatListTest.php | 10 +- .../SC_Helper_DB_sfGetMakerIdTest.php | 3 +- .../SC_Helper_DB_sfGetMultiCatTreeTest.php | 2 - .../SC_Helper_DB_sfGetParentsArrayTest.php | 1 - .../SC_Helper_DB_sfGetRollbackPointTest.php | 1 + .../SC_Helper_DB_sfMoveRankTest.php | 28 +- .../helper/SC_Helper_FileManagerTest.php | 1 + .../SC_Helper_Kiyaku_TestBase.php | 30 +- .../SC_Helper_Kiyaku_deleteKiyakuTest.php | 21 +- .../SC_Helper_Kiyaku_getKiyakuTest.php | 43 +- .../SC_Helper_Kiyaku_getListTest.php | 55 +- .../SC_Helper_Kiyaku_isTitleExistTest.php | 27 +- .../SC_Helper_Kiyaku_rankDownTest.php | 19 +- .../SC_Helper_Kiyaku_rankUpTest.php | 19 +- .../SC_Helper_Kiyaku_saveKiyakuTest.php | 26 +- .../SC_Helper_Maker_TestBase.php | 33 +- .../SC_Helper_Maker_getByNameTest.php | 47 +- .../SC_Helper_Maker_getListTest.php | 57 +- .../SC_Helper_Maker_getMakerTest.php | 47 +- .../SC_Helper_Maker_saveMakerTest.php | 44 +- .../SC_Helper_News_TestBase.php | 28 +- .../SC_Helper_News_deleteNewsTest.php | 18 +- .../SC_Helper_News_getCountTest.php | 15 +- .../SC_Helper_News_getListTest.php | 87 +- .../SC_Helper_News_getNewsTest.php | 25 +- .../SC_Helper_News_moveRankTest.php | 18 +- .../SC_Helper_News_rankDownTest.php | 18 +- .../SC_Helper_News_rankUpTest.php | 18 +- .../SC_Helper_News_saveNewsTest.php | 58 +- .../SC_Helper_Purchase_TestBase.php | 197 +- .../SC_Helper_Purchase_cancelOrderTest.php | 248 +-- .../SC_Helper_Purchase_cleanupSessionTest.php | 83 +- ...per_Purchase_clearShipmentItemTempTest.php | 154 +- .../SC_Helper_Purchase_completeOrderTest.php | 224 +-- ...C_Helper_Purchase_copyFromCustomerTest.php | 214 ++- .../SC_Helper_Purchase_copyFromOrderTest.php | 77 +- ...SC_Helper_Purchase_extractShippingTest.php | 52 +- .../SC_Helper_Purchase_getOrderDetailTest.php | 163 +- .../SC_Helper_Purchase_getOrderTempTest.php | 79 +- .../SC_Helper_Purchase_getOrderTest.php | 127 +- ...C_Helper_Purchase_getShipmentItemsTest.php | 180 +- ...SC_Helper_Purchase_getShippingPrefTest.php | 56 +- ...SC_Helper_Purchase_getShippingTempTest.php | 68 +- .../SC_Helper_Purchase_getShippingsTest.php | 123 +- .../SC_Helper_Purchase_isAddPointTest.php | 140 +- .../SC_Helper_Purchase_isUsePointTest.php | 64 +- ...per_Purchase_registerOrderCompleteTest.php | 178 +- ...elper_Purchase_registerOrderDetailTest.php | 116 +- .../SC_Helper_Purchase_registerOrderTest.php | 81 +- ...lper_Purchase_registerShipmentItemTest.php | 269 ++- ...C_Helper_Purchase_registerShippingTest.php | 250 ++- .../SC_Helper_Purchase_rollbackOrderTest.php | 181 +- .../SC_Helper_Purchase_saveOrderTempTest.php | 233 ++- ...C_Helper_Purchase_saveShippingTempTest.php | 100 +- ...lper_Purchase_setDownloadableFlgToTest.php | 163 +- ...urchase_setShipmentItemTempForSoleTest.php | 97 +- ...elper_Purchase_setShipmentItemTempTest.php | 90 +- ...lper_Purchase_sfUpdateOrderNameColTest.php | 169 +- ...elper_Purchase_sfUpdateOrderStatusTest.php | 635 +++---- ...lper_Purchase_unsetAllShippingTempTest.php | 64 +- ...C_Helper_Purchase_unsetOneShippingTest.php | 56 +- ..._Helper_Purchase_unsetShippingTempTest.php | 58 +- .../SC_Helper_TaxRule_TestBase.php | 31 +- .../SC_Helper_TaxRule_getTaxDetailTest.php | 2 + .../SC_Helper_TaxRule_getTaxRuleTest.php | 43 +- ...le_getTaxRule_OptionProductTaxRuleTest.php | 60 +- .../SC_Helper_TaxRule_setTaxRuleTest.php | 19 +- .../modifier/Modifier_ScriptEscapeTest.php | 84 +- tests/class/module/Calendar/CalendarTest.php | 70 +- tests/class/module/HTTP/RequestTest.php | 11 +- .../module/XML/Serializer_ObjectsTest.php | 43 +- .../LC_Page_Admin_Products_UploadCSVTest.php | 24 +- .../LoadClassFileChangeCustomDirTest.php | 2 +- .../class/plugin/LoadClassFileChangeTest.php | 11 +- tests/class/test/util/Test_Utils.php | 102 +- tests/class/test/util/User_Utils.php | 96 +- .../SC_Utils_arrayDefineIndexesTest.php | 63 +- .../SC_Utils_clearCompliedTemplateTest.php | 61 +- .../SC_Utils/SC_Utils_copyDirectoryTest.php | 259 ++- .../SC_Utils/SC_Utils_encodeRFC3986Test.php | 51 +- .../SC_Utils/SC_Utils_getHash2ArrayTest.php | 59 +- .../util/SC_Utils/SC_Utils_getRealURLTest.php | 87 +- .../SC_Utils_getSaveImagePathTest.php | 71 +- .../SC_Utils_isAbsoluteRealPathTest.php | 23 +- .../SC_Utils/SC_Utils_isAppInnerUrlTest.php | 91 +- .../util/SC_Utils/SC_Utils_isBlankTest.php | 224 ++- .../SC_Utils_isInternalDomainTest.php | 72 +- .../util/SC_Utils/SC_Utils_jsonDecodeTest.php | 54 +- .../util/SC_Utils/SC_Utils_jsonEncodeTest.php | 50 +- .../SC_Utils/SC_Utils_recursiveMkDirTest.php | 26 +- .../SC_Utils_repeatStrWithSeparatorTest.php | 74 +- .../SC_Utils/SC_Utils_sfArrCombineTest.php | 95 +- .../SC_Utils/SC_Utils_sfArrKeyValueTest.php | 108 +- .../SC_Utils_sfArrayIntersectKeysTest.php | 61 +- .../SC_Utils/SC_Utils_sfCalcIncTaxTest.php | 82 +- .../util/SC_Utils/SC_Utils_sfCopyDirtest.php | 332 ++-- .../SC_Utils/SC_Utils_sfCutStringTest.php | 279 ++- .../SC_Utils/SC_Utils_sfDBDateToTimeTest.php | 55 +- .../SC_Utils/SC_Utils_sfDispDBDateTest.php | 125 +- .../SC_Utils/SC_Utils_sfEncodeFileTest.php | 72 +- .../SC_Utils/SC_Utils_sfErrorHeaderTest.php | 61 +- .../util/SC_Utils/SC_Utils_sfFlushTest.php | 62 +- .../SC_Utils/SC_Utils_sfGetAddPointTest.php | 65 +- .../SC_Utils/SC_Utils_sfGetAddressTest.php | 206 +-- .../SC_Utils/SC_Utils_sfGetCSVListTest.php | 59 +- .../SC_Utils/SC_Utils_sfGetCheckedTest.php | 53 +- .../SC_Utils_sfGetClassCatCountTest.php | 108 +- .../SC_Utils/SC_Utils_sfGetCommaListTest.php | 94 +- .../SC_Utils/SC_Utils_sfGetEnabledTest.php | 57 +- .../SC_Utils/SC_Utils_sfGetErrorColorTest.php | 57 +- ...Utils_sfGetHashString_authTypeHmacTest.php | 52 +- ...tils_sfGetHashString_authTypePlainTest.php | 47 +- .../SC_Utils_sfGetProductClassIdTest.php | 124 +- .../SC_Utils_sfGetRandomStringTest.php | 54 +- .../SC_Utils_sfGetSearchPageMaxTest.php | 81 +- .../SC_Utils/SC_Utils_sfGetTimestampTest.php | 147 +- .../SC_Utils_sfGetUnderChildrenArrayTest.php | 65 +- .../SC_Utils_sfGetUniqRandomIdTest.php | 64 +- .../util/SC_Utils/SC_Utils_sfIsHTTPSTest.php | 71 +- .../util/SC_Utils/SC_Utils_sfIsIntTest.php | 167 +- ...sfIsMatchHashPassword_authTypeHmacTest.php | 80 +- ...fIsMatchHashPassword_authTypePlainTest.php | 67 +- .../SC_Utils/SC_Utils_sfIsSucceessTest.php | 109 +- .../SC_Utils/SC_Utils_sfIsZeroFillingTest.php | 62 +- .../SC_Utils_sfMakeHiddenArrayTest.php | 58 +- .../SC_Utils_sfMbConvertEncodingTest.php | 52 +- .../util/SC_Utils/SC_Utils_sfMultiplyTest.php | 49 +- .../SC_Utils_sfNoImageMainListTest.php | 65 +- .../SC_Utils/SC_Utils_sfNoImageMainTest.php | 65 +- .../util/SC_Utils/SC_Utils_sfPassLenTest.php | 57 +- .../util/SC_Utils/SC_Utils_sfPrePointTest.php | 99 +- .../util/SC_Utils/SC_Utils_sfPrintRTest.php | 61 +- .../SC_Utils/SC_Utils_sfRmDupSlashTest.php | 71 +- .../SC_Utils/SC_Utils_sfSetErrorStyleTest.php | 50 +- .../SC_Utils/SC_Utils_sfSwapArrayTest.php | 81 +- .../util/SC_Utils/SC_Utils_sfTaxTest.php | 82 +- .../SC_Utils/SC_Utils_sfTermMonthTest.php | 77 +- .../util/SC_Utils/SC_Utils_sfTrimTest.php | 54 +- .../util/SC_Utils/SC_Utils_sfTrimURLTest.php | 63 +- .../SC_Utils/SC_Utils_sfUpDirNameTest.php | 43 +- tests/config.php | 3 +- tests/require.php | 21 +- 592 files changed, 20932 insertions(+), 20328 deletions(-) diff --git a/data/class/SC_AdminView.php b/data/class/SC_AdminView.php index 78b5001da7..737069f1e8 100644 --- a/data/class/SC_AdminView.php +++ b/data/class/SC_AdminView.php @@ -29,8 +29,8 @@ public function init() $this->_smarty->setTemplateDir(realpath(TEMPLATE_ADMIN_REALDIR)); $this->_smarty->setCompileDir(realpath(COMPILE_ADMIN_REALDIR)); - $this->assign('TPL_URLPATH_PC', ROOT_URLPATH . USER_DIR . USER_PACKAGE_DIR . TEMPLATE_NAME . '/'); - $this->assign('TPL_URLPATH_DEFAULT', ROOT_URLPATH . USER_DIR . USER_PACKAGE_DIR . DEFAULT_TEMPLATE_NAME . '/'); - $this->assign('TPL_URLPATH', ROOT_URLPATH . USER_DIR . USER_PACKAGE_DIR . 'admin/'); + $this->assign('TPL_URLPATH_PC', ROOT_URLPATH.USER_DIR.USER_PACKAGE_DIR.TEMPLATE_NAME.'/'); + $this->assign('TPL_URLPATH_DEFAULT', ROOT_URLPATH.USER_DIR.USER_PACKAGE_DIR.DEFAULT_TEMPLATE_NAME.'/'); + $this->assign('TPL_URLPATH', ROOT_URLPATH.USER_DIR.USER_PACKAGE_DIR.'admin/'); } } diff --git a/data/class/SC_Batch.php b/data/class/SC_Batch.php index 0209374ef8..cae7efb8c8 100644 --- a/data/class/SC_Batch.php +++ b/data/class/SC_Batch.php @@ -24,8 +24,8 @@ /** * バッチ処理用 の基底クラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_Batch @@ -34,6 +34,7 @@ class SC_Batch * バッチ処理を実行する * * @param mixed $argv コマンドライン引数 + * * @return mixed バッチの実行結果 */ public function execute($argv = '') diff --git a/data/class/SC_CartSession.php b/data/class/SC_CartSession.php index 4b743a527d..b457ea576b 100644 --- a/data/class/SC_CartSession.php +++ b/data/class/SC_CartSession.php @@ -25,6 +25,7 @@ * カートセッション管理クラス * * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_CartSession @@ -39,7 +40,7 @@ class SC_CartSession public function __construct($cartKey = 'cart') { if (!isset($_SESSION[$cartKey])) { - $_SESSION[$cartKey] = array(); + $_SESSION[$cartKey] = []; } $this->cartSession = &$_SESSION[$cartKey]; } @@ -48,11 +49,11 @@ public function __construct($cartKey = 'cart') /** * @param string $key_tmp - * @param integer $product_type_id + * @param int $product_type_id */ public function saveCurrentCart($key_tmp, $product_type_id) { - $this->key_tmp = 'savecart_' . $key_tmp; + $this->key_tmp = 'savecart_'.$key_tmp; // すでに情報がなければ現状のカート情報を記録しておく if (!isset($_SESSION[$this->key_tmp])) { $_SESSION[$this->key_tmp] = $this->cartSession[$product_type_id]; @@ -78,7 +79,7 @@ public function getCancelPurchase($product_type_id) // 購入処理中に商品に変更がなかったかを判定 /** - * @param integer $product_type_id + * @param int $product_type_id */ public function checkChangeCart($product_type_id) { @@ -114,7 +115,7 @@ public function checkChangeCart($product_type_id) // 次に割り当てるカートのIDを取得する public function getNextCartID($product_type_id) { - $count = array(); + $count = []; foreach ($this->cartSession[$product_type_id] as $key => $value) { $count[] = $this->cartSession[$product_type_id][$key]['cart_no']; } @@ -167,7 +168,7 @@ public function getTotalQuantity($product_type_id) $total = 0; $max = $this->getMax($product_type_id); for ($i = 0; $i <= $max; $i++) { - $total += (int)$this->cartSession[$product_type_id][$i]['quantity']; + $total += (int) $this->cartSession[$product_type_id][$i]['quantity']; } return $total; @@ -230,7 +231,7 @@ public function getAllProductsTax($product_type_id, $pref_id = 0, $country_id = // 全商品の合計ポイント /** - * @param integer $product_type_id + * @param int $product_type_id */ public function getAllProductsPoint($product_type_id) { @@ -284,17 +285,17 @@ public function addProduct($product_class_id, $quantity) * * @deprecated 2.18.0 本体では呼ばれない。 */ - public function setPrevURL($url, $excludePaths = array()) + public function setPrevURL($url, $excludePaths = []) { // 前頁として記録しないページを指定する。 - $arrExclude = array( + $arrExclude = [ '/shopping/' - ); + ]; $arrExclude = array_merge($arrExclude, $excludePaths); $exclude = false; // ページチェックを行う。 foreach ($arrExclude as $val) { - if (preg_match('|' . preg_quote($val) . '|', $url)) { + if (preg_match('|'.preg_quote($val).'|', $url)) { $exclude = true; break; } @@ -345,23 +346,23 @@ public function getValue($key, $product_type_id) */ public function adjustSessionProductsClass(&$arrProductsClass) { - $arrNecessaryItems = array( - 'product_id' => true, - 'product_class_id' => true, - 'name' => true, - 'price02' => true, - 'point_rate' => true, - 'main_list_image' => true, - 'main_image' => true, - 'product_code' => true, - 'stock' => true, - 'stock_unlimited' => true, - 'sale_limit' => true, - 'class_name1' => true, + $arrNecessaryItems = [ + 'product_id' => true, + 'product_class_id' => true, + 'name' => true, + 'price02' => true, + 'point_rate' => true, + 'main_list_image' => true, + 'main_image' => true, + 'product_code' => true, + 'stock' => true, + 'stock_unlimited' => true, + 'sale_limit' => true, + 'class_name1' => true, 'classcategory_name1' => true, - 'class_name2' => true, + 'class_name2' => true, 'classcategory_name2' => true, - ); + ]; // 必要な項目以外を削除。 foreach ($arrProductsClass as $key => $value) { @@ -374,9 +375,11 @@ public function adjustSessionProductsClass(&$arrProductsClass) /** * getCartList用にcartSession情報をセットする * - * @param integer $product_type_id 商品種別ID - * @param integer $key + * @param int $product_type_id 商品種別ID + * @param int $key + * * @return void + * * @deprecated 本体では使用していないメソッドです * MEMO: せっかく一回だけ読み込みにされてますが、税率対応の関係でちょっと保留 */ @@ -409,16 +412,17 @@ public function setCartSession4getCartList($product_type_id, $key) /** * 商品種別ごとにカート内商品の一覧を取得する. * - * @param integer $product_type_id 商品種別ID - * @param integer $pref_id 税金計算用注文者都道府県ID - * @param integer $country_id 税金計算用注文者国ID + * @param int $product_type_id 商品種別ID + * @param int $pref_id 税金計算用注文者都道府県ID + * @param int $country_id 税金計算用注文者国ID + * * @return array カート内商品一覧の配列 */ public function getCartList($product_type_id, $pref_id = 0, $country_id = 0) { $objProduct = new SC_Product_Ex(); $max = $this->getMax($product_type_id); - $arrRet = array(); + $arrRet = []; /* $const_name = '_CALLED_SC_CARTSESSION_GETCARTLIST_' . $product_type_id; @@ -435,7 +439,6 @@ public function getCartList($product_type_id, $pref_id = 0, $country_id = 0) isset($this->cartSession[$product_type_id][$i]['cart_no']) && $this->cartSession[$product_type_id][$i]['cart_no'] != '' ) { - // 商品情報は常に取得 // TODO: 同一インスタンス内では1回のみ呼ぶようにしたい // TODO: ここの商品の合計処理は getAllProductsTotalや getAllProductsTaxとで類似重複なので統一出来そう @@ -490,7 +493,7 @@ public function getCartList($product_type_id, $pref_id = 0, $country_id = 0) */ public function getAllCartList() { - $results = array(); + $results = []; $cartKeys = $this->getKeys(); $i = 0; foreach ($cartKeys as $key) { @@ -508,13 +511,14 @@ public function getAllCartList() /** * カート内にある商品規格IDを全て取得する. * - * @param integer $product_type_id 商品種別ID + * @param int $product_type_id 商品種別ID + * * @return array 商品規格ID の配列 */ public function getAllProductClassID($product_type_id) { $max = $this->getMax($product_type_id); - $productClassIDs = array(); + $productClassIDs = []; for ($i = 0; $i <= $max; $i++) { if ($this->cartSession[$product_type_id][$i]['cart_no'] != '') { $productClassIDs[] = $this->cartSession[$product_type_id][$i]['id']; @@ -527,7 +531,8 @@ public function getAllProductClassID($product_type_id) /** * 商品種別ID を指定して, カート内の商品を全て削除する. * - * @param integer $product_type_id 商品種別ID + * @param int $product_type_id 商品種別ID + * * @return void */ public function delAllProducts($product_type_id) @@ -570,9 +575,10 @@ public function downQuantity($cart_no, $product_type_id) /** * カート番号と商品種別IDを指定して, 数量を取得する. * - * @param integer $cart_no カート番号 - * @param integer $product_type_id 商品種別ID - * @return integer 該当商品規格の数量 + * @param int $cart_no カート番号 + * @param int $product_type_id 商品種別ID + * + * @return int 該当商品規格の数量 */ public function getQuantity($cart_no, $product_type_id) { @@ -589,9 +595,9 @@ public function getQuantity($cart_no, $product_type_id) /** * カート番号と商品種別IDを指定して, 数量を設定する. * - * @param integer $quantity 設定する数量 - * @param integer $cart_no カート番号 - * @param integer $product_type_id 商品種別ID + * @param int $quantity 設定する数量 + * @param int $cart_no カート番号 + * @param int $product_type_id 商品種別ID * @retrun void */ public function setQuantity($quantity, $cart_no, $product_type_id) @@ -607,9 +613,11 @@ public function setQuantity($quantity, $cart_no, $product_type_id) /** * カート番号と商品種別IDを指定して, 商品規格IDを取得する. * - * @param integer $cart_no カート番号 - * @param integer $product_type_id 商品種別ID - * @return integer 商品規格ID + * @param int $cart_no カート番号 + * @param int $product_type_id 商品種別ID + * + * @return int 商品規格ID + * * @deprecated 本体では使用していないメソッドです */ public function getProductClassId($cart_no, $product_type_id) @@ -635,6 +643,7 @@ public function getProductClassId($cart_no, $product_type_id) * 4. 在庫数チェック * * @param string $product_type_id 商品種別ID + * * @return string エラーが発生した場合はエラーメッセージ */ public function checkProducts($product_type_id) @@ -659,8 +668,8 @@ public function checkProducts($product_type_id) * 配送業者のチェック */ if (SC_Utils_Ex::isBlank($arrDeliv)) { - $tpl_message .= '※「' . $product['name'] . '」はまだ配送の準備ができておりません。'; - $tpl_message .= '恐れ入りますがお問い合わせページよりお問い合わせください。' . "\n"; + $tpl_message .= '※「'.$product['name'].'」はまだ配送の準備ができておりません。'; + $tpl_message .= '恐れ入りますがお問い合わせページよりお問い合わせください。'."\n"; $this->delProduct($arrItem['cart_no'], $product_type_id); } @@ -677,11 +686,11 @@ public function checkProducts($product_type_id) $arrItem['id'] ); $this->setProductValue($arrItem['id'], 'total_inctax', $total_inctax, $product_type_id); - $tpl_message .= '※「' . $product['name'] . '」は販売制限(または在庫が不足)しております。'; + $tpl_message .= '※「'.$product['name'].'」は販売制限(または在庫が不足)しております。'; $tpl_message .= "一度に数量{$limit}を超える購入はできません。\n"; } else { $this->delProduct($arrItem['cart_no'], $product_type_id); - $tpl_message .= '※「' . $product['name'] . "」は売り切れました。\n"; + $tpl_message .= '※「'.$product['name']."」は売り切れました。\n"; continue; } } @@ -694,8 +703,9 @@ public function checkProducts($product_type_id) /** * 送料無料条件を満たすかどうかチェックする * - * @param integer $product_type_id 商品種別ID - * @return boolean 送料無料の場合 true + * @param int $product_type_id 商品種別ID + * + * @return bool 送料無料の場合 true */ public function isDelivFree($product_type_id) { @@ -737,15 +747,16 @@ public function isDelivFree($product_type_id) * - payment_total: お支払い合計 * - add_point: 加算ポイント * - * @param integer $product_type_id 商品種別ID + * @param int $product_type_id 商品種別ID * @param SC_Customer $objCustomer ログイン中の SC_Customer インスタンス - * @param integer $use_point 今回使用ポイント - * @param integer|array $deliv_pref 配送先都道府県ID. 複数に配送する場合は都道府県IDの配列 - * @param integer $charge 手数料 - * @param integer $discount 値引き - * @param integer $deliv_id 配送業者ID - * @param integer $order_pref 注文者の都道府県ID - * @param integer $order_country_id 注文者の国 + * @param int $use_point 今回使用ポイント + * @param int|array $deliv_pref 配送先都道府県ID. 複数に配送する場合は都道府県IDの配列 + * @param int $charge 手数料 + * @param int $discount 値引き + * @param int $deliv_id 配送業者ID + * @param int $order_pref 注文者の都道府県ID + * @param int $order_country_id 注文者の国 + * * @return array カートの計算結果の配列 */ public function calculate( @@ -759,8 +770,7 @@ public function calculate( $order_pref = 0, $order_country_id = 0 ) { - - $results = array(); + $results = []; $total_point = $this->getAllProductsPoint($product_type_id); // MEMO: 税金計算は注文者の住所基準 $results['tax'] = $this->getAllProductsTax($product_type_id, $order_pref, $order_country_id); @@ -838,7 +848,8 @@ public function getKeys() /** * カートに設定された現在のキー(商品種別ID)を登録する. * - * @param integer $key 商品種別ID + * @param int $key 商品種別ID + * * @return void */ public function registerKey($key) @@ -859,7 +870,7 @@ public function unsetKey() /** * カートに設定された現在のキー(商品種別ID)を取得する. * - * @return integer 商品種別ID + * @return int 商品種別ID */ public function getKey() { @@ -869,7 +880,7 @@ public function getKey() /** * 複数商品種別かどうか. * - * @return boolean カートが複数商品種別の場合 true + * @return bool カートが複数商品種別の場合 true */ public function isMultiple() { @@ -879,8 +890,9 @@ public function isMultiple() /** * 引数の商品種別の商品がカートに含まれるかどうか. * - * @param integer $product_type_id 商品種別ID - * @return boolean 指定の商品種別がカートに含まれる場合 true + * @param int $product_type_id 商品種別ID + * + * @return bool 指定の商品種別がカートに含まれる場合 true */ public function hasProductType($product_type_id) { diff --git a/data/class/SC_CheckError.php b/data/class/SC_CheckError.php index a660ccd209..184a7256ea 100644 --- a/data/class/SC_CheckError.php +++ b/data/class/SC_CheckError.php @@ -28,7 +28,7 @@ */ class SC_CheckError { - public $arrErr = array(); + public $arrErr = []; public $arrParam; // チェック対象の値が含まれる配列をセットする。 @@ -39,7 +39,6 @@ public function __construct($array = '') } else { $this->arrParam = $_POST; } - } /** @@ -58,6 +57,7 @@ public function doFunc($value, $arrFunc) * @param array $value value[0] = 項目名 * value[1] = 判定対象 * value[2] = 許可するタグが格納された配列 + * * @return void */ public function HTML_TAG_CHECK($value) @@ -73,7 +73,7 @@ public function HTML_TAG_CHECK($value) $this->createParam($value); // HTMLに含まれているタグを抽出する - $match = array(); + $match = []; preg_match_all('/<\/?([a-z\d]+)/i', $this->arrParam[$keyname], $match); $arrTagIncludedHtml = $match[1]; // 抽出結果を小文字に変換 @@ -82,11 +82,13 @@ public function HTML_TAG_CHECK($value) } $arrDiffTag = array_diff($arrTagIncludedHtml, $arrAllowedTag); - if (empty($arrDiffTag)) return; + if (empty($arrDiffTag)) { + return; + } // 少々荒っぽいが、表示用 HTML に変換する foreach ($arrDiffTag as &$tag) { - $tag = '[' . htmlspecialchars($tag) . ']'; + $tag = '['.htmlspecialchars($tag).']'; } $html_diff_tag_list = implode(', ', $arrDiffTag); @@ -101,7 +103,9 @@ public function HTML_TAG_CHECK($value) * 必須入力の判定 * * 受け取りがない場合エラーを返す + * * @param array $value value[0] = 項目名 value[1] = 判定対象 + * * @return void */ public function EXIST_CHECK($value) @@ -133,7 +137,9 @@ public function EXIST_CHECK($value) * 必須入力の判定(逆順) * * 受け取りがない場合エラーを返す + * * @param array $value value[0] = 判定対象 value[1] = 項目名 + * * @return void */ public function EXIST_CHECK_REVERSE($value) @@ -157,7 +163,9 @@ public function EXIST_CHECK_REVERSE($value) * スペース、タブの判定 * * 受け取りがない場合エラーを返す + * * @param array $value value[0] = 項目名 value[1] = 判定対象 + * * @return void */ public function SPTAB_CHECK($value) @@ -186,7 +194,9 @@ public function SPTAB_CHECK($value) * スペース、タブの判定 * * 受け取りがない場合エラーを返す + * * @param array $value value[0] = 項目名 value[1] = 判定対象 + * * @return void */ public function NO_SPTAB($value) @@ -215,7 +225,9 @@ public function NO_SPTAB($value) * ゼロで開始されている数値の判定 * * ゼロで始まる数値の場合エラーを返す + * * @param array $value value[0] = 項目名 value[1] = 判定対象 + * * @return void */ public function ZERO_START($value) @@ -231,7 +243,7 @@ public function ZERO_START($value) $input_var = $this->arrParam[$keyname]; if (strlen($input_var) != 0 - && preg_match("/^[0]+[0-9]+$/", $input_var) + && preg_match('/^[0]+[0-9]+$/', $input_var) ) { $this->arrErr[$keyname] = "※ {$disp_name}に0で始まる数値が入力されています。
"; @@ -242,7 +254,9 @@ public function ZERO_START($value) * 必須選択の判定 * * プルダウンなどで選択されていない場合エラーを返す + * * @param array $value value[0] = 項目名 value[1] = 判定対象 + * * @return void */ public function SELECT_CHECK($value) @@ -266,10 +280,12 @@ public function SELECT_CHECK($value) * 同一性の判定 * * 入力が指定文字数以上ならエラーを返す + * * @param array $value value[0] = 項目名1 * value[1] = 項目名2 * value[2] = 判定対象文字列1 * value[3] = 判定対象文字列2 + * * @return void */ public function EQUAL_CHECK($value) @@ -298,10 +314,12 @@ public function EQUAL_CHECK($value) * 値が異なることの判定 * * 入力が指定文字数以上ならエラーを返す + * * @param array $value value[0] = 項目名1 * value[1] = 項目名2 * value[2] = 判定対象文字列1 * value[3] = 判定対象文字列2 + * * @return void */ public function DIFFERENT_CHECK($value) @@ -333,10 +351,12 @@ public function DIFFERENT_CHECK($value) * 値の大きさを比較する value[2] < value[3]でなければエラー * * 入力が指定文字数以上ならエラーを返す + * * @param array $value value[0] = 項目名1 * value[1] = 項目名2 * value[2] = 判定対象文字列1 * value[3] = 判定対象文字列2 + * * @return void */ public function GREATER_CHECK($value) @@ -373,9 +393,11 @@ public function GREATER_CHECK($value) * 最大文字数制限の判定 * * 入力が指定文字数以上ならエラーを返す - * @param integer[] $value value[0] = 項目名 + * + * @param int[] $value value[0] = 項目名 * value[1] = 判定対象文字列 * value[2] = 最大文字数(半角も全角も1文字として数える) + * * @return void */ public function MAX_LENGTH_CHECK($value) @@ -404,9 +426,11 @@ public function MAX_LENGTH_CHECK($value) * 最小文字数制限の判定 * * 入力が指定文字数未満ならエラーを返す + * * @param array $value value[0] = 項目名 * value[1] = 判定対象文字列 * value[2] = 最小文字数(半角も全角も1文字として数える) + * * @return void */ public function MIN_LENGTH_CHECK($value) @@ -435,9 +459,11 @@ public function MIN_LENGTH_CHECK($value) * 最大数制限の判定 * * 入力が最大数より大きければエラーを返す + * * @param array $value value[0] = 項目名 * value[1] = 判定対象文字列 * value[2] = 最大数 + * * @return void */ public function MAX_CHECK($value) @@ -466,9 +492,11 @@ public function MAX_CHECK($value) * 最小数値制限の判定 * * 入力が最小数未満ならエラーを返す + * * @param array $value value[0] = 項目名 * value[1] = 判定対象文字列 * value[2] = 最小数 + * * @return void */ public function MIN_CHECK($value) @@ -496,7 +524,9 @@ public function MIN_CHECK($value) * 数字の判定 * * 入力文字が数字以外ならエラーを返す + * * @param array $value value[0] = 項目名 value[1] = 判定対象文字列 + * * @return void */ public function NUM_CHECK($value) @@ -520,7 +550,9 @@ public function NUM_CHECK($value) * 小数点を含む数字の判定 * * 入力文字が数字以外ならエラーを返す + * * @param array $value value[0] = 項目名 value[1] = 判定対象文字列 + * * @return void */ public function NUM_POINT_CHECK($value) @@ -565,6 +597,7 @@ public function ALPHA_CHECK($value) * 電話番号の判定 * * 数字チェックと文字数チェックを実施する。 + * * @param array $value 各要素は以下の通り。
* [0]: 項目名
* [1]: 電番1項目目
@@ -572,6 +605,7 @@ public function ALPHA_CHECK($value) * [3]: 電番3項目目
* [4]: 電話番号各項目制限 (指定なしの場合、TEL_ITEM_LEN)
* [5]: 電話番号総数 (指定なしの場合、TEL_LEN) + * * @return void */ public function TEL_CHECK($value) @@ -615,7 +649,7 @@ public function TEL_CHECK($value) if (strlen($input_var) > 0 && strlen($input_var) > $telItemLen) { $this->arrErr[$keyname] = sprintf( '※ %sは%d字以内で入力してください。
', - $disp_name . $i, + $disp_name.$i, $telItemLen ); } elseif ($this->numelicCheck($input_var)) { @@ -775,7 +809,7 @@ public function TOP_EXIST_CHECK($value) } } - /* カタカナの判定 */ + /* カタカナの判定  */ // 入力文字がカナ以外ならエラーを返す // value[0] = 項目名 value[1] = 判定対象文字列 public function KANA_CHECK($value) @@ -790,7 +824,7 @@ public function KANA_CHECK($value) $this->createParam($value); $input_var = $this->arrParam[$keyname]; - $pattern = "/^[ァ-ヶヲ-゚ー]+$/u"; + $pattern = '/^[ァ-ヶヲ-゚ー]+$/u'; if (strlen($input_var) > 0 && !preg_match($pattern, $input_var)) { $this->arrErr[$keyname] = "※ {$disp_name}はカタカナで入力してください。
"; @@ -819,7 +853,7 @@ public function KANABLANK_CHECK($value) } } - /* 英数字の判定 */ + /* 英数字の判定  */ // 入力文字が英数字以外ならエラーを返す // value[0] = 項目名 value[1] = 判定対象文字列 public function ALNUM_CHECK($value) @@ -840,7 +874,7 @@ public function ALNUM_CHECK($value) } } - /* 英数記号の判定 */ + /* 英数記号の判定  */ // 入力文字が英数記号以外ならエラーを返す // value[0] = 項目名 value[1] = 判定対象文字列 public function GRAPH_CHECK($value) @@ -855,7 +889,7 @@ public function GRAPH_CHECK($value) $this->createParam($value); $input_var = $this->arrParam[$keyname]; - $pattern = "/^[[:graph:][:space:]]+$/i"; + $pattern = '/^[[:graph:][:space:]]+$/i'; if (strlen($input_var) > 0 && !preg_match($pattern, $input_var)) { $this->arrErr[$keyname] = "※ {$disp_name}は英数記号で入力してください。
"; @@ -889,11 +923,11 @@ public function PASSWORD_CHAR_CHECK($value) $pattern = '/\A(?=.*?[a-z])(?=.*?\d)[!-~]{'.PASSWORD_MIN_LEN.','.PASSWORD_MAX_LEN.'}+\z/i'; if (strlen($input_var) > 0 && !preg_match($pattern, $input_var)) { $this->arrErr[$keyname] = - "※ {$disp_name}は英数字をそれぞれ1種類使用し、".PASSWORD_MIN_LEN."文字以上で入力してください。
"; + "※ {$disp_name}は英数字をそれぞれ1種類使用し、".PASSWORD_MIN_LEN.'文字以上で入力してください。
'; } } - /* 必須選択の判定 */ + /* 必須選択の判定  */ // 入力値で0が許されない場合エラーを返す // value[0] = 項目名 value[1] = 判定対象 public function ZERO_CHECK($value) @@ -909,7 +943,7 @@ public function ZERO_CHECK($value) } } - /* 桁数の判定 (最小最大)*/ + /* 桁数の判定 (最小最大) */ // 入力文字の桁数判定 → 最小桁数<入力文字列<最大桁数 // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 最小桁数 value[3] = 最大桁数 public function NUM_RANGE_CHECK($value) @@ -937,7 +971,7 @@ public function NUM_RANGE_CHECK($value) } } - /* 桁数の判定 */ + /* 桁数の判定  */ // 入力文字の桁数判定 → 入力文字列 = 桁数 以外はNGの場合 // value[0] = 項目名 value[1] = 判定対象文字列 value[2] = 桁数 public function NUM_COUNT_CHECK($value) @@ -965,6 +999,7 @@ public function NUM_COUNT_CHECK($value) * @param array $value 各要素は以下の通り。
* [0]: 項目名
* [1]: 判定対象を格納している配列キー + * * @return void */ public function EMAIL_CHECK($value) @@ -983,21 +1018,21 @@ public function EMAIL_CHECK($value) return; } - $wsp = '[\x20\x09]'; - $vchar = '[\x21-\x7e]'; - $quoted_pair = "\\\\(?:$vchar|$wsp)"; - $qtext = '[\x21\x23-\x5b\x5d-\x7e]'; - $qcontent = "(?:$qtext|$quoted_pair)"; + $wsp = '[\x20\x09]'; + $vchar = '[\x21-\x7e]'; + $quoted_pair = "\\\\(?:$vchar|$wsp)"; + $qtext = '[\x21\x23-\x5b\x5d-\x7e]'; + $qcontent = "(?:$qtext|$quoted_pair)"; $quoted_string = "\"$qcontent*\""; - $atext = '[a-zA-Z0-9!#$%&\'*+\-\/\=?^_`{|}~]'; - $dot_atom = "$atext+(?:[.]$atext+)*"; - $local_part = "(?:$dot_atom|$quoted_string)"; - $domain = $dot_atom; - $addr_spec = "{$local_part}[@]$domain"; + $atext = '[a-zA-Z0-9!#$%&\'*+\-\/\=?^_`{|}~]'; + $dot_atom = "$atext+(?:[.]$atext+)*"; + $local_part = "(?:$dot_atom|$quoted_string)"; + $domain = $dot_atom; + $addr_spec = "{$local_part}[@]$domain"; - $dot_atom_loose = "$atext+(?:[.]|$atext)*"; + $dot_atom_loose = "$atext+(?:[.]|$atext)*"; $local_part_loose = "(?:$dot_atom_loose|$quoted_string)"; - $addr_spec_loose = "{$local_part_loose}[@]$domain"; + $addr_spec_loose = "{$local_part_loose}[@]$domain"; if (RFC_COMPLIANT_EMAIL_CHECK) { $regexp = "/\A{$addr_spec}\z/"; @@ -1018,7 +1053,7 @@ public function EMAIL_CHECK($value) $this->MAX_LENGTH_CHECK($arrValueTemp); } - /* メールアドレスに使用できる文字の判定 */ + /* メールアドレスに使用できる文字の判定  */ // メールアドレスに使用する文字を正規表現で判定する // value[0] = 項目名 value[1] = 判定対象メールアドレス public function EMAIL_CHAR_CHECK($value) @@ -1040,7 +1075,7 @@ public function EMAIL_CHAR_CHECK($value) } } - /* URL形式の判定 */ + /* URL形式の判定  */ // URLを正規表現で判定する。デフォルトでhttp://があってもOK // value[0] = 項目名 value[1] = 判定対象URL public function URL_CHECK($value) @@ -1060,7 +1095,7 @@ public function URL_CHECK($value) } } - /* IPアドレスの判定 */ + /* IPアドレスの判定  */ // value[0] = 項目名 value[1] = 判定対象IPアドレス文字列 public function IP_CHECK($value) { @@ -1071,7 +1106,7 @@ public function IP_CHECK($value) return; } - //改行コードが含まれている場合には配列に変換 + // 改行コードが含まれている場合には配列に変換 $params = str_replace("\r", '', $this->arrParam[$keyname]); if (!empty($params)) { if (strpos($params, "\n") === false) { @@ -1088,7 +1123,7 @@ public function IP_CHECK($value) } } - /* 拡張子の判定 */ + /* 拡張子の判定  */ // 受け取りがない場合エラーを返す // value[0] = 項目名 value[1] = 判定対象 value[2]=array(拡張子) public function FILE_EXT_CHECK($value) @@ -1107,10 +1142,10 @@ public function FILE_EXT_CHECK($value) $filename = $_FILES[$keyname]['name']; if (strlen($filename) >= 1) { foreach ($arrExtension as $check_ext) { - $pattern = '/' . preg_quote('.' . $check_ext) . '$/i'; + $pattern = '/'.preg_quote('.'.$check_ext).'$/i'; $match = preg_match($pattern, $filename) >= 1; if ($match === true) { - break 1; + break; } } } @@ -1142,7 +1177,7 @@ public function FIND_FILE($value) $dir = IMAGE_SAVE_REALDIR; } - $path = $dir . '/' . $this->arrParam[$keyname]; + $path = $dir.'/'.$this->arrParam[$keyname]; $path = str_replace('//', '/', $path); if ($this->arrParam[$keyname] != '' && !file_exists($path)) { @@ -1150,7 +1185,7 @@ public function FIND_FILE($value) } } - /* ファイルが上げられたか確認 */ + /* ファイルが上げられたか確認  */ // 受け取りがない場合エラーを返す // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) public function FILE_EXIST_CHECK($value) @@ -1171,7 +1206,7 @@ public function FILE_EXIST_CHECK($value) } } - /* ファイルサイズの判定 */ + /* ファイルサイズの判定  */ // 受け取りがない場合エラーを返す // value[0] = 項目名 value[1] = 判定対象 value[2] = 指定サイズ(KB) public function FILE_SIZE_CHECK($value) @@ -1186,7 +1221,7 @@ public function FILE_SIZE_CHECK($value) $this->createParam($value); - if ($_FILES[$keyname]['size'] > $max_file_size * 1024) { + if ($_FILES[$keyname]['size'] > $max_file_size * 1024) { $byte = 'KB'; if ($max_file_size >= 1000) { $max_file_size = $max_file_size / 1000; @@ -1201,7 +1236,7 @@ public function FILE_SIZE_CHECK($value) } } - /* ファイル名の判定 */ + /* ファイル名の判定  */ // 入力文字が英数字,'_','-','.'以外ならエラーを返す // value[0] = 項目名 value[1] = 判定対象文字列 public function FILE_NAME_CHECK($value) @@ -1223,7 +1258,7 @@ public function FILE_NAME_CHECK($value) } } - /* ファイル名の判定(アップロード以外の時) */ + /* ファイル名の判定(アップロード以外の時)  */ // 入力文字が英数字,'_','-','.'以外ならエラーを返す // value[0] = 項目名 value[1] = 判定対象文字列 public function FILE_NAME_CHECK_BY_NOUPLOAD($value) @@ -1238,14 +1273,14 @@ public function FILE_NAME_CHECK_BY_NOUPLOAD($value) $this->createParam($value); $filename = $this->arrParam[$keyname]; - $pattern = "/[^[:alnum:]_.\\-]/"; + $pattern = '/[^[:alnum:]_.\\-]/'; if (strlen($filename) > 0 && preg_match($pattern, $filename)) { $this->arrErr[$keyname] = "※ {$disp_name}のファイル名には、英数字、記号(_ - .)のみを入力して下さい。
"; } } - //日付チェック + // 日付チェック // value[0] = 項目名 // value[1] = YYYY // value[2] = MM @@ -1277,7 +1312,7 @@ public function CHECK_DATE($value) } } - //日付チェック + // 日付チェック // value[0] = 項目名 // value[1] = YYYY // value[2] = MM @@ -1308,14 +1343,14 @@ public function CHECK_DATE2($value) if (!(strlen($input_year) > 0 && strlen($input_month) > 0 && strlen($input_day) > 0 && strlen($input_hour) > 0 && strlen($input_minute) > 0)) { $this->arrErr[$keyname] = "※ {$disp_name}は全ての項目を入力して下さい。
"; - } elseif (! checkdate((int) $input_month, (int) $input_day, (int) $input_year)) { + } elseif (!checkdate((int) $input_month, (int) $input_day, (int) $input_year)) { $this->arrErr[$keyname] = "※ {$disp_name}が正しくありません。
"; } } } - //日付チェック + // 日付チェック // value[0] = 項目名 // value[1] = YYYY // value[2] = MM @@ -1338,14 +1373,14 @@ public function CHECK_DATE3($value) if (!(strlen($input_year) > 0 && strlen($input_month) > 0)) { $this->arrErr[$keyname] = "※ {$disp_name}は全ての項目を入力して下さい。
"; - } elseif (! checkdate((int) $input_month, 1, (int) $input_year)) { + } elseif (!checkdate((int) $input_month, 1, (int) $input_year)) { $this->arrErr[$keyname] = "※ {$disp_name}が正しくありません。
"; } } } - //誕生日チェック + // 誕生日チェック // value[0] = 項目名 // value[1] = YYYY // value[2] = MM @@ -1364,8 +1399,8 @@ public function CHECK_BIRTHDAY($value) // 年が入力されている。 if (strlen($this->arrParam[$keyname]) >= 1) { // 年の数字チェック、最小数値制限チェック - $this->doFunc(array("{$disp_name}(年)", $keyname, BIRTH_YEAR), - array('NUM_CHECK', 'MIN_CHECK')); + $this->doFunc(["{$disp_name}(年)", $keyname, BIRTH_YEAR], + ['NUM_CHECK', 'MIN_CHECK']); // 上のチェックでエラーある場合、中断する。 if (isset($this->arrErr[$keyname])) { return; @@ -1373,8 +1408,8 @@ public function CHECK_BIRTHDAY($value) // 年の最大数値制限チェック $current_year = date('Y'); - $this->doFunc(array("{$disp_name}(年)", $keyname, $current_year), - array('MAX_CHECK')); + $this->doFunc(["{$disp_name}(年)", $keyname, $current_year], + ['MAX_CHECK']); // 上のチェックでエラーある場合、中断する。 if (isset($this->arrErr[$keyname])) { return; @@ -1385,7 +1420,7 @@ public function CHECK_BIRTHDAY($value) $this->CHECK_DATE($value); } - /*-----------------------------------------------------------------*/ + /* ----------------------------------------------------------------- */ /* CHECK_SET_TERM /* 年月日に別れた2つの期間の妥当性をチェックし、整合性と期間を返す /* 引数 (開始年,開始月,開始日,終了年,終了月,終了日) @@ -1423,13 +1458,13 @@ public function CHECK_SET_TERM($value) $end_month = $this->arrParam[$value[6]]; $end_day = $this->arrParam[$value[7]]; if ((strlen($start_year) > 0 || strlen($start_month) > 0 || strlen($start_day) > 0) - && ! checkdate((int) $start_month, (int) $start_day, (int) $start_year) + && !checkdate((int) $start_month, (int) $start_day, (int) $start_year) ) { $this->arrErr[$keyname1] = "※ {$disp_name1}を正しく指定してください。
"; } if ((strlen($end_year) > 0 || strlen($end_month) > 0 || strlen($end_day) > 0) - && ! checkdate((int) $end_month, (int) $end_day, (int) $end_year) + && !checkdate((int) $end_month, (int) $end_day, (int) $end_year) ) { $this->arrErr[$keyname2] = "※ {$disp_name2}を正しく指定してください。
"; @@ -1447,7 +1482,7 @@ public function CHECK_SET_TERM($value) } } - /*-----------------------------------------------------------------*/ + /* ----------------------------------------------------------------- */ /* CHECK_SET_TERM2 /* 年月日時に別れた2つの期間の妥当性をチェックし、整合性と期間を返す /* 引数 (開始年,開始月,開始日,開始時間,開始分,開始秒, @@ -1472,7 +1507,7 @@ public function CHECK_SET_TERM($value) // value[12] = end_minute // value[13] = end_second - /*-----------------------------------------------------------------*/ + /* ----------------------------------------------------------------- */ public function CHECK_SET_TERM2($value) { $disp_name1 = $value[0]; @@ -1500,13 +1535,13 @@ public function CHECK_SET_TERM2($value) $end_minute = $this->arrParam[$value[12]]; $end_second = $this->arrParam[$value[13]]; if ((strlen($start_year) > 0 || strlen($start_month) > 0 || strlen($start_day) > 0 || strlen($start_hour) > 0) - && ! checkdate((int) $start_month, (int) $start_day, (int) $start_year) + && !checkdate((int) $start_month, (int) $start_day, (int) $start_year) ) { $this->arrErr[$keyname1] = "※ {$disp_name1}を正しく指定してください。
"; } if ((strlen($end_year) > 0 || strlen($end_month) > 0 || strlen($end_day) > 0 || strlen($end_hour) > 0) - && ! checkdate((int) $end_month, (int) $end_day, (int) $end_year) + && !checkdate((int) $end_month, (int) $end_day, (int) $end_year) ) { $this->arrErr[$keyname2] = "※ {$disp_name2}を正しく指定してください。
"; @@ -1529,11 +1564,10 @@ public function CHECK_SET_TERM2($value) $this->arrErr[$keyname1] = "※ {$disp_name1}と{$disp_name2}の期間指定が不正です。
"; } - } } - /*-----------------------------------------------------------------*/ + /* ----------------------------------------------------------------- */ /* CHECK_SET_TERM3 /* 年月に別れた2つの期間の妥当性をチェックし、整合性と期間を返す /* 引数 (開始年,開始月,終了年,終了月) @@ -1567,18 +1601,18 @@ public function CHECK_SET_TERM3($value) $end_year = $this->arrParam[$value[4]]; $end_month = $this->arrParam[$value[5]]; if ((strlen($start_year) > 0 || strlen($start_month) > 0) - && ! checkdate((int) $start_month, 1, (int) $start_year) + && !checkdate((int) $start_month, 1, (int) $start_year) ) { $this->arrErr[$keyname1] = "※ {$disp_name1}を正しく指定してください。
"; } if ((strlen($end_year) > 0 || strlen($end_month) > 0) - && ! checkdate((int) $end_month, 1, (int) $end_year) + && !checkdate((int) $end_month, 1, (int) $end_year) ) { $this->arrErr[$keyname2] = "※ {$disp_name2}を正しく指定してください。
"; } - if ((strlen($start_year) > 0 && strlen($start_month) > 0 && (strlen($end_year) > 0 || strlen($end_month) > 0))) { + if (strlen($start_year) > 0 && strlen($start_month) > 0 && (strlen($end_year) > 0 || strlen($end_month) > 0)) { $date1 = sprintf('%d%02d', $start_year, $start_month); $date2 = sprintf('%d%02d', $end_year, $end_month); @@ -1589,7 +1623,7 @@ public function CHECK_SET_TERM3($value) } } - //ディレクトリ存在チェック + // ディレクトリ存在チェック public function DIR_CHECK($value) { $disp_name = $value[0]; @@ -1624,7 +1658,7 @@ public function DOMAIN_CHECK($value) } } - /* 携帯メールアドレスの判定 */ + /* 携帯メールアドレスの判定  */ // メールアドレスを正規表現で判定する // value[0] = 項目名 value[1] = 判定対象メールアドレス public function MOBILE_EMAIL_CHECK($value) @@ -1641,7 +1675,7 @@ public function MOBILE_EMAIL_CHECK($value) $objMobile = new SC_Helper_Mobile_Ex(); $input_var = $this->arrParam[$keyname]; if (strlen($input_var) > 0 - &&!$objMobile->gfIsMobileMailAddress($input_var) + && !$objMobile->gfIsMobileMailAddress($input_var) ) { $this->arrErr[$keyname] = "※ {$disp_name}は携帯電話のものではありません。
"; @@ -1652,8 +1686,9 @@ public function MOBILE_EMAIL_CHECK($value) * CHECK_REGIST_CUSTOMER_EMAIL * * メールアドレスが会員登録されているか調べる + * * @param array $value value[0] = 項目名 value[1] = 判定対象メールアドレス - * @access public + * * @return void */ public function CHECK_REGIST_CUSTOMER_EMAIL($value) @@ -1701,10 +1736,10 @@ public function PROHIBITED_STR_CHECK($value) $this->createParam($value); - $targetStr = $this->arrParam[$keyname]; - $prohibitedStr = str_replace(array('|', '/'), array('\|', '\/'), $arrProhibitedStr); + $targetStr = $this->arrParam[$keyname]; + $prohibitedStr = str_replace(['|', '/'], ['\|', '\/'], $arrProhibitedStr); - $pattern = '/' . join('|', $prohibitedStr) . '/i'; + $pattern = '/'.implode('|', $prohibitedStr).'/i'; if (preg_match_all($pattern, $targetStr, $matches)) { $this->arrErr[$keyname] = "※ {$disp_name}は入力できません。
"; @@ -1714,8 +1749,8 @@ public function PROHIBITED_STR_CHECK($value) /** * パラメーターとして適切な文字列かチェックする. * - * @access private * @param array $value [0] => 項目名, [1] => 評価する文字列 + * * @return void */ public function EVAL_CHECK($value) @@ -1742,8 +1777,9 @@ public function EVAL_CHECK($value) * ・PHPコードとして評価可能であること。 * ・評価した結果がスカラデータ(定数に指定できる値)であること。 * 本メソッドの利用や改訂にあたっては、eval 関数の危険性を意識する必要がある。 - * @access private + * * @param string 評価する文字列 + * * @return bool パラメーターとして適切な文字列か */ public function evalCheck($value) @@ -1751,14 +1787,15 @@ public function evalCheck($value) if ($value === '' || $value === null) { return true; } - return @eval('return is_scalar(' . $value . ');'); + + return @eval('return is_scalar('.$value.');'); } /** * 未定義の $this->arrParam に空要素を代入する. * - * @access private * @param array $value 配列 + * * @return void */ public function createParam($value) @@ -1766,10 +1803,12 @@ public function createParam($value) foreach ($value as $val_key => $key) { if ($val_key != 0 && (is_string($key) || is_int($key))) { if (!is_numeric($key) && preg_match('/^[a-z0-9_]+$/i', $key)) { - if (!isset($this->arrParam[$key])) $this->arrParam[$key] = ''; + if (!isset($this->arrParam[$key])) { + $this->arrParam[$key] = ''; + } if (!is_array($this->arrParam[$key]) && strlen($this->arrParam[$key]) > 0 && (preg_match('/^[[:alnum:]\-\_]*[\.\/\\\\]*\.\.(\/|\\\\)/', $this->arrParam[$key]) || !preg_match('/\A[^\x00-\x08\x0b\x0c\x0e-\x1f\x7f]+\z/u', $this->arrParam[$key]))) { - $this->arrErr[$value[1]] = '※ ' . $value[0] . 'に禁止された記号の並びまたは制御文字が入っています。
'; + $this->arrErr[$value[1]] = '※ '.$value[0].'に禁止された記号の並びまたは制御文字が入っています。
'; } } elseif (preg_match('/[^a-z0-9_]/i', $key)) { trigger_error('', E_USER_ERROR); @@ -1781,9 +1820,9 @@ public function createParam($value) /** * 値が数字だけかどうかチェックする * - * @access private * @param string $string チェックする文字列 - * @return boolean 値が10進数の数値表現以外の場合 true + * + * @return bool 値が10進数の数値表現以外の場合 true */ public function numelicCheck($string) { @@ -1805,9 +1844,9 @@ public function PREF_CHECK($value) $pref_id = $this->arrParam[$key]; $objQuery = SC_Query_Ex::getSingletonInstance(); - $exists = $objQuery->exists('mtb_pref', 'id = ?', array($pref_id)); + $exists = $objQuery->exists('mtb_pref', 'id = ?', [$pref_id]); if (!$exists) { - $this->arrErr[$key] = '※ ' . $disp . 'が不正な値です。
'; + $this->arrErr[$key] = '※ '.$disp.'が不正な値です。
'; } } } diff --git a/data/class/SC_ClassAutoloader.php b/data/class/SC_ClassAutoloader.php index 323cfd672a..73addec178 100644 --- a/data/class/SC_ClassAutoloader.php +++ b/data/class/SC_ClassAutoloader.php @@ -24,8 +24,8 @@ /** * クラスのオートローディングクラス * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_ClassAutoloader @@ -47,14 +47,14 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R } elseif (($arrClassNamePart[0] === 'SC' || $arrClassNamePart[0] === 'LC') && $is_ex === true && $count >= 4) { $arrClassNamePartTemp = $arrClassNamePart; // FIXME クラスファイルのディレクトリ命名が変。変な現状に合わせて強引な処理をしてる。 - $arrClassNamePartTemp[1] = $arrClassNamePartTemp[1] . '_extends'; + $arrClassNamePartTemp[1] = $arrClassNamePartTemp[1].'_extends'; if ($count <= 5 && $arrClassNamePart[2] === 'Admin' && !in_array($arrClassNamePart[3], ['Home', 'Index', 'Logout'])) { - $classpath .= strtolower(implode('/', array_slice($arrClassNamePartTemp, 1, -1))) . '/'; + $classpath .= strtolower(implode('/', array_slice($arrClassNamePartTemp, 1, -1))).'/'; } else { - $classpath .= strtolower(implode('/', array_slice($arrClassNamePartTemp, 1, -2))) . '/'; + $classpath .= strtolower(implode('/', array_slice($arrClassNamePartTemp, 1, -2))).'/'; } } elseif ($arrClassNamePart[0] === 'SC' && $is_ex === false && $count >= 3) { - $classpath .= strtolower(implode('/', array_slice($arrClassNamePart, 1, -1))) . '/'; + $classpath .= strtolower(implode('/', array_slice($arrClassNamePart, 1, -1))).'/'; } elseif ($arrClassNamePart[0] === 'SC') { // 処理なし } else { @@ -75,7 +75,7 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R $plugin_class = $class; $plugin_classpath = $classpath; - $objPlugin->doAction('loadClassFileChange', array(&$plugin_class, &$plugin_classpath)); + $objPlugin->doAction('loadClassFileChange', [&$plugin_class, &$plugin_classpath]); // FIXME: トリッキーな処理で _Ex ファイルを無視しないようにする(無視するとユーザーカスタマイズで分かりにくい) // SC_XXXX_Ex がロードされる場合にextendsのchainを @@ -94,11 +94,11 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R if ($parent_classname) { $exp = "/(class[ ]+{$plugin_class}[ ]+extends +)[a-zA-Z_\-]+( *{?)/"; - $replace = '$1' . $parent_classname . '$2'; + $replace = '$1'.$parent_classname.'$2'; if (file_exists($plugin_classpath)) { $base_class_str = file_get_contents($plugin_classpath); - $base_class_str = str_replace(array(''), '', $base_class_str); + $base_class_str = str_replace([''], '', $base_class_str); $base_class_str = preg_replace($exp, $replace, $base_class_str, 1); } else { $base_class_str = 'class '.$class.' extends '.$parent_classname.' {}'; @@ -117,11 +117,11 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R if ($is_ex) { $exp = "/(class[ ]+{$class}[ ]+extends +)[a-zA-Z_\-]+( *{?)/"; - $replace = '$1' . $parent_classname . '$2'; + $replace = '$1'.$parent_classname.'$2'; if (file_exists($classpath)) { $base_class_str = file_get_contents($classpath); - $base_class_str = str_replace(array(''), '', $base_class_str); + $base_class_str = str_replace([''], '', $base_class_str); $base_class_str = preg_replace($exp, $replace, $base_class_str, 1); } else { $base_class_str = 'class '.$class.' extends '.$parent_classname.' {}'; @@ -146,7 +146,7 @@ class_alias(preg_replace('/_Ex$/', '', $class), $class); } else { $arrPath = explode(PATH_SEPARATOR, get_include_path()); foreach ($arrPath as $path) { - if (file_exists($path . '/' .$classpath)) { + if (file_exists($path.'/'.$classpath)) { include $classpath; break; } diff --git a/data/class/SC_Cookie.php b/data/class/SC_Cookie.php index 228c8bd4f1..d8f8591e35 100644 --- a/data/class/SC_Cookie.php +++ b/data/class/SC_Cookie.php @@ -23,7 +23,6 @@ /** * クッキー用クラス - * */ class SC_Cookie { @@ -53,6 +52,7 @@ public function setCookie($key, $val, $secure = false, $httponly = true) * クッキー取得 * * EC-CUBE をURLパスルート以外にインストールしている場合、上位ディレクトリの値も(劣後ではあるが)取得する点に留意。 + * * @param string $key */ public function getCookie($key) diff --git a/data/class/SC_Customer.php b/data/class/SC_Customer.php index 5f29b18adb..e7029c340c 100644 --- a/data/class/SC_Customer.php +++ b/data/class/SC_Customer.php @@ -28,6 +28,7 @@ class SC_Customer { /** * 会員情報 + * * @var array */ public $customer_data; @@ -40,6 +41,7 @@ class SC_Customer * @param string $email メールアドレス * @param string $pass パスワード * @param bool $mobile email_mobile も検索対象とする場合 true + * * @return bool */ public function getCustomerDataFromEmailPass($pass, $email, $mobile = false) @@ -47,12 +49,12 @@ public function getCustomerDataFromEmailPass($pass, $email, $mobile = false) // 小文字に変換 $email = strtolower($email); $sql_mobile = $mobile ? ' OR email_mobile = ?' : ''; - $arrValues = array($email); + $arrValues = [$email]; if ($mobile) { $arrValues[] = $email; } // 本登録された会員のみ - $sql = 'SELECT * FROM dtb_customer WHERE (email = ?' . $sql_mobile . ') AND del_flg = 0 AND status = 2'; + $sql = 'SELECT * FROM dtb_customer WHERE (email = ?'.$sql_mobile.') AND del_flg = 0 AND status = 2'; $objQuery = SC_Query_Ex::getSingletonInstance(); $result = $objQuery->getAll($sql, $arrValues); if (empty($result)) { @@ -75,13 +77,15 @@ public function getCustomerDataFromEmailPass($pass, $email, $mobile = false) /** * 携帯端末IDが一致する会員が存在するかどうかをチェックする。 * FIXME - * @return boolean 該当する会員が存在する場合は true、それ以外の場合 + * + * @return bool 該当する会員が存在する場合は true、それ以外の場合 * は false を返す。 + * * @deprecated */ public function checkMobilePhoneId() { - //docomo用にデータを取り出す。 + // docomo用にデータを取り出す。 if (SC_MobileUserAgent_Ex::getCarrier() == 'docomo') { if ($_SESSION['mobile']['phone_id'] == '' && strlen($_SESSION['mobile']['phone_id']) == 0) { $_SESSION['mobile']['phone_id'] = SC_MobileUserAgent_Ex::getId(); @@ -93,7 +97,7 @@ public function checkMobilePhoneId() // 携帯端末IDが一致し、本登録された会員を検索する。 $objQuery = SC_Query_Ex::getSingletonInstance(); - $exists = $objQuery->exists('dtb_customer', 'mobile_phone_id = ? AND del_flg = 0 AND status = 2', array($_SESSION['mobile']['phone_id'])); + $exists = $objQuery->exists('dtb_customer', 'mobile_phone_id = ? AND del_flg = 0 AND status = 2', [$_SESSION['mobile']['phone_id']]); return $exists; } @@ -103,13 +107,15 @@ public function checkMobilePhoneId() * パスワードが合っている場合は会員情報を取得する。 * * @param string $pass パスワード - * @return boolean 該当する会員が存在し、パスワードが合っている場合は true、 + * + * @return bool 該当する会員が存在し、パスワードが合っている場合は true、 * それ以外の場合は false を返す。 + * * @deprecated */ public function getCustomerDataFromMobilePhoneIdPass($pass) { - //docomo用にデータを取り出す。 + // docomo用にデータを取り出す。 if (SC_MobileUserAgent_Ex::getCarrier() == 'docomo') { if ($_SESSION['mobile']['phone_id'] == '' && strlen($_SESSION['mobile']['phone_id']) == 0) { $_SESSION['mobile']['phone_id'] = SC_MobileUserAgent_Ex::getId(); @@ -122,7 +128,7 @@ public function getCustomerDataFromMobilePhoneIdPass($pass) // 携帯端末IDが一致し、本登録された会員を検索する。 $sql = 'SELECT * FROM dtb_customer WHERE mobile_phone_id = ? AND del_flg = 0 AND status = 2'; $objQuery = SC_Query_Ex::getSingletonInstance(); - @list($data) = $objQuery->getAll($sql, array($_SESSION['mobile']['phone_id'])); + @list($data) = $objQuery->getAll($sql, [$_SESSION['mobile']['phone_id']]); // パスワードが合っている場合は、会員情報をcustomer_dataに格納してtrueを返す。 if (SC_Utils_Ex::sfIsMatchHashPassword($pass, $data['password'], $data['salt'])) { @@ -139,6 +145,7 @@ public function getCustomerDataFromMobilePhoneIdPass($pass) * 携帯端末IDを登録する。 * * @return void + * * @deprecated */ public function updateMobilePhoneId() @@ -152,9 +159,9 @@ public function updateMobilePhoneId() } $objQuery = SC_Query_Ex::getSingletonInstance(); - $sqlval = array('mobile_phone_id' => $_SESSION['mobile']['phone_id']); + $sqlval = ['mobile_phone_id' => $_SESSION['mobile']['phone_id']]; $where = 'customer_id = ? AND del_flg = 0 AND status = 2'; - $objQuery->update('dtb_customer', $sqlval, $where, array($this->customer_data['customer_id'])); + $objQuery->update('dtb_customer', $sqlval, $where, [$this->customer_data['customer_id']]); $this->customer_data['mobile_phone_id'] = $_SESSION['mobile']['phone_id']; } @@ -169,8 +176,8 @@ public function setLogin($email) // 本登録された会員のみ $sql = 'SELECT * FROM dtb_customer WHERE (email = ? OR email_mobile = ?) AND del_flg = 0 AND status = 2'; $objQuery = SC_Query_Ex::getSingletonInstance(); - $result = $objQuery->getAll($sql, array($email, $email)); - $data = isset($result[0]) ? $result[0] : array(); + $result = $objQuery->getAll($sql, [$email, $email]); + $data = isset($result[0]) ? $result[0] : []; $this->customer_data = $data; $this->startSession(); } @@ -183,8 +190,8 @@ public function updateSession() $sql = 'SELECT * FROM dtb_customer WHERE customer_id = ? AND del_flg = 0'; $customer_id = $this->getValue('customer_id'); $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrRet = $objQuery->getAll($sql, array($customer_id)); - $this->customer_data = isset($arrRet[0]) ? $arrRet[0] : array(); + $arrRet = $objQuery->getAll($sql, [$customer_id]); + $this->customer_data = isset($arrRet[0]) ? $arrRet[0] : []; $_SESSION['customer'] = $this->customer_data; } @@ -195,7 +202,7 @@ public function startSession() { $_SESSION['customer'] = $this->customer_data; // セッション情報の保存 - GC_Utils_Ex::gfPrintLog('access : user='.$this->customer_data['customer_id'] ."\t".'ip='. $this->getRemoteHost(), CUSTOMER_LOG_REALFILE, false); + GC_Utils_Ex::gfPrintLog('access : user='.$this->customer_data['customer_id']."\t".'ip='.$this->getRemoteHost(), CUSTOMER_LOG_REALFILE, false); } /** @@ -225,6 +232,7 @@ public function EndSession() * ログインに成功しているか判定する。 * * @param bool $dont_check_email_mobile + * * @return bool ログインに成功している場合は true */ public function isLoginSuccess($dont_check_email_mobile = false) @@ -234,12 +242,12 @@ public function isLoginSuccess($dont_check_email_mobile = false) && SC_Utils_Ex::sfIsInt($_SESSION['customer']['customer_id']) ) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $email = $objQuery->get('email', 'dtb_customer', 'customer_id = ?', array($_SESSION['customer']['customer_id'])); + $email = $objQuery->get('email', 'dtb_customer', 'customer_id = ?', [$_SESSION['customer']['customer_id']]); if ($email == $_SESSION['customer']['email']) { // モバイルサイトの場合は携帯のメールアドレスが登録されていることもチェックする。 // ただし $dont_check_email_mobile が true の場合はチェックしない。 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE && !$dont_check_email_mobile) { - $email_mobile = $objQuery->get('email_mobile', 'dtb_customer', 'customer_id = ?', array($_SESSION['customer']['customer_id'])); + $email_mobile = $objQuery->get('email_mobile', 'dtb_customer', 'customer_id = ?', [$_SESSION['customer']['customer_id']]); return isset($email_mobile); } @@ -255,6 +263,7 @@ public function isLoginSuccess($dont_check_email_mobile = false) * パラメーターの取得 * * @param string $keyname パラメーターのキー名 + * * @return string|int|null パラメータの値 */ public function getValue($keyname) @@ -262,7 +271,7 @@ public function getValue($keyname) // ポイントはリアルタイム表示 if ($keyname == 'point') { $objQuery = SC_Query_Ex::getSingletonInstance(); - $point = $objQuery->get('point', 'dtb_customer', 'customer_id = ?', array($_SESSION['customer']['customer_id'])); + $point = $objQuery->get('point', 'dtb_customer', 'customer_id = ?', [$_SESSION['customer']['customer_id']]); $_SESSION['customer']['point'] = $point; return $point; @@ -273,6 +282,7 @@ public function getValue($keyname) /** * パラメーターのセット + * * @param string $keyname * @param string $val */ @@ -285,6 +295,7 @@ public function setValue($keyname, $val) * パラメーターがNULLかどうかの判定 * * @param string $keyname + * * @return bool */ public function hasValue($keyname) @@ -305,8 +316,8 @@ public function isBirthMonth() { if (isset($_SESSION['customer']['birth'])) { $arrRet = preg_split('|[- :/]|', $_SESSION['customer']['birth']); - $birth_month = intval($arrRet[1]); - $now_month = intval(date('m')); + $birth_month = (int) ($arrRet[1]); + $now_month = (int) (date('m')); if ($birth_month == $now_month) { return true; @@ -352,10 +363,10 @@ public static function updateOrderSummary($customer_id) __EOS__; $table = 'dtb_order'; $where = 'customer_id = ? AND del_flg = 0 AND status <> ?'; - $arrWhereVal = array($customer_id, ORDER_CANCEL); + $arrWhereVal = [$customer_id, ORDER_CANCEL]; $arrOrderSummary = $objQuery->getRow($col, $table, $where, $arrWhereVal); - $objQuery->update('dtb_customer', $arrOrderSummary, 'customer_id = ?', array($customer_id)); + $objQuery->update('dtb_customer', $arrOrderSummary, 'customer_id = ?', [$customer_id]); } /** @@ -368,6 +379,7 @@ public static function updateOrderSummary($customer_id) * * @param string $login_email ログインメールアドレス * @param string $login_pass ログインパスワード + * * @return bool ログインに成功した場合 true; 失敗した場合 false */ public function doLogin($login_email, $login_pass) diff --git a/data/class/SC_CustomerList.php b/data/class/SC_CustomerList.php index 5e897eac23..21d536c9da 100644 --- a/data/class/SC_CustomerList.php +++ b/data/class/SC_CustomerList.php @@ -56,45 +56,57 @@ public function __construct($array, $mode = '') } // 会員ID - if (!isset($this->arrSql['search_customer_id'])) $this->arrSql['search_customer_id'] = ''; + if (!isset($this->arrSql['search_customer_id'])) { + $this->arrSql['search_customer_id'] = ''; + } if (strlen($this->arrSql['search_customer_id']) > 0) { $this->setWhere('customer_id = ?'); $this->arrVal[] = $this->arrSql['search_customer_id']; } // 名前 - if (!isset($this->arrSql['search_name'])) $this->arrSql['search_name'] = ''; + if (!isset($this->arrSql['search_name'])) { + $this->arrSql['search_name'] = ''; + } if (strlen($this->arrSql['search_name']) > 0) { - $this->setWhere('(' . $dbFactory->concatColumn(array('name01', 'name02')) . ' LIKE ?)'); + $this->setWhere('('.$dbFactory->concatColumn(['name01', 'name02']).' LIKE ?)'); $searchName = $this->addSearchStr($this->arrSql['search_name']); $this->arrVal[] = preg_replace('/[  ]+/u', '', $searchName); } // 名前(フリガナ) - if (!isset($this->arrSql['search_kana'])) $this->arrSql['search_kana'] = ''; + if (!isset($this->arrSql['search_kana'])) { + $this->arrSql['search_kana'] = ''; + } if (strlen($this->arrSql['search_kana']) > 0) { - $this->setWhere('(' . $dbFactory->concatColumn(array('kana01', 'kana02')) . ' LIKE ?)'); + $this->setWhere('('.$dbFactory->concatColumn(['kana01', 'kana02']).' LIKE ?)'); $searchKana = $this->addSearchStr($this->arrSql['search_kana']); $this->arrVal[] = preg_replace('/[  ]+/u', '', $searchKana); } // 都道府県 - if (!isset($this->arrSql['search_pref'])) $this->arrSql['search_pref'] = ''; + if (!isset($this->arrSql['search_pref'])) { + $this->arrSql['search_pref'] = ''; + } if (strlen($this->arrSql['search_pref']) > 0) { $this->setWhere('pref = ?'); $this->arrVal[] = $this->arrSql['search_pref']; } // 電話番号 - if (!isset($this->arrSql['search_tel'])) $this->arrSql['search_tel'] = ''; + if (!isset($this->arrSql['search_tel'])) { + $this->arrSql['search_tel'] = ''; + } if (is_numeric($this->arrSql['search_tel'])) { - $this->setWhere('(' . $dbFactory->concatColumn(array('tel01', 'tel02', 'tel03')) . ' LIKE ?)'); + $this->setWhere('('.$dbFactory->concatColumn(['tel01', 'tel02', 'tel03']).' LIKE ?)'); $searchTel = $this->addSearchStr($this->arrSql['search_tel']); $this->arrVal[] = str_replace('-', '', $searchTel); } // 性別 - if (!isset($this->arrSql['search_sex'])) $this->arrSql['search_sex'] = ''; + if (!isset($this->arrSql['search_sex'])) { + $this->arrSql['search_sex'] = ''; + } if (is_array($this->arrSql['search_sex'])) { $arrSexVal = $this->setItemTerm($this->arrSql['search_sex'], 'sex'); foreach ($arrSexVal as $data) { @@ -103,7 +115,9 @@ public function __construct($array, $mode = '') } // 職業 - if (!isset($this->arrSql['search_job'])) $this->arrSql['search_job'] = ''; + if (!isset($this->arrSql['search_job'])) { + $this->arrSql['search_job'] = ''; + } if (is_array($this->arrSql['search_job'])) { if (in_array('不明', $this->arrSql['search_job'])) { $arrJobVal = $this->setItemTermWithNull($this->arrSql['search_job'], 'job'); @@ -118,14 +132,16 @@ public function __construct($array, $mode = '') } // E-MAIL - if (!isset($this->arrSql['search_email'])) $this->arrSql['search_email'] = ''; + if (!isset($this->arrSql['search_email'])) { + $this->arrSql['search_email'] = ''; + } if (strlen($this->arrSql['search_email']) > 0) { - //カンマ区切りで複数の条件指定可能に + // カンマ区切りで複数の条件指定可能に $this->arrSql['search_email'] = explode(',', $this->arrSql['search_email']); $sql_where = ''; foreach ($this->arrSql['search_email'] as $val) { $val = trim($val); - //検索条件を含まない + // 検索条件を含まない if ($this->arrSql['not_emailinc'] == '1') { if ($sql_where == '') { $sql_where .= 'dtb_customer.email NOT ILIKE ? '; @@ -146,15 +162,17 @@ public function __construct($array, $mode = '') } // E-MAIL(mobile) - if (!isset($this->arrSql['search_email_mobile'])) $this->arrSql['search_email_mobile'] = ''; + if (!isset($this->arrSql['search_email_mobile'])) { + $this->arrSql['search_email_mobile'] = ''; + } if (strlen($this->arrSql['search_email_mobile']) > 0) { - //カンマ区切りで複数の条件指定可能に + // カンマ区切りで複数の条件指定可能に $this->arrSql['search_email_mobile'] = explode(',', $this->arrSql['search_email_mobile']); $sql_where = ''; foreach ($this->arrSql['search_email_mobile'] as $val) { $val = trim($val); - //検索条件を含まない + // 検索条件を含まない if ($this->arrSql['not_email_mobileinc'] == '1') { if ($sql_where == '') { $sql_where .= 'dtb_customer.email_mobile NOT ILIKE ? '; @@ -201,15 +219,15 @@ public function __construct($array, $mode = '') case 1: $this->setWhere("(dtb_customer.email <> dtb_customer.email_mobile OR $sqlEmailMobileIsEmpty)"); break; - // 携帯メールアドレス + // 携帯メールアドレス case 2: $this->setWhere("NOT $sqlEmailMobileIsEmpty"); break; - // PCメールアドレス (携帯メールアドレスを登録している会員は除外) + // PCメールアドレス (携帯メールアドレスを登録している会員は除外) case 3: $this->setWhere($sqlEmailMobileIsEmpty); break; - // 携帯メールアドレス (PCメールアドレスを登録している会員は除外) + // 携帯メールアドレス (PCメールアドレスを登録している会員は除外) case 4: $this->setWhere('dtb_customer.email = dtb_customer.email_mobile'); break; @@ -218,8 +236,12 @@ public function __construct($array, $mode = '') } // 購入金額指定 - if (!isset($this->arrSql['search_buy_total_from'])) $this->arrSql['search_buy_total_from'] = ''; - if (!isset($this->arrSql['search_buy_total_to'])) $this->arrSql['search_buy_total_to'] = ''; + if (!isset($this->arrSql['search_buy_total_from'])) { + $this->arrSql['search_buy_total_from'] = ''; + } + if (!isset($this->arrSql['search_buy_total_to'])) { + $this->arrSql['search_buy_total_to'] = ''; + } if (is_numeric($this->arrSql['search_buy_total_from']) || is_numeric($this->arrSql['search_buy_total_to'])) { $arrBuyTotal = $this->selectRange($this->arrSql['search_buy_total_from'], $this->arrSql['search_buy_total_to'], 'buy_total'); foreach ($arrBuyTotal as $data) { @@ -228,8 +250,12 @@ public function __construct($array, $mode = '') } // 購入回数指定 - if (!isset($this->arrSql['search_buy_times_from'])) $this->arrSql['search_buy_times_from'] = ''; - if (!isset($this->arrSql['search_buy_times_to'])) $this->arrSql['search_buy_times_to'] = ''; + if (!isset($this->arrSql['search_buy_times_from'])) { + $this->arrSql['search_buy_times_from'] = ''; + } + if (!isset($this->arrSql['search_buy_times_to'])) { + $this->arrSql['search_buy_times_to'] = ''; + } if (is_numeric($this->arrSql['search_buy_times_from']) || is_numeric($this->arrSql['search_buy_times_to'])) { $arrBuyTimes = $this->selectRange($this->arrSql['search_buy_times_from'], $this->arrSql['search_buy_times_to'], 'buy_times'); foreach ($arrBuyTimes as $data) { @@ -238,63 +264,103 @@ public function __construct($array, $mode = '') } // 誕生日期間指定 - if (!isset($this->arrSql['search_b_start_year'])) $this->arrSql['search_b_start_year'] = ''; - if (!isset($this->arrSql['search_b_start_month'])) $this->arrSql['search_b_start_month'] = ''; - if (!isset($this->arrSql['search_b_start_day'])) $this->arrSql['search_b_start_day'] = ''; - if (!isset($this->arrSql['search_b_end_year'])) $this->arrSql['search_b_end_year'] = ''; - if (!isset($this->arrSql['search_b_end_month'])) $this->arrSql['search_b_end_month'] = ''; - if (!isset($this->arrSql['search_b_end_day'])) $this->arrSql['search_b_end_day'] = ''; + if (!isset($this->arrSql['search_b_start_year'])) { + $this->arrSql['search_b_start_year'] = ''; + } + if (!isset($this->arrSql['search_b_start_month'])) { + $this->arrSql['search_b_start_month'] = ''; + } + if (!isset($this->arrSql['search_b_start_day'])) { + $this->arrSql['search_b_start_day'] = ''; + } + if (!isset($this->arrSql['search_b_end_year'])) { + $this->arrSql['search_b_end_year'] = ''; + } + if (!isset($this->arrSql['search_b_end_month'])) { + $this->arrSql['search_b_end_month'] = ''; + } + if (!isset($this->arrSql['search_b_end_day'])) { + $this->arrSql['search_b_end_day'] = ''; + } if ((strlen($this->arrSql['search_b_start_year']) > 0 && strlen($this->arrSql['search_b_start_month']) > 0 && strlen($this->arrSql['search_b_start_day']) > 0) || strlen($this->arrSql['search_b_end_year']) > 0 && strlen($this->arrSql['search_b_end_month']) > 0 && strlen($this->arrSql['search_b_end_day']) > 0) { $arrBirth = $this->selectTermRange($this->arrSql['search_b_start_year'], $this->arrSql['search_b_start_month'], $this->arrSql['search_b_start_day'], - $this->arrSql['search_b_end_year'], $this->arrSql['search_b_end_month'], $this->arrSql['search_b_end_day'], 'birth'); + $this->arrSql['search_b_end_year'], $this->arrSql['search_b_end_month'], $this->arrSql['search_b_end_day'], 'birth'); foreach ($arrBirth as $data) { $this->arrVal[] = $data; } } // 誕生月の検索 - if (!isset($this->arrSql['search_birth_month'])) $this->arrSql['search_birth_month'] = ''; + if (!isset($this->arrSql['search_birth_month'])) { + $this->arrSql['search_birth_month'] = ''; + } if (is_numeric($this->arrSql['search_birth_month'])) { $this->setWhere(' EXTRACT(month from birth) = ?'); $this->arrVal[] = $this->arrSql['search_birth_month']; } // 登録期間指定 - if (!isset($this->arrSql['search_start_year'])) $this->arrSql['search_start_year'] = ''; - if (!isset($this->arrSql['search_start_month'])) $this->arrSql['search_start_month'] = ''; - if (!isset($this->arrSql['search_start_day'])) $this->arrSql['search_start_day'] = ''; - if (!isset($this->arrSql['search_end_year'])) $this->arrSql['search_end_year'] = ''; - if (!isset($this->arrSql['search_end_month'])) $this->arrSql['search_end_month'] = ''; - if (!isset($this->arrSql['search_end_day'])) $this->arrSql['search_end_day'] = ''; - if ( (strlen($this->arrSql['search_start_year']) > 0 && strlen($this->arrSql['search_start_month']) > 0 && strlen($this->arrSql['search_start_day']) > 0) || - (strlen($this->arrSql['search_end_year']) > 0 && strlen($this->arrSql['search_end_month']) >0 && strlen($this->arrSql['search_end_day']) > 0)) { + if (!isset($this->arrSql['search_start_year'])) { + $this->arrSql['search_start_year'] = ''; + } + if (!isset($this->arrSql['search_start_month'])) { + $this->arrSql['search_start_month'] = ''; + } + if (!isset($this->arrSql['search_start_day'])) { + $this->arrSql['search_start_day'] = ''; + } + if (!isset($this->arrSql['search_end_year'])) { + $this->arrSql['search_end_year'] = ''; + } + if (!isset($this->arrSql['search_end_month'])) { + $this->arrSql['search_end_month'] = ''; + } + if (!isset($this->arrSql['search_end_day'])) { + $this->arrSql['search_end_day'] = ''; + } + if ((strlen($this->arrSql['search_start_year']) > 0 && strlen($this->arrSql['search_start_month']) > 0 && strlen($this->arrSql['search_start_day']) > 0) || + (strlen($this->arrSql['search_end_year']) > 0 && strlen($this->arrSql['search_end_month']) > 0 && strlen($this->arrSql['search_end_day']) > 0)) { $arrRegistTime = $this->selectTermRange($this->arrSql['search_start_year'], $this->arrSql['search_start_month'], $this->arrSql['search_start_day'], - $this->arrSql['search_end_year'], $this->arrSql['search_end_month'], $this->arrSql['search_end_day'], $regdate_col); + $this->arrSql['search_end_year'], $this->arrSql['search_end_month'], $this->arrSql['search_end_day'], $regdate_col); foreach ($arrRegistTime as $data) { $this->arrVal[] = $data; } } // 最終購入日指定 - if (!isset($this->arrSql['search_buy_start_year'])) $this->arrSql['search_buy_start_year'] = ''; - if (!isset($this->arrSql['search_buy_start_month'])) $this->arrSql['search_buy_start_month'] = ''; - if (!isset($this->arrSql['search_buy_start_day'])) $this->arrSql['search_buy_start_day'] = ''; - if (!isset($this->arrSql['search_buy_end_year'])) $this->arrSql['search_buy_end_year'] = ''; - if (!isset($this->arrSql['search_buy_end_month'])) $this->arrSql['search_buy_end_month'] = ''; - if (!isset($this->arrSql['search_buy_end_day'])) $this->arrSql['search_buy_end_day'] = ''; - - if ( (strlen($this->arrSql['search_buy_start_year']) > 0 && strlen($this->arrSql['search_buy_start_month']) > 0 && strlen($this->arrSql['search_buy_start_day']) > 0) || - (strlen($this->arrSql['search_buy_end_year']) > 0 && strlen($this->arrSql['search_buy_end_month']) >0 && strlen($this->arrSql['search_buy_end_day']) > 0)) { + if (!isset($this->arrSql['search_buy_start_year'])) { + $this->arrSql['search_buy_start_year'] = ''; + } + if (!isset($this->arrSql['search_buy_start_month'])) { + $this->arrSql['search_buy_start_month'] = ''; + } + if (!isset($this->arrSql['search_buy_start_day'])) { + $this->arrSql['search_buy_start_day'] = ''; + } + if (!isset($this->arrSql['search_buy_end_year'])) { + $this->arrSql['search_buy_end_year'] = ''; + } + if (!isset($this->arrSql['search_buy_end_month'])) { + $this->arrSql['search_buy_end_month'] = ''; + } + if (!isset($this->arrSql['search_buy_end_day'])) { + $this->arrSql['search_buy_end_day'] = ''; + } + + if ((strlen($this->arrSql['search_buy_start_year']) > 0 && strlen($this->arrSql['search_buy_start_month']) > 0 && strlen($this->arrSql['search_buy_start_day']) > 0) || + (strlen($this->arrSql['search_buy_end_year']) > 0 && strlen($this->arrSql['search_buy_end_month']) > 0 && strlen($this->arrSql['search_buy_end_day']) > 0)) { $arrRegistTime = $this->selectTermRange($this->arrSql['search_buy_start_year'], $this->arrSql['search_buy_start_month'], $this->arrSql['search_buy_start_day'], - $this->arrSql['search_buy_end_year'], $this->arrSql['search_buy_end_month'], $this->arrSql['search_buy_end_day'], 'last_buy_date'); + $this->arrSql['search_buy_end_year'], $this->arrSql['search_buy_end_month'], $this->arrSql['search_buy_end_day'], 'last_buy_date'); foreach ($arrRegistTime as $data) { $this->arrVal[] = $data; } } // 購入商品コード - if (!isset($this->arrSql['search_buy_product_code'])) $this->arrSql['search_buy_product_code'] = ''; + if (!isset($this->arrSql['search_buy_product_code'])) { + $this->arrSql['search_buy_product_code'] = ''; + } if (strlen($this->arrSql['search_buy_product_code']) > 0) { $this->setWhere('customer_id IN (SELECT customer_id FROM dtb_order WHERE order_id IN (SELECT order_id FROM dtb_order_detail WHERE product_code LIKE ?) AND del_flg = 0)'); $search_buyproduct_code = $this->addSearchStr($this->arrSql['search_buy_product_code']); @@ -302,7 +368,9 @@ public function __construct($array, $mode = '') } // 購入商品名称 - if (!isset($this->arrSql['search_buy_product_name'])) $this->arrSql['search_buy_product_name'] = ''; + if (!isset($this->arrSql['search_buy_product_name'])) { + $this->arrSql['search_buy_product_name'] = ''; + } if (strlen($this->arrSql['search_buy_product_name']) > 0) { $this->setWhere('customer_id IN (SELECT customer_id FROM dtb_order WHERE order_id IN (SELECT order_id FROM dtb_order_detail WHERE product_name LIKE ?) AND del_flg = 0)'); $search_buyproduct_name = $this->addSearchStr($this->arrSql['search_buy_product_name']); @@ -310,7 +378,9 @@ public function __construct($array, $mode = '') } // カテゴリを選択している場合のみ絞込検索を行う - if (!isset($this->arrSql['search_category_id'])) $this->arrSql['search_category_id'] = ''; + if (!isset($this->arrSql['search_category_id'])) { + $this->arrSql['search_category_id'] = ''; + } if (strlen($this->arrSql['search_category_id']) > 0) { // カテゴリで絞込検索を行うSQL文生成 list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($this->arrSql['search_category_id']); @@ -323,7 +393,9 @@ public function __construct($array, $mode = '') } // 会員状態 - if (!isset($this->arrSql['search_status'])) $this->arrSql['search_status'] = ''; + if (!isset($this->arrSql['search_status'])) { + $this->arrSql['search_status'] = ''; + } if (is_array($this->arrSql['search_status'])) { $arrStatusVal = $this->setItemTerm($this->arrSql['search_status'], 'status'); foreach ($arrStatusVal as $data) { @@ -349,11 +421,11 @@ public function getList() */ public function getListMailMagazine($is_mobile = false) { - $this->select = " + $this->select = ' SELECT * FROM - dtb_customer"; + dtb_customer'; return $this->getSql(0); } @@ -370,6 +442,7 @@ public function getListCount() /** * CSVダウンロード用SQL + * * @deprecated 本体で使用していないため非推奨 */ public function getListCSV($arrColumnCSV) @@ -378,18 +451,20 @@ public function getListCSV($arrColumnCSV) $i = 0; $state = ''; foreach ($this->arrColumnCSV as $val) { - if ($i != 0) $state .= ', '; + if ($i != 0) { + $state .= ', '; + } $state .= $val['sql']; - $i ++; + $i++; } - $this->select = 'SELECT ' .$state. ' FROM dtb_customer '; + $this->select = 'SELECT '.$state.' FROM dtb_customer '; return $this->getSql(2); } public function getWhere($with_where = false) { - return array(parent::getWhere($with_where), $this->arrVal); + return [parent::getWhere($with_where), $this->arrVal]; } } diff --git a/data/class/SC_Date.php b/data/class/SC_Date.php index ed93939b3f..77a66f076e 100644 --- a/data/class/SC_Date.php +++ b/data/class/SC_Date.php @@ -29,14 +29,18 @@ class SC_Date public $day; public $end_year; - public static $arrHoliday = NULL; - public static $arrRegularHoliday = NULL; + public static $arrHoliday = null; + public static $arrRegularHoliday = null; // コンストラクタ - public function __construct($start_year='', $end_year='') + public function __construct($start_year = '', $end_year = '') { - if ($start_year) $this->setStartYear($start_year); - if ($end_year) $this->setEndYear($end_year); + if ($start_year) { + $this->setStartYear($start_year); + } + if ($end_year) { + $this->setEndYear($end_year); + } } public function setStartYear($year) @@ -75,6 +79,7 @@ public function setDay($day) /** * 年プルダウン用の配列を返す * FIXME $default_year に一致いる行が無かった場合、先頭か末尾に付加すべきと思われる。 + * * @param string $year XMLファイル名 * @param bool|string $default_year * false 「選択なし」は含めない。 @@ -84,15 +89,21 @@ public function setDay($day) */ public function getYear($year = '', $default_year = false, $default_key = '----') { - if ($year) $this->setStartYear($year); + if ($year) { + $this->setStartYear($year); + } $year = $this->start_year; - if (! $year) $year = DATE('Y'); + if (!$year) { + $year = date('Y'); + } $end_year = $this->end_year; - if (! $end_year) $end_year = (DATE('Y') + 3); + if (!$end_year) { + $end_year = (date('Y') + 3); + } - $year_array = array(); + $year_array = []; if ($default_year === true) { $year_array[$default_key] = '----'; @@ -110,15 +121,21 @@ public function getYear($year = '', $default_year = false, $default_key = '----' public function getZeroYear($year = '') { - if ($year) $this->setStartYear($year); + if ($year) { + $this->setStartYear($year); + } $year = $this->start_year; - if (! $year) $year = DATE('Y'); + if (!$year) { + $year = date('Y'); + } $end_year = $this->end_year; - if (! $end_year) $end_year = (DATE('Y') + 3); + if (!$end_year) { + $end_year = (date('Y') + 3); + } - $year_array = array(); + $year_array = []; for ($i = $year; $i <= $end_year; $i++) { $key = substr($i, -2); @@ -130,8 +147,8 @@ public function getZeroYear($year = '') public function getZeroMonth() { - $month_array = array(); - for ($i=1; $i <= 12; $i++) { + $month_array = []; + for ($i = 1; $i <= 12; $i++) { $val = sprintf('%02d', $i); $month_array[$val] = $val; } @@ -141,12 +158,14 @@ public function getZeroMonth() public function getMonth($default = false) { - $month_array = array(); + $month_array = []; - if ($default) $month_array[''] = '--'; + if ($default) { + $month_array[''] = '--'; + } - for ($i=0; $i < 12; $i++) { - $month_array[$i + 1 ] = $i + 1; + for ($i = 0; $i < 12; $i++) { + $month_array[$i + 1] = $i + 1; } return $month_array; @@ -154,12 +173,14 @@ public function getMonth($default = false) public function getDay($default = false) { - $day_array = array(); + $day_array = []; - if ($default) $day_array[''] = '--'; + if ($default) { + $day_array[''] = '--'; + } - for ($i=0; $i < 31; $i++) { - $day_array[ $i + 1 ] = $i + 1; + for ($i = 0; $i < 31; $i++) { + $day_array[$i + 1] = $i + 1; } return $day_array; @@ -167,8 +188,8 @@ public function getDay($default = false) public function getHour() { - $hour_array = array(); - for ($i=0; $i<=23; $i++) { + $hour_array = []; + for ($i = 0; $i <= 23; $i++) { $hour_array[$i] = $i; } @@ -177,8 +198,8 @@ public function getHour() public function getMinutes() { - $minutes_array = array(); - for ($i=0; $i<=59; $i++) { + $minutes_array = []; + for ($i = 0; $i <= 59; $i++) { $minutes_array[$i] = $i; } @@ -187,7 +208,7 @@ public function getMinutes() public function getMinutesInterval() { - $minutes_array = array('00'=>'00', '30'=>'30'); + $minutes_array = ['00' => '00', '30' => '30']; return $minutes_array; } @@ -195,15 +216,20 @@ public function getMinutesInterval() /** * 休日の判定. * - * @param integer $year - * @param integer $month - * @param integer $day - * @return boolean 休日の場合はtrue + * @param int $year + * @param int $month + * @param int $day + * + * @return bool 休日の場合はtrue */ public function isHoliday($year, $month, $day) { - if (is_null(SC_Date_Ex::$arrHoliday)) $this->setArrHoliday(); - if (is_null(SC_Date_Ex::$arrRegularHoliday)) $this->setRegularHoliday(); + if (is_null(SC_Date_Ex::$arrHoliday)) { + $this->setArrHoliday(); + } + if (is_null(SC_Date_Ex::$arrRegularHoliday)) { + $this->setRegularHoliday(); + } if (!empty(SC_Date_Ex::$arrHoliday[$month])) { if (in_array($day, SC_Date_Ex::$arrHoliday[$month])) { @@ -229,8 +255,8 @@ private function setArrHoliday() { $objHoliday = new SC_Helper_Holiday_Ex(); $holiday = $objHoliday->getList(); - $arrHoliday = array(); - foreach ($holiday AS $val) { + $arrHoliday = []; + foreach ($holiday as $val) { $arrHoliday[$val['month']][] = $val['day']; } SC_Date_Ex::$arrHoliday = $arrHoliday; diff --git a/data/class/SC_Display.php b/data/class/SC_Display.php index 0957a115ab..17e0c7a128 100644 --- a/data/class/SC_Display.php +++ b/data/class/SC_Display.php @@ -25,6 +25,7 @@ * Http コンテンツ出力を制御するクラス. * * @author Ryuichi Tokugami + * * @version $Id$ */ class SC_Display @@ -83,9 +84,10 @@ public function prepare($page, $is_admin = false) * リロードを行う. * * SC_Response::reload() のラッパーです. + * * @deprecated SC_Response::reload() を使用してください */ - public function reload($queryString = array(), $removeQueryString = false) + public function reload($queryString = [], $removeQueryString = false) { SC_Response_Ex::reload($queryString, $removeQueryString); } @@ -145,13 +147,15 @@ public function setView($view) * SC_Display::PC = PC = 10 * * @static + * * @param $reset boolean - * @return integer 端末種別ID + * + * @return int 端末種別ID */ - public static function detectDevice($reset = FALSE) + public static function detectDevice($reset = false) { if (is_null(SC_Display_Ex::$device) || $reset) { - //$nu = new Net_UserAgent_Mobile(); + // $nu = new Net_UserAgent_Mobile(); $su = new SC_SmartphoneUserAgent_Ex(); if ($su->isSmartphone()) { SC_Display_Ex::$device = DEVICE_TYPE_SMARTPHONE; @@ -163,7 +167,7 @@ public static function detectDevice($reset = FALSE) return SC_Display_Ex::$device; } - public function assign($val1,$val2) + public function assign($val1, $val2) { $this->view->assign($val1, $val2); } diff --git a/data/class/SC_FormParam.php b/data/class/SC_FormParam.php index aa3556f7f2..1ef32a72ba 100644 --- a/data/class/SC_FormParam.php +++ b/data/class/SC_FormParam.php @@ -26,7 +26,6 @@ * * :XXX: addParam と setParam で言う「パラメーター」が用語として競合しているように感じる。(2009/10/17 Seasoft 塚田) * - * @package SC * @author EC-CUBE CO.,LTD. */ class SC_FormParam @@ -35,29 +34,29 @@ class SC_FormParam * 何も入力されていないときに表示する値 * キーはキー名 */ - public $arrValue = array(); + public $arrValue = []; /** 表示名 */ - public $disp_name = array(); + public $disp_name = []; /** キー名 */ - public $keyname = array(); + public $keyname = []; - public $length = array(); - public $convert = array(); - public $arrCheck = array(); + public $length = []; + public $convert = []; + public $arrCheck = []; public $check_dir; /** * 何も入力されていないときに表示する値 * キーはキー名 */ - public $arrDefault = array(); + public $arrDefault = []; /** DBにそのまま挿入可能か否か */ - public $input_db = array(); + public $input_db = []; - public $html_disp_name = array(); + public $html_disp_name = []; /** * コンストラクタ @@ -73,7 +72,7 @@ public function __construct() $class = $backtraces[1]['class']; $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); if (is_object($objPlugin)) { - $objPlugin->doAction('SC_FormParam_construct', array($class, $this)); + $objPlugin->doAction('SC_FormParam_construct', [$class, $this]); } } @@ -84,17 +83,17 @@ public function __construct() */ public function initParam() { - $this->disp_name = array(); - $this->keyname = array(); - $this->length = array(); - $this->convert = array(); - $this->arrCheck = array(); - $this->arrDefault = array(); - $this->input_db = array(); + $this->disp_name = []; + $this->keyname = []; + $this->length = []; + $this->convert = []; + $this->arrCheck = []; + $this->arrDefault = []; + $this->input_db = []; } // パラメーターの追加 - public function addParam($disp_name, $keyname, $length = '', $convert = '', $arrCheck = array(), $default = '', $input_db = true) + public function addParam($disp_name, $keyname, $length = '', $convert = '', $arrCheck = [], $default = '', $input_db = true) { $this->disp_name[] = $disp_name; $this->keyname[] = $keyname; @@ -111,7 +110,9 @@ public function addParam($disp_name, $keyname, $length = '', $convert = '', $arr // $seq :trueの場合、$arrVal[0]~の配列を登録順にインスタンスに格納する public function setParam($arrVal, $seq = false) { - if (!is_array($arrVal)) return; + if (!is_array($arrVal)) { + return; + } if (!$seq) { foreach ($arrVal as $key => $val) { $this->setValue($key, $val); @@ -135,12 +136,12 @@ public function setHtmlDispNameArray() } if ($find) { - $this->html_disp_name[$index] = $this->disp_name[$index] . '(※ 必須)'; + $this->html_disp_name[$index] = $this->disp_name[$index].'(※ 必須)'; } else { $this->html_disp_name[$index] = $this->disp_name[$index]; } if (strlen($this->arrDefault[$key]) >= 1) { - $this->html_disp_name[$index] .= ' [省略時初期値: ' . $this->arrDefault[$key] . ']'; + $this->html_disp_name[$index] .= ' [省略時初期値: '.$this->arrDefault[$key].']'; } if ($this->input_db[$index] == false) { $this->html_disp_name[$index] .= ' [登録・更新不可] '; @@ -160,7 +161,7 @@ public function setParamList($arrVal2d, $keyname) // DBの件数を取得する。 $no = 1; foreach ($arrVal2d as $arrVal) { - $key = $keyname . $no; + $key = $keyname.$no; $this->setValue($key, $arrVal[$keyname]); $no++; } @@ -197,7 +198,7 @@ public function toLower($key) // エラーチェック public function checkError($br = true) { - $arrErr = array(); + $arrErr = []; foreach ($this->keyname as $index => $key) { foreach ($this->arrCheck[$index] as $func) { @@ -237,20 +238,20 @@ public function checkError($br = true) unset($arrErr[$key]); } break; - // 小文字に変換 + // 小文字に変換 case 'CHANGE_LOWER': $this->toLower($key); break; - // ファイルの存在チェック + // ファイルの存在チェック case 'FILE_EXISTS': - if ($value != '' && !file_exists($this->check_dir . $value)) { - $arrErr[$key] = '※ ' . $this->disp_name[$index] . 'のファイルが存在しません。
'; + if ($value != '' && !file_exists($this->check_dir.$value)) { + $arrErr[$key] = '※ '.$this->disp_name[$index].'のファイルが存在しません。
'; } break; - // ダウンロード用ファイルの存在チェック + // ダウンロード用ファイルの存在チェック case 'DOWN_FILE_EXISTS': - if ($value != '' && !file_exists(DOWN_SAVE_REALDIR . $value)) { - $arrErr[$key] = '※ ' . $this->disp_name[$index] . 'のファイルが存在しません。
'; + if ($value != '' && !file_exists(DOWN_SAVE_REALDIR.$value)) { + $arrErr[$key] = '※ '.$this->disp_name[$index].'のファイルが存在しません。
'; } break; default: @@ -277,7 +278,8 @@ public function checkError($br = true) * @param mixed $value チェック対象の値 * 配列の場合は再帰的にチェックする * @param array $arrErr エラーメッセージを格納する配列(の一部) - * @param integer $length チェック対象の値の長さ + * @param int $length チェック対象の値の長さ + * * @return void */ public function recursionCheck($disp_name, $func, $value, &$arrErr, @@ -287,17 +289,18 @@ public function recursionCheck($disp_name, $func, $value, &$arrErr, if (is_array($value)) { foreach ($value as $key => $in) { $this->recursionCheck($disp_name, $func, $in, $arrErr[$key], - $length); + $length); if (SC_Utils_Ex::isBlank($arrErr[$key])) { unset($arrErr[$key]); } } + return; } $dummy_key = 'dummy'; // 仮のキーを指定。どんな値でも良い。 - $objErr = new SC_CheckError_Ex(array($dummy_key => $value)); - $objErr->doFunc(array($disp_name, $dummy_key, $length), array($func)); + $objErr = new SC_CheckError_Ex([$dummy_key => $value]); + $objErr->doFunc([$disp_name, $dummy_key, $length], [$func]); if (array_key_exists($dummy_key, $objErr->arrErr) && !SC_Utils_Ex::isBlank($objErr->arrErr[$dummy_key])) { $arrErr = $objErr->arrErr[$dummy_key]; } @@ -307,6 +310,7 @@ public function recursionCheck($disp_name, $func, $value, &$arrErr, * フォームの入力パラメーターに応じて, 再帰的に mb_convert_kana 関数を実行する. * * @return void + * * @see mb_convert_kana */ public function convParam() @@ -341,11 +345,12 @@ public function recursionConvParam(&$value, $convert) * 連想配列で返す * * @param array $arrKey 対象のキー + * * @return array 連想配列 */ - public function getHashArray($arrKey = array()) + public function getHashArray($arrKey = []) { - $arrRet = array(); + $arrRet = []; foreach ($this->keyname as $keyname) { if (empty($arrKey) || in_array($keyname, $arrKey)) { $arrRet[$keyname] = $this->getValue($keyname); @@ -358,7 +363,7 @@ public function getHashArray($arrKey = array()) // DB格納用配列の作成 public function getDbArray() { - $dbArray = array(); + $dbArray = []; foreach ($this->keyname as $index => $key) { if ($this->input_db[$index]) { $dbArray[$key] = $this->getValue($key); @@ -372,9 +377,10 @@ public function getDbArray() * 配列の縦横を入れ替えて返す * * @param array $arrKey 対象のキー + * * @return array 縦横を入れ替えた配列 */ - public function getSwapArray($arrKey = array()) + public function getSwapArray($arrKey = []) { $arrTmp = $this->getHashArray($arrKey); @@ -398,7 +404,7 @@ public function getCount() // フォームに渡す用のパラメーターを返す public function getFormParamList() { - $formParamList = array(); + $formParamList = []; foreach ($this->keyname as $index => $key) { // キー名 $formParamList[$key]['keyname'] = $key; @@ -463,7 +469,8 @@ public function splitParamCheckBoxes($keyname) /** * 入力パラメーターの先頭及び末尾にある空白文字を削除する. * - * @param boolean $has_wide_space 全角空白も削除する場合 true + * @param bool $has_wide_space 全角空白も削除する場合 true + * * @return void */ public function trimParam($has_wide_space = true) @@ -477,7 +484,8 @@ public function trimParam($has_wide_space = true) * 再帰的に入力パラメーターの先頭及び末尾にある空白文字を削除する. * * @param mixed $value 変換する値. 配列の場合は再帰的に実行する. - * @param boolean $has_wide_space 全角空白も削除する場合 true + * @param bool $has_wide_space 全角空白も削除する場合 true + * * @return void */ public function recursionTrim(&$value, $has_wide_space = true) @@ -503,13 +511,14 @@ public function recursionTrim(&$value, $has_wide_space = true) * 引数で指定した文字列で始まるパラメーター名の入力値を連想配列で取得する. * * @param string $prefix パラメーター名の接頭辞 + * * @return array 検索結果引き継ぎ用の連想配列. */ public function getSearchArray($prefix = 'search_') { - $arrResults = array(); + $arrResults = []; foreach ($this->keyname as $key) { - if (preg_match('/^' . $prefix . '/', $key)) { + if (preg_match('/^'.$prefix.'/', $key)) { $arrResults[$key] = $this->getValue($key); } } @@ -521,16 +530,17 @@ public function getSearchArray($prefix = 'search_') * 前方互換用 * * 1次キーが添字なのが特徴だったと思われる。 + * * @deprecated 2.12.0 必要ならば getFormParamList メソッドに引数を追加するなどで実現可能 */ public function getFormDispArray() { - $formDispArray = array(); + $formDispArray = []; foreach ($this->keyname as $index => $key) { // キー名 $formDispArray[$index]['keyname'] = $key; // 表示名 - $formDispArray[$index]['disp_name'] = $this->disp_name[$index]; + $formDispArray[$index]['disp_name'] = $this->disp_name[$index]; // 文字数制限 $formDispArray[$index]['length'] = $this->length[$index]; // 入力値 @@ -544,13 +554,14 @@ public function getFormDispArray() * パラメーターの削除 * * addParamの逆の関数 + * * @param string $keyname */ public function removeParam($keyname) { $index = array_search($keyname, $this->keyname); - if ($index !== FALSE) { + if ($index !== false) { // 削除 unset($this->disp_name[$index]); unset($this->keyname[$index]); @@ -561,12 +572,12 @@ public function removeParam($keyname) unset($this->input_db[$index]); // 歯抜けになった配列を詰める - $this->disp_name = array_merge($this->disp_name); - $this->keyname = array_merge($this->keyname); - $this->length = array_merge($this->length); - $this->convert = array_merge($this->convert); - $this->arrCheck = array_merge($this->arrCheck); - $this->input_db = array_merge($this->input_db); + $this->disp_name = array_merge($this->disp_name); + $this->keyname = array_merge($this->keyname); + $this->length = array_merge($this->length); + $this->convert = array_merge($this->convert); + $this->arrCheck = array_merge($this->arrCheck); + $this->input_db = array_merge($this->input_db); } } @@ -581,7 +592,7 @@ public function overwriteParam($keyname, $target, $value) { $index = array_search($keyname, $this->keyname); - if ($index !== FALSE) { + if ($index !== false) { if ($target == 'default') { $this->arrDefault[$keyname] = $value; } else { @@ -595,11 +606,12 @@ public function overwriteParam($keyname, $target, $value) * * @param string $keyname 取得するキー名 * @param string $target 項目名(disp_name,length,convert等) + * * @return mixed パラメーターの設定情報 */ public function getParamSetting($keyname = null, $target = null) { - $arrSetting = array( + $arrSetting = [ 'disp_name', 'keyname', 'length', @@ -607,12 +619,12 @@ public function getParamSetting($keyname = null, $target = null) 'arrCheck', 'arrDefault', 'input_db', - ); + ]; if (is_null($keyname)) { // 全ての設定情報を取得 - $ret = array(); - foreach ($this->keyname as $index=>$key) { + $ret = []; + foreach ($this->keyname as $index => $key) { foreach ($arrSetting as $item) { if ($item == 'arrDefault') { $ret[$key]['default'] = $this->{$item}[$key]; @@ -621,6 +633,7 @@ public function getParamSetting($keyname = null, $target = null) } } } + return $ret; } @@ -629,7 +642,7 @@ public function getParamSetting($keyname = null, $target = null) if ($index !== false) { if (is_null($target)) { // 指定のkeynameの全ての設定情報を取得 - $ret = array(); + $ret = []; foreach ($arrSetting as $item) { if ($item == 'arrDefault') { $ret['default'] = $this->{$item}[$keyname]; @@ -637,6 +650,7 @@ public function getParamSetting($keyname = null, $target = null) $ret[$item] = $this->{$item}[$index]; } } + return $ret; } diff --git a/data/class/SC_Fpdf.php b/data/class/SC_Fpdf.php index fb7995fc13..52b592ede5 100644 --- a/data/class/SC_Fpdf.php +++ b/data/class/SC_Fpdf.php @@ -21,13 +21,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** +/* * PDF 納品書を出力する * * TODO ページクラスとすべき要素を多々含んでいるように感じる。 */ -define('PDF_TEMPLATE_REALDIR', TEMPLATE_ADMIN_REALDIR . 'pdf/'); +define('PDF_TEMPLATE_REALDIR', TEMPLATE_ADMIN_REALDIR.'pdf/'); class SC_Fpdf extends SC_Helper_FPDI { @@ -55,35 +55,36 @@ class SC_Fpdf extends SC_Helper_FPDI public $disp_mode; /** @var int */ public $pageno; + public function __construct($download, $title, $tpl_pdf = 'nouhinsyo1.pdf') { parent::__construct(); // デフォルトの設定 - $this->tpl_pdf = PDF_TEMPLATE_REALDIR . $tpl_pdf; // テンプレートファイル + $this->tpl_pdf = PDF_TEMPLATE_REALDIR.$tpl_pdf; // テンプレートファイル $this->pdf_download = $download; // PDFのダウンロード形式(0:表示、1:ダウンロード) $this->tpl_title = $title; $this->tpl_dispmode = 'real'; // 表示モード $masterData = new SC_DB_MasterData_Ex(); $this->arrPref = $masterData->getMasterData('mtb_pref'); - $this->width_cell = array(110.3,12,21.7,24.5); + $this->width_cell = [110.3, 12, 21.7, 24.5]; $this->label_cell[] = '商品名 / 商品コード / [ 規格 ]'; $this->label_cell[] = '数量'; $this->label_cell[] = '単価'; $this->label_cell[] = '金額(税込)'; - $this->arrMessage = array( + $this->arrMessage = [ 'このたびはお買上げいただきありがとうございます。', '下記の内容にて納品させていただきます。', 'ご確認くださいますよう、お願いいたします。' - ); + ]; // SJISフォント $this->AddSJISFont(); $this->SetFont('SJIS'); - //ページ総数取得 + // ページ総数取得 $this->AliasNbPages(); // マージン設定 @@ -103,7 +104,7 @@ public function setData($arrData) // ページを追加(新規) $this->AddPage(); - //表示倍率(100%) + // 表示倍率(100%) $this->SetDisplayMode($this->tpl_dispmode); if (SC_Utils_Ex::sfIsInt($arrData['order_id'])) { @@ -133,27 +134,27 @@ private function setShopData() // 会社名 $this->lfText(125, 68, $arrInfo['law_company'], 8); // 郵便番号 - $text = '〒 ' . $arrInfo['law_zip01'] . ' - ' . $arrInfo['law_zip02']; + $text = '〒 '.$arrInfo['law_zip01'].' - '.$arrInfo['law_zip02']; $this->lfText(125, 71, $text, 8); // 都道府県+所在地 - $text = $this->arrPref[$arrInfo['law_pref']] . $arrInfo['law_addr01']; + $text = $this->arrPref[$arrInfo['law_pref']].$arrInfo['law_addr01']; $this->lfText(125, 74, $text, 8); $this->lfText(125, 77, $arrInfo['law_addr02'], 8); $text = 'TEL: '.$arrInfo['law_tel01'].'-'.$arrInfo['law_tel02'].'-'.$arrInfo['law_tel03']; - //FAX番号が存在する場合、表示する + // FAX番号が存在する場合、表示する if (strlen($arrInfo['law_fax01']) > 0) { $text .= ' FAX: '.$arrInfo['law_fax01'].'-'.$arrInfo['law_fax02'].'-'.$arrInfo['law_fax03']; } - $this->lfText(125, 80, $text, 8); //TEL・FAX + $this->lfText(125, 80, $text, 8); // TEL・FAX if (strlen($arrInfo['law_email']) > 0) { $text = 'Email: '.$arrInfo['law_email']; - $this->lfText(125, 83, $text, 8); //Email + $this->lfText(125, 83, $text, 8); // Email } - //ロゴ画像 - $logo_file = PDF_TEMPLATE_REALDIR . 'logo.png'; + // ロゴ画像 + $logo_file = PDF_TEMPLATE_REALDIR.'logo.png'; $this->Image($logo_file, 124, 46, 40); if (defined('INVOICE_REGISTRATION_NUM')) { @@ -165,63 +166,63 @@ private function setShopData() private function setMessageData() { // メッセージ - $this->lfText(27, 89, $this->arrData['msg1'], 8); //メッセージ1 - $this->lfText(27, 92, $this->arrData['msg2'], 8); //メッセージ2 - $this->lfText(27, 95, $this->arrData['msg3'], 8); //メッセージ3 + $this->lfText(27, 89, $this->arrData['msg1'], 8); // メッセージ1 + $this->lfText(27, 92, $this->arrData['msg2'], 8); // メッセージ2 + $this->lfText(27, 95, $this->arrData['msg3'], 8); // メッセージ3 $text = '作成日: '.$this->arrData['year'].'年'.$this->arrData['month'].'月'.$this->arrData['day'].'日'; - $this->lfText(158, 288, $text, 8); //作成日 + $this->lfText(158, 288, $text, 8); // 作成日 } private function setOrderData() { - $arrOrder = array(); + $arrOrder = []; // DBから受注情報を読み込む $this->lfGetOrderData($this->arrData['order_id']); // 購入者情報 $text = '〒 '.$this->arrDisp['order_zip01'].' - '.$this->arrDisp['order_zip02']; - $this->lfText(23, 43, $text, 8); //購入者郵便番号 + $this->lfText(23, 43, $text, 8); // 購入者郵便番号 $y = 47; // 住所1の1行目の高さ - $text = $this->arrPref[$this->arrDisp['order_pref']] . $this->arrDisp['order_addr01']; //購入者都道府県+住所1 + $text = $this->arrPref[$this->arrDisp['order_pref']].$this->arrDisp['order_addr01']; // 購入者都道府県+住所1 - while (mb_strwidth($text) > 68){ + while (mb_strwidth($text) > 68) { $line = mb_strimwidth($text, 0, 68); // 1行分の文字列 $this->lfText(27, $y, $line, 8); $cut = strlen($line); - $text = substr($text, $cut , strlen($text) - $cut); + $text = substr($text, $cut, strlen($text) - $cut); $y = $y + 3; } - if ($text != ""){ + if ($text != '') { $this->lfText(27, $y, $text, 8); $y = $y + 3; } - $text = $this->arrDisp['order_addr02']; //購入者住所2 + $text = $this->arrDisp['order_addr02']; // 購入者住所2 - while (mb_strwidth($text) > 68){ + while (mb_strwidth($text) > 68) { $line = mb_strimwidth($text, 0, 68); // 1行分の文字列 $this->lfText(27, $y, $line, 8); $cut = strlen($line); - $text = substr($text, $cut , strlen($text) - $cut); + $text = substr($text, $cut, strlen($text) - $cut); $y = $y + 3; } - if ($text != ""){ + if ($text != '') { $this->lfText(27, $y, $text, 8); $y = $y + 3; } $text = $this->arrDisp['order_name01'].' '.$this->arrDisp['order_name02'].' 様'; - $this->lfText(27, $y + 2, $text, 11); //購入者氏名 + $this->lfText(27, $y + 2, $text, 11); // 購入者氏名 // お届け先情報 $this->SetFont('SJIS', '', 10); - $this->lfText(25, 125, SC_Utils_Ex::sfDispDBDate($this->arrDisp['create_date']), 10); //ご注文日 - $this->lfText(25, 135, $this->arrDisp['order_id'], 10); //注文番号 + $this->lfText(25, 125, SC_Utils_Ex::sfDispDBDate($this->arrDisp['create_date']), 10); // ご注文日 + $this->lfText(25, 135, $this->arrDisp['order_id'], 10); // 注文番号 $this->SetFont('Gothic', 'B', 15); - $this->Cell(0, 10, $this->tpl_title, 0, 2, 'C', 0, ''); //文書タイトル(納品書・請求書) + $this->Cell(0, 10, $this->tpl_title, 0, 2, 'C', 0, ''); // 文書タイトル(納品書・請求書) $this->Cell(0, 66, '', 0, 2, 'R', 0, ''); $this->Cell(5, 0, '', 0, 0, 'R', 0, ''); $this->SetFont('SJIS', 'B', 15); @@ -246,7 +247,7 @@ private function setOrderData() // 小計(商品毎) $data[2] = $data[0] * $data[1]; - $arrOrder[$i][0] = $this->arrDisp['product_name'][$i].' / '; + $arrOrder[$i][0] = $this->arrDisp['product_name'][$i].' / '; $arrOrder[$i][0] .= $this->arrDisp['product_code'][$i].' / '; if ($this->arrDisp['classcategory_name1'][$i]) { $arrOrder[$i][0] .= ' [ '.$this->arrDisp['classcategory_name1'][$i]; @@ -261,9 +262,9 @@ private function setOrderData() if ($this->arrDisp['tax_rate'][$i] < $defaultTaxRule['tax_rate']) { $arrOrder[$i][0] .= ' ※'; } - $arrOrder[$i][1] = number_format($data[0]); - $arrOrder[$i][2] = number_format($data[1]).$monetary_unit; - $arrOrder[$i][3] = number_format($data[2]).$monetary_unit; + $arrOrder[$i][1] = number_format($data[0]); + $arrOrder[$i][2] = number_format($data[1]).$monetary_unit; + $arrOrder[$i][3] = number_format($data[2]).$monetary_unit; if (array_key_exists($this->arrDisp['tax_rate'][$i], $arrTaxableTotal) === false) { $arrTaxableTotal[$this->arrDisp['tax_rate'][$i]] = 0; } @@ -286,14 +287,14 @@ private function setOrderData() $arrOrder[$i][1] = ''; $arrOrder[$i][2] = '送料'; $arrOrder[$i][3] = number_format($this->arrDisp['deliv_fee']).$monetary_unit; - $arrTaxableTotal[intval($defaultTaxRule['tax_rate'])] += $this->arrDisp['deliv_fee']; + $arrTaxableTotal[(int) ($defaultTaxRule['tax_rate'])] += $this->arrDisp['deliv_fee']; $i++; $arrOrder[$i][0] = ''; $arrOrder[$i][1] = ''; $arrOrder[$i][2] = '手数料'; $arrOrder[$i][3] = number_format($this->arrDisp['charge']).$monetary_unit; - $arrTaxableTotal[intval($defaultTaxRule['tax_rate'])] += $this->arrDisp['charge']; + $arrTaxableTotal[(int) ($defaultTaxRule['tax_rate'])] += $this->arrDisp['charge']; $i++; $arrOrder[$i][0] = ''; @@ -359,7 +360,7 @@ private function setEtcData() $this->SetFont('Gothic', 'B', 9); $this->MultiCell(0, 6, '< 備考 >', 'T', 2, 'L'); $this->SetFont('SJIS', '', 8); - $text = SC_Utils_Ex::rtrim($this->arrData['etc1'] . "\n" . $this->arrData['etc2'] . "\n" . $this->arrData['etc3']); + $text = SC_Utils_Ex::rtrim($this->arrData['etc1']."\n".$this->arrData['etc2']."\n".$this->arrData['etc3']); $this->MultiCell(0, 4, $text, '', 2, 'L'); } @@ -385,8 +386,8 @@ public function createPdf() // PDF_Japanese::Text へのパーサー /** - * @param integer $x - * @param integer $y + * @param int $x + * @param int $y */ private function lfText($x, $y, $text, $size = 0, $style = '') { diff --git a/data/class/SC_Image.php b/data/class/SC_Image.php index e404ccfd72..b752d0b2b0 100644 --- a/data/class/SC_Image.php +++ b/data/class/SC_Image.php @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -//---- アップロードファイル加工クラス(thumb.phpとセットで使用する) +// ---- アップロードファイル加工クラス(thumb.phpとセットで使用する) class SC_Image { public $tmp_dir; @@ -29,23 +29,23 @@ class SC_Image public function __construct($tmp_dir) { // ヘッダファイル読込 - $this->tmp_dir = rtrim($tmp_dir, '/') . '/'; + $this->tmp_dir = rtrim($tmp_dir, '/').'/'; } - //--- 一時ファイル生成(サムネイル画像生成用) + // --- 一時ファイル生成(サムネイル画像生成用) public function makeTempImage($keyname, $max_width, $max_height) { // 一意なIDを取得する。 $mainname = uniqid('').'.'; // 拡張子以外を置き換える。 $newFileName = preg_replace("/^.*\./", $mainname, $_FILES[$keyname]['name']); - $result = $this->MakeThumb($_FILES[$keyname]['tmp_name'], $this->tmp_dir, $max_width, $max_height, $newFileName); + $result = $this->MakeThumb($_FILES[$keyname]['tmp_name'], $this->tmp_dir, $max_width, $max_height, $newFileName); GC_Utils_Ex::gfDebugLog($result); return $newFileName; } - //--- ファイルを指定保存DIRへ移動 + // --- ファイルを指定保存DIRへ移動 public function moveTempImage($filename, $save_dir) { // コピー元ファイル、コピー先ディレクトリが存在する場合にのみ実行する @@ -60,7 +60,7 @@ public function moveTempImage($filename, $save_dir) } } - //---- 指定ファイルを削除 + // ---- 指定ファイルを削除 public function deleteImage($filename, $dir) { if (file_exists($dir.'/'.$filename)) { @@ -73,9 +73,9 @@ public function deleteImage($filename, $dir) * * @param string $FromImgPath ファイル名までのパス * @param string $ToImgPath 出力先パス - * @param integer $tmpMW 最大横幅 - * @param integer $tmpMH 最大縦幅 - * @param integer $newFileName 新ファイル名 + * @param int $tmpMW 最大横幅 + * @param int $tmpMH 最大縦幅 + * @param int $newFileName 新ファイル名 * @param array 新ファイル名を格納した配列 */ public function MakeThumb($FromImgPath, $ToImgPath, $tmpMW, $tmpMH, $newFileName = '') @@ -86,33 +86,37 @@ public function MakeThumb($FromImgPath, $ToImgPath, $tmpMW, $tmpMH, $newFileName // 画像の最大縦幅(単位:ピクセル) $ThmMaxHeight = LARGE_IMAGE_HEIGHT; - //拡張子取得 + // 拡張子取得 $array_ext = explode('.', $FromImgPath); $ext = $array_ext[count($array_ext) - 1]; $MW = $ThmMaxWidth; - if ($tmpMW) $MW = $tmpMW; // $MWに最大横幅セット + if ($tmpMW) { + $MW = $tmpMW; + } // $MWに最大横幅セット $MH = $ThmMaxHeight; - if ($tmpMH) $MH = $tmpMH; // $MHに最大縦幅セット + if ($tmpMH) { + $MH = $tmpMH; + } // $MHに最大縦幅セット if (empty($FromImgPath) || empty($ToImgPath)) { - return array(0, '出力元画像パス、または出力先フォルダが指定されていません。'); + return [0, '出力元画像パス、または出力先フォルダが指定されていません。']; } if (!file_exists($FromImgPath)) { - return array(0, '出力元画像が見つかりません。'); + return [0, '出力元画像が見つかりません。']; } - $size = @GetImageSize($FromImgPath); + $size = @getimagesize($FromImgPath); $re_size = $size; // 画像の種類が不明 or swf if (!$size[2] || $size[2] > 3) { - return array(0, '画像形式がサポートされていません。'); + return [0, '画像形式がサポートされていません。']; } - //アスペクト比固定処理 + // アスペクト比固定処理 $tmp_w = $size[0] / $MW; $tmp_h = 0; if ($MH != 0) { @@ -145,53 +149,52 @@ public function MakeThumb($FromImgPath, $ToImgPath, $tmpMW, $tmpMH, $newFileName $ImgDefault = null; $RetVal = ''; switch ($size[2]) { - case '1': //gif形式 + case '1': // gif形式 if ($tmp_w <= 1 && $tmp_h <= 1) { if ($newFileName) { $ToFile = $newFileName; } elseif ($ext) { - $ToFile .= '.' . $ext; + $ToFile .= '.'.$ext; } else { $ToFile .= '.gif'; } if (!@copy($FromImgPath, $ToImgPath.$ToFile)) { // エラー処理 - - return array(0, 'ファイルのコピーに失敗しました。'); + return [0, 'ファイルのコピーに失敗しました。']; } - ImageDestroy($ImgNew); + imagedestroy($ImgNew); - return array(1, $ToFile); + return [1, $ToFile]; } - ImageColorAllocate($ImgNew, 255, 235, 214); //背景色 - $black = ImageColorAllocate($ImgNew, 0, 0, 0); - $red = ImageColorAllocate($ImgNew, 255, 0, 0); - Imagestring($ImgNew, 4, 5, 5, "GIF $size[0]x$size[1]", $red); - ImageRectangle($ImgNew, 0, 0, ($re_size[0]-1), ($re_size[1]-1), $black); + imagecolorallocate($ImgNew, 255, 235, 214); // 背景色 + $black = imagecolorallocate($ImgNew, 0, 0, 0); + $red = imagecolorallocate($ImgNew, 255, 0, 0); + imagestring($ImgNew, 4, 5, 5, "GIF $size[0]x$size[1]", $red); + imagerectangle($ImgNew, 0, 0, $re_size[0] - 1, $re_size[1] - 1, $black); if ($newFileName) { $ToFile = $newFileName; } elseif ($ext) { - $ToFile .= '.' . $ext; + $ToFile .= '.'.$ext; } else { $ToFile .= '.png'; } $TmpPath = $ToImgPath.$ToFile; - @Imagepng($ImgNew, $TmpPath); + @imagepng($ImgNew, $TmpPath); // 画像が作成されていない場合 if (!@file_exists($TmpPath)) { - return array(0, '画像の出力に失敗しました。'); + return [0, '画像の出力に失敗しました。']; } - ImageDestroy($ImgNew); + imagedestroy($ImgNew); - return array(1, $ToFile); + return [1, $ToFile]; - case '2': //jpg形式 - $ImgDefault = ImageCreateFromJpeg($FromImgPath); - //ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); + case '2': // jpg形式 + $ImgDefault = imagecreatefromjpeg($FromImgPath); + // ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); if ($re_size[0] != $size[0] || $re_size[0] != $size[0]) { - ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); + imagecopyresampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); } GC_Utils_Ex::gfDebugLog($size); @@ -200,46 +203,46 @@ public function MakeThumb($FromImgPath, $ToImgPath, $tmpMW, $tmpMH, $newFileName if ($newFileName) { $ToFile = $newFileName; } elseif ($ext) { - $ToFile .= '.' . $ext; + $ToFile .= '.'.$ext; } else { $ToFile .= '.jpg'; } $TmpPath = $ToImgPath.$ToFile; - @ImageJpeg($ImgNew, $TmpPath); + @imagejpeg($ImgNew, $TmpPath); // 画像が作成されていない場合 if (!@file_exists($TmpPath)) { - return array(0, "画像の出力に失敗しました。
${ImgNew}
${TmpPath}"); + return [0, "画像の出力に失敗しました。
{$ImgNew}
{$TmpPath}"]; } $RetVal = $ToFile; break; - case '3': //png形式 - $ImgDefault = ImageCreateFromPNG($FromImgPath); - //ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); - ImageCopyResampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); + case '3': // png形式 + $ImgDefault = imagecreatefrompng($FromImgPath); + // ImageCopyResized($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); + imagecopyresampled($ImgNew, $ImgDefault, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); if ($newFileName) { $ToFile = $newFileName; } elseif ($ext) { - $ToFile .= '.' . $ext; + $ToFile .= '.'.$ext; } else { $ToFile .= '.png'; } $TmpPath = $ToImgPath.$ToFile; - @ImagePNG($ImgNew, $TmpPath); + @imagepng($ImgNew, $TmpPath); // 画像が作成されていない場合 if (!@file_exists($TmpPath)) { - return array(0, '画像の出力に失敗しました。'); + return [0, '画像の出力に失敗しました。']; } $RetVal = $ToFile; break; } if (is_resource($ImgDefault)) { - ImageDestroy($ImgDefault); + imagedestroy($ImgDefault); } - ImageDestroy($ImgNew); + imagedestroy($ImgNew); - return array(1, $RetVal); + return [1, $RetVal]; } } diff --git a/data/class/SC_Initial.php b/data/class/SC_Initial.php index 202e6c3872..bc50ded1fc 100644 --- a/data/class/SC_Initial.php +++ b/data/class/SC_Initial.php @@ -25,6 +25,7 @@ * アプリケーションの初期設定クラス. * * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_Initial @@ -34,14 +35,13 @@ class SC_Initial */ public function __construct() { - /** EC-CUBEのバージョン */ + /* EC-CUBEのバージョン */ define('ECCUBE_VERSION', '2.17.2-p2'); } /** * 初期設定を行う. * - * @access protected * @return void */ public function init() @@ -63,45 +63,43 @@ public function init() /** * 初期設定ファイルを読み込み, パスの設定を行う. * - * @access protected * @return void */ public function requireInitialConfig() { - define('CONFIG_REALFILE', realpath(dirname(__FILE__)) . '/../config/config.php'); + define('CONFIG_REALFILE', realpath(__DIR__).'/../config/config.php'); if (file_exists(CONFIG_REALFILE)) { require_once CONFIG_REALFILE; - // heroku用 - } else if (getenv('DATABASE_URL')) { - ini_set( 'display_errors', 1 ); - copy(realpath(dirname(__FILE__)) . '/../../tests/config.php', CONFIG_REALFILE); + // heroku用 + } elseif (getenv('DATABASE_URL')) { + ini_set('display_errors', 1); + copy(realpath(__DIR__).'/../../tests/config.php', CONFIG_REALFILE); require_once CONFIG_REALFILE; - } else if (!GC_Utils_Ex::isInstallFunction()){ - + } elseif (!GC_Utils_Ex::isInstallFunction()) { // PHP8対応 - if (!defined("HTTP_URL")) { - define ('HTTP_URL', ''); - define ('HTTPS_URL', ''); - define ('ROOT_URLPATH', ''); - define ('DOMAIN_NAME', ''); - define ('DB_TYPE', ''); - define ('DB_USER', ''); - define ('DB_PASSWORD', ''); - define ('DB_SERVER', ''); - define ('DB_NAME', ''); - define ('DB_PORT', ''); - define ('ADMIN_DIR', ''); - define ('ADMIN_FORCE_SSL', ""); - define ('ADMIN_ALLOW_HOSTS', ''); - define ('AUTH_MAGIC', ''); - define ('PASSWORD_HASH_ALGOS', 'sha256'); - define ('MAIL_BACKEND', 'mail'); - define ('SMTP_HOST', ''); - define ('SMTP_PORT', ''); - define ('SMTP_USER', ''); - define ('SMTP_PASSWORD', ''); + if (!defined('HTTP_URL')) { + define('HTTP_URL', ''); + define('HTTPS_URL', ''); + define('ROOT_URLPATH', ''); + define('DOMAIN_NAME', ''); + define('DB_TYPE', ''); + define('DB_USER', ''); + define('DB_PASSWORD', ''); + define('DB_SERVER', ''); + define('DB_NAME', ''); + define('DB_PORT', ''); + define('ADMIN_DIR', ''); + define('ADMIN_FORCE_SSL', ''); + define('ADMIN_ALLOW_HOSTS', ''); + define('AUTH_MAGIC', ''); + define('PASSWORD_HASH_ALGOS', 'sha256'); + define('MAIL_BACKEND', 'mail'); + define('SMTP_HOST', ''); + define('SMTP_PORT', ''); + define('SMTP_USER', ''); + define('SMTP_PASSWORD', ''); } } } @@ -109,8 +107,8 @@ public function requireInitialConfig() /** * DSN を定義する. * - * @access protected * @return void + * * @deprecated 下位互換用 */ public function defineDSN() @@ -118,8 +116,8 @@ public function defineDSN() if (defined('DB_TYPE') && defined('DB_USER') && defined('DB_PASSWORD') && defined('DB_SERVER') && defined('DB_PORT') && defined('DB_NAME') ) { - $dsn = DB_TYPE . '://' . DB_USER . ':' . DB_PASSWORD . '@' . DB_SERVER . ':' . DB_PORT . '/' . DB_NAME; - /** サイト用DB */ + $dsn = DB_TYPE.'://'.DB_USER.':'.DB_PASSWORD.'@'.DB_SERVER.':'.DB_PORT.'/'.DB_NAME; + /* サイト用DB */ // ここで生成した DSN は使用せず, SC_Query のコンストラクタでパラメータを設定する. define('DEFAULT_DSN', $dsn); } @@ -138,7 +136,6 @@ public function setErrorReporting() * * TODO SJIS-win や, eucJP-win への対応 * - * @access protected * @return void */ public function phpconfigInit() @@ -163,9 +160,9 @@ public function phpconfigInit() ini_set('arg_separator.output', '&'); - //ロケールを明示的に設定 + // ロケールを明示的に設定 $res = setlocale(LC_ALL, LOCALE); - if ($res === FALSE) { + if ($res === false) { if ('\\' === DIRECTORY_SEPARATOR && PHP_VERSION_ID >= 70000) { // Windows 版 PHP7 以降の fgetcsv 関数は、日本語のロケールで // UTF-8 のファイルを正常にパースできないため、ロケールを英語に設定する @@ -180,13 +177,12 @@ public function phpconfigInit() } // #1849 (文字エンコーディングの検出を制御する) - mb_detect_order(array('UTF-8', 'SJIS-win', 'eucJP-win')); + mb_detect_order(['UTF-8', 'SJIS-win', 'eucJP-win']); } /** * 定数 DIR_INDEX_PATH を設定する. * - * @access protected * @return void */ public function defineDirectoryIndex() @@ -222,39 +218,38 @@ public function defineDirectoryIndex() * mtb_constants.php を読み込んで定数として定義する. * キャッシュディレクトリに存在しない場合は, 初期データからコピーする. * - * @access protected * @return void */ public function defineParameter() { $errorMessage = '
' - . CACHE_REALDIR - . ' にユーザ書込み権限(777等)を付与して下さい。
'; + .CACHE_REALDIR + .' にユーザ書込み権限(777等)を付与して下さい。'; // 定数を設定 - if (is_file(CACHE_REALDIR . 'mtb_constants.php')) { - require_once CACHE_REALDIR . 'mtb_constants.php'; + if (is_file(CACHE_REALDIR.'mtb_constants.php')) { + require_once CACHE_REALDIR.'mtb_constants.php'; - // キャッシュが無ければ, 初期データからコピー - } elseif (is_file(CACHE_REALDIR . '../mtb_constants_init.php')) { - $mtb_constants = file_get_contents(CACHE_REALDIR . '../mtb_constants_init.php'); + // キャッシュが無ければ, 初期データからコピー + } elseif (is_file(CACHE_REALDIR.'../mtb_constants_init.php')) { + $mtb_constants = file_get_contents(CACHE_REALDIR.'../mtb_constants_init.php'); if (is_writable(CACHE_REALDIR)) { - $handle = fopen(CACHE_REALDIR . 'mtb_constants.php', 'w'); + $handle = fopen(CACHE_REALDIR.'mtb_constants.php', 'w'); if (!$handle) { - die($errorMessage); + exit($errorMessage); } if (fwrite($handle, $mtb_constants) === false) { - die($errorMessage); + exit($errorMessage); } fclose($handle); - require_once CACHE_REALDIR . 'mtb_constants.php'; + require_once CACHE_REALDIR.'mtb_constants.php'; } else { - die($errorMessage); + exit($errorMessage); } } else { - die(CACHE_REALDIR . '../mtb_constants_init.php が存在しません'); + exit(CACHE_REALDIR.'../mtb_constants_init.php が存在しません'); } } @@ -264,23 +259,22 @@ public function defineParameter() * ソースのみ差し替えたバージョンアップを考慮したもの。 * SC_Initial_Ex::defineIfNotDefined() で定義することを想定 * - * @access protected * @return void */ public function complementParameter() { // 2.13.0 のデータとの互換用 - /** サイトトップ */ - SC_Initial_Ex::defineIfNotDefined('TOP_URL', HTTP_URL . DIR_INDEX_PATH); - /** カートトップ */ - SC_Initial_Ex::defineIfNotDefined('CART_URL', HTTP_URL . 'cart/' . DIR_INDEX_PATH); + /* サイトトップ */ + SC_Initial_Ex::defineIfNotDefined('TOP_URL', HTTP_URL.DIR_INDEX_PATH); + /* カートトップ */ + SC_Initial_Ex::defineIfNotDefined('CART_URL', HTTP_URL.'cart/'.DIR_INDEX_PATH); // 2.13.0 のテンプレートとの互換用 // @deprecated 2.13.1 - /** サイトトップ */ - SC_Initial_Ex::defineIfNotDefined('TOP_URLPATH', ROOT_URLPATH . DIR_INDEX_PATH); - /** カートトップ */ - SC_Initial_Ex::defineIfNotDefined('CART_URLPATH', ROOT_URLPATH . 'cart/' . DIR_INDEX_PATH); + /* サイトトップ */ + SC_Initial_Ex::defineIfNotDefined('TOP_URLPATH', ROOT_URLPATH.DIR_INDEX_PATH); + /* カートトップ */ + SC_Initial_Ex::defineIfNotDefined('CART_URLPATH', ROOT_URLPATH.'cart/'.DIR_INDEX_PATH); } /** @@ -288,7 +282,6 @@ public function complementParameter() * * Smarty キャッシュディレクトリを生成する. * - * @access protected * @return void */ public function createCacheDir() @@ -316,163 +309,162 @@ public function createCacheDir() /** * 定数定義 * - * @access protected * @return void */ public function defineConstants() { // LC_Page_Error用 - /** 指定商品ページがない */ + /* 指定商品ページがない */ define('PRODUCT_NOT_FOUND', 1); - /** カート内が空 */ + /* カート内が空 */ define('CART_EMPTY', 2); - /** ページ推移エラー */ + /* ページ推移エラー */ define('PAGE_ERROR', 3); - /** 購入処理中のカート商品追加エラー */ + /* 購入処理中のカート商品追加エラー */ define('CART_ADD_ERROR', 4); - /** 他にも購入手続きが行われた場合 */ + /* 他にも購入手続きが行われた場合 */ define('CANCEL_PURCHASE', 5); - /** 指定カテゴリページがない */ + /* 指定カテゴリページがない */ define('CATEGORY_NOT_FOUND', 6); - /** ログインに失敗 */ + /* ログインに失敗 */ define('SITE_LOGIN_ERROR', 7); - /** 会員専用ページへのアクセスエラー */ + /* 会員専用ページへのアクセスエラー */ define('CUSTOMER_ERROR', 8); - /** 購入時の売り切れエラー */ + /* 購入時の売り切れエラー */ define('SOLD_OUT', 9); - /** カート内商品の読込エラー */ + /* カート内商品の読込エラー */ define('CART_NOT_FOUND', 10); - /** ポイントの不足 */ + /* ポイントの不足 */ define('LACK_POINT', 11); - /** 仮登録者がログインに失敗 */ + /* 仮登録者がログインに失敗 */ define('TEMP_LOGIN_ERROR', 12); - /** URLエラー */ + /* URLエラー */ define('URL_ERROR', 13); - /** ファイル解凍エラー */ + /* ファイル解凍エラー */ define('EXTRACT_ERROR', 14); - /** FTPダウンロードエラー */ + /* FTPダウンロードエラー */ define('FTP_DOWNLOAD_ERROR', 15); - /** FTPログインエラー */ + /* FTPログインエラー */ define('FTP_LOGIN_ERROR', 16); - /** FTP接続エラー */ + /* FTP接続エラー */ define('FTP_CONNECT_ERROR', 17); - /** DB作成エラー */ + /* DB作成エラー */ define('CREATE_DB_ERROR', 18); - /** DBインポートエラー */ + /* DBインポートエラー */ define('DB_IMPORT_ERROR', 19); - /** 設定ファイル存在エラー */ + /* 設定ファイル存在エラー */ define('FILE_NOT_FOUND', 20); - /** 書き込みエラー */ + /* 書き込みエラー */ define('WRITE_FILE_ERROR', 21); - /** ダウンロードファイル存在エラー */ + /* ダウンロードファイル存在エラー */ define('DOWNFILE_NOT_FOUND', 22); - /** フリーメッセージ */ + /* フリーメッセージ */ define('FREE_ERROR_MSG', 999); // LC_Page_Error_DispError用 - /** ログイン失敗 */ + /* ログイン失敗 */ define('LOGIN_ERROR', 1); - /** アクセス失敗(タイムアウト等) */ + /* アクセス失敗(タイムアウト等) */ define('ACCESS_ERROR', 2); - /** アクセス権限違反 */ + /* アクセス権限違反 */ define('AUTH_ERROR', 3); - /** 不正な遷移エラー */ + /* 不正な遷移エラー */ define('INVALID_MOVE_ERRORR', 4); // オーナーズストア通信関連 - /** オーナーズストア通信ステータス */ + /* オーナーズストア通信ステータス */ define('OSTORE_STATUS_ERROR', 'ERROR'); - /** オーナーズストア通信ステータス */ + /* オーナーズストア通信ステータス */ define('OSTORE_STATUS_SUCCESS', 'SUCCESS'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_UNKNOWN', '1000'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_INVALID_PARAM', '1001'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_NO_CUSTOMER', '1002'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_WRONG_URL_PASS', '1003'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_NO_PRODUCTS', '1004'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_NO_DL_DATA', '1005'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_DL_DATA_OPEN', '1006'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_DLLOG_AUTH', '1007'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_ADMIN_AUTH', '2001'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_HTTP_REQ', '2002'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_HTTP_RESP', '2003'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_FAILED_JSON_PARSE', '2004'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_NO_KEY', '2005'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_INVALID_ACCESS', '2006'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_INVALID_PARAM', '2007'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_AUTOUP_DISABLE', '2008'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_PERMISSION', '2009'); - /** オーナーズストア通信エラーコード */ + /* オーナーズストア通信エラーコード */ define('OSTORE_E_C_BATCH_ERR', '2010'); // プラグイン関連 - /** プラグインの状態:アップロード済み */ + /* プラグインの状態:アップロード済み */ define('PLUGIN_STATUS_UPLOADED', '1'); - /** プラグインの状態:インストール済み */ + /* プラグインの状態:インストール済み */ define('PLUGIN_STATUS_INSTALLED', '2'); - /** プラグイン有効/無効:有効 */ + /* プラグイン有効/無効:有効 */ define('PLUGIN_ENABLE_TRUE', '1'); - /** プラグイン有効/無効:無効 */ + /* プラグイン有効/無効:無効 */ define('PLUGIN_ENABLE_FALSE', '2'); // CSV入出力関連 - /** CSV入出力列設定有効無効フラグ: 有効 */ + /* CSV入出力列設定有効無効フラグ: 有効 */ define('CSV_COLUMN_STATUS_FLG_ENABLE', 1); - /** CSV入出力列設定有効無効フラグ: 無効 */ + /* CSV入出力列設定有効無効フラグ: 無効 */ define('CSV_COLUMN_STATUS_FLG_DISABLE', 2); - /** CSV入出力列設定読み書きフラグ: 読み書き可能 */ + /* CSV入出力列設定読み書きフラグ: 読み書き可能 */ define('CSV_COLUMN_RW_FLG_READ_WRITE', 1); - /** CSV入出力列設定読み書きフラグ: 読み込みのみ可能 */ + /* CSV入出力列設定読み書きフラグ: 読み込みのみ可能 */ define('CSV_COLUMN_RW_FLG_READ_ONLY', 2); - /** CSV入出力列設定読み書きフラグ: キー列 */ + /* CSV入出力列設定読み書きフラグ: キー列 */ define('CSV_COLUMN_RW_FLG_KEY_FIELD', 3); // 配置ID - /** 配置ID: 未使用 */ + /* 配置ID: 未使用 */ define('TARGET_ID_UNUSED', 0); - /** 配置ID: LeftNavi */ + /* 配置ID: LeftNavi */ define('TARGET_ID_LEFT', 1); - /** 配置ID: MainHead */ + /* 配置ID: MainHead */ define('TARGET_ID_MAIN_HEAD', 2); - /** 配置ID: RightNavi */ + /* 配置ID: RightNavi */ define('TARGET_ID_RIGHT', 3); - /** 配置ID: MainFoot */ + /* 配置ID: MainFoot */ define('TARGET_ID_MAIN_FOOT', 4); - /** 配置ID: TopNavi */ + /* 配置ID: TopNavi */ define('TARGET_ID_TOP', 5); - /** 配置ID: BottomNavi */ + /* 配置ID: BottomNavi */ define('TARGET_ID_BOTTOM', 6); - /** 配置ID: HeadNavi */ + /* 配置ID: HeadNavi */ define('TARGET_ID_HEAD', 7); - /** 配置ID: HeadTopNavi */ + /* 配置ID: HeadTopNavi */ define('TARGET_ID_HEAD_TOP', 8); - /** 配置ID: FooterBottomNavi */ + /* 配置ID: FooterBottomNavi */ define('TARGET_ID_FOOTER_BOTTOM', 9); - /** 配置ID: HeaderInternalNavi */ + /* 配置ID: HeaderInternalNavi */ define('TARGET_ID_HEADER_INTERNAL', 10); // 他 - /** アクセス成功 */ + /* アクセス成功 */ define('SUCCESS', 0); - /** 無制限フラグ: 無制限 */ + /* 無制限フラグ: 無制限 */ define('UNLIMITED_FLG_UNLIMITED', '1'); - /** 無制限フラグ: 制限有り */ + /* 無制限フラグ: 制限有り */ define('UNLIMITED_FLG_LIMITED', '0'); } @@ -481,7 +473,6 @@ public function defineConstants() * * variables_order ディレクティブによる差を吸収する。 * - * @access protected * @return void */ public function resetSuperglobalsRequest() @@ -494,6 +485,7 @@ public function resetSuperglobalsRequest() * * @param string $name 定数の名前。 * @param string $value 定数の値。 + * * @return void */ public static function defineIfNotDefined($name, $value = null) @@ -548,9 +540,9 @@ public function normalizeHostname() $correct_url = $netUrlRequest->getUrl(); // 警告 $msg = 'ホスト名不一致を検出。リダイレクト実行。'; - $msg .= '要求値=' . var_export($request_hostname, true) . ' '; - $msg .= '設定値=' . var_export($correct_hostname, true) . ' '; - $msg .= 'リダイレクト先=' . var_export($correct_url, true) . ' '; + $msg .= '要求値='.var_export($request_hostname, true).' '; + $msg .= '設定値='.var_export($correct_hostname, true).' '; + $msg .= 'リダイレクト先='.var_export($correct_url, true).' '; trigger_error($msg, E_USER_WARNING); // リダイレクト(恒久的) SC_Response_Ex::sendHttpStatus(301); @@ -562,9 +554,10 @@ public function normalizeHostname() * PHPバージョン互換処理 * * @deprecated https://github.com/EC-CUBE/ec-cube2/issues/681 が実現したら、外部ライブラリへ移行して、削除する予定。 + * * @return void */ - function compatPhp() + public function compatPhp() { if (!function_exists('str_starts_with')) { /** @@ -572,9 +565,11 @@ function compatPhp() * * @param string $haystack * @param string $needle + * * @return bool */ - function str_starts_with($haystack, $needle) { + function str_starts_with($haystack, $needle) + { return strncmp($haystack, $needle, strlen($needle)) === 0; } } @@ -585,12 +580,14 @@ function str_starts_with($haystack, $needle) { * * @param string $haystack * @param string $needle + * * @return bool */ - function str_ends_with($haystack, $needle) { + function str_ends_with($haystack, $needle) + { $needle_len = strlen($needle); - return substr($haystack, - $needle_len, $needle_len) === $needle; + return substr($haystack, -$needle_len, $needle_len) === $needle; } } } diff --git a/data/class/SC_MobileEmoji.php b/data/class/SC_MobileEmoji.php index 86533174a8..8c2d6df28e 100644 --- a/data/class/SC_MobileEmoji.php +++ b/data/class/SC_MobileEmoji.php @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** +/* * 表示できない絵文字を置き換える文字列 (Shift JIS) * デフォルトは空文字列。 */ @@ -29,6 +29,7 @@ /** * 携帯端末の絵文字を扱うクラス + * * @deprecated */ class SC_MobileEmoji @@ -38,6 +39,7 @@ class SC_MobileEmoji * output buffering 用コールバック関数 * * @param string 入力 + * * @return string 出力 */ public static function handler($buffer) @@ -51,6 +53,7 @@ public static function handler($buffer) * 絵文字番号を絵文字を表す Shift JIS の文字列に変換する。 * * @param string $index 絵文字番号 + * * @return string 絵文字を表す Shift JIS の文字列を返す。 */ public function indexToCode($index) @@ -60,9 +63,9 @@ public function indexToCode($index) return MOBILE_EMOJI_SUBSTITUTE; } - static $arrMap = array(); + static $arrMap = []; if (empty($arrMap)) { - $arrMap = @include_once dirname(__FILE__) . "/../include/mobile_emoji_map_$carrier.inc"; + $arrMap = @include_once __DIR__."/../include/mobile_emoji_map_$carrier.inc"; } return isset($arrMap[$index]) ? $arrMap[$index] : MOBILE_EMOJI_SUBSTITUTE; diff --git a/data/class/SC_MobileImage.php b/data/class/SC_MobileImage.php index 406432abca..2f0e65ab1c 100644 --- a/data/class/SC_MobileImage.php +++ b/data/class/SC_MobileImage.php @@ -23,11 +23,12 @@ * 端末の画面解像度にあわせて画像を変換する */ -define('MOBILE_IMAGE_INC_REALDIR', realpath(dirname(__FILE__)) . '/../include/'); -require_once MOBILE_IMAGE_INC_REALDIR . 'image_converter.inc'; +define('MOBILE_IMAGE_INC_REALDIR', realpath(__DIR__).'/../include/'); +require_once MOBILE_IMAGE_INC_REALDIR.'image_converter.inc'; /** * 画像変換クラス + * * @deprecated */ class SC_MobileImage @@ -37,34 +38,35 @@ class SC_MobileImage * output buffering 用コールバック関数 * * @param string 入力 + * * @return string 出力 */ public static function handler($buffer) { // 端末情報を取得する $carrier = SC_MobileUserAgent_Ex::getCarrier(); - $model = SC_MobileUserAgent_Ex::getModel(); + $model = SC_MobileUserAgent_Ex::getModel(); // 携帯電話の場合のみ処理を行う - if ($carrier !== FALSE) { + if ($carrier !== false) { // HTML中のIMGタグを取得する - $images = array(); + $images = []; $pattern = '/]*src=[\'"]?([^>"\'\s]+)[\'"]?[^>]*>/i'; $result = preg_match_all($pattern, $buffer, $images); // 端末の情報を取得する - $fp = fopen(MOBILE_IMAGE_INC_REALDIR . "mobile_image_map_$carrier.csv", 'r'); + $fp = fopen(MOBILE_IMAGE_INC_REALDIR."mobile_image_map_$carrier.csv", 'r'); // 取得できない場合は, 入力内容をそのまま返す if ($fp === false) { return $buffer; } - while (($data = fgetcsv($fp, 1000, ',')) !== FALSE) { + while (($data = fgetcsv($fp, 1000, ',')) !== false) { if ($data[1] == $model || $data[1] == '*') { - $cacheSize = $data[2]; + $cacheSize = $data[2]; $imageFileSize = $data[7]; - $imageType = $data[6]; - $imageWidth = $data[5]; - $imageHeight = $data[4]; + $imageType = $data[6]; + $imageWidth = $data[5]; + $imageHeight = $data[4]; break; } } @@ -72,7 +74,7 @@ public static function handler($buffer) // docomoとsoftbankの場合は画像ファイル一つに利用可能なサイズの上限を計算する // auはHTMLのbyte数上限に画像ファイルサイズが含まれないのでimageFileSizeのまま。 - if ($carrier == 'docomo' or $carrier == 'softbank') { + if ($carrier == 'docomo' || $carrier == 'softbank') { if ($result != false && $result > 0) { // 計算式:(利用端末で表示可能なcacheサイズ - HTMLのバイト数 - 変換後の画像名のバイト数(目安値)) / HTML中の画像数 $temp_imagefilesize = ($cacheSize - strlen($buffer) - (140 * $result)) / $result; @@ -87,7 +89,7 @@ public static function handler($buffer) } // 画像変換の情報をセットする - $imageConverter = New ImageConverter(); + $imageConverter = new ImageConverter(); $imageConverter->setOutputDir(MOBILE_IMAGE_REALDIR); $imageConverter->setImageType($imageType); $imageConverter->setImageWidth($imageWidth); @@ -97,7 +99,7 @@ public static function handler($buffer) // HTML中のIMGタグを変換後のファイルパスに置換する foreach ($images[1] as $key => $path) { // resize_image.phpは除外 - if (stripos($path, ROOT_URLPATH . 'resize_image.php') !== FALSE) { + if (stripos($path, ROOT_URLPATH.'resize_image.php') !== false) { continue; } @@ -105,7 +107,7 @@ public static function handler($buffer) $realpath = substr_replace($realpath, HTML_REALDIR, 0, strlen(ROOT_URLPATH)); $converted = $imageConverter->execute($realpath); if (isset($converted['outputImageName'])) { - $buffer = str_replace($path, MOBILE_IMAGE_URLPATH . $converted['outputImageName'], $buffer); + $buffer = str_replace($path, MOBILE_IMAGE_URLPATH.$converted['outputImageName'], $buffer); } else { $buffer = str_replace($images[0][$key], '', $buffer); } diff --git a/data/class/SC_MobileUserAgent.php b/data/class/SC_MobileUserAgent.php index f396885b27..b5e0b57bd5 100644 --- a/data/class/SC_MobileUserAgent.php +++ b/data/class/SC_MobileUserAgent.php @@ -26,6 +26,7 @@ * * 対象とする携帯端末は $_SERVER から決定する。 * 全てのメソッドはクラスメソッド。 + * * @deprecated */ class SC_MobileUserAgent @@ -37,11 +38,13 @@ class SC_MobileUserAgent * * @return string|false 携帯端末のキャリアを表す文字列を返す。 * 携帯端末ではない場合は false を返す。 + * * @deprecated */ public static function getCarrier() { - trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + @trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + return false; } @@ -54,11 +57,13 @@ public static function getCarrier() * + softbank ... 端末シリアル番号 * * @deprecated + * * @return string|false 取得したIDを返す。取得できなかった場合は false を返す。 */ public static function getId() { - trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + @trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + return false; } @@ -70,7 +75,8 @@ public static function getId() */ public static function getModel() { - trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + @trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + return false; } @@ -84,11 +90,12 @@ public static function getModel() * - EzWeb で WAP2 以外の端末 * - DoCoMo 501i, 502i, 209i, 210i, SH821i, N821i, P821i, P651ps, R691i, F671i, SH251i, SH251iS * - * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 + * @return bool サポートしている場合は true、それ以外の場合は false を返す。 */ public static function isSupported() { - trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + @trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + return false; } @@ -97,11 +104,12 @@ public static function isSupported() * * ※一部モジュールで使用。ただし、本メソッドは将来的に削除しますので新規ご利用は控えてください。 * - * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 + * @return bool サポートしている場合は true、それ以外の場合は false を返す。 */ public function isMobile() { - trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + @trigger_error('Net_UserAgent_Mobile is deprecated', E_USER_DEPRECATED); + return false; } } diff --git a/data/class/SC_PageNavi.php b/data/class/SC_PageNavi.php index d0d9e2febc..8350ad95f2 100644 --- a/data/class/SC_PageNavi.php +++ b/data/class/SC_PageNavi.php @@ -45,8 +45,9 @@ class SC_PageNavi public $max_page; // 最終のページ番号 public $start_row; // 開始レコード public $strnavi; // ページ送り文字列 - public $arrPagenavi = array(); // ページ + public $arrPagenavi = []; // ページ public $all_row; + /** * コンストラクタ * @@ -56,8 +57,8 @@ public function __construct($now_page, $all_row, $page_row, $func_name, $navi_ma { $this->arrPagenavi['mode'] = 'search'; - //現在ページ($now_page)が正しい数値でない場合 - if (!preg_match("/^[[:digit:]]+$/", $now_page) || $now_page < 1 || strlen($now_page) == 0) { + // 現在ページ($now_page)が正しい数値でない場合 + if (!preg_match('/^[[:digit:]]+$/', $now_page) || $now_page < 1 || strlen($now_page) == 0) { $this->now_page = 1; } else { $this->now_page = htmlspecialchars($now_page, ENT_QUOTES, CHAR_CODE); @@ -65,15 +66,15 @@ public function __construct($now_page, $all_row, $page_row, $func_name, $navi_ma $this->arrPagenavi['now_page'] = $this->now_page; // 最終ページの計算 - $this->max_page = ceil($all_row/$page_row); + $this->max_page = ceil($all_row / $page_row); // 最終ページよりも現在ページが大きい場合は、最初に戻す。 if ($this->max_page < $this->now_page) { $this->now_page = 1; } - $this->start_row = ($this->now_page - 1) * $page_row; - $this->all_row = $all_row; + $this->start_row = ($this->now_page - 1) * $page_row; + $this->all_row = $all_row; // 開始行が不正な場合 if (!($this->start_row < $all_row && $this->start_row >= 0)) { @@ -81,7 +82,7 @@ public function __construct($now_page, $all_row, $page_row, $func_name, $navi_ma } if ($all_row > 1) { - //「前へ」「次へ」の設定 + // 「前へ」「次へ」の設定 $before = ''; $next = ''; if ($this->now_page > 1) { @@ -124,7 +125,7 @@ public function __construct($now_page, $all_row, $page_row, $func_name, $navi_ma $disp_min = $this->now_page - $navi_max + 1; } - $this->arrPagenavi['arrPageno'] = array(); + $this->arrPagenavi['arrPageno'] = []; $page_number = ''; for ($i = $disp_min; $i <= $disp_max; $i++) { if ($i == $this->now_page) { @@ -141,9 +142,9 @@ public function __construct($now_page, $all_row, $page_row, $func_name, $navi_ma } if ($before && $next) { - $this->strnavi = $before .(($display_number) ? $page_number : ' | ') .$next; + $this->strnavi = $before.(($display_number) ? $page_number : ' | ').$next; } elseif ($before || $next) { - $this->strnavi = $before .(($display_number) ? $page_number : '') .$next; + $this->strnavi = $before.(($display_number) ? $page_number : '').$next; } } else { $this->arrPagenavi['arrPageno'][0] = 1; diff --git a/data/class/SC_Product.php b/data/class/SC_Product.php index 9b99d0beb9..1b48868562 100644 --- a/data/class/SC_Product.php +++ b/data/class/SC_Product.php @@ -26,6 +26,7 @@ * * @author EC-CUBE CO.,LTD. * @author Kentaro Ohkouchi + * * @version $Id$ */ class SC_Product @@ -35,7 +36,7 @@ class SC_Product /** 規格分類名一覧 */ public $arrClassCatName; /** このプロパティが保持する price01 及び price02 は、税金付与した金額である。 */ - public $classCategories = array(); + public $classCategories = []; public $stock_find; /** 規格1クラス名 */ public $className1 = []; @@ -61,11 +62,12 @@ class SC_Product * @param string $col 並び替えの基準とするフィールド * @param string $table 並び替えの基準とするフィールドがあるテーブル * @param string $order 並び替えの順序 ASC / DESC + * * @return void */ public function setProductsOrder($col, $table = 'dtb_products', $order = 'ASC') { - $this->arrOrderData = array('col' => $col, 'table' => $table, 'order' => $order); + $this->arrOrderData = ['col' => $col, 'table' => $table, 'order' => $order]; } /** @@ -75,13 +77,14 @@ public function setProductsOrder($col, $table = 'dtb_products', $order = 'ASC') * * @param SC_Query $objQuery SC_Query インスタンス * @param array $arrVal 検索パラメーターの配列 + * * @return array 商品IDの配列 */ - public function findProductIdsOrder(&$objQuery, $arrVal = array()) + public function findProductIdsOrder(&$objQuery, $arrVal = []) { $table = 'dtb_products AS alldtl'; - if (is_array($this->arrOrderData) and $objQuery->order == '') { + if (is_array($this->arrOrderData) && $objQuery->order == '') { $o_col = $this->arrOrderData['col']; $o_table = $this->arrOrderData['table']; $o_order = $this->arrOrderData['order']; @@ -103,9 +106,10 @@ public function findProductIdsOrder(&$objQuery, $arrVal = array()) * * @param SC_Query $objQuery SC_Query インスタンス * @param array $arrVal 検索パラメーターの配列 - * @return integer 対象商品ID数 + * + * @return int 対象商品ID数 */ - public function findProductCount(&$objQuery, $arrVal = array()) + public function findProductCount(&$objQuery, $arrVal = []) { $table = 'dtb_products AS alldtl'; @@ -121,9 +125,10 @@ public function findProductCount(&$objQuery, $arrVal = array()) * * @param SC_Query $objQuery SC_Query インスタンス * @param array $product_ids 商品IDの配列 + * * @return array 商品一覧の配列 */ - public function lists(&$objQuery, $product_ids = array()) + public function lists(&$objQuery, $product_ids = []) { $col = <<< __EOS__ product_id @@ -163,15 +168,16 @@ public function lists(&$objQuery, $product_ids = array()) * * @param SC_Query $objQuery SC_Query インスタンス * @param array $arrProductId 商品ID + * * @return array 商品一覧の配列 (キー: 商品ID) */ - public function getListByProductIds(&$objQuery, $arrProductId = array()) + public function getListByProductIds(&$objQuery, $arrProductId = []) { if (empty($arrProductId)) { - return array(); + return []; } - $where = 'alldtl.product_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($arrProductId)) . ')'; + $where = 'alldtl.product_id IN ('.SC_Utils_Ex::repeatStrWithSeparator('?', count($arrProductId)).')'; $where .= ' AND alldtl.del_flg = 0'; $objQuery->setWhere( @@ -187,11 +193,11 @@ public function getListByProductIds(&$objQuery, $arrProductId = array()) // SC_Query::setOrder() の指定がない場合、$arrProductId で指定された商品IDの順に配列要素を並び替え if (strlen($objQuery->order) === 0) { - $arrTmp = array(); + $arrTmp = []; foreach ($arrProductId as $product_id) { $arrTmp[$product_id] = $arrProducts[$product_id]; } - $arrProducts =& $arrTmp; + $arrProducts = &$arrTmp; unset($arrTmp); } @@ -204,19 +210,20 @@ public function getListByProductIds(&$objQuery, $arrProductId = array()) /** * 商品詳細を取得する. * - * @param integer $product_id 商品ID + * @param int $product_id 商品ID + * * @return array 商品詳細情報の配列 */ public function getDetail($product_id) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $from = static::alldtlSQL('', array($product_id)); + $from = static::alldtlSQL('', [$product_id]); $where = 'product_id = ?'; // SC_DB_DBFactory::alldtlSQL() で生成される追加条件のため // product_id の配列を生成ておく - $arrWhereVal = array($product_id, $product_id, $product_id); - $arrProduct = (array)$objQuery->getRow('*', $from, $where, $arrWhereVal); + $arrWhereVal = [$product_id, $product_id, $product_id]; + $arrProduct = (array) $objQuery->getRow('*', $from, $where, $arrWhereVal); // 税込金額を設定する SC_Product_Ex::setIncTaxToProduct($arrProduct); @@ -227,7 +234,8 @@ public function getDetail($product_id) /** * 商品詳細情報と商品規格を取得する. * - * @param integer $productClassId 商品規格ID + * @param int $productClassId 商品規格ID + * * @return array 商品詳細情報と商品規格の配列 */ public function getDetailAndProductsClass($productClassId) @@ -245,7 +253,8 @@ public function getDetailAndProductsClass($productClassId) * 設定する. * * @param array $arrProductId 商品ID の配列 - * @param boolean $has_deleted 削除された商品規格も含む場合 true; 初期値 false + * @param bool $has_deleted 削除された商品規格も含む場合 true; 初期値 false + * * @return void */ public function setProductsClassByProductIds($arrProductId, $has_deleted = false) @@ -253,7 +262,7 @@ public function setProductsClassByProductIds($arrProductId, $has_deleted = false foreach ($arrProductId as $productId) { $arrProductClasses = $this->getProductsClassFullByProductId($productId, $has_deleted); - $classCats1 = array(); + $classCats1 = []; $classCats1['__unselected'] = '選択してください'; // 規格1クラス名 @@ -274,7 +283,7 @@ public function setProductsClassByProductIds($arrProductId, $has_deleted = false $this->classCat2_find[$productId] = $arrProductClasses[0]['classcategory_id2'] > 0; // 要変更ただし、他にも改修が必要となる $this->stock_find[$productId] = false; - $classCategories = array(); + $classCategories = []; $classCategories['__unselected']['__unselected']['name'] = '選択してください'; $classCategories['__unselected']['__unselected']['product_class_id'] = $arrProductClasses[0]['product_class_id']; // 商品種別 @@ -283,14 +292,14 @@ public function setProductsClassByProductIds($arrProductId, $has_deleted = false // 商品種別 $this->product_type[$productId] = $arrProductClasses[0]['product_type_id']; foreach ($arrProductClasses as $arrProductsClass) { - $arrClassCats2 = array(); + $arrClassCats2 = []; $classcategory_id1 = $arrProductsClass['classcategory_id1']; $classcategory_id2 = $arrProductsClass['classcategory_id2']; // 在庫 $stock_find_class = ($arrProductsClass['stock_unlimited'] || $arrProductsClass['stock'] > 0); $arrClassCats2['classcategory_id2'] = $classcategory_id2; - $arrClassCats2['name'] = $arrProductsClass['classcategory_name2'] . ($stock_find_class ? '' : ' (品切れ中)'); + $arrClassCats2['name'] = $arrProductsClass['classcategory_name2'].($stock_find_class ? '' : ' (品切れ中)'); $arrClassCats2['stock_find'] = $stock_find_class; @@ -300,7 +309,7 @@ public function setProductsClassByProductIds($arrProductId, $has_deleted = false if (!in_array($classcategory_id1, array_keys($classCats1))) { $classCats1[$classcategory_id1] = $arrProductsClass['classcategory_name1'] - . ($classcategory_id2 == 0 && !$stock_find_class ? ' (品切れ中)' : ''); + .($classcategory_id2 == 0 && !$stock_find_class ? ' (品切れ中)' : ''); } // 価格 @@ -330,11 +339,11 @@ public function setProductsClassByProductIds($arrProductId, $has_deleted = false if (!$this->classCat1_find[$productId]) { $classcategory_id1 = '__unselected2'; } - $classCategories[$classcategory_id1]['#'] = array( + $classCategories[$classcategory_id1]['#'] = [ 'classcategory_id2' => '', 'name' => '選択してください', - ); - $classCategories[$classcategory_id1]['#' . $classcategory_id2] = $arrClassCats2; + ]; + $classCategories[$classcategory_id1]['#'.$classcategory_id2] = $arrClassCats2; } $this->classCategories[$productId] = $classCategories; @@ -349,6 +358,7 @@ public function setProductsClassByProductIds($arrProductId, $has_deleted = false * * @param SC_Query $objQuery SC_Queryインスタンス * @param array $params 検索パラメーターの配列 + * * @return array 商品規格の配列 */ public function getProductsClassByQuery(&$objQuery, $params) @@ -403,7 +413,8 @@ public function getProductsClassByQuery(&$objQuery, $params) * * 削除された商品規格は取得しない. * - * @param integer $productClassId 商品規格ID + * @param int $productClassId 商品規格ID + * * @return array 商品規格の配列 */ public function getProductsClass($productClassId) @@ -429,16 +440,17 @@ public function getProductsClass($productClassId) * 複数の商品IDに紐づいた, 商品規格を取得する. * * @param array $productIds 商品IDの配列 - * @param boolean $has_deleted 削除された商品規格も含む場合 true; 初期値 false + * @param bool $has_deleted 削除された商品規格も含む場合 true; 初期値 false + * * @return array 商品規格の配列 */ - public function getProductsClassByProductIds($productIds = array(), $has_deleted = false) + public function getProductsClassByProductIds($productIds = [], $has_deleted = false) { if (empty($productIds)) { - return array(); + return []; } $objQuery = SC_Query_Ex::getSingletonInstance(); - $where = 'product_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($productIds)) . ')'; + $where = 'product_id IN ('.SC_Utils_Ex::repeatStrWithSeparator('?', count($productIds)).')'; if (!$has_deleted) { $where .= ' AND T1.del_flg = 0'; } @@ -451,12 +463,13 @@ public function getProductsClassByProductIds($productIds = array(), $has_deleted * 商品IDに紐づいた, 商品規格を全ての組み合わせごとに取得する. * * @param array $productId 商品ID - * @param boolean $has_deleted 削除された商品規格も含む場合 true; 初期値 false + * @param bool $has_deleted 削除された商品規格も含む場合 true; 初期値 false + * * @return array 全ての組み合わせの商品規格の配列 */ public function getProductsClassFullByProductId($productId, $has_deleted = false) { - $arrRet = $this->getProductsClassByProductIds(array($productId), $has_deleted); + $arrRet = $this->getProductsClassByProductIds([$productId], $has_deleted); return $arrRet; } @@ -465,19 +478,20 @@ public function getProductsClassFullByProductId($productId, $has_deleted = false * 商品IDをキーにした, 商品ステータスIDの配列を取得する. * * @param array 商品ID の配列 + * * @return array 商品IDをキーにした商品ステータスIDの配列 */ public function getProductStatus($productIds) { if (empty($productIds)) { - return array(); + return []; } $objQuery = SC_Query_Ex::getSingletonInstance(); $cols = 'product_id, product_status_id'; $from = 'dtb_product_status'; - $where = 'del_flg = 0 AND product_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($productIds)) . ')'; + $where = 'del_flg = 0 AND product_id IN ('.SC_Utils_Ex::repeatStrWithSeparator('?', count($productIds)).')'; $productStatus = $objQuery->select($cols, $from, $where, $productIds); - $results = array(); + $results = []; foreach ($productStatus as $status) { $results[$status['product_id']][] = $status['product_status_id']; } @@ -490,7 +504,7 @@ public function getProductStatus($productIds) * * TODO 現在は DELETE/INSERT だが, UPDATE を検討する. * - * @param integer $productId 商品ID + * @param int $productId 商品ID * @param array $productStatusIds ON にする商品ステータスIDの配列 */ public function setProductStatus($productId, $productStatusIds) @@ -502,9 +516,11 @@ public function setProductStatus($productId, $productStatusIds) $val['del_flg'] = '0'; $objQuery = SC_Query_Ex::getSingletonInstance(); - $objQuery->delete('dtb_product_status', 'product_id = ?', array($productId)); + $objQuery->delete('dtb_product_status', 'product_id = ?', [$productId]); foreach ($productStatusIds as $productStatusId) { - if ($productStatusId == '') continue; + if ($productStatusId == '') { + continue; + } $val['product_status_id'] = $productStatusId; $objQuery->insert('dtb_product_status', $val); } @@ -516,7 +532,9 @@ public function setProductStatus($productId, $productStatusIds) * getDetailAndProductsClass() の結果から, 販売制限数を取得する. * * @param array $p 商品詳細の検索結果の配列 - * @return integer 商品詳細の結果から求めた販売制限数. + * + * @return int 商品詳細の結果から求めた販売制限数. + * * @see getDetailAndProductsClass() */ public function getBuyLimit($p) @@ -541,9 +559,10 @@ public function getBuyLimit($p) * 在庫の減少を中止し, false を返す. * 在庫の減少に成功した場合は true を返す. * - * @param integer $productClassId 商品規格ID - * @param integer $quantity 減少させる在庫数 - * @return boolean 在庫の減少に成功した場合 true; 失敗した場合 false + * @param int $productClassId 商品規格ID + * @param int $quantity 減少させる在庫数 + * + * @return bool 在庫の減少に成功した場合 true; 失敗した場合 false */ public function reduceStock($productClassId, $quantity) { @@ -552,9 +571,9 @@ public function reduceStock($productClassId, $quantity) } $objQuery = SC_Query_Ex::getSingletonInstance(); - $objQuery->update('dtb_products_class', array(), - 'product_class_id = ?', array($productClassId), - array('stock' => 'stock - ?'), array($quantity)); + $objQuery->update('dtb_products_class', [], + 'product_class_id = ?', [$productClassId], + ['stock' => 'stock - ?'], [$quantity]); // TODO エラーハンドリング $productsClass = $this->getDetailAndProductsClass($productClassId); @@ -571,6 +590,7 @@ public function reduceStock($productClassId, $quantity) * この関数は, 主にスマートフォンで使用します. * * @param array $arrProducts 商品情報の配列 + * * @return array 旧バージョン互換用のデータ */ public static function setPriceTaxTo(&$arrProducts) @@ -591,10 +611,10 @@ public static function setPriceTaxTo(&$arrProducts) // @deprecated 2.12.4 // 旧バージョン互換用 // 本来は、税額の代入で使用すべきキー名。 - $arrProduct['price01_min_tax_format'] =& $arrProduct['price01_min_inctax_format']; - $arrProduct['price01_max_tax_format'] =& $arrProduct['price01_max_inctax_format']; - $arrProduct['price02_min_tax_format'] =& $arrProduct['price02_min_inctax_format']; - $arrProduct['price02_max_tax_format'] =& $arrProduct['price02_max_inctax_format']; + $arrProduct['price01_min_tax_format'] = &$arrProduct['price01_min_inctax_format']; + $arrProduct['price01_max_tax_format'] = &$arrProduct['price01_max_inctax_format']; + $arrProduct['price02_min_tax_format'] = &$arrProduct['price02_min_inctax_format']; + $arrProduct['price02_max_tax_format'] = &$arrProduct['price02_max_inctax_format']; } // @deprecated 2.12.4 // 旧バージョン互換用 @@ -606,6 +626,7 @@ public static function setPriceTaxTo(&$arrProducts) * 商品情報の配列に税込金額を設定する * * @param array $arrProducts 商品情報の配列 + * * @return void */ public static function setIncTaxToProducts(&$arrProducts) @@ -619,6 +640,7 @@ public static function setIncTaxToProducts(&$arrProducts) * 商品情報の配列に税込金額を設定する * * @param array $arrProduct 商品情報の配列 + * * @return void */ public static function setIncTaxToProduct(&$arrProduct) @@ -634,9 +656,10 @@ public static function setIncTaxToProduct(&$arrProduct) * * @param string $where_products_class 商品規格情報の WHERE 句 * @param array $product_ids 商品IDの配列 + * * @return string 商品詳細の SQL */ - public static function alldtlSQL($where_products_class = '', $product_ids = array()) + public static function alldtlSQL($where_products_class = '', $product_ids = []) { $objDBFactory = SC_DB_DBFactory_Ex::getInstance(); @@ -649,13 +672,14 @@ public static function alldtlSQL($where_products_class = '', $product_ids = arra * MEMO: 2.4系 vw_product_classに相当(?)するイメージ * * @param string $where 商品詳細の WHERE 句 + * * @return string 商品規格詳細の SQL */ public static function prdclsSQL($where = '') { $where_clause = ''; if (!SC_Utils_Ex::isBlank($where)) { - $where_clause = ' WHERE ' . $where; + $where_clause = ' WHERE '.$where; } $sql = <<< __EOS__ ( @@ -699,9 +723,9 @@ public static function prdclsSQL($where = '') */ public static function getProductDispConditions($tablename = null) { - $tablename = ($tablename) ? $tablename . '.' : null; + $tablename = ($tablename) ? $tablename.'.' : null; - return $tablename . 'del_flg = 0 AND ' . $tablename . 'status = 1 '; + return $tablename.'del_flg = 0 AND '.$tablename.'status = 1 '; } /** @@ -709,16 +733,17 @@ public static function getProductDispConditions($tablename = null) * * @param int $product_id * @param bool $include_hidden + * * @return array */ public function getCategoryIds($product_id, $include_hidden = false) { if ($this->isValidProductId($product_id, $include_hidden)) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', array($product_id)); + $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', [$product_id]); } else { // 不正な場合は、空の配列を返す。 - $category_id = array(); + $category_id = []; } return $category_id; @@ -730,6 +755,7 @@ public function getCategoryIds($product_id, $include_hidden = false) * @param int $product_id * @param bool $include_hidden * @param bool $include_deleted + * * @return bool */ public function isValidProductId($product_id, $include_hidden = false, $include_deleted = false) @@ -747,10 +773,11 @@ public function isValidProductId($product_id, $include_hidden = false, $include_ if ( SC_Utils_Ex::sfIsInt($product_id) && !SC_Utils_Ex::sfIsZeroFilling($product_id) - && SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', array($product_id), $where) + && SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', [$product_id], $where) ) { return true; } + return false; } } diff --git a/data/class/SC_Query.php b/data/class/SC_Query.php index e114aa24e4..0bd0dea689 100644 --- a/data/class/SC_Query.php +++ b/data/class/SC_Query.php @@ -27,13 +27,14 @@ * TODO エラーハンドリング, ロギング方法を見直す * * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_Query { public $option = ''; public $where = ''; - public $arrWhereVal = array(); + public $arrWhereVal = []; public $conn; public $groupby = ''; public $order = ''; @@ -42,31 +43,31 @@ class SC_Query public $dbFactory; /** シングルトン動作のためのインスタンスプール配列。キーは DSN の識別情報。 */ - public static $arrPoolInstance = array(); + public static $arrPoolInstance = []; /** * コンストラクタ. * * @param string $dsn データソース名 - * @param boolean $force_run エラーが発生しても処理を続行する場合 true - * @param boolean $new 新規に接続を行うかどうか + * @param bool $force_run エラーが発生しても処理を続行する場合 true + * @param bool $new 新規に接続を行うかどうか */ public function __construct($dsn = '', $force_run = false, $new = false) { if ($dsn == '') { - $dsn = array( - 'phptype' => DB_TYPE, + $dsn = [ + 'phptype' => DB_TYPE, 'username' => DB_USER, 'password' => DB_PASSWORD, 'protocol' => 'tcp', 'hostspec' => DB_SERVER, - 'port' => DB_PORT, + 'port' => DB_PORT, 'database' => DB_NAME, - ); + ]; } // オプション - $options = array( + $options = [ // 持続的接続 'persistent' => PEAR_DB_PERSISTENT, // Debugモード @@ -74,7 +75,7 @@ public function __construct($dsn = '', $force_run = false, $new = false) // バッファリング true にするとメモリが解放されない。 // 連続クエリ実行時に問題が生じる。 'result_buffering' => false, - ); + ]; // fix for PHP7.2 if (!array_key_exists('_MDB2_dsninfo_default', $GLOBALS)) { @@ -105,8 +106,9 @@ public function __construct($dsn = '', $force_run = false, $new = false) * シングルトンの SC_Query インスタンスを取得する. * * @param string $dsn データソース名 - * @param boolean $force_run エラーが発生しても処理を続行する場合 true - * @param boolean $new 新規に接続を行うかどうか + * @param bool $force_run エラーが発生しても処理を続行する場合 true + * @param bool $new 新規に接続を行うかどうか + * * @return SC_Query シングルトンの SC_Query インスタンス */ public static function getSingletonInstance($dsn = '', $force_run = false, $new = false) @@ -129,7 +131,8 @@ public static function getSingletonInstance($dsn = '', $force_run = false, $new * エラー判定を行う. * * @deprecated PEAR::isError() を使用して下さい - * @return boolean + * + * @return bool */ public function isError() { @@ -146,9 +149,10 @@ public function isError() * @param string $table テーブル名 * @param string $where where句 * @param array $arrWhereVal プレースホルダ - * @return integer 件数 + * + * @return int 件数 */ - public function count($table, $where = '', $arrWhereVal = array()) + public function count($table, $where = '', $arrWhereVal = []) { return $this->get('COUNT(*)', $table, $where, $arrWhereVal); } @@ -159,9 +163,10 @@ public function count($table, $where = '', $arrWhereVal = array()) * @param string $table テーブル名 * @param string $where where句 * @param array $arrWhereVal プレースホルダ - * @return boolean 有無 + * + * @return bool 有無 */ - public function exists($table, $where = '', $arrWhereVal = array()) + public function exists($table, $where = '', $arrWhereVal = []) { $sql_inner = $this->getSql('*', $table, $where, $arrWhereVal); $sql = "SELECT CASE WHEN EXISTS($sql_inner) THEN 1 ELSE 0 END"; @@ -177,10 +182,11 @@ public function exists($table, $where = '', $arrWhereVal = array()) * @param string $from テーブル名 * @param string $where WHERE句 * @param array $arrWhereVal プレースホルダ - * @param integer $fetchmode 使用するフェッチモード。デフォルトは MDB2_FETCHMODE_ASSOC。 + * @param int $fetchmode 使用するフェッチモード。デフォルトは MDB2_FETCHMODE_ASSOC。 + * * @return array|null */ - public function select($cols, $from = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) + public function select($cols, $from = '', $where = '', $arrWhereVal = [], $fetchmode = MDB2_FETCHMODE_ASSOC) { $sqlse = $this->getSql($cols, $from, $where, $arrWhereVal); @@ -190,14 +196,15 @@ public function select($cols, $from = '', $where = '', $arrWhereVal = array(), $ /** * 直前に実行されたSQL文を取得する. * - * @param boolean $disp trueの場合、画面出力を行う. + * @param bool $disp trueの場合、画面出力を行う. + * * @return string SQL文 */ public function getLastQuery($disp = true) { $sql = $this->conn->last_query; if ($disp) { - echo $sql . ";
\n"; + echo $sql.";
\n"; } return $sql; @@ -247,7 +254,7 @@ public function rollback() /** * トランザクションが開始されているかチェックする. * - * @return boolean トランザクションが開始されている場合 true + * @return bool トランザクションが開始されている場合 true */ public function inTransaction() { @@ -261,7 +268,7 @@ public function inTransaction() * * FIXME MDB2::exec() の実装であるべき */ - public function exec($str, $arrVal = array()) + public function exec($str, $arrVal = []) { return $this->query($str, $arrVal); } @@ -269,13 +276,14 @@ public function exec($str, $arrVal = array()) /** * クエリを実行し、結果行毎にコールバック関数を適用する * - * @param callback $function コールバック先 + * @param callable $function コールバック先 * @param string $sql SQL クエリ * @param array $arrVal プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。 - * @param integer $fetchmode 使用するフェッチモード。デフォルトは DB_FETCHMODE_ASSOC。 - * @return boolean 結果 + * @param int $fetchmode 使用するフェッチモード。デフォルトは DB_FETCHMODE_ASSOC。 + * + * @return bool 結果 */ - public function doCallbackAll($cbFunc, $sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) + public function doCallbackAll($cbFunc, $sql, $arrVal = [], $fetchmode = MDB2_FETCHMODE_ASSOC) { $sql = $this->dbFactory->sfChangeMySQL($sql); @@ -305,10 +313,11 @@ public function doCallbackAll($cbFunc, $sql, $arrVal = array(), $fetchmode = MDB * * @param string $sql SQL クエリ * @param array $arrVal プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。 - * @param integer $fetchmode 使用するフェッチモード。デフォルトは DB_FETCHMODE_ASSOC。 + * @param int $fetchmode 使用するフェッチモード。デフォルトは DB_FETCHMODE_ASSOC。 + * * @return array データを含む2次元配列。失敗した場合に 0 または DB_Error オブジェクトを返します。 */ - public function getAll($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) + public function getAll($sql, $arrVal = [], $fetchmode = MDB2_FETCHMODE_ASSOC) { $sql = $this->dbFactory->sfChangeMySQL($sql); @@ -335,10 +344,12 @@ public function getAll($sql, $arrVal = array(), $fetchmode = MDB2_FETCHMODE_ASSO * 構築した SELECT 文を取得する. * * クラス変数から WHERE 句を組み立てる場合、$arrWhereVal を経由してプレースホルダもクラス変数のもので上書きする。 + * * @param string $cols SELECT 文に含めるカラム名 * @param string $from SELECT 文に含めるテーブル名 * @param string $where SELECT 文に含める WHERE 句 * @param mixed $arrWhereVal プレースホルダ(参照) + * * @return string 構築済みの SELECT 文 */ public function getSql($cols, $from = '', $where = '', &$arrWhereVal = null) @@ -348,7 +359,7 @@ public function getSql($cols, $from = '', $where = '', &$arrWhereVal = null) $sqlse = "SELECT $cols"; if (strlen($from) === 0) { - $sqlse .= ' ' . $dbFactory->getDummyFromClauseSql(); + $sqlse .= ' '.$dbFactory->getDummyFromClauseSql(); } else { $sqlse .= " FROM $from"; } @@ -357,7 +368,7 @@ public function getSql($cols, $from = '', $where = '', &$arrWhereVal = null) if (strlen($where) >= 1) { $sqlse .= " WHERE $where"; } elseif (strlen($this->where) >= 1) { - $sqlse .= ' WHERE ' . $this->where; + $sqlse .= ' WHERE '.$this->where; // 実行時と同じくキャストしてから評価する (空文字を要素1の配列と評価させる意図) $arrWhereValForEval = (array) $arrWhereVal; if (empty($arrWhereValForEval)) { @@ -365,7 +376,7 @@ public function getSql($cols, $from = '', $where = '', &$arrWhereVal = null) } } - $sqlse .= ' ' . $this->groupby . ' ' . $this->order . ' ' . $this->option; + $sqlse .= ' '.$this->groupby.' '.$this->order.' '.$this->option; return $sqlse; } @@ -376,6 +387,7 @@ public function getSql($cols, $from = '', $where = '', &$arrWhereVal = null) * この関数で設定した値は SC_Query::getSql() で使用されます. * * @param string $str 付与する SQL 文 + * * @return SC_Query 自分自身のインスタンス */ public function setOption($str) @@ -390,8 +402,9 @@ public function setOption($str) * * この関数で設定した値は SC_Query::getSql() で使用されます. * - * @param integer $limit LIMIT 句に付与する値 - * @param integer $offset OFFSET 句に付与する値 + * @param int $limit LIMIT 句に付与する値 + * @param int $offset OFFSET 句に付与する値 + * * @return SC_Query 自分自身のインスタンス */ public function setLimitOffset($limit, $offset = 0) @@ -409,6 +422,7 @@ public function setLimitOffset($limit, $offset = 0) * この関数で設定した値は SC_Query::getSql() で使用されます. * * @param string $str GROUP BY 句に付与する文字列 + * * @return SC_Query 自分自身のインスタンス */ public function setGroupBy($str) @@ -416,7 +430,7 @@ public function setGroupBy($str) if (strlen($str) == 0) { $this->groupby = ''; } else { - $this->groupby = 'GROUP BY ' . $str; + $this->groupby = 'GROUP BY '.$str; } return $this; @@ -428,12 +442,13 @@ public function setGroupBy($str) * この関数で設定した値は SC_Query::getSql() で使用されます. * * @param string $str WHERE 句に付与する AND 条件の文字列 + * * @return SC_Query 自分自身のインスタンス */ public function andWhere($str) { if ($this->where != '') { - $this->where .= ' AND ' . $str; + $this->where .= ' AND '.$str; } else { $this->where = $str; } @@ -447,12 +462,13 @@ public function andWhere($str) * この関数で設定した値は SC_Query::getSql() で使用されます. * * @param string $str WHERE 句に付与する OR 条件の文字列 + * * @return SC_Query 自分自身のインスタンス */ public function orWhere($str) { if ($this->where != '') { - $this->where .= ' OR ' . $str; + $this->where .= ' OR '.$str; } else { $this->where = $str; } @@ -467,9 +483,10 @@ public function orWhere($str) * * @param string $where WHERE 句に付与する文字列 * @param mixed $arrWhereVal プレースホルダ + * * @return SC_Query 自分自身のインスタンス */ - public function setWhere($where = '', $arrWhereVal = array()) + public function setWhere($where = '', $arrWhereVal = []) { $this->where = $where; $this->arrWhereVal = $arrWhereVal; @@ -483,6 +500,7 @@ public function setWhere($where = '', $arrWhereVal = array()) * この関数で設定した値は SC_Query::getSql() で使用されます. * * @param string $str ORDER BY 句に付与する文字列 + * * @return SC_Query 自分自身のインスタンス */ public function setOrder($str) @@ -490,7 +508,7 @@ public function setOrder($str) if (strlen($str) == 0) { $this->order = ''; } else { - $this->order = 'ORDER BY ' . $str; + $this->order = 'ORDER BY '.$str; } return $this; @@ -501,7 +519,8 @@ public function setOrder($str) * * この関数で設定した値は SC_Query::getSql() で使用されます. * - * @param integer $limit LIMIT 句に設定する値 + * @param int $limit LIMIT 句に設定する値 + * * @return SC_Query 自分自身のインスタンス */ public function setLimit($limit) @@ -518,7 +537,8 @@ public function setLimit($limit) * * この関数で設定した値は SC_Query::getSql() で使用されます. * - * @param integer $offset OFFSET 句に設定する値 + * @param int $offset OFFSET 句に設定する値 + * * @return SC_Query 自分自身のインスタンス */ public function setOffset($offset) @@ -539,17 +559,18 @@ public function setOffset($offset) * @param array $arrSqlVal SQL文の中で使用するプレースホルダ配列 * @param string $from FROM 句・WHERE 句 * @param array $arrFromVal FROM 句・WHERE 句で使用するプレースホルダ配列 - * @return integer|DB_Error|boolean 挿入件数またはエラー(DB_Error, false) + * + * @return int|DB_Error|bool 挿入件数またはエラー(DB_Error, false) */ - public function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), $from = '', $arrFromVal = array()) + public function insert($table, $arrVal, $arrSql = [], $arrSqlVal = [], $from = '', $arrFromVal = []) { $strcol = ''; $strval = ''; $find = false; - $arrValForQuery = array(); + $arrValForQuery = []; foreach ($arrVal as $key => $val) { - $strcol .= $key . ','; + $strcol .= $key.','; if (strcasecmp('Now()', $val) === 0) { $strval .= 'Now(),'; } elseif (strcasecmp('CURRENT_TIMESTAMP', $val) === 0) { @@ -562,8 +583,8 @@ public function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), } foreach ($arrSql as $key => $val) { - $strcol .= $key . ','; - $strval .= $val . ','; + $strcol .= $key.','; + $strval .= $val.','; $find = true; } @@ -578,7 +599,7 @@ public function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), $sqlin = "INSERT INTO $table($strcol) SELECT $strval"; if (strlen($from) >= 1) { - $sqlin .= ' ' . $from; + $sqlin .= ' '.$from; $arrValForQuery = array_merge($arrValForQuery, $arrFromVal); } @@ -597,21 +618,22 @@ public function insert($table, $arrVal, $arrSql = array(), $arrSqlVal = array(), * @param array $arrWhereVal WHERE句用のプレースホルダ配列 (従来は追加カラム用も兼ねていた) * @param array $arrRawSql 追加カラム * @param array $arrRawSqlVal 追加カラム用のプレースホルダ配列 + * * @return */ - public function update($table, $arrVal, $where = '', $arrWhereVal = array(), $arrRawSql = array(), $arrRawSqlVal = array()) + public function update($table, $arrVal, $where = '', $arrWhereVal = [], $arrRawSql = [], $arrRawSqlVal = []) { - $arrCol = array(); - $arrValForQuery = array(); + $arrCol = []; + $arrValForQuery = []; $find = false; foreach ($arrVal as $key => $val) { if (strcasecmp('Now()', $val) === 0) { - $arrCol[] = $key . '= Now()'; + $arrCol[] = $key.'= Now()'; } elseif (strcasecmp('CURRENT_TIMESTAMP', $val) === 0) { - $arrCol[] = $key . '= CURRENT_TIMESTAMP'; + $arrCol[] = $key.'= CURRENT_TIMESTAMP'; } else { - $arrCol[] = $key . '= ?'; + $arrCol[] = $key.'= ?'; $arrValForQuery[] = $val; } $find = true; @@ -653,9 +675,10 @@ public function update($table, $arrVal, $where = '', $arrWhereVal = array(), $ar * @param string $col カラム名 * @param string $where 付与する WHERE 句 * @param array $arrWhereVal プレースホルダに挿入する値 - * @return integer MAX文の実行結果 + * + * @return int MAX文の実行結果 */ - public function max($col, $table, $where = '', $arrWhereVal = array()) + public function max($col, $table, $where = '', $arrWhereVal = []) { $ret = $this->get("MAX($col)", $table, $where, $arrWhereVal); @@ -669,9 +692,10 @@ public function max($col, $table, $where = '', $arrWhereVal = array()) * @param string $col カラム名 * @param string $where 付与する WHERE 句 * @param array $arrWhereVal プレースホルダに挿入する値 - * @return integer MIN文の実行結果 + * + * @return int MIN文の実行結果 */ - public function min($col, $table, $where = '', $arrWhereVal = array()) + public function min($col, $table, $where = '', $arrWhereVal = []) { $ret = $this->get("MIN($col)", $table, $where, $arrWhereVal); @@ -685,9 +709,10 @@ public function min($col, $table, $where = '', $arrWhereVal = array()) * @param string $col カラム名 * @param string $where 付与する WHERE 句 * @param array $arrWhereVal プレースホルダに挿入する値 + * * @return mixed SQL の実行結果 */ - public function get($col, $table = '', $where = '', $arrWhereVal = array()) + public function get($col, $table = '', $where = '', $arrWhereVal = []) { $sqlse = $this->getSql($col, $table, $where, $arrWhereVal); // SQL文の実行 @@ -701,9 +726,10 @@ public function get($col, $table = '', $where = '', $arrWhereVal = array()) * * @param string $sql 実行する SQL * @param array $arrVal プレースホルダに挿入する値 + * * @return mixed SQL の実行結果 */ - public function getOne($sql, $arrVal = array()) + public function getOne($sql, $arrVal = []) { $sql = $this->dbFactory->sfChangeMySQL($sql); @@ -733,10 +759,11 @@ public function getOne($sql, $arrVal = array()) * @param string $col カラム名 * @param string $where WHERE句 * @param array $arrWhereVal プレースホルダ配列 - * @param integer $fetchmode 使用するフェッチモード。デフォルトは MDB2_FETCHMODE_ASSOC。 + * @param int $fetchmode 使用するフェッチモード。デフォルトは MDB2_FETCHMODE_ASSOC。 + * * @return array array('カラム名' => '値', ...)の連想配列 */ - public function getRow($col, $table = '', $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) + public function getRow($col, $table = '', $where = '', $arrWhereVal = [], $fetchmode = MDB2_FETCHMODE_ASSOC) { $sql = $this->getSql($col, $table, $where, $arrWhereVal); $sql = $this->dbFactory->sfChangeMySQL($sql); @@ -767,9 +794,10 @@ public function getRow($col, $table = '', $where = '', $arrWhereVal = array(), $ * @param string $col カラム名 * @param string $where 付与する WHERE 句 * @param array $arrWhereVal プレースホルダに挿入する値 + * * @return array SQL の実行結果の配列 */ - public function getCol($col, $table = '', $where = '', $arrWhereVal = array()) + public function getCol($col, $table = '', $where = '', $arrWhereVal = []) { $sql = $this->getSql($col, $table, $where, $arrWhereVal); $sql = $this->dbFactory->sfChangeMySQL($sql); @@ -799,14 +827,15 @@ public function getCol($col, $table = '', $where = '', $arrWhereVal = array()) * @param string $table テーブル名 * @param string $where WHERE句 * @param array $arrWhereVal プレースホルダ + * * @return */ - public function delete($table, $where = '', $arrWhereVal = array()) + public function delete($table, $where = '', $arrWhereVal = []) { if (strlen($where) <= 0) { - $sqlde = 'DELETE FROM ' . $this->conn->quoteIdentifier($table); + $sqlde = 'DELETE FROM '.$this->conn->quoteIdentifier($table); } else { - $sqlde = 'DELETE FROM ' . $this->conn->quoteIdentifier($table) . ' WHERE ' . $where; + $sqlde = 'DELETE FROM '.$this->conn->quoteIdentifier($table).' WHERE '.$where; } $ret = $this->query($sqlde, $arrWhereVal, false, null, MDB2_PREPARE_MANIP); @@ -817,7 +846,7 @@ public function delete($table, $where = '', $arrWhereVal = array()) * 次のシーケンス値を取得する. * * @param string $seq_name 取得するシーケンス名 - * @param integer 次のシーケンス値 + * @param int 次のシーケンス値 */ public function nextVal($seq_name) { @@ -828,7 +857,8 @@ public function nextVal($seq_name) * 現在のシーケンス値を取得する. * * @param string $seq_name 取得するシーケンス名 - * @return integer 現在のシーケンス値 + * + * @return int 現在のシーケンス値 */ public function currVal($seq_name) { @@ -839,7 +869,8 @@ public function currVal($seq_name) * シーケンス値を設定する. * * @param string $seq_name シーケンス名 - * @param integer $start 設定するシーケンス値 + * @param int $start 設定するシーケンス値 + * * @return MDB2_OK */ public function setVal($seq_name, $start) @@ -867,12 +898,13 @@ public function setVal($seq_name, $start) * * @param string $n 実行する SQL 文 * @param array $arr プレースホルダに挿入する値 - * @param boolean $ignore_err MDB2切替で無効化されている (エラーが発生しても処理を続行する場合 true) + * @param bool $ignore_err MDB2切替で無効化されている (エラーが発生しても処理を続行する場合 true) * @param mixed $types プレースホルダの型指定 デフォルトnull = string * @param mixed $result_types 返値の型指定またはDML実行(MDB2_PREPARE_MANIP) + * * @return array SQL の実行結果の配列 */ - public function query($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) + public function query($n, $arr = [], $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) { $n = $this->dbFactory->sfChangeMySQL($n); @@ -918,6 +950,7 @@ public function listTables() * テーブルのカラム一覧を取得する. * * @param string $table テーブル名 + * * @return array 指定のテーブルのカラム名の配列 */ public function listTableFields($table) @@ -931,6 +964,7 @@ public function listTableFields($table) * テーブルのインデックス一覧を取得する. * * @param string $table テーブル名 + * * @return array 指定のテーブルのインデックス一覧 */ public function listTableIndexes($table) @@ -973,13 +1007,14 @@ public function dropIndex($table, $name) * テーブルの詳細情報を取得する。 * * @param string $table テーブル名 + * * @return array テーブル情報の配列 */ public function getTableInfo($table) { $objManager = $this->conn->loadModule('Reverse'); - return $objManager->tableInfo($table, NULL); + return $objManager->tableInfo($table, null); } /** @@ -990,7 +1025,9 @@ public function getTableInfo($table) * 本来であれば, MDB2::prepare() を適切に使用するべき * * @see MDB2::quote() + * * @param string $val クォートを行う文字列 + * * @return string クォートされた文字列 */ public function quote($val) @@ -1003,12 +1040,13 @@ public function quote($val) * * @param string $table テーブル名 * @param array プレースホルダの連想配列 + * * @return array テーブルに存在する列のみ抽出した連想配列 */ public function extractOnlyColsOf($table, $arrParams) { $arrCols = $this->listTableFields($table); - $arrResults = array(); + $arrResults = []; foreach ($arrParams as $key => $val) { if (in_array($key, $arrCols)) { $arrResults[$key] = $val; @@ -1021,10 +1059,10 @@ public function extractOnlyColsOf($table, $arrParams) /** * プリペアドステートメントを構築する. * - * @access private * @param string $sql プリペアドステートメントを構築する SQL * @param mixed $types プレースホルダの型指定 デフォルト null * @param mixed $result_types 返値の型指定またはDML実行(MDB2_PREPARE_MANIP)、nullは指定無し + * * @return MDB2_Statement_Common プリペアドステートメントインスタンス */ public function prepare($sql, $types = null, $result_types = MDB2_PREPARE_RESULT) @@ -1041,12 +1079,12 @@ public function prepare($sql, $types = null, $result_types = MDB2_PREPARE_RESULT /** * プリペアドクエリを実行する. * - * @access private * @param MDB2_Statement_Common プリペアドステートメントインスタンス * @param array $arrVal プレースホルダに挿入する配列 + * * @return MDB2_Result 結果セットのインスタンス */ - public function execute(&$sth, $arrVal = array()) + public function execute(&$sth, $arrVal = []) { // #1658 (SC_Query の各種メソッドでプレースホルダの数に誤りがあるとメモリリークが発生する) 対応 // TODO 現状は PEAR 内のバックトレースを抑制することで、メモリーリークの影響を小さくしている。 @@ -1076,20 +1114,21 @@ public function execute(&$sth, $arrVal = array()) * * XXX trigger_error で処理する場合、1024文字以内に抑える必要がある。 * XXX 重要な情報を先頭に置き、冗長になりすぎないように留意する。 - * @access private + * * @param PEAR::Error $error PEAR::Error インスタンス * @param string $sql エラーの発生した SQL 文 * @param array $arrVal プレースホルダ + * * @return string トレースしたエラー文字列 */ public function traceError($error, $sql = '', $arrVal = false) { $err = "SQL: [$sql]\n"; if ($arrVal !== false) { - $err .= 'PlaceHolder: [' . var_export($arrVal, true) . "]\n"; + $err .= 'PlaceHolder: ['.var_export($arrVal, true)."]\n"; } - $err .= $error->getMessage() . "\n"; - $err .= rtrim($error->getUserInfo()) . "\n"; + $err .= $error->getMessage()."\n"; + $err .= rtrim($error->getUserInfo())."\n"; // PEAR::MDB2 内部のスタックトレースを出力する場合、下記のコメントを外す。 // $err .= GC_Utils_Ex::toStringBacktrace($error->getBackTrace()); @@ -1101,7 +1140,7 @@ public function traceError($error, $sql = '', $arrVal = false) */ public function error($msg) { - $msg = "DB処理でエラーが発生しました。\n" . $msg; + $msg = "DB処理でエラーが発生しました。\n".$msg; if (!$this->force_run) { trigger_error($msg, E_USER_ERROR); } else { @@ -1114,12 +1153,13 @@ public function error($msg) * * @param string $n 実行する SQL 文 * @param array $arr プレースホルダに挿入する値 - * @param boolean エラーが発生しても処理を続行する場合 true + * @param bool エラーが発生しても処理を続行する場合 true * @param mixed $types プレースホルダの型指定 デフォルトnull = string * @param mixed $result_types 返値の型指定またはDML実行(MDB2_PREPARE_MANIP) + * * @return array 実行結果の配列 */ - public function getQueryDefsFields($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) + public function getQueryDefsFields($n, $arr = [], $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT) { $n = $this->dbFactory->sfChangeMySQL($n); @@ -1144,6 +1184,7 @@ public function getQueryDefsFields($n ,$arr = array(), $ignore_err = false, $typ * * @param string 実行するSQL文 * @param array $arrVal プレースホルダに挿入する配列 + * * @return array */ private function lfStartDbTraceLog(&$objSth, &$arrVal) @@ -1152,20 +1193,20 @@ private function lfStartDbTraceLog(&$objSth, &$arrVal) return; } if (!array_key_exists('_SC_Query_TraceLogInfo', $GLOBALS)) { - $GLOBALS['_SC_Query_TraceLogInfo'] = array(); + $GLOBALS['_SC_Query_TraceLogInfo'] = []; } - $arrInfo =& $GLOBALS['_SC_Query_TraceLogInfo']; + $arrInfo = &$GLOBALS['_SC_Query_TraceLogInfo']; if (!isset($arrInfo['http_request_id'])) { $arrInfo['http_request_id'] = uniqid(); } if (!isset($arrInfo['count'])) { $arrInfo['count'] = 0; } - $arrStartInfo = array( - 'http_request_id' => $arrInfo['http_request_id'], - 'time_start' => microtime(true), - 'count' => ++$arrInfo['count'], - ); + $arrStartInfo = [ + 'http_request_id' => $arrInfo['http_request_id'], + 'time_start' => microtime(true), + 'count' => ++$arrInfo['count'], + ]; // ログモード1の場合、開始はログに出力しない if (SQL_QUERY_LOG_MODE === 1) { @@ -1173,8 +1214,8 @@ private function lfStartDbTraceLog(&$objSth, &$arrVal) } $msg = "[execute start {$arrStartInfo['http_request_id']}#{$arrStartInfo['count']}]\n" - . 'SQL: ' . $objSth->query . "\n" - . 'PlaceHolder: ' . var_export($arrVal, true) . "\n"; + .'SQL: '.$objSth->query."\n" + .'PlaceHolder: '.var_export($arrVal, true)."\n"; GC_Utils_Ex::gfPrintLog($msg, DB_LOG_REALFILE); return $arrStartInfo; @@ -1185,6 +1226,7 @@ private function lfStartDbTraceLog(&$objSth, &$arrVal) * * @param string 実行するSQL文 * @param array $arrVal プレースホルダに挿入する配列 + * * @return void */ private function lfEndDbTraceLog(&$arrStartInfo, &$objSth, &$arrVal) @@ -1204,11 +1246,11 @@ private function lfEndDbTraceLog(&$arrStartInfo, &$objSth, &$arrVal) return; } // 開始時にログ出力していないため、ここで実行内容を出力する - $msg .= 'SQL: ' . $objSth->query . "\n"; - $msg .= 'PlaceHolder: ' . var_export($arrVal, true) . "\n"; + $msg .= 'SQL: '.$objSth->query."\n"; + $msg .= 'PlaceHolder: '.var_export($arrVal, true)."\n"; } - $msg .= 'execution time: ' . sprintf('%.2f sec', $timeExecTime) . "\n"; + $msg .= 'execution time: '.sprintf('%.2f sec', $timeExecTime)."\n"; GC_Utils_Ex::gfPrintLog($msg, DB_LOG_REALFILE); } @@ -1217,6 +1259,7 @@ private function lfEndDbTraceLog(&$arrStartInfo, &$objSth, &$arrVal) * * @param SC_Query $objThis プールするインスタンス * @param string $dsn データソース名 + * * @return SC_Query プールしたインスタンス */ public static function setPoolInstance(&$objThis, $dsn = '') @@ -1230,6 +1273,7 @@ public static function setPoolInstance(&$objThis, $dsn = '') * プールしているインスタンスを取得する * * @param string $dsn データソース名 + * * @return SC_Query|null */ public static function getPoolInstance($dsn = '') diff --git a/data/class/SC_Response.php b/data/class/SC_Response.php index 09c9531076..d3e75ef10a 100644 --- a/data/class/SC_Response.php +++ b/data/class/SC_Response.php @@ -25,6 +25,7 @@ * HttpResponse を扱うクラス. * * @author Ryuichi Tokugami + * * @version $Id$ */ class SC_Response @@ -32,15 +33,15 @@ class SC_Response /** * コンテンツタイプ * Enter description here ... + * * @var unknown_type */ public $contentType; public $body; public $statusCode; - public $header = array(); + public $header = []; /** - * * Enter description here ... */ public $encoding; @@ -104,10 +105,10 @@ public static function actionExit() if (array_key_exists('object', $backtrace) && is_object($backtrace['object'])) { $parent_class_name = get_parent_class($backtrace['object']); - $objPlugin->doAction($parent_class_name . '_action_' . $backtrace['object']->getMode(), array($backtrace['object'])); + $objPlugin->doAction($parent_class_name.'_action_'.$backtrace['object']->getMode(), [$backtrace['object']]); $class_name = get_class($backtrace['object']); if ($class_name != $parent_class_name) { - $objPlugin->doAction($class_name . '_action_' . $backtrace['object']->getMode(), array($backtrace['object'])); + $objPlugin->doAction($class_name.'_action_'.$backtrace['object']->getMode(), [$backtrace['object']]); } break; } @@ -125,14 +126,16 @@ public static function actionExit() * 1. 引数 $inheritQueryString が true の場合、$_SERVER['QUERY_STRING'] * 2. $location に含まれる クエリ * 3. 引数 $arrQueryString + * * @param string $location 「url-path」「現在のURLからのパス」「URL」のいずれか。「../」の解釈は行なわない。 * @param array $arrQueryString URL に付加するクエリ * @param bool $inheritQueryString 現在のリクエストのクエリを継承するか * @param bool|null $useSsl true:HTTPSを強制, false:HTTPを強制, null:継承 + * * @return void * @static */ - public static function sendRedirect($location, $arrQueryString = array(), $inheritQueryString = false, $useSsl = null) + public static function sendRedirect($location, $arrQueryString = [], $inheritQueryString = false, $useSsl = null) { // ローカルフックポイント処理 $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); @@ -143,11 +146,11 @@ public static function sendRedirect($location, $arrQueryString = array(), $inher foreach ($arrBacktrace as $backtrace) { if (array_key_exists('object', $backtrace) && is_object($backtrace['object']) && method_exists($backtrace['object'], 'getMode')) { $parent_class_name = get_parent_class($backtrace['object']); - $objPlugin->doAction($parent_class_name . '_action_' . $backtrace['object']->getMode(), array($backtrace['object'])); + $objPlugin->doAction($parent_class_name.'_action_'.$backtrace['object']->getMode(), [$backtrace['object']]); $class_name = get_class($backtrace['object']); if ($class_name != $parent_class_name) { - $objPlugin->doAction($class_name . '_action_' . $backtrace['object']->getMode(), array($backtrace['object'])); + $objPlugin->doAction($class_name.'_action_'.$backtrace['object']->getMode(), [$backtrace['object']]); } break; @@ -155,16 +158,16 @@ public static function sendRedirect($location, $arrQueryString = array(), $inher $pattern = '/^[a-zA-Z0-9_]+$/'; $mode = null; if (isset($_GET['mode']) && preg_match($pattern, $_GET['mode'])) { - $mode = $_GET['mode']; + $mode = $_GET['mode']; } elseif (isset($_POST['mode']) && preg_match($pattern, $_POST['mode'])) { $mode = $_POST['mode']; } $parent_class_name = get_parent_class($backtrace['object']); - $objPlugin->doAction($parent_class_name . '_action_' . $mode, array($backtrace['object'])); + $objPlugin->doAction($parent_class_name.'_action_'.$mode, [$backtrace['object']]); $class_name = get_class($backtrace['object']); if ($class_name != $parent_class_name) { - $objPlugin->doAction($class_name . '_action_' . $mode, array($backtrace['object'])); + $objPlugin->doAction($class_name.'_action_'.$mode, [$backtrace['object']]); } break; @@ -183,12 +186,12 @@ public static function sendRedirect($location, $arrQueryString = array(), $inher $url = $location; if (is_bool($useSsl)) { if ($useSsl) { - $pattern = '/^' . preg_quote(HTTP_URL, '/') . '(.*)/'; - $replacement = HTTPS_URL . '\1'; + $pattern = '/^'.preg_quote(HTTP_URL, '/').'(.*)/'; + $replacement = HTTPS_URL.'\1'; $url = preg_replace($pattern, $replacement, $url); } else { - $pattern = '/^' . preg_quote(HTTPS_URL, '/') . '(.*)/'; - $replacement = HTTP_URL . '\1'; + $pattern = '/^'.preg_quote(HTTPS_URL, '/').'(.*)/'; + $replacement = HTTP_URL.'\1'; $url = preg_replace($pattern, $replacement, $url); } } @@ -198,12 +201,12 @@ public static function sendRedirect($location, $arrQueryString = array(), $inher $useSsl = SC_Utils_Ex::sfIsHTTPS(); } $netUrl = new Net_URL($useSsl ? HTTPS_URL : HTTP_URL); - $netUrl->path = dirname($_SERVER['SCRIPT_NAME']) . '/' . $location; + $netUrl->path = dirname($_SERVER['SCRIPT_NAME']).'/'.$location; $url = $netUrl->getUrl(); } if (!SC_Utils_Ex::isInternalUrl($url)) { - trigger_error('アプリケーション外へのリダイレクトは扱わない: ' . var_export($url, true), E_USER_ERROR); + trigger_error('アプリケーション外へのリダイレクトは扱わない: '.var_export($url, true), E_USER_ERROR); } $netUrl = new Net_URL($url); @@ -226,7 +229,7 @@ public static function sendRedirect($location, $arrQueryString = array(), $inher $netUrl->addQueryString(session_name(), session_id()); } - /** + /* * transactionid を受け取ったリクエストに関して、値を継承してリダイレクトする。 * @see https://github.com/EC-CUBE/ec-cube2/issues/922 */ @@ -252,26 +255,28 @@ public static function sendRedirect($location, $arrQueryString = array(), $inher * /html/ からのパスを指定してリダイレクトする * * FIXME メソッド名を分かりやすくしたい。現状だと、引数が「url-path より後」とも「url-path」とも読み取れる。(前者が意図したいところ) + * * @param string $location /html/ からのパス。先頭に / を含むかは任意。「../」の解釈は行なわない。 + * * @return void * @static */ - public static function sendRedirectFromUrlPath($location, $arrQueryString = array(), $inheritQueryString = false, $useSsl = null) + public static function sendRedirectFromUrlPath($location, $arrQueryString = [], $inheritQueryString = false, $useSsl = null) { - $location = ROOT_URLPATH . ltrim($location, '/'); + $location = ROOT_URLPATH.ltrim($location, '/'); SC_Response_Ex::sendRedirect($location, $arrQueryString, $inheritQueryString, $useSsl); } /** * @static */ - public static function reload($arrQueryString = array(), $removeQueryString = false) + public static function reload($arrQueryString = [], $removeQueryString = false) { // 現在の URL を取得 $netUrl = new Net_URL($_SERVER['REQUEST_URI']); if ($removeQueryString) { - $netUrl->querystring = array(); + $netUrl->querystring = []; } SC_Response_Ex::sendRedirect($netUrl->getURL(), $arrQueryString); @@ -290,15 +295,21 @@ public function setStatusCode($statusCode = null) /** * HTTPステータスコードを送出する。 * - * @param integer $statusCode HTTPステータスコード + * @param int $statusCode HTTPステータスコード + * * @return void + * * @author Seasoft (新規作成) + * * @see Moony_Action::status() (オリジナル) - * @link http://moony.googlecode.com/ (オリジナル) + * @see http://moony.googlecode.com/ (オリジナル) + * * @author YAMAOKA Hiroyuki (オリジナル) * @copyright 2005-2008 YAMAOKA Hiroyuki (オリジナル) * @license http://opensource.org/licenses/bsd-license.php New BSD License (オリジナル) - * @link http://ja.wikipedia.org/wiki/HTTP%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9%E3%82%B3%E3%83%BC%E3%83%89 (邦訳) + * + * @see http://ja.wikipedia.org/wiki/HTTP%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9%E3%82%B3%E3%83%BC%E3%83%89 (邦訳) + * * @license http://www.gnu.org/licenses/fdl.html GFDL (邦訳) * @static */ @@ -306,7 +317,7 @@ public static function sendHttpStatus($statusCode) { $protocol = $_SERVER['SERVER_PROTOCOL']; $httpVersion = (strpos($protocol, '1.1') !== false) ? '1.1' : '1.0'; - $messages = array( + $messages = [ // Informational 1xx // 【情報】 100 => 'Continue', // 継続 101 => 'Switching Protocols', // プロトコル切替え @@ -354,7 +365,7 @@ public static function sendHttpStatus($statusCode) 504 => 'Gateway Timeout', // ゲートウェイタイムアウト 505 => 'HTTP Version Not Supported', // サポートしていないHTTPバージョン 509 => 'Bandwidth Limit Exceeded' // 帯域幅制限超過 - ); + ]; if (isset($messages[$statusCode])) { if ($httpVersion !== '1.1') { // HTTP/1.0 @@ -369,9 +380,11 @@ public static function sendHttpStatus($statusCode) * ダウンロード用の HTTP ヘッダを出力する * * @param string $file_name + * * @return void */ - public static function headerForDownload($file_name) { + public static function headerForDownload($file_name) + { header("Content-disposition: attachment; filename={$file_name}"); header("Content-type: application/octet-stream; name={$file_name}"); header('Cache-Control: '); @@ -381,7 +394,8 @@ public static function headerForDownload($file_name) { /** * exit をスキップする場合はオーバーライドすること. */ - protected static function exitWrapper() { + protected static function exitWrapper() + { exit; } } diff --git a/data/class/SC_SelectSql.php b/data/class/SC_SelectSql.php index e258af372c..3e3f6986da 100644 --- a/data/class/SC_SelectSql.php +++ b/data/class/SC_SelectSql.php @@ -53,11 +53,12 @@ public function __construct($array = []) * SQL文生成 * * @param string $mode + * * @return string */ public function getSql($mode = '') { - $this->sql = $this->select .' '. $this->where .' '. $this->group .' '; + $this->sql = $this->select.' '.$this->where.' '.$this->group.' '; if ($mode == 2) { $this->sql .= $this->order; @@ -71,7 +72,7 @@ public function getSql($mode = '') */ public static function addSearchStr($val) { - $return = '%' .$val. '%'; + $return = '%'.$val.'%'; return $return; } @@ -82,26 +83,27 @@ public static function addSearchStr($val) * @param int $from * @param int $to * @param string $column + * * @return array */ public function selectRange($from, $to, $column) { // ある単位のみ検索($from = $to) if ($from == $to) { - $this->setWhere($column .' = ?'); - $return = array($from); + $this->setWhere($column.' = ?'); + $return = [$from]; // ~$toまで検索 } elseif (strlen($from) == 0 && strlen($to) > 0) { - $this->setWhere($column .' <= ? '); - $return = array($to); + $this->setWhere($column.' <= ? '); + $return = [$to]; // ~$from以上を検索 } elseif (strlen($from) > 0 && strlen($to) == 0) { - $this->setWhere($column .' >= ? '); - $return = array($from); + $this->setWhere($column.' >= ? '); + $return = [$from]; // $from~$toの検索 } else { - $this->setWhere($column .' BETWEEN ? AND ?'); - $return = array($from, $to); + $this->setWhere($column.' BETWEEN ? AND ?'); + $return = [$from, $to]; } return $return; @@ -117,26 +119,27 @@ public function selectRange($from, $to, $column) * @param int $to_month * @param int $to_day * @param string $column + * * @return array */ public function selectTermRange($from_year, $from_month, $from_day, $to_year, $to_month, $to_day, $column) { - $return = array(); + $return = []; // 開始期間の構築 - $date1 = $from_year . '/' . $from_month . '/' . $from_day; + $date1 = $from_year.'/'.$from_month.'/'.$from_day; // 終了期間の構築 // @see http://svn.ec-cube.net/open_trac/ticket/328 // FIXME とりあえずintvalで対策... - $date2 = mktime(0, 0, 0, intval($to_month), intval($to_day), intval($to_year)); + $date2 = mktime(0, 0, 0, (int) $to_month, (int) $to_day, (int) $to_year); $date2 = $date2 + 86400; // SQL文のdate関数に与えるフォーマットは、yyyy/mm/ddで指定する。 $date2 = date('Y/m/d', $date2); // 開始期間だけ指定の場合 if (($from_year != '') && ($from_month != '') && ($from_day != '') && ($to_year == '') && ($to_month == '') && ($to_day == '')) { - $this->setWhere($column .' >= ?'); + $this->setWhere($column.' >= ?'); $return[] = $date1; } @@ -144,14 +147,14 @@ public function selectTermRange($from_year, $from_month, $from_day, $to_year, $t if (($from_year != '') && ($from_month != '') && ($from_day != '') && ($to_year != '') && ($to_month != '') && ($to_day != '') ) { - $this->setWhere($column . ' >= ? AND ' . $column . ' < date(?)'); + $this->setWhere($column.' >= ? AND '.$column.' < date(?)'); $return[] = $date1; $return[] = $date2; } // 終了期間だけ指定の場合 if (($from_year == '') && ($from_month == '') && ($from_day == '') && ($to_year != '') && ($to_month != '') && ($to_day != '')) { - $this->setWhere($column . ' < date(?)'); + $this->setWhere($column.' < date(?)'); $return[] = $date2; } @@ -162,22 +165,24 @@ public function selectTermRange($from_year, $from_month, $from_day, $to_year, $t * checkboxなどで同一カラム内で単一、もしくは複数選択肢が有る場合 * * 例: AND ( sex = xxx OR sex = xxx OR sex = xxx) AND ... + * * @param array $arr * @param string $ItemStr + * * @return array */ public function setItemTerm($arr, $ItemStr) { - $return = array(); + $return = []; $item = ''; foreach ($arr as $data) { if (count($arr) > 1) { if (!is_null($data)) { - $item .= $ItemStr . ' = ? OR '; + $item .= $ItemStr.' = ? OR '; } } else { if (!is_null($data)) { - $item = $ItemStr . ' = ?'; + $item = $ItemStr.' = ?'; } } $return[] = $data; @@ -185,7 +190,7 @@ public function setItemTerm($arr, $ItemStr) if (count($arr) > 1) { // FIXME 多分この rtrim の使い方は不適切(偶然動作しそうだが) - $item = '(' . rtrim($item, ' OR ') . ')'; + $item = '('.rtrim($item, ' OR ').')'; } $this->setWhere($item); @@ -197,11 +202,12 @@ public function setItemTerm($arr, $ItemStr) * * @param array $arr * @param string $ItemStr + * * @return array */ public function setItemTermWithNull($arr, $ItemStr) { - $return = array(); + $return = []; $item = " {$ItemStr} IS NULL "; if ($arr) { @@ -221,20 +227,23 @@ public function setItemTermWithNull($arr, $ItemStr) /** * NULLもしくは''で検索する場合 + * * @deprecated 本体で使用していないため非推奨 */ public function setItemTermWithNullAndSpace($arr, $ItemStr) { - $return = array(); + $return = []; $count = count($arr); $item = " {$ItemStr} IS NULL OR {$ItemStr} = '' "; $i = 1; if ($arr) { foreach ($arr as $data) { - if ($i == $count) break; + if ($i == $count) { + break; + } $item .= " OR {$ItemStr} = ?"; $return[] = $data; - $i ++; + $i++; } } $item = "({$item}) "; @@ -246,7 +255,7 @@ public function setItemTermWithNullAndSpace($arr, $ItemStr) /** * 複数のカラムでORで優先検索する場合 例: AND ( item_flag1 = xxx OR item_flag2 = xxx OR item_flag3 = xxx) AND ... * - * 配列の構造例  + * 配列の構造例 * if ($_POST['show_site1']) $arrShowsite_1 = array('column' => 'show_site1', * 'value' => $_POST['show_site1']); * @@ -259,16 +268,16 @@ public function setWhereByOR($arrWhere) for ($i = 0; $i < $count; $i++) { if (isset($arrWhere[$i]['value'])) { - $statement .= $arrWhere[$i]['column'] .' = ' . SC_Utils_Ex::sfQuoteSmart($arrWhere[$i]['value']) .' OR '; + $statement .= $arrWhere[$i]['column'].' = '.SC_Utils_Ex::sfQuoteSmart($arrWhere[$i]['value']).' OR '; } } - $statement = '(' . rtrim($statement, ' OR ') . ')'; + $statement = '('.rtrim($statement, ' OR ').')'; if ($this->where) { - $this->where .= ' AND ' . $statement; + $this->where .= ' AND '.$statement; } else { - $this->where = 'WHERE ' . $statement; + $this->where = 'WHERE '.$statement; } } @@ -276,7 +285,9 @@ public function setWhereByOR($arrWhere) * WHERE を取得する。 * * ヘンテコセッター互換仕様。 + * * @param $with_where boolean 必要に応じて WHERE を前置するか + * * @return string WHERE */ public function getWhere($with_where = false) @@ -297,9 +308,9 @@ public function setWhere($where) { if ($where != '') { if ($this->where) { - $this->where .= ' AND ' . $where; + $this->where .= ' AND '.$where; } else { - $this->where = 'WHERE ' . $where; + $this->where = 'WHERE '.$where; } } } @@ -309,7 +320,7 @@ public function setWhere($where) */ public function setOrder($order) { - $this->order = 'ORDER BY ' . $order; + $this->order = 'ORDER BY '.$order; } /** @@ -317,7 +328,7 @@ public function setOrder($order) */ public function setGroup($group) { - $this->group = 'GROUP BY ' . $group; + $this->group = 'GROUP BY '.$group; } /** diff --git a/data/class/SC_SendMail.php b/data/class/SC_SendMail.php index 70c9228820..e8aa371a81 100644 --- a/data/class/SC_SendMail.php +++ b/data/class/SC_SendMail.php @@ -52,7 +52,7 @@ class SC_SendMail */ public function __construct() { - $this->arrRecip = array(); + $this->arrRecip = []; $this->to = ''; $this->subject = ''; $this->body = ''; @@ -65,8 +65,8 @@ public function __construct() $this->port = SMTP_PORT; // PEAR::Mailを使ってメール送信オブジェクト作成 - $this->objMail =& Mail::factory($this->backend, - $this->getBackendParams($this->backend)); + $this->objMail = &Mail::factory($this->backend, + $this->getBackendParams($this->backend)); if (PEAR::isError($this->objMail)) { // XXX 環境によっては文字エンコードに差異がないか些か心配 trigger_error($this->objMail->getMessage(), E_USER_ERROR); @@ -146,7 +146,7 @@ public function setReturnPath($return_path) public function setSubject($subject) { $this->subject = mb_encode_mimeheader($subject, 'ISO-2022-JP-MS', 'B', "\n"); - $this->subject = str_replace(array("\r\n", "\r"), "\n", $this->subject); + $this->subject = str_replace(["\r\n", "\r"], "\n", $this->subject); } // 本文の設定 @@ -154,7 +154,7 @@ public function setBody($body) { // iso-2022-jpだと特殊文字が?で送信されるのでISO-2022-JP-MSを使用する $this->body = mb_convert_encoding($body, 'ISO-2022-JP-MS', CHAR_CODE); - $this->body = str_replace(array("\r\n", "\r"), "\n", $this->body); + $this->body = str_replace(["\r\n", "\r"], "\n", $this->body); } /** @@ -166,12 +166,12 @@ public function setHost($host) { trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); $this->host = $host; - $arrHost = array( + $arrHost = [ 'host' => $this->host, 'port' => $this->port - ); + ]; // PEAR::Mailを使ってメール送信オブジェクト作成 - $this->objMail =& Mail::factory('smtp', $arrHost); + $this->objMail = &Mail::factory('smtp', $arrHost); } /** @@ -183,12 +183,12 @@ public function setPort($port) { trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); $this->port = $port; - $arrHost = array( + $arrHost = [ 'host' => $this->host, 'port' => $this->port - ); + ]; // PEAR::Mailを使ってメール送信オブジェクト作成 - $this->objMail =& Mail::factory('smtp', $arrHost); + $this->objMail = &Mail::factory('smtp', $arrHost); } // 名前<メールアドレス>の形式を生成 @@ -198,25 +198,25 @@ public function setPort($port) */ public function getNameAddress($name, $mail_address) { - if ($name != '') { - // 制御文字を変換する。 - $_name = $name; - $_name = mb_encode_mimeheader($_name, 'ISO-2022-JP-MS', 'B', "\n"); - $_name = str_replace('"', '\"', $_name); - $name_address = sprintf('"%s" <%s>', $_name, $mail_address); - } else { - $name_address = $mail_address; - } - - return $name_address; + if ($name != '') { + // 制御文字を変換する。 + $_name = $name; + $_name = mb_encode_mimeheader($_name, 'ISO-2022-JP-MS', 'B', "\n"); + $_name = str_replace('"', '\"', $_name); + $name_address = sprintf('"%s" <%s>', $_name, $mail_address); + } else { + $name_address = $mail_address; + } + + return $name_address; } - public function setItem($to, $subject, $body, $fromaddress, $from_name, $reply_to='', $return_path='', $errors_to='', $bcc='', $cc ='') + public function setItem($to, $subject, $body, $fromaddress, $from_name, $reply_to = '', $return_path = '', $errors_to = '', $bcc = '', $cc = '') { $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); } - public function setItemHtml($to, $subject, $body, $fromaddress, $from_name, $reply_to='', $return_path='', $errors_to='', $bcc='', $cc ='') + public function setItemHtml($to, $subject, $body, $fromaddress, $from_name, $reply_to = '', $return_path = '', $errors_to = '', $bcc = '', $cc = '') { $this->setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to, $return_path, $errors_to, $bcc, $cc); } @@ -233,7 +233,7 @@ public function setItemHtml($to, $subject, $body, $fromaddress, $from_name, $rep $cc -> カーボンコピー $bcc -> ブラインドカーボンコピー */ - public function setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to='', $return_path='', $errors_to='', $bcc='', $cc ='') + public function setBase($to, $subject, $body, $fromaddress, $from_name, $reply_to = '', $return_path = '', $errors_to = '', $bcc = '', $cc = '') { // 宛先設定 $this->setTo($to); @@ -264,7 +264,7 @@ public function setBase($to, $subject, $body, $fromaddress, $from_name, $reply_t public function getBaseHeader() { // 送信するメールの内容と送信先 - $arrHeader = array(); + $arrHeader = []; $arrHeader['MIME-Version'] = '1.0'; $arrHeader['To'] = $this->to; $arrHeader['Subject'] = $this->subject; @@ -327,7 +327,7 @@ public function getRecip() * * 設定された情報を利用して, メールを送信する. * - * @return boolean + * @return bool */ public function sendMail($isHtml = false) { @@ -338,7 +338,7 @@ public function sendMail($isHtml = false) if (PEAR::isError($result)) { // XXX Windows 環境では SJIS でメッセージを受け取るようなので変換する。 $msg = mb_convert_encoding($result->getMessage(), CHAR_CODE, 'auto'); - $msg = 'メール送信に失敗しました。[' . $msg . ']'; + $msg = 'メール送信に失敗しました。['.$msg.']'; trigger_error($msg, E_USER_WARNING); GC_Utils_Ex::gfPrintLog($result->getMessage()); GC_Utils_Ex::gfDebugLog($header); @@ -352,7 +352,7 @@ public function sendMail($isHtml = false) /** * HTMLメール送信を実行する. * - * @return boolean + * @return bool */ public function sendHtmlMail() { @@ -363,32 +363,33 @@ public function sendHtmlMail() * メーラーバックエンドに応じたパラメーターを返す. * * @param string $backend Pear::Mail のバックエンド + * * @return array メーラーバックエンドに応じたパラメーターの配列 */ public function getBackendParams($backend) { switch ($backend) { case 'mail': - $arrParams = array(); + $arrParams = []; $objDb = new SC_Helper_DB_Ex(); $objSite = $objDb->sfGetBasisData(); if (!empty($objSite['email04']) && strpos($objSite['email04'], '@') > 0) { - $arrParams[] = "-f ".$objSite['email04']; + $arrParams[] = '-f '.$objSite['email04']; } break; case 'sendmail': - $arrParams = array( + $arrParams = [ 'sendmail_path' => '/usr/bin/sendmail', 'sendmail_args' => '-i', - ); + ]; break; case 'smtp': - $arrParams = array( + $arrParams = [ 'host' => $this->host, 'port' => $this->port, - ); + ]; if (defined('SMTP_USER') && defined('SMTP_PASSWORD') && !SC_Utils_Ex::isBlank(SMTP_USER) @@ -400,7 +401,7 @@ public function getBackendParams($backend) break; default: - trigger_error('不明なバックエンド。[$backend = ' . var_export($backend, true) . ']', E_USER_ERROR); + trigger_error('不明なバックエンド。[$backend = '.var_export($backend, true).']', E_USER_ERROR); exit; } diff --git a/data/class/SC_Session.php b/data/class/SC_Session.php index e5b9dbc42d..910e7a4339 100644 --- a/data/class/SC_Session.php +++ b/data/class/SC_Session.php @@ -49,12 +49,12 @@ public function __construct() if (isset($_SESSION['cert'])) { $this->sid = substr(sha1(session_id()), 0, 8); $this->cert = $_SESSION['cert']; - $this->login_id = $_SESSION['login_id']; + $this->login_id = $_SESSION['login_id']; // 管理者:0, 店舗オーナー:1, 閲覧:2, 販売担当:3 (XXX 現状 0, 1 を暫定実装。2, 3 は未実装。) $this->authority = $_SESSION['authority']; $this->member_id = $_SESSION['member_id']; if (isset($_SESSION['uniq_id'])) { - $this->uniqid = $_SESSION['uniq_id']; + $this->uniqid = $_SESSION['uniq_id']; } // ログに記録する @@ -64,6 +64,7 @@ public function __construct() GC_Utils_Ex::gfPrintLog('access error.'); } } + /* 認証成功の判定 */ public function IsSuccess($admin_dir = ADMIN_DIR) { @@ -94,6 +95,7 @@ public function IsSuccess($admin_dir = ADMIN_DIR) } } } + return SUCCESS; } @@ -168,6 +170,7 @@ public static function regenerateSID() if (session_status() === PHP_SESSION_ACTIVE) { return session_regenerate_id(true); } + return false; } } diff --git a/data/class/SC_SessionFactory.php b/data/class/SC_SessionFactory.php index d5b4bd72a4..7f90c10d51 100644 --- a/data/class/SC_SessionFactory.php +++ b/data/class/SC_SessionFactory.php @@ -37,8 +37,8 @@ * $sessionFactory = SC_SessionFactory::getInstance() * $sessionFactory->initSession(); * - * @package SC_Session * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_SessionFactory @@ -57,21 +57,21 @@ public static function getInstance() switch ($type) { // セッションの維持にリクエストパラメーターを使用する case 'useRequest': - $session = new SC_SessionFactory_UseRequest_Ex; + $session = new SC_SessionFactory_UseRequest_Ex(); SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE ? $session->setState('mobile') : $session->setState('pc'); break; - // クッキーを使用する + // クッキーを使用する case 'useCookie': default: // モバイルの場合はSC_SessionFactory_UseRequestを使用する if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { - $session = new SC_SessionFactory_UseRequest_Ex; + $session = new SC_SessionFactory_UseRequest_Ex(); $session->setState('mobile'); } else { - $session = new SC_SessionFactory_UseCookie_Ex; + $session = new SC_SessionFactory_UseCookie_Ex(); } break; } @@ -81,7 +81,6 @@ public static function getInstance() /** * セッションの初期化を行う. - * */ public function initSession() { @@ -90,7 +89,7 @@ public function initSession() /** * Cookieを使用するかどうかを返す. * - * @return boolean|null + * @return bool|null */ public function useCookie() { diff --git a/data/class/SC_SmartphoneUserAgent.php b/data/class/SC_SmartphoneUserAgent.php index 22b8ea1f65..388a8da411 100644 --- a/data/class/SC_SmartphoneUserAgent.php +++ b/data/class/SC_SmartphoneUserAgent.php @@ -34,7 +34,7 @@ class SC_SmartphoneUserAgent * スマートフォンかどうかを判別する。 * $_SESSION['pc_disp'] = true の場合はPC表示。 * - * @return boolean + * @return bool */ public static function isSmartphone() { @@ -47,7 +47,7 @@ public static function isSmartphone() /** * スマートフォンかどうかを判別する。 * - * @return boolean + * @return bool */ public static function isNonSmartphone() { diff --git a/data/class/SC_UploadFile.php b/data/class/SC_UploadFile.php index c7c8547aac..4bc7b11658 100644 --- a/data/class/SC_UploadFile.php +++ b/data/class/SC_UploadFile.php @@ -28,34 +28,34 @@ class SC_UploadFile public $save_dir; /** ファイルinputタグのname */ - public $keyname = array(); + public $keyname = []; /** 横サイズ */ - public $width = array(); + public $width = []; /** 縦サイズ */ - public $height = array(); + public $height = []; /** 指定する拡張子 */ - public $arrExt = array(); + public $arrExt = []; /** 保存されたファイル名 */ - public $temp_file = array(); + public $temp_file = []; /** DBから読み出したファイル名 */ - public $save_file = array(); + public $save_file = []; /** 項目名 */ - public $disp_name = array(); + public $disp_name = []; /** 制限サイズ */ - public $size = array(); + public $size = []; /** 必須の場合:true */ - public $necessary = array(); + public $necessary = []; /** 画像の場合:true */ - public $image = array(); + public $image = []; /** @var int */ public $file_max; @@ -63,13 +63,13 @@ class SC_UploadFile // ファイル管理クラス public function __construct($temp_dir, $save_dir) { - $this->temp_dir = rtrim($temp_dir, '/') . '/'; - $this->save_dir = rtrim($save_dir, '/') . '/'; + $this->temp_dir = rtrim($temp_dir, '/').'/'; + $this->save_dir = rtrim($save_dir, '/').'/'; $this->file_max = 0; } // ファイル情報追加 - public function addFile($disp_name, $keyname, $arrExt, $size, $necessary=false, $width=0, $height=0, $image=true) + public function addFile($disp_name, $keyname, $arrExt, $size, $necessary = false, $width = 0, $height = 0, $image = true) { $this->disp_name[] = $disp_name; $this->keyname[] = $keyname; @@ -102,7 +102,7 @@ public function makeThumb($src_file, $width, $height, $dst_file) // アップロードされたファイルを保存する。 /** - * @param boolean $rename + * @param bool $rename */ public function makeTempFile($keyname, $rename = IMAGE_RENAME) { @@ -114,9 +114,9 @@ public function makeTempFile($keyname, $rename = IMAGE_RENAME) // 一致したキーのファイルに情報を保存する。 if ($val == $keyname) { // 拡張子チェック - $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->arrExt[$cnt]), array('FILE_EXT_CHECK')); + $objErr->doFunc([$this->disp_name[$cnt], $keyname, $this->arrExt[$cnt]], ['FILE_EXT_CHECK']); // ファイルサイズチェック - $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->size[$cnt]), array('FILE_SIZE_CHECK')); + $objErr->doFunc([$this->disp_name[$cnt], $keyname, $this->size[$cnt]], ['FILE_SIZE_CHECK']); // エラーがない場合 if (!isset($objErr->arrErr[$keyname])) { // 画像ファイルの場合 @@ -128,16 +128,16 @@ public function makeTempFile($keyname, $rename = IMAGE_RENAME) } else { // 一意なファイル名を作成する。 if ($rename) { - $uniqname = date('mdHi') . '_' . uniqid('').'.'; + $uniqname = date('mdHi').'_'.uniqid('').'.'; $this->temp_file[$cnt] = preg_replace("/^.*\./", $uniqname, $_FILES[$keyname]['name']); } else { $this->temp_file[$cnt] = $_FILES[$keyname]['name']; } - if (move_uploaded_file($_FILES[$keyname]['tmp_name'], $this->temp_dir . $this->temp_file[$cnt])) { - GC_Utils_Ex::gfPrintLog($_FILES[$keyname]['name'].' -> '. $this->temp_dir . $this->temp_file[$cnt]); + if (move_uploaded_file($_FILES[$keyname]['tmp_name'], $this->temp_dir.$this->temp_file[$cnt])) { + GC_Utils_Ex::gfPrintLog($_FILES[$keyname]['name'].' -> '.$this->temp_dir.$this->temp_file[$cnt]); } else { $objErr->arrErr[$keyname] = '※ ファイルのアップロードに失敗しました。
'; - GC_Utils_Ex::gfPrintLog('File Upload Error!: ' . $_FILES[$keyname]['name'].' -> '. $this->temp_dir . $this->temp_file[$cnt]); + GC_Utils_Ex::gfPrintLog('File Upload Error!: '.$_FILES[$keyname]['name'].' -> '.$this->temp_dir.$this->temp_file[$cnt]); } } } @@ -150,7 +150,7 @@ public function makeTempFile($keyname, $rename = IMAGE_RENAME) } // アップロードされたダウンロードファイルを保存する。 - public function makeTempDownFile($keyname='down_file') + public function makeTempDownFile($keyname = 'down_file') { $objErr = new SC_CheckError_Ex(); $cnt = 0; @@ -160,16 +160,16 @@ public function makeTempDownFile($keyname='down_file') // 一致したキーのファイルに情報を保存する。 if ($val == $keyname) { // 拡張子チェック - $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->arrExt[$cnt]), array('FILE_EXT_CHECK')); + $objErr->doFunc([$this->disp_name[$cnt], $keyname, $this->arrExt[$cnt]], ['FILE_EXT_CHECK']); // ファイルサイズチェック - $objErr->doFunc(array($this->disp_name[$cnt], $keyname, $this->size[$cnt]), array('FILE_SIZE_CHECK')); + $objErr->doFunc([$this->disp_name[$cnt], $keyname, $this->size[$cnt]], ['FILE_SIZE_CHECK']); // エラーがない場合 if (!isset($objErr->arrErr[$keyname])) { // 一意なファイル名を作成する。 - $uniqname = date('mdHi') . '_' . uniqid('').'.'; + $uniqname = date('mdHi').'_'.uniqid('').'.'; $this->temp_file[$cnt] = preg_replace("/^.*\./", $uniqname, $_FILES[$keyname]['name']); - $result = copy($_FILES[$keyname]['tmp_name'], $this->temp_dir . $this->temp_file[$cnt]); - GC_Utils_Ex::gfPrintLog($result.' -> '. $this->temp_dir . $this->temp_file[$cnt]); + $result = copy($_FILES[$keyname]['tmp_name'], $this->temp_dir.$this->temp_file[$cnt]); + GC_Utils_Ex::gfPrintLog($result.' -> '.$this->temp_dir.$this->temp_file[$cnt]); SC_Utils_Ex::extendTimeOut(); } } @@ -213,7 +213,7 @@ public function deleteKikakuFile($keyname) $objImage->deleteImage($this->temp_file[$cnt], $this->temp_dir); } $this->temp_file[$cnt] = ''; - //$this->save_file[$cnt] = ''; + // $this->save_file[$cnt] = ''; } $cnt++; } @@ -231,7 +231,7 @@ public function getTempFilePath($keyname) foreach ($this->keyname as $val) { if ($val == $keyname) { if ($this->temp_file[$cnt] != '') { - $filepath = $this->temp_dir . $this->temp_file[$cnt]; + $filepath = $this->temp_dir.$this->temp_file[$cnt]; } } $cnt++; @@ -282,13 +282,13 @@ public function moveTempDownFile() public function getHiddenFileList() { $cnt = 0; - $arrRet = array(); + $arrRet = []; foreach ($this->keyname as $val) { if (isset($this->temp_file[$cnt])) { - $arrRet['temp_' . $val] = $this->temp_file[$cnt]; + $arrRet['temp_'.$val] = $this->temp_file[$cnt]; } if (isset($this->save_file[$cnt]) && $this->save_file[$cnt] != '') { - $arrRet['save_' . $val] = $this->save_file[$cnt]; + $arrRet['save_'.$val] = $this->save_file[$cnt]; } $cnt++; } @@ -301,11 +301,11 @@ public function setHiddenFileList($arrPOST) { $cnt = 0; foreach ($this->keyname as $val) { - $key = 'temp_' . $val; + $key = 'temp_'.$val; if (isset($arrPOST[$key]) && !empty($arrPOST[$key])) { $this->temp_file[$cnt] = $arrPOST[$key]; } - $key = 'save_' . $val; + $key = 'save_'.$val; if (isset($arrPOST[$key]) && !empty($arrPOST[$key])) { $this->save_file[$cnt] = $arrPOST[$key]; } @@ -320,11 +320,11 @@ public function setHiddenKikakuFileList($arrPOST) { $cnt = 0; foreach ($this->keyname as $val) { - $key = 'temp_' . $val; + $key = 'temp_'.$val; if (isset($arrPOST[$key])) { $this->temp_file[$cnt] = $arrPOST[$key]; } - $key = 'save_' . $val; + $key = 'save_'.$val; if (isset($arrPOST[$key]) && !empty($arrPOST[$key])) { $this->save_file[$cnt] = $arrPOST[$key]; } @@ -335,26 +335,26 @@ public function setHiddenKikakuFileList($arrPOST) // フォームに渡す用のファイル情報配列を返す public function getFormFileList($temp_url = null, $save_url = null, $real_size = false) { - $arrRet = array(); + $arrRet = []; $cnt = 0; foreach ($this->keyname as $val) { if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != '') { $real_filepath = - $arrRet[$val]['real_filepath'] = $this->temp_dir . $this->temp_file[$cnt]; + $arrRet[$val]['real_filepath'] = $this->temp_dir.$this->temp_file[$cnt]; if (is_null($temp_url)) { - $arrRet[$val]['filepath'] = ROOT_URLPATH . substr($real_filepath, strlen(HTML_REALDIR)); + $arrRet[$val]['filepath'] = ROOT_URLPATH.substr($real_filepath, strlen(HTML_REALDIR)); } else { // パスのスラッシュ/が連続しないようにする。 - $arrRet[$val]['filepath'] = rtrim($temp_url, '/') . '/' . $this->temp_file[$cnt]; + $arrRet[$val]['filepath'] = rtrim($temp_url, '/').'/'.$this->temp_file[$cnt]; } } elseif (isset($this->save_file[$cnt]) && $this->save_file[$cnt] != '') { $real_filepath = - $arrRet[$val]['real_filepath'] = $this->save_dir . $this->save_file[$cnt]; + $arrRet[$val]['real_filepath'] = $this->save_dir.$this->save_file[$cnt]; if (is_null($save_url)) { - $arrRet[$val]['filepath'] = ROOT_URLPATH . substr($real_filepath, strlen(HTML_REALDIR)); + $arrRet[$val]['filepath'] = ROOT_URLPATH.substr($real_filepath, strlen(HTML_REALDIR)); } else { // パスのスラッシュ/が連続しないようにする。 - $arrRet[$val]['filepath'] = rtrim($save_url, '/') . '/' . $this->save_file[$cnt]; + $arrRet[$val]['filepath'] = rtrim($save_url, '/').'/'.$this->save_file[$cnt]; } } if (isset($arrRet[$val]['filepath']) && !empty($arrRet[$val]['filepath'])) { @@ -403,7 +403,7 @@ public function getFormDownFile() */ public function getFormKikakuDownFile() { - $arrRet = array(); + $arrRet = []; $cnt = 0; foreach ($this->keyname as $val) { if (isset($this->temp_file[$cnt])) { @@ -421,7 +421,7 @@ public function getFormKikakuDownFile() public function getDBFileList() { $cnt = 0; - $dbFileList = array(); + $dbFileList = []; foreach ($this->keyname as $val) { if (isset($this->temp_file[$cnt]) && $this->temp_file[$cnt] != '') { $dbFileList[$val] = $this->temp_file[$cnt]; @@ -460,9 +460,9 @@ public function setDBDownFile($arrVal) */ public function setPostFileList($arrPost) { - for ($cnt = 0;$cnt < count($this->keyname); $cnt++) { - if (isset($arrPost['temp_down_realfilename:' . ($cnt+1)])) { - $this->temp_file[$cnt] = $arrPost['temp_down_realfilename:' . ($cnt+1)]; + for ($cnt = 0; $cnt < count($this->keyname); $cnt++) { + if (isset($arrPost['temp_down_realfilename:'.($cnt + 1)])) { + $this->temp_file[$cnt] = $arrPost['temp_down_realfilename:'.($cnt + 1)]; } } } @@ -516,17 +516,21 @@ public function deleteDBDownFile($arrVal) public function checkExists($keyname = '') { $cnt = 0; - $arrRet = array(); + $arrRet = []; foreach ($this->keyname as $val) { if ($val == $keyname || $keyname == '') { // 必須であればエラーチェック if ($this->necessary[$cnt] == true) { - if (!isset($this->save_file[$cnt])) $this->save_file[$cnt] = ''; - if (!isset($this->temp_file[$cnt])) $this->temp_file[$cnt] = ''; + if (!isset($this->save_file[$cnt])) { + $this->save_file[$cnt] = ''; + } + if (!isset($this->temp_file[$cnt])) { + $this->temp_file[$cnt] = ''; + } if ($this->save_file[$cnt] == '' && $this->temp_file[$cnt] == '' ) { - $arrRet[$val] = '※ ' . $this->disp_name[$cnt] . 'がアップロードされていません。
'; + $arrRet[$val] = '※ '.$this->disp_name[$cnt].'がアップロードされていません。
'; } } } @@ -547,7 +551,7 @@ public function saveResizeImage($keyname, $to_w, $to_h) // keynameの添付ファイルを取得 $arrImageKey = array_flip($this->keyname); $file = $this->temp_file[$arrImageKey[$keyname]]; - $filepath = $this->temp_dir . $file; + $filepath = $this->temp_dir.$file; $path = $this->makeThumb($filepath, $to_w, $to_h, ''); @@ -560,19 +564,20 @@ public function saveResizeImage($keyname, $to_w, $to_h) * * @param string $rename * @param int $keyname + * * @return string */ public function lfGetTmpImageName($rename, $keyname = '', $uploadfile = '') { if ($rename === true) { // 一意なIDを取得し、画像名をリネームし保存 - $uniqname = date('mdHi') . '_' . uniqid(''); + $uniqname = date('mdHi').'_'.uniqid(''); } else { // アップロードした画像名で保存 $uploadfile = strlen($uploadfile) > 0 ? $uploadfile : $_FILES[$keyname]['name']; - $uniqname = preg_replace('/(.+)\.(.+?)$/', '$1', $uploadfile); + $uniqname = preg_replace('/(.+)\.(.+?)$/', '$1', $uploadfile); } - $dst_file = $this->temp_dir . $uniqname; + $dst_file = $this->temp_dir.$uniqname; return $dst_file; } @@ -582,7 +587,8 @@ public function lfGetTmpImageName($rename, $keyname = '', $uploadfile = '') * * @param string $keyname ファイルinputタグのname * @param SC_CheckError $objErr SC_CheckErrorインスタンス - * @return boolean + * + * @return bool */ public function checkUploadError($keyname, SC_CheckError &$objErr) { @@ -594,23 +600,23 @@ public function checkUploadError($keyname, SC_CheckError &$objErr) break; case UPLOAD_ERR_NO_FILE: $objErr->arrErr[$keyname] = '※ ' - . $this->disp_name[$index] - . 'が選択されていません。' - . '
'; + .$this->disp_name[$index] + .'が選択されていません。' + .'
'; break; case UPLOAD_ERR_INI_SIZE: $objErr->arrErr[$keyname] = '※ ' - . $this->disp_name[$index] - . 'のアップロードに失敗しました。' - . '(.htaccessファイルのphp_value upload_max_filesizeを調整してください)' - . '
'; + .$this->disp_name[$index] + .'のアップロードに失敗しました。' + .'(.htaccessファイルのphp_value upload_max_filesizeを調整してください)' + .'
'; break; default: $objErr->arrErr[$keyname] = '※ ' - . $this->disp_name[$index] - . 'のアップロードに失敗しました。' - . 'エラーコードは[' . $_FILES[$keyname]['error'] . ']です。' - . '
'; + .$this->disp_name[$index] + .'のアップロードに失敗しました。' + .'エラーコードは['.$_FILES[$keyname]['error'].']です。' + .'
'; break; } diff --git a/data/class/SC_View.php b/data/class/SC_View.php index 01f94f7a47..bab1244bc6 100644 --- a/data/class/SC_View.php +++ b/data/class/SC_View.php @@ -45,15 +45,15 @@ public function init() $this->_smarty->setLeftDelimiter(''); $this->_smarty->registerPlugin('modifier', 'sfDispDBDate', function ($dbdate, $time = true) { return SC_Utils_Ex::sfDispDBDate($dbdate, $time); }); - $this->_smarty->registerPlugin('modifier', 'sfGetErrorColor', array('SC_Utils_Ex', 'sfGetErrorColor')); - $this->_smarty->registerPlugin('modifier', 'sfTrim', array('SC_Utils_Ex', 'sfTrim')); - $this->_smarty->registerPlugin('modifier', 'sfCalcIncTax', array('SC_Helper_DB_Ex', 'sfCalcIncTax')); - $this->_smarty->registerPlugin('modifier', 'sfPrePoint', array('SC_Utils_Ex', 'sfPrePoint')); - $this->_smarty->registerPlugin('modifier', 'sfGetChecked',array('SC_Utils_Ex', 'sfGetChecked')); - $this->_smarty->registerPlugin('modifier', 'sfTrimURL', array('SC_Utils_Ex', 'sfTrimURL')); - $this->_smarty->registerPlugin('modifier', 'sfMultiply', array('SC_Utils_Ex', 'sfMultiply')); - $this->_smarty->registerPlugin('modifier', 'sfRmDupSlash', array('SC_Utils_Ex', 'sfRmDupSlash')); - $this->_smarty->registerPlugin('modifier', 'sfCutString', array('SC_Utils_Ex', 'sfCutString')); + $this->_smarty->registerPlugin('modifier', 'sfGetErrorColor', ['SC_Utils_Ex', 'sfGetErrorColor']); + $this->_smarty->registerPlugin('modifier', 'sfTrim', ['SC_Utils_Ex', 'sfTrim']); + $this->_smarty->registerPlugin('modifier', 'sfCalcIncTax', ['SC_Helper_DB_Ex', 'sfCalcIncTax']); + $this->_smarty->registerPlugin('modifier', 'sfPrePoint', ['SC_Utils_Ex', 'sfPrePoint']); + $this->_smarty->registerPlugin('modifier', 'sfGetChecked', ['SC_Utils_Ex', 'sfGetChecked']); + $this->_smarty->registerPlugin('modifier', 'sfTrimURL', ['SC_Utils_Ex', 'sfTrimURL']); + $this->_smarty->registerPlugin('modifier', 'sfMultiply', ['SC_Utils_Ex', 'sfMultiply']); + $this->_smarty->registerPlugin('modifier', 'sfRmDupSlash', ['SC_Utils_Ex', 'sfRmDupSlash']); + $this->_smarty->registerPlugin('modifier', 'sfCutString', ['SC_Utils_Ex', 'sfCutString']); $this->_smarty->registerPlugin('function', 'from_to', 'smarty_function_from_to'); $this->_smarty->registerPlugin('function', 'include_php_ex', 'smarty_function_include_php_ex'); $this->_smarty->registerPlugin('modifier', 'h', 'smarty_modifier_h'); @@ -61,9 +61,9 @@ public function init() $this->_smarty->registerPlugin('modifier', 'nl2br_html', 'smarty_modifier_nl2br_html'); $this->_smarty->registerPlugin('modifier', 'script_escape', 'smarty_modifier_script_escape'); $this->_smarty->registerPlugin('modifier', 'u', 'smarty_modifier_u'); - $this->_smarty->registerPlugin('modifier', 'sfMbConvertEncoding', array('SC_Utils_Ex', 'sfMbConvertEncoding')); - $this->_smarty->registerPlugin('modifier', 'sfGetEnabled', array('SC_Utils_Ex', 'sfGetEnabled')); - $this->_smarty->registerPlugin('modifier', 'sfNoImageMainList', array('SC_Utils_Ex', 'sfNoImageMainList')); + $this->_smarty->registerPlugin('modifier', 'sfMbConvertEncoding', ['SC_Utils_Ex', 'sfMbConvertEncoding']); + $this->_smarty->registerPlugin('modifier', 'sfGetEnabled', ['SC_Utils_Ex', 'sfGetEnabled']); + $this->_smarty->registerPlugin('modifier', 'sfNoImageMainList', ['SC_Utils_Ex', 'sfNoImageMainList']); $this->_smarty->registerPlugin('modifier', 'file_exists', 'file_exists'); $this->_smarty->registerPlugin('modifier', 'function_exists', 'function_exists'); $this->_smarty->registerPlugin('modifier', 'preg_quote', 'preg_quote'); @@ -71,10 +71,10 @@ public function init() $this->_smarty->registerPlugin('modifier', 'php_uname', 'php_uname'); $this->_smarty->registerPlugin('modifier', 'array_key_exists', 'array_key_exists'); // XXX register_function で登録すると if で使用できないのではないか? - $this->_smarty->registerPlugin('function','sfIsHTTPS', array('SC_Utils_Ex', 'sfIsHTTPS')); - $this->_smarty->registerPlugin('function','sfSetErrorStyle', array('SC_Utils_Ex', 'sfSetErrorStyle')); - $this->_smarty->registerPlugin('function','printXMLDeclaration', array('GC_Utils_Ex', 'printXMLDeclaration')); - $this->_smarty->default_modifiers = array('script_escape'); + $this->_smarty->registerPlugin('function', 'sfIsHTTPS', ['SC_Utils_Ex', 'sfIsHTTPS']); + $this->_smarty->registerPlugin('function', 'sfSetErrorStyle', ['SC_Utils_Ex', 'sfSetErrorStyle']); + $this->_smarty->registerPlugin('function', 'printXMLDeclaration', ['GC_Utils_Ex', 'printXMLDeclaration']); + $this->_smarty->default_modifiers = ['script_escape']; if (ADMIN_MODE == '1') { $this->time_start = microtime(true); @@ -84,7 +84,7 @@ public function init() // 各filterをセットします. $this->registFilter(); // smarty:nodefaultsの後方互換を維持 - $this->_smarty->registerFilter('pre', array($this, 'lower_compatibility_smarty')); + $this->_smarty->registerFilter('pre', [$this, 'lower_compatibility_smarty']); } // テンプレートに値を割り当てる @@ -105,9 +105,12 @@ public function fetch($template) /** * SC_Display用にレスポンスを返す + * * @global string $GLOBAL_ERR + * * @param array $template - * @param boolean $no_error + * @param bool $no_error + * * @return string */ public function getResponse($template, $no_error = false) @@ -120,11 +123,11 @@ public function getResponse($template, $no_error = false) define('OUTPUT_ERR', 'ON'); } } - $res = $this->_smarty->fetch($template); + $res = $this->_smarty->fetch($template); if (ADMIN_MODE == '1') { $time_end = microtime(true); $time = $time_end - $this->time_start; - $res .= '処理時間: ' . sprintf('%.3f', $time) . '秒'; + $res .= '処理時間: '.sprintf('%.3f', $time).'秒'; } return $res; @@ -132,37 +135,42 @@ public function getResponse($template, $no_error = false) /** * Pageオブジェクトをセットします. + * * @param LC_Page_Ex $objPage + * * @return void */ public function setPage($objPage) { - $this->objPage = $objPage; + $this->objPage = $objPage; } /** * Smartyのfilterをセットします. + * * @return void */ public function registFilter() { - $this->_smarty->registerFilter('pre', array(&$this, 'prefilter_transform')); - $this->_smarty->registerFilter('output', array(&$this, 'outputfilter_transform')); + $this->_smarty->registerFilter('pre', [&$this, 'prefilter_transform']); + $this->_smarty->registerFilter('output', [&$this, 'outputfilter_transform']); } /** * prefilter用のフィルタ関数。プラグイン用のフックポイント処理を実行 + * * @param string $source ソース * @param \Smarty\Template $smarty Smartyのコンパイラクラス + * * @return string $source ソース */ - public function prefilter_transform($source, \Smarty\Template $template) + public function prefilter_transform($source, Smarty\Template $template) { if (!is_null($this->objPage)) { // フックポイントを実行. $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); if ($objPlugin) { - $objPlugin->doAction('prefilterTransform', array(&$source, $this->objPage, $this->getCurrentTemplateFile($template))); + $objPlugin->doAction('prefilterTransform', [&$source, $this->objPage, $this->getCurrentTemplateFile($template)]); } } @@ -171,17 +179,19 @@ public function prefilter_transform($source, \Smarty\Template $template) /** * outputfilter用のフィルタ関数。プラグイン用のフックポイント処理を実行 + * * @param string $source ソース * @param \Smarty\Template $smarty Smartyのコンパイラクラス + * * @return string $source ソース */ - public function outputfilter_transform($source, \Smarty\Template $template) + public function outputfilter_transform($source, Smarty\Template $template) { if (!is_null($this->objPage)) { // フックポイントを実行. $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); if ($objPlugin) { - $objPlugin->doAction('outputfilterTransform', array(&$source, $this->objPage, $this->getCurrentTemplateFile($template))); + $objPlugin->doAction('outputfilterTransform', [&$source, $this->objPage, $this->getCurrentTemplateFile($template)]); } } @@ -190,6 +200,7 @@ public function outputfilter_transform($source, \Smarty\Template $template) /** * テンプレートの処理結果を表示 + * * @param string $template * @param bool $no_error */ @@ -208,12 +219,13 @@ public function display($template, $no_error = false) if (ADMIN_MODE == '1') { $time_end = microtime(true); $time = $time_end - $this->time_start; - echo '処理時間: ' . sprintf('%.3f', $time) . '秒'; + echo '処理時間: '.sprintf('%.3f', $time).'秒'; } } /** * オブジェクト内の変数を全て割り当てる。 + * * @param object $obj */ public function assignobj($obj) @@ -227,6 +239,7 @@ public function assignobj($obj) /** * 連想配列内の変数を全て割り当てる。 + * * @param array $array */ public function assignarray($array) @@ -239,7 +252,7 @@ public function assignarray($array) /** * テンプレートパスをアサインする. * - * @param integer $device_type_id 端末種別ID + * @param int $device_type_id 端末種別ID */ public function assignTemplatePath($device_type_id) { @@ -248,8 +261,8 @@ public function assignTemplatePath($device_type_id) // ヘッダとフッタを割り当て $templatePath = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id); - $header_tpl = $templatePath . 'header.tpl'; - $footer_tpl = $templatePath . 'footer.tpl'; + $header_tpl = $templatePath.'header.tpl'; + $footer_tpl = $templatePath.'footer.tpl'; $this->assign('header_tpl', $header_tpl); $this->assign('footer_tpl', $footer_tpl); @@ -257,6 +270,7 @@ public function assignTemplatePath($device_type_id) /** * デバッグ + * * @param bool $var */ public function debug($var = true) @@ -264,18 +278,18 @@ public function debug($var = true) $this->_smarty->debugging = $var; } - /** * 2.13のテンプレートのまま動作するためにsmartyの後方互換処理 * * @param mixed $tpl_source * @param mixed $smarty + * * @return array|string|null */ public function lower_compatibility_smarty($tpl_source, $smarty) { - $pattern = array("/\|smarty:nodefaults/", "/include_php /", "/=`(.+?)`/"); - $replace = array(' ', 'include_php_ex ', "=$1"); + $pattern = ["/\|smarty:nodefaults/", '/include_php /', '/=`(.+?)`/']; + $replace = [' ', 'include_php_ex ', '=$1']; return preg_replace($pattern, $replace, $tpl_source); } @@ -291,11 +305,13 @@ public function lower_compatibility_smarty($tpl_source, $smarty) * この関数は 2.13 と同様にテンプレートディレクトリからの相対パスを返す * * @param Smarty_Internal_Template $template + * * @return string 現在のテンプレートファイルパス */ - public function getCurrentTemplateFile(\Smarty\Template $template) + public function getCurrentTemplateFile(Smarty\Template $template) { $current_file = str_replace($template->getSmarty()->getTemplateDir(), '', $template->getSource()->getFilepath()); + return str_replace('\\', '/', $current_file); // Windows 向けにパスの区切り文字を正規化する } } diff --git a/data/class/api/SC_Api_Abstract.php b/data/class/api/SC_Api_Abstract.php index ddb6a05e2b..f374c1bc23 100644 --- a/data/class/api/SC_Api_Abstract.php +++ b/data/class/api/SC_Api_Abstract.php @@ -24,25 +24,24 @@ /** * APIの抽象クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - abstract class SC_Api_Abstract { /** 認証タイプ */ - const API_AUTH_TYPE_REFERER = '1'; // リファラー - const API_AUTH_TYPE_SESSION_TOKEN = '2'; // CSRF TOKEN - const API_AUTH_TYPE_API_SIGNATURE = '3'; // API 署名認証 推奨 - const API_AUTH_TYPE_CUSTOMER = '4'; // 会員認証 - const API_AUTH_TYPE_MEMBER = '5'; // 管理者認証 - const API_AUTH_TYPE_CUSTOMER_LOGIN_SESSION = '6'; // 顧客ログインセッションが有効 - const API_AUTH_TYPE_MEMBER_LOGIN_SESSION = '7'; // 管理者ログインセッションが有効 - const API_AUTH_TYPE_IP = '8'; // IP認証 - const API_AUTH_TYPE_HOST = '9'; // ホスト認証 - const API_AUTH_TYPE_SSL = '10'; // SSL強制 - const API_AUTH_TYPE_OPEN = '99'; // 完全オープン + public const API_AUTH_TYPE_REFERER = '1'; // リファラー + public const API_AUTH_TYPE_SESSION_TOKEN = '2'; // CSRF TOKEN + public const API_AUTH_TYPE_API_SIGNATURE = '3'; // API 署名認証 推奨 + public const API_AUTH_TYPE_CUSTOMER = '4'; // 会員認証 + public const API_AUTH_TYPE_MEMBER = '5'; // 管理者認証 + public const API_AUTH_TYPE_CUSTOMER_LOGIN_SESSION = '6'; // 顧客ログインセッションが有効 + public const API_AUTH_TYPE_MEMBER_LOGIN_SESSION = '7'; // 管理者ログインセッションが有効 + public const API_AUTH_TYPE_IP = '8'; // IP認証 + public const API_AUTH_TYPE_HOST = '9'; // ホスト認証 + public const API_AUTH_TYPE_SSL = '10'; // SSL強制 + public const API_AUTH_TYPE_OPEN = '99'; // 完全オープン /** API Operation default */ protected $operation_name = 'operation_name'; @@ -53,8 +52,8 @@ abstract class SC_Api_Abstract protected $default_sub_data = ''; protected $status = true; - protected $arrErr = array(); - protected $arrResponse = array(); + protected $arrErr = []; + protected $arrResponse = []; /** @var SC_FormParam */ protected $objFormParam; @@ -87,7 +86,7 @@ public function getErrorArray() public function getDefaultConfig() { - $arrApiConfig = array(); + $arrApiConfig = []; $arrApiConfig['operation_name'] = $this->operation_name; $arrApiConfig['operation_description'] = $this->operation_description; $arrApiConfig['auth_types'] = $this->default_auth_types; @@ -120,7 +119,7 @@ protected function checkErrorExtended($arrParam) { } - protected function doInitParam($arrParam = array()) + protected function doInitParam($arrParam = []) { $this->objFormParam = new SC_FormParam_Ex(); $this->lfInitParam($this->objFormParam); diff --git a/data/class/api/SC_Api_Operation.php b/data/class/api/SC_Api_Operation.php index 5881bc2612..0019f9572f 100644 --- a/data/class/api/SC_Api_Operation.php +++ b/data/class/api/SC_Api_Operation.php @@ -26,44 +26,44 @@ * 権限チェックと設定チェックを行い、APIオペレーション本体を呼び出す。 * 結果データの生成 * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class SC_Api_Operation { /** API_DEBUG_MODE */ - const API_DEBUG_MODE = false; + public const API_DEBUG_MODE = false; /** 認証タイプ */ - const API_AUTH_TYPE_REFERER = '1'; // リファラー - const API_AUTH_TYPE_SESSION_TOKEN = '2'; // CSRF TOKEN - const API_AUTH_TYPE_API_SIGNATURE = '3'; // API 署名認証 推奨 - const API_AUTH_TYPE_CUSTOMER = '4'; // 会員認証 - const API_AUTH_TYPE_MEMBER = '5'; // 管理者認証 - const API_AUTH_TYPE_CUSTOMER_LOGIN_SESSION = '6'; // 顧客ログインセッションが有効 - const API_AUTH_TYPE_MEMBER_LOGIN_SESSION = '7'; // 管理者ログインセッションが有効 - const API_AUTH_TYPE_IP = '8'; // IP認証 - const API_AUTH_TYPE_HOST = '9'; // ホスト認証 - const API_AUTH_TYPE_SSL = '10'; // SSL強制 - const API_AUTH_TYPE_OPEN = '99'; // 完全オープン + public const API_AUTH_TYPE_REFERER = '1'; // リファラー + public const API_AUTH_TYPE_SESSION_TOKEN = '2'; // CSRF TOKEN + public const API_AUTH_TYPE_API_SIGNATURE = '3'; // API 署名認証 推奨 + public const API_AUTH_TYPE_CUSTOMER = '4'; // 会員認証 + public const API_AUTH_TYPE_MEMBER = '5'; // 管理者認証 + public const API_AUTH_TYPE_CUSTOMER_LOGIN_SESSION = '6'; // 顧客ログインセッションが有効 + public const API_AUTH_TYPE_MEMBER_LOGIN_SESSION = '7'; // 管理者ログインセッションが有効 + public const API_AUTH_TYPE_IP = '8'; // IP認証 + public const API_AUTH_TYPE_HOST = '9'; // ホスト認証 + public const API_AUTH_TYPE_SSL = '10'; // SSL強制 + public const API_AUTH_TYPE_OPEN = '99'; // 完全オープン /** * 有効な管理者ID/PASSかどうかチェックする * * @param string $member_id ログインID文字列 * @param string $member_password ログインパスワード文字列 - * @return boolean ログイン情報が有効な場合 true + * + * @return bool ログイン情報が有効な場合 true */ protected static function checkMemberAccount($member_id, $member_password) { $objQuery = SC_Query_Ex::getSingletonInstance(); - //パスワード、saltの取得 + // パスワード、saltの取得 $cols = 'password, salt'; $table = 'dtb_member'; $where = 'login_id = ? AND del_flg <> 1 AND work = 1'; - $arrData = $objQuery->getRow($cols, $table, $where, array($member_id)); + $arrData = $objQuery->getRow($cols, $table, $where, [$member_id]); if (SC_Utils_Ex::isBlank($arrData)) { return false; } @@ -80,7 +80,8 @@ protected static function checkMemberAccount($member_id, $member_password) * * @param string $login_email ログインメールアドレス * @param string $login_password ログインパスワード - * @return boolean ログインに成功した場合 true; 失敗した場合 false + * + * @return bool ログインに成功した場合 true; 失敗した場合 false */ protected static function checkCustomerAccount($login_email, $login_password) { @@ -95,17 +96,17 @@ protected static function checkCustomerAccount($login_email, $login_password) /** * リファラーチェックを実行する. * - * @return boolean チェックに成功した場合 true; 失敗した場合 false + * @return bool チェックに成功した場合 true; 失敗した場合 false */ protected static function checkReferer() { $ret = false; if (!SC_Utils_Ex::isBlank($_SERVER['HTTP_REFERER'])) { - $domain = SC_Utils_Ex::sfIsHTTPS() ? HTTPS_URL : HTTP_URL; + $domain = SC_Utils_Ex::sfIsHTTPS() ? HTTPS_URL : HTTP_URL; $pattern = sprintf('|^%s.*|', $domain); $referer = $_SERVER['HTTP_REFERER']; if (preg_match($pattern, $referer)) { - $ret = true; + $ret = true; } } @@ -118,7 +119,8 @@ protected static function checkReferer() * * @param string 実行処理名 * @param array リクエストパラメータ - * @return boolean 署名認証に成功した場合 true; 失敗した場合 false + * + * @return bool 署名認証に成功した場合 true; 失敗した場合 false */ protected static function checkApiSignature($operation_name, $arrParam, $arrApiConfig) { @@ -128,12 +130,12 @@ protected static function checkApiSignature($operation_name, $arrParam, $arrApiC if (SC_Utils_Ex::isBlank($arrParam['Timestamp'])) { return false; } -/* - $allow_account_id = SC_Api_Operation_Ex::getOperationSubConfig($operation_name, 'allow_account_id', $arrApiConfig); - if (!SC_Utils_Ex::isBlank($allow_account_id) and) { - $arrAllowAccountIds = explode('|', $allow_account_id); - } -*/ + /* + $allow_account_id = SC_Api_Operation_Ex::getOperationSubConfig($operation_name, 'allow_account_id', $arrApiConfig); + if (!SC_Utils_Ex::isBlank($allow_account_id) and) { + $arrAllowAccountIds = explode('|', $allow_account_id); + } + */ $access_key = $arrParam['AccessKeyId']; $secret_key = SC_Api_Operation_Ex::getApiSecretKey($access_key); @@ -152,15 +154,15 @@ protected static function checkApiSignature($operation_name, $arrParam, $arrApiC case 'Signature': break; default: - $check_str .= '&' . SC_Utils_Ex::encodeRFC3986($key) . '=' . SC_Utils_Ex::encodeRFC3986($val); + $check_str .= '&'.SC_Utils_Ex::encodeRFC3986($key).'='.SC_Utils_Ex::encodeRFC3986($val); break; } } $check_str = substr($check_str, 1); - $check_str = strtoupper($_SERVER['REQUEST_METHOD']) . "\n" - . strtolower($_SERVER['SERVER_NAME']) . "\n" - . $_SERVER['PHP_SELF'] . "\n" - . $check_str; + $check_str = strtoupper($_SERVER['REQUEST_METHOD'])."\n" + .strtolower($_SERVER['SERVER_NAME'])."\n" + .$_SERVER['PHP_SELF']."\n" + .$check_str; $signature = base64_encode(hash_hmac('sha256', $check_str, $secret_key, true)); if ($signature === $arrParam['Signature']) { return true; @@ -173,7 +175,8 @@ protected static function checkApiSignature($operation_name, $arrParam, $arrApiC * IPチェックを実行する. * * @param string 実行処理名 - * @return boolean チェックに成功した場合 true; 失敗した場合 false + * + * @return bool チェックに成功した場合 true; 失敗した場合 false */ protected static function checkIp($operation_name) { @@ -181,7 +184,7 @@ protected static function checkIp($operation_name) $allow_hosts = SC_Api_Utils_Ex::getOperationSubConfig($operation_name, 'allow_hosts'); $arrAllowHost = explode("\n", $allow_hosts); if (is_array($arrAllowHost) && count($arrAllowHost) > 0) { - if (array_search($_SERVER['REMOTE_ADDR'], $arrAllowHost) !== FALSE) { + if (array_search($_SERVER['REMOTE_ADDR'], $arrAllowHost) !== false) { $ret = true; } } @@ -201,12 +204,13 @@ protected static function checkHost($operation_name) * ApiAccessKeyに対応した秘密鍵を取得する。 * * @param string $access_key + * * @return string 秘密鍵文字列 */ protected static function getApiSecretKey($access_key) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $secret_key = $objQuery->get('api_secret_key', 'dtb_api_account', 'api_access_key = ? and enable = 1 and del_flg = 0', array($access_key)); + $secret_key = $objQuery->get('api_secret_key', 'dtb_api_account', 'api_access_key = ? and enable = 1 and del_flg = 0', [$access_key]); return $secret_key; } @@ -216,7 +220,8 @@ protected static function getApiSecretKey($access_key) * * @param string オペレーション名 * @param array リクエストパラメータ - * @return boolean 権限がある場合 true; 無い場合 false + * + * @return bool 権限がある場合 true; 無い場合 false */ protected static function checkOperationAuth($operation_name, &$arrParam, &$arrApiConfig) { @@ -282,21 +287,23 @@ protected static function checkOperationAuth($operation_name, &$arrParam, &$arrA * * @param object SC_FormParam * @param SC_FormParam_Ex $objFormParam + * * @return void */ protected static function setApiBaseParam(&$objFormParam) { - $objFormParam->addParam('Operation', 'Operation', STEXT_LEN, 'an', array('EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('Service', 'Service', STEXT_LEN, 'an', array('EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('Style', 'Style', STEXT_LEN, 'an', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('Validate', 'Validate', STEXT_LEN, 'an', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('Version', 'Version', STEXT_LEN, 'an', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('Operation', 'Operation', STEXT_LEN, 'an', ['EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('Service', 'Service', STEXT_LEN, 'an', ['EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('Style', 'Style', STEXT_LEN, 'an', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('Validate', 'Validate', STEXT_LEN, 'an', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('Version', 'Version', STEXT_LEN, 'an', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); } /** * API実行 * * @param array $arrPost リクエストパラメーター + * * @return array(string レスポンス名, array レスポンス配列) */ public static function doApiAction($arrPost) @@ -310,11 +317,11 @@ public static function doApiAction($arrPost) $objFormParam->convParam(); $arrErr = SC_Api_Operation_Ex::checkParam($objFormParam); - $arrOperationRequestValid = array(); + $arrOperationRequestValid = []; $operation_name = ''; $response_group_name = ''; $objApiOperation = null; - $arrResponseBody = array(); + $arrResponseBody = []; // API機能が有効であるかをチェック. if (API_ENABLE_FLAG == false) { $arrErr['ECCUBE.Function.Disable'] = 'API機能が無効です。'; @@ -345,7 +352,7 @@ public static function doApiAction($arrPost) // オペレーション結果処理 if ($operation_result) { $arrOperationRequestValid = $objApiOperation->getRequestValidate(); - $arrResponseBody = $objApiOperation->getResponseArray(); + $arrResponseBody = $objApiOperation->getResponseArray(); $response_group_name = $objApiOperation->getResponseGroupName(); } else { $arrErr = $objApiOperation->getErrorArray(); @@ -360,41 +367,41 @@ public static function doApiAction($arrPost) if (count($arrErr) == 0) { // 実行成功 - $arrResponseValidSection = array('Request' => array( + $arrResponseValidSection = ['Request' => [ 'IsValid' => 'True', - $operation_name . 'Request' => $arrOperationRequestValid - ) - ); - $response_outer = $operation_name . 'Response'; + $operation_name.'Request' => $arrOperationRequestValid + ] + ]; + $response_outer = $operation_name.'Response'; SC_Api_Utils_Ex::printApiLog('Operation SUCCESS', $start_time, $response_outer); } else { // 実行失敗 - $arrResponseErrorSection = array(); + $arrResponseErrorSection = []; foreach ($arrErr as $error_code => $error_msg) { - $arrResponseErrorSection[] = array('Code' => $error_code, 'Message' => $error_msg); + $arrResponseErrorSection[] = ['Code' => $error_code, 'Message' => $error_msg]; } - $arrResponseValidSection = array('Request' => array( + $arrResponseValidSection = ['Request' => [ 'IsValid' => 'False', - 'Errors' => array('Error' => $arrResponseErrorSection) - ) - ); + 'Errors' => ['Error' => $arrResponseErrorSection] + ] + ]; if (is_object($objApiOperation)) { - $response_outer = $operation_name . 'Response'; + $response_outer = $operation_name.'Response'; } else { $response_outer = 'ECCUBEApiCommonResponse'; } SC_Api_Utils_Ex::printApiLog('Operation FAILED', $start_time, $response_outer); } - $arrResponse = array(); + $arrResponse = []; $arrResponse['OperationRequest'] = SC_Api_Operation_Ex::getOperationRequestEcho($arrPost, $start_time); - $arrResponse[$response_group_name] = array(); // Items + $arrResponse[$response_group_name] = []; // Items $arrResponse[$response_group_name] = $arrResponseValidSection; if (is_array($arrResponseBody)) { $arrResponse[$response_group_name] = array_merge((array) $arrResponse[$response_group_name], (array) $arrResponseBody); } - return array($response_outer, $arrResponse); + return [$response_outer, $arrResponse]; } /** @@ -402,18 +409,19 @@ public static function doApiAction($arrPost) * * @param array $arrParam リクエストパラメーター * @param float $start_time 実行時間計測用開始時間 + * * @return array エコー情報配列 (XML用の _attributes 指定入り) */ protected static function getOperationRequestEcho($arrParam, $start_time) { - $arrRet = array( - 'HTTPHeaders' => array('Header' => array('_attributes' => array('Name' => 'UserAgent', - 'Value' => htmlspecialchars($_SERVER['HTTP_USER_AGENT'])))), + $arrRet = [ + 'HTTPHeaders' => ['Header' => ['_attributes' => ['Name' => 'UserAgent', + 'Value' => htmlspecialchars($_SERVER['HTTP_USER_AGENT'])]]], 'RequestId' => $start_time, - 'Arguments' => array(), - ); + 'Arguments' => [], + ]; foreach ($arrParam as $key => $val) { - $arrRet['Arguments'][] = array('_attributes' => array('Name' => htmlentities($key, ENT_NOQUOTES, 'UTF-8'), 'Value' => htmlentities($val, ENT_NOQUOTES, 'UTF-8'))); + $arrRet['Arguments'][] = ['_attributes' => ['Name' => htmlentities($key, ENT_NOQUOTES, 'UTF-8'), 'Value' => htmlentities($val, ENT_NOQUOTES, 'UTF-8')]]; } $arrRet['RequestProcessingTime'] = microtime(true) - $start_time; @@ -430,6 +438,7 @@ public static function sendApiResponse($type, $response_outer_name, &$arrRespons { if (API_ENABLE_FLAG == false) { http_response_code(403); + return; } switch ($type) { @@ -450,6 +459,7 @@ public static function sendApiResponse($type, $response_outer_name, &$arrRespons * APIのリクエスト基本パラメーターのチェック * * @param SC_FormParam_Ex $objFormParam + * * @return array $arrErr */ protected static function checkParam($objFormParam) @@ -470,6 +480,7 @@ protected static function checkParam($objFormParam) if (!preg_match("/^[a-zA-Z0-9\-\_\.]+$/", $objFormParam->getValue('Version')) && !SC_Utils::isBlank($objFormParam->getValue('Version'))) { $arrErr['ECCUBE.Version.ParamError'] = 'Versionの値が不正です。'; } + return $arrErr; } } diff --git a/data/class/api/SC_Api_Utils.php b/data/class/api/SC_Api_Utils.php index 5d5db21494..a39073a6b3 100644 --- a/data/class/api/SC_Api_Utils.php +++ b/data/class/api/SC_Api_Utils.php @@ -21,30 +21,30 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** +/* * API関係処理のユーティリティ * * @package Api * @author EC-CUBE CO.,LTD. * @version $Id$ */ -define('API_UPLOAD_REALDIR', DATA_REALDIR . 'downloads/api/'); -define('API_CLASS_EX_REALDIR', CLASS_EX_REALDIR . 'api_extends/operations/'); -define('API_CLASS_REALDIR', CLASS_REALDIR . 'api/operations/'); +define('API_UPLOAD_REALDIR', DATA_REALDIR.'downloads/api/'); +define('API_CLASS_EX_REALDIR', CLASS_EX_REALDIR.'api_extends/operations/'); +define('API_CLASS_REALDIR', CLASS_REALDIR.'api/operations/'); class SC_Api_Utils { /** API XML Namspase Header */ - const API_XMLNS = 'http://www.ec-cube.net/ECCUBEApi/'; + public const API_XMLNS = 'http://www.ec-cube.net/ECCUBEApi/'; /** API XML lang */ - const API_XML_LANG = 'ja'; + public const API_XML_LANG = 'ja'; /** API LOGFILE_NAME */ - const API_LOGFILE = 'logs/api.log'; + public const API_LOGFILE = 'logs/api.log'; /** API_DEBUG_MODE */ - const API_DEBUG_MODE = false; + public const API_DEBUG_MODE = false; /** * オペレーション名に対応した追加の設定情報を取得する @@ -58,7 +58,7 @@ public static function getOperationSubConfig($operation_name, $key_name = '', $a } if (!SC_Utils_Ex::isBlank($arrApiConfig['sub_data'])) { $arrData = @unserialize($arrApiConfig['sub_data']); - if ($arrData === FALSE) { + if ($arrData === false) { return $arrApiConfig['sub_data']; } else { if ($key_name != '') { @@ -77,6 +77,7 @@ public static function getOperationSubConfig($operation_name, $key_name = '', $a * Configが無い場合は、APIデフォルトを取得する * * @param string $operation_name + * * @return array 設定配列 */ public static function getApiConfig($operation_name) @@ -84,7 +85,7 @@ public static function getApiConfig($operation_name) // 設定優先度 DB > plugin default > base $objQuery = SC_Query_Ex::getSingletonInstance(); $where = 'operation_name Like ? AND del_flg = 0 AND enable = 1'; - $arrApiConfig = $objQuery->getRow('*', 'dtb_api_config', $where, array($operation_name)); + $arrApiConfig = $objQuery->getRow('*', 'dtb_api_config', $where, [$operation_name]); if (SC_Utils_Ex::isBlank($arrApiConfig)) { $objApi = SC_Api_Utils_Ex::loadApiOperation($operation_name); if (is_object($objApi)) { @@ -114,15 +115,15 @@ public static function getApiConfig($operation_name) * @param text $operation_name @ @rturn void */ - public static function printApiLog($msg, $start_time = '' , $operation_name = '') + public static function printApiLog($msg, $start_time = '', $operation_name = '') { if (!SC_Utils_Ex::isBlank($operation_name)) { - $msg = 'API_' . $operation_name . ':' . $msg; + $msg = 'API_'.$operation_name.':'.$msg; } if (!SC_Utils_Ex::isBlank($start_time)) { - $msg = '(RequestId:' . $start_time . ')' . $msg; + $msg = '(RequestId:'.$start_time.')'.$msg; } - GC_Utils_Ex::gfPrintLog($msg, DATA_REALDIR . self::API_LOGFILE, self::API_DEBUG_MODE); + GC_Utils_Ex::gfPrintLog($msg, DATA_REALDIR.self::API_LOGFILE, self::API_DEBUG_MODE); } /** @@ -130,26 +131,27 @@ public static function printApiLog($msg, $start_time = '' , $operation_name = '' * * @param string $operation_name オペレーション名 * @param array $arrParam リクエストパラメーター + * * @return object APIオペレーションクラスオブジェクト */ - public static function loadApiOperation($operation_name, $arrParam = array()) + public static function loadApiOperation($operation_name, $arrParam = []) { // API_UPLOADのほうが優先 // API_UPLOAD > API_CLASS_EX > API_CLASS - if (file_exists(API_UPLOAD_REALDIR . $operation_name . '.php')) { - $api_operation_file = API_UPLOAD_REALDIR . $operation_name . '.php'; - $api_class_name = 'API_' . $operation_name; - } elseif (file_exists(API_CLASS_EX_REALDIR . $operation_name . '_Ex.php')) { - $api_operation_file = API_CLASS_EX_REALDIR . $operation_name . '_Ex.php'; - $api_class_name = 'API_' . $operation_name . '_Ex'; - } elseif (file_exists(API_CLASS_REALDIR . $operation_name . '.php')) { - $api_operation_file = API_CLASS_REALDIR . $operation_name . '.php'; - $api_class_name = 'API_' . $operation_name; + if (file_exists(API_UPLOAD_REALDIR.$operation_name.'.php')) { + $api_operation_file = API_UPLOAD_REALDIR.$operation_name.'.php'; + $api_class_name = 'API_'.$operation_name; + } elseif (file_exists(API_CLASS_EX_REALDIR.$operation_name.'_Ex.php')) { + $api_operation_file = API_CLASS_EX_REALDIR.$operation_name.'_Ex.php'; + $api_class_name = 'API_'.$operation_name.'_Ex'; + } elseif (file_exists(API_CLASS_REALDIR.$operation_name.'.php')) { + $api_operation_file = API_CLASS_REALDIR.$operation_name.'.php'; + $api_class_name = 'API_'.$operation_name; } else { return false; } require_once $api_operation_file; - $objApiOperation = new $api_class_name ($arrParam); + $objApiOperation = new $api_class_name($arrParam); return $objApiOperation; } @@ -161,13 +163,13 @@ public static function loadApiOperation($operation_name, $arrParam = array()) */ public function getApiDirFiles() { - $arrFiles = array(); + $arrFiles = []; // Core API ディレクトリ if (is_dir(API_CLASS_EX_REALDIR)) { if ($dh = opendir(API_CLASS_EX_REALDIR)) { while (($file_name = readdir($dh)) !== false) { if ($file_name != '.' && $file_name != '..' && substr($file_name, -4) == '.php') { - $arrFiles[] = API_CLASS_EX_REALDIR . $file_name; + $arrFiles[] = API_CLASS_EX_REALDIR.$file_name; } } closedir($dh); @@ -179,7 +181,7 @@ public function getApiDirFiles() if ($dh = opendir(API_UPLOAD_REALDIR)) { while (($file_name = readdir($dh)) !== false) { if ($file_name != '.' && $file_name != '..' && substr($file_name, -4) == '.php') { - $arrFiles[] = API_UPLOAD_REALDIR . $file_name; + $arrFiles[] = API_UPLOAD_REALDIR.$file_name; } } closedir($dh); @@ -194,12 +196,12 @@ public function getApiDirFiles() */ public static function sendResponseJson($response_outer_name, &$arrResponse) { - if (isset($arrResponse["callback"])) { - $callback = $arrResponse["callback"]; - unset($arrResponse["callback"]); + if (isset($arrResponse['callback'])) { + $callback = $arrResponse['callback']; + unset($arrResponse['callback']); header('Content-Type: application/javascript; charset=UTF-8'); $arrResponse['response_name'] = $response_outer_name; - echo $callback . "(" . SC_Utils_Ex::jsonEncode($arrResponse) . ")"; + echo $callback.'('.SC_Utils_Ex::jsonEncode($arrResponse).')'; } else { header('Content-Type: application/json; charset=UTF-8'); $arrResponse['response_name'] = $response_outer_name; @@ -224,7 +226,7 @@ public static function sendResponseXml($response_outer_name, &$arrResponse) { require_once 'XML/Serializer.php'; - $options = array( + $options = [ 'mode' => 'simplexml', 'indent' => "\t", 'linebreak' => "\n", @@ -232,11 +234,11 @@ public static function sendResponseXml($response_outer_name, &$arrResponse) 'addDecl' => true, 'encoding' => 'UTF-8', 'rootName' => $response_outer_name, - 'rootAttributes' => array('xmlns' => self::API_XMLNS . ECCUBE_VERSION, - 'xml:lang' => self::API_XML_LANG), + 'rootAttributes' => ['xmlns' => self::API_XMLNS.ECCUBE_VERSION, + 'xml:lang' => self::API_XML_LANG], 'defaultTagName' => 'Response', 'attributesArray' => '_attributes' - ); + ]; $objSerializer = new XML_Serializer($options); $ret = $objSerializer->serialize($arrResponse); diff --git a/data/class/api/operations/AddrFromZip.php b/data/class/api/operations/AddrFromZip.php index 6ec4ffa9ad..632ca07b0f 100644 --- a/data/class/api/operations/AddrFromZip.php +++ b/data/class/api/operations/AddrFromZip.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_AddrFromZip extends SC_Api_Abstract_Ex { protected $operation_name = 'AddrFromZip'; @@ -42,15 +41,15 @@ public function doAction($arrParam) { $arrRequest = $this->doInitParam($arrParam); if (!$this->isParamError()) { - $zipcode = $arrRequest['zip1'] . $arrRequest['zip2']; + $zipcode = $arrRequest['zip1'].$arrRequest['zip2']; $arrAddrList = SC_Utils_Ex::sfGetAddress($zipcode); if (!SC_Utils_Ex::isBlank($arrAddrList)) { - $this->setResponse('Address', array( + $this->setResponse('Address', [ 'State' => $arrAddrList[0]['state'], 'City' => $arrAddrList[0]['city'], 'Town' => $arrAddrList[0]['town'], - ) - ); + ] + ); return true; } @@ -61,8 +60,8 @@ public function doAction($arrParam) protected function lfInitParam(&$objFormParam) { - $objFormParam->addParam('郵便番号1', 'zip1', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('郵便番号2', 'zip2', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('郵便番号1', 'zip1', ZIP01_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('郵便番号2', 'zip2', ZIP02_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); } public function getResponseGroupName() diff --git a/data/class/api/operations/BrowseNodeLookup.php b/data/class/api/operations/BrowseNodeLookup.php index c12262fcb1..28f929cbfa 100644 --- a/data/class/api/operations/BrowseNodeLookup.php +++ b/data/class/api/operations/BrowseNodeLookup.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_BrowseNodeLookup extends SC_Api_Abstract_Ex { protected $operation_name = 'BrowseNodeLookup'; @@ -51,7 +50,7 @@ public function doAction($arrParam) } // LC_Page_Products_CategoryList::lfGetCategories() と相当類似しているので共通化したい $arrCategory = null; // 選択されたカテゴリ - $arrChildren = array(); // 子カテゴリ + $arrChildren = []; // 子カテゴリ $arrAll = SC_Helper_DB_Ex::sfGetCatTree($category_id, true); foreach ($arrAll as $category) { @@ -69,30 +68,30 @@ public function doAction($arrParam) } if (!SC_Utils_Ex::isBlank($arrCategory)) { - $arrData = array( + $arrData = [ 'BrowseNodeId' => $category_id, 'Name' => $arrCategory['category_name'], - 'PageURL' => HTTP_URL . 'products/list.php?category_id=' . $arrCategory['category_id'], + 'PageURL' => HTTP_URL.'products/list.php?category_id='.$arrCategory['category_id'], 'has_children' => count($arrChildren) > 0 - ); + ]; } else { - $arrData = array( + $arrData = [ 'BrowseNodeId' => $category_id, 'Name' => 'ホーム', - 'PageURL' => HTTP_URL, + 'PageURL' => HTTP_URL, 'has_children' => count($arrChildren) > 0 - ); + ]; } if (!SC_Utils_Ex::isBlank($arrChildren)) { - $arrData['Children'] = array(); + $arrData['Children'] = []; foreach ($arrChildren as $category) { - $arrData['Children']['BrowseNode'][] = array( + $arrData['Children']['BrowseNode'][] = [ 'BrowseNodeId' => $category['category_id'], 'Name' => $category['category_name'], - 'PageURL' => HTTP_URL . 'products/list.php?category_id=' . $category['category_id'], + 'PageURL' => HTTP_URL.'products/list.php?category_id='.$category['category_id'], 'has_children' => $category['has_children'] - ); + ]; } } $this->setResponse('BrowseNode', $arrData); @@ -106,8 +105,8 @@ public function doAction($arrParam) protected function lfInitParam(&$objFormParam) { - $objFormParam->addParam('対象カテゴリID', 'BrowseNodeId', INT_LEN, 'a', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('返答種別', 'ResponseGroup', INT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('対象カテゴリID', 'BrowseNodeId', INT_LEN, 'a', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('返答種別', 'ResponseGroup', INT_LEN, 'a', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); } public function getResponseGroupName() diff --git a/data/class/api/operations/CartAdd.php b/data/class/api/operations/CartAdd.php index 367b405f6c..4c868cc17f 100644 --- a/data/class/api/operations/CartAdd.php +++ b/data/class/api/operations/CartAdd.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_CartAdd extends SC_Api_Abstract_Ex { protected $operation_name = 'CartAdd'; @@ -40,8 +39,8 @@ class API_CartAdd extends SC_Api_Abstract_Ex public function doAction($arrParam) { - $this->arrResponse = array( - 'Version' => ECCUBE_VERSION); + $this->arrResponse = [ + 'Version' => ECCUBE_VERSION]; return true; } diff --git a/data/class/api/operations/CartClear.php b/data/class/api/operations/CartClear.php index 54f539d782..514e450bc4 100644 --- a/data/class/api/operations/CartClear.php +++ b/data/class/api/operations/CartClear.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_CartClear extends SC_Api_Abstract_Ex { protected $operation_name = 'CartClear'; @@ -40,8 +39,8 @@ class API_CartClear extends SC_Api_Abstract_Ex public function doAction($arrParam) { - $this->arrResponse = array( - 'Version' => ECCUBE_VERSION); + $this->arrResponse = [ + 'Version' => ECCUBE_VERSION]; return true; } diff --git a/data/class/api/operations/CartCreate.php b/data/class/api/operations/CartCreate.php index 2af3cacb0c..b5a9355e6e 100644 --- a/data/class/api/operations/CartCreate.php +++ b/data/class/api/operations/CartCreate.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_CartCreate extends SC_Api_Abstract_Ex { protected $operation_name = 'CartCreate'; @@ -40,8 +39,8 @@ class API_CartCreate extends SC_Api_Abstract_Ex public function doAction($arrParam) { - $this->arrResponse = array( - 'Version' => ECCUBE_VERSION); + $this->arrResponse = [ + 'Version' => ECCUBE_VERSION]; return true; } diff --git a/data/class/api/operations/CartGet.php b/data/class/api/operations/CartGet.php index 8561e4a0be..1b32f6d436 100644 --- a/data/class/api/operations/CartGet.php +++ b/data/class/api/operations/CartGet.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_CartGet extends SC_Api_Abstract_Ex { protected $operation_name = 'CartGet'; @@ -40,8 +39,8 @@ class API_CartGet extends SC_Api_Abstract_Ex public function doAction($arrParam) { - $this->arrResponse = array( - 'Version' => ECCUBE_VERSION); + $this->arrResponse = [ + 'Version' => ECCUBE_VERSION]; return true; } diff --git a/data/class/api/operations/CartModify.php b/data/class/api/operations/CartModify.php index d5b4e10dbb..4cd288f0f0 100644 --- a/data/class/api/operations/CartModify.php +++ b/data/class/api/operations/CartModify.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_CartModify extends SC_Api_Abstract_Ex { protected $operation_name = 'CartModify'; @@ -40,8 +39,8 @@ class API_CartModify extends SC_Api_Abstract_Ex public function doAction($arrParam) { - $this->arrResponse = array( - 'Version' => ECCUBE_VERSION); + $this->arrResponse = [ + 'Version' => ECCUBE_VERSION]; return true; } diff --git a/data/class/api/operations/Default.php b/data/class/api/operations/Default.php index 0668e99178..a84d9f98db 100644 --- a/data/class/api/operations/Default.php +++ b/data/class/api/operations/Default.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_Default extends SC_Api_Abstract_Ex { protected $operation_name = 'Default'; @@ -40,14 +39,14 @@ class API_Default extends SC_Api_Abstract_Ex public function doAction($arrParam) { - $this->arrResponse = array('DefaultEmpty' => array()); + $this->arrResponse = ['DefaultEmpty' => []]; return true; } public function getRequestValidate() { - return array('DefaultResponse' => array()); + return ['DefaultResponse' => []]; } public function getResponseGroupName() diff --git a/data/class/api/operations/GetVersion.php b/data/class/api/operations/GetVersion.php index 755fe39c32..00f47c0f31 100644 --- a/data/class/api/operations/GetVersion.php +++ b/data/class/api/operations/GetVersion.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_GetVersion extends SC_Api_Abstract_Ex { protected $operation_name = 'GetVersion'; @@ -40,8 +39,8 @@ class API_GetVersion extends SC_Api_Abstract_Ex public function doAction($arrParam) { - $this->arrResponse = array( - 'Version' => ECCUBE_VERSION); + $this->arrResponse = [ + 'Version' => ECCUBE_VERSION]; return true; } diff --git a/data/class/api/operations/ItemLookup.php b/data/class/api/operations/ItemLookup.php index f52ca5cce8..b1e46ea0dd 100644 --- a/data/class/api/operations/ItemLookup.php +++ b/data/class/api/operations/ItemLookup.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_ItemLookup extends SC_Api_Abstract_Ex { protected $operation_name = 'ItemLookup'; @@ -42,34 +41,34 @@ public function doAction($arrParam) { $arrRequest = $this->doInitParam($arrParam); if (!$this->isParamError()) { - $arrProduct = array(); + $arrProduct = []; $objProduct = new SC_Product_Ex(); switch ($arrRequest['IdType']) { - case 'product_code': - $search_column = 'product_code'; - break; - case 'product_class_id': - $arrProduct = $objProduct->getDetailAndProductsClass($arrRequest['ItemId']); - break; - case 'product_id': - default: - $arrProduct = $objProduct->getDetail($arrRequest['ItemId']); - break; + case 'product_code': + $search_column = 'product_code'; + break; + case 'product_class_id': + $arrProduct = $objProduct->getDetailAndProductsClass($arrRequest['ItemId']); + break; + case 'product_id': + default: + $arrProduct = $objProduct->getDetail($arrRequest['ItemId']); + break; } - $objProduct->setProductsClassByProductIds(array($arrProduct['product_id'])); + $objProduct->setProductsClassByProductIds([$arrProduct['product_id']]); if ($arrProduct['del_flg'] == '0' && $arrProduct['status'] == '1') { unset($arrProduct['note']); $this->setResponse('product_id', $arrProduct['product_id']); - $this->setResponse('DetailPageURL', HTTP_URL . 'products/detail.php?product_id=' . $arrProduct['product_id']); + $this->setResponse('DetailPageURL', HTTP_URL.'products/detail.php?product_id='.$arrProduct['product_id']); $this->setResponse('Title', $arrProduct['name']); $this->setResponse('ItemAttributes', $arrProduct); return true; } else { - $this->addError(array('ItemLookup.Error' => '※ 要求された情報は見つかりませんでした。')); + $this->addError(['ItemLookup.Error' => '※ 要求された情報は見つかりませんでした。']); } } @@ -79,30 +78,30 @@ public function doAction($arrParam) protected function checkErrorExtended($arrParam) { switch ($arrParam['IdType']) { - case 'product_code': - break; - case 'product_id': - case 'product_class_id': - default: - $objErr = new SC_CheckError_Ex($arrParam); - $objErr->doFunc(array('指定ID', 'ItemId', INT_LEN), array('MAX_LENGTH_CHECK', 'NUM_CHECK')); - $this->addError($objErr->arrErr); - break; + case 'product_code': + break; + case 'product_id': + case 'product_class_id': + default: + $objErr = new SC_CheckError_Ex($arrParam); + $objErr->doFunc(['指定ID', 'ItemId', INT_LEN], ['MAX_LENGTH_CHECK', 'NUM_CHECK']); + $this->addError($objErr->arrErr); + break; } } protected function lfInitParam(&$objFormParam) { - $objFormParam->addParam('商品コンディション', 'Condition', STEXT_LEN, 'a', array('ALNUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('商品ID種別', 'IdType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('指定ID', 'ItemId', STEXT_LEN, 'a', array('EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('関連商品数', 'RelatedItemsPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('関連商品種別', 'RelationshipType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('レビューページ番号', 'ReviewPage', INT_LEN, 'N', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('レビューページソート', 'ReviewSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('関連タグページ', 'TagPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('関連タグページ数', 'TagsPerPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('関連タグソート', 'TagSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('商品コンディション', 'Condition', STEXT_LEN, 'a', ['ALNUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('商品ID種別', 'IdType', STEXT_LEN, 'a', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('指定ID', 'ItemId', STEXT_LEN, 'a', ['EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('関連商品数', 'RelatedItemsPage', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('関連商品種別', 'RelationshipType', STEXT_LEN, 'a', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('レビューページ番号', 'ReviewPage', INT_LEN, 'N', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('レビューページソート', 'ReviewSort', STEXT_LEN, 'a', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('関連タグページ', 'TagPage', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('関連タグページ数', 'TagsPerPage', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('関連タグソート', 'TagSort', STEXT_LEN, 'a', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); } public function getResponseGroupName() diff --git a/data/class/api/operations/ItemSearch.php b/data/class/api/operations/ItemSearch.php index edd714dd20..6c45d1a0ea 100644 --- a/data/class/api/operations/ItemSearch.php +++ b/data/class/api/operations/ItemSearch.php @@ -24,11 +24,10 @@ /** * APIの基本クラス * - * @package Api * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ - class API_ItemSearch extends SC_Api_Abstract_Ex { protected $operation_name = 'ItemSearch'; @@ -42,17 +41,17 @@ public function doAction($arrParam) { $arrRequest = $this->doInitParam($arrParam); if (!$this->isParamError()) { - $masterData = new SC_DB_MasterData_Ex(); - $arrSTATUS = $masterData->getMasterData('mtb_status'); - $arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image'); + $masterData = new SC_DB_MasterData_Ex(); + $arrSTATUS = $masterData->getMasterData('mtb_status'); + $arrSTATUS_IMAGE = $masterData->getMasterData('mtb_status_image'); $objProduct = new SC_Product_Ex(); - $arrSearchData = array( + $arrSearchData = [ 'category_id' => $arrRequest['BrowseNode'], 'maker_name' => $arrRequest['Manufacturer'], 'name' => $arrRequest['Keywords'], 'orderby' => $arrRequest['Sort'], - ); + ]; $arrSearchCondition = $this->getSearchCondition($arrSearchData); $disp_number = 10; @@ -67,23 +66,23 @@ public function doAction($arrParam) if (!SC_Utils_Ex::isBlank($arrProducts)) { $arrProducts = $this->setStatusDataTo($arrProducts, $arrSTATUS, $arrSTATUS_IMAGE); SC_Product_Ex::setPriceTaxTo($arrProducts); - foreach ($arrProducts as $key=>$val) { + foreach ($arrProducts as $key => $val) { $arrProducts[$key]['main_list_image'] = SC_Utils_Ex::sfNoImageMainList($val['main_list_image']); } - $arrData = array(); + $arrData = []; foreach ($arrProducts as $key => $val) { - $arrData[] = array( + $arrData[] = [ 'product_id' => $val['product_id'], - 'DetailPageURL' => HTTP_URL . 'products/detail.php?product_id=' . $val['product_id'], + 'DetailPageURL' => HTTP_URL.'products/detail.php?product_id='.$val['product_id'], 'ItemAttributes' => $val - ); + ]; } $this->setResponse('Item', $arrData); return true; } else { - $this->addError(array('ItemSearch.Error' => '※ 要求された情報は見つかりませんでした。')); + $this->addError(['ItemSearch.Error' => '※ 要求された情報は見つかりませんでした。']); } } @@ -92,11 +91,11 @@ public function doAction($arrParam) protected function lfInitParam(&$objFormParam) { - $objFormParam->addParam('カテゴリID', 'BrowseNode', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('キーワード', 'Keywords', STEXT_LEN, 'a', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('メーカー名', 'Manufacturer', STEXT_LEN, 'a', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('ページ番号', 'ItemPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('ソート', 'Sort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('カテゴリID', 'BrowseNode', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('キーワード', 'Keywords', STEXT_LEN, 'a', ['SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('メーカー名', 'Manufacturer', STEXT_LEN, 'a', ['SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('ページ番号', 'ItemPage', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('ソート', 'Sort', STEXT_LEN, 'a', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); } public function getResponseGroupName() @@ -107,9 +106,10 @@ public function getResponseGroupName() /** * 商品一覧の取得 * - * @param integer $disp_number - * @param integer $linemax + * @param int $disp_number + * @param int $linemax * @param SC_Product_Ex $objProduct + * * @return array * TODO: LC_Page_Products_List::lfGetProductsList() と共通化 */ @@ -117,7 +117,7 @@ protected function getProductsList($searchCondition, $disp_number, $startno, $li { $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrOrderVal = array(); + $arrOrderVal = []; // 表示順序 switch ($searchCondition['orderby']) { @@ -125,18 +125,18 @@ protected function getProductsList($searchCondition, $disp_number, $startno, $li case 'price': $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC'); break; - // 販売価格が高い順 + // 販売価格が高い順 case '-price': $objProduct->setProductsOrder('price02', 'dtb_products_class', 'DESC'); break; - // 新着順 + // 新着順 case 'releasedate': case 'date': $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC'); break; - // 新着順 + // 新着順 case 'releasedate': case 'date': $objProduct->setProductsOrder('create_date', 'dtb_products', 'ASC'); @@ -145,7 +145,7 @@ protected function getProductsList($searchCondition, $disp_number, $startno, $li default: if (strlen($searchCondition['where_category']) >= 1) { $dtb_product_categories = '(SELECT * FROM dtb_product_categories WHERE '.$searchCondition['where_category'].')'; - $arrOrderVal = $searchCondition['arrvalCategory']; + $arrOrderVal = $searchCondition['arrvalCategory']; } else { $dtb_product_categories = 'dtb_product_categories'; } @@ -183,13 +183,13 @@ protected function getProductsList($searchCondition, $disp_number, $startno, $li */ protected function getSearchCondition($arrSearchData) { - $searchCondition = array( - 'where' => '', - 'arrval' => array(), - 'where_category' => '', - 'arrvalCategory' => array(), - 'orderby' => '' - ); + $searchCondition = [ + 'where' => '', + 'arrval' => [], + 'where_category' => '', + 'arrvalCategory' => [], + 'orderby' => '' + ]; // カテゴリからのWHERE文字列取得 if (!SC_Utils_Ex::isBlank($arrSearchData['category_id'])) { @@ -200,7 +200,7 @@ protected function getSearchCondition($arrSearchData) $searchCondition['where'] = 'alldtl.del_flg = 0 AND alldtl.status = 1 '; if (strlen($searchCondition['where_category']) >= 1) { - $searchCondition['where'] .= ' AND EXISTS (SELECT * FROM dtb_product_categories WHERE ' . $searchCondition['where_category'] . ' AND product_id = alldtl.product_id)'; + $searchCondition['where'] .= ' AND EXISTS (SELECT * FROM dtb_product_categories WHERE '.$searchCondition['where_category'].' AND product_id = alldtl.product_id)'; $searchCondition['arrval'] = array_merge($searchCondition['arrval'], $searchCondition['arrvalCategory']); } @@ -214,15 +214,15 @@ protected function getSearchCondition($arrSearchData) // 分割したキーワードを一つずつwhere文に追加 foreach ($names as $val) { if (strlen($val) > 0) { - $searchCondition['where'] .= ' AND ( alldtl.name ILIKE ? OR alldtl.comment3 ILIKE ?) '; - $searchCondition['arrval'][] = "%$val%"; - $searchCondition['arrval'][] = "%$val%"; + $searchCondition['where'] .= ' AND ( alldtl.name ILIKE ? OR alldtl.comment3 ILIKE ?) '; + $searchCondition['arrval'][] = "%$val%"; + $searchCondition['arrval'][] = "%$val%"; } } // メーカーらのWHERE文字列取得 if ($arrSearchData['maker_id']) { - $searchCondition['where'] .= ' AND alldtl.maker_id = ? '; + $searchCondition['where'] .= ' AND alldtl.maker_id = ? '; $searchCondition['arrval'][] = $arrSearchData['maker_id']; } @@ -245,10 +245,11 @@ protected function getSearchCondition($arrSearchData) /** * 商品情報配列に商品ステータス情報を追加する * - * @param Array $arrProducts 商品一覧情報 - * @param Array $arrStatus 商品ステータス配列 - * @param Array $arrStatusImage スタータス画像配列 - * @return Array $arrProducts 商品一覧情報 + * @param array $arrProducts 商品一覧情報 + * @param array $arrStatus 商品ステータス配列 + * @param array $arrStatusImage スタータス画像配列 + * + * @return array $arrProducts 商品一覧情報 */ protected function setStatusDataTo($arrProducts, $arrStatus, $arrStatusImage) { @@ -256,11 +257,11 @@ protected function setStatusDataTo($arrProducts, $arrStatus, $arrStatusImage) for ($i = 0; $i < count($arrValues); $i++) { $product_status_id = $arrValues[$i]; if (!empty($product_status_id)) { - $arrProductStatus = array( + $arrProductStatus = [ 'status_cd' => $product_status_id, 'status_name' => $arrStatus[$product_status_id], - 'status_image' =>$arrStatusImage[$product_status_id], - ); + 'status_image' => $arrStatusImage[$product_status_id], + ]; $arrProducts['productStatus'][$product_id][$i] = $arrProductStatus; } } diff --git a/data/class/batch/SC_Batch_Update.php b/data/class/batch/SC_Batch_Update.php index 03f238550b..a3e9f4ff58 100644 --- a/data/class/batch/SC_Batch_Update.php +++ b/data/class/batch/SC_Batch_Update.php @@ -26,8 +26,8 @@ * * XXX Singleton にするべき... * - * @package Batch * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_Batch_Update extends SC_Batch @@ -46,22 +46,23 @@ class SC_Batch_Update extends SC_Batch * バッチ処理を実行する. * * @param string $target アップデータファイルのディレクトリパス + * * @return void */ public function execute($target = '.') { $msg = ''; $oldMask = umask(0); - $bkupDistInfoArray = array(); //バックアップファイル用のdistinfoファイル内容 - $bkupPath = DATA_REALDIR . 'downloads/backup/update_' . time() . '/'; - $bkupPathFile = $bkupPath . 'files/'; - $this->lfMkdirRecursive($bkupPathFile . 'dummy'); - - $arrLog = array( - 'err' => array(), - 'ok' => array(), + $bkupDistInfoArray = []; // バックアップファイル用のdistinfoファイル内容 + $bkupPath = DATA_REALDIR.'downloads/backup/update_'.time().'/'; + $bkupPathFile = $bkupPath.'files/'; + $this->lfMkdirRecursive($bkupPathFile.'dummy'); + + $arrLog = [ + 'err' => [], + 'ok' => [], 'buckup_path' => $bkupPath - ); + ]; if (!is_writable($bkupPath) || !is_writable($bkupPathFile)) { $msg = 'バックアップディレクトリの作成に失敗しました'; @@ -93,8 +94,8 @@ public function execute($target = '.') // 除外ファイルをスキップ if (in_array($fileName, $excludeArray)) { - //$arrLog['ok'][] = '次のファイルは除外されました: ' . $path; - $msg = '次のファイルは除外されました: ' . $path; + // $arrLog['ok'][] = '次のファイルは除外されました: ' . $path; + $msg = '次のファイルは除外されました: '.$path; $this->printLog($msg); continue; } @@ -102,7 +103,7 @@ public function execute($target = '.') // sha1 を取得 $sha1 = sha1_file($path); - //$arrLog[] = $sha1 . ' => ' . $path; + // $arrLog[] = $sha1 . ' => ' . $path; // 変換対象を順に処理 foreach ($includeArray as $include) { @@ -114,30 +115,30 @@ public function execute($target = '.') if (!empty($distinfo[$sha1])) { $out = $distinfo[$sha1]; } else { - $msg = 'ハッシュ値が一致しないため, コピー先が取得できません: ' . $path; + $msg = 'ハッシュ値が一致しないため, コピー先が取得できません: '.$path; $arrLog['err'][] = $msg; $this->printLog($msg); break 2; } if (file_exists($out) && $sha1 == sha1_file($out)) { - $msg = '同じ内容のファイルをスキップしました: ' . $out; + $msg = '同じ内容のファイルをスキップしました: '.$out; $this->printLog($msg); continue; } // バックアップを作成 if (file_exists($out)) { - $bkupTo = $bkupPathFile . pathinfo($out, PATHINFO_BASENAME); + $bkupTo = $bkupPathFile.pathinfo($out, PATHINFO_BASENAME); $bkupDistInfoArray[sha1_file($out)] = $out; if (!@copy($out, $bkupTo)) { - $msg = 'バックアップファイルの作成に失敗しました: ' . $out . ' -> ' . $bkupTo; + $msg = 'バックアップファイルの作成に失敗しました: '.$out.' -> '.$bkupTo; $arrLog['err'][] = $msg; $this->printLog($msg); break 2; } - $msg = 'バックアップファイルの作成に成功しました: ' . $out . ' -> ' . $bkupTo; + $msg = 'バックアップファイルの作成に成功しました: '.$out.' -> '.$bkupTo; $this->printLog($msg); } @@ -148,7 +149,7 @@ public function execute($target = '.') $this->lfMkdirRecursive($out); $handle = @fopen($out, 'w'); if (!$handle) { - $msg = 'コピー先に書き込み権限がありません: ' . $out; + $msg = 'コピー先に書き込み権限がありません: '.$out; $arrLog['err'][] = $msg; $this->printLog($msg); continue; @@ -157,13 +158,13 @@ public function execute($target = '.') // 取得した内容を書き込む if (fwrite($handle, $contents) === false) { - $msg = 'コピー先に書き込み権限がありません: ' . $out; + $msg = 'コピー先に書き込み権限がありません: '.$out; $arrLog['err'][] = $msg; $this->printLog($msg); continue; } - $msg = 'ファイルのコピーに成功しました: ' . $out; + $msg = 'ファイルのコピーに成功しました: '.$out; $arrLog['ok'][] = $msg; $this->printLog($msg); // ファイルを閉じる @@ -174,13 +175,13 @@ public function execute($target = '.') } $src = $this->makeDistInfo($bkupDistInfoArray); if (is_writable($bkupPath)) { - $handle = @fopen($bkupPath . 'distinfo.php', 'w'); + $handle = @fopen($bkupPath.'distinfo.php', 'w'); @fwrite($handle, $src); @fclose($handle); - $msg = 'distinfoファイルの作成に成功しました: ' . $bkupPath . 'distinfo.php'; + $msg = 'distinfoファイルの作成に成功しました: '.$bkupPath.'distinfo.php'; $this->printLog($msg); } else { - $msg = 'distinfoファイルの作成に失敗しました: ' . $bkupPath . 'distinfo.php'; + $msg = 'distinfoファイルの作成に失敗しました: '.$bkupPath.'distinfo.php'; $arrLog['err'][] = $msg; $this->printLog($msg); } @@ -194,18 +195,24 @@ public function execute($target = '.') * * @param string 任意のパス名 * @param string $dir + * * @return array $dir より下層に存在するパス名の配列 + * * @see http://www.php.net/glob */ public function listdirs($dir) { - static $alldirs = array(); - $dirs = glob($dir . '/*'); + static $alldirs = []; + $dirs = glob($dir.'/*'); if (is_array($dirs) && count($dirs) > 0) { - foreach ($dirs as $d) $alldirs[] = $d; + foreach ($dirs as $d) { + $alldirs[] = $d; + } } if (is_array($dirs)) { - foreach ($dirs as $dir) $this->listdirs($dir); + foreach ($dirs as $dir) { + $this->listdirs($dir); + } } return $alldirs; @@ -233,9 +240,11 @@ public function lfMkdirRecursive($path) $arrDirs = explode('/', str_replace('\\', '/', $path)); foreach ($arrDirs as $n) { - $dir .= $n . '/'; + $dir .= $n.'/'; if (!file_exists($dir)) { - if (!@mkdir($dir)) break; + if (!@mkdir($dir)) { + break; + } } } } @@ -243,10 +252,10 @@ public function lfMkdirRecursive($path) public function makeDistInfo($bkupDistInfoArray) { $src = " $value) { - $src .= "'${key}' => '${value}',\n"; + $src .= "'{$key}' => '{$value}',\n"; } $src .= ");\n?>"; @@ -258,6 +267,6 @@ public function makeDistInfo($bkupDistInfoArray) */ public function printLog($msg) { - GC_Utils_Ex::gfPrintLog($msg, DATA_REALDIR . 'logs/ownersstore_batch_update.log'); + GC_Utils_Ex::gfPrintLog($msg, DATA_REALDIR.'logs/ownersstore_batch_update.log'); } } diff --git a/data/class/db/SC_DB_DBFactory.php b/data/class/db/SC_DB_DBFactory.php index cad8b94b8c..695d265111 100644 --- a/data/class/db/SC_DB_DBFactory.php +++ b/data/class/db/SC_DB_DBFactory.php @@ -24,8 +24,8 @@ /** * DBに依存した処理を抽象化するファクトリークラス. * - * @package DB * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_DB_DBFactory @@ -34,6 +34,7 @@ class SC_DB_DBFactory * DB_TYPE に応じた DBFactory インスタンスを生成する. * * @param string $db_type 任意のインスタンスを返したい場合は DB_TYPE 文字列を指定 + * * @return SC_DB_DBFactory DBFactory インスタンス */ public static function getInstance($db_type = DB_TYPE) @@ -47,7 +48,7 @@ public static function getInstance($db_type = DB_TYPE) return new SC_DB_DBFactory_PGSQL(); default: - return new SC_DB_DBFactory(); + return new self(); } } @@ -59,20 +60,21 @@ public static function getInstance($db_type = DB_TYPE) * $dsn が空ではない場合は, $dsn の値を返す. * * @param string $dsn データソース名 + * * @return string データソース名またはDB接続パラメータの連想配列 */ public function getDSN($dsn = '') { if (empty($dsn)) { if (defined('DEFAULT_DSN')) { - $dsn = array('phptype' => DB_TYPE, + $dsn = ['phptype' => DB_TYPE, 'username' => DB_USER, 'password' => DB_PASSWORD, 'protocol' => 'tcp', 'hostspec' => DB_SERVER, - 'port' => DB_PORT, + 'port' => DB_PORT, 'database' => DB_NAME - ); + ]; } else { return ''; } @@ -85,6 +87,7 @@ public function getDSN($dsn = '') * DBのバージョンを取得する. * * @param string $dsn データソース名 + * * @return string データベースのバージョン */ public function sfGetDBVersion($dsn = '') @@ -96,6 +99,7 @@ public function sfGetDBVersion($dsn = '') * MySQL 用の SQL 文に変更する. * * @param string $sql SQL 文 + * * @return string MySQL 用に置換した SQL 文 */ public function sfChangeMySQL($sql) @@ -107,6 +111,7 @@ public function sfChangeMySQL($sql) * 昨日の売上高・売上件数を算出する SQL を返す. * * @param string $method SUM または COUNT + * * @return string 昨日の売上高・売上件数を算出する SQL */ public function getOrderYesterdaySql($method) @@ -118,6 +123,7 @@ public function getOrderYesterdaySql($method) * 当月の売上高・売上件数を算出する SQL を返す. * * @param string $method SUM または COUNT + * * @return string 当月の売上高・売上件数を算出する SQL */ public function getOrderMonthSql($method) @@ -159,6 +165,7 @@ public function getDownloadableDaysWhereSql() * 文字列連結を行う. * * @param string[] $columns 連結を行うカラム名 + * * @return string 連結後の SQL 文 */ public function concatColumn($columns) @@ -172,12 +179,14 @@ public function concatColumn($columns) * 引数に部分一致するテーブル名を配列で返す. * * @deprecated SC_Query::listTables() を使用してください + * * @param string $expression 検索文字列 + * * @return array テーブル名の配列 */ public function findTableNames($expression = '') { - return array(); + return []; } /** @@ -187,6 +196,7 @@ public function findTableNames($expression = '') * * @param string $table 対象テーブル名 * @param string $name 対象カラム名 + * * @return array インデックス設定情報配列 */ public function sfGetCreateIndexDefinition($table, $name, $definition) @@ -198,6 +208,7 @@ public function sfGetCreateIndexDefinition($table, $name, $definition) * 各 DB に応じた SC_Query での初期化を行う * * @param SC_Query $objQuery SC_Query インスタンス + * * @return void */ public function initObjQuery(SC_Query &$objQuery) @@ -211,7 +222,7 @@ public function initObjQuery(SC_Query &$objQuery) */ public function listTables(SC_Query &$objQuery) { - $objManager =& $objQuery->conn->loadModule('Manager'); + $objManager = &$objQuery->conn->loadModule('Manager'); return $objManager->listTables(); } @@ -220,11 +231,12 @@ public function listTables(SC_Query &$objQuery) * SQL 文に OFFSET, LIMIT を付加する。 * * @param string 元の SQL 文 - * @param integer LIMIT - * @param integer OFFSET + * @param int LIMIT + * @param int OFFSET + * * @return string 付加後の SQL 文 */ - function addLimitOffset($sql, $limit = 0, $offset = 0) + public function addLimitOffset($sql, $limit = 0, $offset = 0) { if ($limit != 0) { $sql .= " LIMIT $limit"; @@ -242,12 +254,13 @@ function addLimitOffset($sql, $limit = 0, $offset = 0) * * @param string $where_products_class 商品規格情報の WHERE 句 * @param array $product_ids 商品IDの配列 + * * @return string 商品詳細の SQL */ - public function alldtlSQL($where_products_class = '', $product_ids = array()) + public function alldtlSQL($where_products_class = '', $product_ids = []) { if (!SC_Utils_Ex::isBlank($where_products_class)) { - $where_products_class = 'AND (' . $where_products_class . ')'; + $where_products_class = 'AND ('.$where_products_class.')'; } $dtb_products_table = 'dtb_products'; diff --git a/data/class/db/SC_DB_MasterData.php b/data/class/db/SC_DB_MasterData.php index 3804936ac6..5738da7d40 100644 --- a/data/class/db/SC_DB_MasterData.php +++ b/data/class/db/SC_DB_MasterData.php @@ -37,8 +37,8 @@ * マスターデータがキャッシュされると, key => value 形式の配列として使用できる. * マスターデータのキャッシュは, MASTER_DATA_REALDIR/マスターデータ名.php というファイルが生成される. * - * @package DB * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_DB_MasterData @@ -47,7 +47,7 @@ class SC_DB_MasterData public $objQuery; /** デフォルトのテーブルカラム名 */ - public $columns = array('id', 'name', 'rank', 'remarks'); + public $columns = ['id', 'name', 'rank', 'remarks']; /** * マスターデータを取得する. @@ -62,13 +62,14 @@ class SC_DB_MasterData * @param string $name マスターデータ名 * @param array $columns [0] => キー, [1] => 表示文字列, [2] => 表示順 * を表すカラム名を格納した配列 + * * @return array マスターデータ */ - public function getMasterData($name, $columns = array()) + public function getMasterData($name, $columns = []) { $columns = $this->getDefaultColumnName($columns); - $filepath = MASTER_DATA_REALDIR . $name . '.serial'; + $filepath = MASTER_DATA_REALDIR.$name.'.serial'; if (!file_exists($filepath)) { // キャッシュ生成 @@ -94,7 +95,8 @@ public function getMasterData($name, $columns = array()) * を表すカラム名を格納した配列 * @param array $masterData マスターデータ * @param bool $autoCommit トランザクションを自動的に commit する場合 true - * @return integer マスターデータの登録数 + * + * @return int マスターデータの登録数 */ public function registMasterData($name, $columns, $masterData, $autoCommit = true) { @@ -106,9 +108,9 @@ public function registMasterData($name, $columns, $masterData, $autoCommit = tru } $i = 0; foreach ($masterData as $key => $val) { - $sqlVal = array($columns[0] => (string) $key, + $sqlVal = [$columns[0] => (string) $key, $columns[1] => (string) $val, - $columns[2] => (string) $i); + $columns[2] => (string) $i]; $this->objQuery->insert($name, $sqlVal); $i++; } @@ -130,7 +132,8 @@ public function registMasterData($name, $columns, $masterData, $autoCommit = tru * を表すカラム名を格納した配列 * @param array $masterData マスターデータ * @param bool $autoCommit トランザクションを自動的に commit する場合 true - * @return integer マスターデータの更新数 + * + * @return int マスターデータの更新数 */ public function updateMasterData($name, $columns, $masterData, $autoCommit = true) { @@ -144,8 +147,8 @@ public function updateMasterData($name, $columns, $masterData, $autoCommit = tru // 指定のデータを更新 $i = 0; foreach ($masterData as $key => $val) { - $sqlVal = array($columns[1] => $val); - $this->objQuery->update($name, $sqlVal, $columns[0] . ' = ' . SC_Utils_Ex::sfQuoteSmart($key)); + $sqlVal = [$columns[1] => $val]; + $this->objQuery->update($name, $sqlVal, $columns[0].' = '.SC_Utils_Ex::sfQuoteSmart($key)); $i++; } if ($autoCommit) { @@ -165,7 +168,8 @@ public function updateMasterData($name, $columns, $masterData, $autoCommit = tru * @param string $key キー名 * @param string $comment コメント * @param bool $autoCommit トランザクションを自動的に commit する場合 true - * @return integer マスターデータの更新数 + * + * @return int マスターデータの更新数 */ public function insertMasterData($name, $key, $value, $comment, $autoCommit = true) { @@ -198,7 +202,8 @@ public function insertMasterData($name, $key, $value, $comment, $autoCommit = tr * * @param string $name マスターデータ名 * @param bool $autoCommit トランザクションを自動的に commit する場合 true - * @return integer マスターデータの削除数 + * + * @return int マスターデータの削除数 */ public function deleteMasterData($name, $autoCommit = true) { @@ -222,15 +227,16 @@ public function deleteMasterData($name, $autoCommit = true) * マスターデータのキャッシュを消去する. * * @param string $name マスターデータ名 - * @return boolean|null 消去した場合 true + * + * @return bool|null 消去した場合 true */ public function clearCache($name) { - $masterDataFile = MASTER_DATA_REALDIR . $name . '.php'; + $masterDataFile = MASTER_DATA_REALDIR.$name.'.php'; if (is_file($masterDataFile)) { unlink($masterDataFile); } - $masterDataFile = MASTER_DATA_REALDIR . $name . '.serial'; + $masterDataFile = MASTER_DATA_REALDIR.$name.'.serial'; if (is_file($masterDataFile)) { unlink($masterDataFile); } @@ -249,9 +255,10 @@ public function clearCache($name) * @param bool $isDefine 定数を生成する場合 true * @param string[] $commentColumn [0] => キー, [1] => コメント文字列, * [2] => 表示順 を表すカラム名を格納した配列 + * * @return bool キャッシュの生成に成功した場合 true */ - public function createCache($name, $columns = array(), $isDefine = false, $commentColumn = array()) + public function createCache($name, $columns = [], $isDefine = false, $commentColumn = []) { // マスターデータを取得 $masterData = $this->getDbMasterData($name, $columns); @@ -259,7 +266,7 @@ public function createCache($name, $columns = array(), $isDefine = false, $comme // マスターデータを文字列にする // 定数を生成する場合 if ($isDefine) { - $path = MASTER_DATA_REALDIR . $name . '.php'; + $path = MASTER_DATA_REALDIR.$name.'.php'; $data = "getMasterDataAsDefine($masterData); } - $data .= "\n"; + $data .= "\n"; // 配列を生成する場合 } else { - $path = MASTER_DATA_REALDIR . $name . '.serial'; + $path = MASTER_DATA_REALDIR.$name.'.serial'; $data = serialize($masterData); } @@ -302,9 +309,10 @@ public function createCache($name, $columns = array(), $isDefine = false, $comme * @param string $name マスターデータ名 * @param array $columns [0] => キー, [1] => 表示文字列, [2] => 表示順 * を表すカラム名を格納した配列 + * * @return array マスターデータ */ - public function getDbMasterData($name, $columns = array()) + public function getDbMasterData($name, $columns = []) { $columns = $this->getDefaultColumnName($columns); @@ -312,10 +320,10 @@ public function getDbMasterData($name, $columns = array()) if (isset($columns[2]) && strlen($columns[2]) >= 1) { $this->objQuery->setOrder($columns[2]); } - $results = $this->objQuery->select($columns[0] . ', ' . $columns[1], $name); + $results = $this->objQuery->select($columns[0].', '.$columns[1], $name); // 結果を key => value 形式に格納 - $masterData = array(); + $masterData = []; foreach ($results as $result) { $masterData[$result[$columns[0]]] = $result[$columns[1]]; } @@ -331,9 +339,10 @@ public function getDbMasterData($name, $columns = array()) * * @param array $columns [0] => キー, [1] => 表示文字列, [2] => 表示順 * を表すカラム名を格納した配列 + * * @return array カラム名を格納した配列 */ - public function getDefaultColumnName($columns = array()) + public function getDefaultColumnName($columns = []) { if (!empty($columns)) { return $columns; @@ -345,19 +354,19 @@ public function getDefaultColumnName($columns = array()) /** * マスターデータの配列を定数定義の文字列として出力する. * - * @access private * @param array $masterData マスターデータの配列 * @param array $comments コメントの配列 + * * @return string 定数定義の文字列 */ - public function getMasterDataAsDefine($masterData, $comments = array()) + public function getMasterDataAsDefine($masterData, $comments = []) { $data = ''; foreach ($masterData as $key => $val) { if (!empty($comments[$key])) { - $data .= '/** ' . $comments[$key] . " */\n"; + $data .= '/** '.$comments[$key]." */\n"; } - $data .= "define('" . $key . "', " . $val . ");\n"; + $data .= "define('".$key."', ".$val.");\n"; } return $data; diff --git a/data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php b/data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php index 46dc8b391b..14e65da6e2 100644 --- a/data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php +++ b/data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php @@ -28,8 +28,8 @@ * 必ず SC_DB_DBFactory クラスを経由してインスタンス化する. * また, SC_DB_DBFactory クラスの関数を必ずオーバーライドしている必要がある. * - * @package DB * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_DB_DBFactory_MYSQL extends SC_DB_DBFactory @@ -41,6 +41,7 @@ class SC_DB_DBFactory_MYSQL extends SC_DB_DBFactory * DBのバージョンを取得する. * * @param string $dsn データソース名 + * * @return string データベースのバージョン */ public function sfGetDBVersion($dsn = '') @@ -48,14 +49,14 @@ public function sfGetDBVersion($dsn = '') $objQuery = SC_Query_Ex::getSingletonInstance($dsn); $val = $objQuery->getOne('select version()'); - return 'MySQL ' . $val; + return 'MySQL '.$val; } /** * MySQL 用の SQL 文に変更する. * - * @access private * @param string $sql SQL 文 + * * @return string MySQL 用に置換した SQL 文 */ public function sfChangeMySQL($sql) @@ -72,6 +73,7 @@ public function sfChangeMySQL($sql) $sql = $this->sfChangeArrayToString($sql); // rank に引用符をつける $sql = $this->sfChangeReservedWords($sql); + return $sql; } @@ -92,29 +94,31 @@ public function getCharSet() * 昨日の売上高・売上件数を算出する SQL を返す. * * @param string $method SUM または COUNT + * * @return string 昨日の売上高・売上件数を算出する SQL */ public function getOrderYesterdaySql($method) { - return 'SELECT ' . $method . '(total) FROM dtb_order ' - . 'WHERE del_flg = 0 ' - . 'AND cast(create_date as date) = DATE_ADD(current_date, interval -1 day) ' - . 'AND status <> ' . ORDER_CANCEL; + return 'SELECT '.$method.'(total) FROM dtb_order ' + .'WHERE del_flg = 0 ' + .'AND cast(create_date as date) = DATE_ADD(current_date, interval -1 day) ' + .'AND status <> '.ORDER_CANCEL; } /** * 当月の売上高・売上件数を算出する SQL を返す. * * @param string $method SUM または COUNT + * * @return string 当月の売上高・売上件数を算出する SQL */ public function getOrderMonthSql($method) { return 'SELECT '.$method.'(total) FROM dtb_order ' - . 'WHERE del_flg = 0 ' - . "AND date_format(create_date, '%Y/%m') = ? " - . "AND date_format(create_date, '%Y/%m/%d') <> date_format(CURRENT_TIMESTAMP, '%Y/%m/%d') " - . 'AND status <> ' . ORDER_CANCEL; + .'WHERE del_flg = 0 ' + ."AND date_format(create_date, '%Y/%m') = ? " + ."AND date_format(create_date, '%Y/%m/%d') <> date_format(CURRENT_TIMESTAMP, '%Y/%m/%d') " + .'AND status <> '.ORDER_CANCEL; } /** @@ -125,12 +129,12 @@ public function getOrderMonthSql($method) public function getReviewYesterdaySql() { return 'SELECT COUNT(*) FROM dtb_review AS A ' - . 'LEFT JOIN dtb_products AS B ' - . 'ON A.product_id = B.product_id ' - . 'WHERE A.del_flg = 0 ' - . 'AND B.del_flg = 0 ' - . 'AND cast(A.create_date as date) = DATE_ADD(current_date, interval -1 day) ' - . 'AND cast(A.create_date as date) != current_date'; + .'LEFT JOIN dtb_products AS B ' + .'ON A.product_id = B.product_id ' + .'WHERE A.del_flg = 0 ' + .'AND B.del_flg = 0 ' + .'AND cast(A.create_date as date) = DATE_ADD(current_date, interval -1 day) ' + .'AND cast(A.create_date as date) != current_date'; } /** @@ -147,6 +151,7 @@ public function getSendHistoryWhereStartdateSql() * ダウンロード販売の検索条件の SQL を返す. * * @param string $dtb_order_alias + * * @return string 検索条件の SQL */ public function getDownloadableDaysWhereSql($dtb_order_alias = 'dtb_order') @@ -169,6 +174,7 @@ public function getDownloadableDaysWhereSql($dtb_order_alias = 'dtb_order') * 売上集計の期間別集計のSQLを返す * * @param mixed $type + * * @return string 検索条件のSQL */ public function getOrderTotalDaysWhereSql($type) @@ -217,6 +223,7 @@ public function getOrderTotalAgeColSql() * 文字列連結を行う. * * @param string[] $columns 連結を行うカラム名 + * * @return string 連結後の SQL 文 */ public function concatColumn($columns) @@ -226,7 +233,7 @@ public function concatColumn($columns) $total = count($columns); foreach ($columns as $column) { $sql .= $column; - if ($i < $total -1) { + if ($i < $total - 1) { $sql .= ', '; } $i++; @@ -242,12 +249,13 @@ public function concatColumn($columns) * 引数に部分一致するテーブル名を配列で返す. * * @param string $expression 検索文字列 + * * @return array テーブル名の配列 */ public function findTableNames($expression = '') { $objQuery = SC_Query_Ex::getSingletonInstance(); - $sql = 'SHOW TABLES LIKE '. $objQuery->quote('%' . $expression . '%'); + $sql = 'SHOW TABLES LIKE '.$objQuery->quote('%'.$expression.'%'); $arrColList = $objQuery->getAll($sql); $arrColList = SC_Utils_Ex::sfSwapArray($arrColList, false); @@ -257,8 +265,8 @@ public function findTableNames($expression = '') /** * ILIKE句 を LIKE句へ変換する. * - * @access private * @param string $sql SQL文 + * * @return string 変換後の SQL 文 */ public function sfChangeILIKE($sql) @@ -271,8 +279,8 @@ public function sfChangeILIKE($sql) /** * RANDOM() を RAND() に変換する. * - * @access private * @param string $sql SQL文 + * * @return string 変換後の SQL 文 */ public function sfChangeRANDOM($sql) @@ -285,8 +293,8 @@ public function sfChangeRANDOM($sql) /** * TRUNC() を TRUNCATE() に変換する. * - * @access private * @param string $sql SQL文 + * * @return string 変換後の SQL 文 */ public function sfChangeTrunc($sql) @@ -299,17 +307,17 @@ public function sfChangeTrunc($sql) /** * ARRAY_TO_STRING(ARRAY(A),B) を GROUP_CONCAT() に変換する. * - * @access private * @param string $sql SQL文 + * * @return string 変換後の SQL 文 */ public function sfChangeArrayToString($sql) { - if (strpos(strtoupper($sql), 'ARRAY_TO_STRING') !== FALSE) { + if (strpos(strtoupper($sql), 'ARRAY_TO_STRING') !== false) { preg_match_all('/ARRAY_TO_STRING.*?\(.*?ARRAY\(.*?SELECT (.+?) FROM (.+?) WHERE (.+?)\).*?\,.*?\'(.+?)\'.*?\)/is', $sql, $match, PREG_SET_ORDER); foreach ($match as $item) { - $replace = 'GROUP_CONCAT(' . $item[1] . ' SEPARATOR \'' . $item[4] . '\') FROM ' . $item[2] . ' WHERE ' . $item[3]; + $replace = 'GROUP_CONCAT('.$item[1].' SEPARATOR \''.$item[4].'\') FROM '.$item[2].' WHERE '.$item[3]; $sql = str_replace($item[0], $replace, $sql); } } @@ -324,6 +332,7 @@ public function sfChangeArrayToString($sql) * * @param string $table 対象テーブル名 * @param string $name 対象カラム名 + * * @return array インデックス設定情報配列 */ public function sfGetCreateIndexDefinition($table, $name, $definition) @@ -350,6 +359,7 @@ public function sfChangeReservedWords($sql) { $changesql = preg_replace('/(^|[^\w])RANK([^\w]|$)/i', '$1`RANK`$2', $sql); $changesql = preg_replace('/``/i', '`', $changesql); // 2重エスケープ問題の対処 + return $changesql; } @@ -367,6 +377,7 @@ public function getDummyFromClauseSql() * 各 DB に応じた SC_Query での初期化を行う * * @param SC_Query $objQuery SC_Query インスタンス + * * @return void */ public function initObjQuery(SC_Query &$objQuery) diff --git a/data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php b/data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php index 64eed7faee..cf13cf8568 100644 --- a/data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php +++ b/data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php @@ -28,8 +28,8 @@ * 必ず SC_DB_DBFactory クラスを経由してインスタンス化する. * また, SC_DB_DBFactory クラスの関数を必ずオーバーライドしている必要がある. * - * @package DB * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_DB_DBFactory_PGSQL extends SC_DB_DBFactory @@ -38,6 +38,7 @@ class SC_DB_DBFactory_PGSQL extends SC_DB_DBFactory * DBのバージョンを取得する. * * @param string $dsn データソース名 + * * @return string データベースのバージョン */ public function sfGetDBVersion($dsn = '') @@ -46,7 +47,7 @@ public function sfGetDBVersion($dsn = '') $val = $objQuery->getOne('select version()'); $arrLine = explode(' ', $val); - return $arrLine[0] . ' ' . str_replace(',', '', $arrLine[1]); + return $arrLine[0].' '.str_replace(',', '', $arrLine[1]); } /** @@ -54,8 +55,8 @@ public function sfGetDBVersion($dsn = '') * * DB_TYPE が PostgreSQL の場合は何もしない * - * @access private * @param string $sql SQL 文 + * * @return string MySQL 用に置換した SQL 文 */ public function sfChangeMySQL($sql) @@ -67,29 +68,31 @@ public function sfChangeMySQL($sql) * 昨日の売上高・売上件数を算出する SQL を返す. * * @param string $method SUM または COUNT + * * @return string 昨日の売上高・売上件数を算出する SQL */ public function getOrderYesterdaySql($method) { return 'SELECT '.$method.'(total) FROM dtb_order ' - . 'WHERE del_flg = 0 ' - . "AND to_char(create_date,'YYYY/MM/DD') = to_char(CURRENT_TIMESTAMP - interval '1 days','YYYY/MM/DD') " - . 'AND status <> ' . ORDER_CANCEL; + .'WHERE del_flg = 0 ' + ."AND to_char(create_date,'YYYY/MM/DD') = to_char(CURRENT_TIMESTAMP - interval '1 days','YYYY/MM/DD') " + .'AND status <> '.ORDER_CANCEL; } /** * 当月の売上高・売上件数を算出する SQL を返す. * * @param string $method SUM または COUNT + * * @return string 当月の売上高・売上件数を算出する SQL */ public function getOrderMonthSql($method) { return 'SELECT '.$method.'(total) FROM dtb_order ' - . 'WHERE del_flg = 0 ' - . "AND to_char(create_date,'YYYY/MM') = ? " - . "AND to_char(create_date,'YYYY/MM/DD') <> to_char(CURRENT_TIMESTAMP,'YYYY/MM/DD') " - . 'AND status <> ' . ORDER_CANCEL; + .'WHERE del_flg = 0 ' + ."AND to_char(create_date,'YYYY/MM') = ? " + ."AND to_char(create_date,'YYYY/MM/DD') <> to_char(CURRENT_TIMESTAMP,'YYYY/MM/DD') " + .'AND status <> '.ORDER_CANCEL; } /** @@ -100,12 +103,12 @@ public function getOrderMonthSql($method) public function getReviewYesterdaySql() { return 'SELECT COUNT(*) FROM dtb_review AS A ' - . 'LEFT JOIN dtb_products AS B ' - . 'ON A.product_id = B.product_id ' - . 'WHERE A.del_flg=0 ' - . 'AND B.del_flg = 0 ' - . "AND to_char(A.create_date, 'YYYY/MM/DD') = to_char(CURRENT_TIMESTAMP - interval '1 days','YYYY/MM/DD') " - . "AND to_char(A.create_date,'YYYY/MM/DD') != to_char(CURRENT_TIMESTAMP,'YYYY/MM/DD')"; + .'LEFT JOIN dtb_products AS B ' + .'ON A.product_id = B.product_id ' + .'WHERE A.del_flg=0 ' + .'AND B.del_flg = 0 ' + ."AND to_char(A.create_date, 'YYYY/MM/DD') = to_char(CURRENT_TIMESTAMP - interval '1 days','YYYY/MM/DD') " + ."AND to_char(A.create_date,'YYYY/MM/DD') != to_char(CURRENT_TIMESTAMP,'YYYY/MM/DD')"; } /** @@ -122,12 +125,13 @@ public function getSendHistoryWhereStartdateSql() * ダウンロード販売の検索条件の SQL を返す. * * @param string $dtb_order_alias + * * @return string 検索条件の SQL */ public function getDownloadableDaysWhereSql($dtb_order_alias = 'dtb_order') { $baseinfo = SC_Helper_DB_Ex::sfGetBasisData(); - //downloadable_daysにNULLが入っている場合(無期限ダウンロード可能時)もあるので、NULLの場合は0日に補正 + // downloadable_daysにNULLが入っている場合(無期限ダウンロード可能時)もあるので、NULLの場合は0日に補正 $downloadable_days = $baseinfo['downloadable_days']; // FIXME 怪しい比較「== null」 if ($downloadable_days == null || $downloadable_days == '') { @@ -151,6 +155,7 @@ public function getDownloadableDaysWhereSql($dtb_order_alias = 'dtb_order') * 売上集計の期間別集計のSQLを返す * * @param mixed $type + * * @return string 検索条件のSQL */ public function getOrderTotalDaysWhereSql($type) @@ -199,6 +204,7 @@ public function getOrderTotalAgeColSql() * 文字列連結を行う. * * @param string[] $columns 連結を行うカラム名 + * * @return string 連結後の SQL 文 */ public function concatColumn($columns) @@ -208,7 +214,7 @@ public function concatColumn($columns) $total = count($columns); foreach ($columns as $column) { $sql .= $column; - if ($i < $total -1) { + if ($i < $total - 1) { $sql .= ' || '; } $i++; @@ -223,25 +229,27 @@ public function concatColumn($columns) * 引数に部分一致するテーブル名を配列で返す. * * @deprecated SC_Query::listTables() を使用してください + * * @param string $expression 検索文字列 + * * @return array テーブル名の配列 */ public function findTableNames($expression = '') { $objQuery = SC_Query_Ex::getSingletonInstance(); $sql = ' SELECT c.relname AS name, ' - . ' CASE c.relkind ' - . " WHEN 'r' THEN 'table' " - . " WHEN 'v' THEN 'view' END AS type " - . ' FROM pg_catalog.pg_class c ' - . 'LEFT JOIN pg_catalog.pg_namespace n ' - . ' ON n.oid = c.relnamespace ' - . " WHERE c.relkind IN ('r','v') " - . " AND n.nspname NOT IN ('pg_catalog', 'pg_toast') " - . ' AND pg_catalog.pg_table_is_visible(c.oid) ' - . ' AND c.relname LIKE ?' - . ' ORDER BY 1,2;'; - $arrColList = $objQuery->getAll($sql, array('%' . $expression . '%')); + .' CASE c.relkind ' + ." WHEN 'r' THEN 'table' " + ." WHEN 'v' THEN 'view' END AS type " + .' FROM pg_catalog.pg_class c ' + .'LEFT JOIN pg_catalog.pg_namespace n ' + .' ON n.oid = c.relnamespace ' + ." WHERE c.relkind IN ('r','v') " + ." AND n.nspname NOT IN ('pg_catalog', 'pg_toast') " + .' AND pg_catalog.pg_table_is_visible(c.oid) ' + .' AND c.relname LIKE ?' + .' ORDER BY 1,2;'; + $arrColList = $objQuery->getAll($sql, ['%'.$expression.'%']); $arrColList = SC_Utils_Ex::sfSwapArray($arrColList, false); return $arrColList[0]; @@ -255,7 +263,7 @@ public function findTableNames($expression = '') public function getCharSet() { // 未実装 - return array(); + return []; } /** @@ -272,6 +280,7 @@ public function getDummyFromClauseSql() * テーブル一覧を取得する * * MDB2_Driver_Manager_pgsql#listTables の不具合回避を目的として独自実装している。 + * * @return array テーブル名の配列 */ public function listTables(SC_Query &$objQuery) diff --git a/data/class/graph/SC_Graph_Bar.php b/data/class/graph/SC_Graph_Bar.php index f1742fe4b7..bf2e837815 100644 --- a/data/class/graph/SC_Graph_Bar.php +++ b/data/class/graph/SC_Graph_Bar.php @@ -27,7 +27,8 @@ class SC_Graph_Bar extends SC_Graph_Line_Ex // コンストラクタ public function __construct( $bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, - $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) { + $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) + { parent::__construct($bgw, $bgh, $left, $top, $area_width, $area_height); } @@ -54,7 +55,7 @@ public function drawGraph() // 棒グラフの描画 /** - * @param integer $line_no + * @param int $line_no */ public function drawBar($line_no) { @@ -62,11 +63,11 @@ public function drawBar($line_no) // データ数を数える $count = count($arrPointList); // 半目盛りの幅を求める - $half_scale = intval($this->area_width / ($count + 1) / 2); + $half_scale = (int) ($this->area_width / ($count + 1) / 2); // 目盛りの幅を求める - $scale_width = intval($this->area_width / ($count + 1)); + $scale_width = (int) ($this->area_width / ($count + 1)); // 棒グラフのサイズを求める - $bar_width = intval(($scale_width - (BAR_PAD * 2)) / $this->line_max); + $bar_width = (int) (($scale_width - (BAR_PAD * 2)) / $this->line_max); // 色数の取得 $c_max = count($this->arrColor); for ($i = 0; $i < $count; $i++) { @@ -79,7 +80,7 @@ public function drawBar($line_no) if ($this->shade_on) { imagefilledrectangle($this->image, $left + 2, $top + 2, $right + 2, $bottom, $this->shade_color); } - //imagefilledrectangle($this->image, $left, $top, $right, $bottom, $this->arrColor[($i % $c_max)]); + // imagefilledrectangle($this->image, $left, $top, $right, $bottom, $this->arrColor[($i % $c_max)]); imagefilledrectangle($this->image, $left, $top, $right, $bottom, $this->arrColor[$line_no]); imagerectangle($this->image, $left, $top, $right, $bottom, $this->flame_color); } @@ -88,7 +89,7 @@ public function drawBar($line_no) // ラベルを描画する /** - * @param integer $line_no + * @param int $line_no */ public function drawLabel($line_no) { diff --git a/data/class/graph/SC_Graph_Base.php b/data/class/graph/SC_Graph_Base.php index 49e0d71d75..d5a59532d6 100644 --- a/data/class/graph/SC_Graph_Base.php +++ b/data/class/graph/SC_Graph_Base.php @@ -21,113 +21,113 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** TTFフォントファイル */ -define('FONT_REALFILE', DATA_REALDIR . 'fonts/wlmaru20044.ttf'); +/* TTFフォントファイル */ +define('FONT_REALFILE', DATA_REALDIR.'fonts/wlmaru20044.ttf'); -/** フォントサイズ */ +/* フォントサイズ */ define('FONT_SIZE', 8); -/** タイトルフォントサイズ */ +/* タイトルフォントサイズ */ define('TITLE_FONT_SIZE', 11); -/** 背景幅 */ +/* 背景幅 */ define('BG_WIDTH', 720); -/** 背景高さ */ +/* 背景高さ */ define('BG_HEIGHT', 400); -/** 行間 */ +/* 行間 */ define('LINE_PAD', 5); -/** フォント補正値(実際の描画幅/フォントサイズ) */ +/* フォント補正値(実際の描画幅/フォントサイズ) */ define('TEXT_RATE', 0.75); // ----------------------------------------------------------------------------- // 円グラフ // ----------------------------------------------------------------------------- -/** 円グラフ位置 */ +/* 円グラフ位置 */ define('PIE_LEFT', 200); -/** 円グラフ位置 */ +/* 円グラフ位置 */ define('PIE_TOP', 150); -/** 円グラフ幅 */ +/* 円グラフ幅 */ define('PIE_WIDTH', 230); -/** 円グラフ高さ */ +/* 円グラフ高さ */ define('PIE_HEIGHT', 100); -/** 円グラフ太さ */ +/* 円グラフ太さ */ define('PIE_THICK', 30); -/** 円グラフのラベル位置を上にあげる */ +/* 円グラフのラベル位置を上にあげる */ define('PIE_LABEL_UP', 20); -/** 値が大きいほど影が長くなる */ +/* 値が大きいほど影が長くなる */ define('PIE_SHADE_IMPACT', 0.1); // ----------------------------------------------------------------------------- // 折れ線グラフ // ----------------------------------------------------------------------------- -/** Y軸の目盛り数 */ +/* Y軸の目盛り数 */ define('LINE_Y_SCALE', 10); -/** X軸の目盛り数 */ +/* X軸の目盛り数 */ define('LINE_X_SCALE', 10); -/** 線グラフ位置 */ +/* 線グラフ位置 */ define('LINE_LEFT', 60); -/** 線グラフ位置 */ +/* 線グラフ位置 */ define('LINE_TOP', 50); -/** 線グラフ背景のサイズ */ +/* 線グラフ背景のサイズ */ define('LINE_AREA_WIDTH', 600); -/** 線グラフ背景のサイズ */ +/* 線グラフ背景のサイズ */ define('LINE_AREA_HEIGHT', 300); -/** 線グラフマークのサイズ */ +/* 線グラフマークのサイズ */ define('LINE_MARK_SIZE', 6); -/** 目盛り幅 */ +/* 目盛り幅 */ define('LINE_SCALE_SIZE', 6); -/** X軸のラベルの表示制限数 */ +/* X軸のラベルの表示制限数 */ define('LINE_XLABEL_MAX', 30); -/** X軸のタイトルと軸の間隔 */ +/* X軸のタイトルと軸の間隔 */ define('LINE_XTITLE_PAD', -5); -/** Y軸のタイトルと軸の間隔 */ +/* Y軸のタイトルと軸の間隔 */ define('LINE_YTITLE_PAD', 15); // ----------------------------------------------------------------------------- // 棒グラフ // ----------------------------------------------------------------------------- -/** グラフと目盛りの間隔 */ +/* グラフと目盛りの間隔 */ define('BAR_PAD', 6); // ----------------------------------------------------------------------------- // タイトルラベル // ----------------------------------------------------------------------------- -/** 背景枠との上幅 */ +/* 背景枠との上幅 */ define('TITLE_TOP', 10); // ----------------------------------------------------------------------------- // 凡例 // ----------------------------------------------------------------------------- -/** 背景枠との上幅 */ +/* 背景枠との上幅 */ define('LEGEND_TOP', 10); -/** 背景枠との右幅 */ +/* 背景枠との右幅 */ define('LEGEND_RIGHT', 10); /** * SC_Graph 共通クラス. * - * @package Graph * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_Graph_Base @@ -190,7 +190,9 @@ public function __construct($bgw, $bgh, $left, $top) $this->bgh = $bgh; $this->image = imagecreatetruecolor($bgw, $bgh); // アンチエイリアス有効 - if (function_exists('imageantialias')) imageantialias($this->image, true); + if (function_exists('imageantialias')) { + imageantialias($this->image, true); + } // 背景色をセット imagefill($this->image, 0, 0, $this->lfGetImageColor($this->image, $this->ARR_BG_COLOR)); @@ -277,9 +279,9 @@ public function getTextWidth($text, $font_size) // テキストを出力する /** - * @param integer $color + * @param int $color */ - public function setText($font_size, $left, $top, $text, $color = NULL, $angle = 0, $labelbg = false) + public function setText($font_size, $left, $top, $text, $color = null, $angle = 0, $labelbg = false) { // 時計回りに角度を変更 $angle = -$angle; @@ -303,11 +305,11 @@ public function setText($font_size, $left, $top, $text, $color = NULL, $angle = * */ $text = mb_convert_encoding($text, 'EUC-JP', CHAR_CODE); - //$text = mb_convert_encoding($text, CHAR_CODE); - if ($color != NULL) { - ImageTTFText($this->image, $font_size, $angle, $left, $top + $font_size, $color, FONT_REALFILE, $text); + // $text = mb_convert_encoding($text, CHAR_CODE); + if ($color != null) { + imagettftext($this->image, $font_size, $angle, $left, $top + $font_size, $color, FONT_REALFILE, $text); } else { - ImageTTFText($this->image, $font_size, $angle, $left, $top + $font_size, $this->text_color, FONT_REALFILE, $text); + imagettftext($this->image, $font_size, $angle, $left, $top + $font_size, $this->text_color, FONT_REALFILE, $text); } } @@ -333,7 +335,7 @@ public function debugPrint($text) $this->text_top = FONT_SIZE + LINE_PAD; } // テキスト描画 - ImageTTFText($this->image, FONT_SIZE, 0, LINE_PAD, $this->text_top, $this->text_color, FONT_REALFILE, $text); + imagettftext($this->image, FONT_SIZE, 0, LINE_PAD, $this->text_top, $this->text_color, FONT_REALFILE, $text); $this->text_top += FONT_SIZE + LINE_PAD; } @@ -380,7 +382,7 @@ public function drawLegend($legend_max = '', $clabelbg = true) for ($i = 0; $i < $label_max; $i++) { // カラーアイコンの表示 imagerectangle($this->image, $left, $top, $left + FONT_SIZE, $top + FONT_SIZE, $this->flame_color); - imagefilledrectangle($this->image, $left + 1, $top + 1, $left + FONT_SIZE - 1, $top + FONT_SIZE - 1, $this->arrColor[($i % $c_max)]); + imagefilledrectangle($this->image, $left + 1, $top + 1, $left + FONT_SIZE - 1, $top + FONT_SIZE - 1, $this->arrColor[$i % $c_max]); // ラベルの表示 $this->setText(FONT_SIZE, $left + FONT_SIZE + LINE_PAD, $top, $this->arrLegend[$i]); $top += FONT_SIZE + LINE_PAD; @@ -390,9 +392,9 @@ public function drawLegend($legend_max = '', $clabelbg = true) // カラーラベル背景の描画 /** - * @param double $left - * @param double $right - * @param integer $bottom + * @param float $left + * @param float $right + * @param int $bottom */ public function drawClabelBG($left, $top, $right, $bottom) { @@ -416,50 +418,50 @@ public function setLegend($arrLegend) * * 表示色をメンバ変数にセットする. * - * @access protected * @return void */ public function init() { // 凡例背景 - $this->ARR_LEGENDBG_COLOR = array(245,245,245); + $this->ARR_LEGENDBG_COLOR = [245, 245, 245]; // ラベル背景 - $this->ARR_LABELBG_COLOR = array(255,255,255); + $this->ARR_LABELBG_COLOR = [255, 255, 255]; // グラフカラー - $this->ARR_GRAPH_RGB = array( - array(200,50,50), - array(50,50,200), - array(50,200,50), - array(255,255,255), - array(244,200,200), - array(200,200,255), - array(50,200,50), - array(255,255,255), - array(244,244,244), - ); + $this->ARR_GRAPH_RGB = [ + [200, 50, 50], + [50, 50, 200], + [50, 200, 50], + [255, 255, 255], + [244, 200, 200], + [200, 200, 255], + [50, 200, 50], + [255, 255, 255], + [244, 244, 244], + ]; // 影の色 - $this->ARR_SHADE_COLOR = array(100,100,100); + $this->ARR_SHADE_COLOR = [100, 100, 100]; // 縁の色 - $this->ARR_FLAME_COLOR = array(0, 0, 0); + $this->ARR_FLAME_COLOR = [0, 0, 0]; // 文字色 - $this->ARR_TEXT_COLOR = array(0, 0, 0); + $this->ARR_TEXT_COLOR = [0, 0, 0]; // 背景カラー - $this->ARR_BG_COLOR = array(255,255,255); + $this->ARR_BG_COLOR = [255, 255, 255]; // タイトル文字色 - $this->ARR_TITLE_COLOR = array(0, 0, 0); + $this->ARR_TITLE_COLOR = [0, 0, 0]; // グリッド線色 - $this->ARR_GRID_COLOR = array(200, 200, 200); + $this->ARR_GRID_COLOR = [200, 200, 200]; // マークの色 - $this->ARR_MARK_COLOR = array(130, 130, 255); + $this->ARR_MARK_COLOR = [130, 130, 255]; } /** * 円の中心点と直径から弧の終端座標を算出する. * - * @param integer $cx 中心点X座標 - * @param integer $cy 中心点Y座標 - * @param integer $e 角度 - * @return double[] 円の中心点と直径から弧の終端座標の配列 + * @param int $cx 中心点X座標 + * @param int $cy 中心点Y座標 + * @param int $e 角度 + * + * @return float[] 円の中心点と直径から弧の終端座標の配列 */ public function lfGetArcPos($cx, $cy, $cw, $ch, $e) { @@ -470,25 +472,25 @@ public function lfGetArcPos($cx, $cy, $cw, $ch, $e) $x = $cx + ($r * cos(deg2rad($s))); $y = $cy - (($r * sin(deg2rad($s))) * ($ch / $cw)); - return array(round($x), round($y)); + return [round($x), round($y)]; } /** 画像にテキストを描画する */ public function lfImageText($dst_image, $text, $font_size, $left, $top, $font, $arrRGB) { - $color = ImageColorAllocate($dst_image, $arrRGB[0], $arrRGB[1], $arrRGB[2]); + $color = imagecolorallocate($dst_image, $arrRGB[0], $arrRGB[1], $arrRGB[2]); $text = mb_convert_encoding($text, 'UTF-8', CHAR_CODE); // 表示角度 $angle = 0; // テキスト描画 - ImageTTFText($dst_image, $font_size, $angle, $left, $top, $color, $font, $text); + imagettftext($dst_image, $font_size, $angle, $left, $top, $color, $font, $text); } /** 表示色の取得 */ public function lfGetImageColor($image, $array) { if (count($array) != 3) { - return NULL; + return null; } $ret = imagecolorallocate($image, $array[0], $array[1], $array[2]); @@ -499,10 +501,10 @@ public function lfGetImageColor($image, $array) public function lfGetImageDarkColor($image, $array) { if (count($array) != 3) { - return NULL; + return null; } $i = 0; - $dark = array(); + $dark = []; foreach ($array as $val) { $dark[$i] = $val - 45; if ($dark[$i] < 0) { diff --git a/data/class/graph/SC_Graph_Line.php b/data/class/graph/SC_Graph_Line.php index 9083026033..63a6cedced 100644 --- a/data/class/graph/SC_Graph_Line.php +++ b/data/class/graph/SC_Graph_Line.php @@ -42,7 +42,8 @@ class SC_Graph_Line extends SC_Graph_Base_Ex // コンストラクタ public function __construct( $bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, - $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) { + $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) + { parent::__construct($bgw, $bgh, $left, $top); $this->area_width = $area_width; $this->area_height = $area_height; @@ -57,7 +58,7 @@ public function __construct( // X軸ラベルの角度セット /** - * @param integer $Angle + * @param int $Angle */ public function setXLabelAngle($Angle) { @@ -123,7 +124,7 @@ public function drawXLine($bar = false) // 棒グラフの場合は半目盛りずらす if ($bar) { - $half_scale = intval($this->area_width / ($count + 1) / 2); + $half_scale = (int) ($this->area_width / ($count + 1) / 2); } else { $half_scale = 0; } @@ -148,7 +149,7 @@ public function drawXLine($bar = false) $bar_margin = 0; } - $this->setText(FONT_SIZE, $x_pos + $this->x_margin + $bar_margin, $pos + FONT_SIZE + $this->y_margin, $this->arrXLabel[$i], NULL, $this->XLabelAngle); + $this->setText(FONT_SIZE, $x_pos + $this->x_margin + $bar_margin, $pos + FONT_SIZE + $this->y_margin, $this->arrXLabel[$i], null, $this->XLabelAngle); } } @@ -169,18 +170,18 @@ public function setYGridOn($ygrid_on) // ポイントの描画 /** - * @param integer $line_no + * @param int $line_no */ public function setMark($line_no, $left, $top, $size = LINE_MARK_SIZE) { // 偶数に変換しておく $size += $size % 2; - $array = array( + $array = [ $left, $top - ($size / 2), $left + ($size / 2), $top, $left, $top + ($size / 2), $left - ($size / 2), $top, - ); + ]; imagefilledpolygon($this->image, $array, 4, $this->arrColor[$line_no]); imagepolygon($this->image, $array, 4, $this->flame_color); imagesetpixel($this->image, $left, $top + ($size / 2), $this->flame_color); @@ -190,7 +191,7 @@ public function setMark($line_no, $left, $top, $size = LINE_MARK_SIZE) public function setYScale() { // 1目盛りの値 - $number = intval($this->graph_max / LINE_Y_SCALE); + $number = (int) ($this->graph_max / LINE_Y_SCALE); // 目盛り幅を求める $size = $this->area_height / LINE_Y_SCALE; $pos = 0; @@ -203,7 +204,6 @@ public function setYScale() } } - // public function setMax($arrData) { // データの最大値を取得する。 @@ -211,9 +211,9 @@ public function setMax($arrData) // 10の何倍かを取得 $figure = strlen($data_max) - 1; // 次の桁を計算する - $tenval = pow(10, $figure); + $tenval = 10 ** $figure; // グラフ上での最大値を求める - $this->graph_max = $tenval * (intval($data_max / $tenval) + 1); + $this->graph_max = $tenval * ((int) ($data_max / $tenval) + 1); // 最大値が10未満の場合の対応 if ($this->graph_max < 10) { $this->graph_max = 10; @@ -249,7 +249,7 @@ public function drawGraph() // ラインを描画する /** - * @param integer $line_no + * @param int $line_no */ public function drawLine($line_no) { @@ -270,7 +270,7 @@ public function drawLine($line_no) // マークを描画する /** - * @param integer $line_no + * @param int $line_no */ public function drawMark($line_no) { @@ -286,7 +286,7 @@ public function drawMark($line_no) // ラベルを描画する /** - * @param integer $line_no + * @param int $line_no */ public function drawLabel($line_no) { @@ -313,14 +313,14 @@ public function setData($arrData) // 描画率を計算 $count = count($this->arrDataList[$this->line_max]); $scale_width = $this->area_width / ($count + 1); - $this->arrPointList[$this->line_max] = array(); + $this->arrPointList[$this->line_max] = []; for ($i = 0; $i < $count; $i++) { // X座標を求める - $x = intval($this->left + ($scale_width * ($i + 1))); + $x = (int) ($this->left + ($scale_width * ($i + 1))); // Y座標を求める - $y = intval($this->top + $this->area_height - ($this->arrDataList[$this->line_max][$i] * $rate)); + $y = (int) ($this->top + $this->area_height - ($this->arrDataList[$this->line_max][$i] * $rate)); // XY座標を保存する - $this->arrPointList[$this->line_max][] = array($x, $y); + $this->arrPointList[$this->line_max][] = [$x, $y]; } $this->line_max++; } diff --git a/data/class/graph/SC_Graph_Pie.php b/data/class/graph/SC_Graph_Pie.php index 0863d9583f..2cee0691c3 100644 --- a/data/class/graph/SC_Graph_Pie.php +++ b/data/class/graph/SC_Graph_Pie.php @@ -50,7 +50,7 @@ public function getCircleData($array) if (!is_array($array)) { return; } - $arrRet = array(); + $arrRet = []; foreach ($array as $val) { $total += $val; } @@ -63,10 +63,10 @@ public function getCircleData($array) $cnt = 0; foreach ($array as $val) { $ret = round($val * $rate); - $new_total+= $ret; + $new_total += $ret; $arrRet[] = $ret; // パーセント表示用 - $this->arrLabel[] = round($val * $p_rate) . ' %'; + $this->arrLabel[] = round($val * $p_rate).' %'; $cnt++; } // 合計が360になるように補正しておく @@ -78,8 +78,8 @@ public function getCircleData($array) // 円の位置設定を行う /** - * @param double $cx - * @param double $cy + * @param float $cx + * @param float $cy */ public function setPosition($cx, $cy) { @@ -147,10 +147,10 @@ public function drawGraph() $end = $start + $arrRad[$j]; if ($start == 0 && $end == 360) { // -90~270で指定すると円が描画できないので0~360に指定 - imagearc($this->image, $x, $i, $w, $h, 0, 360, $this->arrDarkColor[($j % $dc_max)]); + imagearc($this->image, $x, $i, $w, $h, 0, 360, $this->arrDarkColor[$j % $dc_max]); } else { // -90°は12時の位置から開始するように補正している - imagearc($this->image, $x, $i, $w, $h, $start - 90, $end - 90, $this->arrDarkColor[($j % $dc_max)]); + imagearc($this->image, $x, $i, $w, $h, $start - 90, $end - 90, $this->arrDarkColor[$j % $dc_max]); } $start = $end; } @@ -166,15 +166,15 @@ public function drawGraph() // 開始・終了が同一値だと、(imagefilledarc 関数における) 0°から360°として動作するようなので、スキップする。 // XXX 値ラベルは別ロジックなので、実質問題を生じないと考えている。 if ($start == $end) { - continue 1; + continue; } // -90°は12時の位置から開始するように補正するもの。 // 塗りつぶし - imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->arrColor[($key % $c_max)], IMG_ARC_PIE); + imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->arrColor[$key % $c_max], IMG_ARC_PIE); // FIXME 360°描画の場合、(imagefilledarc 関数における) 0°から360°として動作する。本来-90°から360°として動作すべき。 // なお、360°と0°の組み合わせを考慮すると線が無いのも問題があるので、この処理をスキップする対応は不適当である。 // 縁取り線 - imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->flame_color, IMG_ARC_EDGED|IMG_ARC_NOFILL); + imagefilledarc($this->image, $x, $y, $w, $h, $start - 90, $end - 90, $this->flame_color, IMG_ARC_EDGED | IMG_ARC_NOFILL); $start = $end; } @@ -209,11 +209,11 @@ public function drawLabel($arrRad) foreach ($arrRad as $key => $rad) { $center = $start + ($rad / 2); $end = $start + $rad; - list($sx, $sy) = $this->lfGetArcPos($this->cx, $this->cy, ($this->cw / 1.5), ($this->ch / 1.5), $center); - list($ex, $ey) = $this->lfGetArcPos($this->cx, $this->cy, ($this->cw * 1.5), ($this->ch * 1.5), $center); + list($sx, $sy) = $this->lfGetArcPos($this->cx, $this->cy, $this->cw / 1.5, $this->ch / 1.5, $center); + list($ex, $ey) = $this->lfGetArcPos($this->cx, $this->cy, $this->cw * 1.5, $this->ch * 1.5, $center); // 指示線の描画 imageline($this->image, $sx, $sy, $ex + 2, $ey - PIE_LABEL_UP, $this->flame_color); - $this->setText(FONT_SIZE, $ex - 10, $ey - PIE_LABEL_UP - FONT_SIZE, $this->arrLabel[$key], NULL, 0, true); + $this->setText(FONT_SIZE, $ex - 10, $ey - PIE_LABEL_UP - FONT_SIZE, $this->arrLabel[$key], null, 0, true); $start = $end; } } diff --git a/data/class/helper/SC_Helper_Address.php b/data/class/helper/SC_Helper_Address.php index 2dd177a8d7..b6c93e2193 100644 --- a/data/class/helper/SC_Helper_Address.php +++ b/data/class/helper/SC_Helper_Address.php @@ -24,8 +24,8 @@ /** * 会員の登録配送先を管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_Address @@ -34,6 +34,7 @@ class SC_Helper_Address * お届け先を登録 * * @param array $sqlval + * * @return array() */ public function registAddress($sqlval) @@ -47,11 +48,11 @@ public function registAddress($sqlval) $other_deliv_id = $sqlval['other_deliv_id']; // 追加 - if (intval($other_deliv_id) === 0) { + if ((int) $other_deliv_id === 0) { // 別のお届け先最大登録数に達している場合、エラー - $from = 'dtb_other_deliv'; - $where = 'customer_id = ?'; - $arrVal = array($customer_id); + $from = 'dtb_other_deliv'; + $where = 'customer_id = ?'; + $arrVal = [$customer_id]; $deliv_count = $objQuery->count($from, $where, $arrVal); if ($deliv_count >= DELIV_ADDR_MAX) { return false; @@ -63,9 +64,9 @@ public function registAddress($sqlval) // 変更 } else { - $from = 'dtb_other_deliv'; - $where = 'customer_id = ? AND other_deliv_id = ?'; - $arrVal = array($customer_id, $other_deliv_id); + $from = 'dtb_other_deliv'; + $where = 'customer_id = ? AND other_deliv_id = ?'; + $arrVal = [$customer_id, $other_deliv_id]; $deliv_count = $objQuery->count($from, $where, $arrVal); if ($deliv_count != 1) { return false; @@ -81,21 +82,22 @@ public function registAddress($sqlval) /** * お届け先を取得 * - * @param integer $other_deliv_id + * @param int $other_deliv_id + * * @return array() */ public function getAddress($other_deliv_id, $customer_id = '') { - if (self::delivErrorCheck(array('customer_id' => $customer_id, 'other_deliv_id' => $other_deliv_id))) { + if (self::delivErrorCheck(['customer_id' => $customer_id, 'other_deliv_id' => $other_deliv_id])) { return false; } $objQuery = SC_Query_Ex::getSingletonInstance(); - $col = '*'; - $from = 'dtb_other_deliv'; - $where = 'customer_id = ? AND other_deliv_id = ?'; - $arrVal = array($customer_id, $other_deliv_id); + $col = '*'; + $from = 'dtb_other_deliv'; + $where = 'customer_id = ? AND other_deliv_id = ?'; + $arrVal = [$customer_id, $other_deliv_id]; $address = $objQuery->getRow($col, $from, $where, $arrVal); return $address; @@ -104,27 +106,29 @@ public function getAddress($other_deliv_id, $customer_id = '') /** * お届け先の一覧を取得 * - * @param integer $customer_id - * @param integer $startno + * @param int $customer_id + * @param int $startno + * * @return array */ public function getList($customer_id, $startno = '') { - if (self::delivErrorCheck(array('customer_id' => $customer_id))) { + if (self::delivErrorCheck(['customer_id' => $customer_id])) { return false; } $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->setOrder('other_deliv_id DESC'); - //スマートフォン用の処理 + // スマートフォン用の処理 if ($startno != '') { $objQuery->setLimitOffset(SEARCH_PMAX, $startno); } - $col = '*'; - $from = 'dtb_other_deliv'; - $where = 'customer_id = ?'; - $arrVal = array($customer_id); + $col = '*'; + $from = 'dtb_other_deliv'; + $where = 'customer_id = ?'; + $arrVal = [$customer_id]; + return $objQuery->select($col, $from, $where, $arrVal); } @@ -135,15 +139,16 @@ public function getList($customer_id, $startno = '') */ public function deleteAddress($other_deliv_id, $customer_id = '') { - if (self::delivErrorCheck(array('customer_id' => $customer_id, 'other_deliv_id' => $other_deliv_id))) { + if (self::delivErrorCheck(['customer_id' => $customer_id, 'other_deliv_id' => $other_deliv_id])) { return false; } - $objQuery = SC_Query_Ex::getSingletonInstance(); + $objQuery = SC_Query_Ex::getSingletonInstance(); + + $from = 'dtb_other_deliv'; + $where = 'customer_id = ? AND other_deliv_id = ?'; + $arrVal = [$customer_id, $other_deliv_id]; - $from = 'dtb_other_deliv'; - $where = 'customer_id = ? AND other_deliv_id = ?'; - $arrVal = array($customer_id, $other_deliv_id); return $objQuery->delete($from, $where, $arrVal); } @@ -151,6 +156,7 @@ public function deleteAddress($other_deliv_id, $customer_id = '') * お届け先フォーム初期化 * * @param SC_FormParam $objFormParam SC_FormParam インスタンス + * * @return void */ public function setFormParam(&$objFormParam) @@ -163,6 +169,7 @@ public function setFormParam(&$objFormParam) * お届け先フォームエラーチェック * * @param SC_FormParam $objFormParam SC_FormParam インスタンス + * * @return void */ public function errorCheck(&$objFormParam) @@ -176,7 +183,8 @@ public function errorCheck(&$objFormParam) * お届け先エラーチェック * * @param array $arrParam - * @return boolean / false + * + * @return bool / false */ public function delivErrorCheck($arrParam) { diff --git a/data/class/helper/SC_Helper_BestProducts.php b/data/class/helper/SC_Helper_BestProducts.php index e38f55b4d7..6b7637e020 100644 --- a/data/class/helper/SC_Helper_BestProducts.php +++ b/data/class/helper/SC_Helper_BestProducts.php @@ -24,8 +24,8 @@ /** * おすすめ商品を管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_BestProducts @@ -33,8 +33,9 @@ class SC_Helper_BestProducts /** * おすすめ商品の情報を取得. * - * @param integer $best_id おすすめ商品ID - * @param boolean $has_deleted 削除されたおすすめ商品も含む場合 true; 初期値 false + * @param int $best_id おすすめ商品ID + * @param bool $has_deleted 削除されたおすすめ商品も含む場合 true; 初期値 false + * * @return array */ public static function getBestProducts($best_id, $has_deleted = false) @@ -45,7 +46,7 @@ public static function getBestProducts($best_id, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select($col, 'dtb_best_products', $where, array($best_id)); + $arrRet = $objQuery->select($col, 'dtb_best_products', $where, [$best_id]); return $arrRet[0]; } @@ -53,8 +54,9 @@ public static function getBestProducts($best_id, $has_deleted = false) /** * おすすめ商品の情報をランクから取得. * - * @param integer $rank ランク - * @param boolean $has_deleted 削除されたおすすめ商品も含む場合 true; 初期値 false + * @param int $rank ランク + * @param bool $has_deleted 削除されたおすすめ商品も含む場合 true; 初期値 false + * * @return array */ public static function getByRank($rank, $has_deleted = false) @@ -65,7 +67,7 @@ public static function getByRank($rank, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select($col, 'dtb_best_products', $where, array($rank)); + $arrRet = $objQuery->select($col, 'dtb_best_products', $where, [$rank]); return $arrRet[0]; } @@ -73,9 +75,10 @@ public static function getByRank($rank, $has_deleted = false) /** * おすすめ商品一覧の取得. * - * @param integer $dispNumber 表示件数 - * @param integer $pageNumber ページ番号 - * @param boolean $has_deleted 削除されたおすすめ商品も含む場合 true; 初期値 false + * @param int $dispNumber 表示件数 + * @param int $pageNumber ページ番号 + * @param bool $has_deleted 削除されたおすすめ商品も含む場合 true; 初期値 false + * * @return array */ public static function getList($dispNumber = 0, $pageNumber = 0, $has_deleted = false) @@ -90,7 +93,7 @@ public static function getList($dispNumber = 0, $pageNumber = 0, $has_deleted = $objQuery->setOrder('rank'); if ($dispNumber > 0) { if ($pageNumber > 0) { - $objQuery->setLimitOffset($dispNumber, (($pageNumber - 1) * $dispNumber)); + $objQuery->setLimitOffset($dispNumber, ($pageNumber - 1) * $dispNumber); } else { $objQuery->setLimit($dispNumber); } @@ -104,6 +107,7 @@ public static function getList($dispNumber = 0, $pageNumber = 0, $has_deleted = * おすすめ商品の登録. * * @param array $sqlval + * * @return multiple 登録成功:おすすめ商品ID, 失敗:FALSE */ public static function saveBestProducts($sqlval) @@ -126,16 +130,17 @@ public static function saveBestProducts($sqlval) unset($sqlval['creator_id']); unset($sqlval['create_date']); $where = 'best_id = ?'; - $ret = $objQuery->update('dtb_best_products', $sqlval, $where, array($best_id)); + $ret = $objQuery->update('dtb_best_products', $sqlval, $where, [$best_id]); } - return ($ret) ? $sqlval['best_id'] : FALSE; + return ($ret) ? $sqlval['best_id'] : false; } /** * おすすめ商品の削除. * - * @param integer $best_id おすすめ商品ID + * @param int $best_id おすすめ商品ID + * * @return void */ public static function deleteBestProducts($best_id) @@ -143,9 +148,9 @@ public static function deleteBestProducts($best_id) $objQuery = SC_Query_Ex::getSingletonInstance(); $table = 'dtb_best_products'; - $arrVal = array('del_flg' => 1); + $arrVal = ['del_flg' => 1]; $where = 'best_id = ?'; - $arrWhereVal = array($best_id); + $arrWhereVal = [$best_id]; $objQuery->update($table, $arrVal, $where, $arrWhereVal); } @@ -153,6 +158,7 @@ public static function deleteBestProducts($best_id) * 商品IDの配列からおすすめ商品を削除. * * @param array $productIDs 商品ID + * * @return void */ public static function deleteByProductIDs($productIDs) @@ -168,7 +174,8 @@ public static function deleteByProductIDs($productIDs) /** * おすすめ商品の表示順をひとつ上げる. * - * @param integer $best_id おすすめ商品ID + * @param int $best_id おすすめ商品ID + * * @return void */ public static function rankUp($best_id) @@ -196,7 +203,8 @@ public static function rankUp($best_id) /** * おすすめ商品の表示順をひとつ下げる. * - * @param integer $best_id おすすめ商品ID + * @param int $best_id おすすめ商品ID + * * @return void */ public static function rankDown($best_id) @@ -224,8 +232,9 @@ public static function rankDown($best_id) /** * 対象IDのrankを指定値に変更する * - * @param integer $best_id 対象ID - * @param integer $rank 変更したいrank値 + * @param int $best_id 対象ID + * @param int $rank 変更したいrank値 + * * @return void */ public static function changeRank($best_id, $rank) @@ -233,9 +242,9 @@ public static function changeRank($best_id, $rank) $objQuery = SC_Query_Ex::getSingletonInstance(); $table = 'dtb_best_products'; - $sqlval = array('rank' => $rank); + $sqlval = ['rank' => $rank]; $where = 'best_id = ?'; - $arrWhereVal = array($best_id); + $arrWhereVal = [$best_id]; $objQuery->update($table, $sqlval, $where, $arrWhereVal); } } diff --git a/data/class/helper/SC_Helper_Bloc.php b/data/class/helper/SC_Helper_Bloc.php index 228a4a8854..7d4e32a5af 100644 --- a/data/class/helper/SC_Helper_Bloc.php +++ b/data/class/helper/SC_Helper_Bloc.php @@ -24,13 +24,13 @@ /** * ブロックを管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_Bloc { - private $device_type_id = NULL; + private $device_type_id = null; public function __construct($devide_type_id = DEVICE_TYPE_PC) { @@ -40,7 +40,8 @@ public function __construct($devide_type_id = DEVICE_TYPE_PC) /** * ブロックの情報を取得. * - * @param integer $bloc_id ブロックID + * @param int $bloc_id ブロックID + * * @return array */ public function getBloc($bloc_id) @@ -48,11 +49,11 @@ public function getBloc($bloc_id) $objQuery = SC_Query_Ex::getSingletonInstance(); $col = '*'; $where = 'bloc_id = ? AND device_type_id = ?'; - $arrRet = $objQuery->getRow($col, 'dtb_bloc', $where, array($bloc_id, $this->device_type_id)); + $arrRet = $objQuery->getRow($col, 'dtb_bloc', $where, [$bloc_id, $this->device_type_id]); if (SC_Utils_Ex::isAbsoluteRealPath($arrRet['tpl_path'])) { $tpl_path = $arrRet['tpl_path']; } else { - $tpl_path = SC_Helper_PageLayout_Ex::getTemplatePath($this->device_type_id) . BLOC_DIR . $arrRet['tpl_path']; + $tpl_path = SC_Helper_PageLayout_Ex::getTemplatePath($this->device_type_id).BLOC_DIR.$arrRet['tpl_path']; } if (file_exists($tpl_path)) { $arrRet['bloc_html'] = file_get_contents($tpl_path); @@ -72,7 +73,7 @@ public function getList() $col = '*'; $where = 'device_type_id = ?'; $table = 'dtb_bloc'; - $arrRet = $objQuery->select($col, $table, $where, array($this->device_type_id)); + $arrRet = $objQuery->select($col, $table, $where, [$this->device_type_id]); return $arrRet; } @@ -83,11 +84,11 @@ public function getList() * @param string $where * @param array $sqlval */ - public function getWhere($where = '', $sqlval = array()) + public function getWhere($where = '', $sqlval = []) { $objQuery = SC_Query_Ex::getSingletonInstance(); $col = '*'; - $where = 'device_type_id = ? ' . (SC_Utils_Ex::isBlank($where) ? $where : 'AND ' . $where); + $where = 'device_type_id = ? '.(SC_Utils_Ex::isBlank($where) ? $where : 'AND '.$where); array_unshift($sqlval, $this->device_type_id); $table = 'dtb_bloc'; $arrRet = $objQuery->select($col, $table, $where, $sqlval); @@ -99,6 +100,7 @@ public function getWhere($where = '', $sqlval = array()) * ブロックの登録. * * @param array $sqlval + * * @return multiple 登録成功:ブロックID, 失敗:FALSE */ public function save($sqlval) @@ -108,13 +110,13 @@ public function save($sqlval) // blod_id が空の場合は新規登録 $is_new = SC_Utils_Ex::isBlank($sqlval['bloc_id']); - $bloc_dir = SC_Helper_PageLayout_Ex::getTemplatePath($sqlval['device_type_id']) . BLOC_DIR; + $bloc_dir = SC_Helper_PageLayout_Ex::getTemplatePath($sqlval['device_type_id']).BLOC_DIR; // 既存データの重複チェック if (!$is_new) { $arrExists = $this->getBloc($sqlval['bloc_id']); // 既存のファイルが存在する場合は削除しておく - $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl'; + $exists_file = $bloc_dir.$arrExists[0]['filename'].'.tpl'; if (file_exists($exists_file)) { unlink($exists_file); } @@ -122,23 +124,23 @@ public function save($sqlval) $table = 'dtb_bloc'; $arrValues = $objQuery->extractOnlyColsOf($table, $sqlval); - $arrValues['tpl_path'] = $sqlval['filename'] . '.tpl'; + $arrValues['tpl_path'] = $sqlval['filename'].'.tpl'; $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; // 新規登録 if ($is_new || SC_Utils_Ex::isBlank($arrExists)) { $objQuery->setOrder(''); $arrValues['bloc_id'] = 1 + $objQuery->max('bloc_id', $table, 'device_type_id = ?', - array($arrValues['device_type_id'])); + [$arrValues['device_type_id']]); $arrValues['create_date'] = 'CURRENT_TIMESTAMP'; $objQuery->insert($table, $arrValues); // 更新 } else { $objQuery->update($table, $arrValues, 'bloc_id = ? AND device_type_id = ?', - array($arrValues['bloc_id'], $arrValues['device_type_id'])); + [$arrValues['bloc_id'], $arrValues['device_type_id']]); } - $bloc_path = $bloc_dir . $arrValues['tpl_path']; + $bloc_path = $bloc_dir.$arrValues['tpl_path']; if (!SC_Helper_FileManager_Ex::sfWriteFile($bloc_path, $sqlval['bloc_html'])) { $objQuery->rollback(); @@ -153,24 +155,25 @@ public function save($sqlval) /** * ブロックの削除. * - * @param integer $bloc_id - * @return boolean + * @param int $bloc_id + * + * @return bool */ public function delete($bloc_id) { $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); - $arrExists = $this->getWhere('bloc_id = ? AND deletable_flg = 1', array($bloc_id)); + $arrExists = $this->getWhere('bloc_id = ? AND deletable_flg = 1', [$bloc_id]); $is_error = false; if (!SC_Utils_Ex::isBlank($arrExists)) { $objQuery->delete('dtb_bloc', 'bloc_id = ? AND device_type_id = ?', - array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id'])); + [$arrExists[0]['bloc_id'], $arrExists[0]['device_type_id']]); $objQuery->delete('dtb_blocposition', 'bloc_id = ? AND device_type_id = ?', - array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id'])); + [$arrExists[0]['bloc_id'], $arrExists[0]['device_type_id']]); - $bloc_dir = SC_Helper_PageLayout_Ex::getTemplatePath($this->device_type_id) . BLOC_DIR; - $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl'; + $bloc_dir = SC_Helper_PageLayout_Ex::getTemplatePath($this->device_type_id).BLOC_DIR; + $exists_file = $bloc_dir.$arrExists[0]['filename'].'.tpl'; // ファイルの削除 if (file_exists($exists_file)) { @@ -195,7 +198,7 @@ public function delete($bloc_id) /** * 端末種別IDのメンバー変数を取得. * - * @return integer 端末種別ID + * @return int 端末種別ID */ public function getDeviceTypeID() { diff --git a/data/class/helper/SC_Helper_CSV.php b/data/class/helper/SC_Helper_CSV.php index 7a2d0a7c77..0b1de8bd4c 100644 --- a/data/class/helper/SC_Helper_CSV.php +++ b/data/class/helper/SC_Helper_CSV.php @@ -1,4 +1,5 @@ init(); + } + + /** + * 項目情報を初期化する. + * + * @return void + */ + public function init() + { + $this->arrSubnavi = [ + 1 => 'product', + 2 => 'customer', + 3 => 'order', + 4 => 'review', + 5 => 'category', + ]; + + $this->arrSubnaviName = [ + 1 => '商品管理', + 2 => '会員管理', + 3 => '受注管理', + 4 => 'レビュー', + 5 => 'カテゴリ', + ]; + } + + /** + * CSVファイルを送信する + * + * @param int $csv_id CSVフォーマットID + * @param string $where WHERE条件文 + * @param array $arrVal プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。 + * @param string $order ORDER文 + * @param bool $is_download true:ダウンロード用出力までさせる false:CSVの内容を返す(旧方式、メモリを食います。) + * + * @return bool|string $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string + */ + public function sfDownloadCsv($csv_id, $where = '', $arrVal = [], $order = '', $is_download = false) + { + $objQuery = SC_Query_Ex::getSingletonInstance(); + + // CSV出力タイトル行の作成 + $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfGetCsvOutput($csv_id, 'status = '.CSV_COLUMN_STATUS_FLG_ENABLE)); + if (count($arrOutput) <= 0) { + return false; + } // 失敗終了 + $arrOutputCols = $arrOutput['col']; + + $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true); + + // 商品の場合 + $from = ''; + if ($csv_id == 1) { + // この WHERE 句を足さないと無効な規格も出力される。現行仕様と合わせる為追加。 + $inner_where = 'dtb_products_class.del_flg = 0'; + $from = SC_Product_Ex::prdclsSQL($inner_where); + // 会員の場合 + } elseif ($csv_id == 2) { + $from = 'dtb_customer'; + // 注文の場合 + } elseif ($csv_id == 3) { + $from = 'dtb_order'; + // レビューの場合 + } elseif ($csv_id == 4) { + $from = 'dtb_review AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id'; + // カテゴリの場合 + } elseif ($csv_id == 5) { + $from = 'dtb_category'; + } + + $objQuery->setOrder($order); + $sql = $objQuery->getSql($cols, $from, $where); + + return $this->sfDownloadCsvFromSql($sql, $arrVal, $this->arrSubnavi[$csv_id], $arrOutput['disp_name'], $is_download); + } + + /** + * CSV 項目を出力する. + * + * @param int $csv_id CSV ID + * @param string $where SQL の WHERE 句 + * @param array $arrVal WHERE 句の要素 + * @param array $order SQL の ORDER BY 句 + * + * @return array CSV 項目の配列 + */ + public function sfGetCsvOutput($csv_id = '', $where = '', $arrVal = [], $order = 'rank, no') + { + $objQuery = SC_Query_Ex::getSingletonInstance(); + + $cols = 'no, csv_id, col, disp_name, rank, status, rw_flg, mb_convert_kana_option, size_const_type, error_check_types'; + $table = 'dtb_csv'; + + if (SC_Utils_Ex::sfIsInt($csv_id)) { + if ($where == '') { + $where = 'csv_id = ?'; + } else { + $where = "$where AND csv_id = ?"; + } + $arrVal[] = $csv_id; + } + $objQuery->setOrder($order); + + $arrRet = $objQuery->select($cols, $table, $where, $arrVal); + + return $arrRet; + } + + /** + * CSVが出力設定でインポート可能かのチェック + * + * @param array sfGetCsvOutputで取得した内容(またはそれと同等の配列) + * + * @return bool true:インポート可能、false:インポート不可 + */ + public function sfIsImportCSVFrame(&$arrCSVFrame) + { + $result = true; + foreach ($arrCSVFrame as $val) { + if ($val['status'] != CSV_COLUMN_STATUS_FLG_ENABLE + && $val['rw_flg'] == CSV_COLUMN_RW_FLG_READ_WRITE + && $val['error_check_types'] != '' + && strpos(strtoupper($val['error_check_types']), 'EXIST_CHECK') !== false + ) { + // 必須フィールド + $result = false; + } + } + + return $result; + } + + /** + * CSVが出力設定で更新可能かのチェック + * + * @param array sfGetCsvOutputで取得した内容(またはそれと同等の配列) + * + * @return bool true:更新可能、false:新規追加のみ不可 + */ + public function sfIsUpdateCSVFrame(&$arrCSVFrame) + { + $result = true; + foreach ($arrCSVFrame as $val) { + if ($val['status'] != CSV_COLUMN_STATUS_FLG_ENABLE + && $val['rw_flg'] == CSV_COLUMN_RW_FLG_KEY_FIELD + ) { + // キーフィールド + $result = false; + } + } + + return $result; + } + + /** + * CSVファイルのカウント数を得る. + * + * @param resource $fp fopenを使用して作成したファイルポインタ + * + * @return int CSV のカウント数 + */ + public function sfGetCSVRecordCount($fp) + { + $count = 0; + while (!feof($fp)) { + $arrCSV = fgetcsv($fp, CSV_LINE_MAX); + $count++; + } + // ファイルポインタを戻す + if (rewind($fp)) { + return $count - 1; + } else { + return false; + } + } + + /** + * CSV作成 テンポラリファイル出力 コールバック関数 + * + * @param mixed $data 出力データ + * + * @return bool true (true:固定 false:中断) + */ + public function cbOutputCSV($data) + { + // mb_convert_variablesで変換できない文字は"?"にする + mb_substitute_character(SUBSTITUTE_CHAR); + // 1行目のみヘッダーを出力する + if ($this->output_header) { + $header = array_keys($data); + mb_convert_variables('cp932', CHAR_CODE, $header); + fputcsv($this->fpOutput, $header); + $this->output_header = false; + } + mb_convert_variables('cp932', CHAR_CODE, $data); + fputcsv($this->fpOutput, $data); + SC_Utils_Ex::extendTimeOut(); + + return true; + } + + /** + * SQL文からクエリ実行し CSVファイルを送信する + * + * @param int $sql SQL文 + * @param array $arrVal プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。 + * @param string ファイル名の頭に付ける文字列 + * @param array|null ヘッダ出力列配列。null の場合、SQL 文の列名を出力する。 + * @param bool true:ダウンロード用出力までさせる false:CSVの内容を返す(旧方式、メモリを食います。) + * + * @return bool|string $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string + */ + public function sfDownloadCsvFromSql($sql, $arrVal = [], $file_head = 'csv', $arrHeader = null, $is_download = false) + { + $objQuery = SC_Query_Ex::getSingletonInstance(); + + if (!$is_download) { + ob_start(); + } + + $this->fpOutput = &SC_Helper_CSV_Ex::fopen_for_output_csv(); + + // mb_convert_variablesで変換できない文字は"?"にする + mb_substitute_character(SUBSTITUTE_CHAR); + // ヘッダー構築 + $this->output_header = false; + if (is_array($arrHeader)) { + mb_convert_variables('cp932', CHAR_CODE, $arrHeader); + fputcsv($this->fpOutput, $arrHeader); + } elseif (is_null($arrHeader)) { + // ループバック内でヘッダーを出力する + $this->output_header = true; + } + + $objQuery->doCallbackAll([&$this, 'cbOutputCSV'], $sql, $arrVal); + + // コールバック内でヘッダー出力する場合、0行時にヘッダーを生成できない。 + // コールバックが呼ばれていない場合、念のため CRLF を出力しておく。 + // XXX WEB画面前提で、アラート表示する流れのほうが親切かもしれない。 + if ($this->output_header) { + fwrite($this->fpOutput, "\r\n"); + } + + fclose($this->fpOutput); + + // CSV 用の HTTP ヘッダーを送出する。 + if ($is_download) { + $file_name = $file_head.'_'.date('ymd_His').'.csv'; + SC_Response_Ex::headerForDownload($file_name); + $return = true; + } + // 戻り値にCSVデータをセットする + else { + $return = ob_get_clean(); + } + + return $return; + } + + /** + * 前方互換用 + * + * @deprecated 2.13.2 fputcsv を使うこと。(sfDownloadCsvFromSql や cbOutputCSV の実装を参照) + */ + public function sfArrayToCsv($fields, $delimiter = ',', $enclosure = '"', $arrayDelimiter = '|') + { + trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); + if (strlen($delimiter) != 1) { + trigger_error('delimiter must be a single character', E_USER_WARNING); + + return ''; + } + + if (strlen($enclosure) < 1) { + trigger_error('enclosure must be a single character', E_USER_WARNING); + + return ''; + } + + foreach ($fields as $key => $value) { + $field = &$fields[$key]; + + // 配列を「|」区切りの文字列に変換する + if (is_array($field)) { + $field = implode($arrayDelimiter, $field); + } + + /* enclose a field that contains a delimiter, an enclosure character, or a newline */ + if (is_string($field) + && preg_match('/['.preg_quote($delimiter).preg_quote($enclosure).'\\s]/', $field) + ) { + $field = $enclosure.preg_replace('/'.preg_quote($enclosure).'/', $enclosure.$enclosure, $field).$enclosure; + } + } + + return implode($delimiter, $fields); + } + + /** + * 前方互換用 + * + * @deprecated 2.13.2 + */ + public function lfDownloadCsv($arrData, $prefix = '') + { + trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); + if ($prefix == '') { + $dir_name = SC_Utils_Ex::sfUpDirName(); + $file_name = $dir_name.date('ymdHis').'.csv'; + } else { + $file_name = $prefix.date('ymdHis').'.csv'; + } + SC_Response_Ex::headerForDownload($file_name); + + /* データを出力 */ + $fp = &SC_Helper_CSV_Ex::fopen_for_output_csv(); + foreach ($arrData as $lineArray) { + fputcsv($fp, $lineArray); + } + fclose($fp); + } + + /** + * 前方互換用 + * + * @deprecated 2.13.2 + */ + public function lfDownloadCSVFile($filepath, $prefix = '') + { + trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); + $file_name = $prefix.date('YmdHis').'.csv'; + SC_Response_Ex::headerForDownload($file_name); + + /* データを出力 */ + // file_get_contentsはメモリマッピングも自動的に使ってくれるので高速&省メモリ + echo file_get_contents($filepath); + } + + /** + * CSV 出力用のファイルポインタリソースを開く + * + * @return resource ファイルポインタリソース + */ + public static function &fopen_for_output_csv($filename = 'php://output') + { + $fp = fopen($filename, 'w'); + + stream_filter_append($fp, 'convert.eccube_lf2crlf'); + + return $fp; + } + } + + /** + * 改行コードを CRLF に変換するフィルター + * + * @author Seasoft 塚田将久 (新規作成) + * * @version $Id$ */ -class SC_Helper_CSV -{ - /** 項目英名 */ - public $arrSubnavi; - - /** 項目名 */ - public $arrSubnaviName; - - /** @var resource */ - public $fpOutput; - - /** ヘッダーを出力するか (cbOutputCSV 用) */ - private $output_header = false; - - /** - * デフォルトコンストラクタ. - */ - public function __construct() - { - $this->init(); - } - - /** - * 項目情報を初期化する. - * - * @access private - * @return void - */ - public function init() - { - $this->arrSubnavi = array( - 1 => 'product', - 2 => 'customer', - 3 => 'order', - 4 => 'review', - 5 => 'category', - ); - - $this->arrSubnaviName = array( - 1 => '商品管理', - 2 => '会員管理', - 3 => '受注管理', - 4 => 'レビュー', - 5 => 'カテゴリ', - ); - } - - /** - * CSVファイルを送信する - * - * @param integer $csv_id CSVフォーマットID - * @param string $where WHERE条件文 - * @param array $arrVal プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。 - * @param string $order ORDER文 - * @param boolean $is_download true:ダウンロード用出力までさせる false:CSVの内容を返す(旧方式、メモリを食います。) - * @return boolean|string $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string - */ - public function sfDownloadCsv($csv_id, $where = '', $arrVal = array(), $order = '', $is_download = false) - { - $objQuery = SC_Query_Ex::getSingletonInstance(); - - // CSV出力タイトル行の作成 - $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfGetCsvOutput($csv_id, 'status = ' . CSV_COLUMN_STATUS_FLG_ENABLE)); - if (count($arrOutput) <= 0) return false; // 失敗終了 - $arrOutputCols = $arrOutput['col']; - - $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true); - - // 商品の場合 - $from = ''; - if ($csv_id == 1) { - // この WHERE 句を足さないと無効な規格も出力される。現行仕様と合わせる為追加。 - $inner_where = 'dtb_products_class.del_flg = 0'; - $from = SC_Product_Ex::prdclsSQL($inner_where); - // 会員の場合 - } elseif ($csv_id == 2) { - $from = 'dtb_customer'; - // 注文の場合 - } elseif ($csv_id == 3) { - $from = 'dtb_order'; - // レビューの場合 - } elseif ($csv_id == 4) { - $from = 'dtb_review AS A INNER JOIN dtb_products AS B on A.product_id = B.product_id'; - // カテゴリの場合 - } elseif ($csv_id == 5) { - $from = 'dtb_category'; - } - - $objQuery->setOrder($order); - $sql = $objQuery->getSql($cols, $from, $where); - - return $this->sfDownloadCsvFromSql($sql, $arrVal, $this->arrSubnavi[$csv_id], $arrOutput['disp_name'], $is_download); - } - - /** - * CSV 項目を出力する. - * - * @param integer $csv_id CSV ID - * @param string $where SQL の WHERE 句 - * @param array $arrVal WHERE 句の要素 - * @param array $order SQL の ORDER BY 句 - * @return array CSV 項目の配列 - */ - public function sfGetCsvOutput($csv_id = '', $where = '', $arrVal = array(), $order = 'rank, no') - { - $objQuery = SC_Query_Ex::getSingletonInstance(); - - $cols = 'no, csv_id, col, disp_name, rank, status, rw_flg, mb_convert_kana_option, size_const_type, error_check_types'; - $table = 'dtb_csv'; - - if (SC_Utils_Ex::sfIsInt($csv_id)) { - if ($where == '') { - $where = 'csv_id = ?'; - } else { - $where = "$where AND csv_id = ?"; - } - $arrVal[] = $csv_id; - } - $objQuery->setOrder($order); - - $arrRet = $objQuery->select($cols, $table, $where, $arrVal); - - return $arrRet; - } - - /** - * CSVが出力設定でインポート可能かのチェック - * - * @param array sfGetCsvOutputで取得した内容(またはそれと同等の配列) - * @return boolean true:インポート可能、false:インポート不可 - */ - public function sfIsImportCSVFrame(&$arrCSVFrame) - { - $result = true; - foreach ($arrCSVFrame as $val) { - if ($val['status'] != CSV_COLUMN_STATUS_FLG_ENABLE - && $val['rw_flg'] == CSV_COLUMN_RW_FLG_READ_WRITE - && $val['error_check_types'] != '' - && strpos(strtoupper($val['error_check_types']), 'EXIST_CHECK') !== FALSE - ) { - //必須フィールド - $result = false; - } - } - - return $result; - } - - /** - * CSVが出力設定で更新可能かのチェック - * - * @param array sfGetCsvOutputで取得した内容(またはそれと同等の配列) - * @return boolean true:更新可能、false:新規追加のみ不可 - */ - public function sfIsUpdateCSVFrame(&$arrCSVFrame) - { - $result = true; - foreach ($arrCSVFrame as $val) { - if ($val['status'] != CSV_COLUMN_STATUS_FLG_ENABLE - && $val['rw_flg'] == CSV_COLUMN_RW_FLG_KEY_FIELD - ) { - //キーフィールド - $result = false; - } - } - - return $result; - } - - /** - * CSVファイルのカウント数を得る. - * - * @param resource $fp fopenを使用して作成したファイルポインタ - * @return integer CSV のカウント数 - */ - public function sfGetCSVRecordCount($fp) - { - $count = 0; - while (!feof($fp)) { - $arrCSV = fgetcsv($fp, CSV_LINE_MAX); - $count++; - } - // ファイルポインタを戻す - if (rewind($fp)) { - return $count-1; - } else { - return FALSE; - } - } - - /** - * CSV作成 テンポラリファイル出力 コールバック関数 - * - * @param mixed $data 出力データ - * @return boolean true (true:固定 false:中断) - */ - public function cbOutputCSV($data) - { - // mb_convert_variablesで変換できない文字は"?"にする - mb_substitute_character(SUBSTITUTE_CHAR); - // 1行目のみヘッダーを出力する - if ($this->output_header) { - $header = array_keys($data); - mb_convert_variables('cp932', CHAR_CODE, $header); - fputcsv($this->fpOutput, $header); - $this->output_header = false; - } - mb_convert_variables('cp932', CHAR_CODE, $data); - fputcsv($this->fpOutput, $data); - SC_Utils_Ex::extendTimeOut(); - - return true; - } - - /** - * SQL文からクエリ実行し CSVファイルを送信する - * - * @param integer $sql SQL文 - * @param array $arrVal プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。 - * @param string ファイル名の頭に付ける文字列 - * @param array|null ヘッダ出力列配列。null の場合、SQL 文の列名を出力する。 - * @param boolean true:ダウンロード用出力までさせる false:CSVの内容を返す(旧方式、メモリを食います。) - * @return boolean|string $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string - */ - public function sfDownloadCsvFromSql($sql, $arrVal = array(), $file_head = 'csv', $arrHeader = null, $is_download = false) - { - $objQuery = SC_Query_Ex::getSingletonInstance(); - - if (!$is_download) { - ob_start(); - } - - $this->fpOutput =& SC_Helper_CSV_Ex::fopen_for_output_csv(); - - // mb_convert_variablesで変換できない文字は"?"にする - mb_substitute_character(SUBSTITUTE_CHAR); - // ヘッダー構築 - $this->output_header = false; - if (is_array($arrHeader)) { - mb_convert_variables('cp932', CHAR_CODE, $arrHeader); - fputcsv($this->fpOutput, $arrHeader); - } elseif (is_null($arrHeader)) { - // ループバック内でヘッダーを出力する - $this->output_header = true; - } - - $objQuery->doCallbackAll(array(&$this, 'cbOutputCSV'), $sql, $arrVal); - - // コールバック内でヘッダー出力する場合、0行時にヘッダーを生成できない。 - // コールバックが呼ばれていない場合、念のため CRLF を出力しておく。 - // XXX WEB画面前提で、アラート表示する流れのほうが親切かもしれない。 - if ($this->output_header) { - fwrite($this->fpOutput, "\r\n"); - } - - fclose($this->fpOutput); - - // CSV 用の HTTP ヘッダーを送出する。 - if ($is_download) { - $file_name = $file_head . '_' . date('ymd_His') .'.csv'; - SC_Response_Ex::headerForDownload($file_name); - $return = true; - } - // 戻り値にCSVデータをセットする - else { - $return = ob_get_clean(); - } - - return $return; - } - - /** - * 前方互換用 - * - * @deprecated 2.13.2 fputcsv を使うこと。(sfDownloadCsvFromSql や cbOutputCSV の実装を参照) - */ - public function sfArrayToCsv($fields, $delimiter = ',', $enclosure = '"', $arrayDelimiter = '|') - { - trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); - if (strlen($delimiter) != 1) { - trigger_error('delimiter must be a single character', E_USER_WARNING); - - return ''; - } - - if (strlen($enclosure) < 1) { - trigger_error('enclosure must be a single character', E_USER_WARNING); - - return ''; - } - - foreach ($fields as $key => $value) { - $field =& $fields[$key]; - - // 配列を「|」区切りの文字列に変換する - if (is_array($field)) { - $field = implode($arrayDelimiter, $field); - } - - /* enclose a field that contains a delimiter, an enclosure character, or a newline */ - if (is_string($field) - && preg_match('/[' . preg_quote($delimiter) . preg_quote($enclosure) . '\\s]/', $field) - ) { - $field = $enclosure . preg_replace('/' . preg_quote($enclosure) . '/', $enclosure . $enclosure, $field) . $enclosure; - } - } - - return implode($delimiter, $fields); - } - - /** - * 前方互換用 - * - * @deprecated 2.13.2 - */ - public function lfDownloadCsv($arrData, $prefix = '') - { - trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); - if ($prefix == '') { - $dir_name = SC_Utils_Ex::sfUpDirName(); - $file_name = $dir_name . date('ymdHis') .'.csv'; - } else { - $file_name = $prefix . date('ymdHis') .'.csv'; - } - SC_Response_Ex::headerForDownload($file_name); - - /* データを出力 */ - $fp =& SC_Helper_CSV_Ex::fopen_for_output_csv(); - foreach ($arrData as $lineArray) { - fputcsv($fp, $lineArray); - } - fclose($fp); - } - - /** - * 前方互換用 - * - * @deprecated 2.13.2 - */ - public function lfDownloadCSVFile($filepath, $prefix = '') - { - trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); - $file_name = $prefix . date('YmdHis') . '.csv'; - SC_Response_Ex::headerForDownload($file_name); - - /* データを出力 */ - // file_get_contentsはメモリマッピングも自動的に使ってくれるので高速&省メモリ - echo file_get_contents($filepath); - } - - /** - * CSV 出力用のファイルポインタリソースを開く - * - * @return resource ファイルポインタリソース - */ - public static function &fopen_for_output_csv($filename = 'php://output') - { - $fp = fopen($filename, 'w'); - - stream_filter_append($fp, 'convert.eccube_lf2crlf'); - - return $fp; - } -} - -/** - * 改行コードを CRLF に変換するフィルター - * - * @package php_user_filter - * @author Seasoft 塚田将久 (新規作成) - * @version $Id$ - */ -class php_user_filter_lf2crlf extends php_user_filter -{ - #[\ReturnTypeWillChange] - public function filter($in, $out, &$consumed, $closing) - { - while ($bucket = stream_bucket_make_writeable($in)) { - $bucket->data = preg_replace("/[\r\n]+$/", "\r\n", $bucket->data); - $consumed += $bucket->datalen; - stream_bucket_append($out, $bucket); - } - return PSFS_PASS_ON; - } -} -stream_filter_register('convert.eccube_lf2crlf', 'php_user_filter_lf2crlf'); + class php_user_filter_lf2crlf extends php_user_filter + { + #[\ReturnTypeWillChange] + public function filter($in, $out, &$consumed, $closing) + { + while ($bucket = stream_bucket_make_writeable($in)) { + $bucket->data = preg_replace("/[\r\n]+$/", "\r\n", $bucket->data); + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + } + + return PSFS_PASS_ON; + } + } + stream_filter_register('convert.eccube_lf2crlf', 'php_user_filter_lf2crlf'); diff --git a/data/class/helper/SC_Helper_Category.php b/data/class/helper/SC_Helper_Category.php index 69a6beeab0..903311134d 100644 --- a/data/class/helper/SC_Helper_Category.php +++ b/data/class/helper/SC_Helper_Category.php @@ -24,8 +24,8 @@ /** * カテゴリーを管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_Category @@ -35,9 +35,9 @@ class SC_Helper_Category /** * コンストラクター * - * @param boolean $count_check 登録商品数をチェックする場合はtrue + * @param bool $count_check 登録商品数をチェックする場合はtrue */ - public function __construct($count_check = FALSE) + public function __construct($count_check = false) { $this->count_check = $count_check; } @@ -45,7 +45,8 @@ public function __construct($count_check = FALSE) /** * カテゴリーの情報を取得. * - * @param integer $category_id カテゴリーID + * @param int $category_id カテゴリーID + * * @return array */ public function get($category_id) @@ -58,7 +59,7 @@ public function get($category_id) if ($this->count_check) { $where .= ' AND product_count > 0'; } - $arrRet = $objQuery->getRow($col, $from, $where, array($category_id)); + $arrRet = $objQuery->getRow($col, $from, $where, [$category_id]); return $arrRet; } @@ -66,12 +67,13 @@ public function get($category_id) /** * カテゴリー一覧の取得. * - * @param boolean $cid_to_key 配列のキーをカテゴリーIDにする場合はtrue + * @param bool $cid_to_key 配列のキーをカテゴリーIDにする場合はtrue + * * @return array カテゴリー一覧の配列 */ - public function getList($cid_to_key = FALSE) + public function getList($cid_to_key = false) { - static $arrCategory = array(), $cidIsKey = array(); + static $arrCategory = [], $cidIsKey = []; if (!isset($arrCategory[$this->count_check])) { $objQuery = SC_Query_Ex::getSingletonInstance(); @@ -108,7 +110,7 @@ public function getList($cid_to_key = FALSE) */ public function getTree() { - static $arrTree = array(); + static $arrTree = []; if (!isset($arrTree[$this->count_check])) { $arrList = $this->getList(); $arrTree[$this->count_check] = SC_Utils_Ex::buildTree('category_id', 'parent_category_id', LEVEL_MAX, $arrList); @@ -120,14 +122,15 @@ public function getTree() /** * 親カテゴリーIDの配列を取得. * - * @param integer $category_id 起点のカテゴリーID - * @param boolean $id_only IDだけの配列を返す場合はtrue + * @param int $category_id 起点のカテゴリーID + * @param bool $id_only IDだけの配列を返す場合はtrue + * * @return array */ - public function getTreeTrail($category_id, $id_only = TRUE) + public function getTreeTrail($category_id, $id_only = true) { - $arrCategory = $this->getList(TRUE); - $arrTrailID = SC_Utils_Ex::getTreeTrail($category_id, 'category_id', 'parent_category_id', $arrCategory, TRUE, 0, $id_only); + $arrCategory = $this->getList(true); + $arrTrailID = SC_Utils_Ex::getTreeTrail($category_id, 'category_id', 'parent_category_id', $arrCategory, true, 0, $id_only); return $arrTrailID; } @@ -136,15 +139,17 @@ public function getTreeTrail($category_id, $id_only = TRUE) * 指定カテゴリーの子孫カテゴリーを取得 * * @param int $category_id カテゴリーID + * * @return array */ - public function getTreeBranch($category_id) { + public function getTreeBranch($category_id) + { $arrTree = $this->getTree(); $arrTrail = $this->getTreeTrail($category_id, true); // ルートから指定カテゴリーまでたどる. foreach ($arrTrail as $parent_id) { - $nextTree = array(); + $nextTree = []; foreach ($arrTree as $branch) { if ($branch['category_id'] == $parent_id && isset($branch['children'])) { $nextTree = $branch['children']; @@ -160,9 +165,11 @@ public function getTreeBranch($category_id) { * カテゴリーの削除 * * @param int $category_id カテゴリーID + * * @return void */ - public function delete($category_id) { + public function delete($category_id) + { $objDb = new SC_Helper_DB_Ex(); // ランク付きレコードの削除(※処理負荷を考慮してレコードごと削除する。) $objDb->sfDeleteRankRecord('dtb_category', 'category_id', $category_id, '', true); @@ -173,9 +180,11 @@ public function delete($category_id) { * * @param int $category_id * @param bool $include_deleted + * * @return bool */ - public function isValidCategoryId($category_id, $include_deleted = false) { + public function isValidCategoryId($category_id, $include_deleted = false) + { if ($include_deleted) { $where = ''; } else { @@ -184,10 +193,11 @@ public function isValidCategoryId($category_id, $include_deleted = false) { if ( SC_Utils_Ex::sfIsInt($category_id) && !SC_Utils_Ex::sfIsZeroFilling($category_id) - && SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', array($category_id), $where) + && SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', [$category_id], $where) ) { return true; } + return false; } } diff --git a/data/class/helper/SC_Helper_Customer.php b/data/class/helper/SC_Helper_Customer.php index 305159cd78..f391a8f921 100644 --- a/data/class/helper/SC_Helper_Customer.php +++ b/data/class/helper/SC_Helper_Customer.php @@ -24,9 +24,8 @@ /** * 会員情報の登録・編集・検索ヘルパークラス. * - * - * @package Helper * @author Hirokazu Fukuda + * * @version $Id$ */ class SC_Helper_Customer @@ -36,8 +35,8 @@ class SC_Helper_Customer * * @param array $arrData 登録するデータの配列(SC_FormParamのgetDbArrayの戻り値) * @param array $customer_id nullの場合はinsert, 存在する場合はupdate - * @access public - * @return integer 登録編集したユーザーのcustomer_id + * + * @return int 登録編集したユーザーのcustomer_id */ public static function sfEditCustomerData($arrData, $customer_id = null) { @@ -50,7 +49,7 @@ public static function sfEditCustomerData($arrData, $customer_id = null) // salt値の生成(insert時)または取得(update時)。 if (is_numeric($customer_id)) { - $salt = $objQuery->get('salt', 'dtb_customer', 'customer_id = ? ', array($customer_id)); + $salt = $objQuery->get('salt', 'dtb_customer', 'customer_id = ? ', [$customer_id]); // 旧バージョン(2.11未満)からの移行を考慮 if (strlen($salt) === 0) { @@ -61,9 +60,9 @@ public static function sfEditCustomerData($arrData, $customer_id = null) $arrData['salt'] = $salt; } $is_password_updated = false; - //-- パスワードの更新がある場合は暗号化 - if ($arrData['password'] == DEFAULT_PASSWORD or $arrData['password'] == '') { - //更新しない + // -- パスワードの更新がある場合は暗号化 + if ($arrData['password'] == DEFAULT_PASSWORD || $arrData['password'] == '') { + // 更新しない unset($arrData['password']); } else { // 旧バージョン(2.11未満)からの移行を考慮 @@ -75,15 +74,15 @@ public static function sfEditCustomerData($arrData, $customer_id = null) $arrData['password'] = SC_Utils_Ex::sfGetHashString($arrData['password'], $salt); } - //-- 秘密の質問の更新がある場合は暗号化 - if ($arrData['reminder_answer'] == DEFAULT_PASSWORD or $arrData['reminder_answer'] == '') { - //更新しない + // -- 秘密の質問の更新がある場合は暗号化 + if ($arrData['reminder_answer'] == DEFAULT_PASSWORD || $arrData['reminder_answer'] == '') { + // 更新しない unset($arrData['reminder_answer']); // 旧バージョン(2.11未満)からの移行を考慮 if ($old_version_flag && $is_password_updated) { // パスワードが更新される場合は、平文になっている秘密の質問を暗号化する - $reminder_answer = $objQuery->get('reminder_answer', 'dtb_customer', 'customer_id = ? ', array($customer_id)); + $reminder_answer = $objQuery->get('reminder_answer', 'dtb_customer', 'customer_id = ? ', [$customer_id]); $arrData['reminder_answer'] = SC_Utils_Ex::sfGetHashString($reminder_answer, $salt); } } else { @@ -96,15 +95,15 @@ public static function sfEditCustomerData($arrData, $customer_id = null) } } - //デフォルト国IDを追加 + // デフォルト国IDを追加 if (FORM_COUNTRY_ENABLE == false) { $arrData['country_id'] = DEFAULT_COUNTRY_ID; } - //-- 編集登録実行 + // -- 編集登録実行 if (is_numeric($customer_id)) { // 編集 - $objQuery->update('dtb_customer', $arrData, 'customer_id = ? ', array($customer_id)); + $objQuery->update('dtb_customer', $arrData, 'customer_id = ? ', [$customer_id]); } else { // 新規登録 @@ -126,20 +125,21 @@ public static function sfEditCustomerData($arrData, $customer_id = null) /** * 注文番号、利用ポイント、加算ポイントから最終ポイントを取得する. * - * @param integer $order_id 注文番号 - * @param integer $use_point 利用ポイント - * @param integer $add_point 加算ポイント + * @param int $order_id 注文番号 + * @param int $use_point 利用ポイント + * @param int $add_point 加算ポイント + * * @return array 最終ポイントの配列 */ public static function sfGetCustomerPoint($order_id, $use_point, $add_point) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrRet = $objQuery->select('customer_id', 'dtb_order', 'order_id = ?', array($order_id)); + $arrRet = $objQuery->select('customer_id', 'dtb_order', 'order_id = ?', [$order_id]); $customer_id = $arrRet[0]['customer_id']; if ($customer_id != '' && $customer_id >= 1) { if (USE_POINT !== false) { - $arrRet = $objQuery->select('point', 'dtb_customer', 'customer_id = ?', array($customer_id)); + $arrRet = $objQuery->select('point', 'dtb_customer', 'customer_id = ?', [$customer_id]); $point = $arrRet[0]['point']; $total_point = $arrRet[0]['point'] - $use_point + $add_point; } else { @@ -151,7 +151,7 @@ public static function sfGetCustomerPoint($order_id, $use_point, $add_point) $point = ''; } - return array($point, $total_point); + return [$point, $total_point]; } /** @@ -160,7 +160,8 @@ public static function sfGetCustomerPoint($order_id, $use_point, $add_point) * XXX SC_CheckError からしか呼び出されず, 本クラスの中で SC_CheckError を呼び出している * * @param string $email メールアドレス - * @return integer 0:登録可能 1:登録済み 2:再登録制限期間内削除ユーザー 3:自分のアドレス + * + * @return int 0:登録可能 1:登録済み 2:再登録制限期間内削除ユーザー 3:自分のアドレス */ public static function sfCheckRegisterUserFromEmail($email) { @@ -177,7 +178,7 @@ public static function sfCheckRegisterUserFromEmail($email) $arrRet = $objQuery->select('email, update_date, del_flg', 'dtb_customer', 'email = ? OR email_mobile = ? ORDER BY del_flg', - array($email, $email)); + [$email, $email]); if (count($arrRet) > 0) { // 会員である場合 @@ -187,8 +188,8 @@ public static function sfCheckRegisterUserFromEmail($email) } else { // 退会した会員である場合 $leave_time = SC_Utils_Ex::sfDBDatetoTime($arrRet[0]['update_date']); - $now_time = time(); - $pass_time = $now_time - $leave_time; + $now_time = time(); + $pass_time = $now_time - $leave_time; // 退会から何時間-経過しているか判定する。 $limit_time = ENTRY_LIMIT_HOUR * 3600; if ($pass_time < $limit_time) { @@ -207,20 +208,21 @@ public static function sfCheckRegisterUserFromEmail($email) * * 会員の保持する email, mobile_email が, 引数 $email と一致するかチェックする * - * @param integer $customer_id チェック対象会員の会員ID + * @param int $customer_id チェック対象会員の会員ID * @param string $email チェック対象のメールアドレス - * @return boolean メールアドレスが重複する場合 true + * + * @return bool メールアドレスが重複する場合 true */ public static function sfCustomerEmailDuplicationCheck($customer_id, $email) { $objQuery = SC_Query_Ex::getSingletonInstance(); $arrResults = $objQuery->getRow('email, email_mobile', - 'dtb_customer', 'customer_id = ?', - array($customer_id)); + 'dtb_customer', 'customer_id = ?', + [$customer_id]); $return - = strlen($arrResults['email']) >= 1 && $email === $arrResults['email'] - || strlen($arrResults['email_mobile']) >= 1 && $email === $arrResults['email_mobile'] + = strlen($arrResults['email']) >= 1 && $email === $arrResults['email'] + || strlen($arrResults['email_mobile']) >= 1 && $email === $arrResults['email_mobile'] ; return $return; @@ -230,22 +232,22 @@ public static function sfCustomerEmailDuplicationCheck($customer_id, $email) * customer_idから会員情報を取得する * * @param mixed $customer_id - * @param boolean $mask_flg - * @access public + * @param bool $mask_flg + * * @return array 会員情報の配列を返す */ public static function sfGetCustomerData($customer_id, $mask_flg = true) { - $objQuery = SC_Query_Ex::getSingletonInstance(); + $objQuery = SC_Query_Ex::getSingletonInstance(); // 会員情報DB取得 - $ret = $objQuery->select('*', 'dtb_customer', 'customer_id=? AND del_flg = 0', array($customer_id)); + $ret = $objQuery->select('*', 'dtb_customer', 'customer_id=? AND del_flg = 0', [$customer_id]); if (empty($ret)) { trigger_error('存在しない会員IDです。', E_USER_ERROR); } - $arrForm = $ret[0]; + $arrForm = $ret[0]; // 確認項目に複製 $arrForm['email02'] = $arrForm['email']; @@ -254,13 +256,13 @@ public static function sfGetCustomerData($customer_id, $mask_flg = true) // 誕生日を年月日に分ける if (isset($arrForm['birth'])) { $birth = explode(' ', $arrForm['birth']); - list($arrForm['year'], $arrForm['month'], $arrForm['day']) = array_map("intval",explode('-', $birth[0])); + list($arrForm['year'], $arrForm['month'], $arrForm['day']) = array_map('intval', explode('-', $birth[0])); } if ($mask_flg) { - $arrForm['password'] = DEFAULT_PASSWORD; - $arrForm['password02'] = DEFAULT_PASSWORD; - $arrForm['reminder_answer'] = DEFAULT_PASSWORD; + $arrForm['password'] = DEFAULT_PASSWORD; + $arrForm['password02'] = DEFAULT_PASSWORD; + $arrForm['reminder_answer'] = DEFAULT_PASSWORD; } return $arrForm; @@ -271,19 +273,19 @@ public static function sfGetCustomerData($customer_id, $mask_flg = true) * * TODO: sfGetCustomerDataと統合したい * - * @param integer $customer_id 会員ID (指定無しでも構わないが、Where条件を入れる事) + * @param int $customer_id 会員ID (指定無しでも構わないが、Where条件を入れる事) * @param string $add_where 追加WHERE条件 * @param string[] $arrAddVal 追加WHEREパラメーター - * @access public + * * @return array 対象会員データ */ - public static function sfGetCustomerDataFromId($customer_id, $add_where = '', $arrAddVal = array()) + public static function sfGetCustomerDataFromId($customer_id, $add_where = '', $arrAddVal = []) { - $objQuery = SC_Query_Ex::getSingletonInstance(); + $objQuery = SC_Query_Ex::getSingletonInstance(); if ($add_where == '') { $where = 'customer_id = ? AND del_flg = 0'; - $arrData = $objQuery->getRow('*', 'dtb_customer', $where, array($customer_id)); + $arrData = $objQuery->getRow('*', 'dtb_customer', $where, [$customer_id]); } else { $where = $add_where; if (SC_Utils_Ex::sfIsInt($customer_id)) { @@ -299,7 +301,6 @@ public static function sfGetCustomerDataFromId($customer_id, $add_where = '', $a /** * 重複しない会員登録キーを発行する。 * - * @access public * @return string 会員登録キーの文字列 */ public static function sfGetUniqSecretKey() @@ -308,7 +309,7 @@ public static function sfGetUniqSecretKey() do { $uniqid = SC_Utils_Ex::sfGetUniqRandomId('r'); - $exists = $objQuery->exists('dtb_customer', 'secret_key = ?', array($uniqid)); + $exists = $objQuery->exists('dtb_customer', 'secret_key = ?', [$uniqid]); } while ($exists); return $uniqid; @@ -318,29 +319,29 @@ public static function sfGetUniqSecretKey() * 会員登録キーから会員IDを取得する. * * @param string $uniqid 会員登録キー - * @param boolean $check_status 本会員のみを対象とするか - * @access public - * @return integer 会員ID + * @param bool $check_status 本会員のみを対象とするか + * + * @return int 会員ID */ public static function sfGetCustomerId($uniqid, $check_status = false) { - $objQuery = SC_Query_Ex::getSingletonInstance(); + $objQuery = SC_Query_Ex::getSingletonInstance(); - $where = 'secret_key = ?'; + $where = 'secret_key = ?'; if ($check_status) { $where .= ' AND status = 1 AND del_flg = 0'; } - return $objQuery->get('customer_id', 'dtb_customer', $where, array($uniqid)); + return $objQuery->get('customer_id', 'dtb_customer', $where, [$uniqid]); } /** * 会員登録時フォーム初期化 * * @param SC_FormParam $objFormParam SC_FormParam インスタンス - * @param boolean $isAdmin true:管理者画面 false:会員向け - * @access public + * @param bool $isAdmin true:管理者画面 false:会員向け + * * @return void */ public static function sfCustomerEntryParam(&$objFormParam, $isAdmin = false) @@ -348,16 +349,16 @@ public static function sfCustomerEntryParam(&$objFormParam, $isAdmin = false) SC_Helper_Customer_Ex::sfCustomerCommonParam($objFormParam); SC_Helper_Customer_Ex::sfCustomerRegisterParam($objFormParam, $isAdmin); if ($isAdmin) { - $objFormParam->addParam('会員ID', 'customer_id', INT_LEN, 'n', array('NUM_CHECK')); - $objFormParam->addParam('携帯メールアドレス', 'email_mobile', null, 'a', array('NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK')); - $objFormParam->addParam('会員状態', 'status', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('SHOP用メモ', 'note', LTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); - $objFormParam->addParam('所持ポイント', 'point', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK'), 0); + $objFormParam->addParam('会員ID', 'customer_id', INT_LEN, 'n', ['NUM_CHECK']); + $objFormParam->addParam('携帯メールアドレス', 'email_mobile', null, 'a', ['NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK']); + $objFormParam->addParam('会員状態', 'status', INT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('SHOP用メモ', 'note', LTEXT_LEN, 'KVa', ['MAX_LENGTH_CHECK']); + $objFormParam->addParam('所持ポイント', 'point', INT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK'], 0); } if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { // 登録確認画面の「戻る」ボタンのためのパラメーター - $objFormParam->addParam('戻る', 'return', '', '', array(), '', false); + $objFormParam->addParam('戻る', 'return', '', '', [], '', false); } } @@ -365,7 +366,7 @@ public static function sfCustomerEntryParam(&$objFormParam, $isAdmin = false) * 会員情報変更フォーム初期化 * * @param SC_FormParam $objFormParam SC_FormParam インスタンス - * @access public + * * @return void */ public static function sfCustomerMypageParam(&$objFormParam) @@ -373,11 +374,11 @@ public static function sfCustomerMypageParam(&$objFormParam) SC_Helper_Customer_Ex::sfCustomerCommonParam($objFormParam); SC_Helper_Customer_Ex::sfCustomerRegisterParam($objFormParam, false, true); if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE) { - $objFormParam->addParam('携帯メールアドレス', 'email_mobile', null, 'a', array('NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK')); - $objFormParam->addParam('携帯メールアドレス(確認)', 'email_mobile02', null, 'a', array('NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK'), '', false); + $objFormParam->addParam('携帯メールアドレス', 'email_mobile', null, 'a', ['NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK']); + $objFormParam->addParam('携帯メールアドレス(確認)', 'email_mobile02', null, 'a', ['NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK'], '', false); } else { - $objFormParam->addParam('携帯メールアドレス', 'email_mobile', null, 'a', array('EXIST_CHECK', 'NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK')); - $objFormParam->addParam('メールアドレス', 'email', null, 'a', array('NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK')); + $objFormParam->addParam('携帯メールアドレス', 'email_mobile', null, 'a', ['EXIST_CHECK', 'NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK']); + $objFormParam->addParam('メールアドレス', 'email', null, 'a', ['NO_SPTAB', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK']); } } @@ -386,79 +387,81 @@ public static function sfCustomerMypageParam(&$objFormParam) * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @param string $prefix キー名にprefixを付ける場合に指定 - * @access public + * * @return void */ public static function sfCustomerCommonParam(&$objFormParam, $prefix = '') { - $objFormParam->addParam('お名前(姓)', $prefix . 'name01', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('お名前(名)', $prefix . 'name02', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('会社名', $prefix . 'company_name', STEXT_LEN, 'aKV', array('MAX_LENGTH_CHECK', 'SPTAB_CHECK')); + $objFormParam->addParam('お名前(姓)', $prefix.'name01', STEXT_LEN, 'aKV', ['EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('お名前(名)', $prefix.'name02', STEXT_LEN, 'aKV', ['EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('会社名', $prefix.'company_name', STEXT_LEN, 'aKV', ['MAX_LENGTH_CHECK', 'SPTAB_CHECK']); if (FORM_COUNTRY_ENABLE === false) { - $objFormParam->addParam('お名前(フリガナ・姓)', $prefix . 'kana01', STEXT_LEN, 'CKV', array('EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK')); - $objFormParam->addParam('お名前(フリガナ・名)', $prefix . 'kana02', STEXT_LEN, 'CKV', array('EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK')); - $objFormParam->addParam('郵便番号1', $prefix . 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); - $objFormParam->addParam('郵便番号2', $prefix . 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); - $objFormParam->addParam('国', $prefix . 'country_id', INT_LEN, 'n', array('NUM_CHECK')); - $objFormParam->addParam('都道府県', $prefix . 'pref', INT_LEN, 'n', array('PREF_CHECK', 'EXIST_CHECK', 'NUM_CHECK')); + $objFormParam->addParam('お名前(フリガナ・姓)', $prefix.'kana01', STEXT_LEN, 'CKV', ['EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK']); + $objFormParam->addParam('お名前(フリガナ・名)', $prefix.'kana02', STEXT_LEN, 'CKV', ['EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK']); + $objFormParam->addParam('郵便番号1', $prefix.'zip01', ZIP01_LEN, 'n', ['EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK']); + $objFormParam->addParam('郵便番号2', $prefix.'zip02', ZIP02_LEN, 'n', ['EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK']); + $objFormParam->addParam('国', $prefix.'country_id', INT_LEN, 'n', ['NUM_CHECK']); + $objFormParam->addParam('都道府県', $prefix.'pref', INT_LEN, 'n', ['PREF_CHECK', 'EXIST_CHECK', 'NUM_CHECK']); } else { - $objFormParam->addParam('お名前(フリガナ・姓)', $prefix . 'kana01', STEXT_LEN, 'CKV', array('NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK')); - $objFormParam->addParam('お名前(フリガナ・名)', $prefix . 'kana02', STEXT_LEN, 'CKV', array('NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK')); - $objFormParam->addParam('郵便番号1', $prefix . 'zip01', ZIP01_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); - $objFormParam->addParam('郵便番号2', $prefix . 'zip02', ZIP02_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); - $objFormParam->addParam('国', $prefix . 'country_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK')); - $objFormParam->addParam('ZIPCODE', $prefix . 'zipcode', STEXT_LEN, 'n', array('NO_SPTAB', 'SPTAB_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('都道府県', $prefix . 'pref', INT_LEN, 'n', array('NUM_CHECK')); + $objFormParam->addParam('お名前(フリガナ・姓)', $prefix.'kana01', STEXT_LEN, 'CKV', ['NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK']); + $objFormParam->addParam('お名前(フリガナ・名)', $prefix.'kana02', STEXT_LEN, 'CKV', ['NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANA_CHECK']); + $objFormParam->addParam('郵便番号1', $prefix.'zip01', ZIP01_LEN, 'n', ['SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK']); + $objFormParam->addParam('郵便番号2', $prefix.'zip02', ZIP02_LEN, 'n', ['SPTAB_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK']); + $objFormParam->addParam('国', $prefix.'country_id', INT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('ZIPCODE', $prefix.'zipcode', STEXT_LEN, 'n', ['NO_SPTAB', 'SPTAB_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('都道府県', $prefix.'pref', INT_LEN, 'n', ['NUM_CHECK']); } - $objFormParam->addParam('住所1', $prefix . 'addr01', MTEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('住所2', $prefix . 'addr02', MTEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('お電話番号1', $prefix . 'tel01', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('お電話番号2', $prefix . 'tel02', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('お電話番号3', $prefix . 'tel03', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('FAX番号1', $prefix . 'fax01', TEL_ITEM_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('FAX番号2', $prefix . 'fax02', TEL_ITEM_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('FAX番号3', $prefix . 'fax03', TEL_ITEM_LEN, 'n', array('SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('住所1', $prefix.'addr01', MTEXT_LEN, 'aKV', ['EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('住所2', $prefix.'addr02', MTEXT_LEN, 'aKV', ['EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('お電話番号1', $prefix.'tel01', TEL_ITEM_LEN, 'n', ['EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('お電話番号2', $prefix.'tel02', TEL_ITEM_LEN, 'n', ['EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('お電話番号3', $prefix.'tel03', TEL_ITEM_LEN, 'n', ['EXIST_CHECK', 'SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('FAX番号1', $prefix.'fax01', TEL_ITEM_LEN, 'n', ['SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('FAX番号2', $prefix.'fax02', TEL_ITEM_LEN, 'n', ['SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('FAX番号3', $prefix.'fax03', TEL_ITEM_LEN, 'n', ['SPTAB_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); } /** * 会員登録共通 * * @param SC_FormParam $objFormParam SC_FormParam インスタンス - * @param boolean $isAdmin true:管理者画面 false:会員向け - * @param boolean $is_mypage マイページの場合 true + * @param bool $isAdmin true:管理者画面 false:会員向け + * @param bool $is_mypage マイページの場合 true * @param string $prefix キー名にprefixを付ける場合に指定 + * * @return void */ public static function sfCustomerRegisterParam(&$objFormParam, $isAdmin = false, $is_mypage = false, $prefix = '') { - $objFormParam->addParam('パスワード', $prefix . 'password', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'SPTAB_CHECK', 'PASSWORD_CHAR_CHECK')); - $objFormParam->addParam('パスワード確認用の質問の答え', $prefix . 'reminder_answer', STEXT_LEN, '', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('パスワード確認用の質問', $prefix . 'reminder', STEXT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('性別', $prefix . 'sex', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('職業', $prefix . 'job', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('年', $prefix . 'year', 4, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false); - $objFormParam->addParam('月', $prefix . 'month', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false); - $objFormParam->addParam('日', $prefix . 'day', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), '', false); + $objFormParam->addParam('パスワード', $prefix.'password', PASSWORD_MAX_LEN, '', ['EXIST_CHECK', 'SPTAB_CHECK', 'PASSWORD_CHAR_CHECK']); + $objFormParam->addParam('パスワード確認用の質問の答え', $prefix.'reminder_answer', STEXT_LEN, '', ['EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('パスワード確認用の質問', $prefix.'reminder', STEXT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('性別', $prefix.'sex', INT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('職業', $prefix.'job', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('年', $prefix.'year', 4, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK'], '', false); + $objFormParam->addParam('月', $prefix.'month', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK'], '', false); + $objFormParam->addParam('日', $prefix.'day', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK'], '', false); - $objFormParam->addParam('メールマガジン', $prefix . 'mailmaga_flg', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('メールマガジン', $prefix.'mailmaga_flg', INT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE) { - $objFormParam->addParam('メールアドレス', $prefix . 'email', null, 'a', array('NO_SPTAB', 'EXIST_CHECK', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK')); - $objFormParam->addParam('パスワード(確認)', $prefix . 'password02', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'SPTAB_CHECK', 'PASSWORD_CHAR_CHECK'), '', false); + $objFormParam->addParam('メールアドレス', $prefix.'email', null, 'a', ['NO_SPTAB', 'EXIST_CHECK', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK']); + $objFormParam->addParam('パスワード(確認)', $prefix.'password02', PASSWORD_MAX_LEN, '', ['EXIST_CHECK', 'SPTAB_CHECK', 'PASSWORD_CHAR_CHECK'], '', false); if (!$isAdmin) { - $objFormParam->addParam('メールアドレス(確認)', $prefix . 'email02', null, 'a', array('NO_SPTAB', 'EXIST_CHECK', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK'), '', false); + $objFormParam->addParam('メールアドレス(確認)', $prefix.'email02', null, 'a', ['NO_SPTAB', 'EXIST_CHECK', 'EMAIL_CHECK', 'SPTAB_CHECK', 'EMAIL_CHAR_CHECK'], '', false); } } else { if (!$is_mypage) { - $objFormParam->addParam('メールアドレス', $prefix . 'email', null, 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'NO_SPTAB', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK')); + $objFormParam->addParam('メールアドレス', $prefix.'email', null, 'a', ['EXIST_CHECK', 'EMAIL_CHECK', 'NO_SPTAB', 'EMAIL_CHAR_CHECK', 'MOBILE_EMAIL_CHECK']); } } } /** * 会員登録エラーチェック + * * @param SC_FormParam $objFormParam SC_FormParam インスタンス - * @access public + * * @return array エラーの配列 */ public static function sfCustomerEntryErrorCheck(&$objFormParam) @@ -487,8 +490,8 @@ public static function sfCustomerEntryErrorCheck(&$objFormParam) * 会員情報変更エラーチェック * * @param SC_FormParam $objFormParam SC_FormParam インスタンス - * @param boolean $isAdmin 管理画面チェック時:true - * @access public + * @param bool $isAdmin 管理画面チェック時:true + * * @return array エラーの配列 */ public static function sfCustomerMypageErrorCheck(&$objFormParam, $isAdmin = false) @@ -517,23 +520,23 @@ public static function sfCustomerMypageErrorCheck(&$objFormParam, $isAdmin = fal * * @param SC_FormParam $objFormParam SC_FormParam インスタンス * @param string $prefix キー名にprefixを付ける場合に指定 - * @access public + * * @return SC_CheckError_Ex エラー情報の配列 */ public static function sfCustomerCommonErrorCheck(&$objFormParam, $prefix = '') { $objFormParam->convParam(); - $objFormParam->toLower($prefix . 'email'); - $objFormParam->toLower($prefix . 'email02'); + $objFormParam->toLower($prefix.'email'); + $objFormParam->toLower($prefix.'email02'); $arrParams = $objFormParam->getHashArray(); // 入力データを渡す。 $objErr = new SC_CheckError_Ex($arrParams); $objErr->arrErr = $objFormParam->checkError(); - $objErr->doFunc(array('電話番号', $prefix . 'tel01', $prefix . 'tel02', $prefix . 'tel03'), array('TEL_CHECK')); - $objErr->doFunc(array('FAX番号', $prefix . 'fax01', $prefix . 'fax02', $prefix . 'fax03'), array('TEL_CHECK')); - $objErr->doFunc(array('郵便番号', $prefix . 'zip01', $prefix . 'zip02'), array('ALL_EXIST_CHECK')); + $objErr->doFunc(['電話番号', $prefix.'tel01', $prefix.'tel02', $prefix.'tel03'], ['TEL_CHECK']); + $objErr->doFunc(['FAX番号', $prefix.'fax01', $prefix.'fax02', $prefix.'fax03'], ['TEL_CHECK']); + $objErr->doFunc(['郵便番号', $prefix.'zip01', $prefix.'zip02'], ['ALL_EXIST_CHECK']); return $objErr; } @@ -542,25 +545,26 @@ public static function sfCustomerCommonErrorCheck(&$objFormParam, $prefix = '') * 会員登録編集共通の相関チェック * * @param SC_CheckError $objErr SC_CheckError インスタンス - * @param boolean $isAdmin 管理画面チェック時:true + * @param bool $isAdmin 管理画面チェック時:true + * * @return SC_CheckError $objErr エラー情報 */ public static function sfCustomerRegisterErrorCheck(&$objErr, $isAdmin = false) { - $objErr->doFunc(array('生年月日', 'year', 'month', 'day'), array('CHECK_BIRTHDAY')); - $objErr->doFunc(array('パスワード', 'password', PASSWORD_MIN_LEN, PASSWORD_MAX_LEN), array('NUM_RANGE_CHECK')); + $objErr->doFunc(['生年月日', 'year', 'month', 'day'], ['CHECK_BIRTHDAY']); + $objErr->doFunc(['パスワード', 'password', PASSWORD_MIN_LEN, PASSWORD_MAX_LEN], ['NUM_RANGE_CHECK']); if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE) { if (!$isAdmin) { - $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', 'email', 'email02'), array('EQUAL_CHECK')); + $objErr->doFunc(['メールアドレス', 'メールアドレス(確認)', 'email', 'email02'], ['EQUAL_CHECK']); } - $objErr->doFunc(array('パスワード', 'パスワード(確認)', 'password', 'password02'), array('EQUAL_CHECK')); + $objErr->doFunc(['パスワード', 'パスワード(確認)', 'password', 'password02'], ['EQUAL_CHECK']); } if (!$isAdmin) { // 現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可 - $objErr->doFunc(array('メールアドレス', 'email'), array('CHECK_REGIST_CUSTOMER_EMAIL')); - $objErr->doFunc(array('携帯メールアドレス', 'email_mobile'), array('CHECK_REGIST_CUSTOMER_EMAIL', 'MOBILE_EMAIL_CHECK')); + $objErr->doFunc(['メールアドレス', 'email'], ['CHECK_REGIST_CUSTOMER_EMAIL']); + $objErr->doFunc(['携帯メールアドレス', 'email_mobile'], ['CHECK_REGIST_CUSTOMER_EMAIL', 'MOBILE_EMAIL_CHECK']); } return $objErr; @@ -570,57 +574,57 @@ public static function sfCustomerRegisterErrorCheck(&$objErr, $isAdmin = false) * 会員検索パラメーター(管理画面用) * * @param SC_FormParam $objFormParam SC_FormParam インスタンス - * @access public + * * @return void */ public static function sfSetSearchParam(&$objFormParam) { - $objFormParam->addParam('会員ID', 'search_customer_id', ID_MAX_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('お名前', 'search_name', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('お名前(フリガナ)', 'search_kana', STEXT_LEN, 'CKV', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANABLANK_CHECK')); - $objFormParam->addParam('都道府県', 'search_pref', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('誕生日(開始年)', 'search_b_start_year', 4, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('誕生日(開始月)', 'search_b_start_month', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('誕生日(開始日)', 'search_b_start_day', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - - $objFormParam->addParam('誕生日(終了年)', 'search_b_end_year', 4, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('誕生日(終了月)', 'search_b_end_month', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('誕生日(終了日)', 'search_b_end_day', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('誕生月', 'search_birth_month', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('メールアドレス', 'search_email', MTEXT_LEN, 'a', array('SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('携帯メールアドレス', 'search_email_mobile', MTEXT_LEN, 'a', array('SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('電話番号', 'search_tel', TEL_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('購入金額(開始)', 'search_buy_total_from', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('購入金額(終了)', 'search_buy_total_to', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('購入回数(開始)', 'search_buy_times_from', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('購入回数(終了)', 'search_buy_times_to', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('登録・更新日(開始年)', 'search_start_year', 4, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('登録・更新日(開始月)', 'search_start_month', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('登録・更新日(開始日)', 'search_start_day', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('登録・更新日(終了年)', 'search_end_year', 4, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('登録・更新日(終了月)', 'search_end_month', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('登録・更新日(終了日)', 'search_end_day', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('表示件数', 'search_page_max', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), SEARCH_PMAX, false); - $objFormParam->addParam('ページ番号', 'search_pageno', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'), 1, false); - $objFormParam->addParam('最終購入日(開始年)', 'search_buy_start_year', 4, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('最終購入日(開始月)', 'search_buy_start_month', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('最終購入日(開始日)', 'search_buy_start_day', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('最終購入日(終了年)', 'search_buy_end_year', 4, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('最終購入日(終了月)', 'search_buy_end_month', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('最終購入日(終了日)', 'search_buy_end_day', 2, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('購入商品コード', 'search_buy_product_code', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('購入商品名', 'search_buy_product_name', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('カテゴリ', 'search_category_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('性別', 'search_sex', INT_LEN, 'n', array('MAX_LENGTH_CHECK')); - $objFormParam->addParam('会員状態', 'search_status', INT_LEN, 'n', array('MAX_LENGTH_CHECK')); - $objFormParam->addParam('職業', 'search_job', INT_LEN, 'n', array('MAX_LENGTH_CHECK')); + $objFormParam->addParam('会員ID', 'search_customer_id', ID_MAX_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('お名前', 'search_name', STEXT_LEN, 'KVa', ['SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('お名前(フリガナ)', 'search_kana', STEXT_LEN, 'CKV', ['SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'KANABLANK_CHECK']); + $objFormParam->addParam('都道府県', 'search_pref', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('誕生日(開始年)', 'search_b_start_year', 4, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('誕生日(開始月)', 'search_b_start_month', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('誕生日(開始日)', 'search_b_start_day', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + + $objFormParam->addParam('誕生日(終了年)', 'search_b_end_year', 4, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('誕生日(終了月)', 'search_b_end_month', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('誕生日(終了日)', 'search_b_end_day', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('誕生月', 'search_birth_month', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('メールアドレス', 'search_email', MTEXT_LEN, 'a', ['SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('携帯メールアドレス', 'search_email_mobile', MTEXT_LEN, 'a', ['SPTAB_CHECK', 'EMAIL_CHAR_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('電話番号', 'search_tel', TEL_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('購入金額(開始)', 'search_buy_total_from', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('購入金額(終了)', 'search_buy_total_to', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('購入回数(開始)', 'search_buy_times_from', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('購入回数(終了)', 'search_buy_times_to', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('登録・更新日(開始年)', 'search_start_year', 4, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('登録・更新日(開始月)', 'search_start_month', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('登録・更新日(開始日)', 'search_start_day', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('登録・更新日(終了年)', 'search_end_year', 4, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('登録・更新日(終了月)', 'search_end_month', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('登録・更新日(終了日)', 'search_end_day', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('表示件数', 'search_page_max', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK'], SEARCH_PMAX, false); + $objFormParam->addParam('ページ番号', 'search_pageno', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK'], 1, false); + $objFormParam->addParam('最終購入日(開始年)', 'search_buy_start_year', 4, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('最終購入日(開始月)', 'search_buy_start_month', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('最終購入日(開始日)', 'search_buy_start_day', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('最終購入日(終了年)', 'search_buy_end_year', 4, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('最終購入日(終了月)', 'search_buy_end_month', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('最終購入日(終了日)', 'search_buy_end_day', 2, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('購入商品コード', 'search_buy_product_code', STEXT_LEN, 'KVa', ['SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('購入商品名', 'search_buy_product_name', STEXT_LEN, 'KVa', ['SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('カテゴリ', 'search_category_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('性別', 'search_sex', INT_LEN, 'n', ['MAX_LENGTH_CHECK']); + $objFormParam->addParam('会員状態', 'search_status', INT_LEN, 'n', ['MAX_LENGTH_CHECK']); + $objFormParam->addParam('職業', 'search_job', INT_LEN, 'n', ['MAX_LENGTH_CHECK']); } /** * 会員検索パラメーター エラーチェック(管理画面用) * * @param SC_FormParam $objFormParam SC_FormParam インスタンス - * @access public + * * @return array エラー配列 */ public static function sfCheckErrorSearchParam(&$objFormParam) @@ -632,17 +636,17 @@ public static function sfCheckErrorSearchParam(&$objFormParam) // 拡張エラーチェック初期化 $objErr = new SC_CheckError_Ex($array); // 拡張エラーチェック - $objErr->doFunc(array('誕生日(開始日)', 'search_b_start_year', 'search_b_start_month', 'search_b_start_day'), array('CHECK_DATE')); - $objErr->doFunc(array('誕生日(終了日)', 'search_b_end_year', 'search_b_end_month', 'search_b_end_day'), array('CHECK_DATE')); - - $objErr->doFunc(array('誕生日(開始日)', '誕生日(終了日)', 'search_b_start_year', 'search_b_start_month', 'search_b_start_day', 'search_b_end_year', 'search_b_end_month', 'search_b_end_day'), array('CHECK_SET_TERM')); - $objErr->doFunc(array('登録・更新日(開始日)', 'search_start_year', 'search_start_month', 'search_start_day'), array('CHECK_DATE')); - $objErr->doFunc(array('登録・更新日(終了日)', 'search_end_year', 'search_end_month', 'search_end_day'), array('CHECK_DATE')); - $objErr->doFunc(array('登録・更新日(開始日)', '登録・更新日(終了日)', 'search_start_year', 'search_start_month', 'search_start_day', 'search_end_year', 'search_end_month', 'search_end_day'), array('CHECK_SET_TERM')); - $objErr->doFunc(array('最終購入日(開始)', 'search_buy_start_year', 'search_buy_start_month', 'search_buy_start_day'), array('CHECK_DATE')); - $objErr->doFunc(array('最終購入日(終了)', 'search_buy_end_year', 'search_buy_end_month', 'search_buy_end_day'), array('CHECK_DATE')); + $objErr->doFunc(['誕生日(開始日)', 'search_b_start_year', 'search_b_start_month', 'search_b_start_day'], ['CHECK_DATE']); + $objErr->doFunc(['誕生日(終了日)', 'search_b_end_year', 'search_b_end_month', 'search_b_end_day'], ['CHECK_DATE']); + + $objErr->doFunc(['誕生日(開始日)', '誕生日(終了日)', 'search_b_start_year', 'search_b_start_month', 'search_b_start_day', 'search_b_end_year', 'search_b_end_month', 'search_b_end_day'], ['CHECK_SET_TERM']); + $objErr->doFunc(['登録・更新日(開始日)', 'search_start_year', 'search_start_month', 'search_start_day'], ['CHECK_DATE']); + $objErr->doFunc(['登録・更新日(終了日)', 'search_end_year', 'search_end_month', 'search_end_day'], ['CHECK_DATE']); + $objErr->doFunc(['登録・更新日(開始日)', '登録・更新日(終了日)', 'search_start_year', 'search_start_month', 'search_start_day', 'search_end_year', 'search_end_month', 'search_end_day'], ['CHECK_SET_TERM']); + $objErr->doFunc(['最終購入日(開始)', 'search_buy_start_year', 'search_buy_start_month', 'search_buy_start_day'], ['CHECK_DATE']); + $objErr->doFunc(['最終購入日(終了)', 'search_buy_end_year', 'search_buy_end_month', 'search_buy_end_day'], ['CHECK_DATE']); // 開始 > 終了 の場合はエラーとする - $objErr->doFunc(array('最終購入日(開始)', '最終購入日(終了)', 'search_buy_start_year', 'search_buy_start_month', 'search_buy_start_day', 'search_buy_end_year', 'search_buy_end_month', 'search_buy_end_day'), array('CHECK_SET_TERM')); + $objErr->doFunc(['最終購入日(開始)', '最終購入日(終了)', 'search_buy_start_year', 'search_buy_start_month', 'search_buy_start_day', 'search_buy_end_year', 'search_buy_end_month', 'search_buy_end_day'], ['CHECK_SET_TERM']); if (SC_Utils_Ex::sfIsInt($array['search_buy_total_from']) && SC_Utils_Ex::sfIsInt($array['search_buy_total_to']) @@ -669,6 +673,7 @@ public static function sfCheckErrorSearchParam(&$objFormParam) * * @param array $arrParam 検索パラメーター連想配列 * @param string $limitMode ページングを利用するか判定用フラグ + * * @return array( integer 全体件数, mixed 会員データ一覧配列, mixed SC_PageNaviオブジェクト) */ public static function sfGetSearchData($arrParam, $limitMode = '') @@ -681,7 +686,7 @@ public static function sfGetSearchData($arrParam, $limitMode = '') if ($disp_pageno == 0) { $disp_pageno = 1; } - $offset = intval($page_max) * (intval($disp_pageno) - 1); + $offset = (int) $page_max * ((int) $disp_pageno - 1); if ($limitMode == '') { $objQuery->setLimitOffset($page_max, $offset); } @@ -693,26 +698,27 @@ public static function sfGetSearchData($arrParam, $limitMode = '') // ページ送りの取得 $objNavi = new SC_PageNavi_Ex($arrParam['search_pageno'], - $linemax, - $page_max, - 'eccube.moveSearchPage', - NAVI_PMAX); + $linemax, + $page_max, + 'eccube.moveSearchPage', + NAVI_PMAX); - return array($linemax, $arrData, $objNavi); + return [$linemax, $arrData, $objNavi]; } /** * 仮会員かどうかを判定する. * * @param string $login_email メールアドレス - * @return boolean 仮会員の場合 true + * + * @return bool 仮会員の場合 true */ public static function checkTempCustomer($login_email) { $objQuery = SC_Query_Ex::getSingletonInstance(); $where = 'email = ? AND status = 1 AND del_flg = 0'; - $exists = $objQuery->exists('dtb_customer', $where, array($login_email)); + $exists = $objQuery->exists('dtb_customer', $where, [$login_email]); return $exists; } @@ -720,20 +726,21 @@ public static function checkTempCustomer($login_email) /** * 会員を削除する処理 * - * @param integer $customer_id 会員ID - * @return boolean true:成功 false:失敗 + * @param int $customer_id 会員ID + * + * @return bool true:成功 false:失敗 */ public static function delete($customer_id) { $arrData = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id, 'del_flg = 0'); if (SC_Utils_Ex::isBlank($arrData)) { - //対象となるデータが見つからない。 + // 対象となるデータが見つからない。 return false; } // XXXX: 仮会員は物理削除となっていたが論理削除に変更。 - $arrVal = array( + $arrVal = [ 'del_flg' => '1', - ); + ]; SC_Helper_Customer_Ex::sfEditCustomerData($arrVal, $customer_id); return true; diff --git a/data/class/helper/SC_Helper_DB.php b/data/class/helper/SC_Helper_DB.php index 7d0f916325..b1a5bbf2f4 100644 --- a/data/class/helper/SC_Helper_DB.php +++ b/data/class/helper/SC_Helper_DB.php @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/** +/* * DB関連のヘルパークラス. * * @package Helper @@ -30,7 +30,7 @@ */ // NOTE: PHP5 対応が不要となったらクラス定数に変更する。 -define('SC_HELPER_DB_BASIS_DATA_CACHE_REALFILE', MASTER_DATA_REALDIR . 'dtb_baseinfo.serial'); +define('SC_HELPER_DB_BASIS_DATA_CACHE_REALFILE', MASTER_DATA_REALDIR.'dtb_baseinfo.serial'); class SC_Helper_DB { @@ -62,6 +62,7 @@ class SC_Helper_DB * @param string $colType カラムのデータ型 * @param string $dsn データソース名 * @param bool $add カラムの作成も行う場合 true + * * @return bool カラムが存在する場合とカラムの生成に成功した場合 true, * テーブルが存在しない場合 false, * 引数 $add == false でカラムが存在しない場合 false @@ -74,7 +75,9 @@ public static function sfColumnExists($tableName, $colName, $colType = '', $dsn $objQuery = SC_Query_Ex::getSingletonInstance($dsn); // テーブルが無ければエラー - if (!in_array($tableName, $objQuery->listTables())) return false; + if (!in_array($tableName, $objQuery->listTables())) { + return false; + } // 正常に接続されている場合 if (!$objQuery->isError()) { @@ -111,6 +114,7 @@ public static function sfColumnAdd($tableName, $colName, $colType) * @param string $tableName テーブル名 * @param string $where データを検索する WHERE 句 * @param array $arrWhereVal WHERE句のプレースホルダ値 + * * @return bool データが存在する場合 true, データの追加に成功した場合 true, * $add == false で, データが存在しない場合 false */ @@ -127,7 +131,8 @@ public static function sfDataExists($tableName, $where, $arrWhereVal) * * 引数 $force が false の場合は, キャッシュされた結果を使用する. * - * @param boolean $force キャッシュファイルを生成し、ローカルキャッシュを削除するか + * @param bool $force キャッシュファイルを生成し、ローカルキャッシュを削除するか + * * @return array 店舗基本情報の配列 */ public static function sfGetBasisData($force = false) @@ -160,8 +165,11 @@ public static function sfGetBasisData($force = false) * 基本情報のキャッシュデータを取得する * * エラー画面表示で直接呼ばれる。キャッシュファイルが存在しなくとも空の配列を応答することで、(幾らかの情報欠落などはあるかもしれないが) エラー画面の表示できるよう考慮している。 - * @param boolean $generate キャッシュファイルが無い時、DBのデータを基にキャッシュを生成するか + * + * @param bool $generate キャッシュファイルが無い時、DBのデータを基にキャッシュを生成するか + * * @return array 店舗基本情報の配列 + * * @deprecated 2.17.1 本体で使用されていないため非推奨 */ public static function sfGetBasisDataCache($generate = false) @@ -183,7 +191,9 @@ public static function sfGetBasisDataCache($generate = false) * 基本情報のキャッシュデータを取得する * * エラー画面表示で直接呼ばれる。キャッシュファイルが存在しなくとも空の配列を応答することで、(幾らかの情報欠落などはあるかもしれないが) エラー画面の表示できるよう考慮している。 - * @param boolean $ignore_error エラーを無視するか + * + * @param bool $ignore_error エラーを無視するか + * * @return array 店舗基本情報の配列 */ public static function getBasisDataFromCacheFile($ignore_error = false) @@ -194,8 +204,7 @@ public static function getBasisDataFromCacheFile($ignore_error = false) if (file_exists(SC_HELPER_DB_BASIS_DATA_CACHE_REALFILE)) { // キャッシュデータファイルを読み込みアンシリアライズした配列を取得 $arrReturn = unserialize(file_get_contents(SC_HELPER_DB_BASIS_DATA_CACHE_REALFILE)); - } - elseif (!$ignore_error) { + } elseif (!$ignore_error) { throw new Exception('基本情報のキャッシュデータファイルが存在しません。'); } @@ -255,6 +264,7 @@ public static function sfCreateBasisDataCache() * 基本情報の登録数を取得する * * @return int + * * @deprecated */ public function sfGetBasisCount() @@ -267,7 +277,7 @@ public function sfGetBasisCount() /** * 基本情報の登録有無を取得する * - * @return boolean 有無 + * @return bool 有無 */ public function sfGetBasisExists() { @@ -278,6 +288,7 @@ public function sfGetBasisExists() /** * 選択中のアイテムのルートカテゴリIDを取得する + * * @deprecated 本体で使用されていないため非推奨 */ public function sfGetRootId() @@ -285,8 +296,12 @@ public function sfGetRootId() if (!$this->g_root_on) { $this->g_root_on = true; - if (!isset($_GET['product_id'])) $_GET['product_id'] = ''; - if (!isset($_GET['category_id'])) $_GET['category_id'] = ''; + if (!isset($_GET['product_id'])) { + $_GET['product_id'] = ''; + } + if (!isset($_GET['category_id'])) { + $_GET['category_id'] = ''; + } if (!empty($_GET['product_id']) || !empty($_GET['category_id'])) { // 選択中のカテゴリIDを判定する @@ -311,19 +326,20 @@ public function sfGetRootId() /** * 受注番号、最終ポイント、加算ポイント、利用ポイントから「オーダー前ポイント」を取得する * - * @param integer $order_id 受注番号 - * @param integer $use_point 利用ポイント - * @param integer $add_point 加算ポイント - * @param integer $order_status 対応状況 + * @param int $order_id 受注番号 + * @param int $use_point 利用ポイント + * @param int $add_point 加算ポイント + * @param int $order_status 対応状況 + * * @return array オーダー前ポイントの配列 */ public static function sfGetRollbackPoint($order_id, $use_point, $add_point, $order_status) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrRet = $objQuery->select('customer_id', 'dtb_order', 'order_id = ?', array($order_id)); + $arrRet = $objQuery->select('customer_id', 'dtb_order', 'order_id = ?', [$order_id]); $customer_id = $arrRet[0]['customer_id']; if ($customer_id != '' && $customer_id >= 1) { - $arrRet = $objQuery->select('point', 'dtb_customer', 'customer_id = ?', array($customer_id)); + $arrRet = $objQuery->select('point', 'dtb_customer', 'customer_id = ?', [$customer_id]); $point = $arrRet[0]['point']; $rollback_point = $arrRet[0]['point']; @@ -341,14 +357,15 @@ public static function sfGetRollbackPoint($order_id, $use_point, $add_point, $or $point = ''; } - return array($point, $rollback_point); + return [$point, $rollback_point]; } /** * カテゴリツリーの取得を行う. * - * @param integer $parent_category_id 親カテゴリID + * @param int $parent_category_id 親カテゴリID * @param bool $count_check 登録商品数のチェックを行う場合 true + * * @return array カテゴリツリーの配列 */ public static function sfGetCatTree($parent_category_id, $count_check = false) @@ -393,9 +410,10 @@ public static function sfGetCatTree($parent_category_id, $count_check = false) * カテゴリツリーを走査し, パンくずリスト用の配列を生成する. * * @param array カテゴリの配列 - * @param integer $parent 上位カテゴリID + * @param int $parent 上位カテゴリID * @param array パンくずリスト用の配列 * @result void + * * @see sfGetCatTree() * @deprecated 本体で使用されていないため非推奨 */ @@ -406,11 +424,11 @@ public function findTree(&$arrTree, $parent, &$result) } else { foreach ($arrTree as $val) { if ($val['category_id'] == $parent) { - $result[] = array( + $result[] = [ 'category_id' => $val['category_id'], 'parent_category_id' => (int) $val['parent_category_id'], 'category_name' => $val['category_name'], - ); + ]; $this->findTree($arrTree, $val['parent_category_id'], $result); } } @@ -420,8 +438,9 @@ public function findTree(&$arrTree, $parent, &$result) /** * カテゴリツリーの取得を複数カテゴリで行う. * - * @param integer $product_id 商品ID + * @param int $product_id 商品ID * @param bool $count_check 登録商品数のチェックを行う場合 true + * * @return array カテゴリツリーの配列 */ public static function sfGetMultiCatTree($product_id, $count_check = false) @@ -450,7 +469,7 @@ public static function sfGetMultiCatTree($product_id, $count_check = false) $arrCategory_id = SC_Helper_DB_Ex::sfGetCategoryId($product_id); - $arrCatTree = array(); + $arrCatTree = []; foreach ($arrCategory_id as $pkey => $parent_category_id) { $arrParentID = SC_Helper_DB_Ex::sfGetParentsArray('dtb_category', 'parent_category_id', 'category_id', $parent_category_id); @@ -470,8 +489,10 @@ public static function sfGetMultiCatTree($product_id, $count_check = false) /** * 親カテゴリを連結した文字列を取得する. * - * @param integer $category_id カテゴリID + * @param int $category_id カテゴリID + * * @return string 親カテゴリを連結した文字列 + * * @deprecated 本体で使用されていないため非推奨 */ public function sfGetCatCombName($category_id) @@ -484,9 +505,9 @@ public function sfGetCatCombName($category_id) // カテゴリ名称を取得する foreach ($arrCatID as $val) { $sql = 'SELECT category_name FROM dtb_category WHERE category_id = ?'; - $arrVal = array($val); + $arrVal = [$val]; $CatName = $objQuery->getOne($sql, $arrVal); - $ConbName .= $CatName . ' | '; + $ConbName .= $CatName.' | '; } // 最後の | をカットする $ConbName = substr_replace($ConbName, '', strlen($ConbName) - 2, 2); @@ -497,21 +518,23 @@ public function sfGetCatCombName($category_id) /** * 指定したカテゴリIDの大カテゴリを取得する. * - * @param integer $category_id カテゴリID + * @param int $category_id カテゴリID + * * @return array 指定したカテゴリIDの大カテゴリ + * * @deprecated 本体で使用されていないため非推奨 */ public function sfGetFirstCat($category_id) { // 商品が属するカテゴリIDを縦に取得 $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrRet = array(); + $arrRet = []; $arrCatID = $this->sfGetParentsArray('dtb_category', 'parent_category_id', 'category_id', $category_id); $arrRet['id'] = $arrCatID[0]; // カテゴリ名称を取得する $sql = 'SELECT category_name FROM dtb_category WHERE category_id = ?'; - $arrVal = array($arrRet['id']); + $arrVal = [$arrRet['id']]; $arrRet['name'] = $objQuery->getOne($sql, $arrVal); return $arrRet; @@ -525,6 +548,7 @@ public function sfGetFirstCat($category_id) * @param string $addwhere 追加する WHERE 句 * @param bool $products_check 商品の存在するカテゴリのみ取得する場合 true * @param string $head カテゴリ名のプレフィックス文字列 + * * @return array カテゴリツリーの配列 */ public static function sfGetCategoryList($addwhere = '', $products_check = false, $head = CATEGORY_HEAD) @@ -533,7 +557,7 @@ public static function sfGetCategoryList($addwhere = '', $products_check = false $where = 'del_flg = 0'; if ($addwhere != '') { - $where.= " AND $addwhere"; + $where .= " AND $addwhere"; } $objQuery->setOption('ORDER BY rank DESC'); @@ -550,11 +574,11 @@ public static function sfGetCategoryList($addwhere = '', $products_check = false $arrRet = $objQuery->select($col, $from, $where); $max = count($arrRet); - $arrList = array(); + $arrList = []; for ($cnt = 0; $cnt < $max; $cnt++) { $id = $arrRet[$cnt]['category_id']; $name = $arrRet[$cnt]['category_name']; - $arrList[$id] = str_repeat($head, $arrRet[$cnt]['level']) . $name; + $arrList[$id] = str_repeat($head, $arrRet[$cnt]['level']).$name; } return $arrList; @@ -566,6 +590,7 @@ public static function sfGetCategoryList($addwhere = '', $products_check = false * 親カテゴリの Value=0 を対象とする * * @param bool $parent_zero 親カテゴリの Value=0 の場合 true + * * @return array カテゴリツリーの配列 */ public static function sfGetLevelCatList($parent_zero = true) @@ -577,12 +602,12 @@ public static function sfGetLevelCatList($parent_zero = true) $where = 'del_flg = 0'; $objQuery->setOption('ORDER BY level'); $arrRet = $objQuery->select($col, 'dtb_category', $where); - $arrCatName = array(); + $arrCatName = []; foreach ($arrRet as $arrTmp) { $arrCatName[$arrTmp['category_id']] = - (($arrTmp['parent_category_id'] > 0)? + (($arrTmp['parent_category_id'] > 0) ? $arrCatName[$arrTmp['parent_category_id']] : '') - . CATEGORY_HEAD . $arrTmp['category_name']; + .CATEGORY_HEAD.$arrTmp['category_name']; } $col = 'category_id, parent_category_id, category_name, level'; @@ -591,8 +616,8 @@ public static function sfGetLevelCatList($parent_zero = true) $arrRet = $objQuery->select($col, 'dtb_category', $where); $max = count($arrRet); - $arrValue = array(); - $arrOutput = array(); + $arrValue = []; + $arrOutput = []; for ($cnt = 0; $cnt < $max; $cnt++) { if ($parent_zero) { if ($arrRet[$cnt]['level'] == LEVEL_MAX) { @@ -607,7 +632,7 @@ public static function sfGetLevelCatList($parent_zero = true) $arrOutput[$cnt] = $arrCatName[$arrRet[$cnt]['category_id']]; } - return array($arrValue, $arrOutput); + return [$arrValue, $arrOutput]; } /** @@ -616,9 +641,10 @@ public static function sfGetLevelCatList($parent_zero = true) * 引数のカテゴリIDが有効な場合は, カテゴリIDを含んだ配列を返す * 引数のカテゴリIDが無効な場合, dtb_product_categories にレコードが存在する場合は, カテゴリIDを含んだ配列を返す * - * @param integer $product_id プロダクトID - * @param integer $category_id カテゴリID + * @param int $product_id プロダクトID + * @param int $category_id カテゴリID * @param bool $closed 引数のカテゴリIDが無効な場合で, 非表示の商品を含む場合はtrue + * * @return array 選択中の商品のカテゴリIDの配列 */ public static function sfGetCategoryId($product_id, $category_id = 0, $closed = false) @@ -633,13 +659,13 @@ public static function sfGetCategoryId($product_id, $category_id = 0, $closed = $objCategory = new SC_Helper_Category_Ex(); // XXX SC_Helper_Category::isValidCategoryId() で使用している SC_Helper_DB::sfIsRecord() が内部で del_flg = 0 を追加するため, $closed は機能していない if ($objCategory->isValidCategoryId($category_id, $closed)) { - $category_id = array($category_id); - } elseif (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_products','product_id', $product_id, $status)) { + $category_id = [$category_id]; + } elseif (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', $product_id, $status)) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', array($product_id)); + $category_id = $objQuery->getCol('category_id', 'dtb_product_categories', 'product_id = ?', [$product_id]); } else { // 不正な場合は、空の配列を返す。 - $category_id = array(); + $category_id = []; } return $category_id; @@ -648,45 +674,48 @@ public static function sfGetCategoryId($product_id, $category_id = 0, $closed = /** * 商品をカテゴリの先頭に追加する. * - * @param integer $category_id カテゴリID - * @param integer $product_id プロダクトID + * @param int $category_id カテゴリID + * @param int $product_id プロダクトID + * * @return void */ public function addProductBeforCategories($category_id, $product_id) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $sqlval = array('category_id' => $category_id, - 'product_id' => $product_id); + $sqlval = ['category_id' => $category_id, + 'product_id' => $product_id]; - $arrSql = array(); + $arrSql = []; $arrSql['rank'] = '(SELECT COALESCE(MAX(rank), 0) FROM dtb_product_categories sub WHERE category_id = ?) + 1'; $from_and_where = $objQuery->dbFactory->getDummyFromClauseSql(); $from_and_where .= ' WHERE NOT EXISTS(SELECT * FROM dtb_product_categories WHERE category_id = ? AND product_id = ?)'; - $objQuery->insert('dtb_product_categories', $sqlval, $arrSql, array($category_id), $from_and_where, array($category_id, $product_id)); + $objQuery->insert('dtb_product_categories', $sqlval, $arrSql, [$category_id], $from_and_where, [$category_id, $product_id]); } /** * 商品をカテゴリの末尾に追加する. * - * @param integer $category_id カテゴリID - * @param integer $product_id プロダクトID + * @param int $category_id カテゴリID + * @param int $product_id プロダクトID + * * @return void + * * @deprecated 本体で使用されていないため非推奨 */ public function addProductAfterCategories($category_id, $product_id) { - $sqlval = array('category_id' => $category_id, - 'product_id' => $product_id); + $sqlval = ['category_id' => $category_id, + 'product_id' => $product_id]; $objQuery = SC_Query_Ex::getSingletonInstance(); // 現在の商品カテゴリを取得 $arrCat = $objQuery->select('product_id, category_id, rank', - 'dtb_product_categories', - 'category_id = ?', - array($category_id)); + 'dtb_product_categories', + 'category_id = ?', + [$category_id]); $min = 0; foreach ($arrCat as $val) { @@ -704,22 +733,24 @@ public function addProductAfterCategories($category_id, $product_id) /** * 商品をカテゴリから削除する. * - * @param integer $category_id カテゴリID - * @param integer $product_id プロダクトID + * @param int $category_id カテゴリID + * @param int $product_id プロダクトID + * * @return void */ public function removeProductByCategories($category_id, $product_id) { $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->delete('dtb_product_categories', - 'category_id = ? AND product_id = ?', array($category_id, $product_id)); + 'category_id = ? AND product_id = ?', [$category_id, $product_id]); } /** * 商品カテゴリを更新する. * * @param array $arrCategory_id 登録するカテゴリIDの配列 - * @param integer $product_id プロダクトID + * @param int $product_id プロダクトID + * * @return void */ public function updateProductCategories($arrCategory_id, $product_id) @@ -728,9 +759,9 @@ public function updateProductCategories($arrCategory_id, $product_id) // 現在のカテゴリ情報を取得 $arrCurrentCat = $objQuery->getCol('category_id', - 'dtb_product_categories', - 'product_id = ?', - array($product_id)); + 'dtb_product_categories', + 'product_id = ?', + [$product_id]); // 登録するカテゴリ情報と比較 foreach ($arrCurrentCat as $category_id) { @@ -750,18 +781,17 @@ public function updateProductCategories($arrCategory_id, $product_id) /** * カテゴリ数の登録を行う. * - * * @param SC_Query $objQuery SC_Query インスタンス - * @param boolean $is_force_all_count 全カテゴリの集計を強制する場合 true + * @param bool $is_force_all_count 全カテゴリの集計を強制する場合 true * @param bool $is_nostock_hidden 在庫切れの商品は非表示にする場合 true * * @return void */ - public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $is_nostock_hidden = NOSTOCK_HIDDEN) + public function sfCountCategory($objQuery = null, $is_force_all_count = false, $is_nostock_hidden = NOSTOCK_HIDDEN) { $objProduct = new SC_Product_Ex(); - if ($objQuery == NULL) { + if ($objQuery == null) { $objQuery = SC_Query_Ex::getSingletonInstance(); } @@ -771,7 +801,7 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ $is_out_trans = true; } - //共通のfrom/where文の構築 + // 共通のfrom/where文の構築 $where_alldtl = SC_Product_Ex::getProductDispConditions('alldtl'); // 在庫無し商品の非表示 if ($is_nostock_hidden) { @@ -780,7 +810,7 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ $from_alldtl = 'dtb_products as alldtl'; } - //dtb_category_countの構成 + // dtb_category_countの構成 // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを含まない。 if ($is_force_all_count) { @@ -791,7 +821,7 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ $arrCategoryCountOld = $objQuery->select('category_id, product_count', 'dtb_category_count'); } - //各カテゴリ内の商品数を数えて取得 + // 各カテゴリ内の商品数を数えて取得 $sql = <<< __EOS__ SELECT T1.category_id, count(*) as product_count FROM dtb_category AS T1 @@ -807,15 +837,15 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ $arrCategoryCountNew = $objQuery->getAll($sql); // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを「含む」。 - //差分を取得して、更新対象カテゴリだけを確認する。 + // 差分を取得して、更新対象カテゴリだけを確認する。 - //各カテゴリ毎のデータ値において以前との差を見る - //古いデータの構造入れ替え + // 各カテゴリ毎のデータ値において以前との差を見る + // 古いデータの構造入れ替え $arrOld = []; foreach ($arrCategoryCountOld as $item) { $arrOld[$item['category_id']] = $item['product_count']; } - //新しいデータの構造入れ替え + // 新しいデータの構造入れ替え $arrNew = []; foreach ($arrCategoryCountNew as $item) { $arrNew[$item['category_id']] = $item['product_count']; @@ -825,7 +855,7 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ unset($arrCategoryCountNew); $arrNotExistsProductCategoryId = []; - //削除カテゴリを想定して、古いカテゴリ一覧から見て商品数が異なるデータが無いか確認。 + // 削除カテゴリを想定して、古いカテゴリ一覧から見て商品数が異なるデータが無いか確認。 foreach ($arrOld as $category_id => $count) { // 商品が存在しない if (!isset($arrNew[$category_id])) { @@ -841,7 +871,7 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ $arrTgtCategoryId = $arrNotExistsProductCategoryId; foreach ($arrNotExistsProductCategoryId as $category_id) { - $objQuery->delete('dtb_category_count', 'category_id = ?', array($category_id)); + $objQuery->delete('dtb_category_count', 'category_id = ?', [$category_id]); $arrParentID = self::sfGetParentsArray('dtb_category', 'parent_category_id', 'category_id', $category_id); $arrTgtCategoryId = array_merge($arrTgtCategoryId, $arrParentID); @@ -853,7 +883,7 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; $sqlval['product_count'] = $count; if (isset($arrOld[$category_id])) { - $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', array($category_id)); + $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', [$category_id]); } else { $sqlval['category_id'] = $category_id; $objQuery->insert('dtb_category_count', $sqlval); @@ -866,14 +896,14 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ unset($arrOld); unset($arrNew); - //dtb_category_total_count 集計処理開始 - //更新対象カテゴリIDだけ集計しなおす。 + // dtb_category_total_count 集計処理開始 + // 更新対象カテゴリIDだけ集計しなおす。 $arrUpdateData = []; foreach ($arrTgtCategoryId as $category_id) { $arrWhereVal = []; list($tmp_where, $arrTmpVal) = static::sfGetCatWhere($category_id); if ($tmp_where != '') { - $where_product_ids = 'product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')'; + $where_product_ids = 'product_id IN (SELECT product_id FROM dtb_product_categories WHERE '.$tmp_where.')'; $arrWhereVal = $arrTmpVal; } else { $where_product_ids = '0<>0'; // 一致させない @@ -888,14 +918,14 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ // 更新対象だけを更新。 foreach ($arrUpdateData as $category_id => $count) { if ($count == 0) { - $objQuery->delete('dtb_category_total_count', 'category_id = ?', array($category_id)); - continue 1; + $objQuery->delete('dtb_category_total_count', 'category_id = ?', [$category_id]); + continue; } $sqlval = [ 'product_count' => $count, 'create_date' => 'CURRENT_TIMESTAMP', ]; - $ret = $objQuery->update('dtb_category_total_count', $sqlval, 'category_id = ?', array($category_id)); + $ret = $objQuery->update('dtb_category_total_count', $sqlval, 'category_id = ?', [$category_id]); if (!$ret) { $sqlval['category_id'] = $category_id; $objQuery->insert('dtb_category_total_count', $sqlval); @@ -914,8 +944,9 @@ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false, $ * @param string $table テーブル名 * @param string $pid_name 親ID名 * @param string $id_name ID名 - * @param integer $id ID + * @param int $id ID * @param array 子ID の配列 + * * @deprecated 本体で使用されていないため非推奨 */ public static function sfGetChildsID($table, $pid_name, $id_name, $id) @@ -931,13 +962,14 @@ public static function sfGetChildsID($table, $pid_name, $id_name, $id) * @param string $table テーブル名 * @param string $pid_name 親ID名 * @param string $id_name ID名 - * @param integer $id ID番号 + * @param int $id ID番号 + * * @return array 子IDの配列 */ public static function sfGetChildrenArray($table, $pid_name, $id_name, $id) { - $arrChildren = array(); - $arrRet = array($id); + $arrChildren = []; + $arrRet = [$id]; while (count($arrRet) > 0) { $arrChildren = array_merge($arrChildren, $arrRet); @@ -954,13 +986,14 @@ public static function sfGetChildrenArray($table, $pid_name, $id_name, $id) * @param string $id_name ID名 * @param array $arrPID 親IDの配列 * @param string $table + * * @return array 子IDの配列 */ public static function sfGetChildrenArraySub($table, $pid_name, $id_name, $arrPID) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $where = "$pid_name IN (" . SC_Utils_Ex::repeatStrWithSeparator('?', count($arrPID)) . ')'; + $where = "$pid_name IN (".SC_Utils_Ex::repeatStrWithSeparator('?', count($arrPID)).')'; $return = $objQuery->getCol($id_name, $table, $where, $arrPID); @@ -973,8 +1006,10 @@ public static function sfGetChildrenArraySub($table, $pid_name, $id_name, $arrPI * @param string $table テーブル名 * @param string $pid_name 親ID名 * @param string $id_name ID名 - * @param integer $id ID + * @param int $id ID + * * @return array 親IDの配列 + * * @deprecated SC_Helper_DB::sfGetParentsArray() を使用して下さい */ public static function sfGetParents($table, $pid_name, $id_name, $id) @@ -990,12 +1025,13 @@ public static function sfGetParents($table, $pid_name, $id_name, $id) * @param string $table テーブル名 * @param string $pid_name 親ID名 * @param string $id_name ID名 - * @param integer $id ID + * @param int $id ID + * * @return array 親IDの配列 */ public static function sfGetParentsArray($table, $pid_name, $id_name, $id) { - $arrParents = array(); + $arrParents = []; $ret = $id; $loop_cnt = 1; @@ -1030,7 +1066,7 @@ public static function sfGetParentsArraySub($table, $pid_name, $id_name, $child) } $objQuery = SC_Query_Ex::getSingletonInstance(); if (!is_array($child)) { - $child = array($child); + $child = [$child]; } $parent = $objQuery->get($pid_name, $table, "$id_name = ?", $child); @@ -1040,7 +1076,8 @@ public static function sfGetParentsArraySub($table, $pid_name, $id_name, $child) /** * カテゴリから商品を検索する場合のWHERE文と値を返す. * - * @param integer $category_id カテゴリID + * @param int $category_id カテゴリID + * * @return array 商品を検索する場合の配列 */ public static function sfGetCatWhere($category_id) @@ -1048,9 +1085,9 @@ public static function sfGetCatWhere($category_id) // 子カテゴリIDの取得 $arrRet = SC_Helper_DB_Ex::sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $category_id); - $where = 'category_id IN (' . SC_Utils_Ex::repeatStrWithSeparator('?', count($arrRet)) . ')'; + $where = 'category_id IN ('.SC_Utils_Ex::repeatStrWithSeparator('?', count($arrRet)).')'; - return array($where, $arrRet); + return [$where, $arrRet]; } /** @@ -1061,9 +1098,10 @@ public static function sfGetCatWhere($category_id) * @param string $valname データ内容のカラム名 * @param string $where WHERE句 * @param array $arrVal プレースホルダ + * * @return array SELECT ボックス用リストの配列 */ - public static function sfGetIDValueList($table, $keyname, $valname, $where = '', $arrVal = array()) + public static function sfGetIDValueList($table, $keyname, $valname, $where = '', $arrVal = []) { $objQuery = SC_Query_Ex::getSingletonInstance(); $col = "$keyname, $valname"; @@ -1071,7 +1109,7 @@ public static function sfGetIDValueList($table, $keyname, $valname, $where = '', $objQuery->setOrder('rank DESC'); $arrList = $objQuery->select($col, $table, $where, $arrVal); $count = count($arrList); - $arrRet = array(); + $arrRet = []; for ($cnt = 0; $cnt < $count; $cnt++) { $key = $arrList[$cnt][$keyname]; $val = $arrList[$cnt][$valname]; @@ -1086,8 +1124,9 @@ public static function sfGetIDValueList($table, $keyname, $valname, $where = '', * * @param string $table テーブル名 * @param string $colname カラム名 - * @param integer $id テーブルのキー + * @param int $id テーブルのキー * @param string $andwhere SQL の AND 条件である WHERE 句 + * * @return void */ public function sfRankUp($table, $colname, $id, $andwhere = '') @@ -1096,10 +1135,10 @@ public function sfRankUp($table, $colname, $id, $andwhere = '') $objQuery->begin(); $where = "$colname = ?"; if ($andwhere != '') { - $where.= " AND $andwhere"; + $where .= " AND $andwhere"; } // 対象項目のランクを取得 - $rank = $objQuery->get('rank', $table, $where, array($id)); + $rank = $objQuery->get('rank', $table, $where, [$id]); // ランクの最大値を取得 $maxrank = $objQuery->max('rank', $table, $andwhere); // ランクが最大値よりも小さい場合に実行する。 @@ -1107,10 +1146,10 @@ public function sfRankUp($table, $colname, $id, $andwhere = '') // ランクが一つ上のIDを取得する。 $where = 'rank = ?'; if ($andwhere != '') { - $where.= " AND $andwhere"; + $where .= " AND $andwhere"; } $uprank = $rank + 1; - $up_id = $objQuery->get($colname, $table, $where, array($uprank)); + $up_id = $objQuery->get($colname, $table, $where, [$uprank]); // ランク入れ替えの実行 $where = "$colname = ?"; @@ -1118,16 +1157,16 @@ public function sfRankUp($table, $colname, $id, $andwhere = '') $where .= " AND $andwhere"; } - $sqlval = array( + $sqlval = [ 'rank' => $rank + 1, - ); - $arrWhereVal = array($id); + ]; + $arrWhereVal = [$id]; $objQuery->update($table, $sqlval, $where, $arrWhereVal); - $sqlval = array( + $sqlval = [ 'rank' => $rank, - ); - $arrWhereVal = array($up_id); + ]; + $arrWhereVal = [$up_id]; $objQuery->update($table, $sqlval, $where, $arrWhereVal); } $objQuery->commit(); @@ -1138,8 +1177,9 @@ public function sfRankUp($table, $colname, $id, $andwhere = '') * * @param string $table テーブル名 * @param string $colname カラム名 - * @param integer $id テーブルのキー + * @param int $id テーブルのキー * @param string $andwhere SQL の AND 条件である WHERE 句 + * * @return void */ public function sfRankDown($table, $colname, $id, $andwhere = '') @@ -1148,20 +1188,20 @@ public function sfRankDown($table, $colname, $id, $andwhere = '') $objQuery->begin(); $where = "$colname = ?"; if ($andwhere != '') { - $where.= " AND $andwhere"; + $where .= " AND $andwhere"; } // 対象項目のランクを取得 - $rank = $objQuery->get('rank', $table, $where, array($id)); + $rank = $objQuery->get('rank', $table, $where, [$id]); // ランクが1(最小値)よりも大きい場合に実行する。 if ($rank > 1) { // ランクが一つ下のIDを取得する。 $where = 'rank = ?'; if ($andwhere != '') { - $where.= " AND $andwhere"; + $where .= " AND $andwhere"; } $downrank = $rank - 1; - $down_id = $objQuery->get($colname, $table, $where, array($downrank)); + $down_id = $objQuery->get($colname, $table, $where, [$downrank]); // ランク入れ替えの実行 $where = "$colname = ?"; @@ -1169,16 +1209,16 @@ public function sfRankDown($table, $colname, $id, $andwhere = '') $where .= " AND $andwhere"; } - $sqlval = array( + $sqlval = [ 'rank' => $rank - 1, - ); - $arrWhereVal = array($id); + ]; + $arrWhereVal = [$id]; $objQuery->update($table, $sqlval, $where, $arrWhereVal); - $sqlval = array( + $sqlval = [ 'rank' => $rank, - ); - $arrWhereVal = array($down_id); + ]; + $arrWhereVal = [$down_id]; $objQuery->update($table, $sqlval, $where, $arrWhereVal); } $objQuery->commit(); @@ -1189,9 +1229,10 @@ public function sfRankDown($table, $colname, $id, $andwhere = '') * * @param string $tableName テーブル名 * @param string $keyIdColumn キーを保持するカラム名 - * @param integer $keyId キーの値 - * @param integer $pos 指定順位 + * @param int $keyId キーの値 + * @param int $pos 指定順位 * @param string $where SQL の AND 条件である WHERE 句 + * * @return void */ public function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = '') @@ -1201,11 +1242,11 @@ public function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = '') // 自身のランクを取得する if ($where != '') { - $getWhere = "$keyIdColumn = ? AND " . $where; + $getWhere = "$keyIdColumn = ? AND ".$where; } else { $getWhere = "$keyIdColumn = ?"; } - $oldRank = $objQuery->get('rank', $tableName, $getWhere, array($keyId)); + $oldRank = $objQuery->get('rank', $tableName, $getWhere, [$keyId]); $max = $objQuery->max('rank', $tableName, $where); @@ -1219,14 +1260,14 @@ public function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = '') } // 指定した順位へrankを書き換える。 - $sqlval = array( + $sqlval = [ 'rank' => $newRank, - ); + ]; $str_where = "$keyIdColumn = ?"; if ($where != '') { $str_where .= " AND $where"; } - $arrWhereVal = array($keyId); + $arrWhereVal = [$keyId]; $objQuery->update($tableName, $sqlval, $str_where, $arrWhereVal); $objQuery->commit(); @@ -1239,6 +1280,7 @@ public function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = '') * * @param int $position 指定された位置 * @param int $maxRank 現在のランク最大値 + * * @return int $newRank DBに登録するRANK値 */ public function getNewRank($position, $maxRank) @@ -1262,26 +1304,27 @@ public function getNewRank($position, $maxRank) * @param SC_Query $objQuery * @param string $tableName * @param string $addWhere - * @return boolean + * + * @return bool */ public function moveOtherItemRank($newRank, $oldRank, &$objQuery, $tableName, $addWhere) { - $sqlval = array(); - $arrRawSql = array(); + $sqlval = []; + $arrRawSql = []; $where = 'rank BETWEEN ? AND ?'; if ($addWhere != '') { $where .= " AND $addWhere"; } if ($newRank > $oldRank) { - //位置を上げる場合、他の商品の位置を1つ下げる(ランクを1下げる) + // 位置を上げる場合、他の商品の位置を1つ下げる(ランクを1下げる) $arrRawSql['rank'] = 'rank - 1'; - $arrWhereVal = array($oldRank + 1, $newRank); + $arrWhereVal = [$oldRank + 1, $newRank]; } elseif ($newRank < $oldRank) { - //位置を下げる場合、他の商品の位置を1つ上げる(ランクを1上げる) + // 位置を下げる場合、他の商品の位置を1つ上げる(ランクを1上げる) $arrRawSql['rank'] = 'rank + 1'; - $arrWhereVal = array($newRank, $oldRank - 1); + $arrWhereVal = [$newRank, $oldRank - 1]; } else { - //入れ替え先の順位が入れ替え元の順位と同じ場合なにもしない + // 入れ替え先の順位が入れ替え元の順位と同じ場合なにもしない return false; } @@ -1295,46 +1338,48 @@ public function moveOtherItemRank($newRank, $oldRank, &$objQuery, $tableName, $a * * @param string $table テーブル名 * @param string $colname カラム名 - * @param integer $id テーブルのキー + * @param int $id テーブルのキー * @param string $andwhere SQL の AND 条件である WHERE 句 * @param bool $delete レコードごと削除する場合 true, * レコードごと削除しない場合 false + * * @return void */ public function sfDeleteRankRecord($table, $colname, $id, $andwhere = '', - $delete = false) { + $delete = false) + { $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); // 削除レコードのランクを取得する。 $where = "$colname = ?"; if ($andwhere != '') { - $where.= " AND $andwhere"; + $where .= " AND $andwhere"; } - $rank = $objQuery->get('rank', $table, $where, array($id)); + $rank = $objQuery->get('rank', $table, $where, [$id]); if (!$delete) { // ランクを最下位にする、DELフラグON - $sqlval = array( - 'rank' => 0, - 'del_flg' => 1, - ); + $sqlval = [ + 'rank' => 0, + 'del_flg' => 1, + ]; $where = "$colname = ?"; - $arrWhereVal = array($id); + $arrWhereVal = [$id]; $objQuery->update($table, $sqlval, $where, $arrWhereVal); } else { - $objQuery->delete($table, "$colname = ?", array($id)); + $objQuery->delete($table, "$colname = ?", [$id]); } // 追加レコードのランクより上のレコードを一つずらす。 - $sqlval = array(); + $sqlval = []; $where = 'rank > ?'; if ($andwhere != '') { $where .= " AND $andwhere"; } - $arrWhereVal = array($rank); - $arrRawSql = array( + $arrWhereVal = [$rank]; + $arrRawSql = [ 'rank' => '(rank - 1)', - ); + ]; $objQuery->update($table, $sqlval, $where, $arrWhereVal, $arrRawSql); $objQuery->commit(); @@ -1348,7 +1393,9 @@ public function sfDeleteRankRecord($table, $colname, $id, $andwhere = '', * @param string $id_name ID名 * @param string $col_name カラム名 * @param array $arrId IDの配列 + * * @return array 特定のカラムの配列 + * * @deprecated 本体で使用されていないため非推奨 */ public function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId) @@ -1361,7 +1408,7 @@ public function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId) if ($where == '') { $where = "$id_name = ?"; } else { - $where.= " OR $id_name = ?"; + $where .= " OR $id_name = ?"; } } @@ -1380,10 +1427,12 @@ public function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId) * @param string $table テーブル名 * @param string $id_name ID名 * @param string $cat_name カテゴリ名 - * @param integer $old_catid 旧カテゴリID - * @param integer $new_catid 新カテゴリID - * @param integer $id ID + * @param int $old_catid 旧カテゴリID + * @param int $new_catid 新カテゴリID + * @param int $id ID + * * @return void + * * @deprecated 本体で使用されていないため非推奨 */ public function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) @@ -1393,25 +1442,25 @@ public function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid } // 旧カテゴリでのランク削除処理 // 移動レコードのランクを取得する。 - $sqlval = array(); + $sqlval = []; $where = "$id_name = ?"; - $rank = $objQuery->get('rank', $table, $where, array($id)); + $rank = $objQuery->get('rank', $table, $where, [$id]); // 削除レコードのランクより上のレコードを一つ下にずらす。 $where = "rank > ? AND $cat_name = ?"; - $arrWhereVal = array($rank, $old_catid); - $arrRawSql = array( + $arrWhereVal = [$rank, $old_catid]; + $arrRawSql = [ 'rank' => '(rank - 1)', - ); + ]; $objQuery->update($table, $sqlval, $where, $arrWhereVal, $arrRawSql); // 新カテゴリでの登録処理 // 新カテゴリの最大ランクを取得する。 - $max_rank = $objQuery->max('rank', $table, "$cat_name = ?", array($new_catid)) + 1; - $sqlval = array( + $max_rank = $objQuery->max('rank', $table, "$cat_name = ?", [$new_catid]) + 1; + $sqlval = [ 'rank' => $max_rank, - ); + ]; $where = "$id_name = ?"; - $arrWhereVal = array($id); + $arrWhereVal = [$id]; $objQuery->update($table, $sqlval, $where, $arrWhereVal); } @@ -1424,7 +1473,9 @@ public function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid * @param string $col カラム名 * @param array $arrVal 要素の配列 * @param string $addwhere SQL の AND 条件である WHERE 句 + * * @return bool レコードが存在する場合 true + * * @deprecated SC_Query::exists() を使用してください */ public static function sfIsRecord($table, $col, $arrVal, $addwhere = '') @@ -1435,7 +1486,7 @@ public static function sfIsRecord($table, $col, $arrVal, $addwhere = '') $where = 'del_flg = 0'; if ($addwhere != '') { - $where.= " AND $addwhere"; + $where .= " AND $addwhere"; } foreach ($arrCol as $val) { @@ -1443,7 +1494,7 @@ public static function sfIsRecord($table, $col, $arrVal, $addwhere = '') if ($where == '') { $where = "$val = ?"; } else { - $where.= " AND $val = ?"; + $where .= " AND $val = ?"; } } } @@ -1460,14 +1511,15 @@ public static function sfIsRecord($table, $col, $arrVal, $addwhere = '') * メーカー商品数数の登録を行う. * * @param SC_Query $objQuery SC_Query インスタンス + * * @return void */ public function sfCountMaker($objQuery) { - //テーブル内容の削除 + // テーブル内容の削除 $objQuery->query('DELETE FROM dtb_maker_count'); - //各メーカーの商品数を数えて格納 + // 各メーカーの商品数を数えて格納 $sql = ' INSERT INTO dtb_maker_count(maker_id, product_count, create_date) '; $sql .= ' SELECT T1.maker_id, count(T2.maker_id), CURRENT_TIMESTAMP '; $sql .= ' FROM dtb_maker AS T1 LEFT JOIN dtb_products AS T2'; @@ -1480,10 +1532,10 @@ public function sfCountMaker($objQuery) /** * 選択中の商品のメーカーを取得する. * - * @param integer $product_id プロダクトID - * @param integer $maker_id メーカーID - * @return array 選択中の商品のメーカーIDの配列 + * @param int $product_id プロダクトID + * @param int $maker_id メーカーID * + * @return array 選択中の商品のメーカーIDの配列 */ public function sfGetMakerId($product_id, $maker_id = 0, $closed = false) { @@ -1498,14 +1550,14 @@ public function sfGetMakerId($product_id, $maker_id = 0, $closed = false) $maker_id = (int) $maker_id; $product_id = (int) $product_id; if (SC_Utils_Ex::sfIsInt($maker_id) && $maker_id != 0 && $this->sfIsRecord('dtb_maker', 'maker_id', $maker_id)) { - $this->g_maker_id = array($maker_id); + $this->g_maker_id = [$maker_id]; } elseif (SC_Utils_Ex::sfIsInt($product_id) && $product_id != 0 && $this->sfIsRecord('dtb_products', 'product_id', $product_id, $status)) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $maker_id = $objQuery->getCol('maker_id', 'dtb_products', 'product_id = ?', array($product_id)); + $maker_id = $objQuery->getCol('maker_id', 'dtb_products', 'product_id = ?', [$product_id]); $this->g_maker_id = $maker_id; } else { // 不正な場合は、空の配列を返す。 - $this->g_maker_id = array(); + $this->g_maker_id = []; } } @@ -1519,6 +1571,7 @@ public function sfGetMakerId($product_id, $maker_id = 0, $closed = false) * * @param string $addwhere 追加する WHERE 句 * @param bool $products_check 商品の存在するカテゴリのみ取得する場合 true + * * @return array カテゴリツリーの配列 */ public function sfGetMakerList($addwhere = '', $products_check = false) @@ -1527,7 +1580,7 @@ public function sfGetMakerList($addwhere = '', $products_check = false) $where = 'del_flg = 0'; if ($addwhere != '') { - $where.= " AND $addwhere"; + $where .= " AND $addwhere"; } $objQuery->setOption('ORDER BY rank DESC'); @@ -1544,7 +1597,7 @@ public function sfGetMakerList($addwhere = '', $products_check = false) $arrRet = $objQuery->select($col, $from, $where); $max = count($arrRet); - $arrList = array(); + $arrList = []; for ($cnt = 0; $cnt < $max; $cnt++) { $id = $arrRet[$cnt]['maker_id']; $name = $arrRet[$cnt]['name']; @@ -1557,8 +1610,10 @@ public function sfGetMakerList($addwhere = '', $products_check = false) /** * 店舗基本情報に基づいて税金額を返す * - * @param integer $price 計算対象の金額 - * @return double 税金額 + * @param int $price 計算対象の金額 + * + * @return float 税金額 + * * @deprecated SC_Helper_TaxRule::sfTax() を使用してください */ public function sfTax($price) @@ -1576,14 +1631,16 @@ public function sfTax($price) * @param int $price 計算対象の金額 * @param int $tax * @param int $tax_rule - * @return double 税金付与した金額 + * + * @return float 税金付与した金額 + * * @deprecated SC_Helper_TaxRule::calcTax() を使用してください */ public static function sfCalcIncTax($price, $tax = null, $tax_rule = null) { // 店舗基本情報を取得 $CONF = SC_Helper_DB_Ex::sfGetBasisData(); - $tax = $tax === null ? $CONF['tax'] : $tax; + $tax = $tax === null ? $CONF['tax'] : $tax; $tax_rule = $tax_rule === null ? $CONF['tax_rule'] : $tax_rule; return SC_Utils_Ex::sfCalcIncTax($price, $tax, $tax_rule); @@ -1592,9 +1649,10 @@ public static function sfCalcIncTax($price, $tax = null, $tax_rule = null) /** * 店舗基本情報に基づいて加算ポイントを返す * - * @param integer $totalpoint - * @param integer $use_point - * @return integer 加算ポイント + * @param int $totalpoint + * @param int $use_point + * + * @return int 加算ポイント */ public static function sfGetAddPoint($totalpoint, $use_point) { @@ -1610,7 +1668,9 @@ public static function sfGetAddPoint($totalpoint, $use_point) * XXX プラグイン用に追加。将来消すかも。 * * @param string $sqlFilePath SQL ファイルのパス + * * @return void + * * @deprecated 本体で使用されていないため非推奨 */ public function sfExecSqlByFile($sqlFilePath) @@ -1619,11 +1679,15 @@ public function sfExecSqlByFile($sqlFilePath) $objQuery = SC_Query_Ex::getSingletonInstance(); $sqls = file_get_contents($sqlFilePath); - if ($sqls === false) trigger_error('ファイルは存在するが読み込めない', E_USER_ERROR); + if ($sqls === false) { + trigger_error('ファイルは存在するが読み込めない', E_USER_ERROR); + } foreach (explode(';', $sqls) as $sql) { $sql = trim($sql); - if (strlen($sql) == 0) continue; + if (strlen($sql) == 0) { + continue; + } $objQuery->query($sql); } } @@ -1632,16 +1696,19 @@ public function sfExecSqlByFile($sqlFilePath) /** * 商品規格を設定しているか * - * @param integer $product_id 商品ID + * @param int $product_id 商品ID + * * @return bool 商品規格が存在する場合:true, それ以外:false */ public function sfHasProductClass($product_id) { - if (!SC_Utils_Ex::sfIsInt($product_id)) return false; + if (!SC_Utils_Ex::sfIsInt($product_id)) { + return false; + } $objQuery = SC_Query_Ex::getSingletonInstance(); $where = 'product_id = ? AND del_flg = 0 AND (classcategory_id1 != 0 OR classcategory_id2 != 0)'; - $exists = $objQuery->exists('dtb_products_class', $where, array($product_id)); + $exists = $objQuery->exists('dtb_products_class', $where, [$product_id]); return $exists; } @@ -1650,6 +1717,7 @@ public function sfHasProductClass($product_id) * 店舗基本情報を登録する * * @param array $arrData 登録するデータ + * * @return void */ public static function registerBasisData($arrData) @@ -1686,10 +1754,12 @@ public static function registerBasisData($arrData) * @param string $table * @param string $where * @param array $arrval - * @return integer レコード件数 + * + * @return int レコード件数 + * * @deprecated SC_Query::count() を使用してください */ - public function countRecords($table, $where = '', $arrval = array()) + public function countRecords($table, $where = '', $arrval = []) { $objQuery = SC_Query_Ex::getSingletonInstance(); $col = 'COUNT(*)'; diff --git a/data/class/helper/SC_Helper_Delivery.php b/data/class/helper/SC_Helper_Delivery.php index 7544bbcf6f..358f0cffe9 100644 --- a/data/class/helper/SC_Helper_Delivery.php +++ b/data/class/helper/SC_Helper_Delivery.php @@ -24,8 +24,8 @@ /** * 配送方法を管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_Delivery @@ -33,8 +33,9 @@ class SC_Helper_Delivery /** * 配送方法の情報を取得. * - * @param integer $deliv_id 配送方法ID - * @param boolean $has_deleted 削除された支払方法も含む場合 true; 初期値 false + * @param int $deliv_id 配送方法ID + * @param bool $has_deleted 削除された支払方法も含む場合 true; 初期値 false + * * @return array */ public function get($deliv_id, $has_deleted = false) @@ -48,10 +49,10 @@ public function get($deliv_id, $has_deleted = false) $where .= ' AND del_flg = 0'; } $table = 'dtb_deliv'; - $arrRet = $objQuery->select($col, $table, $where, array($deliv_id)); + $arrRet = $objQuery->select($col, $table, $where, [$deliv_id]); if (empty($arrRet)) { - return array(); + return []; } $arrDeliv = $arrRet[0]; @@ -70,8 +71,9 @@ public function get($deliv_id, $has_deleted = false) /** * 配送方法一覧の取得. * - * @param integer $product_type_id 商品種別ID - * @param boolean $has_deleted 削除された支払方法も含む場合 true; 初期値 false + * @param int $product_type_id 商品種別ID + * @param bool $has_deleted 削除された支払方法も含む場合 true; 初期値 false + * * @return array */ public function getList($product_type_id = null, $has_deleted = false) @@ -79,7 +81,7 @@ public function getList($product_type_id = null, $has_deleted = false) $objQuery = SC_Query_Ex::getSingletonInstance(); $col = '*'; $where = ''; - $arrVal = array(); + $arrVal = []; if (!$has_deleted) { $where .= 'del_flg = 0'; } @@ -101,7 +103,8 @@ public function getList($product_type_id = null, $has_deleted = false) * 配送方法の登録. * * @param array $sqlval - * @return integer $deliv_id + * + * @return int $deliv_id */ public function save($sqlval) { @@ -128,18 +131,18 @@ public function save($sqlval) unset($sqlval['create_date']); $deliv_id = $sqlval['deliv_id']; $where = 'deliv_id = ?'; - $objQuery->update('dtb_deliv', $sqlval, $where, array($deliv_id)); + $objQuery->update('dtb_deliv', $sqlval, $where, [$deliv_id]); // お届け時間の登録 $table = 'dtb_delivtime'; $where = 'deliv_id = ? AND time_id = ?'; for ($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) { - $arrWhereVal = array($deliv_id, $cnt); + $arrWhereVal = [$deliv_id, $cnt]; // 既存データの有無を確認 $curData = $objQuery->select('*', $table, $where, $arrWhereVal); if (isset($sqlval_deliv_time[$cnt])) { - $deliv_time = array(); + $deliv_time = []; $deliv_time['deliv_time'] = $sqlval_deliv_time[$cnt]; // 入力が空ではなく、DBに情報があれば更新 @@ -160,7 +163,7 @@ public function save($sqlval) // 配送料の登録 if (INPUT_DELIV_FEE) { foreach ($sqlval_deliv_fee as $deliv_fee) { - $objQuery->update('dtb_delivfee', array('fee' => $deliv_fee['fee']), 'deliv_id = ? AND fee_id = ?', array($deliv_id, $deliv_fee['fee_id'])); + $objQuery->update('dtb_delivfee', ['fee' => $deliv_fee['fee']], 'deliv_id = ? AND fee_id = ?', [$deliv_id, $deliv_fee['fee_id']]); } } } else { @@ -174,7 +177,7 @@ public function save($sqlval) // お届け時間の設定 foreach ($sqlval_deliv_time as $cnt => $deliv_time_name) { - $deliv_time = array(); + $deliv_time = []; $deliv_time['deliv_time'] = $deliv_time_name; $deliv_time['deliv_id'] = $deliv_id; $deliv_time['time_id'] = $cnt; @@ -193,10 +196,10 @@ public function save($sqlval) } // 支払い方法 - $objQuery->delete('dtb_payment_options', 'deliv_id = ?', array($deliv_id)); + $objQuery->delete('dtb_payment_options', 'deliv_id = ?', [$deliv_id]); $i = 1; foreach ($sqlval_payment_ids as $payment_id) { - $sqlval_payment_id = array(); + $sqlval_payment_id = []; $sqlval_payment_id['deliv_id'] = $deliv_id; $sqlval_payment_id['payment_id'] = $payment_id; $sqlval_payment_id['rank'] = $i; @@ -212,7 +215,8 @@ public function save($sqlval) /** * 配送方法の削除. * - * @param integer $deliv_id 配送方法ID + * @param int $deliv_id 配送方法ID + * * @return void */ public function delete($deliv_id) @@ -225,7 +229,8 @@ public function delete($deliv_id) /** * 配送方法の表示順をひとつ上げる. * - * @param integer $deliv_id 配送方法ID + * @param int $deliv_id 配送方法ID + * * @return void */ public function rankUp($deliv_id) @@ -237,7 +242,8 @@ public function rankUp($deliv_id) /** * 配送方法の表示順をひとつ下げる. * - * @param integer $deliv_id 配送方法ID + * @param int $deliv_id 配送方法ID + * * @return void */ public function rankDown($deliv_id) @@ -250,16 +256,17 @@ public function rankDown($deliv_id) * 同じ内容の配送方法が存在するか確認. * * @param array $arrDeliv - * @return boolean + * + * @return bool */ public function checkExist($arrDeliv) { $objDb = new SC_Helper_DB_Ex(); if ($arrDeliv['deliv_id'] == '') { - $ret = $objDb->sfIsRecord('dtb_deliv', 'service_name', array($arrDeliv['service_name'])); + $ret = $objDb->sfIsRecord('dtb_deliv', 'service_name', [$arrDeliv['service_name']]); } else { $objQuery = SC_Query_Ex::getSingletonInstance(); - $ret = (($objQuery->count('dtb_deliv', 'deliv_id != ? AND service_name = ? AND del_flg = 0', array($arrDeliv['deliv_id'], $arrDeliv['service_name'])) > 0) ? true : false); + $ret = (($objQuery->count('dtb_deliv', 'deliv_id != ? AND service_name = ? AND del_flg = 0', [$arrDeliv['deliv_id'], $arrDeliv['service_name']]) > 0) ? true : false); } return $ret; @@ -269,6 +276,7 @@ public function checkExist($arrDeliv) * 配送方法IDをキー, 名前を値とする配列を取得. * * @param string $type 値のタイプ + * * @return array */ public static function getIDValueList($type = 'name') @@ -279,15 +287,16 @@ public static function getIDValueList($type = 'name') /** * 配送業者IDからお届け時間の配列を取得する. * - * @param integer $deliv_id 配送業者ID + * @param int $deliv_id 配送業者ID + * * @return array お届け時間の配列 */ public static function getDelivTime($deliv_id) { $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->setOrder('time_id'); - $results = $objQuery->select('time_id, deliv_time', 'dtb_delivtime', 'deliv_id = ?', array($deliv_id)); - $arrDelivTime = array(); + $results = $objQuery->select('time_id, deliv_time', 'dtb_delivtime', 'deliv_id = ?', [$deliv_id]); + $arrDelivTime = []; foreach ($results as $val) { $arrDelivTime[$val['time_id']] = $val['deliv_time']; } @@ -298,7 +307,8 @@ public static function getDelivTime($deliv_id) /** * 配送業者ID から, 有効な支払方法IDを取得する. * - * @param integer $deliv_id 配送業者ID + * @param int $deliv_id 配送業者ID + * * @return array 有効な支払方法IDの配列 */ public static function getPayments($deliv_id) @@ -306,21 +316,22 @@ public static function getPayments($deliv_id) $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->setOrder('rank'); - return $objQuery->getCol('payment_id', 'dtb_payment_options', 'deliv_id = ?', array($deliv_id)); + return $objQuery->getCol('payment_id', 'dtb_payment_options', 'deliv_id = ?', [$deliv_id]); } /** * 都道府県から配送料金を取得する. * - * @param integer|array $pref_id 都道府県ID 又は都道府県IDの配列 - * @param integer $deliv_id 配送業者ID + * @param int|array $pref_id 都道府県ID 又は都道府県IDの配列 + * @param int $deliv_id 配送業者ID + * * @return string 指定の都道府県, 配送業者の配送料金 */ public static function getDelivFee($pref_id, $deliv_id = 0) { $objQuery = SC_Query_Ex::getSingletonInstance(); if (!is_array($pref_id)) { - $pref_id = array($pref_id); + $pref_id = [$pref_id]; } $sql = <<< __EOS__ SELECT T1.fee AS fee @@ -333,7 +344,7 @@ public static function getDelivFee($pref_id, $deliv_id = 0) __EOS__; $result = 0; foreach ($pref_id as $pref) { - $result += $objQuery->getOne($sql, array($pref, $deliv_id)); + $result += $objQuery->getOne($sql, [$pref, $deliv_id]); } return $result; @@ -342,7 +353,8 @@ public static function getDelivFee($pref_id, $deliv_id = 0) /** * 配送業者ID から, 配送料金の一覧を取得する. * - * @param integer $deliv_id 配送業者ID + * @param int $deliv_id 配送業者ID + * * @return array 配送料金の配列 */ public static function getDelivFeeList($deliv_id) @@ -353,6 +365,6 @@ public static function getDelivFeeList($deliv_id) $where = 'deliv_id = ?'; $table = 'dtb_delivfee'; - return $objQuery->select($col, $table, $where, array($deliv_id)); + return $objQuery->select($col, $table, $where, [$deliv_id]); } } diff --git a/data/class/helper/SC_Helper_FPDI.php b/data/class/helper/SC_Helper_FPDI.php index 836d3d2062..fa8724e429 100644 --- a/data/class/helper/SC_Helper_FPDI.php +++ b/data/class/helper/SC_Helper_FPDI.php @@ -1,6 +1,7 @@ 'Japan1','supplement'=>2); + $registry = ['ordering' => 'Japan1', 'supplement' => 2]; $this->AddCIDFonts('Gothic', 'KozGoPro-Medium-Acro,MS-PGothic,Osaka', $cw, $c_map, $registry); } - public function SJISMultiCell($w, $h, $txt, $border=0, $align='L', $fill=false) + public function SJISMultiCell($w, $h, $txt, $border = 0, $align = 'L', $fill = false) { $arrArg = func_get_args(); @@ -72,7 +73,7 @@ public function FancyTable($header, $data, $w) $this->Cell(0, $h, '', 0, 0, '', 0, ''); $product_width = $this->GetStringWidth($row[0]); if ($w[0] < $product_width) { - $output_lines = (int)($product_width / $w[0]) + 1; + $output_lines = (int) ($product_width / $w[0]) + 1; $output_height = $output_lines * $h; if ($this->y + $output_height >= $this->PageBreakTrigger) { $this->AddPage(); @@ -102,15 +103,15 @@ public function FancyTable($header, $data, $w) } /** - * @param integer $x - * @param integer $y + * @param int $x + * @param int $y */ public function Text($x, $y, $txt) { parent::Text($x, $y, $this->lfConvSjis($txt)); } - public function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') + public function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '') { parent::Cell($w, $h, $this->lfConvSjis($txt), $border, $ln, $align, $fill, $link); } @@ -128,13 +129,14 @@ public function lfConvSjis($conv_str) public function _out($s) { // Add a line to the document - if($this->state==2) + if ($this->state == 2) { $this->pages[$this->page] .= $s."\n"; - elseif($this->state==1) + } elseif ($this->state == 1) { $this->_put($s); - elseif($this->state==0) + } elseif ($this->state == 0) { $this->Error('No page has been added yet'); - elseif($this->state==3) + } elseif ($this->state == 3) { $this->Error('The document is closed'); + } } } diff --git a/data/class/helper/SC_Helper_FileManager.php b/data/class/helper/SC_Helper_FileManager.php index cd26cefc60..876b168364 100644 --- a/data/class/helper/SC_Helper_FileManager.php +++ b/data/class/helper/SC_Helper_FileManager.php @@ -24,8 +24,8 @@ /** * ファイル管理 のヘルパークラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_Helper_FileManager @@ -34,20 +34,23 @@ class SC_Helper_FileManager * 指定パス配下のディレクトリ取得する. * * @param string $dir 取得するディレクトリパス + * * @return array */ public static function sfGetFileList($dir) { - $arrFileList = array(); - $arrDirList = array(); + $arrFileList = []; + $arrDirList = []; if (is_dir($dir)) { $dh = opendir($dir); if ($dh) { $cnt = 0; - $arrDir = array(); + $arrDir = []; // 行末の/を取り除く - while (($file = readdir($dh)) !== false) $arrDir[] = $file; + while (($file = readdir($dh)) !== false) { + $arrDir[] = $file; + } $dir = rtrim($dir, '/'); // アルファベットと数字でソート natcasesort($arrDir); @@ -56,7 +59,7 @@ public static function sfGetFileList($dir) if ($file != '.' && $file != '..') { $path = $dir.'/'.$file; // SELECT内の見た目を整えるため指定文字数で切る - $file_size = SC_Utils_Ex::sfCutString(SC_Helper_FileManager::sfGetDirSize($path), FILE_NAME_LEN); + $file_size = SC_Utils_Ex::sfCutString(self::sfGetDirSize($path), FILE_NAME_LEN); $file_time = date('Y/m/d', filemtime($path)); // ディレクトリとファイルで格納配列を変える @@ -90,7 +93,8 @@ public static function sfGetFileList($dir) * 指定したディレクトリのバイト数を取得する. * * @param string $dir ディレクトリ - * @return integer + * + * @return int */ public static function sfGetDirSize($dir) { @@ -129,12 +133,13 @@ public static function sfGetDirSize($dir) * @param string $dir ディレクトリ * @param string $tree_status 現在のツリーの状態開いているフォルダのパスを * | 区切りで格納 + * * @return array ツリー生成用の配列 */ public function sfGetFileTree($dir, $tree_status) { $cnt = 0; - $arrTree = array(); + $arrTree = []; $default_rank = count(explode('/', $dir)); // 文末の/を取り除く @@ -167,9 +172,10 @@ public function sfGetFileTree($dir, $tree_status) * @param string $dir ディレクトリ * @param string $default_rank デフォルトの階層 * (/区切りで 0,1,2・・・とカウント) - * @param integer $cnt 連番 + * @param int $cnt 連番 * @param string $tree_status 現在のツリーの状態開いているフォルダのパスが * | 区切りで格納 + * * @return void */ public function sfGetFileTreeSub($dir, $default_rank, &$cnt, &$arrTree, $tree_status) @@ -177,8 +183,10 @@ public function sfGetFileTreeSub($dir, $default_rank, &$cnt, &$arrTree, $tree_st if (file_exists($dir)) { $handle = opendir($dir); if ($handle) { - $arrDir = array(); - while (false !== ($item = readdir($handle))) $arrDir[] = $item; + $arrDir = []; + while (false !== ($item = readdir($handle))) { + $arrDir[] = $item; + } // アルファベットと数字でソート natcasesort($arrDir); foreach ($arrDir as $item) { @@ -218,6 +226,7 @@ public function sfGetFileTreeSub($dir, $default_rank, &$cnt, &$arrTree, $tree_st * * @param string ディレクトリ * @param string $dir + * * @return bool ファイルが存在する場合 true */ public function sfDirChildExists($dir) @@ -245,6 +254,7 @@ public function sfDirChildExists($dir) * @param string $dir ディレクトリ * @param string $tree_status 現在のツリーの状態開いているフォルダのパスが * | 区切りで格納 + * * @return bool 前回開かれた状態の場合 true */ public function lfIsFileOpen($dir, $tree_status) @@ -262,24 +272,26 @@ public function lfIsFileOpen($dir, $tree_status) * ファイルのダウンロードを行う. * * @param string $file ファイルパス + * * @return void */ public function sfDownloadFile($file) { // ファイルの場合はダウンロードさせる $file_name = basename($file); - header('Content-disposition: attachment; filename=' . $file_name); - header('Content-type: application/octet-stream; name=' . $file_name); + header('Content-disposition: attachment; filename='.$file_name); + header('Content-type: application/octet-stream; name='.$file_name); header('Cache-Control: '); header('Pragma: '); - echo ($this->sfReadFile($file)); + echo $this->sfReadFile($file); } /** * ファイル作成を行う. * * @param string $file ファイルパス - * @param integer $mode パーミッション + * @param int $mode パーミッション + * * @return bool ファイル作成に成功した場合 true */ public function sfCreateFile($file, $mode = '') @@ -299,16 +311,17 @@ public function sfCreateFile($file, $mode = '') * * @param string ファイルパス * @param string $filename + * * @return string ファイルの内容 */ public function sfReadFile($filename) { $str = ''; // バイナリモードでオープン - $fp = @fopen($filename, 'rb'); - //ファイル内容を全て変数に読み込む + $fp = @fopen($filename, 'r'); + // ファイル内容を全て変数に読み込む if ($fp) { - $str = @fread($fp, filesize($filename)+1); + $str = @fread($fp, filesize($filename) + 1); } @fclose($fp); @@ -320,7 +333,8 @@ public function sfReadFile($filename) * * @param string $filename ファイルパス * @param string $value 書き込み内容 - * @return boolean ファイルの書き込みに成功した場合 true + * + * @return bool ファイルの書き込みに成功した場合 true */ public static function sfWriteFile($filename, $value) { @@ -335,28 +349,30 @@ public static function sfWriteFile($filename, $value) return false; } - return fclose($fp);; + return fclose($fp); } /** * ユーザが作成したファイルをアーカイブしダウンロードさせる * TODO 要リファクタリング + * * @param string $dir アーカイブを行なうディレクトリ * @param string $template_code テンプレートコード - * @return boolean 成功した場合 true; 失敗した場合 false + * + * @return bool 成功した場合 true; 失敗した場合 false */ public static function downloadArchiveFiles($dir, $template_code) { // ダウンロードされるファイル名 - $dlFileName = 'tpl_package_' . $template_code . '_' . date('YmdHis') . '.tar.gz'; + $dlFileName = 'tpl_package_'.$template_code.'_'.date('YmdHis').'.tar.gz'; - $debug_message = $dir . ' から ' . $dlFileName . " を作成します...\n"; + $debug_message = $dir.' から '.$dlFileName." を作成します...\n"; // ファイル一覧取得 $arrFileHash = SC_Helper_FileManager_Ex::sfGetFileList($dir); - $arrFileList = array(); + $arrFileList = []; foreach ($arrFileHash as $val) { $arrFileList[] = $val['file_name']; - $debug_message.= '圧縮:'.$val['file_name']."\n"; + $debug_message .= '圧縮:'.$val['file_name']."\n"; } GC_Utils_Ex::gfPrintLog($debug_message); @@ -366,12 +382,12 @@ public static function downloadArchiveFiles($dir, $template_code) $tar = new Archive_Tar($dlFileName, true); if ($tar->create($arrFileList)) { // ダウンロード用HTTPヘッダ出力 - header("Content-disposition: attachment; filename=${dlFileName}"); - header("Content-type: application/octet-stream; name=${dlFileName}"); + header("Content-disposition: attachment; filename={$dlFileName}"); + header("Content-type: application/octet-stream; name={$dlFileName}"); header('Cache-Control: '); header('Pragma: '); readfile($dlFileName); - unlink($dir . '/' . $dlFileName); + unlink($dir.'/'.$dlFileName); return true; } else { @@ -383,7 +399,8 @@ public static function downloadArchiveFiles($dir, $template_code) * tarアーカイブを解凍する. * * @param string $path アーカイブパス - * @return boolean Archive_Tar::extractModify()のエラー + * + * @return bool Archive_Tar::extractModify()のエラー */ public static function unpackFile($path) { @@ -397,11 +414,11 @@ public static function unpackFile($path) $unpacking_name = preg_replace("/(\.tar|\.tar\.gz)$/", '', $file_name); // 指定されたフォルダ内に解凍する - $result = $tar->extractModify($dir. '/', $unpacking_name); - GC_Utils_Ex::gfPrintLog('解凍:' . $dir.'/'.$file_name.'->'.$dir.'/'.$unpacking_name); + $result = $tar->extractModify($dir.'/', $unpacking_name); + GC_Utils_Ex::gfPrintLog('解凍:'.$dir.'/'.$file_name.'->'.$dir.'/'.$unpacking_name); // フォルダ削除 - SC_Helper_FileManager_Ex::deleteFile($dir . '/' . $unpacking_name); + SC_Helper_FileManager_Ex::deleteFile($dir.'/'.$unpacking_name); // 圧縮ファイル削除 unlink($path); @@ -412,7 +429,8 @@ public static function unpackFile($path) * 指定されたパスの配下を再帰的に削除. * * @param string $path 削除対象のディレクトリまたはファイルのパス - * @param boolean $del_myself $pathそのものを削除するか. true なら削除する. + * @param bool $del_myself $pathそのものを削除するか. true なら削除する. + * * @return bool */ public static function deleteFile($path, $del_myself = true) @@ -420,16 +438,18 @@ public static function deleteFile($path, $del_myself = true) $flg = false; // 対象が存在するかを検証. if (file_exists($path) === false) { - GC_Utils_Ex::gfPrintLog($path . ' が存在しません.'); + GC_Utils_Ex::gfPrintLog($path.' が存在しません.'); } elseif (is_dir($path)) { // ディレクトリが指定された場合 $handle = opendir($path); if (!$handle) { - GC_Utils_Ex::gfPrintLog($path . ' が開けませんでした.'); + GC_Utils_Ex::gfPrintLog($path.' が開けませんでした.'); } while (($item = readdir($handle)) !== false) { - if ($item === '.' || $item === '..') continue; - $cur_path = $path . '/' . $item; + if ($item === '.' || $item === '..') { + continue; + } + $cur_path = $path.'/'.$item; if (is_dir($cur_path)) { // ディレクトリの場合、再帰処理 $flg = SC_Helper_FileManager_Ex::deleteFile($cur_path); @@ -440,13 +460,13 @@ public static function deleteFile($path, $del_myself = true) } closedir($handle); // ディレクトリを削除 - GC_Utils_Ex::gfPrintLog($path . ' を削除します.'); + GC_Utils_Ex::gfPrintLog($path.' を削除します.'); if ($del_myself) { $flg = @rmdir($path); } } else { // ファイルが指定された場合. - GC_Utils_Ex::gfPrintLog($path . ' を削除します.'); + GC_Utils_Ex::gfPrintLog($path.' を削除します.'); $flg = @unlink($path); } @@ -459,6 +479,7 @@ public static function deleteFile($path, $del_myself = true) * パスが USER_REALDIR の範囲外の場合は USER_DIR を返す. * * @param string $path 変換するパス + * * @return string USER_REALDIR 以下の相対パス */ public static function convertToRelativePath($path) @@ -480,13 +501,14 @@ public static function convertToRelativePath($path) * パスが USER_REALDIR の範囲外の場合は USER_REALDIR を返す. * * @param string $path 変換するパス + * * @return string USER_REALDIR 以下の絶対パス */ public static function convertToAbsolutePath($path) { $endsWithSlash = substr($path, -1) === '/'; // 絶対パスかどうか - if (strpos($path , '/') === 0 || preg_match('/^[a-z]:/i', $path)) { + if (strpos($path, '/') === 0 || preg_match('/^[a-z]:/i', $path)) { $path = realpath($path); } else { $path = realpath(HTML_REALDIR.$path); diff --git a/data/class/helper/SC_Helper_HandleError.php b/data/class/helper/SC_Helper_HandleError.php index a1b1d81843..c82a3c01db 100644 --- a/data/class/helper/SC_Helper_HandleError.php +++ b/data/class/helper/SC_Helper_HandleError.php @@ -26,16 +26,16 @@ * * 依存するクラスに構文エラーがあると、捕捉できない。よって、依存は最小に留めること。 * 現状 GC_Utils_Ex(GC_Utils) に依存しているため、その中で構文エラーは捕捉できない。 - * @package Helper + * * @version $Id$ */ class SC_Helper_HandleError { /** エラー処理中か */ - static $under_error_handling = false; + public static $under_error_handling = false; /** display_errors の初期値 */ - static $default_display_errors; + public static $default_display_errors; /** * 処理の読み込みを行う @@ -58,10 +58,10 @@ public static function load() if (!(defined('SAFE') && SAFE === true) && !(defined('INSTALL_FUNCTION') && INSTALL_FUNCTION === true)) { // E_USER_ERROR または警告を捕捉した場合のエラーハンドラ - set_error_handler(array(__CLASS__, 'handle_warning'), E_USER_ERROR | E_WARNING | E_USER_WARNING | E_CORE_WARNING | E_COMPILE_WARNING); + set_error_handler([__CLASS__, 'handle_warning'], E_USER_ERROR | E_WARNING | E_USER_WARNING | E_CORE_WARNING | E_COMPILE_WARNING); // E_USER_ERROR 以外のエラーを捕捉した場合の処理用 - register_shutdown_function(array(__CLASS__, 'handle_error')); + register_shutdown_function([__CLASS__, 'handle_error']); // 以降の処理では画面へのエラー表示は行なわない ini_set('display_errors', 0); } @@ -76,11 +76,12 @@ public static function load() * E_WARNING, E_USER_WARNING が発生した場合、ログを記録して、true を返す。 * (エラー画面・エラー文言は表示させない。) * - * @param integer $errno エラーコード + * @param int $errno エラーコード * @param string $errstr エラーメッセージ * @param string $errfile エラーが発生したファイル名 - * @param integer $errline エラーが発生した行番号 - * @return void|boolean E_USER_ERROR が発生した場合は, エラーページへリダイレクト; + * @param int $errline エラーが発生した行番号 + * + * @return void|bool E_USER_ERROR が発生した場合は, エラーページへリダイレクト; * E_WARNING, E_USER_WARNING が発生した場合、true を返す */ public static function handle_warning($errno, $errstr, $errfile, $errline) @@ -139,17 +140,19 @@ public static function handle_warning($errno, $errstr, $errfile, $errline) * エラーページへリダイレクトする. * * @param string $buffer 出力バッファリングの内容 + * * @return string|void エラーが捕捉された場合は, エラーページへリダイレクトする; * エラーが捕捉されない場合は, 出力バッファリングの内容を返す + * * @deprecated 2.18 EC-CUBE 本体では使用していない。 */ - static function &_fatal_error_handler(&$buffer) + public static function &_fatal_error_handler(&$buffer) { if (preg_match('/(Fatal error)<\/b>: +(.+) in (.+)<\/b> on line (\d+)<\/b>
/i', $buffer, $matches)) { $message = "$matches[1]: $matches[2] on [$matches[3]($matches[4])]"; GC_Utils_Ex::gfPrintLog($message, ERROR_LOG_REALFILE, true); if (DEBUG_MODE !== true) { - $url = HTTP_URL . 'error.php'; + $url = HTTP_URL.'error.php'; if (defined('ADMIN_FUNCTION') && ADMIN_FUNCTION === true) { $url .= '?admin'; } @@ -211,6 +214,7 @@ public static function handle_error() * エラー画面を表示する * * @param string|null $errstr エラーメッセージ + * * @return void */ public static function displaySystemError($errstr = null) diff --git a/data/class/helper/SC_Helper_Holiday.php b/data/class/helper/SC_Helper_Holiday.php index a49ac12989..2601d0b529 100644 --- a/data/class/helper/SC_Helper_Holiday.php +++ b/data/class/helper/SC_Helper_Holiday.php @@ -24,8 +24,8 @@ /** * 休日を管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_Holiday @@ -33,8 +33,9 @@ class SC_Helper_Holiday /** * 休日の情報を取得. * - * @param integer $holiday_id 休日ID - * @param boolean $has_deleted 削除された休日も含む場合 true; 初期値 false + * @param int $holiday_id 休日ID + * @param bool $has_deleted 削除された休日も含む場合 true; 初期値 false + * * @return array */ public function get($holiday_id, $has_deleted = false) @@ -44,7 +45,7 @@ public function get($holiday_id, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select('*', 'dtb_holiday', $where, array($holiday_id)); + $arrRet = $objQuery->select('*', 'dtb_holiday', $where, [$holiday_id]); return $arrRet[0]; } @@ -52,7 +53,8 @@ public function get($holiday_id, $has_deleted = false) /** * 休日一覧の取得. * - * @param boolean $has_deleted 削除された休日も含む場合 true; 初期値 false + * @param bool $has_deleted 削除された休日も含む場合 true; 初期値 false + * * @return array */ public function getList($has_deleted = false) @@ -74,6 +76,7 @@ public function getList($has_deleted = false) * 休日の登録. * * @param array $sqlval + * * @return multiple 登録成功:休日ID, 失敗:FALSE */ public function save($sqlval) @@ -94,16 +97,17 @@ public function save($sqlval) unset($sqlval['creator_id']); unset($sqlval['create_date']); $where = 'holiday_id = ?'; - $ret = $objQuery->update('dtb_holiday', $sqlval, $where, array($holiday_id)); + $ret = $objQuery->update('dtb_holiday', $sqlval, $where, [$holiday_id]); } - return ($ret) ? $sqlval['holiday_id'] : FALSE; + return ($ret) ? $sqlval['holiday_id'] : false; } /** * 休日の削除. * - * @param integer $holiday_id 休日ID + * @param int $holiday_id 休日ID + * * @return void */ public function delete($holiday_id) @@ -116,7 +120,8 @@ public function delete($holiday_id) /** * 休日の表示順をひとつ上げる. * - * @param integer $holiday_id 休日ID + * @param int $holiday_id 休日ID + * * @return void */ public function rankUp($holiday_id) @@ -128,7 +133,8 @@ public function rankUp($holiday_id) /** * 休日の表示順をひとつ下げる. * - * @param integer $holiday_id 休日ID + * @param int $holiday_id 休日ID + * * @return void */ public function rankDown($holiday_id) @@ -140,16 +146,17 @@ public function rankDown($holiday_id) /** * 同じ日付の休日が存在するか確認. * - * @param integer $month - * @param integer $day - * @param integer $holiday_id - * @return boolean 同日付の休日が存在:true + * @param int $month + * @param int $day + * @param int $holiday_id + * + * @return bool 同日付の休日が存在:true */ - public function isDateExist($month, $day, $holiday_id = NULL) + public function isDateExist($month, $day, $holiday_id = null) { $objQuery = SC_Query_Ex::getSingletonInstance(); $where = 'del_flg = 0 AND month = ? AND day = ?'; - $arrVal = array($month, $day); + $arrVal = [$month, $day]; if (!SC_Utils_Ex::isBlank($holiday_id)) { $where .= ' AND holiday_id <> ?'; $arrVal[] = $holiday_id; diff --git a/data/class/helper/SC_Helper_Kiyaku.php b/data/class/helper/SC_Helper_Kiyaku.php index 20b631a912..1b27892836 100644 --- a/data/class/helper/SC_Helper_Kiyaku.php +++ b/data/class/helper/SC_Helper_Kiyaku.php @@ -24,8 +24,8 @@ /** * 会員規約を管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_Kiyaku @@ -33,8 +33,9 @@ class SC_Helper_Kiyaku /** * 会員規約の情報を取得. * - * @param integer $kiyaku_id 会員規約ID - * @param boolean $has_deleted 削除された会員規約も含む場合 true; 初期値 false + * @param int $kiyaku_id 会員規約ID + * @param bool $has_deleted 削除された会員規約も含む場合 true; 初期値 false + * * @return array */ public function getKiyaku($kiyaku_id, $has_deleted = false) @@ -44,7 +45,7 @@ public function getKiyaku($kiyaku_id, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select('*', 'dtb_kiyaku', $where, array($kiyaku_id)); + $arrRet = $objQuery->select('*', 'dtb_kiyaku', $where, [$kiyaku_id]); return $arrRet[0]; } @@ -52,7 +53,8 @@ public function getKiyaku($kiyaku_id, $has_deleted = false) /** * 会員規約一覧の取得. * - * @param boolean $has_deleted 削除された会員規約も含む場合 true; 初期値 false + * @param bool $has_deleted 削除された会員規約も含む場合 true; 初期値 false + * * @return array */ public function getList($has_deleted = false) @@ -74,6 +76,7 @@ public function getList($has_deleted = false) * 会員規約の登録. * * @param array $sqlval + * * @return multiple 登録成功:会員規約ID, 失敗:FALSE */ public function saveKiyaku($sqlval) @@ -94,16 +97,17 @@ public function saveKiyaku($sqlval) unset($sqlval['creator_id']); unset($sqlval['create_date']); $where = 'kiyaku_id = ?'; - $ret = $objQuery->update('dtb_kiyaku', $sqlval, $where, array($kiyaku_id)); + $ret = $objQuery->update('dtb_kiyaku', $sqlval, $where, [$kiyaku_id]); } - return ($ret) ? $sqlval['kiyaku_id'] : FALSE; + return ($ret) ? $sqlval['kiyaku_id'] : false; } /** * 会員規約の削除. * - * @param integer $kiyaku_id 会員規約ID + * @param int $kiyaku_id 会員規約ID + * * @return void */ public function deleteKiyaku($kiyaku_id) @@ -116,7 +120,8 @@ public function deleteKiyaku($kiyaku_id) /** * 会員規約の表示順をひとつ上げる. * - * @param integer $kiyaku_id 会員規約ID + * @param int $kiyaku_id 会員規約ID + * * @return void */ public function rankUp($kiyaku_id) @@ -128,7 +133,8 @@ public function rankUp($kiyaku_id) /** * 会員規約の表示順をひとつ下げる. * - * @param integer $kiyaku_id 会員規約ID + * @param int $kiyaku_id 会員規約ID + * * @return void */ public function rankDown($kiyaku_id) @@ -141,18 +147,19 @@ public function rankDown($kiyaku_id) * 同じタイトルの規約が存在するか確認. * * @param string $title 規約タイトル - * @param integer $kiyaku_id 会員規約ID - * @return boolean 同名のタイトルが存在:TRUE + * @param int $kiyaku_id 会員規約ID + * + * @return bool 同名のタイトルが存在:TRUE */ - public function isTitleExist($title, $kiyaku_id = NULL) + public function isTitleExist($title, $kiyaku_id = null) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $where = 'del_flg = 0 AND kiyaku_title = ?'; - $arrVal = array($title); + $where = 'del_flg = 0 AND kiyaku_title = ?'; + $arrVal = [$title]; if (!SC_Utils_Ex::isBlank($kiyaku_id)) { - $where .= ' AND kiyaku_id <> ?'; + $where .= ' AND kiyaku_id <> ?'; $arrVal[] = $kiyaku_id; } diff --git a/data/class/helper/SC_Helper_Mail.php b/data/class/helper/SC_Helper_Mail.php index 3fc82696e2..9e1a00c713 100644 --- a/data/class/helper/SC_Helper_Mail.php +++ b/data/class/helper/SC_Helper_Mail.php @@ -24,8 +24,8 @@ /** * メール関連 のヘルパークラス. * - * @package Helper * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_Helper_Mail @@ -51,7 +51,7 @@ class SC_Helper_Mail public function __construct() { $masterData = new SC_DB_MasterData_Ex(); - $this->arrMAILTPLPATH = $masterData->getMasterData('mtb_mail_tpl_path'); + $this->arrMAILTPLPATH = $masterData->getMasterData('mtb_mail_tpl_path'); $this->arrPref = $masterData->getMasterData('mtb_pref'); $this->arrCountry = $masterData->getMasterData('mtb_country'); } @@ -80,7 +80,7 @@ public function getPage() /** * @param string $to_name - * @param integer $template_id + * @param int $template_id * @param LC_Page_Contact $objPage */ public function sfSendTemplateMail($to, $to_name, $template_id, &$objPage, $from_address = '', $from_name = '', $reply_to = '', $bcc = '') @@ -102,9 +102,15 @@ public function sfSendTemplateMail($to, $to_name, $template_id, &$objPage, $from // メール送信処理 $objSendMail = new SC_SendMail_Ex(); - if ($from_address == '') $from_address = $arrInfo['email03']; - if ($from_name == '') $from_name = $arrInfo['shop_name']; - if ($reply_to == '') $reply_to = $arrInfo['email03']; + if ($from_address == '') { + $from_address = $arrInfo['email03']; + } + if ($from_name == '') { + $from_name = $arrInfo['shop_name']; + } + if ($reply_to == '') { + $reply_to = $arrInfo['email03']; + } $error = $arrInfo['email04']; $tosubject = $this->sfMakeSubject($tmp_subject, $objMailView); @@ -137,7 +143,7 @@ public function sfSendOrderMail($order_id, $template_id, $subject = '', $header // 受注情報の取得 $where = 'order_id = ? AND del_flg = 0'; - $arrOrder = $objQuery->getRow('*', 'dtb_order', $where, array($order_id)); + $arrOrder = $objQuery->getRow('*', 'dtb_order', $where, [$order_id]); if (empty($arrOrder)) { trigger_error("該当する受注が存在しない。(注文番号: $order_id)", E_USER_ERROR); @@ -145,7 +151,7 @@ public function sfSendOrderMail($order_id, $template_id, $subject = '', $header $where = 'order_id = ?'; $objQuery->setOrder('order_detail_id'); - $arrTplVar->arrOrderDetail = $objQuery->select('*', 'dtb_order_detail', $where, array($order_id)); + $arrTplVar->arrOrderDetail = $objQuery->select('*', 'dtb_order_detail', $where, [$order_id]); // 配送情報の取得 $arrTplVar->arrShipping = $this->sfGetShippingData($order_id); @@ -155,13 +161,13 @@ public function sfSendOrderMail($order_id, $template_id, $subject = '', $header // 会員情報の取得 $customer_id = $arrOrder['customer_id']; $objQuery->setOrder('customer_id'); - $arrRet = $objQuery->select('point', 'dtb_customer', 'customer_id = ?', array($customer_id)); + $arrRet = $objQuery->select('point', 'dtb_customer', 'customer_id = ?', [$customer_id]); $arrCustomer = isset($arrRet[0]) ? $arrRet[0] : ''; $arrTplVar->arrCustomer = $arrCustomer; $arrTplVar->arrOrder = $arrOrder; - //その他決済情報 + // その他決済情報 if ($arrOrder['memo02'] != '') { $arrOther = unserialize($arrOrder['memo02']); @@ -202,7 +208,7 @@ public function sfSendOrderMail($order_id, $template_id, $subject = '', $header $tosubject = $this->sfMakeSubject($tmp_subject, $objMailView); $objSendMail->setItem('', $tosubject, $body, $from, $arrInfo['shop_name'], $from, $error, $error, $bcc); - $objSendMail->setTo($arrOrder['order_email'], $arrOrder['order_name01'] . ' '. $arrOrder['order_name02'] .' 様'); + $objSendMail->setTo($arrOrder['order_email'], $arrOrder['order_name01'].' '.$arrOrder['order_name02'].' 様'); // 送信フラグ:trueの場合は、送信する。 if ($send) { @@ -217,7 +223,8 @@ public function sfSendOrderMail($order_id, $template_id, $subject = '', $header /** * 配送情報の取得 * - * @param integer $order_id 受注ID + * @param int $order_id 受注ID + * * @return array 配送情報を格納した配列 */ public function sfGetShippingData($order_id) @@ -225,13 +232,13 @@ public function sfGetShippingData($order_id) $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->setOrder('shipping_id'); - $arrRet = $objQuery->select('*', 'dtb_shipping', 'order_id = ?', array($order_id)); + $arrRet = $objQuery->select('*', 'dtb_shipping', 'order_id = ?', [$order_id]); foreach ($arrRet as $key => $value) { $col = 's_i.*, tax_rate, tax_rule'; $from = 'dtb_shipment_item AS s_i JOIN dtb_order_detail AS o_d ON s_i.order_id = o_d.order_id AND s_i.product_class_id = o_d.product_class_id'; $where = 'o_d.order_id = ? AND shipping_id = ?'; - $arrWhereVal = array($order_id, $arrRet[$key]['shipping_id']); + $arrWhereVal = [$order_id, $arrRet[$key]['shipping_id']]; $objQuery->setOrder('order_detail_id'); $arrItems = $objQuery->select($col, $from, $where, $arrWhereVal); $arrRet[$key]['shipment_item'] = $arrItems; @@ -247,7 +254,7 @@ public function sfSendTplMail($to, $tmp_subject, $tplpath, &$objPage) $objMailView->setPage($this->getPage()); $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); // メール本文の取得 - $objPage->tpl_shopname=$arrInfo['shop_name']; + $objPage->tpl_shopname = $arrInfo['shop_name']; $objPage->tpl_infoemail = $arrInfo['email02']; $objMailView->assignobj($objPage); $body = $objMailView->fetch($tplpath); @@ -277,23 +284,23 @@ public function sfSendMail($to, $tmp_subject, $body) $objSendMail->sendMail(); } - //件名にテンプレートを用いる + // 件名にテンプレートを用いる /** * @param SC_SiteView_Ex $objMailView */ - public function sfMakeSubject($subject, &$objMailView = NULL) + public function sfMakeSubject($subject, &$objMailView = null) { if (empty($objMailView)) { $objMailView = new SC_SiteView_Ex(); $objMailView->setPage($this->getPage()); } - $objTplAssign = new stdClass; + $objTplAssign = new stdClass(); $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); - $objTplAssign->tpl_shopname=$arrInfo['shop_name']; - $objTplAssign->tpl_infoemail=$subject; // 従来互換 - $objTplAssign->tpl_mailtitle=$subject; + $objTplAssign->tpl_shopname = $arrInfo['shop_name']; + $objTplAssign->tpl_infoemail = $subject; // 従来互換 + $objTplAssign->tpl_mailtitle = $subject; $objMailView->assignobj($objTplAssign); $subject = $objMailView->fetch('mail_templates/mail_title.tpl'); // #1940 (SC_Helper_Mail#sfMakeSubject 先頭に改行を含む値を返す) 対応 @@ -309,12 +316,14 @@ public function sfMakeSubject($subject, &$objMailView = NULL) */ public function sfSaveMailHistory($order_id, $template_id, $subject, $body) { - $sqlval = array(); + $sqlval = []; $sqlval['subject'] = $subject; $sqlval['order_id'] = $order_id; $sqlval['template_id'] = $template_id; $sqlval['send_date'] = 'CURRENT_TIMESTAMP'; - if (!isset($_SESSION['member_id'])) $_SESSION['member_id'] = ''; + if (!isset($_SESSION['member_id'])) { + $_SESSION['member_id'] = ''; + } if ($_SESSION['member_id'] != '') { $sqlval['creator_id'] = $_SESSION['member_id']; } else { @@ -329,6 +338,7 @@ public function sfSaveMailHistory($order_id, $template_id, $subject, $body) /** * 会員登録があるかどうかのチェック(仮会員を含まない) + * * @deprecated 本体では使用されていないため非推奨 */ public function sfCheckCustomerMailMaga($email) @@ -337,7 +347,7 @@ public function sfCheckCustomerMailMaga($email) $from = 'dtb_customer'; $where = '(email = ? OR email_mobile = ?) AND status = 2 AND del_flg = 0'; $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrRet = $objQuery->select($col, $from, $where, array($email)); + $arrRet = $objQuery->select($col, $from, $where, [$email]); // 会員のメールアドレスが登録されている if (!empty($arrRet[0]['customer_id'])) { return true; @@ -350,11 +360,11 @@ public function sfCheckCustomerMailMaga($email) * 登録メールを送信する。 * * @param string $secret_key 会員固有キー - * @param integer $customer_id 会員ID - * @param boolean $is_mobile false(default):PCアドレスにメールを送る true:携帯アドレスにメールを送る + * @param int $customer_id 会員ID + * @param bool $is_mobile false(default):PCアドレスにメールを送る true:携帯アドレスにメールを送る * @param $resend_flg true 仮登録メール再送 - * @return boolean true:成功 false:失敗 * + * @return bool true:成功 false:失敗 */ public function sfSendRegistMail($secret_key, $customer_id = '', $is_mobile = false, $resend_flg = false) { @@ -362,7 +372,7 @@ public function sfSendRegistMail($secret_key, $customer_id = '', $is_mobile = fa if (SC_Utils_Ex::sfIsInt($customer_id)) { $arrCustomerData = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); } else { - $arrCustomerData = SC_Helper_Customer_Ex::sfGetCustomerDataFromId('', 'secret_key = ?', array($secret_key)); + $arrCustomerData = SC_Helper_Customer_Ex::sfGetCustomerDataFromId('', 'secret_key = ?', [$secret_key]); } if (SC_Utils_Ex::isBlank($arrCustomerData)) { return false; @@ -378,15 +388,14 @@ public function sfSendRegistMail($secret_key, $customer_id = '', $is_mobile = fa $objMailText->assign('uniqid', $arrCustomerData['secret_key']); $objMailText->assignobj($arrCustomerData); - $objHelperMail = new SC_Helper_Mail_Ex(); + $objHelperMail = new SC_Helper_Mail_Ex(); // 仮会員が有効の場合 - if (CUSTOMER_CONFIRM_MAIL == true and $arrCustomerData['status'] == 1 or $arrCustomerData['status'] == 1 and $resend_flg == true) { - $subject = $objHelperMail->sfMakeSubject('会員登録のご確認', $objMailText); + if (CUSTOMER_CONFIRM_MAIL == true && $arrCustomerData['status'] == 1 || $arrCustomerData['status'] == 1 && $resend_flg == true) { + $subject = $objHelperMail->sfMakeSubject('会員登録のご確認', $objMailText); $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl'); } else { - $subject = $objHelperMail->sfMakeSubject('会員登録のご完了', $objMailText); + $subject = $objHelperMail->sfMakeSubject('会員登録のご完了', $objMailText); $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl'); - } $objMail = new SC_SendMail_Ex(); @@ -407,7 +416,7 @@ public function sfSendRegistMail($secret_key, $customer_id = '', $is_mobile = fa } else { $to_addr = $arrCustomerData['email']; } - $objMail->setTo($to_addr, $arrCustomerData['name01'] . $arrCustomerData['name02'] .' 様'); + $objMail->setTo($to_addr, $arrCustomerData['name01'].$arrCustomerData['name02'].' 様'); $objMail->sendMail(); @@ -416,8 +425,11 @@ public function sfSendRegistMail($secret_key, $customer_id = '', $is_mobile = fa /** * 保存されているメルマガテンプレートの取得 - * @param integer 特定IDのテンプレートを取り出したい時はtemplate_idを指定。未指定時は全件取得 + * + * @param int 特定IDのテンプレートを取り出したい時はtemplate_idを指定。未指定時は全件取得 + * * @return array メールテンプレート情報を格納した配列 + * * @todo 表示順も引数で変更できるように */ public static function sfGetMailmagaTemplate($template_id = null) @@ -429,7 +441,7 @@ public static function sfGetMailmagaTemplate($template_id = null) // 条件文 $where = 'del_flg = ?'; $arrValues[] = 0; - //template_id指定時 + // template_id指定時 if (SC_Utils_Ex::sfIsInt($template_id) === true) { $where .= ' AND template_id = ?'; $arrValues[] = $template_id; @@ -445,7 +457,9 @@ public static function sfGetMailmagaTemplate($template_id = null) /** * 保存されているメルマガ送信履歴の取得 - * @param integer 特定の送信履歴を取り出したい時はsend_idを指定。未指定時は全件取得 + * + * @param int 特定の送信履歴を取り出したい時はsend_idを指定。未指定時は全件取得 + * * @return array 送信履歴情報を格納した配列 */ public function sfGetSendHistory($send_id = null) @@ -458,7 +472,7 @@ public function sfGetSendHistory($send_id = null) $where = 'del_flg = ?'; $arrValues[] = 0; - //send_id指定時 + // send_id指定時 if (SC_Utils_Ex::sfIsInt($send_id) === true) { $where .= ' AND send_id = ?'; $arrValues[] = $send_id; @@ -475,7 +489,8 @@ public function sfGetSendHistory($send_id = null) /** * 指定したIDのメルマガ配送を行う * - * @param integer $send_id dtb_send_history の情報 + * @param int $send_id dtb_send_history の情報 + * * @return void */ public static function sfSendMailmagazine($send_id) @@ -486,17 +501,19 @@ public static function sfSendMailmagazine($send_id) $objMail = new SC_SendMail_Ex(); $where = 'del_flg = 0 AND send_id = ?'; - $arrMail = $objQuery->getRow('*', 'dtb_send_history', $where, array($send_id)); + $arrMail = $objQuery->getRow('*', 'dtb_send_history', $where, [$send_id]); // 対象となる$send_idが見つからない - if (SC_Utils_Ex::isBlank($arrMail)) return; + if (SC_Utils_Ex::isBlank($arrMail)) { + return; + } // 送信先リストの取得 $arrDestinationList = $objQuery->select( '*', 'dtb_send_customer', 'send_id = ? AND (send_flag = 2 OR send_flag IS NULL)', - array($send_id) + [$send_id] ); // 現在の配信数 @@ -541,19 +558,19 @@ public static function sfSendMailmagazine($send_id) // 送信結果情報を更新 $objQuery->update('dtb_send_customer', - array('send_flag'=>$sendFlag), - 'send_id = ? AND customer_id = ?', - array($send_id,$arrDestination['customer_id'])); + ['send_flag' => $sendFlag], + 'send_id = ? AND customer_id = ?', + [$send_id, $arrDestination['customer_id']]); } // メール全件送信完了後の処理 $objQuery->update('dtb_send_history', - array('end_date'=>'CURRENT_TIMESTAMP', 'complete_count'=>$complete_count), - 'send_id = ?', - array($send_id)); + ['end_date' => 'CURRENT_TIMESTAMP', 'complete_count' => $complete_count], + 'send_id = ?', + [$send_id]); // 送信完了 報告メール - $compSubject = date('Y年m月d日H時i分') . ' 下記メールの配信が完了しました。'; + $compSubject = date('Y年m月d日H時i分').' 下記メールの配信が完了しました。'; // 管理者宛に変更 $objMail->setTo($objSite['email03']); $objMail->setSubject($compSubject); diff --git a/data/class/helper/SC_Helper_Mailtemplate.php b/data/class/helper/SC_Helper_Mailtemplate.php index a95d1dc7bd..965da1b83e 100644 --- a/data/class/helper/SC_Helper_Mailtemplate.php +++ b/data/class/helper/SC_Helper_Mailtemplate.php @@ -24,8 +24,8 @@ /** * メールテンプレートを管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_Mailtemplate @@ -33,8 +33,9 @@ class SC_Helper_Mailtemplate /** * メールテンプレートの情報を取得. * - * @param integer $template_id メールテンプレートID - * @param boolean $has_deleted 削除されたメールテンプレートも含む場合 true; 初期値 false + * @param int $template_id メールテンプレートID + * @param bool $has_deleted 削除されたメールテンプレートも含む場合 true; 初期値 false + * * @return array */ public function get($template_id, $has_deleted = false) @@ -45,7 +46,7 @@ public function get($template_id, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select($col, 'dtb_mailtemplate', $where, array($template_id)); + $arrRet = $objQuery->select($col, 'dtb_mailtemplate', $where, [$template_id]); return $arrRet[0]; } @@ -53,7 +54,8 @@ public function get($template_id, $has_deleted = false) /** * メールテンプレート一覧の取得. * - * @param boolean $has_deleted 削除されたメールテンプレートも含む場合 true; 初期値 false + * @param bool $has_deleted 削除されたメールテンプレートも含む場合 true; 初期値 false + * * @return array */ public function getList($has_deleted = false) @@ -74,6 +76,7 @@ public function getList($has_deleted = false) * メールテンプレートの登録. * * @param array $sqlval + * * @return multiple 登録成功:メールテンプレートID, 失敗:FALSE */ public function save($sqlval) @@ -84,7 +87,7 @@ public function save($sqlval) $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; // 存在確認 $where = 'template_id = ?'; - $exist = $objQuery->exists('dtb_mailtemplate', $where, array($template_id)); + $exist = $objQuery->exists('dtb_mailtemplate', $where, [$template_id]); // 新規登録 if (!$exist) { // INSERTの実行 @@ -97,9 +100,9 @@ public function save($sqlval) } else { unset($sqlval['creator_id']); unset($sqlval['create_date']); - $ret = $objQuery->update('dtb_mailtemplate', $sqlval, $where, array($template_id)); + $ret = $objQuery->update('dtb_mailtemplate', $sqlval, $where, [$template_id]); } - return ($ret) ? $sqlval['template_id'] : FALSE; + return ($ret) ? $sqlval['template_id'] : false; } } diff --git a/data/class/helper/SC_Helper_Maker.php b/data/class/helper/SC_Helper_Maker.php index f2b7078953..3370ca6df8 100644 --- a/data/class/helper/SC_Helper_Maker.php +++ b/data/class/helper/SC_Helper_Maker.php @@ -24,8 +24,8 @@ /** * メーカーを管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_Maker @@ -33,8 +33,9 @@ class SC_Helper_Maker /** * メーカーの情報を取得. * - * @param integer $maker_id メーカーID - * @param boolean $has_deleted 削除されたメーカーも含む場合 true; 初期値 false + * @param int $maker_id メーカーID + * @param bool $has_deleted 削除されたメーカーも含む場合 true; 初期値 false + * * @return array */ public function getMaker($maker_id, $has_deleted = false) @@ -44,7 +45,7 @@ public function getMaker($maker_id, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select('*', 'dtb_maker', $where, array($maker_id)); + $arrRet = $objQuery->select('*', 'dtb_maker', $where, [$maker_id]); return $arrRet[0]; } @@ -52,8 +53,9 @@ public function getMaker($maker_id, $has_deleted = false) /** * 名前からメーカーの情報を取得. * - * @param integer $name メーカー名 - * @param boolean $has_deleted 削除されたメーカーも含む場合 true; 初期値 false + * @param int $name メーカー名 + * @param bool $has_deleted 削除されたメーカーも含む場合 true; 初期値 false + * * @return array */ public function getByName($name, $has_deleted = false) @@ -63,7 +65,7 @@ public function getByName($name, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select('*', 'dtb_maker', $where, array($name)); + $arrRet = $objQuery->select('*', 'dtb_maker', $where, [$name]); return $arrRet[0]; } @@ -71,7 +73,8 @@ public function getByName($name, $has_deleted = false) /** * メーカー一覧の取得. * - * @param boolean $has_deleted 削除されたメーカーも含む場合 true; 初期値 false + * @param bool $has_deleted 削除されたメーカーも含む場合 true; 初期値 false + * * @return array */ public function getList($has_deleted = false) @@ -93,6 +96,7 @@ public function getList($has_deleted = false) * メーカーの登録. * * @param array $sqlval + * * @return multiple 登録成功:メーカーID, 失敗:FALSE */ public function saveMaker($sqlval) @@ -113,16 +117,17 @@ public function saveMaker($sqlval) unset($sqlval['creator_id']); unset($sqlval['create_date']); $where = 'maker_id = ?'; - $ret = $objQuery->update('dtb_maker', $sqlval, $where, array($maker_id)); + $ret = $objQuery->update('dtb_maker', $sqlval, $where, [$maker_id]); } - return ($ret) ? $sqlval['maker_id'] : FALSE; + return ($ret) ? $sqlval['maker_id'] : false; } /** * メーカーの削除. * - * @param integer $maker_id メーカーID + * @param int $maker_id メーカーID + * * @return void */ public function delete($maker_id) @@ -135,7 +140,8 @@ public function delete($maker_id) /** * メーカーの表示順をひとつ上げる. * - * @param integer $maker_id メーカーID + * @param int $maker_id メーカーID + * * @return void */ public function rankUp($maker_id) @@ -147,7 +153,8 @@ public function rankUp($maker_id) /** * メーカーの表示順をひとつ下げる. * - * @param integer $maker_id メーカーID + * @param int $maker_id メーカーID + * * @return void */ public function rankDown($maker_id) diff --git a/data/class/helper/SC_Helper_Mobile.php b/data/class/helper/SC_Helper_Mobile.php index dbc41f520b..6396cea665 100644 --- a/data/class/helper/SC_Helper_Mobile.php +++ b/data/class/helper/SC_Helper_Mobile.php @@ -24,9 +24,10 @@ /** * モバイルのヘルパークラス. * - * @package Helper * @author EC-CUBE CO.,LTD. + * * @version $Id$ + * * @deprecated */ class SC_Helper_Mobile @@ -37,12 +38,12 @@ class SC_Helper_Mobile /** 拡張MimeType配列 * Application/octet-streamで対応出来ないファイルタイプのみ拡張子をキーに記述する * 拡張子が本配列に存在しない場合は application/force-download を利用する */ - public $arrMimetypes = array( - 'html'=> 'text/html', + public $arrMimetypes = [ + 'html' => 'text/html', 'css' => 'text/css', - 'hdml'=> 'text/x-hdml', + 'hdml' => 'text/x-hdml', 'mmf' => 'application/x-smaf', - 'jpeg'=> 'image/jpeg', + 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'png' => 'image/png', @@ -73,7 +74,7 @@ class SC_Helper_Mobile 'doc' => 'application/msword', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint' - ); + ]; /** * EC-CUBE がサポートする携帯端末かどうかをチェックする。 @@ -84,7 +85,7 @@ class SC_Helper_Mobile public function lfMobileCheckCompatibility() { if (!SC_MobileUserAgent_Ex::isSupported()) { - header('Location: ' . ROOT_URLPATH . 'unsupported/' . DIR_INDEX_PATH); + header('Location: '.ROOT_URLPATH.'unsupported/'.DIR_INDEX_PATH); exit; } } @@ -93,6 +94,7 @@ public function lfMobileCheckCompatibility() * 入力データを内部エンコーディングに変換し、絵文字を除去する。 * * @param string &$value 入力データへの参照 + * * @return void */ public function lfMobileConvertInputValue(&$value) @@ -117,9 +119,9 @@ public function lfMobileConvertInputValue(&$value) */ public function lfMobileInitInput() { - array_walk($_GET, array($this, 'lfMobileConvertInputValue')); - array_walk($_POST, array($this, 'lfMobileConvertInputValue')); - array_walk($_REQUEST, array($this, 'lfMobileConvertInputValue')); + array_walk($_GET, [$this, 'lfMobileConvertInputValue']); + array_walk($_POST, [$this, 'lfMobileConvertInputValue']); + array_walk($_REQUEST, [$this, 'lfMobileConvertInputValue']); } /** @@ -130,7 +132,7 @@ public function lfMobileInitInput() */ public function lfMobileGetExtSessionId() { - if (!preg_match('|^' . ROOT_URLPATH . '(.*)$|', $_SERVER['SCRIPT_NAME'], $matches)) { + if (!preg_match('|^'.ROOT_URLPATH.'(.*)$|', $_SERVER['SCRIPT_NAME'], $matches)) { return null; } @@ -140,8 +142,8 @@ public function lfMobileGetExtSessionId() foreach ($_REQUEST as $key => $value) { $session_id = $objQuery->get('session_id', 'dtb_mobile_ext_session_id', - 'param_key = ? AND param_value = ? AND url = ? AND create_date >= ?', - array($key, $value, $url, $time)); + 'param_key = ? AND param_value = ? AND url = ? AND create_date >= ?', + [$key, $value, $url, $time]); if (isset($session_id)) { return $session_id; } @@ -173,7 +175,7 @@ public function lfMobileGetSessionId() // セッションIDの存在をチェックする。 $objSession = new SC_Helper_Session_Ex(); if ($objSession->sfSessRead($sessionId) === null) { - GC_Utils_Ex::gfPrintLog("Non-existent session id : sid=".substr(sha1($sessionId), 0, 8)); + GC_Utils_Ex::gfPrintLog('Non-existent session id : sid='.substr(sha1($sessionId), 0, 8)); return false; } @@ -186,7 +188,7 @@ public function lfMobileGetSessionId() * * FIXME '@' でエラーを抑制するのは良くない * - * @return boolean セッションデータが有効な場合は true、無効な場合は false を返す。 + * @return bool セッションデータが有効な場合は true、無効な場合は false を返す。 */ public function lfMobileValidateSession() { @@ -196,9 +198,9 @@ public function lfMobileValidateSession() } // 有効期限を過ぎていないかどうかをチェックする。 - if (intval(@$_SESSION['mobile']['expires']) < time()) { - $msg = 'Session expired at ' . date('Y/m/d H:i:s', @$_SESSION['mobile']['expires']) - . ' : sid=' . substr(sha1(session_id()), 0, 8); + if ((int) (@$_SESSION['mobile']['expires']) < time()) { + $msg = 'Session expired at '.date('Y/m/d H:i:s', @$_SESSION['mobile']['expires']) + .' : sid='.substr(sha1(session_id()), 0, 8); GC_Utils_Ex::gfPrintLog($msg); return false; @@ -208,8 +210,8 @@ public function lfMobileValidateSession() $model = SC_MobileUserAgent_Ex::getModel(); if (@$_SESSION['mobile']['model'] != $model) { $msg = 'User agent model mismatch : ' - . '"$model" != "' . @$_SESSION['mobile']['model'] - . '" (expected), sid=' . substr(sha1(session_id()), 0, 8); + .'"$model" != "'.@$_SESSION['mobile']['model'] + .'" (expected), sid='.substr(sha1(session_id()), 0, 8); GC_Utils_Ex::gfPrintLog($msg); return false; @@ -236,13 +238,13 @@ public function lfMobileInitOutput() mb_http_output('SJIS-win'); // 端末に合わせて画像サイズを変換する。 - ob_start(array('SC_MobileImage_Ex', 'handler')); + ob_start(['SC_MobileImage_Ex', 'handler']); // 内部エンコーディングから Shift JIS に変換する。 ob_start('mb_output_handler'); - //download.phpに対してカタカナ変換をするとファイルが壊れてしまうため回避する - if ($_SERVER['SCRIPT_FILENAME'] != HTML_REALDIR . 'mypage/download.php') { + // download.phpに対してカタカナ変換をするとファイルが壊れてしまうため回避する + if ($_SERVER['SCRIPT_FILENAME'] != HTML_REALDIR.'mypage/download.php') { // 全角カタカナを半角カタカナに変換する。 ob_start(create_function('$buffer', 'return mb_convert_kana($buffer, "k");')); } @@ -267,7 +269,7 @@ public function sfMobileInit() /** * Location等でセッションIDを付加する必要があるURLにセッションIDを付加する。 * - * @return String + * @return string */ public function gfAddSessionId($url = null) { @@ -283,9 +285,9 @@ public function gfAddSessionId($url = null) * @param array $array 元となる配列 * @param array セッション ID を追加した配列 */ - public function sessionIdArray($array = array()) + public function sessionIdArray($array = []) { - return array_merge($array, array(session_name() => session_id())); + return array_merge($array, [session_name() => session_id()]); } /** @@ -303,6 +305,7 @@ public function lfGenerateKaraMailToken() * * @param string $next_url 空メール受け付け後に遷移させるページ (モバイルサイトトップからの相対URL) * @param string $session_id セッションID (省略した場合は現在のセッションID) + * * @return string|false トークンを返す。エラーが発生した場合はfalseを返す。 */ public function gfPrepareKaraMail($next_url, $session_id = null) @@ -315,14 +318,14 @@ public function gfPrepareKaraMail($next_url, $session_id = null) // GC $time = date('Y-m-d H:i:s', time() - MOBILE_SESSION_LIFETIME); - $objQuery->delete('dtb_mobile_kara_mail', 'email IS NULL AND create_date < ?', array($time)); + $objQuery->delete('dtb_mobile_kara_mail', 'email IS NULL AND create_date < ?', [$time]); - $objQuery->delete('dtb_mobile_kara_mail', 'session_id = ?', array($session_id)); + $objQuery->delete('dtb_mobile_kara_mail', 'session_id = ?', [$session_id]); - $arrValues = array( + $arrValues = [ 'session_id' => $session_id, - 'next_url' => $next_url, - ); + 'next_url' => $next_url, + ]; $try = 10; @@ -331,13 +334,13 @@ public function gfPrepareKaraMail($next_url, $session_id = null) $arrValues['kara_mail_id'] = $objQuery->nextVal('dtb_mobile_kara_mail_kara_mail_id'); $objQuery->insert('dtb_mobile_kara_mail', $arrValues); - $exists = $objQuery->exists('dtb_mobile_kara_mail', 'token = ?', array($token)); + $exists = $objQuery->exists('dtb_mobile_kara_mail', 'token = ?', [$token]); if ($exists) { break; } - $objQuery->delete('dtb_mobile_kara_mail', 'session_id = ?', array($session_id)); + $objQuery->delete('dtb_mobile_kara_mail', 'session_id = ?', [$session_id]); $token = false; --$try; } @@ -350,7 +353,8 @@ public function gfPrepareKaraMail($next_url, $session_id = null) * * @param string $token トークン * @param string $email メールアドレス - * @return boolean 成功した場合はtrue、失敗した場合はfalseを返す。 + * + * @return bool 成功した場合はtrue、失敗した場合はfalseを返す。 */ public function gfRegisterKaraMail($token, $email) { @@ -359,28 +363,29 @@ public function gfRegisterKaraMail($token, $email) // GC $time = date('Y-m-d H:i:s', time() - MOBILE_SESSION_LIFETIME); $objQuery->delete('dtb_mobile_kara_mail', - '(email IS NULL AND create_date < ?) OR (email IS NOT NULL AND receive_date < ?)', - array($time, $time)); + '(email IS NULL AND create_date < ?) OR (email IS NOT NULL AND receive_date < ?)', + [$time, $time]); - $kara_mail_id = $objQuery->get('kara_mail_id', 'dtb_mobile_kara_mail', 'token = ?', array($token)); + $kara_mail_id = $objQuery->get('kara_mail_id', 'dtb_mobile_kara_mail', 'token = ?', [$token]); if (!isset($kara_mail_id)) { return false; } - $arrValues = array('email' => $email); - $arrRawValues = array('receive_date' => 'CURRENT_TIMESTAMP'); - $objQuery->update('dtb_mobile_kara_mail', $arrValues, 'kara_mail_id = ?', array($kara_mail_id), $arrRawValues); + $arrValues = ['email' => $email]; + $arrRawValues = ['receive_date' => 'CURRENT_TIMESTAMP']; + $objQuery->update('dtb_mobile_kara_mail', $arrValues, 'kara_mail_id = ?', [$kara_mail_id], $arrRawValues); return true; } /** * 空メール管理テーブルからトークンが一致する行を削除し、 - * 次に遷移させるページのURLを返す。  + * 次に遷移させるページのURLを返す。 * * メールアドレスは $_SESSION['mobile']['kara_mail_from'] に登録される。 * * @param string $token トークン + * * @return string|false URLを返す。エラーが発生した場合はfalseを返す。 */ public function gfFinishKaraMail($token) @@ -391,7 +396,7 @@ public function gfFinishKaraMail($token) 'session_id, next_url, email', 'dtb_mobile_kara_mail', 'token = ? AND email IS NOT NULL AND receive_date >= ?', - array($token, date('Y-m-d H:i:s', time() - MOBILE_SESSION_LIFETIME)), + [$token, date('Y-m-d H:i:s', time() - MOBILE_SESSION_LIFETIME)], DB_FETCHMODE_ORDERED ); @@ -399,10 +404,10 @@ public function gfFinishKaraMail($token) return false; } - $objQuery->delete('dtb_mobile_kara_mail', 'token = ?', array($token)); + $objQuery->delete('dtb_mobile_kara_mail', 'token = ?', [$token]); list($session_id, $next_url, $email) = $arrRow; - $objURL = new Net_URL(HTTP_URL . $next_url); + $objURL = new Net_URL(HTTP_URL.$next_url); $objURL->addQueryString(session_name(), $session_id); $url = $objURL->getURL(); @@ -420,6 +425,7 @@ public function gfFinishKaraMail($token) * @param string $param_key パラメーター名 * @param string $param_value パラメーター値 * @param string $url URL + * * @return void */ public function sfMobileSetExtSessionId($param_key, $param_value, $url) @@ -428,14 +434,14 @@ public function sfMobileSetExtSessionId($param_key, $param_value, $url) // GC $time = date('Y-m-d H:i:s', time() - MOBILE_SESSION_LIFETIME); - $objQuery->delete('dtb_mobile_ext_session_id', 'create_date < ?', array($time)); + $objQuery->delete('dtb_mobile_ext_session_id', 'create_date < ?', [$time]); - $arrValues = array( - 'session_id' => session_id(), - 'param_key' => $param_key, + $arrValues = [ + 'session_id' => session_id(), + 'param_key' => $param_key, 'param_value' => $param_value, - 'url' => $url, - ); + 'url' => $url, + ]; $objQuery->insert('dtb_mobile_ext_session_id', $arrValues); } @@ -444,7 +450,8 @@ public function sfMobileSetExtSessionId($param_key, $param_value, $url) * メールアドレスが携帯のものかどうかを判別する。 * * @param string $address メールアドレス - * @return boolean 携帯のメールアドレスの場合はtrue、それ以外の場合はfalseを返す。 + * + * @return bool 携帯のメールアドレスの場合はtrue、それ以外の場合はfalseを返す。 */ public function gfIsMobileMailAddress($address) { @@ -465,11 +472,12 @@ public function gfIsMobileMailAddress($address) * ファイルのMIMEタイプを判別する * * @param string $filename ファイル名 + * * @return string MIMEタイプ */ public function getMimeType($filename) { - //ファイルの拡張子からコンテンツタイプを決定する + // ファイルの拡張子からコンテンツタイプを決定する $file_extension = strtolower(substr(strrchr($filename, '.'), 1)); $mime_type = $this->defaultMimeType; if (array_key_exists($file_extension, $this->arrMimetypes)) { diff --git a/data/class/helper/SC_Helper_News.php b/data/class/helper/SC_Helper_News.php index 5ff42f593d..d8bfc76750 100644 --- a/data/class/helper/SC_Helper_News.php +++ b/data/class/helper/SC_Helper_News.php @@ -24,8 +24,8 @@ /** * ニュースを管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_News @@ -33,8 +33,9 @@ class SC_Helper_News /** * ニュースの情報を取得. * - * @param integer $news_id ニュースID - * @param boolean $has_deleted 削除されたニュースも含む場合 true; 初期値 false + * @param int $news_id ニュースID + * @param bool $has_deleted 削除されたニュースも含む場合 true; 初期値 false + * * @return array */ public static function getNews($news_id, $has_deleted = false) @@ -45,7 +46,7 @@ public static function getNews($news_id, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select($col, 'dtb_news', $where, array($news_id)); + $arrRet = $objQuery->select($col, 'dtb_news', $where, [$news_id]); return $arrRet[0]; } @@ -53,9 +54,10 @@ public static function getNews($news_id, $has_deleted = false) /** * ニュース一覧の取得. * - * @param integer $dispNumber 表示件数 - * @param integer $pageNumber ページ番号 - * @param boolean $has_deleted 削除されたニュースも含む場合 true; 初期値 false + * @param int $dispNumber 表示件数 + * @param int $pageNumber ページ番号 + * @param bool $has_deleted 削除されたニュースも含む場合 true; 初期値 false + * * @return array */ public function getList($dispNumber = 0, $pageNumber = 0, $has_deleted = false) @@ -70,7 +72,7 @@ public function getList($dispNumber = 0, $pageNumber = 0, $has_deleted = false) $objQuery->setOrder('rank DESC'); if ($dispNumber > 0) { if ($pageNumber > 0) { - $objQuery->setLimitOffset($dispNumber, (($pageNumber - 1) * $dispNumber)); + $objQuery->setLimitOffset($dispNumber, ($pageNumber - 1) * $dispNumber); } else { $objQuery->setLimit($dispNumber); } @@ -84,6 +86,7 @@ public function getList($dispNumber = 0, $pageNumber = 0, $has_deleted = false) * ニュースの登録. * * @param array $sqlval + * * @return multiple 登録成功:ニュースID, 失敗:FALSE */ public function saveNews($sqlval) @@ -104,16 +107,17 @@ public function saveNews($sqlval) unset($sqlval['creator_id']); unset($sqlval['create_date']); $where = 'news_id = ?'; - $ret = $objQuery->update('dtb_news', $sqlval, $where, array($news_id)); + $ret = $objQuery->update('dtb_news', $sqlval, $where, [$news_id]); } - return ($ret) ? $sqlval['news_id'] : FALSE; + return ($ret) ? $sqlval['news_id'] : false; } /** * ニュースの削除. * - * @param integer $news_id ニュースID + * @param int $news_id ニュースID + * * @return void */ public function deleteNews($news_id) @@ -126,7 +130,8 @@ public function deleteNews($news_id) /** * ニュースの表示順をひとつ上げる. * - * @param integer $news_id ニュースID + * @param int $news_id ニュースID + * * @return void */ public function rankUp($news_id) @@ -138,7 +143,8 @@ public function rankUp($news_id) /** * ニュースの表示順をひとつ下げる. * - * @param integer $news_id ニュースID + * @param int $news_id ニュースID + * * @return void */ public function rankDown($news_id) @@ -150,8 +156,9 @@ public function rankDown($news_id) /** * ニュースの表示順を指定する. * - * @param integer $news_id ニュースID - * @param integer $rank 移動先の表示順 + * @param int $news_id ニュースID + * @param int $rank 移動先の表示順 + * * @return void */ public function moveRank($news_id, $rank) @@ -163,8 +170,9 @@ public function moveRank($news_id, $rank) /** * ニュース記事数を計算. * - * @param boolean $has_deleted 削除されたニュースも含む場合 true; 初期値 false - * @return integer ニュース記事数 + * @param bool $has_deleted 削除されたニュースも含む場合 true; 初期値 false + * + * @return int ニュース記事数 */ public function getCount($has_deleted = false) { diff --git a/data/class/helper/SC_Helper_PageLayout.php b/data/class/helper/SC_Helper_PageLayout.php index 1296ddf61d..45bc56d964 100644 --- a/data/class/helper/SC_Helper_PageLayout.php +++ b/data/class/helper/SC_Helper_PageLayout.php @@ -24,8 +24,8 @@ /** * Webページのレイアウト情報を制御するヘルパークラス. * - * @package Helper * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_Helper_PageLayout @@ -36,19 +36,19 @@ class SC_Helper_PageLayout * 現在の URL に応じたページのレイアウト情報を取得し, LC_Page インスタンスに * 設定する. * - * @access public * @param LC_Page $objPage LC_Page インスタンス - * @param boolean $preview プレビュー表示の場合 true + * @param bool $preview プレビュー表示の場合 true * @param string $url ページのURL($_SERVER['SCRIPT_NAME'] の情報) - * @param integer $device_type_id 端末種別ID + * @param int $device_type_id 端末種別ID + * * @return void */ public function sfGetPageLayout(&$objPage, $preview = false, $url = '', $device_type_id = DEVICE_TYPE_PC) { // URLを元にページ情報を取得 if ($preview === false) { - $url = preg_replace('|^' . preg_quote(ROOT_URLPATH) . '|', '', $url); - $arrPageData = $this->getPageProperties($device_type_id, null, 'url = ?', array($url)); + $url = preg_replace('|^'.preg_quote(ROOT_URLPATH).'|', '', $url); + $arrPageData = $this->getPageProperties($device_type_id, null, 'url = ?', [$url]); // プレビューの場合は, プレビュー用のデータを取得 } else { $arrPageData = $this->getPageProperties($device_type_id, 0); @@ -58,14 +58,14 @@ public function sfGetPageLayout(&$objPage, $preview = false, $url = '', $device_ trigger_error('ページ情報を取得できませんでした。', E_USER_WARNING); } - $objPage->tpl_mainpage = static::getTemplatePath($device_type_id) . $arrPageData[0]['filename'] . '.tpl'; + $objPage->tpl_mainpage = static::getTemplatePath($device_type_id).$arrPageData[0]['filename'].'.tpl'; if (!file_exists($objPage->tpl_mainpage)) { - $msg = 'メイン部のテンプレートが存在しません。[' . $objPage->tpl_mainpage . ']'; + $msg = 'メイン部のテンプレートが存在しません。['.$objPage->tpl_mainpage.']'; trigger_error($msg, E_USER_WARNING); } - $objPage->arrPageLayout =& $arrPageData[0]; + $objPage->arrPageLayout = &$arrPageData[0]; if (strlen($objPage->arrPageLayout['author']) === 0) { $arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); $objPage->arrPageLayout['author'] = $arrInfo['company_name']; @@ -94,8 +94,8 @@ public function sfGetPageLayout(&$objPage, $preview = false, $url = '', $device_ $objPage->arrPageLayout[$arrTarget[$target_id]][] = $arrBloc; } else { $error = "ブロックが見つかりません\n" - . 'tpl_path: ' . $arrBloc['tpl_path'] . "\n" - . 'php_path: ' . $arrBloc['php_path']; + .'tpl_path: '.$arrBloc['tpl_path']."\n" + .'php_path: '.$arrBloc['php_path']; trigger_error($error, E_USER_WARNING); } } @@ -111,25 +111,25 @@ public function sfGetPageLayout(&$objPage, $preview = false, $url = '', $device_ * $device_type_id は必須. デフォルト値は DEVICE_TYPE_PC. * $page_id が null の場合は, $page_id が 0 以外のものを検索する. * - * @access public - * @param integer $device_type_id 端末種別ID - * @param integer $page_id ページID; null の場合は, 0 以外を検索する. + * @param int $device_type_id 端末種別ID + * @param int $page_id ページID; null の場合は, 0 以外を検索する. * @param string $where 追加の検索条件 * @param string[] $arrParams 追加の検索パラメーター + * * @return array ページ属性の配列 */ - public function getPageProperties($device_type_id = DEVICE_TYPE_PC, $page_id = null, $where = '', $arrParams = array()) + public function getPageProperties($device_type_id = DEVICE_TYPE_PC, $page_id = null, $where = '', $arrParams = []) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $where = 'device_type_id = ? ' . (SC_Utils_Ex::isBlank($where) ? $where : 'AND ' . $where); + $where = 'device_type_id = ? '.(SC_Utils_Ex::isBlank($where) ? $where : 'AND '.$where); if ($page_id === null) { - $where = 'page_id <> ? AND ' . $where; + $where = 'page_id <> ? AND '.$where; $page_id = 0; } else { - $where = 'page_id = ? AND ' . $where; + $where = 'page_id = ? AND '.$where; } $objQuery->setOrder('page_id'); - $arrParams = array_merge(array($page_id, $device_type_id), $arrParams); + $arrParams = array_merge([$page_id, $device_type_id], $arrParams); return $objQuery->select('*', 'dtb_pagelayout', $where, $arrParams); } @@ -137,14 +137,14 @@ public function getPageProperties($device_type_id = DEVICE_TYPE_PC, $page_id = n /** * ブロック情報を取得する. * - * @access public - * @param integer $device_type_id 端末種別ID + * @param int $device_type_id 端末種別ID * @param string $where 追加の検索条件 * @param array $arrParams 追加の検索パラメーター - * @param boolean $has_realpath php_path, tpl_path の絶対パスを含める場合 true + * @param bool $has_realpath php_path, tpl_path の絶対パスを含める場合 true + * * @return array ブロック情報の配列 */ - public function getBlocs($device_type_id = DEVICE_TYPE_PC, $where = '', $arrParams = array(), $has_realpath = true) + public function getBlocs($device_type_id = DEVICE_TYPE_PC, $where = '', $arrParams = [], $has_realpath = true) { $objBloc = new SC_Helper_Bloc_Ex($device_type_id); $arrBlocs = $objBloc->getWhere($where, $arrParams); @@ -158,10 +158,10 @@ public function getBlocs($device_type_id = DEVICE_TYPE_PC, $where = '', $arrPara /** * ブロック配置情報を取得する. * - * @access public - * @param integer $device_type_id 端末種別ID - * @param integer $page_id ページID - * @param boolean $has_realpath php_path, tpl_path の絶対パスを含める場合 true + * @param int $device_type_id 端末種別ID + * @param int $page_id ページID + * @param bool $has_realpath php_path, tpl_path の絶対パスを含める場合 true + * * @return array 配置情報を含めたブロックの配列 */ public function getBlocPositions($device_type_id, $page_id, $has_realpath = true) @@ -176,13 +176,13 @@ public function getBlocPositions($device_type_id, $page_id, $has_realpath = true __EOF__; $where = 'bloc.device_type_id = ? AND ((anywhere = 1 AND pos.page_id != 0) OR pos.page_id = ?)'; $objQuery->setOrder('target_id, bloc_row'); - $arrBlocs = $objQuery->select('*', $table, $where, array($device_type_id, $page_id)); + $arrBlocs = $objQuery->select('*', $table, $where, [$device_type_id, $page_id]); if ($has_realpath) { $this->setBlocPathTo($device_type_id, $arrBlocs); } - //全ページ設定と各ページのブロックの重複を削除 - $arrUniqBlocIds = array(); + // 全ページ設定と各ページのブロックの重複を削除 + $arrUniqBlocIds = []; foreach ($arrBlocs as $index => $arrBloc) { if ($arrBloc['anywhere'] == 1) { $arrUniqBlocIds[] = $arrBloc['bloc_id']; @@ -202,10 +202,10 @@ public function getBlocPositions($device_type_id, $page_id, $has_realpath = true * * XXX ファイルを確実に削除したかどうかのチェック * - * @access public - * @param integer $page_id ページID - * @param integer $device_type_id 端末種別ID - * @return integer 削除数 + * @param int $page_id ページID + * @param int $device_type_id 端末種別ID + * + * @return int 削除数 */ public function lfDelPageData($page_id, $device_type_id = DEVICE_TYPE_PC) { @@ -214,7 +214,7 @@ public function lfDelPageData($page_id, $device_type_id = DEVICE_TYPE_PC) $ret = null; if ($page_id != '') { $arrPageData = $this->getPageProperties($device_type_id, $page_id); - $ret = $objQuery->delete('dtb_pagelayout', 'page_id = ? AND device_type_id = ?', array($page_id, $device_type_id)); + $ret = $objQuery->delete('dtb_pagelayout', 'page_id = ? AND device_type_id = ?', [$page_id, $device_type_id]); // ファイルの削除 $this->lfDelFile($arrPageData[0]['filename'], $device_type_id); } @@ -227,9 +227,9 @@ public function lfDelPageData($page_id, $device_type_id = DEVICE_TYPE_PC) * * dtb_pagelayout の削除後に呼び出すこと。 * - * @access private * @param string $filename - * @param integer $device_type_id 端末種別ID + * @param int $device_type_id 端末種別ID + * * @return void // TODO boolean にするべき? */ public function lfDelFile($filename, $device_type_id) @@ -240,18 +240,18 @@ public function lfDelFile($filename, $device_type_id) * 同名ファイルの使用件数 * PHP ファイルは, 複数のデバイスで共有するため, device_type_id を条件に入れない */ - $exists = $objQuery->exists('dtb_pagelayout', 'filename = ?', array($filename)); + $exists = $objQuery->exists('dtb_pagelayout', 'filename = ?', [$filename]); if (!$exists) { // phpファイルの削除 - $del_php = HTML_REALDIR . $filename . '.php'; + $del_php = HTML_REALDIR.$filename.'.php'; if (file_exists($del_php)) { unlink($del_php); } } // tplファイルの削除 - $del_tpl = static::getTemplatePath($device_type_id) . $filename . '.tpl'; + $del_tpl = static::getTemplatePath($device_type_id).$filename.'.tpl'; if (file_exists($del_tpl)) { unlink($del_tpl); } @@ -260,10 +260,10 @@ public function lfDelFile($filename, $device_type_id) /** * 編集可能ページかどうか. * - * @access public - * @param integer $device_type_id 端末種別ID - * @param integer $page_id ページID - * @return boolean �合 true + * @param int $device_type_id 端末種別ID + * @param int $page_id ページID + * + * @return bool �合 true */ public function isEditablePage($device_type_id, $page_id) { @@ -281,9 +281,9 @@ public function isEditablePage($device_type_id, $page_id) /** * テンプレートのパスを取得する. * - * @access public - * @param integer $device_type_id 端末種別ID - * @param boolean $isUser USER_REALDIR 以下のパスを返す場合 true + * @param int $device_type_id 端末種別ID + * @param bool $isUser USER_REALDIR 以下のパスを返す場合 true + * * @return string テンプレートのパス */ public static function getTemplatePath($device_type_id = DEVICE_TYPE_PC, $isUser = false) @@ -308,7 +308,7 @@ public static function getTemplatePath($device_type_id = DEVICE_TYPE_PC, $isUser } $userPath = USER_REALDIR; if ($isUser) { - $dir = $userPath . USER_PACKAGE_DIR . $templateName . '/'; + $dir = $userPath.USER_PACKAGE_DIR.$templateName.'/'; } return $dir; @@ -320,29 +320,29 @@ public static function getTemplatePath($device_type_id = DEVICE_TYPE_PC, $isUser * 引数 $hasPackage を true にした場合は, user_data/packages/template_name * を取得する. * - * @access public - * @param integer $device_type_id 端末種別ID - * @param boolean $hasPackage パッケージのパスも含める場合 true + * @param int $device_type_id 端末種別ID + * @param bool $hasPackage パッケージのパスも含める場合 true + * * @return string 端末に応じた DocumentRoot から user_data までのパス */ public static function getUserDir($device_type_id = DEVICE_TYPE_PC, $hasPackage = false) { switch ($device_type_id) { - case DEVICE_TYPE_MOBILE: - $templateName = MOBILE_TEMPLATE_NAME; - break; + case DEVICE_TYPE_MOBILE: + $templateName = MOBILE_TEMPLATE_NAME; + break; - case DEVICE_TYPE_SMARTPHONE: - $templateName = SMARTPHONE_TEMPLATE_NAME; - break; + case DEVICE_TYPE_SMARTPHONE: + $templateName = SMARTPHONE_TEMPLATE_NAME; + break; - case DEVICE_TYPE_PC: - default: - $templateName = TEMPLATE_NAME; + case DEVICE_TYPE_PC: + default: + $templateName = TEMPLATE_NAME; } - $userDir = ROOT_URLPATH . USER_DIR; + $userDir = ROOT_URLPATH.USER_DIR; if ($hasPackage) { - return $userDir . USER_PACKAGE_DIR . $templateName . '/'; + return $userDir.USER_PACKAGE_DIR.$templateName.'/'; } return $userDir; @@ -351,36 +351,41 @@ public static function getUserDir($device_type_id = DEVICE_TYPE_PC, $hasPackage /** * ブロックの php_path, tpl_path を設定する. * - * @access private - * @param integer $device_type_id 端末種別ID + * @param int $device_type_id 端末種別ID * @param array $arrBlocs 設定するブロックの配列 + * * @return void */ - public function setBlocPathTo($device_type_id = DEVICE_TYPE_PC, &$arrBlocs = array()) + public function setBlocPathTo($device_type_id = DEVICE_TYPE_PC, &$arrBlocs = []) { foreach ($arrBlocs as $key => $value) { - $arrBloc =& $arrBlocs[$key]; - $arrBloc['php_path'] = SC_Utils_Ex::isBlank($arrBloc['php_path']) ? '' : HTML_REALDIR . $arrBloc['php_path']; - $bloc_dir = $this->getTemplatePath($device_type_id) . BLOC_DIR; - $arrBloc['tpl_path'] = SC_Utils_Ex::isBlank($arrBloc['tpl_path']) ? '' : $bloc_dir . $arrBloc['tpl_path']; + $arrBloc = &$arrBlocs[$key]; + $arrBloc['php_path'] = SC_Utils_Ex::isBlank($arrBloc['php_path']) ? '' : HTML_REALDIR.$arrBloc['php_path']; + $bloc_dir = $this->getTemplatePath($device_type_id).BLOC_DIR; + $arrBloc['tpl_path'] = SC_Utils_Ex::isBlank($arrBloc['tpl_path']) ? '' : $bloc_dir.$arrBloc['tpl_path']; } } /** * カラム数を取得する. * - * @access private * @param array $arrPageLayout レイアウト情報の配列 - * @return integer $col_num カラム数 + * + * @return int $col_num カラム数 */ public function getColumnNum($arrPageLayout) { // メインは確定 $col_num = 1; // LEFT NAVI - if (!empty($arrPageLayout['LeftNavi'])) $col_num++; + if (!empty($arrPageLayout['LeftNavi'])) { + $col_num++; + } // RIGHT NAVI - if (!empty($arrPageLayout['RightNavi'])) $col_num++; + if (!empty($arrPageLayout['RightNavi'])) { + $col_num++; + } + return $col_num; } } diff --git a/data/class/helper/SC_Helper_Payment.php b/data/class/helper/SC_Helper_Payment.php index 6f2e638e6c..ccaca7670a 100644 --- a/data/class/helper/SC_Helper_Payment.php +++ b/data/class/helper/SC_Helper_Payment.php @@ -24,8 +24,8 @@ /** * 支払方法を管理するヘルパークラス. * - * @package Helper * @author pineray + * * @version $Id$ */ class SC_Helper_Payment @@ -33,8 +33,9 @@ class SC_Helper_Payment /** * 支払方法の情報を取得. * - * @param integer $payment_id 支払方法ID - * @param boolean $has_deleted 削除された支払方法も含む場合 true; 初期値 false + * @param int $payment_id 支払方法ID + * @param bool $has_deleted 削除された支払方法も含む場合 true; 初期値 false + * * @return array */ public function get($payment_id, $has_deleted = false) @@ -44,7 +45,7 @@ public function get($payment_id, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select('*', 'dtb_payment', $where, array($payment_id)); + $arrRet = $objQuery->select('*', 'dtb_payment', $where, [$payment_id]); return $arrRet[0]; } @@ -52,7 +53,8 @@ public function get($payment_id, $has_deleted = false) /** * 支払方法一覧の取得. * - * @param boolean $has_deleted 削除された支払方法も含む場合 true; 初期値 false + * @param bool $has_deleted 削除された支払方法も含む場合 true; 初期値 false + * * @return array */ public function getList($has_deleted = false) @@ -73,14 +75,15 @@ public function getList($has_deleted = false) /** * 購入金額に応じた支払方法を取得する. * - * @param integer $total 購入金額 + * @param int $total 購入金額 + * * @return array 購入金額に応じた支払方法の配列 */ public function getByPrice($total) { // 削除されていない支払方法を取得 $payments = $this->getList(); - $arrPayment = array(); + $arrPayment = []; foreach ($payments as $data) { // 下限と上限が設定されている if (strlen($data['rule_max']) != 0 && strlen($data['upper_rule']) != 0) { @@ -110,6 +113,7 @@ public function getByPrice($total) * 支払方法の登録. * * @param array $sqlval + * * @return void */ public function save($sqlval) @@ -130,14 +134,15 @@ public function save($sqlval) unset($sqlval['creator_id']); unset($sqlval['create_date']); $where = 'payment_id = ?'; - $objQuery->update('dtb_payment', $sqlval, $where, array($payment_id)); + $objQuery->update('dtb_payment', $sqlval, $where, [$payment_id]); } } /** * 支払方法の削除. * - * @param integer $payment_id 支払方法ID + * @param int $payment_id 支払方法ID + * * @return void */ public function delete($payment_id) @@ -150,7 +155,8 @@ public function delete($payment_id) /** * 支払方法の表示順をひとつ上げる. * - * @param integer $payment_id 支払方法ID + * @param int $payment_id 支払方法ID + * * @return void */ public function rankUp($payment_id) @@ -162,7 +168,8 @@ public function rankUp($payment_id) /** * 支払方法の表示順をひとつ下げる. * - * @param integer $payment_id 支払方法ID + * @param int $payment_id 支払方法ID + * * @return void */ public function rankDown($payment_id) @@ -176,13 +183,14 @@ public function rankDown($payment_id) * * dtb_payment.memo03 に値が入っている場合は決済モジュールと見なす. * - * @param integer $payment_id 支払い方法ID - * @return boolean 決済モジュールを使用する支払い方法の場合 true + * @param int $payment_id 支払い方法ID + * + * @return bool 決済モジュールを使用する支払い方法の場合 true */ public static function useModule($payment_id) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $memo03 = $objQuery->get('memo03', 'dtb_payment', 'payment_id = ?', array($payment_id)); + $memo03 = $objQuery->get('memo03', 'dtb_payment', 'payment_id = ?', [$payment_id]); return !SC_Utils_Ex::isBlank($memo03); } @@ -191,6 +199,7 @@ public static function useModule($payment_id) * 支払方法IDをキー, 名前を値とする配列を取得. * * @param string $type 値のタイプ + * * @return array */ public static function getIDValueList($type = 'payment_method') diff --git a/data/class/helper/SC_Helper_Plugin.php b/data/class/helper/SC_Helper_Plugin.php index 6ff3e27d7d..f340ed5664 100644 --- a/data/class/helper/SC_Helper_Plugin.php +++ b/data/class/helper/SC_Helper_Plugin.php @@ -24,32 +24,38 @@ /** * プラグインのヘルパークラス. * - * @package Helper * @version $Id$ */ class SC_Helper_Plugin { // プラグインのインスタンスの配列. - public $arrPluginInstances = array(); + public $arrPluginInstances = []; // プラグインのアクションの配列. - public $arrRegistedPluginActions = array(); + public $arrRegistedPluginActions = []; // プラグインのIDの配列. - public $arrPluginIds = array(); + public $arrPluginIds = []; // HeadNaviブロックの配列 - public $arrHeadNaviBlocsByPlugin = array(); + public $arrHeadNaviBlocsByPlugin = []; /** * 有効なプラグインのロード. プラグインエンジンが有効になっていない場合は * プラグインエンジン自身のインストール処理を起動する * * @param bool $plugin_activate_flg プラグインを有効化する場合 true + * * @return void */ public function load($plugin_activate_flg = true, $plugin_upload_realdir = PLUGIN_UPLOAD_REALDIR) { - if (!defined('CONFIG_REALFILE') || !file_exists(CONFIG_REALFILE)) return; // インストール前 - if (GC_Utils_Ex::isInstallFunction()) return; // インストール中 - if ($plugin_activate_flg === false) return; + if (!defined('CONFIG_REALFILE') || !file_exists(CONFIG_REALFILE)) { + return; + } // インストール前 + if (GC_Utils_Ex::isInstallFunction()) { + return; + } // インストール中 + if ($plugin_activate_flg === false) { + return; + } // 有効なプラグインを取得 $arrPluginDataList = SC_Plugin_Util_Ex::getEnablePlugin(); // pluginディレクトリを取得 @@ -57,15 +63,15 @@ public function load($plugin_activate_flg = true, $plugin_upload_realdir = PLUGI foreach ($arrPluginDataList as $arrPluginData) { // プラグイン本体ファイル名が取得したプラグインディレクトリ一覧にある事を確認 if (array_search($arrPluginData['plugin_code'], $arrPluginDirectory) !== false) { - $plugin_file_path = $plugin_upload_realdir . $arrPluginData['plugin_code'] . '/' . $arrPluginData['class_name'] . '.php'; + $plugin_file_path = $plugin_upload_realdir.$arrPluginData['plugin_code'].'/'.$arrPluginData['class_name'].'.php'; // プラグイン本体ファイルが存在しない場合 if (!file_exists($plugin_file_path)) { // エラー出力 $msg = 'プラグイン本体ファイルが存在しない。当該プラグインを無視して続行する。'; - $msg .= 'ファイル=' . var_export($plugin_file_path, true) . '; '; + $msg .= 'ファイル='.var_export($plugin_file_path, true).'; '; trigger_error($msg, E_USER_WARNING); // 次のプラグインへ続行 - continue 1; + continue; } // プラグイン本体ファイルをrequire. require_once $plugin_file_path; @@ -88,6 +94,7 @@ public function load($plugin_activate_flg = true, $plugin_upload_realdir = PLUGI * SC_Helper_Plugin オブジェクトを返す(Singletonパターン) * * @param bool $plugin_activate_flg プラグインを有効化する場合 true + * * @return SC_Helper_Plugin SC_Helper_Pluginオブジェクト */ public static function getSingletonInstance($plugin_activate_flg = PLUGIN_ACTIVATE_FLAG, $plugin_upload_realdir = PLUGIN_UPLOAD_REALDIR) @@ -95,7 +102,7 @@ public static function getSingletonInstance($plugin_activate_flg = PLUGIN_ACTIVA if (!isset($GLOBALS['_SC_Helper_Plugin_instance'])) { // プラグインのローダーがDB接続を必要とするため、 // SC_Queryインスタンス生成後のみオブジェクトを生成する。 - require_once CLASS_EX_REALDIR . 'SC_Query_Ex.php'; + require_once CLASS_EX_REALDIR.'SC_Query_Ex.php'; if (is_null(SC_Query_Ex::getPoolInstance())) { return false; } @@ -112,16 +119,17 @@ public static function getSingletonInstance($plugin_activate_flg = PLUGIN_ACTIVA * * @param string $hook_point フックポイント * @param array $arrArgs コールバック関数へ渡す引数 + * * @return void */ - public function doAction($hook_point, $arrArgs = array()) + public function doAction($hook_point, $arrArgs = []) { if (is_array($arrArgs) === false) { - array(&$arrArgs); + [&$arrArgs]; } - $arrSaveArgs = array(); - $arrClassName = array(); - $arrClassPath = array(); + $arrSaveArgs = []; + $arrClassName = []; + $arrClassPath = []; if ($hook_point == 'loadClassFileChange') { $arrSaveArgs = $arrArgs; } @@ -135,7 +143,7 @@ public function doAction($hook_point, $arrArgs = array()) if ($hook_point == 'loadClassFileChange') { $classname = $arrSaveArgs[0]; $classpath = $arrSaveArgs[1]; - $arrTempArgs = array(&$classname, &$classpath); + $arrTempArgs = [&$classname, &$classpath]; call_user_func_array($func['function'], $arrTempArgs); @@ -162,7 +170,7 @@ public function doAction($hook_point, $arrArgs = array()) /** * スーパーフックポイントを登録します. * - * @param Object $objPlugin プラグインのインスタンス + * @param object $objPlugin プラグインのインスタンス * @param string $hook_point スーパーフックポイント * @param string $function_name 実行する関数名 * @param string $priority 実行順 @@ -172,14 +180,14 @@ public function registerSuperHookPoint($objPlugin, $hook_point, $function_name, // スーパープラグイン関数を定義しているかを検証. if (method_exists($objPlugin, $function_name) === true) { // アクションの登録 - $this->addAction($hook_point, array($objPlugin, $function_name), $priority); + $this->addAction($hook_point, [$objPlugin, $function_name], $priority); } } /** * ローカルフックポイントを登録します. * - * @param Object $objPlugin プラグインのインスタンス + * @param object $objPlugin プラグインのインスタンス * @param string $priority 実行順 */ public function registerLocalHookPoint($objPlugin, $priority) @@ -187,7 +195,7 @@ public function registerLocalHookPoint($objPlugin, $priority) // ローカルプラグイン関数を定義しているかを検証. if (method_exists($objPlugin, 'register') === true) { // アクションの登録(プラグイン側に記述) - $objPluginHelper =& SC_Helper_Plugin::getSingletonInstance(); + $objPluginHelper = &self::getSingletonInstance(); $objPlugin->register($objPluginHelper, $priority); } } @@ -196,9 +204,10 @@ public function registerLocalHookPoint($objPlugin, $priority) * プラグイン コールバック関数を追加する * * @param string $hook_point フックポイント名 - * @param callback $function コールバック関数名 - * @param integer $priority 同一フックポイント内での実行優先度 - * @return boolean 成功すればtrue + * @param callable $function コールバック関数名 + * @param int $priority 同一フックポイント内での実行優先度 + * + * @return bool 成功すればtrue */ public function addAction($hook_point, $function, $priority = 0) { @@ -206,7 +215,7 @@ public function addAction($hook_point, $function, $priority = 0) // TODO エラー処理; コール可能な形式ではありません } $idx = $this->makeActionUniqueId($hook_point, $function, $priority); - $this->arrRegistedPluginActions[$hook_point][$priority][$idx] = array('function' => $function); + $this->arrRegistedPluginActions[$hook_point][$priority][$idx] = ['function' => $function]; return true; } @@ -215,8 +224,9 @@ public function addAction($hook_point, $function, $priority = 0) * コールバック関数を一意に識別するIDの生成 * * @param string $hook_point フックポイント名 - * @param callback $function コールバック関数名 - * @param integer $priority 同一フックポイント内での実行優先度 + * @param callable $function コールバック関数名 + * @param int $priority 同一フックポイント内での実行優先度 + * * @return string コールバック関数を一意に識別するID */ public function makeActionUniqueId($hook_point, $function, $priority) @@ -228,18 +238,19 @@ public function makeActionUniqueId($hook_point, $function, $priority) } if (is_object($function)) { - $function = array($function, ''); + $function = [$function, '']; } else { $function = (array) $function; } if (is_object($function[0])) { if (function_exists('spl_object_hash')) { - return spl_object_hash($function[0]) . $function[1]; + return spl_object_hash($function[0]).$function[1]; } else { $obj_idx = get_class($function[0]).$function[1]; - if ( false === $priority) + if (false === $priority) { return false; + } $obj_idx .= isset($this->arrRegistedPluginActions[$hook_point][$priority]) ? count((array) $this->arrRegistedPluginActions[$hook_point][$priority]) : $filter_id_count; @@ -257,6 +268,7 @@ public function makeActionUniqueId($hook_point, $function, $priority) * ブロックの配列から有効でないpluginのブロックを除外して返します. * * @param array $arrBlocs プラグインのインストールディレクトリ + * * @return array $arrBlocsサイトルートからメディアディレクトリへの相対パス */ public function getEnableBlocs($arrBlocs) @@ -267,7 +279,7 @@ public function getEnableBlocs($arrBlocs) // 通常ブロック以外. if ($value['plugin_id'] != '') { // ブロック配列から削除する - unset ($arrBlocs[$key]); + unset($arrBlocs[$key]); } } } @@ -275,10 +287,11 @@ public function getEnableBlocs($arrBlocs) return $arrBlocs; } - /** + /** * テンプレートのヘッダに追加するPHPのURLをセットする * * @param string $url PHPファイルのURL + * * @return void */ public function setHeadNavi($url) @@ -290,15 +303,16 @@ public function setHeadNavi($url) * PHPのURLをテンプレートのヘッダに追加する * * @param array|null $arrBlocs 配置情報を含めたブロックの配列 + * * @return void */ public function setHeadNaviBlocs(&$arrBlocs) { foreach ($this->arrHeadNaviBlocsByPlugin as $key => $value) { - $arrBlocs[] = array( - 'target_id' =>$value, + $arrBlocs[] = [ + 'target_id' => $value, 'php_path' => $key - ); + ]; } } @@ -307,23 +321,25 @@ public function setHeadNaviBlocs(&$arrBlocs) * * @param string $hook_point hook point * @param SC_SiteView[] $arrArgs argument passing to callback function - * @param boolean $plugin_activate_flg + * @param bool $plugin_activate_flg + * * @return void */ - public static function hook($hook_point, $arrArgs = array(), $plugin_activate_flg = PLUGIN_ACTIVATE_FLAG) + public static function hook($hook_point, $arrArgs = [], $plugin_activate_flg = PLUGIN_ACTIVATE_FLAG) { // エラー処理中は実行しない if (SC_Helper_HandleError_Ex::$under_error_handling) { return; } - $objPlugin = SC_Helper_Plugin::getSingletonInstance($plugin_activate_flg); + $objPlugin = self::getSingletonInstance($plugin_activate_flg); // 以前、エラー処理中に (オブジェクトではない) false に対し、doAction をコールする不具合があった。(#1971, #2551) // 現在、そういった状況は回避している認識だが、念のため同様の状況が発生した場合、ログを残し、実行しない。 if (!is_object($objPlugin)) { // XXX 致命的エラーの処理中だと、この方法ではログが残らない模様。実質的に問題無いと考えている。 trigger_error('プラグインの処理で意図しない状況が発生しました。', E_USER_WARNING); + return; } diff --git a/data/class/helper/SC_Helper_Purchase.php b/data/class/helper/SC_Helper_Purchase.php index 3f58a5221b..17716a5cc2 100644 --- a/data/class/helper/SC_Helper_Purchase.php +++ b/data/class/helper/SC_Helper_Purchase.php @@ -27,18 +27,17 @@ * TODO 購入時強制会員登録機能(#521)の実装を検討 * TODO dtb_customer.buy_times, dtb_customer.buy_total の更新 * - * @package Helper * @author Kentaro Ohkouchi + * * @version $Id$ */ class SC_Helper_Purchase { - - public $arrShippingKey = array( + public $arrShippingKey = [ 'name01', 'name02', 'kana01', 'kana02', 'company_name', 'sex', 'zip01', 'zip02', 'country_id', 'zipcode', 'pref', 'addr01', 'addr02', 'tel01', 'tel02', 'tel03', 'fax01', 'fax02', 'fax03', - ); + ]; /** * 受注を完了する. @@ -57,7 +56,8 @@ class SC_Helper_Purchase * 決済モジュールを使用する場合は対応状況を「決済処理中」に設定し, * 決済完了後「新規受付」に変更すること * - * @param integer $orderStatus 受注処理を完了する際に設定する対応状況 + * @param int $orderStatus 受注処理を完了する際に設定する対応状況 + * * @return void */ public function completeOrder($orderStatus = ORDER_NEW) @@ -84,7 +84,7 @@ public function completeOrder($orderStatus = ORDER_NEW) $orderTemp['status'] = $orderStatus; $cartkey = $objCartSession->getKey(); $order_id = $this->registerOrderComplete($orderTemp, $objCartSession, $cartkey); - $isMultiple = SC_Helper_Purchase::isMultiple(); + $isMultiple = self::isMultiple(); $shippingTemp = &$this->getShippingTemp($isMultiple); foreach ($shippingTemp as $shippingId => $val) { $this->registerShipmentItem($order_id, $shippingId, $val['shipment_item']); @@ -93,14 +93,14 @@ public function completeOrder($orderStatus = ORDER_NEW) $this->registerShipping($order_id, $shippingTemp); $objQuery->commit(); - //会員情報の最終購入日、購入合計を更新 + // 会員情報の最終購入日、購入合計を更新 if ($customerId > 0) { SC_Customer_Ex::updateOrderSummary($customerId); } $this->cleanupSession($order_id, $objCartSession, $objCustomer, $cartkey); - GC_Utils_Ex::gfPrintLog('order complete. order_id=' . $order_id); + GC_Utils_Ex::gfPrintLog('order complete. order_id='.$order_id); } /** @@ -114,9 +114,10 @@ public function completeOrder($orderStatus = ORDER_NEW) * 引数 $is_delete が true の場合は, 受注データを論理削除する. * 商品の在庫数は, 受注前の在庫数に戻される. * - * @param integer $order_id 受注ID - * @param integer $orderStatus 対応状況 - * @param boolean $is_delete 受注データを論理削除する場合 true + * @param int $order_id 受注ID + * @param int $orderStatus 対応状況 + * @param bool $is_delete 受注データを論理削除する場合 true + * * @return void */ public static function cancelOrder($order_id, $orderStatus = ORDER_CANCEL, $is_delete = false) @@ -127,7 +128,7 @@ public static function cancelOrder($order_id, $orderStatus = ORDER_CANCEL, $is_d $objQuery->begin(); } - $arrParams = array(); + $arrParams = []; $arrParams['status'] = $orderStatus; if ($is_delete) { $arrParams['del_flg'] = 1; @@ -139,11 +140,11 @@ public static function cancelOrder($order_id, $orderStatus = ORDER_CANCEL, $is_d foreach ($arrOrderDetail as $arrDetail) { $objQuery->update( 'dtb_products_class', - array(), + [], 'product_class_id = ?', - array($arrDetail['product_class_id']), - array('stock' => 'stock + ?'), - array($arrDetail['quantity']) + [$arrDetail['product_class_id']], + ['stock' => 'stock + ?'], + [$arrDetail['quantity']] ); } if (!$in_transaction) { @@ -162,9 +163,10 @@ public static function cancelOrder($order_id, $orderStatus = ORDER_CANCEL, $is_d * 引数 $is_delete が true の場合は, 受注データを論理削除する. * 商品の在庫数, カートの内容は受注前の状態に戻される. * - * @param integer $order_id 受注ID - * @param integer $orderStatus 対応状況 - * @param boolean $is_delete 受注データを論理削除する場合 true + * @param int $order_id 受注ID + * @param int $orderStatus 対応状況 + * @param bool $is_delete 受注データを論理削除する場合 true + * * @return string 受注一時ID */ public static function rollbackOrder($order_id, $orderStatus = ORDER_CANCEL, $is_delete = false) @@ -214,6 +216,7 @@ public static function rollbackOrder($order_id, $orderStatus = ORDER_CANCEL, $is * * @param string $uniqId ユニークID * @param SC_CartSession $objCartSession + * * @return void */ public static function verifyChangeCart($uniqId, &$objCartSession) @@ -249,27 +252,29 @@ public static function verifyChangeCart($uniqId, &$objCartSession) /** * 受注一時情報を取得する. * - * @param integer $uniqId 受注一時情報ID + * @param int $uniqId 受注一時情報ID + * * @return array 受注一時情報の配列 */ public static function getOrderTemp($uniqId) { $objQuery = SC_Query_Ex::getSingletonInstance(); - return $objQuery->getRow('*', 'dtb_order_temp', 'order_temp_id = ?', array($uniqId)); + return $objQuery->getRow('*', 'dtb_order_temp', 'order_temp_id = ?', [$uniqId]); } /** * 受注IDをキーにして受注一時情報を取得する. * - * @param integer $order_id 受注ID + * @param int $order_id 受注ID + * * @return array 受注一時情報の配列 */ public static function getOrderTempByOrderId($order_id) { $objQuery = SC_Query_Ex::getSingletonInstance(); - return $objQuery->getRow('*', 'dtb_order_temp', 'order_id = ?', array($order_id)); + return $objQuery->getRow('*', 'dtb_order_temp', 'order_id = ?', [$order_id]); } /** @@ -277,12 +282,13 @@ public static function getOrderTempByOrderId($order_id) * * 既存のデータが存在しない場合は新規保存. 存在する場合は更新する. * - * @param integer $uniqId 受注一時情報ID + * @param int $uniqId 受注一時情報ID * @param array $params 登録する受注情報の配列 * @param SC_Customer $objCustomer SC_Customer インスタンス + * * @return void */ - public static function saveOrderTemp($uniqId, $params, &$objCustomer = NULL) + public static function saveOrderTemp($uniqId, $params, &$objCustomer = null) { if (SC_Utils_Ex::isBlank($uniqId)) { return; @@ -291,7 +297,7 @@ public static function saveOrderTemp($uniqId, $params, &$objCustomer = NULL) $objQuery = SC_Query_Ex::getSingletonInstance(); // 存在するカラムのみを対象とする $cols = $objQuery->listTableFields('dtb_order_temp'); - $sqlval = array(); + $sqlval = []; foreach ($params as $key => $val) { if (in_array($key, $cols)) { $sqlval[$key] = $val; @@ -305,15 +311,15 @@ public static function saveOrderTemp($uniqId, $params, &$objCustomer = NULL) } $exists = SC_Helper_Purchase_Ex::getOrderTemp($uniqId); - //国ID追加 - $sqlval['order_country_id'] = ($sqlval['order_country_id']) ? $sqlval['order_country_id'] : DEFAULT_COUNTRY_ID; + // 国ID追加 + $sqlval['order_country_id'] = ($sqlval['order_country_id']) ? $sqlval['order_country_id'] : DEFAULT_COUNTRY_ID; if (SC_Utils_Ex::isBlank($exists)) { $sqlval['order_temp_id'] = $uniqId; $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; $objQuery->insert('dtb_order_temp', $sqlval); } else { - $objQuery->update('dtb_order_temp', $sqlval, 'order_temp_id = ?', array($uniqId)); + $objQuery->update('dtb_order_temp', $sqlval, 'order_temp_id = ?', [$uniqId]); } } @@ -325,11 +331,15 @@ public static function saveOrderTemp($uniqId, $params, &$objCustomer = NULL) public static function getShippingTemp($has_shipment_item = false) { // ダウンロード商品の場合setされていないので空の配列を返す. - if (!isset($_SESSION['shipping'])) return array(); + if (!isset($_SESSION['shipping'])) { + return []; + } if ($has_shipment_item) { - $arrReturn = array(); + $arrReturn = []; foreach ($_SESSION['shipping'] as $key => $arrVal) { - if (is_array($arrVal['shipment_item']) && count($arrVal['shipment_item']) == 0) continue; + if (is_array($arrVal['shipment_item']) && count($arrVal['shipment_item']) == 0) { + continue; + } $arrReturn[$key] = $arrVal; } @@ -342,7 +352,8 @@ public static function getShippingTemp($has_shipment_item = false) /** * 配送商品をクリア(消去)する * - * @param integer $shipping_id 配送先ID + * @param int $shipping_id 配送先ID + * * @return void */ public function clearShipmentItemTemp($shipping_id = null) @@ -352,8 +363,12 @@ public function clearShipmentItemTemp($shipping_id = null) $this->clearShipmentItemTemp($key); } } else { - if (!isset($_SESSION['shipping'][$shipping_id])) return; - if (!is_array($_SESSION['shipping'][$shipping_id])) return; + if (!isset($_SESSION['shipping'][$shipping_id])) { + return; + } + if (!is_array($_SESSION['shipping'][$shipping_id])) { + return; + } unset($_SESSION['shipping'][$shipping_id]['shipment_item']); } } @@ -361,9 +376,10 @@ public function clearShipmentItemTemp($shipping_id = null) /** * 配送商品を設定する. * - * @param integer $shipping_id 配送先ID - * @param integer $product_class_id 商品規格ID - * @param integer $quantity 数量 + * @param int $shipping_id 配送先ID + * @param int $product_class_id 商品規格ID + * @param int $quantity 数量 + * * @return void */ public function setShipmentItemTemp($shipping_id, $product_class_id, $quantity) @@ -400,11 +416,12 @@ public function setShipmentItemTemp($shipping_id, $product_class_id, $quantity) /** * 配送先都道府県の配列を返す. - * @param boolean $is_multiple + * + * @param bool $is_multiple */ public static function getShippingPref($is_multiple) { - $results = array(); + $results = []; foreach (SC_Helper_Purchase_Ex::getShippingTemp($is_multiple) as $val) { $results[] = $val['shipping_pref']; } @@ -415,7 +432,7 @@ public static function getShippingPref($is_multiple) /** * 複数配送指定の購入かどうか. * - * @return boolean 複数配送指定の購入の場合 true + * @return bool 複数配送指定の購入の場合 true */ public function isMultiple() { @@ -426,8 +443,10 @@ public function isMultiple() * 配送情報をセッションに保存する. * * XXX マージする理由が不明(なんとなく便利な気はするけど)。分かる方コメントに残してください。 + * * @param array $arrSrc 配送情報の連想配列 - * @param integer $shipping_id 配送先ID + * @param int $shipping_id 配送先ID + * * @return void */ public static function saveShippingTemp($arrSrc, $shipping_id = 0) @@ -436,7 +455,7 @@ public static function saveShippingTemp($arrSrc, $shipping_id = 0) unset($arrSrc['shipment_item']); if (!isset($_SESSION['shipping'][$shipping_id])) { - $_SESSION['shipping'][$shipping_id] = array(); + $_SESSION['shipping'][$shipping_id] = []; } $_SESSION['shipping'][$shipping_id] = array_merge($_SESSION['shipping'][$shipping_id], $arrSrc); $_SESSION['shipping'][$shipping_id]['shipping_id'] = $shipping_id; @@ -446,6 +465,7 @@ public static function saveShippingTemp($arrSrc, $shipping_id = 0) * セッションの配送情報を破棄する. * * @deprecated 2.12.0 から EC-CUBE 本体では使用していない。 + * * @return void */ public static function unsetShippingTemp() @@ -457,6 +477,7 @@ public static function unsetShippingTemp() * セッションの配送情報を全て破棄する * * @param bool $multiple_temp 複数お届け先の画面戻り処理用の情報も破棄するか + * * @return void */ public static function unsetAllShippingTemp($multiple_temp = false) @@ -470,7 +491,8 @@ public static function unsetAllShippingTemp($multiple_temp = false) /** * セッションの配送情報を個別に破棄する * - * @param integer $shipping_id 配送先ID + * @param int $shipping_id 配送先ID + * * @return void */ public static function unsetOneShippingTemp($shipping_id) @@ -489,23 +511,24 @@ public static function unsetOneShippingTemp($shipping_id) * @param SC_Customer $objCustomer SC_Customer インスタンス * @param string $prefix コピー先の接頭辞. デフォルト order * @param array $keys コピー対象のキー + * * @return void */ public static function copyFromCustomer( &$dest, &$objCustomer, $prefix = 'order', - $keys = array( + $keys = [ 'name01', 'name02', 'kana01', 'kana02', 'company_name', 'sex', 'zip01', 'zip02', 'country_id', 'zipcode', 'pref', 'addr01', 'addr02', 'tel01', 'tel02', 'tel03', 'fax01', 'fax02', 'fax03', 'job', 'birth', 'email', - ) + ] ) { if ($objCustomer->isLoginSuccess(true)) { foreach ($keys as $key) { if (in_array($key, $keys)) { - $dest[$prefix . '_' . $key] = $objCustomer->getValue($key); + $dest[$prefix.'_'.$key] = $objCustomer->getValue($key); } } @@ -514,9 +537,9 @@ public static function copyFromCustomer( ) { $email_mobile = $objCustomer->getValue('email_mobile'); if (empty($email_mobile)) { - $dest[$prefix . '_email'] = $objCustomer->getValue('email'); + $dest[$prefix.'_email'] = $objCustomer->getValue('email'); } else { - $dest[$prefix . '_email'] = $email_mobile; + $dest[$prefix.'_email'] = $email_mobile; } } @@ -537,6 +560,7 @@ public static function copyFromCustomer( * @param array $arrKey コピー対象のキー * @param string $prefix コピー先の接頭辞. デフォルト shipping * @param string $src_prefix コピー元の接頭辞. デフォルト order + * * @return void */ public function copyFromOrder(&$dest, $src, $prefix = 'shipping', $src_prefix = 'order', $arrKey = null) @@ -545,14 +569,14 @@ public function copyFromOrder(&$dest, $src, $prefix = 'shipping', $src_prefix = $arrKey = $this->arrShippingKey; } if (!SC_Utils_Ex::isBlank($prefix)) { - $prefix = $prefix . '_'; + $prefix = $prefix.'_'; } if (!SC_Utils_Ex::isBlank($src_prefix)) { - $src_prefix = $src_prefix . '_'; + $src_prefix = $src_prefix.'_'; } foreach ($arrKey as $key) { - if (isset($src[$src_prefix . $key])) { - $dest[$prefix . $key] = $src[$src_prefix . $key]; + if (isset($src[$src_prefix.$key])) { + $dest[$prefix.$key] = $src[$src_prefix.$key]; } } } @@ -561,13 +585,14 @@ public function copyFromOrder(&$dest, $src, $prefix = 'shipping', $src_prefix = * 配送情報のみ抜き出す。 * * @param string $arrSrc 元となる配列 + * * @return void */ public function extractShipping($arrSrc) { - $arrKey = array(); + $arrKey = []; foreach ($this->arrShippingKey as $key) { - $arrKey[] = 'shipping_' . $key; + $arrKey[] = 'shipping_'.$key; } return SC_Utils_Ex::sfArrayIntersectKeys($arrSrc, $arrKey); @@ -575,61 +600,62 @@ public function extractShipping($arrSrc) /** * お届け日一覧を取得する. + * * @param SC_CartSession $objCartSess - * @param integer $product_type_id + * @param int $product_type_id */ public function getDelivDate(&$objCartSess, $product_type_id) { $cartList = $objCartSess->getCartList($product_type_id); - $delivDateIds = array(); + $delivDateIds = []; foreach ($cartList as $item) { $delivDateIds[] = $item['productsClass']['deliv_date_id']; } $max_date = max($delivDateIds); - //発送目安 + // 発送目安 switch ($max_date) { - //即日発送 + // 即日発送 case '1': $start_day = 1; break; - //1-2日後 + // 1-2日後 case '2': $start_day = 3; break; - //3-4日後 + // 3-4日後 case '3': $start_day = 5; break; - //1週間以降 + // 1週間以降 case '4': $start_day = 8; break; - //2週間以降 + // 2週間以降 case '5': $start_day = 15; break; - //3週間以降 + // 3週間以降 case '6': $start_day = 22; break; - //1ヶ月以降 + // 1ヶ月以降 case '7': $start_day = 32; break; - //2ヶ月以降 + // 2ヶ月以降 case '8': $start_day = 62; break; - //お取り寄せ(商品入荷後) + // お取り寄せ(商品入荷後) case '9': $start_day = ''; break; default: - //お届け日が設定されていない場合 + // お届け日が設定されていない場合 $start_day = ''; break; } - //お届け可能日のスタート値から、お届け日の配列を取得する + // お届け可能日のスタート値から、お届け日の配列を取得する $arrDelivDate = $this->getDateArray($start_day, DELIV_DATE_END_MAX); return $arrDelivDate; @@ -642,8 +668,8 @@ public function getDateArray($start_day, $end_day) { $masterData = new SC_DB_MasterData_Ex(); $arrWDAY = $masterData->getMasterData('mtb_wday'); - $arrDate = array(); - //お届け可能日のスタート値がセットされていれば + $arrDate = []; + // お届け可能日のスタート値がセットされていれば if ($start_day >= 1) { $now_time = time(); $max_day = $start_day + $end_day; @@ -669,9 +695,10 @@ public function getDateArray($start_day, $end_day) * * TODO UPDATE/INSERT にする * - * @param integer $order_id 受注ID + * @param int $order_id 受注ID * @param array $arrParams 配送情報の連想配列 - * @param boolean $convert_shipping_date yyyy/mm/dd(EEE) 形式の配送日付を変換する場合 true + * @param bool $convert_shipping_date yyyy/mm/dd(EEE) 形式の配送日付を変換する場合 true + * * @return void */ public static function registerShipping($order_id, $arrParams, $convert_shipping_date = true) @@ -681,7 +708,7 @@ public static function registerShipping($order_id, $arrParams, $convert_shipping $where = 'order_id = ?'; if ($objQuery->count($table, $where, [$order_id]) > 0) { - $objQuery->delete($table, $where, array($order_id)); + $objQuery->delete($table, $where, [$order_id]); } foreach ($arrParams as $key => $arrShipping) { @@ -705,7 +732,7 @@ public static function registerShipping($order_id, $arrParams, $convert_shipping $arrValues['order_id'] = $order_id; $arrValues['create_date'] = 'CURRENT_TIMESTAMP'; $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; - //国ID追加 + // 国ID追加 /*いらないかもしれないんでとりあえずコメントアウト $arrValues['shipping_country_id'] = DEFAULT_COUNTRY_ID; */ @@ -721,20 +748,20 @@ public static function registerShipping($order_id, $arrParams, $convert_shipping __EOS__; $objQuery->update( 'dtb_shipping', - array(), + [], $where, - array($order_id), - array('shipping_time' => "($sql_sub)") + [$order_id], + ['shipping_time' => "($sql_sub)"] ); - } /** * 配送商品を登録する. * - * @param integer $order_id 受注ID - * @param integer $shipping_id 配送先ID + * @param int $order_id 受注ID + * @param int $shipping_id 配送先ID * @param array $arrParams 配送商品の配列 + * * @return void */ public static function registerShipmentItem($order_id, $shipping_id, $arrParams) @@ -742,7 +769,7 @@ public static function registerShipmentItem($order_id, $shipping_id, $arrParams) $objQuery = SC_Query_Ex::getSingletonInstance(); $table = 'dtb_shipment_item'; $where = 'order_id = ? AND shipping_id = ?'; - $objQuery->delete($table, $where, array($order_id, $shipping_id)); + $objQuery->delete($table, $where, [$order_id, $shipping_id]); $objProduct = new SC_Product_Ex(); foreach ($arrParams as $arrValues) { @@ -791,18 +818,19 @@ public static function registerShipmentItem($order_id, $shipping_id, $arrParams) * * @param array $orderParams 登録する受注情報の配列 * @param SC_CartSession $objCartSession カート情報のインスタンス - * @param integer $cartKey 登録を行うカート情報のキー - * @return integer 受注ID + * @param int $cartKey 登録を行うカート情報のキー + * + * @return int 受注ID */ public function registerOrderComplete($orderParams, &$objCartSession, $cartKey) { $objQuery = SC_Query_Ex::getSingletonInstance(); // 不要な変数を unset - $unsets = array( + $unsets = [ 'mailmaga_flg', 'deliv_check', 'point_check', 'password', 'reminder', 'reminder_answer', 'mail_flag', 'session' - ); + ]; foreach ($unsets as $unset) { unset($orderParams[$unset]); } @@ -824,7 +852,7 @@ public function registerOrderComplete($orderParams, &$objCartSession, $cartKey) // 詳細情報を生成 $objProduct = new SC_Product_Ex(); $i = 0; - $arrDetail = array(); + $arrDetail = []; foreach ($cartItems as $item) { $p = &$item['productsClass']; $arrDetail[$i]['order_id'] = $orderParams['order_id']; @@ -852,9 +880,9 @@ public function registerOrderComplete($orderParams, &$objCartSession, $cartKey) $objQuery->update( 'dtb_order_temp', - array('del_flg' => 1), + ['del_flg' => 1], 'order_temp_id = ?', - array(SC_SiteSession_Ex::getUniqId()) + [SC_SiteSession_Ex::getUniqId()] ); return $orderParams['order_id']; @@ -866,9 +894,10 @@ public function registerOrderComplete($orderParams, &$objCartSession, $cartKey) * 既に受注IDが存在する場合は, 受注情報を更新する. * 引数の受注IDが, 空白又は null の場合は, 新しく受注IDを発行して登録する. * - * @param integer $order_id 受注ID + * @param int $order_id 受注ID * @param array $arrParams 受注情報の連想配列 - * @return integer 受注ID + * + * @return int 受注ID */ public static function registerOrder($order_id, $arrParams) { @@ -877,7 +906,7 @@ public static function registerOrder($order_id, $arrParams) $objQuery = SC_Query_Ex::getSingletonInstance(); $arrValues = $objQuery->extractOnlyColsOf($table, $arrParams); - $exists = $objQuery->exists($table, $where, array($order_id)); + $exists = $objQuery->exists($table, $where, [$order_id]); if ($exists) { static::sfUpdateOrderStatus( $order_id, @@ -889,7 +918,7 @@ public static function registerOrder($order_id, $arrParams) static::sfUpdateOrderNameCol($order_id); $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; - $objQuery->update($table, $arrValues, $where, array($order_id)); + $objQuery->update($table, $arrValues, $where, [$order_id]); } else { if (SC_Utils_Ex::isBlank($order_id)) { $order_id = static::getNextOrderID(); @@ -926,8 +955,9 @@ public static function registerOrder($order_id, $arrParams) * * 既に, 該当の受注が存在する場合は, 受注情報を削除し, 登録する. * - * @param integer $order_id 受注ID + * @param int $order_id 受注ID * @param array $arrParams 受注情報の連想配列 + * * @return void */ public static function registerOrderDetail($order_id, $arrParams) @@ -936,7 +966,7 @@ public static function registerOrderDetail($order_id, $arrParams) $where = 'order_id = ?'; $objQuery = SC_Query_Ex::getSingletonInstance(); - $objQuery->delete($table, $where, array($order_id)); + $objQuery->delete($table, $where, [$order_id]); foreach ($arrParams as $arrDetail) { $arrValues = $objQuery->extractOnlyColsOf($table, $arrDetail); $arrValues['order_detail_id'] = $objQuery->nextVal('dtb_order_detail_order_detail_id'); @@ -948,15 +978,16 @@ public static function registerOrderDetail($order_id, $arrParams) /** * 受注情報を取得する. * - * @param integer $order_id 受注ID - * @param integer $customer_id 会員ID + * @param int $order_id 受注ID + * @param int $customer_id 会員ID + * * @return array 受注情報の配列 */ public static function getOrder($order_id, $customer_id = null) { $objQuery = SC_Query_Ex::getSingletonInstance(); $where = 'order_id = ?'; - $arrValues = array($order_id); + $arrValues = [$order_id]; if (!SC_Utils_Ex::isBlank($customer_id)) { $where .= ' AND customer_id = ?'; $arrValues[] = $customer_id; @@ -968,14 +999,15 @@ public static function getOrder($order_id, $customer_id = null) /** * 受注詳細を取得する. * - * @param integer $order_id 受注ID - * @param boolean $has_order_status 対応状況, 入金日も含める場合 true + * @param int $order_id 受注ID + * @param bool $has_order_status 対応状況, 入金日も含める場合 true + * * @return array 受注詳細の配列 */ public static function getOrderDetail($order_id, $has_order_status = true) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $dbFactory = SC_DB_DBFactory_Ex::getInstance(); + $dbFactory = SC_DB_DBFactory_Ex::getInstance(); $col = <<< __EOS__ T3.product_id, T3.product_class_id as product_class_id, @@ -1005,7 +1037,7 @@ public static function getOrderDetail($order_id, $has_order_status = true) ELSE '0' END AS enable, __EOS__; - $col .= $dbFactory->getDownloadableDaysWhereSql('T1') . ' AS effective'; + $col .= $dbFactory->getDownloadableDaysWhereSql('T1').' AS effective'; $from = <<< __EOS__ dtb_order T1 JOIN dtb_order_detail T2 @@ -1015,7 +1047,7 @@ public static function getOrderDetail($order_id, $has_order_status = true) __EOS__; $objQuery->setOrder('T2.order_detail_id'); - return $objQuery->select($col, $from, 'T1.order_id = ?', array($order_id)); + return $objQuery->select($col, $from, 'T1.order_id = ?', [$order_id]); } /** @@ -1027,7 +1059,9 @@ public static function getOrderDetail($order_id, $has_order_status = true) * 2. 販売価格が 0 円である * * 受注詳細行には, is_downloadable という真偽値が設定される. + * * @param array 受注詳細の配列 + * * @return void */ public static function setDownloadableFlgTo(&$arrOrderDetail) @@ -1036,7 +1070,7 @@ public static function setDownloadableFlgTo(&$arrOrderDetail) // 販売価格が 0 円 if ($arrOrderDetail[$key]['price'] == '0') { $arrOrderDetail[$key]['is_downloadable'] = true; - // ダウンロード期限内かつ, 入金日あり + // ダウンロード期限内かつ, 入金日あり } elseif ( $arrOrderDetail[$key]['effective'] == '1' && !SC_Utils_Ex::isBlank($arrOrderDetail[$key]['payment_date']) @@ -1051,20 +1085,21 @@ public static function setDownloadableFlgTo(&$arrOrderDetail) /** * 配送情報を取得する. * - * @param integer $order_id 受注ID - * @param boolean $has_items 結果に配送商品も含める場合 true + * @param int $order_id 受注ID + * @param bool $has_items 結果に配送商品も含める場合 true + * * @return array 配送情報の配列 */ public function getShippings($order_id, $has_items = true) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrResults = array(); + $arrResults = []; $objQuery->setOrder('shipping_id'); $arrShippings = $objQuery->select( '*', 'dtb_shipping', 'order_id = ?', - array($order_id) + [$order_id] ); // shipping_id ごとの配列を生成する foreach ($arrShippings as $shipping) { @@ -1086,16 +1121,17 @@ public function getShippings($order_id, $has_items = true) /** * 配送商品を取得する. * - * @param integer $order_id 受注ID - * @param integer $shipping_id 配送先ID - * @param boolean $has_detail 商品詳細も取得する場合 true + * @param int $order_id 受注ID + * @param int $shipping_id 配送先ID + * @param bool $has_detail 商品詳細も取得する場合 true + * * @return array 商品規格IDをキーにした配送商品の配列 */ public static function getShipmentItems($order_id, $shipping_id, $has_detail = true) { $objQuery = SC_Query_Ex::getSingletonInstance(); $objProduct = new SC_Product_Ex(); - $arrResults = array(); + $arrResults = []; $objQuery->setOrder('order_detail_id'); $arrItems = $objQuery->select( 'dtb_shipment_item.*', @@ -1103,7 +1139,7 @@ public static function getShipmentItems($order_id, $shipping_id, $has_detail = t ON dtb_shipment_item.product_class_id = dtb_order_detail.product_class_id AND dtb_shipment_item.order_id = dtb_order_detail.order_id', 'dtb_order_detail.order_id = ? AND shipping_id = ?', - array($order_id, $shipping_id) + [$order_id, $shipping_id] ); foreach ($arrItems as $key => $arrItem) { @@ -1128,11 +1164,12 @@ public static function getShipmentItems($order_id, $shipping_id, $has_detail = t * 端末種別IDにより, 携帯電話の場合は携帯用の文面, * それ以外の場合は PC 用の文面でメールを送信する. * - * @param integer $order_id 受注ID + * @param int $order_id 受注ID * @param object $objPage LC_Page インスタンス - * @return boolean 送信に成功したか。現状では、正確には取得できない。 + * + * @return bool 送信に成功したか。現状では、正確には取得できない。 */ - public static function sendOrderMail($order_id, &$objPage = NULL) + public static function sendOrderMail($order_id, &$objPage = null) { $objMail = new SC_Helper_Mail_Ex(); @@ -1156,17 +1193,18 @@ public static function sendOrderMail($order_id, &$objPage = NULL) * * 必ず呼び出し元でトランザクションブロックを開いておくこと。 * - * @param integer $orderId 注文番号 - * @param integer|null $newStatus 対応状況 (null=変更無し) - * @param integer|null $newAddPoint 加算ポイント (null=変更無し) - * @param integer|null $newUsePoint 使用ポイント (null=変更無し) + * @param int $orderId 注文番号 + * @param int|null $newStatus 対応状況 (null=変更無し) + * @param int|null $newAddPoint 加算ポイント (null=変更無し) + * @param int|null $newUsePoint 使用ポイント (null=変更無し) * @param array $sqlval 更新後の値をリファレンスさせるためのパラメーター + * * @return void */ - public static function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddPoint = null, $newUsePoint = null, &$sqlval = array()) + public static function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddPoint = null, $newUsePoint = null, &$sqlval = []) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrOrderOld = $objQuery->getRow('status, add_point, use_point, customer_id', 'dtb_order', 'order_id = ?', array($orderId)); + $arrOrderOld = $objQuery->getRow('status, add_point, use_point, customer_id', 'dtb_order', 'order_id = ?', [$orderId]); // 対応状況が変更無しの場合、DB値を引き継ぐ if (is_null($newStatus)) { @@ -1215,18 +1253,18 @@ public static function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddP // ▼会員テーブルの更新 $objQuery->update( 'dtb_customer', - array('update_date' => 'CURRENT_TIMESTAMP'), + ['update_date' => 'CURRENT_TIMESTAMP'], 'customer_id = ?', - array($arrOrderOld['customer_id']), - array('point' => 'point + ?'), - array($addCustomerPoint) + [$arrOrderOld['customer_id']], + ['point' => 'point + ?'], + [$addCustomerPoint] ); // ▲会員テーブルの更新 // 会員.ポイントをマイナスした場合、 if ($addCustomerPoint < 0) { $sql = 'SELECT point FROM dtb_customer WHERE customer_id = ?'; - $point = $objQuery->getOne($sql, array($arrOrderOld['customer_id'])); + $point = $objQuery->getOne($sql, [$arrOrderOld['customer_id']]); // 変更後の会員.ポイントがマイナスの場合、 if ($point < 0) { // ロールバック @@ -1240,7 +1278,7 @@ public static function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddP // ▼受注テーブルの更新 if (empty($sqlval)) { - $sqlval = array(); + $sqlval = []; } if (USE_POINT !== false) { @@ -1250,7 +1288,7 @@ public static function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddP // 対応状況が発送済みに変更の場合、発送日を更新 if ($arrOrderOld['status'] != ORDER_DELIV && $newStatus == ORDER_DELIV) { $sqlval['commit_date'] = 'CURRENT_TIMESTAMP'; - // 対応状況が入金済みに変更の場合、入金日を更新 + // 対応状況が入金済みに変更の場合、入金日を更新 } elseif ($arrOrderOld['status'] != ORDER_PRE_END && $newStatus == ORDER_PRE_END) { $sqlval['payment_date'] = 'CURRENT_TIMESTAMP'; } @@ -1259,11 +1297,11 @@ public static function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddP $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; $dest = $objQuery->extractOnlyColsOf('dtb_order', $sqlval); - $objQuery->update('dtb_order', $dest, 'order_id = ?', array($orderId)); + $objQuery->update('dtb_order', $dest, 'order_id = ?', [$orderId]); // ▲受注テーブルの更新 - //会員情報の最終購入日、購入合計を更新 - if ($arrOrderOld['customer_id'] > 0 and $arrOrderOld['status'] != $newStatus) { + // 会員情報の最終購入日、購入合計を更新 + if ($arrOrderOld['customer_id'] > 0 && $arrOrderOld['status'] != $newStatus) { SC_Customer_Ex::updateOrderSummary($arrOrderOld['customer_id']); } } @@ -1271,8 +1309,8 @@ public static function sfUpdateOrderStatus($orderId, $newStatus = null, $newAddP /** * 受注の名称列を更新する * - * @param integer $order_id 更新対象の注文番号 - * @param boolean $temp_table 更新対象は「受注_Temp」か + * @param int $order_id 更新対象の注文番号 + * @param bool $temp_table 更新対象は「受注_Temp」か * @static */ public static function sfUpdateOrderNameCol($order_id, $temp_table = false) @@ -1289,11 +1327,10 @@ public static function sfUpdateOrderNameCol($order_id, $temp_table = false) $objQuery->update( $tgt_table, - array(), + [], $sql_where, - array($order_id), - array('payment_method' => - '(SELECT payment_method FROM dtb_payment WHERE payment_id = ' . $tgt_table . '.payment_id)') + [$order_id], + ['payment_method' => '(SELECT payment_method FROM dtb_payment WHERE payment_id = '.$tgt_table.'.payment_id)'] ); } @@ -1302,8 +1339,9 @@ public static function sfUpdateOrderNameCol($order_id, $temp_table = false) * * $status が null の場合は false を返す. * - * @param integer $status 対応状況 - * @return boolean 使用するか(会員テーブルから減算するか) + * @param int $status 対応状況 + * + * @return bool 使用するか(会員テーブルから減算するか) */ public static function isUsePoint($status) { @@ -1312,7 +1350,6 @@ public static function isUsePoint($status) } switch ($status) { case ORDER_CANCEL: // キャンセル - return false; default: break; @@ -1324,8 +1361,9 @@ public static function isUsePoint($status) /** * ポイント加算するかの判定 * - * @param integer $status 対応状況 - * @return boolean 加算するか + * @param int $status 対応状況 + * + * @return bool 加算するか */ public static function isAddPoint($status) { @@ -1335,11 +1373,9 @@ public static function isAddPoint($status) case ORDER_PRE_END: // 入金済み case ORDER_CANCEL: // キャンセル case ORDER_BACK_ORDER: // 取り寄せ中 - return false; case ORDER_DELIV: // 発送済み - return true; default: @@ -1361,10 +1397,10 @@ public static function isAddPoint($status) * * $orderId が使われていない。 * - * @param integer $orderId 注文番号 + * @param int $orderId 注文番号 * @param SC_CartSession $objCartSession カート情報のインスタンス * @param SC_Customer $objCustomer SC_Customer インスタンス - * @param integer $cartKey 登録を行うカート情報のキー + * @param int $cartKey 登録を行うカート情報のキー */ public static function cleanupSession($orderId, &$objCartSession, &$objCustomer, $cartKey) { @@ -1381,7 +1417,8 @@ public static function cleanupSession($orderId, &$objCartSession, &$objCustomer, * 単一配送指定用に配送商品を設定する * * @param SC_CartSession $objCartSession カート情報のインスタンス - * @param integer $shipping_id 配送先ID + * @param int $shipping_id 配送先ID + * * @return void */ public function setShipmentItemTempForSole(&$objCartSession, $shipping_id = 0) @@ -1392,7 +1429,9 @@ public function setShipmentItemTempForSole(&$objCartSession, $shipping_id = 0) $arrCartList = &$objCartSession->getCartList($objCartSess->getKey()); foreach ($arrCartList as $arrCartRow) { - if ($arrCartRow['quantity'] == 0) continue; + if ($arrCartRow['quantity'] == 0) { + continue; + } $this->setShipmentItemTemp($shipping_id, $arrCartRow['id'], $arrCartRow['quantity']); } } @@ -1400,7 +1439,7 @@ public function setShipmentItemTempForSole(&$objCartSession, $shipping_id = 0) /** * 新規受注の注文IDを返す * - * @return integer + * @return int */ public static function getNextOrderID() { @@ -1411,7 +1450,9 @@ public static function getNextOrderID() /** * 決済処理中スタータスの受注データのキャンセル処理 + * * @param bool $cancel_flg 決済処理中ステータスのロールバックをするか(true:する false:しない) + * * @return void */ public function cancelPendingOrder($cancel_flg) @@ -1429,17 +1470,17 @@ public function cancelPendingOrder($cancel_flg) public function checkDbAllPendingOrder() { $term = PENDING_ORDER_CANCEL_TIME; - if (!SC_Utils_Ex::isBlank($term) && preg_match("/^[0-9]+$/", $term)) { - $target_time = strtotime('-' . $term . ' sec'); + if (!SC_Utils_Ex::isBlank($term) && preg_match('/^[0-9]+$/', $term)) { + $target_time = strtotime('-'.$term.' sec'); $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrVal = array(date('Y/m/d H:i:s', $target_time), ORDER_PENDING); + $arrVal = [date('Y/m/d H:i:s', $target_time), ORDER_PENDING]; $objQuery->begin(); $arrOrders = $objQuery->select('order_id', 'dtb_order', 'create_date <= ? and status = ? and del_flg = 0', $arrVal); if (!SC_Utils_Ex::isBlank($arrOrders)) { foreach ($arrOrders as $arrOrder) { $order_id = $arrOrder['order_id']; SC_Helper_Purchase_Ex::cancelOrder($order_id, ORDER_CANCEL, true); - GC_Utils_Ex::gfPrintLog('order cancel.(time expire) order_id=' . $order_id); + GC_Utils_Ex::gfPrintLog('order cancel.(time expire) order_id='.$order_id); } } $objQuery->commit(); @@ -1452,7 +1493,7 @@ public function checkDbMyPendignOrder() if ($objCustomer->isLoginSuccess(true)) { $customer_id = $objCustomer->getValue('customer_id'); $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrVal = array($customer_id, ORDER_PENDING); + $arrVal = [$customer_id, ORDER_PENDING]; $objQuery->setOrder('create_date desc'); $objQuery->begin(); $arrOrders = $objQuery->select('order_id,create_date', 'dtb_order', 'customer_id = ? and status = ? and del_flg = 0', $arrVal); @@ -1463,24 +1504,24 @@ public function checkDbMyPendignOrder() $objCartSess = new SC_CartSession_Ex(); $cartKeys = $objCartSess->getKeys(); $term = PENDING_ORDER_CANCEL_TIME; - if (preg_match("/^[0-9]+$/", $term)) { - $target_time = strtotime('-' . $term . ' sec'); + if (preg_match('/^[0-9]+$/', $term)) { + $target_time = strtotime('-'.$term.' sec'); $create_time = strtotime($arrOrder['create_date']); if (SC_Utils_Ex::isBlank($cartKeys) && $target_time < $create_time) { SC_Helper_Purchase_Ex::rollbackOrder($order_id, ORDER_CANCEL, true); - GC_Utils_Ex::gfPrintLog('order rollback.(my pending) order_id=' . $order_id); + GC_Utils_Ex::gfPrintLog('order rollback.(my pending) order_id='.$order_id); } else { SC_Helper_Purchase_Ex::cancelOrder($order_id, ORDER_CANCEL, true); if ($target_time > $create_time) { - GC_Utils_Ex::gfPrintLog('order cancel.(my pending and time expire) order_id=' . $order_id); + GC_Utils_Ex::gfPrintLog('order cancel.(my pending and time expire) order_id='.$order_id); } else { - GC_Utils_Ex::gfPrintLog('order cancel.(my pending and set cart) order_id=' . $order_id); + GC_Utils_Ex::gfPrintLog('order cancel.(my pending and set cart) order_id='.$order_id); } } } } else { SC_Helper_Purchase_Ex::cancelOrder($order_id, ORDER_CANCEL, true); - GC_Utils_Ex::gfPrintLog('order cancel.(my old pending) order_id=' . $order_id); + GC_Utils_Ex::gfPrintLog('order cancel.(my old pending) order_id='.$order_id); } } } @@ -1490,23 +1531,27 @@ public function checkDbMyPendignOrder() public function checkSessionPendingOrder() { - if (!isset($_SESSION['order_id'])) return; - if (SC_Utils_Ex::isBlank($_SESSION['order_id'])) return; + if (!isset($_SESSION['order_id'])) { + return; + } + if (SC_Utils_Ex::isBlank($_SESSION['order_id'])) { + return; + } $order_id = $_SESSION['order_id']; unset($_SESSION['order_id']); $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); - $arrOrder = SC_Helper_Purchase_Ex::getOrder($order_id); + $arrOrder = SC_Helper_Purchase_Ex::getOrder($order_id); if ($arrOrder['status'] == ORDER_PENDING) { $objCartSess = new SC_CartSession_Ex(); $cartKeys = $objCartSess->getKeys(); if (SC_Utils_Ex::isBlank($cartKeys)) { SC_Helper_Purchase_Ex::rollbackOrder($order_id, ORDER_CANCEL, true); - GC_Utils_Ex::gfPrintLog('order rollback.(session pending) order_id=' . $order_id); + GC_Utils_Ex::gfPrintLog('order rollback.(session pending) order_id='.$order_id); } else { SC_Helper_Purchase_Ex::cancelOrder($order_id, ORDER_CANCEL, true); - GC_Utils_Ex::gfPrintLog('order rollback.(session pending and set card) order_id=' . $order_id); + GC_Utils_Ex::gfPrintLog('order rollback.(session pending and set card) order_id='.$order_id); } } $objQuery->commit(); diff --git a/data/class/helper/SC_Helper_Session.php b/data/class/helper/SC_Helper_Session.php index 7d1b5dccec..6823f16261 100644 --- a/data/class/helper/SC_Helper_Session.php +++ b/data/class/helper/SC_Helper_Session.php @@ -8,8 +8,8 @@ /** * セッション関連のヘルパークラス. * - * @package Helper * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class SC_Helper_Session @@ -25,12 +25,12 @@ public function __construct() { $this->objDb = new SC_Helper_DB_Ex(); if (session_status() !== PHP_SESSION_ACTIVE) { - session_set_save_handler(array(&$this, 'sfSessOpen'), - array(&$this, 'sfSessClose'), - array(&$this, 'sfSessRead'), - array(&$this, 'sfSessWrite'), - array(&$this, 'sfSessDestroy'), - array(&$this, 'sfSessGc')); + session_set_save_handler([&$this, 'sfSessOpen'], + [&$this, 'sfSessClose'], + [&$this, 'sfSessRead'], + [&$this, 'sfSessWrite'], + [&$this, 'sfSessDestroy'], + [&$this, 'sfSessGc']); } // 通常よりも早い段階(オブジェクトが破棄される前)でセッションデータを書き込んでセッションを終了する @@ -43,6 +43,7 @@ public function __construct() * * @param string $save_path セッションを保存するパス(使用しない) * @param string $session_name セッション名(使用しない) + * * @return bool セッションが正常に開始された場合 true */ public function sfSessOpen($save_path, $session_name) @@ -64,6 +65,7 @@ public function sfSessClose() * セッションのデータをDBから読み込む. * * @param string $id セッションID + * * @return string セッションデータの値 */ public function sfSessRead($id) @@ -76,7 +78,7 @@ public function sfSessRead($id) unset($_COOKIE['legacy-ECSESSID']); } $objQuery = SC_Query_Ex::getSingletonInstance(); - $arrRet = $objQuery->select('sess_data', 'dtb_session', 'sess_id = ?', array($id)); + $arrRet = $objQuery->select('sess_data', 'dtb_session', 'sess_id = ?', [$id]); if (empty($arrRet)) { return ''; } else { @@ -89,18 +91,19 @@ public function sfSessRead($id) * * @param string $id セッションID * @param string $sess_data セッションデータの値 + * * @return bool セッションの書き込みに成功した場合 true */ public function sfSessWrite($id, $sess_data) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $exists = $objQuery->exists('dtb_session', 'sess_id = ?', array($id)); - $sqlval = array(); + $exists = $objQuery->exists('dtb_session', 'sess_id = ?', [$id]); + $sqlval = []; if ($exists) { // レコード更新 $sqlval['sess_data'] = $sess_data; $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; - $objQuery->update('dtb_session', $sqlval, 'sess_id = ?', array($id)); + $objQuery->update('dtb_session', $sqlval, 'sess_id = ?', [$id]); } else { // セッションデータがある場合は、レコード作成 if (strlen($sess_data) > 0) { @@ -121,12 +124,13 @@ public function sfSessWrite($id, $sess_data) * セッションを破棄する. * * @param string $id セッションID + * * @return bool セッションを正常に破棄した場合 true */ public function sfSessDestroy($id) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $objQuery->delete('dtb_session', 'sess_id = ?', array($id)); + $objQuery->delete('dtb_session', 'sess_id = ?', [$id]); return true; } @@ -136,14 +140,14 @@ public function sfSessDestroy($id) * * 引数 $maxlifetime の代りに 定数 MAX_LIFETIME を使用する. * - * @param integer $maxlifetime セッションの有効期限(使用しない) + * @param int $maxlifetime セッションの有効期限(使用しない) */ public function sfSessGc($maxlifetime) { // MAX_LIFETIME以上更新されていないセッションを削除する。 $objQuery = SC_Query_Ex::getSingletonInstance(); - $limit = date("Y-m-d H:i:s",time() - MAX_LIFETIME); - $where = "update_date < '". $limit . "' "; + $limit = date('Y-m-d H:i:s', time() - MAX_LIFETIME); + $where = "update_date < '".$limit."' "; $objQuery->delete('dtb_session', $where); return true; @@ -164,7 +168,6 @@ public function sfSessGc($maxlifetime) * 遷移先のページで, LC_Page::isValidToken() の返り値をチェックすることにより, * 画面遷移の妥当性が確認できる. * - * @access protected * @return string トランザクショントークンの文字列 */ public static function getToken() @@ -179,7 +182,6 @@ public static function getToken() /** * トランザクショントークン用の予測困難な文字列を生成して返す. * - * @access private * @return string トランザクショントークン用の文字列 */ public static function createToken() @@ -200,10 +202,10 @@ public static function createToken() * セッションが破棄されるまで, トークンを保持する. * 引数 $is_unset が true の場合は, 妥当性検証後に破棄される. * - * @access protected - * @param boolean $is_unset 妥当性検証後, トークンを unset する場合 true; + * @param bool $is_unset 妥当性検証後, トークンを unset する場合 true; * デフォルト値は false - * @return boolean トランザクショントークンが有効な場合 true + * + * @return bool トランザクショントークンが有効な場合 true */ public static function isValidToken($is_unset = false) { @@ -240,9 +242,9 @@ public static function destroyToken() */ public static function adminAuthorization() { - if (($script_path = realpath($_SERVER['SCRIPT_FILENAME'])) !== FALSE) { + if (($script_path = realpath($_SERVER['SCRIPT_FILENAME'])) !== false) { $arrScriptPath = explode('/', str_replace('\\', '/', $script_path)); - $arrAdminPath = explode('/', str_replace('\\', '/', substr(HTML_REALDIR . ADMIN_DIR, 0, -1))); + $arrAdminPath = explode('/', str_replace('\\', '/', substr(HTML_REALDIR.ADMIN_DIR, 0, -1))); $arrDiff = array_diff_assoc($arrAdminPath, $arrScriptPath); if (in_array(substr(ADMIN_DIR, 0, -1), $arrDiff)) { return; @@ -250,7 +252,7 @@ public static function adminAuthorization() $masterData = new SC_DB_MasterData_Ex(); $arrExcludes = $masterData->getMasterData('mtb_auth_excludes'); foreach ($arrExcludes as $exclude) { - $arrExcludesPath = explode('/', str_replace('\\', '/', HTML_REALDIR . ADMIN_DIR . $exclude)); + $arrExcludesPath = explode('/', str_replace('\\', '/', HTML_REALDIR.ADMIN_DIR.$exclude)); $arrDiff = array_diff_assoc($arrExcludesPath, $arrScriptPath); if (count($arrDiff) === 0) { return; diff --git a/data/class/helper/SC_Helper_TaxRule.php b/data/class/helper/SC_Helper_TaxRule.php index b0b5324097..eb47ff94a0 100644 --- a/data/class/helper/SC_Helper_TaxRule.php +++ b/data/class/helper/SC_Helper_TaxRule.php @@ -24,8 +24,8 @@ /** * 税規約を管理するヘルパークラス. * - * @package Helper * @author AMUAMU + * * @version $Id$ */ class SC_Helper_TaxRule @@ -38,9 +38,10 @@ class SC_Helper_TaxRule * @param int $product_class_id 商品規格ID * @param int $pref_id 都道府県ID * @param int $country_id 国ID - * @return double 税金付与した金額 + * + * @return float 税金付与した金額 */ - public static function sfCalcIncTax($price, $product_id = 0, $product_class_id = 0, $pref_id =0, $country_id = 0) + public static function sfCalcIncTax($price, $product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0) { return (int) $price + SC_Helper_TaxRule_Ex::sfTax($price, $product_id, $product_class_id, $pref_id, $country_id); } @@ -53,9 +54,10 @@ public static function sfCalcIncTax($price, $product_id = 0, $product_class_id = * @param int $product_class_id 商品規格ID * @param int $pref_id 都道府県ID * @param int $country_id 国ID - * @return double 税金付与した金額 + * + * @return float 税金付与した金額 */ - public static function sfTax($price, $product_id = 0, $product_class_id = 0, $pref_id =0, $country_id = 0) + public static function sfTax($price, $product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0) { $arrTaxRule = SC_Helper_TaxRule_Ex::getTaxRule($product_id, $product_class_id, $pref_id, $country_id); @@ -74,6 +76,7 @@ public static function sfTax($price, $product_id = 0, $product_class_id = 0, $pr * * @param array{8?:int, 10?:int} $arrTaxableTotal 税率ごとのお支払い合計金額 * @param int $discount_total 値引額合計 + * * @return array{8?:array{discount;int,total:int,tax:int}, 10?:array{discount;int,total:int,tax:int}} */ public static function getTaxPerTaxRate($arrTaxableTotal, $discount_total = 0) @@ -89,9 +92,9 @@ public static function getTaxPerTaxRate($arrTaxableTotal, $discount_total = 0) // 按分後の値引額の合計(8%対象商品の按分後の値引額 + 10%対象商品の按分後の値引額)が実際の値引額より+-1円となる事への対処 // ①按分した値引き額を四捨五入で丸める foreach ($arrTaxableTotal as $rate => $total) { - $discount[$rate] = $taxable_total !== 0 ? round(($discount_total * $total / $taxable_total), 0) : 0; + $discount[$rate] = $taxable_total !== 0 ? round($discount_total * $total / $taxable_total, 0) : 0; $divide[$rate] = [ - 'discount' => intval($discount[$rate]), + 'discount' => (int) ($discount[$rate]), ]; $cf_discount += $divide[$rate]['discount']; } @@ -108,16 +111,17 @@ public static function getTaxPerTaxRate($arrTaxableTotal, $discount_total = 0) if ($rate == $defaultTaxRule) { $discount[$rate] = $divide[$defaultTaxRule]['discount']; } else { - $discount[$rate] = $taxable_total !== 0 ? round(($discount_total * $total / $taxable_total), 0) : 0; + $discount[$rate] = $taxable_total !== 0 ? round($discount_total * $total / $taxable_total, 0) : 0; } $reduced_total = $total - $discount[$rate]; $tax = $reduced_total * ($rate / (100 + $rate)); $result[$rate] = [ - 'discount' => intval($discount[$rate]), - 'total' => intval($reduced_total), - 'tax' => intval(static::roundByCalcRule($tax, $defaultTaxRule)), + 'discount' => (int) ($discount[$rate]), + 'total' => (int) $reduced_total, + 'tax' => (int) (static::roundByCalcRule($tax, $defaultTaxRule)), ]; } + return $result; } @@ -128,6 +132,7 @@ public static function getTaxPerTaxRate($arrTaxableTotal, $discount_total = 0) * * @param array{8?:int, 10?:int} $arrTaxableTotal 税率ごとのお支払い合計金額 * @param int $discount_total 値引額合計 + * * @return string (<税率>%対象: <値引後税込合計>円 内消費税: <値引後税額>円) */ public static function getTaxDetail($arrTaxableTotal, $discount_total = 0) @@ -135,7 +140,7 @@ public static function getTaxDetail($arrTaxableTotal, $discount_total = 0) $arrTaxPerTaxRate = static::getTaxPerTaxRate($arrTaxableTotal, $discount_total); $result = ''; foreach ($arrTaxPerTaxRate as $rate => $item) { - $result .= '('.$rate .'%対象: '. number_format($item['total']).'円 内消費税: '.number_format($item['tax']).'円)'.PHP_EOL; + $result .= '('.$rate.'%対象: '.number_format($item['total']).'円 内消費税: '.number_format($item['tax']).'円)'.PHP_EOL; } return $result; @@ -147,7 +152,8 @@ public static function getTaxDetail($arrTaxableTotal, $discount_total = 0) * * @param int $price 計算対象の金額 * @param int $tax_rule_id 税規約ID - * @return double 税金付与した金額 + * + * @return float 税金付与した金額 */ public static function calcIncTaxFromRuleId($price, $tax_rule_id = 0) { @@ -160,7 +166,8 @@ public static function calcIncTaxFromRuleId($price, $tax_rule_id = 0) * * @param int $price 計算対象の金額 * @param int $tax_rule_id 税規約ID - * @return double 税金付与した金額 + * + * @return float 税金付与した金額 */ public static function calcTaxFromRuleId($price, $tax_rule_id = 0) { @@ -177,12 +184,13 @@ public static function calcTaxFromRuleId($price, $tax_rule_id = 0) * XXX int のみか不明 * @param int $calc_rule 端数処理 * @param int $tax_adjust 調整額 - * @return double 税金額 + * + * @return float 税金額 */ public static function calcTax($price, $tax, $calc_rule, $tax_adjust = 0) { $real_tax = $tax / 100; - $ret = (int)$price * $real_tax; + $ret = (int) $price * $real_tax; $ret = self::roundByCalcRule($ret, $calc_rule); return $ret + $tax_adjust; @@ -196,6 +204,7 @@ public static function calcTax($price, $tax, $calc_rule, $tax_adjust = 0) * @param int $pref_id 都道府県ID * @param int $country_id 国ID * @param int $option_product_tax_rule 商品別税率を有効にする場合 1, 無効の場合 0 + * * @return array 税設定情報 * * @see https://github.com/EC-CUBE/ec-cube2/pull/301 @@ -203,7 +212,7 @@ public static function calcTax($price, $tax, $calc_rule, $tax_adjust = 0) public static function getTaxRule($product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0, $option_product_tax_rule = OPTION_PRODUCT_TAX_RULE) { // 複数回呼出があるのでキャッシュ化 - static $data_c = array(); + static $data_c = []; // 初期化 $product_id = $product_id > 0 ? $product_id : 0; @@ -232,12 +241,12 @@ public static function getTaxRule($product_id = 0, $product_class_id = 0, $pref_ } } - $arrRet = array(); + $arrRet = []; // リクエストの配列化 - $arrRequest = array('product_id' => $product_id, + $arrRequest = ['product_id' => $product_id, 'product_class_id' => $product_class_id, 'pref_id' => $pref_id, - 'country_id' => $country_id); + 'country_id' => $country_id]; // 地域設定を優先するが、システムパラメーターなどに設定を持っていくか // 後に書いてあるほど優先される、詳細後述MEMO参照 @@ -259,15 +268,15 @@ public static function getTaxRule($product_id = 0, $product_class_id = 0, $pref_ AND (country_id = 0 OR country_id = ?) AND apply_date < CURRENT_TIMESTAMP AND del_flg = 0'; - $arrVal = array($product_id, $product_class_id, $pref_id, $country_id); + $arrVal = [$product_id, $product_class_id, $pref_id, $country_id]; } else { $where = ' product_id = 0 ' - . ' AND product_class_id = 0 ' - . ' AND (pref_id = 0 OR pref_id = ?)' - . ' AND (country_id = 0 OR country_id = ?)' - . ' AND apply_date < CURRENT_TIMESTAMP' - . ' AND del_flg = 0'; - $arrVal = array($pref_id, $country_id); + .' AND product_class_id = 0 ' + .' AND (pref_id = 0 OR pref_id = ?)' + .' AND (country_id = 0 OR country_id = ?)' + .' AND apply_date < CURRENT_TIMESTAMP' + .' AND del_flg = 0'; + $arrVal = [$pref_id, $country_id]; } $order = 'apply_date DESC'; @@ -310,12 +319,13 @@ public static function getTaxRule($product_id = 0, $product_class_id = 0, $pref_ * @param float $tax_rate 消費税率 * @param int $product_id 商品ID * @param int $product_class_id 商品規格ID - * @param integer $tax_adjust 消費税加算額 + * @param int $tax_adjust 消費税加算額 * @param int $pref_id 県ID * @param int $country_id 国ID + * * @return void */ - public static function setTaxRuleForProduct($tax_rate, $product_id = 0, $product_class_id = 0, $tax_adjust=0, $pref_id = 0, $country_id = 0) + public static function setTaxRuleForProduct($tax_rate, $product_id = 0, $product_class_id = 0, $tax_adjust = 0, $pref_id = 0, $country_id = 0) { // 基本設定を取得 $arrRet = SC_Helper_TaxRule_Ex::getTaxRule(); @@ -327,12 +337,12 @@ public static function setTaxRuleForProduct($tax_rate, $product_id = 0, $product // 日付は登録時点を設定 $apply_date = 'CURRENT_TIMESTAMP'; // 税情報を設定 - SC_Helper_TaxRule_Ex::setTaxRule($calc_rule, $tax_rate, $apply_date, NULL, $tax_adjust, $product_id, $product_class_id, $pref_id, $country_id); + SC_Helper_TaxRule_Ex::setTaxRule($calc_rule, $tax_rate, $apply_date, null, $tax_adjust, $product_id, $product_class_id, $pref_id, $country_id); } else { // 商品別レコードが残っていれば削除 $objQuery = SC_Query_Ex::getSingletonInstance(); $where = 'del_flg = 0 AND product_id = ? AND product_class_id= ? AND pref_id = ? AND country_id = ?'; - $arrVal = array($product_id, $product_class_id, $pref_id, $country_id); + $arrVal = [$product_id, $product_class_id, $pref_id, $country_id]; $arrCheck = $objQuery->getRow('*', 'dtb_tax_rule', $where, $arrVal); $tax_rule_id = $arrCheck['tax_rule_id']; if ($tax_rule_id) { @@ -347,18 +357,19 @@ public static function setTaxRuleForProduct($tax_rate, $product_id = 0, $product * @param int $calc_rule 端数処理 * @param int $tax_rate 税率 * @param string $apply_date 適用日時 - * @param null|integer $tax_rule_id 税規約ID + * @param int|null $tax_rule_id 税規約ID * @param int $tax_adjust 調整額 * @param int $product_id 商品ID * @param int $product_class_id 商品規格ID * @param int $pref_id 都道府県ID * @param int $country_id 国ID + * * @return void */ - public static function setTaxRule($calc_rule, $tax_rate, $apply_date, $tax_rule_id=NULL, $tax_adjust=0, $product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0) + public static function setTaxRule($calc_rule, $tax_rate, $apply_date, $tax_rule_id = null, $tax_adjust = 0, $product_id = 0, $product_class_id = 0, $pref_id = 0, $country_id = 0) { $table = 'dtb_tax_rule'; - $arrValues = array(); + $arrValues = []; $arrValues['calc_rule'] = $calc_rule; $arrValues['tax_rate'] = $tax_rate; $arrValues['tax_adjust'] = $tax_adjust; @@ -368,14 +379,14 @@ public static function setTaxRule($calc_rule, $tax_rate, $apply_date, $tax_rule_ // 新規か更新か? $objQuery = SC_Query_Ex::getSingletonInstance(); - if ($tax_rule_id == NULL && $product_id != 0) { + if ($tax_rule_id == null && $product_id != 0) { $where = 'del_flg = 0 AND product_id = ? AND product_class_id = ? AND pref_id = ? AND country_id = ?'; - $arrVal = array($product_id, $product_class_id, $pref_id, $country_id); + $arrVal = [$product_id, $product_class_id, $pref_id, $country_id]; $arrCheck = $objQuery->getRow('*', 'dtb_tax_rule', $where, $arrVal); $tax_rule_id = $arrCheck['tax_rule_id']; } - if ($tax_rule_id == NULL) { + if ($tax_rule_id == null) { // 税情報を新規 // INSERTの実行 $arrValues['tax_rule_id'] = $objQuery->nextVal('dtb_tax_rule_tax_rule_id'); @@ -389,12 +400,13 @@ public static function setTaxRule($calc_rule, $tax_rate, $apply_date, $tax_rule_ } else { // 税情報を更新 $where = 'tax_rule_id = ?'; - $objQuery->update($table, $arrValues, $where, array($tax_rule_id)); + $objQuery->update($table, $arrValues, $where, [$tax_rule_id]); } } /** * @param bool $has_deleted + * * @return array|null */ public function getTaxRuleList($has_deleted = false) @@ -416,6 +428,7 @@ public function getTaxRuleList($has_deleted = false) /** * @param int $tax_rule_id * @param bool $has_deleted + * * @return array */ public static function getTaxRuleData($tax_rule_id, $has_deleted = false) @@ -426,12 +439,13 @@ public static function getTaxRuleData($tax_rule_id, $has_deleted = false) $where .= ' AND del_flg = 0'; } - return $objQuery->getRow('*', 'dtb_tax_rule', $where, array($tax_rule_id)); + return $objQuery->getRow('*', 'dtb_tax_rule', $where, [$tax_rule_id]); } /** * @param string $apply_date * @param bool $has_deleted + * * @return mixed */ public function getTaxRuleByTime($apply_date, $has_deleted = false) @@ -441,7 +455,7 @@ public function getTaxRuleByTime($apply_date, $has_deleted = false) if (!$has_deleted) { $where .= ' AND del_flg = 0'; } - $arrRet = $objQuery->select('*', 'dtb_tax_rule', $where, array($apply_date)); + $arrRet = $objQuery->select('*', 'dtb_tax_rule', $where, [$apply_date]); return $arrRet[0]; } @@ -450,25 +464,27 @@ public function getTaxRuleByTime($apply_date, $has_deleted = false) * 税規約の削除. * * @param int $tax_rule_id 税規約ID + * * @return void */ public static function deleteTaxRuleData($tax_rule_id) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $sqlval = array(); - $sqlval['del_flg'] = 1; + $sqlval = []; + $sqlval['del_flg'] = 1; $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; $where = 'tax_rule_id = ?'; - $objQuery->update('dtb_tax_rule', $sqlval, $where, array($tax_rule_id)); + $objQuery->update('dtb_tax_rule', $sqlval, $where, [$tax_rule_id]); } /** * 課税規則に応じて端数処理を行う * - * @param float|integer $value 端数処理を行う数値 - * @param integer $calc_rule 課税規則 - * @return double 端数処理後の数値 + * @param float|int $value 端数処理を行う数値 + * @param int $calc_rule 課税規則 + * + * @return float 端数処理後の数値 */ public static function roundByCalcRule($value, $calc_rule) { @@ -477,15 +493,15 @@ public static function roundByCalcRule($value, $calc_rule) case 1: $ret = round($value); break; - // 切り捨て + // 切り捨て case 2: $ret = floor($value); break; - // 切り上げ + // 切り上げ case 3: $ret = ceil($value); break; - // デフォルト:切り上げ + // デフォルト:切り上げ default: $ret = ceil($value); break; diff --git a/data/class/helper/SC_Helper_Transform.php b/data/class/helper/SC_Helper_Transform.php index 92dbade067..3c64901dfb 100644 --- a/data/class/helper/SC_Helper_Transform.php +++ b/data/class/helper/SC_Helper_Transform.php @@ -24,7 +24,6 @@ /** * テンプレートをDOM変形するためのヘルパークラス * - * @package Helper * @version $Id$ */ class SC_Helper_Transform @@ -42,34 +41,35 @@ class SC_Helper_Transform protected $footer_source; protected $search_depth; - const ERR_TARGET_ELEMENT_NOT_FOUND = 1; + public const ERR_TARGET_ELEMENT_NOT_FOUND = 1; /** * SmartyのHTMLソースをDOMに変換しておく * * @param string $source 変形対象のテンプレート + * * @return void */ public function __construct($source) { $this->objDOM = new DOMDocument(); $this->objDOM->strictErrorChecking = false; - $this->snip_count = 0; + $this->snip_count = 0; $this->smarty_tags_idx = 0; - $this->arrErr = array(); - $this->arrElementTree = array(); - $this->arrSelectElements = array(); + $this->arrErr = []; + $this->arrElementTree = []; + $this->arrSelectElements = []; $this->html_source = $source; - $this->header_source = NULL; - $this->footer_source = NULL; + $this->header_source = null; + $this->footer_source = null; $this->search_depth = 0; $encoding = mb_detect_encoding($source); - if (!in_array($encoding, array('ASCII', 'UTF-8'))) { + if (!in_array($encoding, ['ASCII', 'UTF-8'])) { if ($encoding === false) { $encoding = '検出不能'; } - $msg = 'テンプレートの文字コードが「' . $encoding . '」です。「UTF-8」のみ利用できます。'; + $msg = 'テンプレートの文字コードが「'.$encoding.'」です。「UTF-8」のみ利用できます。'; SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', true, $msg); } @@ -83,28 +83,28 @@ public function __construct($source) // headタグの内側を退避 $source = preg_replace_callback( '/(]*>)(.+)(<\/head>)/is', - array($this, 'lfCaptureHeadTags2Comment'), + [$this, 'lfCaptureHeadTags2Comment'], $source ); // JavaScript内にSmartyのタグが存在するものを、コメント形式に置換 $source = preg_replace_callback( '//s', - array($this, 'lfCaptureSmartyTags2Comment'), + [$this, 'lfCaptureSmartyTags2Comment'], $source ); // HTMLタグ内にSmartyのタグが存在するものを、まず置換する $source = preg_replace_callback( '/<(?:[^<>]*?(?:(<\!--\{.+?\}-->)|(?R))[^<>]*?)*?>/s', - array($this, 'lfCaptureSmartyTagsInTag'), + [$this, 'lfCaptureSmartyTagsInTag'], $source ); // 通常のノードに属する部分を、コメント形式に置換 $source = preg_replace_callback( '/<\!--{.+?\}-->/s', - array($this, 'lfCaptureSmartyTags2Comment'), + [$this, 'lfCaptureSmartyTags2Comment'], $source ); @@ -127,21 +127,22 @@ public function __construct($source) * jQueryライクなセレクタを用いてエレメントを選択する * * @param string $selector セレクタ - * @param integer $index インデックス(指定がある場合) - * @param boolean $require エレメントが見つからなかった場合、エラーとするか + * @param int $index インデックス(指定がある場合) + * @param bool $require エレメントが見つからなかった場合、エラーとするか * @param string $err_msg エラーメッセージ + * * @return SC_Helper_Transform */ - public function select($selector, $index = NULL, $require = true, $err_msg = NULL) + public function select($selector, $index = null, $require = true, $err_msg = null) { - $this->arrSelectElements = array(); + $this->arrSelectElements = []; $this->search_depth = 0; $regex = $this->lfSelector2Regex($selector); // セレクタをツリー検索用正規表現に変換 $cur_idx = 0; // ツリーを初めから全検索する - for ($iLoop=0; $iLoop < count($this->arrElementTree); $iLoop++) { + for ($iLoop = 0; $iLoop < count($this->arrElementTree); $iLoop++) { if (preg_match($regex, $this->arrElementTree[$iLoop][0])) { // インデックスが指定されていない(見つけたエレメント全て)、もしくは指定されたインデックスなら選択する if (is_null($index) || $cur_idx == $index) { @@ -167,23 +168,24 @@ public function select($selector, $index = NULL, $require = true, $err_msg = NUL * jQueryライクなセレクタを用いて、選択したエレメント内をさらに絞り込む * * @param string $selector セレクタ - * @param integer $index インデックス(指定がある場合) - * @param boolean $require エレメントが見つからなかった場合、エラーとするか + * @param int $index インデックス(指定がある場合) + * @param bool $require エレメントが見つからなかった場合、エラーとするか * @param string $err_msg エラーメッセージ + * * @return SC_Helper_Transform */ - public function find($selector, $index = NULL, $require = true, $err_msg = NULL) + public function find($selector, $index = null, $require = true, $err_msg = null) { $arrParentElements = $this->arrSelectElements[$this->search_depth]; $this->search_depth++; - $this->arrSelectElements[$this->search_depth] = array(); + $this->arrSelectElements[$this->search_depth] = []; foreach ($arrParentElements as $key => &$objElement) { $regex = $this->lfSelector2Regex($selector, $objElement[0]); // セレクタをツリー検索用正規表現に変換(親要素のセレクタを頭に付ける) $cur_idx = 0; // 親エレメント位置からツリーを検索する - for ($iLoop=$objElement[0]; $iLoop < count($this->arrElementTree); $iLoop++) { + for ($iLoop = $objElement[0]; $iLoop < count($this->arrElementTree); $iLoop++) { if (preg_match($regex, $this->arrElementTree[$iLoop][0])) { // インデックスが指定されていない(見つけたエレメント全て)、もしくは指定されたインデックスなら選択する if (is_null($index) || $cur_idx == $index) { @@ -210,6 +212,7 @@ public function find($selector, $index = NULL, $require = true, $err_msg = NULL) * 選択状態を指定数戻す * * @param int $back_num 選択状態を戻す数 + * * @return SC_Helper_Transform */ public function end($back_num = 1) @@ -227,6 +230,7 @@ public function end($back_num = 1) * 要素の前にHTMLを挿入 * * @param string $html_snip 挿入するHTMLの断片 + * * @return SC_Helper_Transform */ public function insertBefore($html_snip) @@ -244,6 +248,7 @@ public function insertBefore($html_snip) * 要素の後にHTMLを挿入 * * @param string $html_snip 挿入するHTMLの断片 + * * @return SC_Helper_Transform */ public function insertAfter($html_snip) @@ -261,6 +266,7 @@ public function insertAfter($html_snip) * 要素の先頭にHTMLを挿入 * * @param string $html_snip 挿入するHTMLの断片 + * * @return SC_Helper_Transform */ public function appendFirst($html_snip) @@ -278,6 +284,7 @@ public function appendFirst($html_snip) * 要素の末尾にHTMLを挿入 * * @param string $html_snip 挿入するHTMLの断片 + * * @return SC_Helper_Transform */ public function appendChild($html_snip) @@ -295,6 +302,7 @@ public function appendChild($html_snip) * 要素を指定したHTMLに置換 * * @param string $html_snip 置換後のHTMLの断片 + * * @return SC_Helper_Transform */ public function replaceElement($html_snip) @@ -346,7 +354,7 @@ public function getHTML() } } // エラー画面表示 - SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', true, 'テンプレートの操作に失敗しました。' . $err_msg); + SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', true, 'テンプレートの操作に失敗しました。'.$err_msg); return null; } elseif ($this->snip_count) { @@ -375,6 +383,7 @@ public function getHTML() * コメント形式への置換 * * @param array $arrMatches マッチしたタグの情報 + * * @return string 代わりの文字列 */ protected function lfCaptureSmartyTags2Comment(array $arrMatches) @@ -393,6 +402,7 @@ protected function lfCaptureSmartyTags2Comment(array $arrMatches) * コメント形式への置換 * * @param array $arrMatches マッチしたタグの情報 + * * @return string 代わりの文字列 */ protected function lfCaptureHeadTags2Comment(array $arrMatches) @@ -416,14 +426,15 @@ protected function lfCaptureHeadTags2Comment(array $arrMatches) * HTMLエレメント内部の処理 * * @param array $arrMatches マッチしたタグの情報 + * * @return string 代わりの文字列 */ protected function lfCaptureSmartyTagsInTag(array $arrMatches) { // Smartyタグ内のクォートを処理しやすいよう、いったんダミーのタグに - $html = preg_replace_callback('/<\!--{.+?\}-->/s', array($this, 'lfCaptureSmartyTags2Temptag'), $arrMatches[0]); - $html = preg_replace_callback('/\"[^"]*?\"/s', array($this, 'lfCaptureSmartyTagsInQuote'), $html); - $html = preg_replace_callback('/###TEMP(\d{8})###/s', array($this, 'lfCaptureSmartyTags2Attr'), $html); + $html = preg_replace_callback('/<\!--{.+?\}-->/s', [$this, 'lfCaptureSmartyTags2Temptag'], $arrMatches[0]); + $html = preg_replace_callback('/\"[^"]*?\"/s', [$this, 'lfCaptureSmartyTagsInQuote'], $html); + $html = preg_replace_callback('/###TEMP(\d{8})###/s', [$this, 'lfCaptureSmartyTags2Attr'], $html); return $html; } @@ -434,6 +445,7 @@ protected function lfCaptureSmartyTagsInTag(array $arrMatches) * ダミーへの置換実行 * * @param array $arrMatches マッチしたタグの情報 + * * @return string 代わりの文字列 */ protected function lfCaptureSmartyTags2Temptag(array $arrMatches) @@ -452,13 +464,14 @@ protected function lfCaptureSmartyTags2Temptag(array $arrMatches) * クォート内(=属性値)内にあるSmartyタグ(ダミーに置換済み)を、テキストに置換 * * @param array $arrMatches マッチしたタグの情報 + * * @return string 代わりの文字列 */ protected function lfCaptureSmartyTagsInQuote(array $arrMatches) { $html = preg_replace_callback( '/###TEMP(\d{8})###/s', - array($this, 'lfCaptureSmartyTags2Value'), + [$this, 'lfCaptureSmartyTags2Value'], $arrMatches[0] ); @@ -471,6 +484,7 @@ protected function lfCaptureSmartyTagsInQuote(array $arrMatches) * テキストへの置換実行 * * @param array $arrMatches マッチしたタグの情報 + * * @return string 代わりの文字列 */ protected function lfCaptureSmartyTags2Value(array $arrMatches) @@ -488,6 +502,7 @@ protected function lfCaptureSmartyTags2Value(array $arrMatches) * エレメント内部にあって、属性値ではないものを、ダミーの属性として置換 * * @param array $arrMatches マッチしたタグの情報 + * * @return string 代わりの文字列 */ protected function lfCaptureSmartyTags2Attr(array $arrMatches) @@ -503,33 +518,41 @@ protected function lfCaptureSmartyTags2Attr(array $arrMatches) * DOM Element / Document を走査し、name、class別に分類する * * @param DOMNode $objDOMElement DOMNodeオブジェクト + * * @return void */ protected function lfScanChild(DOMNode $objDOMElement, $parent_selector = '') { $objNodeList = $objDOMElement->childNodes; - if (is_null($objNodeList)) return; + if (is_null($objNodeList)) { + return; + } foreach ($objNodeList as $element) { // DOMElementのみ取り出す if ($element instanceof DOMElement) { - $arrAttr = array(); + $arrAttr = []; $arrAttr[] = $element->tagName; if (method_exists($element, 'getAttribute')) { // idを持っていればidを付加する - if ($element->hasAttribute('id')) + if ($element->hasAttribute('id')) { $arrAttr[] = '#'.$element->getAttribute('id'); + } // classを持っていればclassを付加する(複数の場合は複数付加する) if ($element->hasAttribute('class')) { $arrClasses = preg_split('/\s+/', $element->getAttribute('class')); - foreach ($arrClasses as $classname) $arrAttr[] = '.'.$classname; + foreach ($arrClasses as $classname) { + $arrAttr[] = '.'.$classname; + } } } // 親要素のセレクタを付けてツリーへ登録する $this_selector = $parent_selector.' '.implode('', $arrAttr); - $this->arrElementTree[] = array($this_selector, $element); + $this->arrElementTree[] = [$this_selector, $element]; // エレメントが子孫要素を持っていればさらに調べる - if ($element->hasChildNodes()) $this->lfScanChild($element, $this_selector); + if ($element->hasChildNodes()) { + $this->lfScanChild($element, $this_selector); + } } } } @@ -539,29 +562,45 @@ protected function lfScanChild(DOMNode $objDOMElement, $parent_selector = '') * * @param string $selector セレクタ * @param string $parent_index セレクタ検索時の親要素の位置(子孫要素検索のため) + * * @return string 正規表現文字列 */ - protected function lfSelector2Regex($selector, $parent_index = NULL) + protected function lfSelector2Regex($selector, $parent_index = null) { // jQueryライクなセレクタを正規表現に $selector = preg_replace('/ *> */', ' >', $selector); // 子セレクタをツリー検索用に 「A >B」の記法にする $regex = '/'; - if (!is_null($parent_index)) $regex .= preg_quote($this->arrElementTree[$parent_index][0], '/'); // (親要素の指定(絞り込み時)があれば頭に付加する(特殊文字はエスケープ) + if (!is_null($parent_index)) { + $regex .= preg_quote($this->arrElementTree[$parent_index][0], '/'); + } // (親要素の指定(絞り込み時)があれば頭に付加する(特殊文字はエスケープ) $arrSelectors = explode(' ', $selector); foreach ($arrSelectors as $sub_selector) { if (preg_match('/^(>?)([\w\-]+)?(#[\w\-]+)?(\.[\w\-]+)*$/', $sub_selector, $arrMatch)) { // 子セレクタ - if (isset($arrMatch[1]) && $arrMatch[1]) $regex .= ' '; - else $regex .= '.* '; + if (isset($arrMatch[1]) && $arrMatch[1]) { + $regex .= ' '; + } else { + $regex .= '.* '; + } // タグ名 - if (isset($arrMatch[2]) && $arrMatch[2]) $regex .= preg_quote($arrMatch[2], '/'); - else $regex .= '([\w\-]+)?'; + if (isset($arrMatch[2]) && $arrMatch[2]) { + $regex .= preg_quote($arrMatch[2], '/'); + } else { + $regex .= '([\w\-]+)?'; + } // id - if (isset($arrMatch[3]) && $arrMatch[3]) $regex .= preg_quote($arrMatch[3], '/'); - else $regex .= '(#(\w|\-|#{3}[0-9]{8}#{3})+)?'; + if (isset($arrMatch[3]) && $arrMatch[3]) { + $regex .= preg_quote($arrMatch[3], '/'); + } else { + $regex .= '(#(\w|\-|#{3}[0-9]{8}#{3})+)?'; + } // class - if (isset($arrMatch[4]) && $arrMatch[4]) $regex .= '(\.(\w|\-|#{3}[0-9]{8}#{3})+)*'.preg_quote($arrMatch[4], '/').'(\.(\w|\-|#{3}[0-9]{8}#{3})+)*'; // class指定の時は前後にもclassが付いているかもしれない - else $regex .= '(\.(\w|\-|#{3}[0-9]{8}#{3})+)*'; + if (isset($arrMatch[4]) && $arrMatch[4]) { + $regex .= '(\.(\w|\-|#{3}[0-9]{8}#{3})+)*'.preg_quote($arrMatch[4], '/').'(\.(\w|\-|#{3}[0-9]{8}#{3})+)*'; + } // class指定の時は前後にもclassが付いているかもしれない + else { + $regex .= '(\.(\w|\-|#{3}[0-9]{8}#{3})+)*'; + } } } $regex .= '$/i'; @@ -572,16 +611,17 @@ protected function lfSelector2Regex($selector, $parent_index = NULL) /** * 見つかった要素をプロパティに登録 * - * @param integer $elementNo エレメントのインデックス + * @param int $elementNo エレメントのインデックス * @param array $arrElement インデックスとDOMオブジェクトをペアとした配列 + * * @return void */ protected function lfAddElement($elementNo, array &$arrElement) { if (is_array($this->arrSelectElements[$this->search_depth]) && array_key_exists($arrElement[0], $this->arrSelectElements[$this->search_depth])) { - //nop + // nop } else { - $this->arrSelectElements[$this->search_depth][$arrElement[0]] = array($elementNo, &$arrElement[1]); + $this->arrSelectElements[$this->search_depth][$arrElement[0]] = [$elementNo, &$arrElement[1]]; } } @@ -591,7 +631,8 @@ protected function lfAddElement($elementNo, array &$arrElement) * @param string $mode 実行するメソッドの種類 * @param string $target_key 対象のエレメントの完全なセレクタ * @param string $html_snip HTMLコード - * @return boolean + * + * @return bool */ protected function lfSetTransform($mode, $target_key, $html_snip) { @@ -609,7 +650,9 @@ protected function lfSetTransform($mode, $target_key, $html_snip) $objElement = &$this->arrElementTree[$target_key][1]; } - if (!$objElement) return false; + if (!$objElement) { + return false; + } try { switch ($mode) { @@ -624,18 +667,22 @@ protected function lfSetTransform($mode, $target_key, $html_snip) $objElement->appendChild($objSnip); break; case 'insertBefore': - if (!is_object($objElement->parentNode)) return false; + if (!is_object($objElement->parentNode)) { + return false; + } $objElement->parentNode->insertBefore($objSnip, $objElement); break; case 'insertAfter': if ($objElement->nextSibling) { - $objElement->parentNode->insertBefore($objSnip, $objElement->nextSibling); + $objElement->parentNode->insertBefore($objSnip, $objElement->nextSibling); } else { - $objElement->parentNode->appendChild($objSnip); + $objElement->parentNode->appendChild($objSnip); } break; case 'replaceElement': - if (!is_object($objElement->parentNode)) return false; + if (!is_object($objElement->parentNode)) { + return false; + } $objElement->parentNode->replaceChild($objSnip, $objElement); break; default: @@ -653,16 +700,17 @@ protected function lfSetTransform($mode, $target_key, $html_snip) * セレクタエラーを記録する * * @param string $selector セレクタ - * @param integer $type エラーの種類 + * @param int $type エラーの種類 * @param string $err_msg エラーメッセージ + * * @return void */ - protected function lfSetError($selector, $type, $err_msg = NULL) + protected function lfSetError($selector, $type, $err_msg = null) { - $this->arrErr[] = array( - 'selector' => $selector, - 'type' => $type, - 'err_msg' => $err_msg - ); + $this->arrErr[] = [ + 'selector' => $selector, + 'type' => $type, + 'err_msg' => $err_msg + ]; } } diff --git a/data/class/pages/LC_Page.php b/data/class/pages/LC_Page.php index 63f3e7229e..7b3e030455 100644 --- a/data/class/pages/LC_Page.php +++ b/data/class/pages/LC_Page.php @@ -28,8 +28,8 @@ * PHP4 ではこのような抽象クラスを作っても継承先で何でもできてしまうため、 * あまり意味がないが、アーキテクトを統一するために作っておく. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page @@ -71,12 +71,13 @@ class LC_Page /** * プラグインを実行フラグ + * * @deprecated 定数 PLUGIN_ACTIVATE_FLAG を使用してください */ public $plugin_activate_flg = PLUGIN_ACTIVATE_FLAG; /** POST に限定する mode */ - public $arrLimitPostMode = array(); + public $arrLimitPostMode = []; /** ページレイアウトを読み込むか */ public $skip_load_page_layout = false; @@ -308,12 +309,12 @@ public function init() if (!$this->skip_load_page_layout) { $layout = new SC_Helper_PageLayout_Ex(); $layout->sfGetPageLayout($this, false, $_SERVER['SCRIPT_NAME'], - $this->objDisplay->detectDevice()); + $this->objDisplay->detectDevice()); } // スーパーフックポイントを実行. $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); - $objPlugin->doAction('LC_Page_preProcess', array($this)); + $objPlugin->doAction('LC_Page_preProcess', [$this]); // 店舗基本情報取得 $this->arrSiteInfo = SC_Helper_DB_Ex::sfGetBasisData(); @@ -352,7 +353,7 @@ public function sendResponse() $objPlugin->setHeadNaviBlocs($this->arrPageLayout['HeadNavi']); // スーパーフックポイントを実行. - $objPlugin->doAction('LC_Page_process', array($this)); + $objPlugin->doAction('LC_Page_process', [$this]); // ページクラス名をテンプレートに渡す $arrBacktrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); // class のみ使用 @@ -370,12 +371,13 @@ public function sendResponse() * * @param string $file_name * @param string $data + * * @return void */ public function sendResponseCSV($file_name, $data) { - $this->objDisplay->addHeader('Content-disposition', "attachment; filename=${file_name}"); - $this->objDisplay->addHeader('Content-type', "application/octet-stream; name=${file_name}"); + $this->objDisplay->addHeader('Content-disposition', "attachment; filename={$file_name}"); + $this->objDisplay->addHeader('Content-type', "application/octet-stream; name={$file_name}"); $this->objDisplay->addHeader('Cache-Control', ''); $this->objDisplay->addHeader('Pragma', ''); @@ -388,6 +390,7 @@ public function sendResponseCSV($file_name, $data) * デストラクタ * * ・ブロックの基底クラス (LC_Page_FrontParts_Bloc) では、継承していない。 + * * @return void */ public function __destruct() @@ -408,6 +411,7 @@ public function __destruct() * ローカルフックポイントを生成し、実行します. * * @param SC_Helper_Plugin_Ex $objPlugin + * * @return void */ public function doLocalHookpointBefore(SC_Helper_Plugin_Ex $objPlugin) @@ -415,11 +419,11 @@ public function doLocalHookpointBefore(SC_Helper_Plugin_Ex $objPlugin) // ローカルフックポイントを実行 $parent_class_name = get_parent_class($this); if ($parent_class_name != 'LC_Page') { - $objPlugin->doAction($parent_class_name . '_action_before', array($this)); + $objPlugin->doAction($parent_class_name.'_action_before', [$this]); } - $class_name = get_class($this); + $class_name = static::class; if ($parent_class_name != 'LC_Page' && $class_name != $parent_class_name) { - $objPlugin->doAction($class_name . '_action_before', array($this)); + $objPlugin->doAction($class_name.'_action_before', [$this]); } } @@ -427,6 +431,7 @@ public function doLocalHookpointBefore(SC_Helper_Plugin_Ex $objPlugin) * ローカルフックポイントを生成し、実行します. * * @param SC_Helper_Plugin_Ex $objPlugin + * * @return void */ public function doLocalHookpointAfter(SC_Helper_Plugin_Ex $objPlugin) @@ -434,17 +439,16 @@ public function doLocalHookpointAfter(SC_Helper_Plugin_Ex $objPlugin) // ローカルフックポイントを実行 $parent_class_name = get_parent_class($this); if ($parent_class_name != 'LC_Page') { - $objPlugin->doAction($parent_class_name . '_action_after', array($this)); + $objPlugin->doAction($parent_class_name.'_action_after', [$this]); } - $class_name = get_class($this); + $class_name = static::class; if ($parent_class_name != 'LC_Page' && $class_name != $parent_class_name) { - $objPlugin->doAction($class_name . '_action_after', array($this)); + $objPlugin->doAction($class_name.'_action_after', [$this]); } } /** * テンプレート取得 - * */ public function getTemplate() { @@ -453,7 +457,6 @@ public function getTemplate() /** * テンプレート設定(ポップアップなどの場合) - * */ public function setTemplate($template) { @@ -471,32 +474,33 @@ public function setTemplate($template) * 返り値に, QUERY_STRING を含めたい場合は, key => value 形式 * の配列を $param へ渡す. * - * @access protected * @param string $path 結果を取得するためのパス * @param array $param URL に付与するパラメーターの配列 * @param mixed $useSSL 結果に HTTPS_URL を使用する場合 true, * HTTP_URL を使用する場合 false, * デフォルト 'escape' 現在のスキーマを使用 + * * @return string $path の存在する http(s):// から始まる絶対パス + * * @see Net_URL */ - public function getLocation($path, $param = array(), $useSSL = 'escape') + public function getLocation($path, $param = [], $useSSL = 'escape') { $rootPath = $this->getRootPath($path); // スキーマを定義 if ($useSSL === true) { - $url = HTTPS_URL . $rootPath; + $url = HTTPS_URL.$rootPath; } elseif ($useSSL === false) { - $url = HTTP_URL . $rootPath; + $url = HTTP_URL.$rootPath; } elseif ($useSSL == 'escape') { if (SC_Utils_Ex::sfIsHTTPS()) { - $url = HTTPS_URL . $rootPath; + $url = HTTPS_URL.$rootPath; } else { - $url = HTTP_URL . $rootPath; + $url = HTTP_URL.$rootPath; } } else { - die("[BUG] Illegal Parametor of \$useSSL "); + exit('[BUG] Illegal Parametor of $useSSL '); } $netURL = new Net_URL($url); @@ -512,6 +516,7 @@ public function getLocation($path, $param = array(), $useSSL = 'escape') * EC-CUBE のWEBルート(/html/)を / としたパスを返す * * @param string $path 結果を取得するためのパス + * * @return string EC-CUBE のWEBルート(/html/)からのパス。 */ public function getRootPath($path) @@ -534,7 +539,7 @@ public function getRootPath($path) // $path が / で始まっている場合 if (substr($path, 0, 1) == '/') { - $realPath = realpath($htmlPath . substr_replace($path, '', 0, strlen(ROOT_URLPATH))); + $realPath = realpath($htmlPath.substr_replace($path, '', 0, strlen(ROOT_URLPATH))); // 相対パスの場合 } else { $realPath = realpath($path); @@ -557,7 +562,7 @@ public function getRootPath($path) // QUERY_STRING を復元する。 if (strlen($query_string) >= 1) { - $rootPath .= '?' . $query_string; + $rootPath .= '?'.$query_string; } return $rootPath; @@ -566,8 +571,8 @@ public function getRootPath($path) /** * 互換性確保用メソッド * - * @access protected * @return void + * * @deprecated 決済モジュール互換のため */ public function allowClientCache() @@ -578,8 +583,8 @@ public function allowClientCache() /** * クライアント・プロキシのキャッシュを制御する. * - * @access protected * @param string $mode (nocache/private) + * * @return void */ public function httpCacheControl($mode = '') @@ -614,7 +619,6 @@ public function httpCacheControl($mode = '') * mode に, 半角英数字とアンダーバー(_) 以外の文字列が検出された場合は null を * 返す. * - * @access protected * @return string|null $_REQUEST['mode'] の文字列 */ public function getMode() @@ -622,7 +626,7 @@ public function getMode() $pattern = '/^[a-zA-Z0-9_]+$/'; $mode = null; if (isset($_REQUEST['mode']) && preg_match($pattern, $_REQUEST['mode'])) { - $mode = $_REQUEST['mode']; + $mode = $_REQUEST['mode']; } return $mode; @@ -639,8 +643,8 @@ public function getMode() * ページによって検証タイミングなどを制御する必要がある場合は, この関数を * オーバーライドし, 個別に設定を行うこと. * - * @access public - * @param boolean $is_admin 管理画面でエラー表示をする場合 true + * @param bool $is_admin 管理画面でエラー表示をする場合 true + * * @return void */ public function doValidToken($is_admin = false) @@ -666,7 +670,6 @@ public function doValidToken($is_admin = false) /** * トランザクショントークンを取得し, 設定する. * - * @access protected * @return void */ public function setTokenTo() @@ -696,8 +699,8 @@ public function log($mess, $log_level) * * デバック用途のみに使用すること. * - * @access protected * @param mixed $val デバックする要素 + * * @return void */ public function p($val) @@ -709,6 +712,7 @@ public function p($val) * POST に限定された mode か検証する。 * * POST 以外で、POST に限定された mode を実行しようとした場合、落とす。 + * * @return void */ public function checkLimitPostMode() diff --git a/data/class/pages/LC_Page_Index.php b/data/class/pages/LC_Page_Index.php index 708501e54f..00687e7634 100644 --- a/data/class/pages/LC_Page_Index.php +++ b/data/class/pages/LC_Page_Index.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * Index のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Index extends LC_Page_Ex @@ -60,7 +59,7 @@ public function process() */ public function action() { - //決済処理中ステータスのロールバック + // 決済処理中ステータスのロールバック $objPurchase = new SC_Helper_Purchase_Ex(); $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG); diff --git a/data/class/pages/LC_Page_InputZip.php b/data/class/pages/LC_Page_InputZip.php index 21b293cfbc..431e18bd67 100644 --- a/data/class/pages/LC_Page_InputZip.php +++ b/data/class/pages/LC_Page_InputZip.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 郵便番号入力 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_InputZip extends LC_Page_Ex @@ -63,14 +62,14 @@ public function process() // エラー無し } else { // 郵便番号検索文作成 - $zipcode = $_GET['zip1'] . $_GET['zip2']; + $zipcode = $_GET['zip1'].$_GET['zip2']; // 郵便番号検索 $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode); // 郵便番号が発見された場合 if (!empty($arrAdsList)) { - $data = $arrAdsList[0]['state']. '|'. $arrAdsList[0]['city']. '|'. $arrAdsList[0]['town']; + $data = $arrAdsList[0]['state'].'|'.$arrAdsList[0]['city'].'|'.$arrAdsList[0]['town']; echo $data; // 該当無し @@ -84,6 +83,7 @@ public function process() * 入力エラーのチェック. * * @param array $arrRequest リクエスト値($_GET) + * * @return array $arrErr エラーメッセージ配列 */ public function fnErrorCheck($arrRequest) @@ -91,8 +91,8 @@ public function fnErrorCheck($arrRequest) // パラメーター管理クラス $objFormParam = new SC_FormParam_Ex(); // パラメーター情報の初期化 - $objFormParam->addParam('郵便番号1', 'zip1', ZIP01_LEN, 'n', array('NUM_COUNT_CHECK', 'NUM_CHECK')); - $objFormParam->addParam('郵便番号2', 'zip2', ZIP02_LEN, 'n', array('NUM_COUNT_CHECK', 'NUM_CHECK')); + $objFormParam->addParam('郵便番号1', 'zip1', ZIP01_LEN, 'n', ['NUM_COUNT_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('郵便番号2', 'zip2', ZIP02_LEN, 'n', ['NUM_COUNT_CHECK', 'NUM_CHECK']); // // リクエスト値をセット $objFormParam->setParam($arrRequest); // エラーチェック @@ -112,7 +112,8 @@ public function fnErrorCheck($arrRequest) * エラーチェック. * * @param string $value - * @return boolean エラー:false + * + * @return bool エラー:false */ public function lfInputNameCheck($value) { diff --git a/data/class/pages/LC_Page_ResizeImage.php b/data/class/pages/LC_Page_ResizeImage.php index 8ff4c51f8b..a5011efbf0 100644 --- a/data/class/pages/LC_Page_ResizeImage.php +++ b/data/class/pages/LC_Page_ResizeImage.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * リサイズイメージ のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_ResizeImage extends LC_Page_Ex @@ -65,14 +64,13 @@ public function action() $objFormParam->setParam($_GET); $arrErr = $objFormParam->checkError(); if (SC_Utils_Ex::isBlank($arrErr)) { - - $arrForm = $objFormParam->getHashArray(); + $arrForm = $objFormParam->getHashArray(); // TODO: ファイル名を直接指定するような処理は避けるべき // NO_IMAGE_REALFILE以外のファイル名が直接渡された場合、ファイル名のチェックを行う - if (strlen($arrForm['image']) >= 1 && $arrForm['image'] !== NO_IMAGE_REALFILE ) { + if (strlen($arrForm['image']) >= 1 && $arrForm['image'] !== NO_IMAGE_REALFILE) { if (!$this->lfCheckFileName($arrForm['image'])) { - GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php image=' . $arrForm['image']); + GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php image='.$arrForm['image']); } $file = SC_Utils_Ex::getSaveImagePath($arrForm['image']); } else { @@ -90,23 +88,25 @@ public function action() */ public function lfInitParam(&$objFormParam) { - $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('商品イメージキー', 'image_key', STEXT_LEN, '', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('画像ファイル名', 'image', STEXT_LEN, 'a', array('MAX_LENGTH_CHECK')); - $objFormParam->addParam('画像の幅', 'width', STEXT_LEN, 'n', array('NUM_CHECK')); - $objFormParam->addParam('画像の高さ', 'height', STEXT_LEN, 'n', array('NUM_CHECK')); + $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('商品イメージキー', 'image_key', STEXT_LEN, '', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('画像ファイル名', 'image', STEXT_LEN, 'a', ['MAX_LENGTH_CHECK']); + $objFormParam->addParam('画像の幅', 'width', STEXT_LEN, 'n', ['NUM_CHECK']); + $objFormParam->addParam('画像の高さ', 'height', STEXT_LEN, 'n', ['NUM_CHECK']); } /** * ファイル名の形式をチェック. * * @deprecated 2.13.0 商品IDを渡す事を推奨 + * * @param $image - * @return boolean 正常な形式:true 不正な形式:false + * + * @return bool 正常な形式:true 不正な形式:false */ public function lfCheckFileName($image) { - $file = trim($image); + $file = trim($image); if (!preg_match("/^[[:alnum:]_\.-]+$/i", $file)) { return false; } else { @@ -118,6 +118,7 @@ public function lfCheckFileName($image) * 商品画像のパスを取得する * * @param $arrForm + * * @return string 指定された商品画像のパス */ public function lfGetProductImage($arrForm) @@ -126,11 +127,11 @@ public function lfGetProductImage($arrForm) $table = 'dtb_products'; $col = $arrForm['image_key']; $product_id = $arrForm['product_id']; - //指定されたカラムが存在する場合にのみ商品テーブルからファイル名を取得 + // 指定されたカラムが存在する場合にのみ商品テーブルからファイル名を取得 if (SC_Helper_DB_Ex::sfColumnExists($table, $col, '', '', false)) { - $product_image = $objQuery->get($col, $table, 'product_id = ?', array($product_id)); + $product_image = $objQuery->get($col, $table, 'product_id = ?', [$product_id]); } else { - GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php image_key=' . $col); + GC_Utils_Ex::gfPrintLog('invalid access :resize_image.php image_key='.$col); $product_image = ''; } // ファイル名が正しく、ファイルが存在する場合だけ、$fileを設定 @@ -143,8 +144,8 @@ public function lfGetProductImage($arrForm) * 画像の出力 * * @param string $file 画像ファイル名 - * @param integer $width 画像の幅 - * @param integer $height 画像の高さ + * @param int $width 画像の幅 + * @param int $height 画像の高さ * * @return void */ diff --git a/data/class/pages/LC_Page_Sitemap.php b/data/class/pages/LC_Page_Sitemap.php index 05677edf98..dd24558c69 100644 --- a/data/class/pages/LC_Page_Sitemap.php +++ b/data/class/pages/LC_Page_Sitemap.php @@ -21,7 +21,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * Sitemapプロトコル ファイル生成モジュール. * PHP versions 4 and 5 @@ -39,10 +38,12 @@ * このモジュールを設置後, 各検索エンジンにサイトマップを登録することにより, 検索エンジンの * インデックス化が促進される. * + * * @see https://www.google.com/webmasters/tools/siteoverview?hl=ja * @see https://siteexplorer.search.yahoo.com/mysites * * @author Kentaro Ohkouchi + * * @version $Id:sitemap.php 15532 2007-08-31 14:39:46Z nanasess * * :TODO: 各ページの changefreq や priority を指定できるようにする @@ -66,9 +67,9 @@ public function init() $this->skip_load_page_layout = true; parent::init(); - $this->staticURL = array(); + $this->staticURL = []; - $this->staticURL[] = HTTP_URL . 'rss/' . DIR_INDEX_PATH; + $this->staticURL[] = HTTP_URL.'rss/'.DIR_INDEX_PATH; } /** @@ -82,24 +83,24 @@ public function process() // FIXME PCサイトのみに限定している。ある程度妥当だとは思うが、よりベターな方法はないだろうか。 $this->arrPageList = $this->getPageData('device_type_id = ?', DEVICE_TYPE_PC); - //キャッシュしない(念のため) + // キャッシュしない(念のため) header('Paragrama: no-cache'); - //XMLテキスト + // XMLテキスト header('Content-type: application/xml; charset=utf-8'); // 必ず UTF-8 として出力 mb_http_output('UTF-8'); ob_start('mb_output_handler'); - echo '' . "\n"; - echo '' . "\n"; + echo ''."\n"; + echo ''."\n"; // TOPページを処理 $arrTopPagesList = $this->getTopPage($this->arrPageList); $this->createSitemap($arrTopPagesList[0]['url'], - $this->date2W3CDatetime($arrTopPagesList[0]['update_date']), - 'daily', 1.0); + $this->date2W3CDatetime($arrTopPagesList[0]['update_date']), + 'daily', 1.0); // 静的なページを処理 foreach ($this->staticURL as $url) { @@ -110,7 +111,7 @@ public function process() $arrEditablePagesList = $this->getEditablePage($this->arrPageList); foreach ($arrEditablePagesList as $arrEditablePage) { $this->createSitemap($arrEditablePage['url'], - $this->date2W3CDatetime($arrEditablePage['update_date'])); + $this->date2W3CDatetime($arrEditablePage['update_date'])); } // 商品一覧ページを処理 @@ -123,10 +124,10 @@ public function process() $arrDetailPagesList = $this->getAllDetail(); foreach ($arrDetailPagesList as $arrDetailPage) { $this->createSitemap($arrDetailPage['url'], - $this->date2W3CDatetime($arrDetailPage['update_date'])); + $this->date2W3CDatetime($arrDetailPage['update_date'])); } - echo '' . "\n"; + echo ''."\n"; } /** @@ -135,8 +136,10 @@ public function process() * @param string $loc ページの URL ※必須 * @param string $lastmod ファイルの最終更新日 YYYY-MM-DD or W3C Datetime 形式 * @param string $changefreq ページの更新頻度 - * @param double $priority URL の優先度 + * @param float $priority URL の優先度 + * * @return void + * * @see https://www.google.com/webmasters/tools/docs/ja/protocol.html#xmlTagDefinitions * TODO Smarty に移行すべき? */ @@ -160,11 +163,12 @@ public function createSitemap($loc, $lastmod = '', $changefreq = '', $priority = * TOPページの情報を取得する. * * @param array $arrPageList 全てのページ情報の配列 + * * @return array TOPページの情報 */ public function getTopPage($arrPageList) { - $arrRet = array(); + $arrRet = []; foreach ($arrPageList as $arrPage) { if ($arrPage['page_id'] == '1') { $arrRet[0] = $arrPage; @@ -173,18 +177,19 @@ public function getTopPage($arrPageList) } } - return array(); + return []; } /** * 全ての編集可能ページの情報を取得する. * * @param array $arrPageList 全てのページ情報の配列 + * * @return array 編集可能ページ */ public function getEditablePage($arrPageList) { - $arrRet = array(); + $arrRet = []; foreach ($arrPageList as $arrPage) { if ($arrPage['page_id'] > 4) { $arrRet[] = $arrPage; @@ -206,11 +211,11 @@ public function getAllProducts() $sql = 'SELECT category_id FROM dtb_category WHERE del_flg = 0'; $result = $objQuery->getAll($sql); - $arrRet = array(); + $arrRet = []; foreach ($result as $row) { // :TODO: カテゴリの最終更新日を取得できるようにする - $arrPage['url'] = HTTP_URL . 'products/list.php?category_id=' . $row['category_id']; + $arrPage['url'] = HTTP_URL.'products/list.php?category_id='.$row['category_id']; $arrRet[] = $arrPage; } @@ -225,14 +230,14 @@ public function getAllProducts() public function getAllDetail() { $objQuery = SC_Query_Ex::getSingletonInstance(); - $sql = 'SELECT product_id, update_date FROM dtb_products WHERE ' . SC_Product_Ex::getProductDispConditions(); + $sql = 'SELECT product_id, update_date FROM dtb_products WHERE '.SC_Product_Ex::getProductDispConditions(); $result = $objQuery->getAll($sql); - $arrRet = array(); + $arrRet = []; foreach ($result as $row) { $arrPage['update_date'] = $row['update_date']; - $arrPage['url'] = HTTP_URL . substr(P_DETAIL_URLPATH, strlen(ROOT_URLPATH)) . $row['product_id']; + $arrPage['url'] = HTTP_URL.substr(P_DETAIL_URLPATH, strlen(ROOT_URLPATH)).$row['product_id']; $arrRet[] = $arrPage; } @@ -244,13 +249,14 @@ public function getAllDetail() * * @param string $where WHERE句 * @param array $arrVal WHERE句の値を格納した配列 + * * @return array $arrPageList ブロック情報 */ public function getPageData($where = '', $arrVal = '') { $objQuery = SC_Query_Ex::getSingletonInstance(); // DB操作オブジェクト $sql = ''; // データ取得SQL生成用 - $arrPageList = array(); // データ取得用 + $arrPageList = []; // データ取得用 // SQL生成(url と update_date 以外は不要?) $sql .= ' SELECT'; @@ -270,7 +276,7 @@ public function getPageData($where = '', $arrVal = '') // where句の指定があれば追加 if ($where != '') { - $sql .= ' WHERE ' . $where; + $sql .= ' WHERE '.$where; } $sql .= ' ORDER BY page_id'; @@ -279,11 +285,11 @@ public function getPageData($where = '', $arrVal = '') // URL にプロトコルの記載が無い場合、HTTP_URL を前置する。 foreach ($arrPageList as $key => $value) { - $arrPage =& $arrPageList[$key]; + $arrPage = &$arrPageList[$key]; if (!preg_match('|^https?://|i', $arrPage['url'])) { - $arrPage['url'] = HTTP_URL . $arrPage['url']; + $arrPage['url'] = HTTP_URL.$arrPage['url']; } - $arrPage['url'] = preg_replace('|/' . preg_quote(DIR_INDEX_FILE) . '$|', '/' . DIR_INDEX_PATH, $arrPage['url']); + $arrPage['url'] = preg_replace('|/'.preg_quote(DIR_INDEX_FILE).'$|', '/'.DIR_INDEX_PATH, $arrPage['url']); } unset($arrPage); @@ -294,15 +300,16 @@ public function getPageData($where = '', $arrVal = '') * date形式の文字列を W3C Datetime 形式に変換して出力する. * * @param date $date 変換する日付 + * * @return string */ public function date2W3CDatetime($date) { - $arr = array(); + $arr = []; // 正規表現で文字列を抽出 preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})/', $date, $arr); // :TODO: time zone も取得するべき... return sprintf('%04d-%02d-%02dT%02d:%02d:%02d+09:00', - $arr[1], $arr[2], $arr[3], $arr[4], $arr[5], $arr[6]); + $arr[1], $arr[2], $arr[3], $arr[4], $arr[5], $arr[6]); } } diff --git a/data/class/pages/abouts/LC_Page_Abouts.php b/data/class/pages/abouts/LC_Page_Abouts.php index 9d04a95e18..1771438d5d 100644 --- a/data/class/pages/abouts/LC_Page_Abouts.php +++ b/data/class/pages/abouts/LC_Page_Abouts.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * サイト概要のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Abouts extends LC_Page_Ex diff --git a/data/class/pages/admin/LC_Page_Admin.php b/data/class/pages/admin/LC_Page_Admin.php index ffd6b830eb..1625f75cf7 100644 --- a/data/class/pages/admin/LC_Page_Admin.php +++ b/data/class/pages/admin/LC_Page_Admin.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 管理者ログイン のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin extends LC_Page_Ex @@ -149,18 +148,18 @@ public function init() SC_Utils_Ex::sfIsSuccess(new SC_Session_Ex()); } - //IP制限チェック + // IP制限チェック $allow_hosts = unserialize(ADMIN_ALLOW_HOSTS); if (is_array($allow_hosts) && count($allow_hosts) > 0) { - if (array_search($_SERVER['REMOTE_ADDR'], $allow_hosts) === FALSE) { + if (array_search($_SERVER['REMOTE_ADDR'], $allow_hosts) === false) { SC_Utils_Ex::sfDispError(AUTH_ERROR); } } - //SSL制限チェック - if (ADMIN_FORCE_SSL == TRUE) { + // SSL制限チェック + if (ADMIN_FORCE_SSL == true) { if (SC_Utils_Ex::sfIsHTTPS() === false) { - SC_Response_Ex::sendRedirect($_SERVER['REQUEST_URI'], $_GET, FALSE, TRUE); + SC_Response_Ex::sendRedirect($_SERVER['REQUEST_URI'], $_GET, false, true); } } @@ -171,7 +170,7 @@ public function init() // スーパーフックポイントを実行. $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); - $objPlugin->doAction('LC_Page_preProcess', array($this)); + $objPlugin->doAction('LC_Page_preProcess', [$this]); // トランザクショントークンの検証と生成 $this->doValidToken(true); @@ -179,10 +178,10 @@ public function init() // ローカルフックポイントを実行 $parent_class_name = get_parent_class($this); - $objPlugin->doAction($parent_class_name . '_action_before', array($this)); - $class_name = get_class($this); + $objPlugin->doAction($parent_class_name.'_action_before', [$this]); + $class_name = static::class; if ($class_name != $parent_class_name) { - $objPlugin->doAction($class_name . '_action_before', array($this)); + $objPlugin->doAction($class_name.'_action_before', [$this]); } } @@ -205,17 +204,17 @@ public function sendResponse() $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(); // ローカルフックポイントを実行 $parent_class_name = get_parent_class($this); - $objPlugin->doAction($parent_class_name . '_action_after', array($this)); - $class_name = get_class($this); + $objPlugin->doAction($parent_class_name.'_action_after', [$this]); + $class_name = static::class; if ($class_name != $parent_class_name) { - $objPlugin->doAction($class_name . '_action_after', array($this)); + $objPlugin->doAction($class_name.'_action_after', [$this]); } // HeadNaviにpluginテンプレートを追加する. $objPlugin->setHeadNaviBlocs($this->arrPageLayout['HeadNavi']); // スーパーフックポイントを実行. - $objPlugin->doAction('LC_Page_process', array($this)); + $objPlugin->doAction('LC_Page_process', [$this]); $this->objDisplay->prepare($this, true); $this->objDisplay->response->write(); @@ -226,7 +225,7 @@ public function sendResponse() * * @deprecated 2.12.0 GC_Utils_Ex::gfPrintLog を使用すること */ - public function log($mess, $log_level='Info') + public function log($mess, $log_level = 'Info') { trigger_error('前方互換用メソッドが使用されました。', E_USER_WARNING); // ログレベル=Debugの場合は、DEBUG_MODEがtrueの場合のみログ出力する diff --git a/data/class/pages/admin/LC_Page_Admin_Home.php b/data/class/pages/admin/LC_Page_Admin_Home.php index e2fc418c6f..d4c165c77f 100644 --- a/data/class/pages/admin/LC_Page_Admin_Home.php +++ b/data/class/pages/admin/LC_Page_Admin_Home.php @@ -22,12 +22,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 管理画面ホーム のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Home extends LC_Page_Admin_Ex @@ -111,10 +110,10 @@ public function action() // 会員の累計ポイント $this->customer_point = $this->lfGetTotalCustomerPoint(); - //昨日のレビュー書き込み数 + // 昨日のレビュー書き込み数 $this->review_yesterday_cnt = $this->lfGetReviewYesterday(); - //レビュー書き込み非表示数 + // レビュー書き込み非表示数 $this->review_nondisp_cnt = $this->lfGetReviewNonDisp(); // 品切れ商品 @@ -134,7 +133,7 @@ public function action() */ public function lfGetPHPVersion() { - return 'PHP ' . phpversion(); + return 'PHP '.PHP_VERSION; } /** @@ -152,7 +151,7 @@ public function lfGetDBVersion() /** * 現在の会員数の取得 * - * @return integer 会員数 + * @return int 会員数 */ public function lfGetCustomerCnt() { @@ -168,7 +167,8 @@ public function lfGetCustomerCnt() * 昨日の売上データの取得 * * @param string $method 取得タイプ 件数:'COUNT' or 金額:'SUM' - * @return integer 結果数値 + * + * @return int 結果数値 */ public function lfGetOrderYesterday($method) { @@ -185,7 +185,8 @@ public function lfGetOrderYesterday($method) * 今月の売上データの取得 * * @param string $method 取得タイプ 件数:'COUNT' or 金額:'SUM' - * @return integer 結果数値 + * + * @return int 結果数値 */ public function lfGetOrderMonth($method) { @@ -196,13 +197,13 @@ public function lfGetOrderMonth($method) $dbFactory = SC_DB_DBFactory_Ex::getInstance(); $sql = $dbFactory->getOrderMonthSql($method); - return $objQuery->getOne($sql, array($month)); + return $objQuery->getOne($sql, [$month]); } /** * 会員の保持ポイント合計の取得 * - * @return integer 会員の保持ポイント合計 + * @return int 会員の保持ポイント合計 */ public function lfGetTotalCustomerPoint() { @@ -218,7 +219,7 @@ public function lfGetTotalCustomerPoint() /** * 昨日のレビュー書き込み数の取得 * - * @return integer 昨日のレビュー書き込み数 + * @return int 昨日のレビュー書き込み数 */ public function lfGetReviewYesterday() { @@ -234,7 +235,7 @@ public function lfGetReviewYesterday() /** * レビュー書き込み非表示数の取得 * - * @return integer レビュー書き込み非表示数 + * @return int レビュー書き込み非表示数 */ public function lfGetReviewNonDisp() { @@ -258,11 +259,11 @@ public function lfGetSoldOut() $cols = 'product_id, name'; $table = 'dtb_products'; $where = 'product_id IN (' - . 'SELECT product_id FROM dtb_products_class ' - . 'WHERE del_flg = 0 AND stock_unlimited = ? AND stock <= 0)' - . ' AND del_flg = 0'; + .'SELECT product_id FROM dtb_products_class ' + .'WHERE del_flg = 0 AND stock_unlimited = ? AND stock <= 0)' + .' AND del_flg = 0'; - return $objQuery->select($cols, $table, $where, array(UNLIMITED_FLG_LIMITED)); + return $objQuery->select($cols, $table, $where, [UNLIMITED_FLG_LIMITED]); } /** @@ -315,24 +316,28 @@ public function lfGetNewOrder() public function lfGetInfo() { // 更新情報の取得ON/OFF確認 - if (!ECCUBE_INFO) return array(); + if (!ECCUBE_INFO) { + return []; + } // パラメーター「UPDATE_HTTP」が空文字の場合、処理しない。 // XXX これと別に on/off を持たせるべきか。 - if (strlen(UPDATE_HTTP) == 0) return array(); + if (strlen(UPDATE_HTTP) == 0) { + return []; + } $query = ''; // サイト情報の送信可否設定 // XXX インストール時に問い合わせて送信可否設定を行うように設定すべきか。 // XXX (URLは強制送信すべきではないと思うが)バージョンは強制送信すべきか。 if (UPDATE_SEND_SITE_INFO === true) { - $query = '?site_url=' . HTTP_URL . '&eccube_version=' . ECCUBE_VERSION; + $query = '?site_url='.HTTP_URL.'&eccube_version='.ECCUBE_VERSION; } - $url = UPDATE_HTTP . $query; + $url = UPDATE_HTTP.$query; // タイムアウト時間設定 - $context = array('http' => array('timeout' => HTTP_REQUEST_TIMEOUT)); + $context = ['http' => ['timeout' => HTTP_REQUEST_TIMEOUT]]; $jsonStr = @file_get_contents($url, false, stream_context_create($context)); @@ -341,9 +346,9 @@ public function lfGetInfo() if (empty($arrTmpData)) { SC_Utils_Ex::sfErrorHeader('>> 更新情報の取得に失敗しました。'); - return array(); + return []; } - $arrInfo = array(); + $arrInfo = []; foreach ($arrTmpData as $objData) { $arrInfo[] = get_object_vars($objData); } diff --git a/data/class/pages/admin/LC_Page_Admin_Index.php b/data/class/pages/admin/LC_Page_Admin_Index.php index 40a8cb784e..1d95d08fec 100644 --- a/data/class/pages/admin/LC_Page_Admin_Index.php +++ b/data/class/pages/admin/LC_Page_Admin_Index.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 管理者ログイン のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Index extends LC_Page_Admin_Ex @@ -66,7 +65,7 @@ public function action() switch ($this->getMode()) { case 'login': - //ログイン処理 + // ログイン処理 $this->lfInitParam($objFormParam); $objFormParam->setParam($_POST); $objFormParam->trimParam(); @@ -95,12 +94,13 @@ public function action() * パラメーター情報の初期化 * * @param SC_FormParam_Ex $objFormParam フォームパラメータークラス + * * @return void */ public function lfInitParam(&$objFormParam) { - $objFormParam->addParam('ID', 'login_id', ID_MAX_LEN, '', array('EXIST_CHECK', 'GRAPH_CHECK' ,'MAX_LENGTH_CHECK')); - $objFormParam->addParam('PASSWORD', 'password', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('ID', 'login_id', ID_MAX_LEN, '', ['EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('PASSWORD', 'password', PASSWORD_MAX_LEN, '', ['EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK']); } /** @@ -109,6 +109,7 @@ public function lfInitParam(&$objFormParam) * TODO: ブルートフォースアタック対策チェックの実装 * * @param SC_FormParam_Ex $objFormParam フォームパラメータークラス + * * @return array $arrErr エラー配列 */ public function lfCheckError(&$objFormParam) @@ -132,16 +133,17 @@ public function lfCheckError(&$objFormParam) * * @param string $login_id ログインID文字列 * @param string $pass ログインパスワード文字列 - * @return boolean ログイン情報が有効な場合 true + * + * @return bool ログイン情報が有効な場合 true */ public function lfIsLoginMember($login_id, $pass) { $objQuery = SC_Query_Ex::getSingletonInstance(); - //パスワード、saltの取得 + // パスワード、saltの取得 $cols = 'password, salt'; $table = 'dtb_member'; $where = 'login_id = ? AND del_flg <> 1 AND work = 1'; - $arrData = $objQuery->getRow($cols, $table, $where, array($login_id)); + $arrData = $objQuery->getRow($cols, $table, $where, [$login_id]); if (SC_Utils_Ex::isBlank($arrData)) { return false; } @@ -157,16 +159,17 @@ public function lfIsLoginMember($login_id, $pass) * 管理者ログイン設定処理 * * @param string $login_id ログインID文字列 + * * @return void */ public function lfDoLogin($login_id) { $objQuery = SC_Query_Ex::getSingletonInstance(); - //メンバー情報取得 + // メンバー情報取得 $cols = 'member_id, authority, login_date, name'; $table = 'dtb_member'; $where = 'login_id = ?'; - $arrData = $objQuery->getRow($cols, $table, $where, array($login_id)); + $arrData = $objQuery->getRow($cols, $table, $where, [$login_id]); // セッション登録 $sid = $this->lfSetLoginSession($arrData['member_id'], $login_id, $arrData['authority'], $arrData['name'], $arrData['login_date']); // ログイン情報記録 @@ -176,11 +179,12 @@ public function lfDoLogin($login_id) /** * ログイン情報セッション登録 * - * @param integer $member_id メンバーID + * @param int $member_id メンバーID * @param string $login_id ログインID文字列 - * @param integer $authority 権限ID + * @param int $authority 権限ID * @param string $login_name ログイン表示名 * @param string $last_login 最終ログイン日時(YYYY/MM/DD HH:ii:ss形式) またはNULL + * * @return string $sid 設定したセッションのセッションID */ public function lfSetLoginSession($member_id, $login_id, $authority, $login_name, $last_login) @@ -209,26 +213,27 @@ public function lfSetLoginSession($member_id, $login_id, $authority, $login_name * ログイン情報の記録 * * @param string $sid セッションID - * @param integer $member_id メンバーID + * @param int $member_id メンバーID * @param string $login_id ログインID文字列 - * @param integer $authority 権限ID + * @param int $authority 権限ID * @param string $last_login 最終ログイン日時(YYYY/MM/DD HH:ii:ss形式) またはNULL + * * @return void */ public function lfSetLoginData($sid, $member_id, $login_id, $authority, $last_login) { // ログイン記録ログ出力 $str_log = "login: user=$login_id($member_id) auth=$authority " - . "lastlogin=$last_login sid=$sid"; + ."lastlogin=$last_login sid=$sid"; GC_Utils_Ex::gfPrintLog($str_log); // 最終ログイン日時更新 $objQuery = SC_Query_Ex::getSingletonInstance(); - $sqlval = array(); + $sqlval = []; $sqlval['login_date'] = date('Y-m-d H:i:s'); $table = 'dtb_member'; $where = 'member_id = ?'; - $objQuery->update($table, $sqlval, $where, array($member_id)); + $objQuery->update($table, $sqlval, $where, [$member_id]); } /** @@ -237,10 +242,11 @@ public function lfSetLoginData($sid, $member_id, $login_id, $authority, $last_lo * TODO: ブルートフォースアタック対策の実装 * * @param string $error_login_id ログイン失敗時に投入されたlogin_id文字列 + * * @return void */ public function lfSetIncorrectData($error_login_id) { - GC_Utils_Ex::gfPrintLog($error_login_id . ' password incorrect.'); + GC_Utils_Ex::gfPrintLog($error_login_id.' password incorrect.'); } } diff --git a/data/class/pages/admin/LC_Page_Admin_Logout.php b/data/class/pages/admin/LC_Page_Admin_Logout.php index 40961bb089..78676e2512 100644 --- a/data/class/pages/admin/LC_Page_Admin_Logout.php +++ b/data/class/pages/admin/LC_Page_Admin_Logout.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * ログアウト のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Logout extends LC_Page_Admin_Ex @@ -61,7 +60,7 @@ public function action() $this->lfDoLogout(); // ログイン画面に遷移 - SC_Response_Ex::sendRedirectFromUrlPath(ADMIN_DIR . DIR_INDEX_PATH); + SC_Response_Ex::sendRedirectFromUrlPath(ADMIN_DIR.DIR_INDEX_PATH); } /** diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis.php index 7d53a3645c..476042405b 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 店舗基本情報 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis extends LC_Page_Admin_Ex @@ -51,7 +50,7 @@ public function init() $this->tpl_maintitle = '基本情報管理'; $this->tpl_subtitle = 'SHOPマスター'; - //定休日用配列 + // 定休日用配列 $this->arrRegularHoliday[0] = '日'; $this->arrRegularHoliday[1] = '月'; $this->arrRegularHoliday[2] = '火'; @@ -85,7 +84,7 @@ public function action() $objFormParam->convParam(); $this->arrForm = $objFormParam->getHashArray(); - $this->tpl_onload = "eccube.checkLimit('downloadable_days', 'downloadable_days_unlimited', '" . DISABLED_RGB . "');"; + $this->tpl_onload = "eccube.checkLimit('downloadable_days', 'downloadable_days_unlimited', '".DISABLED_RGB."');"; switch ($this->getMode()) { case 'confirm': @@ -105,7 +104,8 @@ public function action() SC_Helper_DB_Ex::registerBasisData($arrData); $this->tpl_onload .= "window.alert('SHOPマスターの登録が完了しました。');"; - // breakはつけない + // breakはつけない + // no break default: $arrRet = SC_Helper_DB_Ex::getBasisDataFromDB(); $objFormParam->setParam($arrRet); @@ -142,51 +142,51 @@ public function lfInsertData($arrData) */ public function lfInitParam(&$objFormParam, $post) { - $objFormParam->addParam('会社名', 'company_name', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); - $objFormParam->addParam('会社名(フリガナ)', 'company_kana', STEXT_LEN, 'KVC', array('KANA_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('会社名', 'company_name', STEXT_LEN, 'KVa', ['MAX_LENGTH_CHECK']); + $objFormParam->addParam('会社名(フリガナ)', 'company_kana', STEXT_LEN, 'KVC', ['KANA_CHECK', 'MAX_LENGTH_CHECK']); - $objFormParam->addParam('店名', 'shop_name', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('店名(フリガナ)', 'shop_kana', STEXT_LEN, 'KVC', array('KANA_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('店名(英語表記)', 'shop_name_eng', MTEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('店名', 'shop_name', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('店名(フリガナ)', 'shop_kana', STEXT_LEN, 'KVC', ['KANA_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('店名(英語表記)', 'shop_name_eng', MTEXT_LEN, 'a', ['GRAPH_CHECK', 'MAX_LENGTH_CHECK']); // 郵便番号チェック - $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); - $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); + $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK']); + $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK']); // 所在地チェック - $objFormParam->addParam('都道府県', 'pref', '', 'n', array('EXIST_CHECK')); - $objFormParam->addParam('所在地1', 'addr01', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('所在地2', 'addr02', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('都道府県', 'pref', '', 'n', ['EXIST_CHECK']); + $objFormParam->addParam('所在地1', 'addr01', MTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('所在地2', 'addr02', MTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); // メールチェック - $objFormParam->addParam('商品注文受付メールアドレス', 'email01', null, 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); - $objFormParam->addParam('問い合わせ受付メールアドレス', 'email02', null, 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); - $objFormParam->addParam('メール送信元メールアドレス', 'email03', null, 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); - $objFormParam->addParam('送信エラー受付メールアドレス', 'email04', null, 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); + $objFormParam->addParam('商品注文受付メールアドレス', 'email01', null, 'a', ['EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK']); + $objFormParam->addParam('問い合わせ受付メールアドレス', 'email02', null, 'a', ['EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK']); + $objFormParam->addParam('メール送信元メールアドレス', 'email03', null, 'a', ['EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK']); + $objFormParam->addParam('送信エラー受付メールアドレス', 'email04', null, 'a', ['EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK']); // 電話番号 - $objFormParam->addParam('電話番号1', 'tel01', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('電話番号2', 'tel02', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('電話番号3', 'tel03', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('電話番号1', 'tel01', TEL_ITEM_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('電話番号2', 'tel02', TEL_ITEM_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('電話番号3', 'tel03', TEL_ITEM_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); // FAX番号 - $objFormParam->addParam('FAX番号1', 'fax01', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('FAX番号2', 'fax02', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('FAX番号3', 'fax03', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('FAX番号1', 'fax01', TEL_ITEM_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('FAX番号2', 'fax02', TEL_ITEM_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('FAX番号3', 'fax03', TEL_ITEM_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); // その他 - $objFormParam->addParam('送料無料条件', 'free_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('店舗営業時間', 'business_hour', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); + $objFormParam->addParam('送料無料条件', 'free_rule', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('店舗営業時間', 'business_hour', STEXT_LEN, 'KVa', ['MAX_LENGTH_CHECK']); - $objFormParam->addParam('取扱商品', 'good_traded', LLTEXT_LEN, '', array('MAX_LENGTH_CHECK')); - $objFormParam->addParam('メッセージ', 'message', LLTEXT_LEN, '', array('MAX_LENGTH_CHECK')); + $objFormParam->addParam('取扱商品', 'good_traded', LLTEXT_LEN, '', ['MAX_LENGTH_CHECK']); + $objFormParam->addParam('メッセージ', 'message', LLTEXT_LEN, '', ['MAX_LENGTH_CHECK']); if (!isset($post['downloadable_days_unlimited']) && $post['downloadable_days_unlimited'] != '1') { - $objFormParam->addParam('ダウンロード可能日数', 'downloadable_days', DOWNLOAD_DAYS_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('ダウンロード可能日数', 'downloadable_days', DOWNLOAD_DAYS_LEN, 'n', ['EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); } else { - $objFormParam->addParam('ダウンロード無制限', 'downloadable_days_unlimited', array('EXIST_CHECK')); + $objFormParam->addParam('ダウンロード無制限', 'downloadable_days_unlimited', ['EXIST_CHECK']); } - $objFormParam->addParam('緯度', 'latitude', STEXT_LEN, '', array('MAX_LENGTH_CHECK', 'NUM_POINT_CHECK')); - $objFormParam->addParam('軽度', 'longitude', STEXT_LEN, '', array('MAX_LENGTH_CHECK', 'NUM_POINT_CHECK')); + $objFormParam->addParam('緯度', 'latitude', STEXT_LEN, '', ['MAX_LENGTH_CHECK', 'NUM_POINT_CHECK']); + $objFormParam->addParam('軽度', 'longitude', STEXT_LEN, '', ['MAX_LENGTH_CHECK', 'NUM_POINT_CHECK']); - $objFormParam->addParam('定休日', 'regular_holiday_ids', INT_LEN, 'n', array('MAX_LENGTH_CHECK')); + $objFormParam->addParam('定休日', 'regular_holiday_ids', INT_LEN, 'n', ['MAX_LENGTH_CHECK']); } // 入力エラーチェック @@ -200,11 +200,11 @@ public function lfCheckError(&$objFormParam) $post = $objFormParam->getHashArray(); $objErr = new SC_CheckError_Ex($post); - $objErr->doFunc(array('郵便番号', 'zip01', 'zip02'), array('ALL_EXIST_CHECK')); + $objErr->doFunc(['郵便番号', 'zip01', 'zip02'], ['ALL_EXIST_CHECK']); // 電話番号チェック - $objErr->doFunc(array('TEL', 'tel01', 'tel02', 'tel03'), array('TEL_CHECK')); - $objErr->doFunc(array('FAX', 'fax01', 'fax02', 'fax03'), array('TEL_CHECK')); + $objErr->doFunc(['TEL', 'tel01', 'tel02', 'tel03'], ['TEL_CHECK']); + $objErr->doFunc(['FAX', 'fax01', 'fax02', 'fax03'], ['TEL_CHECK']); return array_merge((array) $arrErr, (array) $objErr->arrErr); } diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Delivery.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Delivery.php index b2a87770d6..9377fb360d 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Delivery.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Delivery.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 配送方法設定 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_Delivery extends LC_Page_Admin_Ex @@ -113,16 +112,17 @@ public function action() * * @param string $mode * @param SC_FormParam_Ex $objFormParam + * * @return array */ public function lfCheckError($mode, &$objFormParam) { - $arrErr = array(); + $arrErr = []; switch ($mode) { case 'delete': case 'up': case 'down': - $objFormParam->addParam('配送業者ID', 'deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('配送業者ID', 'deliv_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); $objFormParam->convParam(); diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php index b55eec511b..5204681acf 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_DeliveryInput.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 配送方法設定 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_DeliveryInput extends LC_Page_Admin_Ex @@ -104,27 +103,27 @@ public function lfInitParam($mode, &$objFormParam) switch ($mode) { case 'edit': - $objFormParam->addParam('配送業者ID', 'deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('配送業者名', 'name', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('名称', 'service_name', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('説明', 'remark', LLTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); - $objFormParam->addParam('伝票No.確認URL', 'confirm_url', URL_LEN, 'n', array('URL_CHECK', 'MAX_LENGTH_CHECK'), 'http://'); - $objFormParam->addParam('取扱商品種別', 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('取扱支払方法', 'payment_ids', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('配送業者ID', 'deliv_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('配送業者名', 'name', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('名称', 'service_name', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('説明', 'remark', LLTEXT_LEN, 'KVa', ['MAX_LENGTH_CHECK']); + $objFormParam->addParam('伝票No.確認URL', 'confirm_url', URL_LEN, 'n', ['URL_CHECK', 'MAX_LENGTH_CHECK'], 'http://'); + $objFormParam->addParam('取扱商品種別', 'product_type_id', INT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('取扱支払方法', 'payment_ids', INT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); for ($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) { - $objFormParam->addParam("お届け時間$cnt", "deliv_time$cnt", STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); + $objFormParam->addParam("お届け時間$cnt", "deliv_time$cnt", STEXT_LEN, 'KVa', ['MAX_LENGTH_CHECK']); } if (INPUT_DELIV_FEE) { for ($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) { - $objFormParam->addParam("配送料", "fee$cnt", PRICE_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); + $objFormParam->addParam('配送料', "fee$cnt", PRICE_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); } } break; case 'pre_edit': - $objFormParam->addParam('配送業者ID', 'deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('配送業者ID', 'deliv_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); break; default: @@ -151,7 +150,7 @@ public function lfRegistData($arrRet, $member_id) $sqlval['creator_id'] = $member_id; // お届け時間 - $sqlval['deliv_time'] = array(); + $sqlval['deliv_time'] = []; for ($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) { $keyname = "deliv_time$cnt"; if ($arrRet[$keyname] != '') { @@ -161,12 +160,12 @@ public function lfRegistData($arrRet, $member_id) // 配送料 if (INPUT_DELIV_FEE) { - $sqlval['deliv_fee'] = array(); + $sqlval['deliv_fee'] = []; // 配送料金の設定 for ($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) { $keyname = "fee$cnt"; if ($arrRet[$keyname] != '') { - $fee = array(); + $fee = []; $fee['fee_id'] = $cnt; $fee['fee'] = $arrRet[$keyname]; $fee['pref'] = $cnt; @@ -176,7 +175,7 @@ public function lfRegistData($arrRet, $member_id) } // 支払い方法 - $sqlval['payment_ids'] = array(); + $sqlval['payment_ids'] = []; foreach ($arrRet['payment_ids'] as $payment_id) { $sqlval['payment_ids'][] = $payment_id; } @@ -199,14 +198,14 @@ public function lfGetDelivData(&$objFormParam) $arrDeliv = $objDelivery->get($deliv_id); // お届け時間 - $deliv_times = array(); + $deliv_times = []; foreach ($arrDeliv['deliv_time'] as $value) { $deliv_times[]['deliv_time'] = $value; } $objFormParam->setParamList($deliv_times, 'deliv_time'); unset($arrDeliv['deliv_time']); // 配送料金 - $deliv_fee = array(); + $deliv_fee = []; foreach ($arrDeliv['deliv_fee'] as $value) { $deliv_fee[]['fee'] = $value['fee']; } @@ -223,7 +222,7 @@ public function lfGetDelivData(&$objFormParam) public function lfCheckError(&$objFormParam) { // 入力データを渡す。 - $arrRet = $objFormParam->getHashArray(); + $arrRet = $objFormParam->getHashArray(); $objErr = new SC_CheckError_Ex($arrRet); $objErr->arrErr = $objFormParam->checkError(); diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php index d90e16549b..aba3c8424a 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Holiday.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 定休日管理のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_Holiday extends LC_Page_Admin_Ex @@ -100,7 +99,7 @@ public function action() $arrParam = $objFormParam->getHashArray(); // 登録実行 $res_holiday_id = $this->doRegist($holiday_id, $arrParam, $objHoliday); - if ($res_holiday_id !== FALSE) { + if ($res_holiday_id !== false) { // 完了メッセージ $holiday_id = $res_holiday_id; $this->tpl_onload = "alert('登録が完了しました。');"; @@ -110,11 +109,11 @@ public function action() $this->tpl_holiday_id = $holiday_id; break; - // 削除 + // 削除 case 'delete': $objHoliday->delete($holiday_id); break; - // 編集前処理 + // 編集前処理 case 'pre_edit': // 編集項目を取得する。 $arrHolidayData = $objHoliday->get($holiday_id); @@ -147,9 +146,10 @@ public function action() /** * 登録処理を実行. * - * @param integer $holiday_id + * @param int $holiday_id * @param array $sqlval * @param SC_Helper_Holiday_Ex $objHoliday + * * @return multiple */ public function doRegist($holiday_id, $sqlval, SC_Helper_Holiday_Ex $objHoliday) @@ -169,16 +169,16 @@ public function lfInitParam($mode, &$objFormParam) switch ($mode) { case 'edit': case 'pre_edit': - $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK')); - $objFormParam->addParam('月', 'month', INT_LEN, 'n', array('SELECT_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK')); - $objFormParam->addParam('日', 'day', INT_LEN, 'n', array('SELECT_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK')); - $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('月', 'month', INT_LEN, 'n', ['SELECT_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('日', 'day', INT_LEN, 'n', ['SELECT_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); break; case 'delete': case 'down': case 'up': default: - $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('定休日ID', 'holiday_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); break; } } @@ -188,6 +188,7 @@ public function lfInitParam($mode, &$objFormParam) * * @param SC_FormParam_Ex $objFormParam * @param SC_Helper_Holiday_Ex $objHoliday + * * @return array */ public function lfCheckError(&$objFormParam, SC_Helper_Holiday_Ex &$objHoliday) diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php index 0ed60b882b..f2075b562e 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Kiyaku.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 会員規約設定 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_Kiyaku extends LC_Page_Admin_Ex @@ -96,7 +95,7 @@ public function action() $arrParam = $objFormParam->getHashArray(); // 登録実行 $res_kiyaku_id = $this->doRegist($kiyaku_id, $arrParam, $objKiyaku); - if ($res_kiyaku_id !== FALSE) { + if ($res_kiyaku_id !== false) { // 完了メッセージ $kiyaku_id = $res_kiyaku_id; $this->tpl_onload = "alert('登録が完了しました。');"; @@ -106,12 +105,12 @@ public function action() // 編集中の規約IDを渡す $this->tpl_kiyaku_id = $kiyaku_id; break; - // 削除 + // 削除 case 'delete': $objKiyaku->deleteKiyaku($kiyaku_id); break; - // 編集前処理 + // 編集前処理 case 'pre_edit': // 編集項目を取得する。 $arrKiyakuData = $objKiyaku->getKiyaku($kiyaku_id); @@ -148,9 +147,10 @@ public function action() /** * 登録処理を実行. * - * @param integer $kiyaku_id + * @param int $kiyaku_id * @param array $sqlval * @param SC_Helper_Kiyaku_Ex $objKiyaku + * * @return multiple */ public function doRegist($kiyaku_id, $sqlval, SC_Helper_Kiyaku_Ex &$objKiyaku) @@ -170,15 +170,15 @@ public function lfInitParam($mode, &$objFormParam) switch ($mode) { case 'confirm': case 'pre_edit': - $objFormParam->addParam('規約タイトル', 'kiyaku_title', SMTEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK')); - $objFormParam->addParam('規約内容', 'kiyaku_text', MLTEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK')); - $objFormParam->addParam('規約ID', 'kiyaku_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('規約タイトル', 'kiyaku_title', SMTEXT_LEN, 'KVa', ['EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('規約内容', 'kiyaku_text', MLTEXT_LEN, 'KVa', ['EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('規約ID', 'kiyaku_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); break; case 'delete': case 'down': case 'up': default: - $objFormParam->addParam('規約ID', 'kiyaku_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('規約ID', 'kiyaku_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); break; } } @@ -188,6 +188,7 @@ public function lfInitParam($mode, &$objFormParam) * * @param SC_Helper_Kiyaku_Ex $objKiyaku * @param SC_FormParam_Ex $objFormParam + * * @return array */ public function lfCheckError($objFormParam, SC_Helper_Kiyaku_Ex &$objKiyaku) diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php index 6a5c8d6c03..5817addb39 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * メール設定 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_Mail extends LC_Page_Admin_Ex @@ -72,7 +71,7 @@ public function action() $mode = $this->getMode(); - $post = array(); + $post = []; if (!empty($_POST)) { $objFormParam = new SC_FormParam_Ex(); $this->lfInitParam($mode, $objFormParam); @@ -87,32 +86,30 @@ public function action() switch ($mode) { case 'id_set': - $mailtemplate = $objMailtemplate->get($post['template_id']); - if ($mailtemplate) { - $this->arrForm = $mailtemplate; - } else { - $this->arrForm['template_id'] = $post['template_id']; - } + $mailtemplate = $objMailtemplate->get($post['template_id']); + if ($mailtemplate) { + $this->arrForm = $mailtemplate; + } else { + $this->arrForm['template_id'] = $post['template_id']; + } break; case 'regist': + $this->arrForm = $post; + if ($this->arrErr) { + // エラーメッセージ + $this->tpl_msg = 'エラーが発生しました'; + } else { + // 正常 + $this->lfRegistMailTemplate($this->arrForm, $_SESSION['member_id'], $objMailtemplate); - $this->arrForm = $post; - if ($this->arrErr) { - // エラーメッセージ - $this->tpl_msg = 'エラーが発生しました'; - } else { - // 正常 - $this->lfRegistMailTemplate($this->arrForm, $_SESSION['member_id'], $objMailtemplate); - - // 完了メッセージ - $this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');"; - unset($this->arrForm); - } + // 完了メッセージ + $this->tpl_onload = "window.alert('メール設定が完了しました。テンプレートを選択して内容をご確認ください。');"; + unset($this->arrForm); + } break; default: break; } - } public function lfRegistMailTemplate($post, $member_id, SC_Helper_Mailtemplate_Ex $objMailtemplate) @@ -129,12 +126,13 @@ public function lfInitParam($mode, &$objFormParam) { switch ($mode) { case 'regist': - $objFormParam->addParam('メールタイトル', 'subject', MTEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK')); - $objFormParam->addParam('ヘッダー', 'header', LTEXT_LEN, 'KVa', array('SPTAB_CHECK','MAX_LENGTH_CHECK')); - $objFormParam->addParam('フッター', 'footer', LTEXT_LEN, 'KVa', array('SPTAB_CHECK','MAX_LENGTH_CHECK')); - $objFormParam->addParam('テンプレート', 'template_id', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('メールタイトル', 'subject', MTEXT_LEN, 'KVa', ['EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('ヘッダー', 'header', LTEXT_LEN, 'KVa', ['SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('フッター', 'footer', LTEXT_LEN, 'KVa', ['SPTAB_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('テンプレート', 'template_id', INT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + // no break case 'id_set': - $objFormParam->addParam('テンプレート', 'template_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('テンプレート', 'template_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); break; default: break; diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Payment.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Payment.php index cf6f9ed250..7615622205 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Payment.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Payment.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 支払方法設定 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_Payment extends LC_Page_Admin_Ex @@ -68,10 +67,10 @@ public function process() public function action() { $objPayment = new SC_Helper_Payment_Ex(); - $post = array(); + $post = []; if (!empty($_POST)) { $objFormParam = new SC_FormParam_Ex(); - $objFormParam->addParam('支払方法ID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('支払方法ID', 'payment_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); $objFormParam->setParam($_POST); $objFormParam->convParam(); diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_PaymentInput.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_PaymentInput.php index 81526a1324..b1c0b27020 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_PaymentInput.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_PaymentInput.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 支払方法設定 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_PaymentInput extends LC_Page_Admin_Ex @@ -103,7 +102,7 @@ public function action() } $this->tpl_payment_id = $post['payment_id']; break; - // 画像のアップロード + // 画像のアップロード case 'upload_image': $objFormParam->setParam($_REQUEST); $objFormParam->convParam(); @@ -114,7 +113,7 @@ public function action() $this->arrErr[$post['image_key']] = $this->objUpFile->makeTempFile($post['image_key']); $this->tpl_payment_id = $post['payment_id']; break; - // 画像の削除 + // 画像の削除 case 'delete_image': $objFormParam->setParam($_REQUEST); $objFormParam->convParam(); @@ -134,10 +133,10 @@ public function action() if (count($this->arrErr) == 0) { $arrRet = $objPayment->get($post['payment_id']); - $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); $objFormParam->addParam('固定', 'fix'); $objFormParam->setParam($arrRet); @@ -161,7 +160,7 @@ public function action() /* ファイル情報の初期化 */ public function lfInitFile() { - $this->objUpFile->addFile('ロゴ画像', 'payment_image', array('gif','jpeg','jpg','png'), IMAGE_SIZE, false); + $this->objUpFile->addFile('ロゴ画像', 'payment_image', ['gif', 'jpeg', 'jpg', 'png'], IMAGE_SIZE, false); return $this->objUpFile; } @@ -176,36 +175,36 @@ public function lfInitParam($mode, &$objFormParam) { switch ($mode) { case 'edit': - $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); $objFormParam->addParam('固定', 'fix'); - $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('課金フラグ', 'charge_flg', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('課金フラグ', 'charge_flg', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); break; case 'upload_image': case 'delete_image': - $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); $objFormParam->addParam('固定', 'fix'); - $objFormParam->addParam('画像キー', 'image_key', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('画像キー', 'image_key', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); break; case 'pre_edit': - $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('課金フラグ', 'charge_flg', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('課金フラグ', 'charge_flg', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); break; default: - $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); $objFormParam->addParam('固定', 'fix'); break; @@ -248,22 +247,22 @@ public function lfCheckError($post, $objFormParam, SC_Helper_Payment_Ex $objPaym } // 入力データを渡す。 - $arrRet = $objFormParam->getHashArray(); + $arrRet = $objFormParam->getHashArray(); $objErr = new SC_CheckError_Ex($arrRet); $objErr->arrErr = $objFormParam->checkError(); // 利用条件(下限)チェック - if ($arrRet['rule_max'] < $arrPaymentData['rule_min'] and $arrPaymentData['rule_min'] != '') { - $objErr->arrErr['rule'] = '利用条件(下限)は' . $arrPaymentData['rule_min'] .'円以上にしてください。
'; + if ($arrRet['rule_max'] < $arrPaymentData['rule_min'] && $arrPaymentData['rule_min'] != '') { + $objErr->arrErr['rule'] = '利用条件(下限)は'.$arrPaymentData['rule_min'].'円以上にしてください。
'; } // 利用条件(上限)チェック - if ($arrRet['upper_rule'] > $arrPaymentData['upper_rule_max'] and $arrPaymentData['upper_rule_max'] != '') { - $objErr->arrErr['upper_rule'] = '利用条件(上限)は' . $arrPaymentData['upper_rule_max'] .'円以下にしてください。
'; + if ($arrRet['upper_rule'] > $arrPaymentData['upper_rule_max'] && $arrPaymentData['upper_rule_max'] != '') { + $objErr->arrErr['upper_rule'] = '利用条件(上限)は'.$arrPaymentData['upper_rule_max'].'円以下にしてください。
'; } // 利用条件チェック - $objErr->doFunc(array('利用条件(~円以上)', '利用条件(~円以下)', 'rule_max', 'upper_rule'), array('GREATER_CHECK')); + $objErr->doFunc(['利用条件(~円以上)', '利用条件(~円以下)', 'rule_max', 'upper_rule'], ['GREATER_CHECK']); return $objErr->arrErr; } diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php index eb74e99b9e..f0923ad1e1 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * ポイント設定 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_Point extends LC_Page_Admin_Ex @@ -106,8 +105,8 @@ public function action() */ public function lfInitParam(&$objFormParam) { - $objFormParam->addParam('ポイント付与率', 'point_rate', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); - $objFormParam->addParam('会員登録時付与ポイント', 'welcome_point', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); + $objFormParam->addParam('ポイント付与率', 'point_rate', PERCENTAGE_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('会員登録時付与ポイント', 'welcome_point', INT_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); } /** diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tax.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tax.php index 319a93f08c..6ca0dcf7c7 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tax.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tax.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 税率設定 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_Tax extends LC_Page_Admin_Ex @@ -57,22 +56,21 @@ public function init() $this->arrPref = $masterData->getMasterData('mtb_pref'); $this->arrTAXCALCRULE = $masterData->getMasterData('mtb_taxrule'); - //適用時刻の項目値設定 + // 適用時刻の項目値設定 $this->objDate = new SC_Date_Ex(); - //適用時間の年を、「現在年~現在年+2」の範囲に設定 - $arrYear = array(); - for ($year=date("Y"); $year<=date("Y") + 2;$year++) { + // 適用時間の年を、「現在年~現在年+2」の範囲に設定 + $arrYear = []; + for ($year = date('Y'); $year <= date('Y') + 2; $year++) { $arrYear[$year] = $year; } $this->arrYear = $arrYear; - $arrMinutes = array(); - for ($minutes=0; $minutes< 60; $minutes++) { + $arrMinutes = []; + for ($minutes = 0; $minutes < 60; $minutes++) { $arrMinutes[$minutes] = $minutes; } $this->arrMinutes = $arrMinutes; - $this->arrEnable = array( '1' => '有効', '0' => '無効'); - + $this->arrEnable = ['1' => '有効', '0' => '無効']; } /** @@ -105,7 +103,7 @@ public function action() // POST値の入力文字変換 $objFormParam->convParam(); - //tax_rule_idを変数にセット + // tax_rule_idを変数にセット $tax_rule_id = $objFormParam->getValue('tax_rule_id'); // モードによる処理切り替え @@ -128,7 +126,7 @@ public function action() break; - // 編集処理 + // 編集処理 case 'edit': // エラーチェック $this->arrErr = $this->lfCheckError($objFormParam, $objTaxRule); @@ -138,7 +136,7 @@ public function action() $arrParam = $objFormParam->getHashArray(); // 登録実行 $res_tax_rule_id = $this->doRegist($tax_rule_id, $arrParam, $objTaxRule); - if ($res_tax_rule_id !== FALSE) { + if ($res_tax_rule_id !== false) { // 完了メッセージ $this->tpl_onload = "alert('登録が完了しました。');"; @@ -152,16 +150,16 @@ public function action() break; - // 編集前処理 + // 編集前処理 case 'pre_edit': $TaxRule = $objTaxRule->getTaxRuleData($tax_rule_id); - $tmp = explode(" ", $TaxRule['apply_date']); - $tmp_ymd = array_map("intval",explode('-', $tmp[0])); + $tmp = explode(' ', $TaxRule['apply_date']); + $tmp_ymd = array_map('intval', explode('-', $tmp[0])); $TaxRule['apply_date_year'] = $tmp_ymd[0]; $TaxRule['apply_date_month'] = $tmp_ymd[1]; $TaxRule['apply_date_day'] = $tmp_ymd[2]; - $tmp_hm = array_map("intval",explode(":", $tmp[1])); + $tmp_hm = array_map('intval', explode(':', $tmp[1])); $TaxRule['apply_date_hour'] = $tmp_hm[0]; $TaxRule['apply_date_minutes'] = $tmp_hm[1]; @@ -171,7 +169,7 @@ public function action() $this->tpl_tax_rule_id = $tax_rule_id; break; - // 削除 + // 削除 case 'delete': $objTaxRule->deleteTaxRuleData($tax_rule_id); @@ -193,39 +191,41 @@ public function action() * パラメーター情報の初期化を行う. * * @param SC_FormParam $objFormParam SC_FormParam インスタンス + * * @return void */ public function lfInitParam(&$objFormParam) { - $objFormParam->addParam('商品個別 税率設定機能', 'product_tax_flg', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'), OPTION_PRODUCT_TAX_RULE); - $objFormParam->addParam('税規約ID', 'tax_rule_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('消費税率', 'tax_rate', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('課税規則', 'calc_rule', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('商品個別 税率設定機能', 'product_tax_flg', INT_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'], OPTION_PRODUCT_TAX_RULE); + $objFormParam->addParam('税規約ID', 'tax_rule_id', INT_LEN, 'n', ['NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('消費税率', 'tax_rate', PERCENTAGE_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('課税規則', 'calc_rule', PERCENTAGE_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK']); // 適用日時 - $objFormParam->addParam('適用年', 'apply_date_year', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); - $objFormParam->addParam('適用月', 'apply_date_month', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); - $objFormParam->addParam('適用日', 'apply_date_day', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); - $objFormParam->addParam('適用時', 'apply_date_hour', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); - $objFormParam->addParam('適用分', 'apply_date_minutes', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); + $objFormParam->addParam('適用年', 'apply_date_year', INT_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('適用月', 'apply_date_month', INT_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('適用日', 'apply_date_day', INT_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('適用時', 'apply_date_hour', INT_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('適用分', 'apply_date_minutes', INT_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); } /** * 登録処理を実行. * - * @param integer $tax_rule_id + * @param int $tax_rule_id * @param SC_Helper_TaxRule_Ex $objTaxRule + * * @return multiple */ public function doRegist($tax_rule_id, $arrParam, SC_Helper_TaxRule_Ex $objTaxRule) { $apply_date = SC_Utils_Ex::sfGetTimestampistime( - $arrParam['apply_date_year'], - sprintf("%02d", $arrParam['apply_date_month']), - sprintf("%02d", $arrParam['apply_date_day']), - sprintf("%02d", $arrParam['apply_date_hour']), - sprintf("%02d", $arrParam['apply_date_minutes']) - ); + $arrParam['apply_date_year'], + sprintf('%02d', $arrParam['apply_date_month']), + sprintf('%02d', $arrParam['apply_date_day']), + sprintf('%02d', $arrParam['apply_date_hour']), + sprintf('%02d', $arrParam['apply_date_minutes']) + ); $calc_rule = $arrParam['calc_rule']; $tax_rate = $arrParam['tax_rate']; @@ -237,24 +237,25 @@ public function doRegist($tax_rule_id, $arrParam, SC_Helper_TaxRule_Ex $objTaxRu * 共通設定の登録処理を実行. * * @param array $arrParam - * @return integer + * + * @return int */ public function doParamRegist($arrParam) { - $arrData = array(); + $arrData = []; foreach ($arrParam as $key => $val) { switch ($key) { - case 'product_tax_flg': - $arrData['OPTION_PRODUCT_TAX_RULE'] = $val; - break; - default: - } + case 'product_tax_flg': + $arrData['OPTION_PRODUCT_TAX_RULE'] = $val; + break; + default: + } } $masterData = new SC_DB_MasterData_Ex(); // DBのデータを更新 - $res = $masterData->updateMasterData('mtb_constants', array(), $arrData); + $res = $masterData->updateMasterData('mtb_constants', [], $arrData); // キャッシュを生成 - $masterData->createCache('mtb_constants', array(), true, array('id', 'remarks')); + $masterData->createCache('mtb_constants', [], true, ['id', 'remarks']); return $res; } @@ -263,6 +264,7 @@ public function doParamRegist($arrParam) * 入力エラーチェック. * * @param SC_FormParam $objFormParam + * * @return array $objErr->arrErr エラー内容 */ public function lfCheckError(&$objFormParam, SC_Helper_TaxRule_Ex &$objTaxRule) @@ -282,15 +284,15 @@ public function lfCheckError(&$objFormParam, SC_Helper_TaxRule_Ex &$objTaxRule) } // 適用日時チェック - $objErr->doFunc(array('適用日時', 'apply_date_year', 'apply_date_month', 'apply_date_day'), array('CHECK_DATE')); + $objErr->doFunc(['適用日時', 'apply_date_year', 'apply_date_month', 'apply_date_day'], ['CHECK_DATE']); if (SC_Utils_Ex::isBlank($objErr->arrErr['apply_date_year']) && $arrForm['tax_rule_id'] != '0') { $apply_date = SC_Utils_Ex::sfGetTimestampistime( - $arrForm['apply_date_year'], - sprintf("%02d", $arrForm['apply_date_month']), - sprintf("%02d", $arrForm['apply_date_day']), - sprintf("%02d", $arrForm['apply_date_hour']), - sprintf("%02d", $arrForm['apply_date_minutes']) - ); + $arrForm['apply_date_year'], + sprintf('%02d', $arrForm['apply_date_month']), + sprintf('%02d', $arrForm['apply_date_day']), + sprintf('%02d', $arrForm['apply_date_hour']), + sprintf('%02d', $arrForm['apply_date_minutes']) + ); // 税規約情報読み込み $arrTaxRuleByTime = $objTaxRule->getTaxRuleByTime($apply_date); diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php index aaa78c366a..5c33113fef 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_Tradelaw.php @@ -21,12 +21,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /** * 特定商取引法 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_Tradelaw extends LC_Page_Admin_Ex @@ -107,27 +106,27 @@ public function action() */ public function lfInitParam(&$objFormParam) { - $objFormParam->addParam('販売業者', 'law_company', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('運営責任者', 'law_manager', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('郵便番号1', 'law_zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); - $objFormParam->addParam('郵便番号2', 'law_zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); - $objFormParam->addParam('都道府県', 'law_pref', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); - $objFormParam->addParam('所在地1', 'law_addr01', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('所在地2', 'law_addr02', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('電話番号1', 'law_tel01', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK' ,'NUM_CHECK')); - $objFormParam->addParam('電話番号2', 'law_tel02', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK' ,'NUM_CHECK')); - $objFormParam->addParam('電話番号3', 'law_tel03', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK' ,'NUM_CHECK')); - $objFormParam->addParam('FAX番号1', 'law_fax01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); - $objFormParam->addParam('FAX番号2', 'law_fax02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); - $objFormParam->addParam('FAX番号3', 'law_fax03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); - $objFormParam->addParam('メールアドレス', 'law_email', null, 'KVa', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); - $objFormParam->addParam('URL', 'law_url', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'URL_CHECK')); - $objFormParam->addParam('必要料金', 'law_term01', MLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('注文方法', 'law_term02', MLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('支払方法', 'law_term03', MLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('支払期限', 'law_term04', MLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('引き渡し時期', 'law_term05', MLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); - $objFormParam->addParam('返品・交換について', 'law_term06', MLTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); + $objFormParam->addParam('販売業者', 'law_company', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('運営責任者', 'law_manager', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('郵便番号1', 'law_zip01', ZIP01_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK']); + $objFormParam->addParam('郵便番号2', 'law_zip02', ZIP02_LEN, 'n', ['EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK']); + $objFormParam->addParam('都道府県', 'law_pref', INT_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('所在地1', 'law_addr01', MTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('所在地2', 'law_addr02', MTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('電話番号1', 'law_tel01', TEL_ITEM_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('電話番号2', 'law_tel02', TEL_ITEM_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('電話番号3', 'law_tel03', TEL_ITEM_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('FAX番号1', 'law_fax01', TEL_ITEM_LEN, 'n', ['MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('FAX番号2', 'law_fax02', TEL_ITEM_LEN, 'n', ['MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('FAX番号3', 'law_fax03', TEL_ITEM_LEN, 'n', ['MAX_LENGTH_CHECK', 'NUM_CHECK']); + $objFormParam->addParam('メールアドレス', 'law_email', null, 'KVa', ['EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK']); + $objFormParam->addParam('URL', 'law_url', STEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'URL_CHECK']); + $objFormParam->addParam('必要料金', 'law_term01', MLTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('注文方法', 'law_term02', MLTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('支払方法', 'law_term03', MLTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('支払期限', 'law_term04', MLTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('引き渡し時期', 'law_term05', MLTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); + $objFormParam->addParam('返品・交換について', 'law_term06', MLTEXT_LEN, 'KVa', ['EXIST_CHECK', 'MAX_LENGTH_CHECK']); } /** @@ -154,14 +153,14 @@ public function lfInsertData($sqlval) public function lfCheckError(&$objFormParam) { // 入力データを渡す。 - $arrRet = $objFormParam->getHashArray(); + $arrRet = $objFormParam->getHashArray(); $objErr = new SC_CheckError_Ex($arrRet); $objErr->arrErr = $objFormParam->checkError(); // 電話番号チェック - $objErr->doFunc(array('TEL', 'law_tel01', 'law_tel02', 'law_tel03'), array('TEL_CHECK')); - $objErr->doFunc(array('FAX', 'law_fax01', 'law_fax02', 'law_fax03'), array('TEL_CHECK')); - $objErr->doFunc(array('郵便番号', 'law_zip01', 'law_zip02'), array('ALL_EXIST_CHECK')); + $objErr->doFunc(['TEL', 'law_tel01', 'law_tel02', 'law_tel03'], ['TEL_CHECK']); + $objErr->doFunc(['FAX', 'law_fax01', 'law_fax02', 'law_fax03'], ['TEL_CHECK']); + $objErr->doFunc(['郵便番号', 'law_zip01', 'law_zip02'], ['ALL_EXIST_CHECK']); return $objErr->arrErr; } diff --git a/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php b/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php index 279ee72a1f..c8852cfc1c 100644 --- a/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php +++ b/data/class/pages/admin/basis/LC_Page_Admin_Basis_ZipInstall.php @@ -21,24 +21,23 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -/** CSV ファイルの最大行数 */ +/* CSV ファイルの最大行数 */ define('ZIP_CSV_LINE_MAX', 8192); -/** 画像の表示数量 */ +/* 画像の表示数量 */ define('IMAGE_MAX', 680); -/** 郵便番号CSV ファイルのパス */ -define('ZIP_CSV_REALFILE', DATA_REALDIR . 'downloads/KEN_ALL.CSV'); +/* 郵便番号CSV ファイルのパス */ +define('ZIP_CSV_REALFILE', DATA_REALDIR.'downloads/KEN_ALL.CSV'); -/** UTF-8 変換済みの郵便番号CSV ファイルのパス */ -define('ZIP_CSV_UTF8_REALFILE', DATA_REALDIR . 'downloads/KEN_ALL_utf-8.CSV'); +/* UTF-8 変換済みの郵便番号CSV ファイルのパス */ +define('ZIP_CSV_UTF8_REALFILE', DATA_REALDIR.'downloads/KEN_ALL_utf-8.CSV'); /** * 郵便番号DB登録 のページクラス. * - * @package Page * @author EC-CUBE CO.,LTD. + * * @version $Id$ */ class LC_Page_Admin_Basis_ZipInstall extends LC_Page_Admin_Ex @@ -77,8 +76,8 @@ public function init() $this->tpl_mainno = 'basis'; $this->tpl_mode = $this->getMode(); - $this->exec = (boolean) $_GET['exec']; - $this->zip_csv_temp_realfile = DATA_REALDIR . 'downloads/tmp/ken_all.zip'; + $this->exec = (bool) $_GET['exec']; + $this->zip_csv_temp_realfile = DATA_REALDIR.'downloads/tmp/ken_all.zip'; } /** @@ -119,7 +118,7 @@ public function action() case 'auto': $this->lfAutoCommitZip(); break; - // DB手動登録 + // DB手動登録 case 'manual': $this->insertMtbZip($this->arrForm['startRowNum']); break; @@ -139,7 +138,7 @@ public function action() $this->tpl_mode = null; break; - // 郵便番号CSV更新 + // 郵便番号CSV更新 case 'update_csv': $this->lfDownloadZipFileFromJp(); $this->lfExtractZipFile(); @@ -148,8 +147,8 @@ public function action() $this->tpl_mode = null; break; - // 自動登録時の郵便番号CSV更新 - // XXX iframe内にエラー表示しない様、ここでlfDownloadZipFileFromJp()を呼ぶ。 + // 自動登録時の郵便番号CSV更新 + // XXX iframe内にエラー表示しない様、ここでlfDownloadZipFileFromJp()を呼ぶ。 case 'auto': if (!$this->tpl_skip_update_csv) { $this->lfDownloadZipFileFromJp(); @@ -199,12 +198,13 @@ public function lfDeleteZip() * パラメーター情報の初期化 * * @param SC_FormParam_Ex $objFormParam + * * @return void */ public function lfInitParam($tpl_mode, &$objFormParam) { if ($tpl_mode == 'manual') { - $objFormParam->addParam('開始行', 'startRowNum', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); + $objFormParam->addParam('開始行', 'startRowNum', INT_LEN, 'n', ['EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK']); } } @@ -217,12 +217,10 @@ public function insertMtbZip($start = 1) { $objQuery = SC_Query_Ex::getSingletonInstance(); - $img_path = USER_URL . USER_PACKAGE_DIR . 'admin/img/basis/'; // 画像パスは admin 固定 - - ?> + $img_path = USER_URL.USER_PACKAGE_DIR.'admin/img/basis/'; // 画像パスは admin 固定?> - +

DB 登録進捗状況

@@ -231,13 +229,13 @@ public function insertMtbZip($start = 1) // 一部のIEは256バイト以上受け取ってから表示を開始する。 SC_Utils_Ex::sfFlush(true); - echo '
'; - echo ''; + echo '
'; + echo ''; SC_Utils_Ex::sfFlush(); // 画像を一個表示する件数を求める。 $line_all = $this->countZipCsv(); - $disp_line = intval($line_all / IMAGE_MAX); + $disp_line = (int) ($line_all / IMAGE_MAX); /** 現在行(CSV形式。空行は除く。) */ $cntCurrentLine = 0; @@ -247,14 +245,16 @@ public function insertMtbZip($start = 1) $fp = $this->openZipCsv(); if (!$fp) { - trigger_error(ZIP_CSV_UTF8_REALFILE . ' の読み込みに失敗しました。', E_USER_ERROR); + trigger_error(ZIP_CSV_UTF8_REALFILE.' の読み込みに失敗しました。', E_USER_ERROR); } while (!feof($fp)) { $arrCSV = fgetcsv($fp, ZIP_CSV_LINE_MAX); - if (empty($arrCSV)) continue; + if (empty($arrCSV)) { + continue; + } $cntCurrentLine++; if ($cntCurrentLine >= $start) { - $sqlval = array(); + $sqlval = []; $sqlval['zip_id'] = $cntCurrentLine; $sqlval['zipcode'] = $arrCSV[2]; $sqlval['state'] = $arrCSV[6]; @@ -266,7 +266,7 @@ public function insertMtbZip($start = 1) // $disp_line件ごとに進捗表示する if ($cntCurrentLine % $disp_line == 0 && $img_cnt < IMAGE_MAX) { - echo ''; + echo ''; SC_Utils_Ex::sfFlush(); $img_cnt++; } @@ -274,9 +274,7 @@ public function insertMtbZip($start = 1) } fclose($fp); - echo ''; - - ?> + echo ''; ?>