/**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param BaseApplication $app An Application instance
  */
 public function register(BaseApplication $app)
 {
     // PEAR
     $app['smarty'] = function () {
         return new \Smarty();
     };
     $app['mobile.detect'] = function () {
         return new \Mobile_Detect();
     };
     $app['pear.archive.tar'] = $app->protect(function ($p_tarname, $p_compress = null) {
         return new \Archive_Tar($p_tarname, $p_compress);
     });
     $app['pear.cache.lite'] = $app->protect(function ($options = array()) {
         return new \Cache_Lite($options);
     });
     $app['pear.calendar.month.weekdays'] = $app->protect(function ($y, $m, $firstDay = null) {
         return new \Calendar_Month_Weekdays($y, $m, $firstDay);
     });
     $app['pear.http.request'] = $app->protect(function ($url = '', $params = array()) {
         return new \HTTP_Request($url, $params);
     });
     $app['pear.mail'] = $app->protect(function ($driver, $params = array()) {
         return \Mail::factory($driver, $params);
     });
     $app['pear.net.user_agent.mobile'] = $app->protect(function ($userAgent = null) {
         return \Net_UserAgent_Mobile::singleton($userAgent);
     });
     $app['pear.net.url'] = $app->protect(function ($url = null, $useBrackets = true) {
         return new \Net_URL($url, $useBrackets);
     });
     $app['pear.services.json'] = $app->protect(function ($use = 0) {
         return new \Services_JSON($use);
     });
     $app['pear.text.password'] = $app->protect(function ($length = 10, $type = 'pronounceable', $chars = '') {
         return \Text_Password::create($length, $type, $chars);
     });
     $app['pear.xml.serializer'] = $app->protect(function ($options = null) {
         return new \XML_Serializer($options);
     });
     // framework
     $app['eccube.cart_session'] = $app->protect(function ($cartKey = 'cart') {
         return new \Eccube\Framework\CartSession($cartKey);
     });
     $app['eccube.customer'] = function () {
         return new \Eccube\Framework\Customer();
     };
     $app['eccube.customer_list'] = $app->protect(function ($array, $mode = '') {
         return new \Eccube\Framework\CustomerList($array, $mode);
     });
     $app['eccube.cookie'] = $app->protect(function ($day = COOKIE_EXPIRE) {
         return new \Eccube\Framework\Cookie($day);
     });
     $app['eccube.check_error'] = $app->protect(function ($array = '') {
         return new \Eccube\Framework\CheckError($array);
     });
     $app['eccube.date'] = $app->protect(function ($start_year = '', $end_year = '') {
         return new \Eccube\Framework\Date($start_year, $end_year);
     });
     $app['eccube.display'] = $app->protect(function ($hasPrevURL = true) {
         return new \Eccube\Framework\Display($hasPrevURL);
     });
     $app['eccube.form_param'] = function () {
         return new \Eccube\Framework\FormParam();
     };
     $app['eccube.page_navi'] = $app->protect(function ($now_page, $all_row, $page_row, $func_name, $navi_max = NAVI_PMAX, $urlParam = '', $display_number = true) {
         return new \Eccube\Framework\PageNavi($now_page, $all_row, $page_row, $func_name, $navi_max, $urlParam, $display_number);
     });
     $app['eccube.product'] = $app->protect(function () {
         return new \Eccube\Framework\Product();
     });
     $app['eccube.response'] = $app->protect(function () {
         return new \Eccube\Framework\Response();
     });
     $app['eccube.query'] = $app->protect(function ($dsn = '', $force_run = false, $new = false) {
         return \Eccube\Framework\Query::getSingletonInstance($dsn, $force_run, $new);
     });
     $app['eccube.site_session'] = $app->share(function () {
         return new \Eccube\Framework\SiteSession();
     });
     $app['eccube.sendmail'] = $app->protect(function () {
         return new \Eccube\Framework\Sendmail();
     });
     // db
     $app['eccube.db.factory'] = $app->protect(function ($db_type = DB_TYPE) {
         return \Eccube\Framework\DB\DBFactory::getInstance($db_type);
     });
     $app['eccube.db.master_data'] = $app->share(function () {
         return new \Eccube\Framework\DB\MasterData();
     });
     // graph
     $app['eccube.graph.bar'] = $app->protect(function ($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) {
         return new \Eccube\Framework\Graph\BarGraph($bgw, $bgh, $left, $top, $area_width, $area_height);
     });
     $app['eccube.graph.line'] = $app->protect(function ($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) {
         return new \Eccube\Framework\Graph\LineGraph($bgw, $bgh, $left, $top, $area_width, $area_height);
     });
     $app['eccube.graph.pie'] = $app->protect(function ($bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = PIE_LEFT, $top = PIE_TOP) {
         return new \Eccube\Framework\Graph\PieGraph($bgw, $bgh, $left, $top);
     });
     // helper
     $app['eccube.helper.address'] = $app->share(function () {
         return new \Eccube\Framework\Helper\AddressHelper();
     });
     $app['eccube.helper.best_products'] = $app->share(function () {
         return new \Eccube\Framework\Helper\BestProductsHelper();
     });
     $app['eccube.helper.bloc'] = $app->protect(function ($devide_type_id = DEVICE_TYPE_PC) {
         return new \Eccube\Framework\Helper\BlocHelper($devide_type_id);
     });
     $app['eccube.helper.category'] = $app->protect(function ($count_check = false) {
         return new \Eccube\Framework\Helper\CategoryHelper($count_check);
     });
     $app['eccube.helper.csv'] = function () {
         return new \Eccube\Framework\Helper\CsvHelper();
     };
     $app['eccube.helper.customer'] = $app->share(function () {
         return new \Eccube\Framework\Helper\CustomerHelper();
     });
     $app['eccube.helper.db'] = $app->share(function () {
         return new \Eccube\Framework\Helper\DbHelper();
     });
     $app['eccube.helper.delivery'] = $app->share(function () {
         return new \Eccube\Framework\Helper\DeliveryHelper();
     });
     $app['eccube.helper.file_manager'] = $app->share(function () {
         return new \Eccube\Framework\Helper\FileManagerHelper();
     });
     $app['eccube.helper.fpdi'] = $app->protect(function ($orientation = 'P', $unit = 'mm', $size = 'A4') {
         return new \Eccube\Framework\Helper\FpdiHelper($orientation, $unit, $size);
     });
     $app['eccube.helper.holiday'] = $app->share(function () {
         return new \Eccube\Framework\Helper\HolidayHelper();
     });
     $app['eccube.helper.kiyaku'] = $app->share(function () {
         return new \Eccube\Framework\Helper\KiyakuHelper();
     });
     $app['eccube.helper.mail'] = $app->share(function () {
         return new \Eccube\Framework\Helper\MailHelper();
     });
     $app['eccube.helper.mailtemplate'] = $app->share(function () {
         return new \Eccube\Framework\Helper\MailtemplateHelper();
     });
     $app['eccube.helper.maker'] = $app->share(function () {
         return new \Eccube\Framework\Helper\MakerHelper();
     });
     $app['eccube.helper.mobile'] = $app->share(function () {
         return new \Eccube\Framework\Helper\MobileHelper();
     });
     $app['eccube.helper.news'] = $app->share(function () {
         return new \Eccube\Framework\Helper\NewsHelper();
     });
     $app['eccube.helper.page_layout'] = $app->share(function () {
         return new \Eccube\Framework\Helper\PageLayoutHelper();
     });
     $app['eccube.helper.payment'] = $app->share(function () {
         return new \Eccube\Framework\Helper\PaymentHelper();
     });
     $app['eccube.helper.plugin'] = function () {
         $plugin_activate_flg = PLUGIN_ACTIVATE_FLAG;
         return \Eccube\Framework\Helper\PluginHelper::getSingletonInstance($plugin_activate_flg);
     };
     $app['eccube.helper.purchase'] = $app->share(function () {
         return new \Eccube\Framework\Helper\PurchaseHelper();
     });
     $app['eccube.helper.session'] = $app->share(function () {
         return new \Eccube\Framework\Helper\SessionHelper();
     });
     $app['eccube.helper.tax_rule'] = $app->share(function () {
         return new \Eccube\Framework\Helper\TaxRuleHelper();
     });
     $app['eccube.helper.transform'] = $app->protect(function ($source) {
         return new \Eccube\Framework\Helper\TransformHelper($source);
     });
     // util
     $app['eccube.util.utils'] = $app->share(function () {
         return new \Eccube\Framework\Util\Utils();
     });
     $app['eccube.util.gc_utils'] = $app->share(function () {
         return new \Eccube\Framework\Util\GcUtils();
     });
     // smarty
     $app['smarty'] = $app->extend('smarty', function ($smarty) {
         /* @var $DbHelper \Eccube\Framework\Helper\DbHelper */
         $DbHelper = Application::alias('eccube.helper.db');
         /* @var $Utils \Eccube\Framework\Util\Utils */
         $Utils = Application::alias('eccube.util.utils');
         /* @var $GcUtils \Eccube\Framework\Util\GcUtils */
         $GcUtils = Application::alias('eccube.util.gc_utils');
         $smarty->left_delimiter = '<!--{';
         $smarty->right_delimiter = '}-->';
         $smarty->plugins_dir = array(realpath(__DIR__ . '/../../smarty_extends'), realpath(__DIR__ . '/../../../vendor/smarty/smarty/libs/plugins'));
         $smarty->register_modifier('sfDispDBDate', array($Utils, 'sfDispDBDate'));
         $smarty->register_modifier('sfGetErrorColor', array($Utils, 'sfGetErrorColor'));
         $smarty->register_modifier('sfTrim', array($Utils, 'sfTrim'));
         $smarty->register_modifier('sfCalcIncTax', array($DbHelper, 'calcIncTax'));
         $smarty->register_modifier('sfPrePoint', array($Utils, 'sfPrePoint'));
         $smarty->register_modifier('sfGetChecked', array($Utils, 'sfGetChecked'));
         $smarty->register_modifier('sfTrimURL', array($Utils, 'sfTrimURL'));
         $smarty->register_modifier('sfMultiply', array($Utils, 'sfMultiply'));
         $smarty->register_modifier('sfRmDupSlash', array($Utils, 'sfRmDupSlash'));
         $smarty->register_modifier('sfCutString', array($Utils, 'sfCutString'));
         $smarty->register_modifier('sfMbConvertEncoding', array($Utils, 'sfMbConvertEncoding'));
         $smarty->register_modifier('sfGetEnabled', array($Utils, 'sfGetEnabled'));
         $smarty->register_modifier('sfNoImageMainList', array($Utils, 'sfNoImageMainList'));
         // XXX register_function で登録すると if で使用できないのではないか?
         $smarty->register_function('sfIsHTTPS', array($Utils, 'sfIsHTTPS'));
         $smarty->register_function('sfSetErrorStyle', array($Utils, 'sfSetErrorStyle'));
         $smarty->register_function('printXMLDeclaration', array($GcUtils, 'printXMLDeclaration'));
         $smarty->default_modifiers = array('script_escape');
         $smarty->force_compile = SMARTY_FORCE_COMPILE_MODE === true;
         return $smarty;
     });
 }
