OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / widgets / custom_search / include / container / admin_custom_searchWidgetContainer.php
1 <?php
2 /**
3  * コンテナクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    カスタム検索
10  * @author     株式会社 毎日メディアサービス
11  * @copyright  Copyright 2010-2013 株式会社 毎日メディアサービス.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: admin_custom_searchWidgetContainer.php 5969 2013-04-29 13:16:04Z fishbone $
14  * @link       http://www.m-media.co.jp
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseAdminWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/custom_searchDb.php');
18
19 class admin_custom_searchWidgetContainer extends BaseAdminWidgetContainer
20 {
21         private $db;    // DB接続オブジェクト
22         private $serialNo;              // 選択中の項目のシリアル番号
23         private $serialArray = array();                 // 表示中のシリアル番号
24         private $langId;
25         private $configId;              // 定義ID
26         private $paramObj;              // パラメータ保存用オブジェクト
27         private $searchTextId;          // 検索用テキストフィールドのタグID
28         private $searchButtonId;                // 検索用ボタンのタグID
29         private $searchResetId;         // 検索エリアリセットボタンのタグID
30         private $fieldInfoArray = array();                      // 項目定義
31         private $categoryArray;         // カテゴリ種別メニュー
32         private $selTypeArray;  // 項目選択タイプメニュー
33         const DEFAULT_NAME_HEAD = '名称未設定';                    // デフォルトの設定名
34         const MESSAGE_NO_USER_CATEGORY = 'カテゴリが登録されていません';                  // ユーザ作成コンテンツ用のカテゴリが登録されていないときのメッセージ
35         const DEFAULT_SEARCH_COUNT      = 20;                           // デフォルトの検索結果表示数
36         
37         /**
38          * コンストラクタ
39          */
40         function __construct()
41         {
42                 // 親クラスを呼び出す
43                 parent::__construct();
44                 
45                 // DBオブジェクト作成
46                 $this->db = new custom_searchDb();
47                 
48                 // 項目選択タイプ
49                 $this->selTypeArray = array(    array(  'name' => '単一選択',       'value' => 'single'),
50                                                                                 array(  'name' => '複数選択',       'value' => 'multi'));
51         }
52         /**
53          * テンプレートファイルを設定
54          *
55          * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
56          * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
57          *
58          * @param RequestManager $request               HTTPリクエスト処理クラス
59          * @param object         $param                 任意使用パラメータ。そのまま_assign()に渡る
60          * @return string                                               テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
61          */
62         function _setTemplate($request, &$param)
63         {
64                 $task = $request->trimValueOf('task');
65                 if ($task == 'list'){           // 一覧画面
66                         return 'admin_list.tmpl.html';
67                 } else {                        // 一覧画面
68                         return 'admin.tmpl.html';
69                 }
70         }
71         /**
72          * テンプレートにデータ埋め込む
73          *
74          * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
75          *
76          * @param RequestManager $request               HTTPリクエスト処理クラス
77          * @param object         $param                 任意使用パラメータ。_setTemplate()と共有。
78          * @param                                                               なし
79          */
80         function _assign($request, &$param)
81         {
82                 $task = $request->trimValueOf('task');
83                 if ($task == 'list'){           // 一覧画面
84                         return $this->createList($request);
85                 } else {                        // 詳細設定画面
86                         return $this->createDetail($request);
87                 }
88         }
89         /**
90          * 詳細画面作成
91          *
92          * @param RequestManager $request               HTTPリクエスト処理クラス
93          * @param                                                               なし
94          */
95         function createDetail($request)
96         {
97                 // ページ定義IDとページ定義のレコードシリアル番号を取得
98                 $this->startPageDefParam($defSerial, $defConfigId, $this->paramObj);
99                 
100                 $userId         = $this->gEnv->getCurrentUserId();
101                 $this->langId   = $this->gEnv->getCurrentLanguage();            // 表示言語を取得
102                 $act = $request->trimValueOf('act');
103                 $this->serialNo = $request->trimValueOf('serial');              // 選択項目のシリアル番号
104
105                 // 入力値を取得
106                 $name   = $request->trimValueOf('item_name');                   // ヘッダタイトル
107                 $searchTemplate = $request->valueOf('item_html');               // 検索用テンプレート
108                 $resultCount    = $request->valueOf('item_result_count');                       // 表示項目数
109                 $this->searchTextId = $request->trimValueOf('item_search_text');                // 検索用テキストフィールドのタグID
110                 $this->searchButtonId = $request->trimValueOf('item_search_button');            // 検索用ボタンのタグID
111                 $this->searchResetId = $request->trimValueOf('item_search_reset');              // 検索エリアリセットボタンのタグID
112                 $this->configId = $request->trimValueOf('item_id');             // 定義ID
113                 if (empty($this->configId)) $this->configId = $defConfigId;             // 呼び出しウィンドウから引き継いだ定義ID
114
115                 // 検索対象
116                 $isTargetContent = ($request->trimValueOf('item_target_content') == 'on') ? 1 : 0;              // 汎用コンテンツを検索対象とするかどうか
117                 $isTargetUser = ($request->trimValueOf('item_target_user') == 'on') ? 1 : 0;                    // ユーザ作成コンテンツを検索対象とするかどうか
118                 $isTargetBlog = ($request->trimValueOf('item_target_blog') == 'on') ? 1 : 0;                    // ブログ記事を検索対象とするかどうか
119                 $isTargetProduct = ($request->trimValueOf('item_target_product') == 'on') ? 1 : 0;                      // 商品情報を検索対象とするかどうか
120                 $isTargetEvent = ($request->trimValueOf('item_target_event') == 'on') ? 1 : 0;                  // イベント情報を検索対象とするかどうか
121                 $isTargetBbs = ($request->trimValueOf('item_target_bbs') == 'on') ? 1 : 0;                      // BBSを検索対象とするかどうか
122                 $isTargetPhoto = ($request->trimValueOf('item_target_photo') == 'on') ? 1 : 0;                  // フォトギャラリーを検索対象とするかどうか
123                 
124                 // カテゴリ項目定義
125                 $fieldCount = intval($request->trimValueOf('fieldcount'));              // カテゴリ定義項目数
126                 $categoryTypes = $request->trimValueOf('item_type');                                    // カテゴリ種別
127                 $selectTypes = $request->trimValueOf('item_sel_type');                  // カテゴリ選択方法
128                 $values = $request->trimValueOf('titlevisible');                        // タイトルの表示制御
129                 $titleVisibles = array();
130                 if (strlen($values) > 0) $titleVisibles = explode(',', $values);
131                 $initValues = $request->trimValueOf('item_init_value');                 // 初期値
132                 
133                 // カテゴリ設定を取得
134                 $this->fieldInfoArray = array();
135                 for ($i = 0; $i < $fieldCount; $i++){
136                         $newInfoObj = new stdClass;
137                         $newInfoObj->categoryType = $categoryTypes[$i];
138                         $newInfoObj->selectType = $selectTypes[$i];
139                         $newInfoObj->titleVisible = $titleVisibles[$i];
140                         $newInfoObj->initValue = $initValues[$i];
141                         $this->fieldInfoArray[] = $newInfoObj;
142                 }
143                 
144                 // Pタグを除去
145                 $searchTemplate = $this->gInstance->getTextConvManager()->deleteTag($searchTemplate, 'p');
146
147                 $replaceNew = false;            // データを再取得するかどうか
148                 if (empty($act)){// 初期起動時
149                         // デフォルト値設定
150                         $this->configId = $defConfigId;         // 呼び出しウィンドウから引き継いだ定義ID
151                         $replaceNew = true;                     // データ再取得
152                 } else if ($act == 'add'){// 新規追加
153                         // 入力チェック
154                         $this->checkInput($name, '名前');
155                         if (empty($isTargetContent) && empty($isTargetUser) && empty($isTargetBlog) && empty($isTargetProduct) && empty($isTargetEvent) && 
156                                         empty($isTargetBbs) && empty($isTargetPhoto)) $this->setUserErrorMsg('検索対象が選択されていません');
157                         $this->checkNumeric($resultCount, '表示件数');
158                         
159                         // 設定名の重複チェック
160                         for ($i = 0; $i < count($this->paramObj); $i++){
161                                 $targetObj = $this->paramObj[$i]->object;
162                                 if ($name == $targetObj->name){         // 定義名
163                                         $this->setUserErrorMsg('名前が重複しています');
164                                         break;
165                                 }
166                         }
167                         
168                         // エラーなしの場合は、データを登録
169                         if ($this->getMsgCount() == 0){
170                                 // 追加オブジェクト作成
171                                 $newObj = new stdClass;
172                                 $newObj->name   = $name;// 表示名
173                                 $newObj->resultCount    = $resultCount;// 表示件数
174                                 $newObj->searchTemplate = $searchTemplate;              // 検索用テンプレート
175                                 $newObj->searchTextId = $this->searchTextId;            // 検索用テキストフィールドのタグID
176                                 $newObj->searchButtonId = $this->searchButtonId;                // 検索用ボタンのタグID
177                                 $newObj->searchResetId = $this->searchResetId;          // 検索エリアリセットボタンのタグID
178                                 $newObj->isTargetContent = $isTargetContent;            // 汎用コンテンツを検索対象とするかどうか
179                                 $newObj->isTargetUser = $isTargetUser;                  // ユーザ作成コンテンツを検索対象とするかどうか
180                                 $newObj->isTargetBlog = $isTargetBlog;                  // ブログ記事を検索対象とするかどうか
181                                 $newObj->isTargetProduct = $isTargetProduct;                    // 商品情報を検索対象とするかどうか
182                                 $newObj->isTargetEvent = $isTargetEvent;                        // イベント情報を検索対象とするかどうか
183                                 $newObj->isTargetBbs = $isTargetBbs;                    // BBSを検索対象とするかどうか
184                                 $newObj->isTargetPhoto = $isTargetPhoto;                        // フォトギャラリーを検索対象とするかどうか
185                                 $newObj->fieldInfo = $this->fieldInfoArray;                     // カテゴリ定義
186                                 
187                                 $ret = $this->addPageDefParam($defSerial, $defConfigId, $this->paramObj, $newObj);
188                                 if ($ret){
189                                         $this->setGuidanceMsg('データを追加しました');
190                                         
191                                         $this->configId = $defConfigId;         // 定義定義IDを更新
192                                         $replaceNew = true;                     // データ再取得
193                                 } else {
194                                         $this->setAppErrorMsg('データ追加に失敗しました');
195                                 }
196                         }
197                 } else if ($act == 'update'){           // 設定更新のとき
198                         // 入力値のエラーチェック
199                         if (empty($isTargetContent) && empty($isTargetUser) && empty($isTargetBlog) && empty($isTargetProduct) && empty($isTargetEvent) && 
200                                         empty($isTargetBbs) && empty($isTargetPhoto)) $this->setUserErrorMsg('検索対象が選択されていません');
201                         $this->checkNumeric($resultCount, '表示件数');
202                         
203                         if ($this->getMsgCount() == 0){                 // エラーのないとき
204                                 // 現在の設定値を取得
205                                 $ret = $this->getPageDefParam($defSerial, $defConfigId, $this->paramObj, $this->configId, $targetObj);
206                                 if ($ret){
207                                         // ウィジェットオブジェクト更新
208                                         $targetObj->resultCount = $resultCount;// 表示件数
209                                         $targetObj->searchTemplate      = $searchTemplate;              // 検索用テンプレート
210                                         $targetObj->searchTextId = $this->searchTextId;         // 検索用テキストフィールドのタグID
211                                         $targetObj->searchButtonId = $this->searchButtonId;             // 検索用ボタンのタグID
212                                         $targetObj->searchResetId = $this->searchResetId;               // 検索エリアリセットボタンのタグID
213                                         $targetObj->isTargetContent = $isTargetContent;         // 汎用コンテンツを検索対象とするかどうか
214                                         $targetObj->isTargetUser = $isTargetUser;                       // ユーザ作成コンテンツを検索対象とするかどうか
215                                         $targetObj->isTargetBlog = $isTargetBlog;                       // ブログ記事を検索対象とするかどうか
216                                         $targetObj->isTargetProduct = $isTargetProduct;                 // 商品情報を検索対象とするかどうか
217                                         $targetObj->isTargetEvent = $isTargetEvent;                     // イベント情報を検索対象とするかどうか
218                                         $targetObj->isTargetBbs = $isTargetBbs;                 // BBSを検索対象とするかどうか
219                                         $targetObj->isTargetPhoto = $isTargetPhoto;                     // フォトギャラリーを検索対象とするかどうか
220                                         $targetObj->fieldInfo = $this->fieldInfoArray;                  // カテゴリ定義
221                                 }
222                                 
223                                 // 設定値を更新
224                                 if ($ret) $ret = $this->updatePageDefParam($defSerial, $defConfigId, $this->paramObj, $this->configId, $targetObj);
225                                 if ($ret){
226                                         $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
227                                         
228                                         $replaceNew = true;                     // データ再取得
229                                 } else {
230                                         $this->setMsg(self::MSG_APP_ERR, 'データ更新に失敗しました');
231                                 }
232                         }
233                 } else if ($act == 'select'){   // 定義IDを変更
234                         $replaceNew = true;                     // データ再取得
235                 }
236                 
237                 // 設定項目選択メニュー作成
238                 $this->createItemMenu();
239                 
240                 // 表示用データを取得
241                 if (empty($this->configId)){            // 新規登録の場合
242                         $this->tmpl->setAttribute('item_name_visible', 'visibility', 'visible');// 名前入力フィールド表示
243                         if ($replaceNew){               // データ再取得時
244                                 $name = $this->createDefaultName();                     // デフォルト登録項目名
245                                 $resultCount    = self::DEFAULT_SEARCH_COUNT;                   // 表示項目数
246                                 $this->fieldInfoArray = array();                        // 項目定義
247                                 
248                                 // デフォルトの検索テンプレート作成
249                                 $tagHead = $this->createTagIdHead();
250                                 $this->searchTextId = $tagHead . '_text';               // 検索用テキストフィールドのタグID
251                                 $this->searchButtonId = $tagHead . '_button';           // 検索用ボタンのタグID
252                                 $this->searchResetId = $tagHead . '_reset';             // 検索エリアリセットボタンのタグID
253                                 $searchTemplate = $this->getParsedTemplateData('default.tmpl.html', array($this, 'makeSearcheTemplate'));// デフォルト用の検索テンプレート
254                                 
255                                 $isTargetContent = 1;           // 汎用コンテンツを検索対象とするかどうか
256                                 $isTargetUser = 1;                      // ユーザ作成コンテンツを検索対象とするかどうか
257                                 $isTargetBlog = 1;                      // ブログ記事を検索対象とするかどうか
258                                 $isTargetProduct = 1;                   // 商品情報を検索対象とするかどうか
259                                 $isTargetEvent = 1;                     // イベント情報を検索対象とするかどうか
260                                 $isTargetBbs = 1;                       // BBSを検索対象とするかどうか
261                                 $isTargetPhoto = 1;                     // フォトギャラリーを検索対象とするかどうか
262                         }
263                         $this->serialNo = 0;
264                 } else {                // 更新の場合
265                         if ($replaceNew){
266                                 $ret = $this->getPageDefParam($defSerial, $defConfigId, $this->paramObj, $this->configId, $targetObj);
267                                 if ($ret){
268                                         $name = $targetObj->name;// 名前
269                                         $resultCount    = $targetObj->resultCount;                      // 表示項目数
270                                         $this->searchTextId = $targetObj->searchTextId;         // 検索用テキストフィールドのタグID
271                                         $this->searchButtonId = $targetObj->searchButtonId;             // 検索用ボタンのタグID
272                                         $this->searchResetId = $targetObj->searchResetId;               // 検索エリアリセットボタンのタグID
273                                         $isTargetContent = $targetObj->isTargetContent;         // 汎用コンテンツを検索対象とするかどうか
274                                         $isTargetUser = $targetObj->isTargetUser;                       // ユーザ作成コンテンツを検索対象とするかどうか
275                                         $isTargetBlog = $targetObj->isTargetBlog;                       // ブログ記事を検索対象とするかどうか
276                                         $isTargetProduct = $targetObj->isTargetProduct;                 // 商品情報を検索対象とするかどうか
277                                         $isTargetEvent = $targetObj->isTargetEvent;                     // イベント情報を検索対象とするかどうか
278                                         $isTargetBbs = $targetObj->isTargetBbs;                 // BBSを検索対象とするかどうか
279                                         $isTargetPhoto = $targetObj->isTargetPhoto;                     // フォトギャラリーを検索対象とするかどうか
280                                         $searchTemplate = $targetObj->searchTemplate;           // 検索用テンプレート
281                                         if (!empty($targetObj->fieldInfo)) $this->fieldInfoArray = $targetObj->fieldInfo;                       // 項目定義
282                                 }
283                         }
284                         $this->serialNo = $this->configId;
285                                 
286                         // 新規作成でないときは、メニューを変更不可にする(画面作成から呼ばれている場合のみ)
287                         if (!empty($defConfigId) && !empty($defSerial)) $this->tmpl->addVar("_widget", "id_disabled", 'disabled');
288                 }
289                 // カテゴリ情報取得
290                 $this->categoryArray = array();         // カテゴリ種別メニュー
291                 $ret = $this->db->getAllCategory($this->langId, $rows);
292                 if ($ret){
293                         for ($i = 0; $i < count($rows); $i++){
294                                 $line = array();
295                                 $line['name'] = $rows[$i]['ua_name'];
296                                 $line['value'] = $rows[$i]['ua_id'];
297                                 $this->categoryArray[] = $line;
298                         }
299                 }
300                 
301                 // メニュー作成
302                 $this->createCategoryMenu();
303                 $this->createSelTypeMenu();
304                 
305                 // 項目定義一覧を作成
306                 $this->createFieldList();
307                 if (empty($this->fieldInfoArray)) $this->tmpl->setAttribute('field_list', 'visibility', 'hidden');// 項目定義一覧を隠す
308                 
309                 // メッセージ設定
310                 if (empty($this->categoryArray)){                       // 絞り込みカテゴリが登録されていないとき
311                         $messageStr = '<b><font color="red">' . self::MESSAGE_NO_USER_CATEGORY . '</font></b>';
312                         $this->tmpl->addVar("_widget", "user_content_message",  $messageStr);           // ユーザ作成コンテンツ用メッセージ
313                 }
314                 
315                 // 画面にデータを埋め込む
316                 $this->tmpl->addVar("item_name_visible", "name", $name);                // 名前
317                 $this->tmpl->addVar("_widget", "result_count",  $resultCount);                  // 表示項目数
318                 $this->tmpl->addVar("_widget", "html",  $searchTemplate);
319                 $this->tmpl->addVar("_widget", "search_text",   $this->searchTextId);           // 検索用テキストフィールドのタグID
320                 $this->tmpl->addVar("_widget", "search_button", $this->searchButtonId);         // 検索用ボタンのタグID
321                 $this->tmpl->addVar("_widget", "search_reset",  $this->searchResetId);          // 検索エリアリセットボタンのタグID
322                 $tagStr = $this->searchTextId . '(入力フィールドのID), ' . $this->searchButtonId . '(検索実行ボタンのID), ' . $this->searchResetId . '(検索リセットボタンのID)';
323                 $this->tmpl->addVar("_widget", "tag_id_str", $tagStr);// タグIDの表示
324                 $this->tmpl->addVar('_widget', 'tag_start', M3_TAG_START . M3_TAG_MACRO_ITEM_KEY);              // 置換タグ(前)
325                 $this->tmpl->addVar('_widget', 'tag_end', M3_TAG_END);          // 置換タグ(後)
326                 if (!empty($isTargetContent)) $this->tmpl->addVar('_widget', 'target_content_checked', 'checked');              // 汎用コンテンツを検索対象とするかどうか
327                 if (!empty($isTargetUser)) $this->tmpl->addVar('_widget', 'target_user_checked', 'checked');                    // ユーザ作成コンテンツを検索対象とするかどうか
328                 if (!empty($isTargetBlog)) $this->tmpl->addVar('_widget', 'target_blog_checked', 'checked');                    // ブログ記事を検索対象とするかどうか
329                 if (!empty($isTargetProduct)) $this->tmpl->addVar('_widget', 'target_product_checked', 'checked');                      // 商品情報を検索対象とするかどうか
330                 if (!empty($isTargetEvent)) $this->tmpl->addVar('_widget', 'target_event_checked', 'checked');                  // イベント情報を検索対象とするかどうか
331                 if (!empty($isTargetBbs)) $this->tmpl->addVar('_widget', 'target_bbs_checked', 'checked');                      // BBSを検索対象とするかどうか
332                 if (!empty($isTargetPhoto)) $this->tmpl->addVar('_widget', 'target_photo_checked', 'checked');                  // フォトギャラリーを検索対象とするかどうか
333                 $this->tmpl->addVar("_widget", "serial", $this->serialNo);// 選択中のシリアル番号、IDを設定
334                 
335                 // ボタンの表示制御
336                 if (empty($this->serialNo)){            // 新規追加項目を選択しているとき
337                         $this->tmpl->setAttribute('add_button', 'visibility', 'visible');// 「新規追加」ボタン
338                 } else {
339                         $this->tmpl->setAttribute('update_button', 'visibility', 'visible');// 「更新」ボタン
340                 }
341                 // ページ定義IDとページ定義のレコードシリアル番号を更新
342                 $this->endPageDefParam($defSerial, $defConfigId, $this->paramObj);
343         }
344         /**
345          * 選択用メニューを作成
346          *
347          * @return なし                                               
348          */
349         function createItemMenu()
350         {
351                 for ($i = 0; $i < count($this->paramObj); $i++){
352                         $id = $this->paramObj[$i]->id;// 定義ID
353                         $targetObj = $this->paramObj[$i]->object;
354                         $name = $targetObj->name;// 定義名
355                         $selected = '';
356
357                         if ($this->configId == $id) $selected = 'selected';
358                         $row = array(
359                                 'name' => $name,                // 名前
360                                 'value' => $id,         // 定義ID
361                                 'selected' => $selected // 選択中の項目かどうか
362                         );
363                         $this->tmpl->addVars('title_list', $row);
364                         $this->tmpl->parseTemplate('title_list', 'a');
365                 }
366         }
367         /**
368          * デフォルトの名前を取得
369          *
370          * @return string       デフォルト名                                              
371          */
372         function createDefaultName()
373         {
374                 $name = self::DEFAULT_NAME_HEAD;
375                 for ($j = 1; $j < 100; $j++){
376                         $name = self::DEFAULT_NAME_HEAD . $j;
377                         // 設定名の重複チェック
378                         for ($i = 0; $i < count($this->paramObj); $i++){
379                                 $targetObj = $this->paramObj[$i]->object;
380                                 if ($name == $targetObj->name){         // 定義名
381                                         break;
382                                 }
383                         }
384                         // 重複なしのときは終了
385                         if ($i == count($this->paramObj)) break;
386                 }
387                 return $name;
388         }
389         /**
390          * 一覧画面作成
391          *
392          * @param RequestManager $request               HTTPリクエスト処理クラス
393          * @param                                                               なし
394          */
395         function createList($request)
396         {
397                 // ページ定義IDとページ定義のレコードシリアル番号を取得
398                 $this->startPageDefParam($defSerial, $defConfigId, $this->paramObj);
399                 
400                 $userId         = $this->gEnv->getCurrentUserId();
401                 $langId = $this->gEnv->getCurrentLanguage();            // 表示言語を取得
402                 $act = $request->trimValueOf('act');
403                 
404                 if ($act == 'delete'){          // メニュー項目の削除
405                         $listedItem = explode(',', $request->trimValueOf('seriallist'));
406                         $delItems = array();
407                         for ($i = 0; $i < count($listedItem); $i++){
408                                 // 項目がチェックされているかを取得
409                                 $itemName = 'item' . $i . '_selected';
410                                 $itemValue = ($request->trimValueOf($itemName) == 'on') ? 1 : 0;
411                                 
412                                 if ($itemValue){                // チェック項目
413                                         $delItems[] = $listedItem[$i];
414                                 }
415                         }
416                         if (count($delItems) > 0){
417                                 $ret = $this->delPageDefParam($defSerial, $defConfigId, $this->paramObj, $delItems);
418                                 if ($ret){              // データ削除成功のとき
419                                         $this->setGuidanceMsg('データを削除しました');
420                                 } else {
421                                         $this->setAppErrorMsg('データ削除に失敗しました');
422                                 }
423                         }
424                 }
425                 // 定義一覧作成
426                 $this->createItemList();
427                 
428                 $this->tmpl->addVar("_widget", "serial_list", implode($this->serialArray, ','));// 表示項目のシリアル番号を設定
429                 
430                 // ページ定義IDとページ定義のレコードシリアル番号を更新
431                 $this->endPageDefParam($defSerial, $defConfigId, $this->paramObj);
432         }
433         /**
434          * 定義一覧作成
435          *
436          * @return なし                                               
437          */
438         function createItemList()
439         {
440                 for ($i = 0; $i < count($this->paramObj); $i++){
441                         $id = $this->paramObj[$i]->id;// 定義ID
442                         $targetObj = $this->paramObj[$i]->object;
443                         $name = $targetObj->name;// 定義名
444                         
445                         $defCount = 0;
446                         if (!empty($id)){
447                                 $defCount = $this->_db->getPageDefCount($this->gEnv->getCurrentWidgetId(), $id);
448                         }
449                         $operationDisagled = '';
450                         if ($defCount > 0) $operationDisagled = 'disabled';
451                         $row = array(
452                                 'index' => $i,
453                                 'ope_disabled' => $operationDisagled,                   // 選択可能かどうか
454                                 'name' => $this->convertToDispString($name),            // 名前
455                                 'def_count' => $defCount                                                        // 使用数
456                         );
457                         $this->tmpl->addVars('itemlist', $row);
458                         $this->tmpl->parseTemplate('itemlist', 'a');
459                         
460                         // シリアル番号を保存
461                         $this->serialArray[] = $id;
462                 }
463         }
464         /**
465          * 検索テンプレートデータ作成処理コールバック
466          *
467          * @param object         $tmpl                  テンプレートオブジェクト
468          * @param                                                               なし
469          */
470         function makeSearcheTemplate($tmpl)
471         {
472                 $tmpl->addVar("_tmpl", "widget_url",    $this->gEnv->getCurrentWidgetRootUrl());                // ウィジェットのURL
473                 $tmpl->addVar("_tmpl", "search_text_id",        $this->searchTextId);           // 検索用テキストフィールドのタグID
474                 $tmpl->addVar("_tmpl", "search_button_id",      $this->searchButtonId);         // 検索用ボタンのタグID
475                 $tmpl->addVar("_tmpl", "search_reset_id",       $this->searchResetId);          // 検索エリアリセットボタンのタグID
476         }
477         /**
478          * inputタグID用のヘッダ文字列を作成
479          *
480          * @return string       ID                                              
481          */
482         function createTagIdHead()
483         {
484                 return $this->gEnv->getCurrentWidgetId() . '_' . $this->getTempConfigId($this->paramObj);
485         }
486         /**
487          * 項目定義一覧を作成
488          *
489          * @return なし                                               
490          */
491         function createFieldList()
492         {
493                 $fieldCount = count($this->fieldInfoArray);
494                 for ($i = 0; $i < $fieldCount; $i++){
495                         $infoObj = $this->fieldInfoArray[$i];
496                         $categoryType = $infoObj->categoryType;// カテゴリ種別
497                         $selectType = $infoObj->selectType;             // 選択方法
498                         $titleVisible = $infoObj->titleVisible;         // タイトル表示制御
499                         $initValue = $infoObj->initValue;               // 初期値
500
501                         // カテゴリ種別メニュー作成
502                         $this->tmpl->clearTemplate('type_list2');
503                         
504                         for ($j = 0; $j < count($this->categoryArray); $j++){
505                                 $value = $this->categoryArray[$j]['value'];
506                                 $name = $this->categoryArray[$j]['name'];
507
508                                 $selected = '';
509                                 if ($value == $categoryType) $selected = 'selected';
510
511                                 $tableLine = array(
512                                         'value'    => $value,                   // タイプ値
513                                         'name'     => $this->convertToDispString($name),                        // タイプ名
514                                         'selected' => $selected                 // 選択中かどうか
515                                 );
516                                 $this->tmpl->addVars('type_list2', $tableLine);
517                                 $this->tmpl->parseTemplate('type_list2', 'a');
518                         }
519                         
520                         // 選択方法メニュー作成
521                         $this->tmpl->clearTemplate('sel_type_list2');
522                         
523                         for ($j = 0; $j < count($this->selTypeArray); $j++){
524                                 $value = $this->selTypeArray[$j]['value'];
525                                 $name = $this->selTypeArray[$j]['name'];
526
527                                 $selected = '';
528                                 if ($value == $selectType) $selected = 'selected';
529
530                                 $tableLine = array(
531                                         'value'    => $value,                   // タイプ値
532                                         'name'     => $this->convertToDispString($name),                        // タイプ名
533                                         'selected' => $selected                 // 選択中かどうか
534                                 );
535                                 $this->tmpl->addVars('sel_type_list2', $tableLine);
536                                 $this->tmpl->parseTemplate('sel_type_list2', 'a');
537                         }
538                         
539                         // タイトルの表示制御
540                         $checked = '';
541                         if (!empty($titleVisible)) $checked = 'checked';
542                         
543                         $row = array(
544                                 'root_url' => $this->convertToDispString($this->getUrl($this->gEnv->getRootUrl())),
545                                 'title_visible_checked' => $checked,
546                                 'init_value' => $this->convertToDispString($initValue)
547                         );
548                         $this->tmpl->addVars('field_list', $row);
549                         $this->tmpl->parseTemplate('field_list', 'a');
550                 }
551         }
552         /**
553          * カテゴリメニュー作成
554          *
555          * @return なし
556          */
557         function createCategoryMenu()
558         {
559                 for ($i = 0; $i < count($this->categoryArray); $i++){
560                         $value = $this->categoryArray[$i]['value'];
561                         $name = $this->categoryArray[$i]['name'];
562                         
563                         $row = array(
564                                 'value'    => $value,                   // タイプ値
565                                 'name'     => $this->convertToDispString($name),                        // タイプ名
566                                 'selected' => $selected                 // 選択中かどうか
567                         );
568                         $this->tmpl->addVars('type_list', $row);
569                         $this->tmpl->parseTemplate('type_list', 'a');
570                 }
571         }
572         /**
573          * 項目選択タイプメニュー作成
574          *
575          * @return なし
576          */
577         function createSelTypeMenu()
578         {
579                 for ($i = 0; $i < count($this->selTypeArray); $i++){
580                         $value = $this->selTypeArray[$i]['value'];
581                         $name = $this->selTypeArray[$i]['name'];
582                         
583                         $row = array(
584                                 'value'    => $value,                   // タイプ値
585                                 'name'     => $this->convertToDispString($name),                        // タイプ名
586                                 'selected' => $selected                 // 選択中かどうか
587                         );
588                         $this->tmpl->addVars('sel_type_list', $row);
589                         $this->tmpl->parseTemplate('sel_type_list', 'a');
590                 }
591         }
592 }
593 ?>