| 44 | | { |
| 45 | | $q = $this->passed_args[0]; |
| | 44 | { |
| | 45 | $q_urlencode = $this->passed_args[0]; |
| | 46 | $q = urldecode($q_urlencode); |
| | 47 | |
| | 48 | { |
| | 49 | $conditions = 'where name='."'".$q."'"; |
| | 50 | $fields = ''; |
| | 51 | $order = ''; |
| | 52 | $tag_list = $this->Tag->findAll($conditions, $fields, $order, null, null); |
| | 53 | } |
| | 54 | $target_gohan_id_str = ""; |
| | 55 | foreach($tag_list as $k => $v){ |
| | 56 | // print "k=".$k; |
| | 57 | if($k==0){ |
| | 58 | $target_gohan_id_str = $target_gohan_id_str."id=".$v['Tag']['target_id']; |
| | 59 | }else{ |
| | 60 | $target_gohan_id_str = $target_gohan_id_str." OR id=".$v['Tag']['target_id']; |
| | 61 | } |
| | 62 | } |
| | 63 | // print "target_gohan_id_str=".$target_gohan_id_str; |
| | 64 | |
| | 65 | { |
| | 66 | $conditions = 'where '.$target_gohan_id_str; |
| | 67 | $fields = array('DISTINCT DATE_FORMAT(date_time_original, "%Y-%m-%d") date_time_originalYMD'); |
| | 68 | $order = 'date_time_original DESC'; |
| | 69 | $day_list = $this->Gohan->findAll($conditions, $fields, $order); |
| | 70 | } |
| | 71 | { |
| | 72 | $gohans = array(); |
| | 73 | foreach($day_list as $value){ |
| | 74 | $date_time_originalYMD = $value[0]['date_time_originalYMD']; |
| | 75 | $conditions = 'DATE_FORMAT(date_time_original, "%Y-%m-%d") = '."'$date_time_originalYMD'"; |
| | 76 | $fields = ''; |
| | 77 | $order = 'date_time_original ASC'; |
| | 78 | |
| | 79 | $gohans[$date_time_originalYMD] = $this->Gohan->findAll($conditions, $fields, $order); |
| | 80 | } |
| | 81 | } |
| | 82 | foreach ($gohans as $key => $value){ |
| | 83 | foreach($value as $key2 => $value2){ |
| | 84 | $id = $value2['Gohan']['id']; |
| | 85 | $conditions = 'target_id = '."'$id'"; |
| | 86 | $fields = ''; |
| | 87 | $order = ''; |
| | 88 | $tags = $this->Tag->findAll($conditions, $fields, $order); |
| | 89 | $gohans[$key][$key2]['Gohan']['tags'] = $tags; |
| | 90 | } |
| | 91 | } |
| | 92 | |
| | 93 | $this->set('gohans', $gohans); |
| | 94 | |