Mercurial > epgrec.yaz
annotate Keyword.class.php @ 106:57676bb30f64
add: ???????????
| author | Sushi-k <epgrec@park.mda.or.jp> |
|---|---|
| date | Mon, 08 Mar 2010 18:07:19 +0900 |
| parents | cb7da56c4198 |
| children | 7a64d5e3baee |
| 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' ); |
| 1 | 7 |
| 8 class Keyword extends DBRecord { | |
| 9 | |
| 10 public function __construct($property = null, $value = null ) { | |
| 11 try { | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
12 parent::__construct(KEYWORD_TBL, $property, $value ); |
| 1 | 13 } |
| 14 catch( Exception $e ) { | |
| 15 throw $e; | |
| 16 } | |
| 17 } | |
| 18 | |
| 19 private function getPrograms() { | |
| 20 if( $this->id == 0 ) return false; | |
| 21 | |
| 22 // ちょっと先を検索する | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
23 $options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + $this->settings->padding_time + 120 )."'"; |
| 1 | 24 |
| 25 if( $this->keyword != "" ) { | |
| 26 if( $this->use_regexp ) { | |
| 27 $options .= " AND CONCAT(title,description) REGEXP '".mysql_real_escape_string($this->keyword)."'"; | |
| 28 } | |
| 29 else { | |
| 30 $options .= " AND CONCAT(title,description) like '%".mysql_real_escape_string($this->keyword)."%'"; | |
| 31 } | |
| 32 } | |
| 33 | |
| 34 if( $this->type != "*" ) { | |
| 35 $options .= " AND type = '".$this->type."'"; | |
| 36 } | |
| 37 | |
| 38 if( $this->category_id != 0 ) { | |
| 39 $options .= " AND category_id = '".$this->category_id."'"; | |
| 40 } | |
| 41 | |
| 42 if( $this->channel_id != 0 ) { | |
| 43 $options .= " AND channel_id = '".$this->channel_id."'"; | |
| 44 } | |
| 45 | |
| 77 | 46 if( $this->weekofday != 7 ) { |
| 47 $options .= " AND WEEKDAY(starttime) = '".$this->weekofday."'"; | |
| 48 } | |
| 49 | |
| 106 | 50 if( $this->prgtime != 24 ) { |
| 51 $options .= " AND time(starttime) BETWEEN cast('".sprintf( "%02d:00:00", $this->prgtime)."' as time) AND cast('".sprintf("%02d:59:59", $this->prgtime)."' as time)"; | |
| 52 } | |
| 53 | |
| 1 | 54 $options .= " ORDER BY starttime ASC"; |
| 55 | |
| 56 $recs = array(); | |
| 57 try { | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
58 $recs = DBRecord::createRecords( PROGRAM_TBL, $options ); |
| 1 | 59 } |
| 60 catch( Exception $e ) { | |
| 61 throw $e; | |
| 62 } | |
| 63 return $recs; | |
| 64 } | |
| 65 | |
| 66 | |
| 67 public function reservation() { | |
| 68 if( $this->id == 0 ) return; | |
| 69 | |
| 70 $precs = array(); | |
| 71 try { | |
| 72 $precs = $this->getPrograms(); | |
| 73 } | |
| 74 catch( Exception $e ) { | |
| 75 throw $e; | |
| 76 } | |
| 77 if( count($precs) < 300 ) { | |
| 78 // 一気に録画予約 | |
| 79 foreach( $precs as $rec ) { | |
| 80 try { | |
| 81 if( $rec->autorec ) { | |
| 77 | 82 Reservation::simple( $rec->id, $this->id, $this->autorec_mode ); |
| 1 | 83 usleep( 100 ); // あんまり時間を空けないのもどう? |
| 84 } | |
| 85 } | |
| 86 catch( Exception $e ) { | |
| 87 // 無視 | |
| 88 } | |
| 89 } | |
| 90 } | |
| 91 else { | |
| 92 throw new Exception( "300件以上の自動録画は実行できません" ); | |
| 93 } | |
| 94 } | |
| 95 | |
| 96 public function delete() { | |
| 97 if( $this->id == 0 ) return; | |
| 98 | |
| 99 $precs = array(); | |
| 100 try { | |
| 101 $precs = $this->getPrograms(); | |
| 102 } | |
| 103 catch( Exception $e ) { | |
| 104 throw $e; | |
| 105 } | |
| 106 // 一気にキャンセル | |
| 107 foreach( $precs as $rec ) { | |
| 108 try { | |
|
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
109 $reserve = new DBRecord( RESERVE_TBL, "program_id", $rec->id ); |
| 1 | 110 // 自動予約されたもののみ削除 |
| 111 if( $reserve->autorec ) { | |
| 112 Reservation::cancel( $reserve->id ); | |
| 113 usleep( 100 ); // あんまり時間を空けないのもどう? | |
| 114 } | |
| 115 } | |
| 116 catch( Exception $e ) { | |
| 117 // 無視 | |
| 118 } | |
| 119 } | |
| 120 try { | |
| 121 parent::delete(); | |
| 122 } | |
| 123 catch( Exception $e ) { | |
| 124 throw $e; | |
| 125 } | |
| 126 } | |
| 127 | |
| 128 // staticなファンクションはオーバーライドできない | |
| 129 static function createKeywords( $options = "" ) { | |
| 130 $retval = array(); | |
| 131 $arr = array(); | |
| 132 try{ | |
| 133 $tbl = new self(); | |
| 134 $sqlstr = "SELECT * FROM ".$tbl->table." " .$options; | |
| 135 $result = $tbl->__query( $sqlstr ); | |
| 136 } | |
| 137 catch( Exception $e ) { | |
| 138 throw $e; | |
| 139 } | |
| 140 if( $result === false ) throw new exception("レコードが存在しません"); | |
| 141 while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { | |
| 142 array_push( $retval, new self('id', $row['id']) ); | |
| 143 } | |
| 144 return $retval; | |
| 145 } | |
| 146 | |
| 147 public function __destruct() { | |
| 148 parent::__destruct(); | |
| 149 } | |
| 150 } | |
| 151 ?> |
