source: branches/dev/data/downloads/module/mdl_ebis_tag/ebis_tag.php @ 15072

Revision 15072, 8.5 KB checked in by adati, 14 years ago (diff)

岩田さん指摘事項対応

Line 
1<?php
2/**
3 *
4 * @copyright   2000-2007 LOCKON CO.,LTD. All Rights Reserved.
5 * @version CVS: $Id: ebis_tag.php,v 1.30 2007/07/18 04:02:40 adachi Exp $
6 * @link        http://www.lockon.co.jp/
7 *
8 */
9
10// ǧ¾Ú³Îǧ
11$objSess = new SC_Session();
12sfIsSuccess($objSess);
13
14//¥Ú¡¼¥¸´ÉÍý¥¯¥é¥¹
15class LC_Page {
16    //¥³¥ó¥¹¥È¥é¥¯¥¿
17    function LC_Page() {
18        //¥á¥¤¥ó¥Æ¥ó¥×¥ì¡¼¥È¤Î»ØÄê
19        $this->tpl_mainpage  = MODULE_PATH . 'mdl_ebis_tag/ebis_tag.tpl';
20        $this->tpl_subtitle  = 'AD EBiS¥¿¥°Ëä¤á¹þ¤ßµ¡Ç½';
21        $this->tpl_uniqid    = '';
22       
23        global $arrEBiSTagCustomerId;
24        $this->arrEBiSTagCustomerId = $arrEBiSTagCustomerId;
25        global $arrEBiSTagPayment;
26        $this->arrEBiSTagPayment = $arrEBiSTagPayment;
27        global $arrEBiSTagOptions;
28        $this->arrEBiSTagOptions = $arrEBiSTagOptions;
29    }
30}
31
32$objPage = new LC_Page();
33$objView = new SC_AdminView();
34
35// ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹
36$objFormParam = new SC_FormParam();
37$objFormParam = lfInitParam($objFormParam);
38// POSTÃͤμèÆÀ
39$objFormParam->setParam($_POST);
40
41switch($_POST['mode']) {
42case 'edit':
43    // ²èÌÌÁ«°Ü¤ÎÀµÅöÀ­¥Á¥§¥Ã¥¯
44    //if (sfIsValidTransition($objSess) == false) {
45    //    sfDispError(INVALID_MOVE_ERRORR);
46    //}
47   
48    // ÆþÎÏ¥¨¥é¡¼È½Äê
49    $objPage->arrErr = $objFormParam->checkError();
50    if(count($objPage->arrErr) == 0) {
51        $arrRet = $objFormParam->getHashArray();
52        $sqlval['sub_data'] = serialize($arrRet);
53        $objQuery = new SC_Query();
54        $objQuery->update("dtb_module", $sqlval, "module_id = ?", array(EBIS_TAG_MID));
55        // javascript¼Â¹Ô
56        $objPage->tpl_onload = "window.close();";
57    }
58    break;
59case 'csv':
60    // ²èÌÌÁ«°Ü¤ÎÀµÅöÀ­¥Á¥§¥Ã¥¯
61    //if (sfIsValidTransition($objSess) == false) {
62    //    sfDispError(INVALID_MOVE_ERRORR);
63    //}
64    $csv = lgGetCsvData();
65    sfCSVDownload($csv, 'ebis_tag_');
66    exit;
67default:
68    $arrRet = $objQuery->select("sub_data", "dtb_module", "module_id = ?", array(EBIS_TAG_MID));
69    $arrSubData = unserialize($arrRet[0]['sub_data']);
70    $objFormParam->setParam($arrSubData);
71   
72    // ¥æ¥Ë¡¼¥¯ID¤òËä¤á¹þ¤ß
73    // $objPage->tpl_uniqid = $objSess->getUniqId();
74    break;
75}
76
77$objPage->arrForm = $objFormParam->getFormParamList();
78$objView->assignobj($objPage);      //ÊÑ¿ô¤ò¥Æ¥ó¥×¥ì¡¼¥È¤Ë¥¢¥µ¥¤¥ó¤¹¤ë
79$objView->display($objPage->tpl_mainpage);      //¥Æ¥ó¥×¥ì¡¼¥È¤Î½ÐÎÏ
80//-------------------------------------------------------------------------------------------------------
81/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
82function lfInitParam($objFormParam) {
83    $objFormParam->addParam("¥í¥°¥¤¥óURL", "login_url", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "URL_CHECK"));
84    $objFormParam->addParam("EBiS°ú¿ô", "cid", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
85   
86    $objFormParam->addParam("¸ÜµÒID", "m1id", INT_LEN, "", array("MAX_LENGTH_CHECK", 'NUM_CHECK'));
87    $objFormParam->addParam("¹ØÆþ¶â³Û", "a1id", INT_LEN, "", array("MAX_LENGTH_CHECK", 'NUM_CHECK'));
88   
89    for ($i = 1; $i <= EBiS_TAG_OPTIONS_MAX; $i++) {
90        $title = "Ǥ°Õ¹àÌÜ$i";
91        $name  = 'o' . $i . 'id';
92        $objFormParam->addParam(
93            $title, $name, INT_LEN, "",
94            array("MAX_LENGTH_CHECK", "NUM_CHECK")
95        );
96    }
97    return $objFormParam;
98}
99
100/**
101 * ¥«¥Æ¥´¥êʸ»úÎó¤ò¼èÆÀ(¥«¥Æ¥´¥ê¡ä¥«¥Æ¥´¥ê¡ä¥«¥Æ¥´¥ê¡ä)
102 *
103 * @param int $category_id ¥«¥Æ¥´¥êID
104 * @param str $sep ¥«¥Æ¥´¥ê¤Î¶èÀÚ¤êʸ»ú
105 * return ¥«¥Æ¥´¥êʸ»úÎó(¥«¥Æ¥´¥ê¡ä¥«¥Æ¥´¥ê¡ä¥«¥Æ¥´¥ê¡ä)
106 */
107function lfGetCategoriesStr($category_id, $sep = ' > ') {
108    $tbl_category = 'dtb_category';
109   
110    // ¿Æ¥«¥Æ¥´¥êID¤ÎÇÛÎó
111    $arrParentsCatId = sfGetParents(null, $tbl_category, 'parent_category_id', 'category_id', $category_id);
112   
113    // WHERE¶ç¤ò¹½ÃÛ
114    $where = str_repeat('category_id = ? OR ' , count($arrParentsCatId));
115    $where = preg_replace('/OR $/', '', $where);
116
117    // ¥«¥Æ¥´¥ê̾¤ò¼èÆÀ
118    $objQuery = new SC_Query();
119    $arrRet   = $objQuery->select('category_name', $tbl_category, $where, $arrParentsCatId);
120   
121    // ¥«¥Æ¥´¥ê¡ä¥«¥Æ¥´¥ê¡ä¥«¥Æ¥´¥ê...¤ò¹½ÃÛ
122    $categories_str = '';
123    foreach($arrRet as $category) {
124        $categories_str .= $category['category_name'] . $sep;
125    }
126   
127    return $categories_str;
128}
129
130/** CSV¼èÆÀ **/
131function lgGetCsvData() {
132    $csv  = '"¥Ú¡¼¥¸ID","¥¿¥¤¥È¥ë","URL"' . "\n";
133    $csv .= lfGetDetailPageCSV();
134    $csv .= lfGetListPageCSV();
135    $csv .= lfGetFrontPageCSV();
136    return $csv;
137}
138
139/** ¾¦Éʾܺ٥ڡ¼¥¸¤ÎCSV¤ò¼èÆÀ **/
140function lfGetDetailPageCSV() {
141    $table    = 'dtb_products';
142    $colmuns  = 'product_id, name, category_id';
143    $objQuery = new SC_Query();
144   
145    $arrRet = $objQuery->select($colmuns, $table);
146   
147    $arrCSV = array();
148    foreach ($arrRet as $index => $product) {
149        $id  = $product['product_id'];
150        $url = SITE_URL . 'products/detail.php?product_id=';
151        $title = lfGetCategoriesStr($product['category_id']) . $product['name'];
152       
153        $arrCSV[$index]['page_id']    = 'detail-p' . $id;
154        $arrCSV[$index]['page_title'] = $title;
155        $arrCSV[$index]['url']        = $url . $id;
156    }
157   
158    return lfCreateCSV($arrCSV);
159}
160
161/** ¾¦ÉÊ°ìÍ÷¥Ú¡¼¥¸¤ÎCSV¤ò¼èÆÀ **/
162function lfGetListPageCSV() {
163    $table    = 'dtb_category';
164    $colmuns  = 'category_id, category_name';
165    $objQuery = new SC_Query();
166   
167    $arrRet = $objQuery->select($colmuns, $table);
168   
169    $arrCSV = array();
170    foreach ($arrRet as $index => $category) {
171        $id  = $category['category_id'];
172        $url = SITE_URL . 'products/list.php?category_id=';
173        $title = $category['category_name'];
174       
175        $arrCSV[$index]['page_id']    = 'list-c' . $id;
176        $arrCSV[$index]['page_title'] = $title;
177        $arrCSV[$index]['url']        = $url . $id;
178    }
179    return lfCreateCSV($arrCSV);
180}
181
182function lfCreateCSV ($arrCSV) {
183    $csv_str = '';
184    $max = count($arrCSV);
185    for ($i=0; $i < $max; $i++) {
186        foreach (array('page_id', 'page_title', 'url') as $key) {
187            $arrCSV[$i][$key] = sprintf(
188                '"%s"',
189                str_replace('"', '""', $arrCSV[$i][$key])
190            );
191        }
192        $csv_str .= join(',', $arrCSV[$i]) . "\n";
193    }
194   
195    return $csv_str;
196}
197
198/** ¤½¤Î¾¥Ú¡¼¥¸¤ÎCSV¤ò¼èÆÀ **/
199function lfGetFrontPageCSV() {
200    // ¹àÌÜÄɲäκݤϲ¼µ­Ï¢ÁÛÇÛÎó¤òÄɲá£
201    // page_title,url¤ÏǤ°Õ¡¢¤Ê¤¤¾ì¹ç¤Ïpage_id¤«¤é¼«Æ°À¸À®¤µ¤ì¤ë
202    // 'page_id' => 'top', 'page_title' => '¥È¥Ã¥×' , 'url' => 'index.php'
203    $arrList = array(
204        array('page_id' => 'top', 'page_title' => '¥È¥Ã¥×' , 'url' => 'index.php'),
205        array('page_id' => 'abouts_index', 'page_title' => 'Åö¥µ¥¤¥È¤Ë¤Ä¤¤¤Æ'),
206        array('page_id' => 'cart_index', 'page_title' => 'Ç㤤ʪ¤«¤´¡Ê¥È¥Ã¥×¡Ë'),
207        array('page_id' => 'contact_index', 'page_title' => '¤ªÌ䤤¹ç¤ï¤»¡ÊÆþÎÏ¡Ë'),
208        array('page_id' => 'contact_confirm', 'page_title' => '¤ªÌ䤤¹ç¤ï¤»¡Ê³Îǧ¡Ë', 'url' => 'contact/index.php'),
209        array('page_id' => 'contact_complete', 'page_title' => '¤ªÌ䤤¹ç¤ï¤»¡Ê´°Î»¡Ë'),
210        array('page_id' => 'order_index', 'page_title' => '¹ØÆþ¡ÊÆþÎÏ¡Ë'),
211        array('page_id' => 'entry_kiyaku', 'page_title' => '¤´ÍøÍѵ¬Ìó'),
212        array('page_id' => 'entry_index', 'page_title' => '²ñ°÷ÅÐÏ¿¡ÊÆþÎÏ'),
213        array('page_id' => 'entry_confirm', 'page_title' => '²ñ°÷ÅÐÏ¿¡Ê³Îǧ¡Ë', 'url' => 'entry/index.php'),
214        array('page_id' => 'regist_complete', 'page_title' => '²ñ°÷ÅÐÏ¿¡Ê´°Î»¡Ë', 'url' => 'entry/complete.php'),
215        array('page_id' => 'shopping_deliv', 'page_title' => '¹ØÆþ¡Ê¤ªÆϤ±Àè»ØÄê¡Ë'),
216        array('page_id' => 'shopping_payment', 'page_title' => '¹ØÆþ¡Ê¤ª»Ùʧ¤¤ÊýË¡»ØÄê¡Ë'),
217        array('page_id' => 'shopping_confirm', 'page_title' => '¹ØÆþ¡Ê³Îǧ¡Ë'),
218        array('page_id' => 'thanks', 'page_title' => '¹ØÆþ¡Ê´°Î»', 'url' => 'shopping/complete.php'),
219        array('page_id' => 'mypage_index', 'page_title' => 'MY¥Ú¡¼¥¸¡Ê¥È¥Ã¥×¡Ë'),
220        array('page_id' => 'mypage_change', 'page_title' => 'MY¥Ú¡¼¥¸ > ²ñ°÷ÅÐÏ¿ÆâÍÆÊѹ¹¡ÊÆþÎÏ¡Ë'),
221        array('page_id' => 'mypage_change_confirm', 'page_title' => 'MY¥Ú¡¼¥¸ > ²ñ°÷ÅÐÏ¿ÆâÍÆÊѹ¹¡Ê³Îǧ¡Ë', 'url' => 'mypage/change.php'),
222        array('page_id' => 'mypage_change_complete', 'page_title' => 'MY¥Ú¡¼¥¸ > ²ñ°÷ÅÐÏ¿ÆâÍÆÊѹ¹¡Ê´°Î»¡Ë', 'url' => 'mypage/change_complete.php'),
223    );
224   
225    foreach ($arrList as $key => $list) {
226        if ( empty($arrList[$key]['page_title']) ) {
227            $arrList[$key]['page_title'] = $arrList[$key]['page_id'];
228        }
229       
230        if ( empty($arrList[$key]['url']) ) {
231            $url = SITE_URL . str_replace('_', '/', $arrList[$key]['page_id']);
232            $arrList[$key]['url'] = $url . '.php';
233        } else {
234            $arrList[$key]['url'] = SITE_URL . $arrList[$key]['url'];
235        }
236    }
237   
238    return lfCreateCSV($arrList);
239}
240
241?>
Note: See TracBrowser for help on using the repository browser.