7 * LICENSE: This source file is licensed under the terms of the GNU General Public License.
10 * @author 株式会社 毎日メディアサービス
11 * @copyright Copyright 2010-2013 株式会社 毎日メディアサービス.
12 * @license http://www.gnu.org/copyleft/gpl.html GPL License
13 * @version SVN: $Id: custom_searchWidgetContainer.php 5969 2013-04-29 13:16:04Z fishbone $
14 * @link http://www.m-media.co.jp
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17 require_once($gEnvManager->getCurrentWidgetDbPath() . '/custom_searchDb.php');
19 class custom_searchWidgetContainer extends BaseWidgetContainer
21 private $db; // DB接続オブジェクト
22 private $langId; // 現在の言語
23 private $categoryInfoArray = array(); // カテゴリ種別メニュー
24 private $resultCount; // 結果表示件数
25 const DEFAULT_CONFIG_ID = 0;
26 const DEFAULT_TITLE = 'カスタム検索'; // デフォルトのウィジェットタイトル
27 const FIELD_HEAD = 'item'; // フィールド名の先頭文字列
28 const DEFAULT_SEARCH_COUNT = 20; // デフォルトの検索結果表示数
29 const LINK_PAGE_COUNT = 10; // リンクページ数
30 const MESSAGE_NO_KEYWORD = '検索キーワードが入力されていません';
31 const MESSAGE_FIND_NO_CONTENT = '該当するコンテンツが見つかりません';
32 const CONTENT_SIZE = 200; // 検索結果コンテンツの文字列最大長
33 const SEARCH_LIST_CONTENT_ID = 'SEARCH_LIST'; // 検索一覧に表示するコンテンツのID
34 const DEFAULT_SEARCH_ACT = 'custom_search'; // 検索実行処理
39 function __construct()
42 parent::__construct();
45 $this->db = new custom_searchDb();
50 * _assign()でデータを埋め込むテンプレートファイルのファイル名を返す。
51 * 読み込むディレクトリは、「自ウィジェットディレクトリ/include/template」に固定。
53 * @param RequestManager $request HTTPリクエスト処理クラス
54 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
55 * @return string テンプレートファイル名。テンプレートライブラリを使用しない場合は空文字列「''」を返す。
57 function _setTemplate($request, &$param)
59 return 'index.tmpl.html';
64 * _setTemplate()で指定したテンプレートファイルにデータを埋め込む。
66 * @param RequestManager $request HTTPリクエスト処理クラス
67 * @param object $param 任意使用パラメータ。_setTemplate()と共有。
70 function _assign($request, &$param)
72 $this->langId = $this->gEnv->getCurrentLanguage();
73 $this->currentPageUrl = $this->gEnv->createCurrentPageUrl();// 現在のページURL
76 $configId = $this->gEnv->getCurrentWidgetConfigId();
77 if (empty($configId)) $configId = self::DEFAULT_CONFIG_ID;
80 $targetObj = $this->getWidgetParamObjByConfigId($configId);
81 if (empty($targetObj)){ // 定義データが取得できないとき
82 $this->cancelParse(); // テンプレート変換処理中断
86 // ログインユーザでないときは、ユーザ制限のない項目だけ表示
88 if ($this->gEnv->isCurrentUserLogined()) $isAll = true;
90 $name = $targetObj->name;// 定義名
91 $this->resultCount = intval($targetObj->resultCount); // 表示項目数
92 if ($this->resultCount <= 0) $this->resultCount = self::DEFAULT_SEARCH_COUNT;
93 $this->searchTextId = $targetObj->searchTextId; // 検索用テキストフィールドのタグID
94 $this->searchButtonId = $targetObj->searchButtonId; // 検索用ボタンのタグID
95 $this->searchResetId = $targetObj->searchResetId; // 検索エリアリセットボタンのタグID
96 $isTargetContent = $targetObj->isTargetContent; // 汎用コンテンツを検索対象とするかどうか
97 $isTargetUser = $targetObj->isTargetUser; // ユーザ作成コンテンツを検索対象とするかどうか
98 $isTargetBlog = $targetObj->isTargetBlog; // ブログ記事を検索対象とするかどうか
99 $isTargetProduct = $targetObj->isTargetProduct; // 商品情報を検索対象とするかどうか
100 $isTargetEvent = $targetObj->isTargetEvent; // イベント情報を検索対象とするかどうか
101 $isTargetBbs = $targetObj->isTargetBbs; // BBSを検索対象とするかどうか
102 $isTargetPhoto = $targetObj->isTargetPhoto; // フォトギャラリーを検索対象とするかどうか
103 $searchTemplate = $targetObj->searchTemplate; // 検索用テンプレート
104 if (!empty($targetObj->fieldInfo)) $this->fieldInfoArray = $targetObj->fieldInfo; // 項目定義
105 $searchFormId = $this->gEnv->getCurrentWidgetId() . '_' . $configId . '_form'; // フォームのID
106 $pageNo = $request->trimIntValueOf(M3_REQUEST_PARAM_PAGE_NO, '1'); // ページ番号
109 $this->valueArray = array();
110 $categoryArray = array();
111 $fieldCount = count($this->fieldInfoArray);
112 for ($i = 0; $i < $fieldCount; $i++){
113 $itemName = self::FIELD_HEAD . ($i + 1);
114 $itemValue = $request->trimValueOf($itemName);
115 $this->valueArray[] = $itemValue;
118 $categoryType = $this->fieldInfoArray[$i]->categoryType;
119 if (!in_array($categoryType, $categoryArray)) $categoryArray[] = $categoryType; // カテゴリ種別メニュー
121 $keyword = $request->trimValueOf('keyword'); // 検索キーワード
122 $act = $request->trimValueOf('act');
123 // ##### joomla!検索インターフェイス #####
124 $task = $request->trimValueOf('task');
125 $option = $request->trimValueOf('option');
127 if ($act == self::DEFAULT_SEARCH_ACT || // 検索実行
128 ($task == 'search' && $option == 'com_search')){ // joomla!検索インターフェイスからの検索
130 // ##### joomla!検索インターフェイスからの実行の場合 #####
131 if ($task == 'search' && $option == 'com_search'){
132 $keyword = $request->trimValueOf('searchword'); // 検索キーワード
135 // 検索キーワードが空以外の場合は、キーワードログを残す
136 $parsedKeywords = array();
137 if (!empty($keyword)){
139 $parsedKeywords = $this->gInstance->getTextConvManager()->parseSearchKeyword($keyword);
142 for ($i = 0; $i < count($parsedKeywords); $i++){
143 $this->gInstance->getAnalyzeManager()->logSearchWord($this->gEnv->getCurrentWidgetId(), $parsedKeywords[$i]);
148 $selectCategory = array();
149 $fieldCount = count($this->fieldInfoArray);
150 for ($i = 0; $i < $fieldCount; $i++){
151 $infoObj = $this->fieldInfoArray[$i];
152 $categoryType = $infoObj->categoryType; // カテゴリ種別
155 $inputValue = $this->valueArray[$i]; // 入力値
156 if (!empty($inputValue)) $selectCategory[$categoryType] = $inputValue; // 入力値
159 // 入力条件が検索キーワードのみの場合、キーワードが入力されていなければエラーメッセージを表示
160 if ($fieldCount == 0 && empty($parsedKeywords)){
161 $message = self::MESSAGE_NO_KEYWORD;
163 // ##### 検索実行の場合 #####
165 // $totalCount = $this->db->searchContentsCountByKeyword($parsedKeywords, $selectCategory, $this->langId, $isAll, $isTargetContent, $isTargetUser, $isTargetBlog,
166 // $isTargetProduct, $isTargetEvent, $isTargetBbs, $isTargetPhoto);
167 $totalCount = $this->db->searchContentsByKeyword(0/*項目数取得*/, 0/*ダミー*/, $parsedKeywords, $selectCategory, $this->langId, $isAll, $isTargetContent, $isTargetUser, $isTargetBlog,
168 $isTargetProduct, $isTargetEvent, $isTargetBbs, $isTargetPhoto);
171 $pageLink = $this->createPageLink($pageNo, $totalCount, $this->resultCount, $this->currentPageUrl . '&act=' . self::DEFAULT_SEARCH_ACT . '&keyword=' . urlencode($keyword));
174 $this->db->searchContentsByKeyword($this->resultCount, $pageNo, $parsedKeywords, $selectCategory, $this->langId, $isAll, $isTargetContent, $isTargetUser, $isTargetBlog,
175 $isTargetProduct, $isTargetEvent, $isTargetBbs, $isTargetPhoto, array($this, 'searchItemsLoop'));
177 if ($this->isExistsViewData){
179 if (!empty($pageLink)){
180 $this->tmpl->setAttribute('page_link_top', 'visibility', 'visible'); // リンク表示
181 $this->tmpl->setAttribute('page_link', 'visibility', 'visible'); // リンク表示
182 $this->tmpl->addVar("page_link_top", "page_link", $pageLink);
183 $this->tmpl->addVar("page_link", "page_link", $pageLink);
185 } else { // 検索結果なしの場合
186 $this->tmpl->setAttribute('result_list', 'visibility', 'hidden');
187 $message = self::MESSAGE_FIND_NO_CONTENT;
192 $ret = $this->db->getAllCategoryForMenu($this->langId, $categoryArray, $rows);
195 $rowCount = count($rows);
196 for ($i = 0; $i < $rowCount; $i++){
198 $itemId = $rows[$i]['ua_item_id'];
199 if (empty($itemId)){ // カテゴリ種別のとき
200 $categoryId = $rows[$i]['ua_id'];
201 $this->categoryInfoArray[$categoryId] = $line;
207 if (!empty($message)){
208 $this->tmpl->setAttribute('message', 'visibility', 'visible');
209 $this->tmpl->addVar("message", "message", $this->convertToDispString($message));
213 $fieldOutput = $this->createFieldOutput($searchTemplate);
216 $this->tmpl->addVar("_widget", "page_sub", $this->gEnv->getCurrentPageSubId()); // ページサブID
217 $this->tmpl->addVar("_widget", "html", $fieldOutput);
218 $this->tmpl->addVar("_widget", "search_text_id", $this->searchTextId); // 検索用テキストフィールドのタグID
219 $this->tmpl->addVar("_widget", "search_button_id", $this->searchButtonId); // 検索用ボタンのタグID
220 $this->tmpl->addVar("_widget", "search_reset_id", $this->searchResetId); // 検索エリアリセットボタンのタグID
221 $this->tmpl->addVar("_widget", "search_form_id", $searchFormId); // 検索フォームのタグID
222 $this->tmpl->addVar("_widget", "keyword", $keyword); // 検索キーワード
223 $this->tmpl->addVar("_widget", "search_act", self::DEFAULT_SEARCH_ACT); // 検索実行処理
228 * @param RequestManager $request HTTPリクエスト処理クラス
229 * @param object $param 任意使用パラメータ。そのまま_assign()に渡る
230 * @return string ウィジェットのタイトル名
232 function _setTitle($request, &$param)
234 return self::DEFAULT_TITLE;
239 * @param string $templateData テンプレートデータ
240 * @return string フィールドデータ
242 function createFieldOutput($templateData)
244 $fieldOutput = $templateData;
246 $fieldCount = count($this->fieldInfoArray);
247 for ($i = 0; $i < $fieldCount; $i++){
248 $infoObj = $this->fieldInfoArray[$i];
249 $categoryType = $infoObj->categoryType; // カテゴリ種別
250 $selectType = $infoObj->selectType; // 選択タイプ
251 $titleVisible = $infoObj->titleVisible; // タイトル表示制御
252 $initValue = $infoObj->initValue; // 初期値
253 $categoryItems = $this->categoryInfoArray[$categoryType]; // カテゴリ項目
254 $categoryItemCount = count($categoryItems) -1;
255 $categoryName = $categoryItems[$categoryItemCount]['ua_name']; // カテゴリ種別名
259 $fieldName = self::FIELD_HEAD . ($i + 1);
260 $inputValue = $this->valueArray[$i]; // 入力値
262 switch ($selectType){
263 case 'single': // 単一選択
265 if (!empty($titleVisible)) $inputTag .= $this->convertToDispString($categoryName);
267 $inputTag .= '<select id="' . $fieldName . '" name="' . $fieldName . '" >' . M3_NL;
269 if (!empty($initValue)) $name = $this->convertToDispString($initValue);
270 $inputTag .= '<option value="">' . $name . '</option>' . M3_NL;
271 for ($j = 0; $j < $categoryItemCount; $j++){
274 $value = $categoryItems[$j]['ua_item_id'];
275 $name = $categoryItems[$j]['ua_name'];
276 if (!empty($inputValue) && strcmp($inputValue, $value) == 0) $param[] = 'selected';
277 if (count($param) > 0) $paramStr = ' ' . implode($param, ' ');
278 $inputTag .= '<option value="' . $this->convertToDispString($value) . '"' . $paramStr . '>' . $this->convertToDispString($name) . '</option>' . M3_NL;
280 $inputTag .= '</select>' . M3_NL;
282 case 'multi': // 複数選択
286 if (!empty($titleVisible)) $inputTag .= $this->convertToDispString($categoryName);
288 for ($j = 0; $j < $categoryItemCount; $j++){
291 $value = $categoryItems[$j]['ua_item_id'];
292 $name = $categoryItems[$j]['ua_name'];
293 for ($k = 0; $k < count($inputValue); $k++){
294 if (!empty($inputValue[$k]) && strcmp($inputValue[$k], $value) == 0) $param[] = 'checked';
296 if (count($param) > 0) $paramStr = ' ' . implode($param, ' ');
297 $inputTag .= '<label><input type="checkbox" name="' . $fieldName . '" value="' . $this->convertToDispString($value) . '"'
298 . $paramStr . ' />' . $this->convertToDispString($name) . '</label>';
305 $keyTag = M3_TAG_START . M3_TAG_MACRO_ITEM_KEY . ($i + 1) . M3_TAG_END;
306 $fieldOutput = str_replace($keyTag, $inputTag, $fieldOutput);
311 * 取得したコンテンツ項目をテンプレートに設定する
313 * @param int $index 行番号
314 * @param array $fetchedRow 取得行
315 * @param object $param 任意使用パラメータ
316 * @return bool trueを返すとループ続行。falseを返すとその時点で終了。
318 function searchItemsLoop($index, $fetchedRow)
322 $summary = ''; // コンテンツ概要
323 $contentType = $fetchedRow['type'];
324 switch ($contentType){
325 case M3_VIEW_TYPE_CONTENT: // 汎用コンテンツの場合
326 $contentId = $fetchedRow['id'];
329 $linkUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_CONTENT_ID . '=' . $contentId, true/*リンク用*/);
332 $ret = $this->db->getContentByContentId(''/*汎用コンテンツ*/, $contentId, $this->langId, $row);
335 $content = $this->gInstance->getTextConvManager()->htmlToText($row['cn_html']);
338 // *** キーワード部分の検索はどうする? ***
339 $this->gInstance->getTextConvManager()->convByKeyValue($content, $content);
341 // 検索結果用にテキストを詰める。改行、タブ、スペース削除。
342 $content = str_replace(array("\r", "\n", "\t", " "), '', $content);
345 if (function_exists('mb_strimwidth')){
346 $content = mb_strimwidth($content, 0, self::CONTENT_SIZE, '…');
348 $content = substr($content, 0, self::CONTENT_SIZE) . '...';
353 case M3_VIEW_TYPE_USER: // ユーザ作成コンテンツの場合
354 $roomId = $fetchedRow['id'];
355 $groupId = $fetchedRow['group_id']; // ルームの所属グループ
358 $linkUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?'. M3_REQUEST_PARAM_ROOM_ID . '=' . $roomId, true/*リンク用*/);
360 // ルームIDに対応したコンテンツをすべて取得
361 $contentArray = $this->getAllContent($roomId, $this->langId, $searchListItemId);
363 if (empty($searchListItemId)){ // 検索一覧用データがないとき
365 $ret = $this->db->getDefaultTab($this->langId, $groupId, $defaultTabRow);
367 // 検索一覧用のコンテンツかデフォルトのタブの内容を表示
370 $content = $defaultTabRow['ub_template_html'];
373 $useItemArray = array();
374 $useItem = $defaultTabRow['ub_use_item_id'];
375 if (!empty($useItem)){
376 $useItemArray = explode(',', $useItem);
380 for ($i = 0; $i < count($useItemArray); $i++){
381 $itemId = $useItemArray[$i];
382 $keyTag = M3_TAG_START . M3_TAG_MACRO_ITEM_KEY . $itemId . M3_TAG_END;// 埋め込みタグ
384 $contentInfo = $contentArray[$itemId];
385 if (isset($contentInfo)){
386 $contentData = $contentInfo['uc_data'];
388 // テキスト、数値のときは文字エスケープ処理
389 if ($contentInfo['ui_type'] != 0){
390 $contentData = $this->convertToDispString($contentData);
396 $content = str_replace($keyTag, $contentData, $content);
400 $content = $this->gInstance->getTextConvManager()->htmlToText($content);
402 // 検索結果用にテキストを詰める。改行、タブ、スペース削除。
403 $content = str_replace(array("\r", "\n", "\t", " "), '', $content);
406 if (function_exists('mb_strimwidth')){
407 $content = mb_strimwidth($content, 0, self::CONTENT_SIZE, '…');
409 $content = substr($content, 0, self::CONTENT_SIZE) . '...';
413 } else { // 検索一覧用データがあるとき
414 $contentInfo = $contentArray[$searchListItemId];
415 if (isset($contentInfo)){
416 $contentData = $contentInfo['uc_data'];
418 // テキスト、数値のときは文字エスケープ処理
419 if ($contentInfo['ui_type'] != 0){
420 $contentData = $this->convertToDispString($contentData);
425 $summary = $contentData;
428 case M3_VIEW_TYPE_BLOG: // ブログコンテンツの場合
429 $entryId = $fetchedRow['id'];
432 $linkUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_BLOG_ENTRY_ID . '=' . $entryId, true/*リンク用*/);
435 $ret = $this->db->getEntryByEntryId($entryId, $this->langId, $row);
438 $content = $this->gInstance->getTextConvManager()->htmlToText($row['be_html']);
440 // 検索結果用にテキストを詰める。改行、タブ、スペース削除。
441 $content = str_replace(array("\r", "\n", "\t", " "), '', $content);
444 if (function_exists('mb_strimwidth')){
445 $content = mb_strimwidth($content, 0, self::CONTENT_SIZE, '…');
447 $content = substr($content, 0, self::CONTENT_SIZE) . '...';
452 case M3_VIEW_TYPE_PRODUCT: // 商品情報の場合
453 $productId = $fetchedRow['id'];
456 $linkUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_PRODUCT_ID . '=' . $productId, true/*リンク用*/);
459 $ret = $this->db->getProductByProductId($productId, $this->langId, $row);
461 $summary = $row['pt_description_short'];
462 if (empty($summary)){
464 $content = $this->gInstance->getTextConvManager()->htmlToText($row['pt_description']);
466 // 検索結果用にテキストを詰める。改行、タブ、スペース削除。
467 $content = str_replace(array("\r", "\n", "\t", " "), '', $content);
470 if (function_exists('mb_strimwidth')){
471 $content = mb_strimwidth($content, 0, self::CONTENT_SIZE, '…');
473 $content = substr($content, 0, self::CONTENT_SIZE) . '...';
479 case M3_VIEW_TYPE_EVENT: // イベント情報の場合
480 $eventId = $fetchedRow['id'];
483 $linkUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_EVENT_ID . '=' . $eventId, true/*リンク用*/);
486 $ret = $this->db->getEvent($eventId, $this->langId, $row);
488 $summary = $row['ee_summary'];
489 if (empty($summary)){
491 $content = $this->gInstance->getTextConvManager()->htmlToText($row['ee_html']);
493 // 検索結果用にテキストを詰める。改行、タブ、スペース削除。
494 $content = str_replace(array("\r", "\n", "\t", " "), '', $content);
497 if (function_exists('mb_strimwidth')){
498 $content = mb_strimwidth($content, 0, self::CONTENT_SIZE, '…');
500 $content = substr($content, 0, self::CONTENT_SIZE) . '...';
506 case M3_VIEW_TYPE_BBS: // BBSスレッド情報の場合
507 $threadId = $fetchedRow['id'];
510 $linkUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_BBS_THREAD_ID . '=' . $threadId, true/*リンク用*/);
513 $ret = $this->db->getBbsThread($threadId, $row);
516 $content = $this->gInstance->getTextConvManager()->htmlToText($row['te_message']);
518 // 検索結果用にテキストを詰める。改行、タブ、スペース削除。
519 $content = str_replace(array("\r", "\n", "\t", " "), '', $content);
522 if (function_exists('mb_strimwidth')){
523 $content = mb_strimwidth($content, 0, self::CONTENT_SIZE, '…');
525 $content = substr($content, 0, self::CONTENT_SIZE) . '...';
530 case M3_VIEW_TYPE_PHOTO: // フォト情報の場合
531 $photoId = $fetchedRow['id'];
534 $linkUrl = $this->getUrl($this->gEnv->getDefaultUrl() . '?' . M3_REQUEST_PARAM_PHOTO_ID . '=' . $photoId, true/*リンク用*/);
537 $ret = $this->db->getPhoto($photoId, $this->langId, $row);
539 $summary = $row['ht_summary'];
540 if (empty($summary)){
542 $content = $this->gInstance->getTextConvManager()->htmlToText($row['ht_description']);
544 // 検索結果用にテキストを詰める。改行、タブ、スペース削除。
545 $content = str_replace(array("\r", "\n", "\t", " "), '', $content);
548 if (function_exists('mb_strimwidth')){
549 $content = mb_strimwidth($content, 0, self::CONTENT_SIZE, '…');
551 $content = substr($content, 0, self::CONTENT_SIZE) . '...';
560 $titleLink = $this->convertToDispString($fetchedRow['name']);
561 if (!empty($linkUrl)) $titleLink = '<a href="' . $this->convertUrlToHtmlEntity($linkUrl) . '" >' . $titleLink . '</a>';
564 'title' => $titleLink, // タイトル
565 'body' => $summary // コンテンツ概要
567 $this->tmpl->addVars('result_list', $row);
568 $this->tmpl->parseTemplate('result_list', 'a');
569 $this->isExistsViewData = true; // 表示データがあるかどうか
575 * @param string $roomId ルームID
576 * @param string $langId 言語ID
577 * @param string $listItemId 検索一覧に表示するコンテンツのID
578 * @return array コンテンツ項目IDをキーにしたコンテンツ項目レコードの連想配列
580 function getAllContent($roomId, $langId, &$listItemId)
582 $destArray = array();
584 $ret = $this->db->getAllContentsByRoomId($roomId, $langId, $rows);
586 $count = count($rows);
587 for ($i = 0; $i < $count; $i++){
588 $key = $rows[$i]['uc_id'];
589 $destArray[$key] = $rows[$i];
592 if ($rows[$i]['ui_key'] == self::SEARCH_LIST_CONTENT_ID) $listItemId = $key;
600 * @param int $pageNo ページ番号(1~)。ページ番号が範囲外にある場合は自動的に調整
601 * @param int $totalCount 総項目数
602 * @param int $viewItemCount 1ページあたりの項目数
603 * @param string $baseUrl リンク用のベースURL
604 * @return string リンクHTML
606 function createPageLink(&$pageNo, $totalCount, $viewItemCount, $baseUrl)
609 $pageCount = (int)(($totalCount -1) / $viewItemCount) + 1; // 総ページ数
610 if ($pageNo < 1) $pageNo = 1;
611 if ($pageNo > $pageCount) $pageNo = $pageCount;
615 if ($pageCount > 1){ // ページが2ページ以上のときリンクを作成
616 //for ($i = 1; $i <= $pageCount; $i++){
617 // ページ数1から「LINK_PAGE_COUNT」までのリンクを作成
618 $maxPageCount = $pageCount < self::LINK_PAGE_COUNT ? $pageCount : self::LINK_PAGE_COUNT;
619 for ($i = 1; $i <= $maxPageCount; $i++){
621 $link = ' ' . $i;
623 //$linkUrl = $this->getUrl($baseUrl . '&page=' . $i, true/*リンク用*/);
624 $linkUrl = $this->getUrl($this->addSearchParam($baseUrl . '&page=' . $i), true/*リンク用*/);
625 $link = ' <a href="' . $this->convertUrlToHtmlEntity($linkUrl) . '" >' . $i . '</a>';
630 if ($pageCount > self::LINK_PAGE_COUNT) $pageLink .= ' ...';
632 if ($pageNo > 1){ // 前ページがあるとき
633 //$linkUrl = $this->getUrl($baseUrl . '&page=' . ($pageNo -1), true/*リンク用*/);
634 $linkUrl = $this->getUrl($this->addSearchParam($baseUrl . '&page=' . ($pageNo -1)), true/*リンク用*/);
635 $link = '<a href="' . $this->convertUrlToHtmlEntity($linkUrl) . '" >前へ</a>';
636 $pageLink = $link . $pageLink;
638 if ($pageNo < $pageCount){ // 次ページがあるとき
639 //$linkUrl = $this->getUrl($baseUrl . '&page=' . ($pageNo +1), true/*リンク用*/);
640 $linkUrl = $this->getUrl($this->addSearchParam($baseUrl . '&page=' . ($pageNo +1)), true/*リンク用*/);
641 $link = ' <a href="' . $this->convertUrlToHtmlEntity($linkUrl) . '" >次へ</a>';
649 * @param string $url URL
650 * @return string 作成されたURL
652 function addSearchParam($url)
655 $fieldCount = count($this->fieldInfoArray);
656 for ($i = 0; $i < $fieldCount; $i++){
657 $itemName = self::FIELD_HEAD . ($i + 1);
658 $itemValue = $this->gRequest->trimValueOf($itemName);
659 if (is_array($itemValue)){
660 $paramCount = count($itemValue);
661 for ($j = 0; $j < $paramCount; $j++){
662 $destUrl .= '&' . $itemName . '[]=' . urlencode($itemValue[$j]);
665 if (!empty($itemValue)) $destUrl .= '&' . $itemName . '=' . urlencode($itemValue);