Beispiel #2
0
 /**
  * 関連商品登録を行う.
  *
  * FIXME: 商品規格登録の実処理自体は、LC_Page_Admin_Products_Productと共通化して欲しい。
  *        DELETE/INSERT ではなく UPDATEへの変更も・・・
  *
  * @param  Query $objQuery   Queryインスタンス
  * @param  array    $arrList    商品規格情報配列
  * @param  integer  $product_id 商品ID
  * @return void
  */
 public function lfRegistReccomendProducts($objQuery, $arrList, $product_id)
 {
     $objQuery->delete('dtb_recommend_products', 'product_id = ?', array($product_id));
     for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) {
         $keyname = 'recommend_product_id' . $i;
         $comment_key = 'recommend_comment' . $i;
         if ($arrList[$keyname] != '') {
             $arrProduct = $objQuery->select('product_id', 'dtb_products', 'product_id = ?', array($arrList[$keyname]));
             if ($arrProduct[0]['product_id'] != '') {
                 $arrWhereVal = array();
                 $arrWhereVal['product_id'] = $product_id;
                 $arrWhereVal['recommend_product_id'] = $arrProduct[0]['product_id'];
                 $arrWhereVal['comment'] = $arrList[$comment_key];
                 $arrWhereVal['update_date'] = $arrList['update_date'];
                 $arrWhereVal['create_date'] = $arrList['update_date'];
                 $arrWhereVal['creator_id'] = $_SESSION['member_id'];
                 $arrWhereVal['rank'] = RECOMMEND_PRODUCT_MAX - $i + 1;
                 $objQuery->insert('dtb_recommend_products', $arrWhereVal);
             }
         }
     }
 }
