Mercurial > epgrec.yaz
annotate Keyword.class.php @ 148:8f4f74463d08
merged with upstream
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 26 Mar 2010 15:41:36 +0900 |
parents | 4afd353b4507 |
children | 190a3c46611d |
rev | line source |
---|---|
1 | 1 <?php |
2 include_once('config.php'); | |
3 include_once( INSTALL_PATH . "/DBRecord.class.php" ); | |
4 include_once( INSTALL_PATH . "/reclib.php" ); | |
5 include_once( INSTALL_PATH . "/Reservation.class.php" ); | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
6 include_once( INSTALL_PATH . '/Settings.class.php' ); |
145
2cb414518ccd
mod: キーワード予約のログの位置を変えた
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
135
diff
changeset
|
7 include_once( INSTALL_PATH . '/recLog.inc.php' ); |
1 | 8 |
9 class Keyword extends DBRecord { | |
10 | |
11 public function __construct($property = null, $value = null ) { | |
12 try { | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
13 parent::__construct(KEYWORD_TBL, $property, $value ); |
1 | 14 } |
15 catch( Exception $e ) { | |
16 throw $e; | |
17 } | |
18 } | |
19 | |
115 | 20 static public function search( $keyword = "", |
21 $use_regexp = false, | |
22 $type = "*", | |
23 $category_id = 0, | |
24 $channel_id = 0, | |
25 $weekofday = 7, | |
26 $prgtime = 24, | |
27 $limit = 300 ) { | |
28 $sts = Settings::factory(); | |
29 | |
30 $dbh = @mysql_connect($sts->db_host, $sts->db_user, $sts->db_pass ); | |
1 | 31 |
32 // <c罎膣≪ | |
115 | 33 $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + $sts->padding_time + 60 )."'"; |
1 | 34 |
115 | 35 if( $keyword != "" ) { |
36 if( $use_regexp ) { | |
37 $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($keyword)."'"; | |
1 | 38 } |
39 else { | |
118 | 40 $options .= " AND CONCAT(title,description) like _utf8'%".mysql_real_escape_string($keyword)."%' collate utf8_unicode_ci"; |
1 | 41 } |
42 } | |
43 | |
115 | 44 if( $type != "*" ) { |
45 $options .= " AND type = '".$type."'"; | |
1 | 46 } |
47 | |
115 | 48 if( $category_id != 0 ) { |
49 $options .= " AND category_id = '".$category_id."'"; | |
1 | 50 } |
51 | |
115 | 52 if( $channel_id != 0 ) { |
53 $options .= " AND channel_id = '".$channel_id."'"; | |
1 | 54 } |
55 | |
115 | 56 if( $weekofday != 7 ) { |
57 $options .= " AND WEEKDAY(starttime) = '".$weekofday."'"; | |
77 | 58 } |
59 | |
115 | 60 if( $prgtime != 24 ) { |
61 $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $prgtime)."' as time)"; | |
106 | 62 } |
63 | |
115 | 64 $options .= " ORDER BY starttime ASC LIMIT ".$limit ; |
1 | 65 |
66 $recs = array(); | |
67 try { | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
68 $recs = DBRecord::createRecords( PROGRAM_TBL, $options ); |
1 | 69 } |
70 catch( Exception $e ) { | |
71 throw $e; | |
72 } | |
73 return $recs; | |
74 } | |
75 | |
115 | 76 private function getPrograms() { |
77 if( $this->id == 0 ) return false; | |
78 $recs = array(); | |
79 try { | |
80 $recs = self::search( trim($this->keyword), $this->use_regexp, $this->type, $this->category_id, $this->channel_id, $this->weekofday, $this->prgtime ); | |
81 } | |
82 catch( Exception $e ) { | |
83 throw $e; | |
84 } | |
85 return $recs; | |
86 } | |
1 | 87 |
88 public function reservation() { | |
89 if( $this->id == 0 ) return; | |
90 | |
91 $precs = array(); | |
92 try { | |
93 $precs = $this->getPrograms(); | |
94 } | |
95 catch( Exception $e ) { | |
96 throw $e; | |
97 } | |
115 | 98 // 筝羂牙私膣 |
99 foreach( $precs as $rec ) { | |
100 try { | |
101 if( $rec->autorec ) { | |
102 Reservation::simple( $rec->id, $this->id, $this->autorec_mode ); | |
145
2cb414518ccd
mod: キーワード予約のログの位置を変えた
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
135
diff
changeset
|
103 reclog( "Keyword.class::若若ID".$this->id."牙祉篋膣"); |
115 | 104 usleep( 100 ); // 障腥冴? |
1 | 105 } |
106 } | |
115 | 107 catch( Exception $e ) { |
108 // ∴ | |
109 } | |
1 | 110 } |
111 } | |
112 | |
113 public function delete() { | |
114 if( $this->id == 0 ) return; | |
115 | |
116 $precs = array(); | |
117 try { | |
118 $precs = $this->getPrograms(); | |
119 } | |
120 catch( Exception $e ) { | |
121 throw $e; | |
122 } | |
123 // 筝羂c潟祉 | |
124 foreach( $precs as $rec ) { | |
125 try { | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
126 $reserve = new DBRecord( RESERVE_TBL, "program_id", $rec->id ); |
1 | 127 // 篋膣水 |
128 if( $reserve->autorec ) { | |
129 Reservation::cancel( $reserve->id ); | |
130 usleep( 100 ); // 障腥冴? | |
131 } | |
132 } | |
133 catch( Exception $e ) { | |
134 // ∴ | |
135 } | |
136 } | |
137 try { | |
138 parent::delete(); | |
139 } | |
140 catch( Exception $e ) { | |
141 throw $e; | |
142 } | |
143 } | |
144 | |
145 // static<潟激с潟若若ゃс | |
146 static function createKeywords( $options = "" ) { | |
147 $retval = array(); | |
148 $arr = array(); | |
149 try{ | |
150 $tbl = new self(); | |
151 $sqlstr = "SELECT * FROM ".$tbl->table." " .$options; | |
152 $result = $tbl->__query( $sqlstr ); | |
153 } | |
154 catch( Exception $e ) { | |
155 throw $e; | |
156 } | |
157 if( $result === false ) throw new exception("潟若絖障"); | |
158 while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { | |
159 array_push( $retval, new self('id', $row['id']) ); | |
160 } | |
161 return $retval; | |
162 } | |
163 | |
164 public function __destruct() { | |
165 parent::__destruct(); | |
166 } | |
167 } | |
130
290a05fd7331
mod: 半角英数で検索しても全角英数がヒットするように変更
Sushi-k <epgrec@park.mda.or.jp>
parents:
115
diff
changeset
|
168 ?> |