Mercurial > epgrec.yaz
annotate Keyword.class.php @ 77:cb7da56c4198
modified: Keyword.class.php
modified: config.php.sample
modified: index.php
modified: install/step1.php
modified: keywordTable.php
modified: programTable.php
modified: simpleReservation.php
modified: templates/index.html
modified: templates/keywordTable.html
modified: templates/programTable.html
author | Sushi-k <epgrec@park.mda.or.jp> |
---|---|
date | Wed, 24 Feb 2010 20:22:19 +0900 |
parents | 3d6e7c606896 |
children | 57676bb30f64 |
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 | |
1 | 50 $options .= " ORDER BY starttime ASC"; |
51 | |
52 $recs = array(); | |
53 try { | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
54 $recs = DBRecord::createRecords( PROGRAM_TBL, $options ); |
1 | 55 } |
56 catch( Exception $e ) { | |
57 throw $e; | |
58 } | |
59 | |
60 return $recs; | |
61 } | |
62 | |
63 | |
64 public function reservation() { | |
65 if( $this->id == 0 ) return; | |
66 | |
67 $precs = array(); | |
68 try { | |
69 $precs = $this->getPrograms(); | |
70 } | |
71 catch( Exception $e ) { | |
72 throw $e; | |
73 } | |
74 if( count($precs) < 300 ) { | |
75 // 一気に録画予約 | |
76 foreach( $precs as $rec ) { | |
77 try { | |
78 if( $rec->autorec ) { | |
77 | 79 Reservation::simple( $rec->id, $this->id, $this->autorec_mode ); |
1 | 80 usleep( 100 ); // あんまり時間を空けないのもどう? |
81 } | |
82 } | |
83 catch( Exception $e ) { | |
84 // 無視 | |
85 } | |
86 } | |
87 } | |
88 else { | |
89 throw new Exception( "300件以上の自動録画は実行できません" ); | |
90 } | |
91 } | |
92 | |
93 public function delete() { | |
94 if( $this->id == 0 ) return; | |
95 | |
96 $precs = array(); | |
97 try { | |
98 $precs = $this->getPrograms(); | |
99 } | |
100 catch( Exception $e ) { | |
101 throw $e; | |
102 } | |
103 // 一気にキャンセル | |
104 foreach( $precs as $rec ) { | |
105 try { | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
1
diff
changeset
|
106 $reserve = new DBRecord( RESERVE_TBL, "program_id", $rec->id ); |
1 | 107 // 自動予約されたもののみ削除 |
108 if( $reserve->autorec ) { | |
109 Reservation::cancel( $reserve->id ); | |
110 usleep( 100 ); // あんまり時間を空けないのもどう? | |
111 } | |
112 } | |
113 catch( Exception $e ) { | |
114 // 無視 | |
115 } | |
116 } | |
117 try { | |
118 parent::delete(); | |
119 } | |
120 catch( Exception $e ) { | |
121 throw $e; | |
122 } | |
123 } | |
124 | |
125 // staticなファンクションはオーバーライドできない | |
126 static function createKeywords( $options = "" ) { | |
127 $retval = array(); | |
128 $arr = array(); | |
129 try{ | |
130 $tbl = new self(); | |
131 $sqlstr = "SELECT * FROM ".$tbl->table." " .$options; | |
132 $result = $tbl->__query( $sqlstr ); | |
133 } | |
134 catch( Exception $e ) { | |
135 throw $e; | |
136 } | |
137 if( $result === false ) throw new exception("レコードが存在しません"); | |
138 while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { | |
139 array_push( $retval, new self('id', $row['id']) ); | |
140 } | |
141 return $retval; | |
142 } | |
143 | |
144 public function __destruct() { | |
145 parent::__destruct(); | |
146 } | |
147 } | |
148 ?> |