Beispiel #3
0
 /**
  * シーケンス生成器を復元する
  * @param string $csv
  * @param Query $objQuery
  */
 public function restoreSequence(&$objQuery, $csv)
 {
     // csvファイルからデータの取得
     $arrCsvData = file($csv);
     foreach ($arrCsvData as $line) {
         list($name, $currval) = explode(',', trim($line));
         if (in_array($name, $this->arrExcludeSequence, true)) {
             continue 1;
         }
         // FIXME テーブルと同様に整合チェックを行う。また不整合時はスキップして続行する。
         // XXX +1 ではなく、nextVal を呼ぶべきかも。
         $objQuery->setVal($name, $currval + 1);
     }
 }
Beispiel #4
0
 /**
  * 規格データをコピーする
  *
  * @param  array   $arrList  フォーム入力パラメーター配列
  * @param  Query  $objQuery Queryインスタンス
  * @return boolean エラーフラグ
  */
 public function lfCopyProductClass($arrList, &$objQuery)
 {
     // 複製元のdtb_products_classを取得(規格なしのため、1件のみの取得)
     $col = '*';
     $table = 'dtb_products_class';
     $where = 'product_id = ?';
     $arrProductClass = $objQuery->select($col, $table, $where, array($arrList['copy_product_id']));
     //トランザクション開始
     $objQuery->begin();
     $err_flag = false;
     //非編集項目は複製、編集項目は上書きして登録
     foreach ($arrProductClass as $records) {
         foreach ($records as $key => $value) {
             if (isset($arrList[$key])) {
                 switch ($key) {
                     case 'stock_unlimited':
                         $records[$key] = (int) $arrList[$key];
                         break;
                     default:
                         $records[$key] = $arrList[$key];
                         break;
                 }
             }
         }
         $records['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id');
         $records['update_date'] = 'CURRENT_TIMESTAMP';
         $records['create_date'] = 'CURRENT_TIMESTAMP';
         $objQuery->insert($table, $records);
         //エラー発生時は中断
         if ($objQuery->isError()) {
             $err_flag = true;
             continue;
         }
     }
     //トランザクション終了
     if ($err_flag) {
         $objQuery->rollback();
     } else {
         $objQuery->commit();
     }
     return !$err_flag;
 }
