Mercurial > epgrec.yaz
diff Keyword.class.php @ 117:f5d58cf2842f
merged with upstream
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sun, 14 Mar 2010 16:31:50 +0900 |
parents | 7a64d5e3baee |
children | db185340a981 290a05fd7331 |
line wrap: on
line diff
--- a/Keyword.class.php Sat Mar 13 18:53:41 2010 +0900 +++ b/Keyword.class.php Sun Mar 14 16:31:50 2010 +0900 @@ -16,42 +16,51 @@ } } - private function getPrograms() { - if( $this->id == 0 ) return false; + static public function search( $keyword = "", + $use_regexp = false, + $type = "*", + $category_id = 0, + $channel_id = 0, + $weekofday = 7, + $prgtime = 24, + $limit = 300 ) { + $sts = Settings::factory(); + + $dbh = @mysql_connect($sts->db_host, $sts->db_user, $sts->db_pass ); // ちょっと先を検索する - $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + $this->settings->padding_time + 120 )."'"; + $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + $sts->padding_time + 60 )."'"; - if( $this->keyword != "" ) { - if( $this->use_regexp ) { - $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($this->keyword)."'"; + if( $keyword != "" ) { + if( $use_regexp ) { + $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($keyword)."'"; } else { - $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($this->keyword)."%'"; + $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($keyword)."%'"; } } - if( $this->type != "*" ) { - $options .= " AND type = '".$this->type."'"; + if( $type != "*" ) { + $options .= " AND type = '".$type."'"; } - if( $this->category_id != 0 ) { - $options .= " AND category_id = '".$this->category_id."'"; + if( $category_id != 0 ) { + $options .= " AND category_id = '".$category_id."'"; } - if( $this->channel_id != 0 ) { - $options .= " AND channel_id = '".$this->channel_id."'"; + if( $channel_id != 0 ) { + $options .= " AND channel_id = '".$channel_id."'"; } - if( $this->weekofday != 7 ) { - $options .= " AND WEEKDAY(starttime) = '".$this->weekofday."'"; + if( $weekofday != 7 ) { + $options .= " AND WEEKDAY(starttime) = '".$weekofday."'"; } - if( $this->prgtime != 24 ) { - $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $this->prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $this->prgtime)."' as time)"; + if( $prgtime != 24 ) { + $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $prgtime)."' as time)"; } - $options .= " ORDER BY starttime ASC"; + $options .= " ORDER BY starttime ASC LIMIT ".$limit ; $recs = array(); try { @@ -63,6 +72,17 @@ return $recs; } + private function getPrograms() { + if( $this->id == 0 ) return false; + $recs = array(); + try { + $recs = self::search( trim($this->keyword), $this->use_regexp, $this->type, $this->category_id, $this->channel_id, $this->weekofday, $this->prgtime ); + } + catch( Exception $e ) { + throw $e; + } + return $recs; + } public function reservation() { if( $this->id == 0 ) return; @@ -74,22 +94,17 @@ catch( Exception $e ) { throw $e; } - if( count($precs) < 300 ) { - // 一気に録画予約 - foreach( $precs as $rec ) { - try { - if( $rec->autorec ) { - Reservation::simple( $rec->id, $this->id, $this->autorec_mode ); - usleep( 100 ); // あんまり時間を空けないのもどう? - } - } - catch( Exception $e ) { - // 無視 + // 一気に録画予約 + foreach( $precs as $rec ) { + try { + if( $rec->autorec ) { + Reservation::simple( $rec->id, $this->id, $this->autorec_mode ); + usleep( 100 ); // あんまり時間を空けないのもどう? } } - } - else { - throw new Exception( "300件以上の自動録画は実行できません" ); + catch( Exception $e ) { + // 無視 + } } }