2011/07/08 調整。
@@ -262,7 +262,7 @@ | ||
262 | 262 | //var_dump($_POST); |
263 | 263 | |
264 | 264 | //バリデート |
265 | - $vld = $this->lordLib('Validation'); | |
265 | + $vld = $this->loadLib('Validation'); | |
266 | 266 | $this->postSet['errMessage'] = ''; |
267 | 267 | $this->postSet['errMsgAry'] = array(); |
268 | 268 |
@@ -415,7 +415,7 @@ | ||
415 | 415 | |
416 | 416 | |
417 | 417 | //データ加工 |
418 | - $dh = $this->lordLib('dataHelper'); | |
418 | + $dh = $this->loadLib('dataHelper'); | |
419 | 419 | $data['pwHash'] = $dh->makePasswordHash($this->getPost('password')); |
420 | 420 | $data['personKey'] = |
421 | 421 | $dh->makePersonKey($this->getPost('author'), $this->getPost('password'), $GLOBALS['USR']['access']['host']); |
@@ -9,16 +9,101 @@ | ||
9 | 9 | */ |
10 | 10 | |
11 | 11 | |
12 | +class Search_Action extends Base_Action { | |
12 | 13 | |
13 | -class Display_Action extends Base_Action { | |
14 | 14 | |
15 | - | |
16 | 15 | public function __construct() |
17 | 16 | { |
17 | + parent::__construct(); | |
18 | 18 | |
19 | + } | |
20 | + | |
21 | + public function input() | |
22 | + { | |
23 | + | |
24 | + if ( empty($_POST) ) { | |
25 | + $this->postSet['errMessage'] = ''; | |
26 | + $this->postSet['errMsgAry'] = array(); | |
27 | + $this->postSet['word'] = ''; | |
28 | + $this->postSet['mode'] = 1; | |
29 | + } | |
30 | + | |
31 | + //スキン | |
32 | + $this->readSkin('search'); | |
33 | + | |
34 | + | |
35 | + | |
36 | + | |
37 | + $myContent = getSearchInputHtml($this->baseSet, $this->postSet); | |
38 | + | |
39 | + $this->content = $myContent; | |
40 | + | |
41 | + | |
42 | + $this->set['view'] = __FUNCTION__; | |
43 | + $this->setLayout('base'); | |
44 | + | |
45 | + return true; | |
46 | + | |
47 | + } | |
48 | + | |
49 | + public function result() | |
50 | + { | |
51 | + | |
52 | + | |
53 | + | |
54 | + // | |
55 | + $word = $this->getPost('word'); | |
56 | + $mode = $this->getPost('mode', 1); | |
57 | + | |
58 | + // | |
59 | + if ( empty($word) or mb_strlen($word)<2 ) { | |
60 | + | |
61 | + // | |
62 | + $this->postSet['word'] = $_POST['word']; | |
63 | + $this->postSet['mode'] = $_POST['mode']; | |
64 | + | |
65 | + $this->postSet['errMessage'] = $GLOBALS['LNG']['postInvalid']; | |
66 | + $this->postSet['errMsgAry'][0] = $GLOBALS['LNG']['searchWordLess']; | |
67 | + $this->input(); | |
68 | + return; | |
69 | + } | |
70 | + | |
71 | + | |
72 | + //接続 | |
73 | + $j = ' AND '; | |
74 | + if ( $mode==2 ) $j = ' OR '; | |
75 | + | |
76 | + //条件 | |
77 | + $wordAry = explode(' ', $word); | |
78 | + $wordQ = ''; | |
79 | + foreach ( $wordAry as $w ) { | |
80 | + if ( $wordQ ) { | |
81 | + $wordQ .= $j; | |
82 | + } | |
83 | + $wordQ .= '( subject LIKE \'%' . $w . '%\' OR author LIKE \'%' . $w . '%\''. | |
84 | + ' OR article LIKE \'%' . $w . '%\' )'; | |
85 | + | |
86 | + } | |
87 | + $where = " status_code<9 AND ( " .$wordQ." )"; | |
88 | + | |
89 | + | |
90 | + $artMdl = $this->loadModel('Article'); | |
91 | + $articles = $artMdl->selectArticles($where, 'id DESC', 50); | |
92 | + | |
93 | + | |
94 | + //スキン | |
95 | + $this->readSkin('search'); | |
96 | + | |
97 | + $myContent = getSearchResultHtml($articles, $this->baseSet); | |
98 | + | |
99 | + $this->content = $myContent; | |
100 | + | |
101 | + | |
102 | + $this->set['view'] = __FUNCTION__; | |
103 | + $this->setLayout('base'); | |
104 | + | |
105 | + return true; | |
19 | 106 | } |
20 | - | |
21 | - | |
22 | 107 | } |
23 | 108 | |
24 | 109 | ?> |
\ No newline at end of file |
@@ -134,10 +134,19 @@ | ||
134 | 134 | |
135 | 135 | protected function loadLib($className) |
136 | 136 | { |
137 | - require_once( APPPATH. "/libs/" . strtolower ($className). '.php' ); | |
137 | + require_once( APPPATH. '/libs/' . strtolower($className). '.php' ); | |
138 | 138 | return new $className(); |
139 | 139 | } |
140 | 140 | |
141 | + protected function loadModel($className) | |
142 | + { | |
143 | + require_once( APPPATH . '/models/' . strtolower($className). '_model.php' ); | |
144 | + | |
145 | + $className .= '_Model'; | |
146 | + return new $className(); | |
147 | + } | |
148 | + | |
149 | + | |
141 | 150 | |
142 | 151 | /** |
143 | 152 | * POSTの画面戻し用。 |
@@ -130,7 +130,7 @@ | ||
130 | 130 | |
131 | 131 | /** |
132 | 132 | * ※SQLiteのトランザクションは微妙なので、こちらを補助に使って制御。 |
133 | - * | |
133 | + * @param string filePath | |
134 | 134 | */ |
135 | 135 | function makeLock($filePath) |
136 | 136 | { |
@@ -343,7 +343,25 @@ | ||
343 | 343 | } |
344 | 344 | |
345 | 345 | |
346 | + | |
347 | + function selectArticles($where, $order, $limit) { | |
346 | 348 | |
349 | + $this->openConn(); | |
350 | + | |
351 | + $sql = "SELECT * FROM epitta_articles " | |
352 | + . " WHERE " . $where . " ORDER BY " . $order . " LIMIT " . $limit; | |
353 | + | |
354 | + echo $sql; | |
355 | + $rows = $this->getRecord($sql, true); | |
356 | + | |
357 | + $this->closeConn(); | |
358 | + | |
359 | + return $rows; | |
360 | + | |
361 | + } | |
362 | + | |
363 | + | |
364 | + | |
347 | 365 | //-------------------------- |
348 | 366 | |
349 | 367 |
@@ -30,7 +30,10 @@ | ||
30 | 30 | 'crtipt' =>array( 'act'=>'Post', 'func'=>'createInput' ), |
31 | 31 | 'create' =>array( 'act'=>'Post', 'func'=>'create' ), |
32 | 32 | 'modipt' =>array( 'act'=>'Post', 'func'=>'modifyInput' ), |
33 | - 'modify' =>array( 'act'=>'Post', 'func'=>'modify' ), | |
33 | + 'modify' =>array( 'act'=>'Post', 'func'=>'modify' ), | |
34 | + // | |
35 | + 'srhipt' =>array( 'act'=>'Search', 'func'=>'input' ), | |
36 | + 'srhrst' =>array( 'act'=>'Search', 'func'=>'result' ), | |
34 | 37 | |
35 | 38 | ); |
36 | 39 |
@@ -58,6 +58,13 @@ | ||
58 | 58 | 'deleteButton' => ' 削 除 ', |
59 | 59 | 'deleteConfirm' => ' 削除確認 ', |
60 | 60 | |
61 | +'searchArticle' => '記事検索', | |
62 | +'searchWord' => '検索単語', | |
63 | +'searchMode' => '検索モード', | |
64 | +'searchButton' => ' 検 索 ', | |
65 | +'searchInfo1' => '※複数の単語は半角スペースで区切ってください。', | |
66 | +'searchWordLess' => '検索単語は2文字以上で入力してください。', | |
67 | + | |
61 | 68 | 'responseTo' => '返信対象', |
62 | 69 | |
63 | 70 | 'articleUnitName' => 'Page', |
@@ -333,30 +333,9 @@ | ||
333 | 333 | } |
334 | 334 | |
335 | 335 | |
336 | -function makeError($msg, $msgAry) { | |
337 | - if (! $msg) return ''; | |
338 | 336 | |
339 | - $myContent = ''; | |
340 | 337 | |
341 | -$myContent .=<<< HTML | |
342 | - <div class="ctr"> | |
343 | - <div class="mainError">{$msg}</div> | |
344 | -HTML; | |
345 | 338 | |
346 | -foreach ($msgAry as $emsg) { | |
347 | -$myContent .=<<< HTML | |
348 | - <div class="itemError">$emsg</div> | |
349 | -HTML; | |
350 | -} | |
351 | - | |
352 | -$myContent .=<<< HTML | |
353 | - </div> | |
354 | -HTML; | |
355 | - | |
356 | - return $myContent; | |
357 | -} | |
358 | - | |
359 | - | |
360 | 339 | function makeFileUpload($number) { |
361 | 340 | $myContent = ''; |
362 | 341 |
@@ -28,7 +28,7 @@ | ||
28 | 28 | |
29 | 29 | <div> |
30 | 30 | <?php |
31 | -if ( $this->set['pager'] ) { | |
31 | +if ( ! empty($this->set['pager']) ) { | |
32 | 32 | echo makePageGuide($this->page, $this->artlSet, $this->baseSet); |
33 | 33 | } |
34 | 34 | ?> |
@@ -46,7 +46,7 @@ | ||
46 | 46 | |
47 | 47 | <div> |
48 | 48 | <?php |
49 | -if ( $this->set['pager'] ) { | |
49 | +if ( ! empty($this->set['pager']) ) { | |
50 | 50 | echo makePagenation($this->page, $this->artlSet, $this->baseSet); |
51 | 51 | } |
52 | 52 | ?> |