Beispiel #5
0
 /**
  * レコードの削除(削除フラグをONにする).
  *
  * @param  Query      $objQuery
  * @param  integer     $id       削除対象のmember_id
  * @return void|UPDATE の結果フラグ
  */
 public function deleteRecode(&$objQuery, $id)
 {
     // Updateする値を作成する.
     $sqlVal = array();
     $sqlVal['rank'] = 0;
     $sqlVal['del_flg'] = 1;
     $where = 'member_id = ?';
     // UPDATEの実行 - ランクを最下位にする、DELフラグON
     return $objQuery->update('dtb_member', $sqlVal, $where, array($id));
 }
 /**
  * 子孫カテゴリーの表示順を一括して下げる.
  *
  * @param Query $objQuery
  * @param int $category_id
  * @param int $count
  * @return array|bool
  */
 private function reduceBranchRank(Query $objQuery, $category_id, $count)
 {
     $table = 'dtb_category';
     /* @var $objDb DbHelper */
     $objDb = Application::alias('eccube.helper.db');
     // 子ID一覧を取得
     $arrRet = $objDb->getChildrenArray($table, 'parent_category_id', 'category_id', $category_id);
     $line = Utils::sfGetCommaList($arrRet);
     $where = "category_id IN ({$line}) AND del_flg = 0";
     $arrRawVal = array('rank' => "(rank - {$count})");
     return $objQuery->update($table, array(), $where, array(), $arrRawVal);
 }
Beispiel #7
0
    /**
     * Query インスタンスに設定された検索条件を使用して商品規格を取得する.
     *
     * @param  Query $objQuery Queryインスタンス
     * @param  array    $params   検索パラメーターの配列
     * @return array    商品規格の配列
     */
    public function getProductsClassByQuery(Query &$objQuery, $params)
    {
        // 末端の規格を取得
        $col = <<<__EOS__
            T1.product_id,
            T1.stock,
            T1.stock_unlimited,
            T1.sale_limit,
            T1.price01,
            T1.price02,
            T1.point_rate,
            T1.product_code,
            T1.product_class_id,
            T1.del_flg,
            T1.product_type_id,
            T1.down_filename,
            T1.down_realfilename,
            T3.name AS classcategory_name1,
            T3.rank AS rank1,
            T4.name AS class_name1,
            T4.class_id AS class_id1,
            T1.classcategory_id1,
            T1.classcategory_id2,
            dtb_classcategory2.name AS classcategory_name2,
            dtb_classcategory2.rank AS rank2,
            dtb_class2.name AS class_name2,
            dtb_class2.class_id AS class_id2
__EOS__;
        $table = <<<__EOS__
            dtb_products_class T1
            LEFT JOIN dtb_classcategory T3
                ON T1.classcategory_id1 = T3.classcategory_id
            LEFT JOIN dtb_class T4
                ON T3.class_id = T4.class_id
            LEFT JOIN dtb_classcategory dtb_classcategory2
                ON T1.classcategory_id2 = dtb_classcategory2.classcategory_id
            LEFT JOIN dtb_class dtb_class2
                ON dtb_classcategory2.class_id = dtb_class2.class_id
__EOS__;
        $objQuery->andWhere(' T3.classcategory_id is not null AND dtb_classcategory2.classcategory_id is not null ');
        $objQuery->setOrder('T3.rank DESC, dtb_classcategory2.rank DESC');
        // XXX
        $arrRet = $objQuery->select($col, $table, '', $params);
        return $arrRet;
    }
 /**
  * テーブル一覧を取得する
  *
  * MDB2_Driver_Manager_pgsql#listTables の不具合回避を目的として独自実装している。
  * @return array テーブル名の配列
  */
 public function listTables(Query &$objQuery)
 {
     $col = 'tablename';
     $from = 'pg_tables';
     $where = "schemaname NOT IN ('pg_catalog', 'information_schema', 'sys')";
     return $objQuery->getCol($col, $from, $where);
 }
Beispiel #9
0
 /**
  * メーカー商品数数の登録を行う.
  *
  * @param  Query $objQuery Query インスタンス
  * @return void
  */
 public function countMaker($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';
     $sql .= ' ON T1.maker_id = T2.maker_id ';
     $sql .= ' WHERE T2.del_flg = 0 AND T2.status = 1 ';
     $sql .= ' GROUP BY T1.maker_id, T2.maker_id ';
     $objQuery->query($sql);
 }
Beispiel #10
0
 /**
  * 商品情報を取得する(vw_products_allclass使用)
  *
  * @param  Query $objQuery DB操作クラス
  * @return array    $arrProduct 取得結果を配列で返す
  */
 public function lfGetProductsAllclass(&$objQuery)
 {
     // --- 商品一覧の取得
     /* @var $objProduct Product */
     $objProduct = Application::alias('eccube.product');
     $objQuery->setWhere($objProduct->getProductDispConditions());
     $objQuery->setOrder('product_id');
     $arrProductLsit = $objProduct->lists($objQuery);
     // 各商品のカテゴリIDとランクの取得
     $arrProducts = array();
     foreach ($arrProductLsit as $key => $val) {
         $sql = '';
         $sql .= ' SELECT';
         $sql .= '   T1.category_id,';
         $sql .= '   T1.rank AS product_rank,';
         $sql .= '   T2.rank AS category_rank';
         $sql .= ' FROM';
         $sql .= '   dtb_product_categories AS T1';
         $sql .= ' LEFT JOIN';
         $sql .= '   dtb_category AS T2';
         $sql .= ' ON';
         $sql .= '   T1.category_id = T2.category_id';
         $sql .= ' WHERE';
         $sql .= '   product_id = ?';
         $arrCategory = $objQuery->getAll($sql, array($val['product_id']));
         if (!empty($arrCategory)) {
             $arrProducts[$key] = array_merge($val, $arrCategory[0]);
         }
     }
     // 税込金額を設定する
     Application::alias('eccube.product')->setIncTaxToProducts($arrProducts);
     return $arrProducts;
 }
Beispiel #11
0
 /**
  * PluginHelper オブジェクトを返す(Singletonパターン)
  *
  * @return PluginHelper PluginHelperオブジェクト
  */
 public static function getSingletonInstance($plugin_activate_flg = true)
 {
     if (!isset($GLOBALS['_PluginHelper_instance'])) {
         // プラグインのローダーがDB接続を必要とするため、
         // Queryインスタンス生成後のみオブジェクトを生成する。
         if (is_null(Query::getPoolInstance())) {
             return null;
         }
         $GLOBALS['_PluginHelper_instance'] = new static();
         $GLOBALS['_PluginHelper_instance']->load($plugin_activate_flg);
     }
     return $GLOBALS['_PluginHelper_instance'];
 }
 /**
  * 各 DB に応じた Query での初期化を行う
  *
  * @param  Query $objQuery Query インスタンス
  * @return void
  */
 public function initObjQuery(Query &$objQuery)
 {
     $objQuery->exec('SET SESSION storage_engine = InnoDB');
     $objQuery->exec("SET SESSION sql_mode = 'ANSI'");
 }
Beispiel #13
0
 /**
  * @param Query $objQuery
  * @param string $table
  * @param string $pid_name
  * @param string $id_name
  * @param integer $count
  */
 public function lfDownRankChilds($objQuery, $table, $pid_name, $id_name, $id, $count)
 {
     /* @var $objDb DbHelper */
     $objDb = Application::alias('eccube.helper.db');
     // 子ID一覧を取得
     $arrRet = $objDb->getChildrenArray($table, $pid_name, $id_name, $id);
     $line = Utils::sfGetCommaList($arrRet);
     $where = "{$id_name} IN ({$line}) AND del_flg = 0";
     $arrRawVal = array('rank' => "(rank - {$count})");
     return $objQuery->update($table, array(), $where, array(), $arrRawVal);
 }