changeset 106:57676bb30f64

add: 時間帯で絞り込みを追加
author Sushi-k <epgrec@park.mda.or.jp>
date Mon, 08 Mar 2010 18:07:19 +0900
parents d9b9d1d903a1
children ee67bb78da2d
files Keyword.class.php keywordTable.php programTable.php templates/keywordTable.html templates/programTable.html upgrade_to_201002.php
diffstat 6 files changed, 48 insertions(+), 143 deletions(-) [+]
line wrap: on
line diff
--- a/Keyword.class.php	Wed Mar 03 00:02:15 2010 +0900
+++ b/Keyword.class.php	Mon Mar 08 18:07:19 2010 +0900
@@ -47,6 +47,10 @@
 			$options .= " AND WEEKDAY(starttime) = '".$this->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)";
+		}
+		
 		$options .= " ORDER BY starttime ASC";
 		
 		$recs = array();
@@ -56,7 +60,6 @@
 		catch( Exception $e ) {
 			throw $e;
 		}
-		
 		return $recs;
 	}
 	
--- a/keywordTable.php	Wed Mar 03 00:02:15 2010 +0900
+++ b/keywordTable.php	Mon Mar 08 18:07:19 2010 +0900
@@ -9,10 +9,13 @@
 
 
 $weekofdays = array( "", "", "羂", "", "", "", "", "" );
+$prgtimes = array();
+for( $i=0 ; $i < 25; $i++ ) {
+	$prgtimes[$i] = $i == 24 ? "" : $i."鐔";
+}
 
 // 域若若鴻
 
-
 if( isset($_POST["add_keyword"]) ) {
 	if( $_POST["add_keyword"] == 1 ) {
 		try {
@@ -23,6 +26,7 @@
 			$rec->channel_id = $_POST['k_station'];
 			$rec->use_regexp = $_POST['k_use_regexp'];
 			$rec->weekofday = $_POST['k_weekofday'];
+			$rec->prgtime   = $_POST['k_prgtime'];
 			$rec->autorec_mode = $_POST['autorec_mode'];
 			
 			// 牙私膣絎茵
@@ -60,6 +64,8 @@
 		
 		$arr['weekofday'] = $weekofdays["$rec->weekofday"];
 		
+		$arr['prgtime'] = $prgtimes["$rec->prgtime"];
+		
 		$arr['autorec_mode'] = $RECORD_MODE[(int)$rec->autorec_mode]['name'];
 		
 		array_push( $keywords, $arr );
--- a/programTable.php	Wed Mar 03 00:02:15 2010 +0900
+++ b/programTable.php	Mon Mar 08 18:07:19 2010 +0900
@@ -20,6 +20,7 @@
 					array( "name" => "", "id" => 7, "selected" => "" ),
 );
 
+
 $autorec_modes = $RECORD_MODE;
 $autorec_modes[(int)($settings->autorec_mode)]['selected'] = "selected";
 
@@ -29,6 +30,8 @@
 $type = "*";
 $category_id = 0;
 $station = 0;
+$prgtime = 24;
+
 
 // mysql_real_escape_string・膓鏆荀
 $dbh = @mysql_connect($settings->db_host, $settings->db_user, $settings->db_pass );
@@ -71,14 +74,21 @@
 			$options .= " AND WEEKDAY(starttime) = '".$weekofday."'";
 		}
 	}
+	if( isset($_POST['prgtime']) ) {
+		$prgtime = (int)($_POST['prgtime']);
+		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 LIMIT 300";
+
+
 $do_keyword = 0;
 if( ($search != "") || ($type != "*") || ($category_id != 0) || ($station != 0) )
 	$do_keyword = 1;
 	
 try{
-	
 	$precs = DBRecord::createRecords(PROGRAM_TBL, $options );
 	
 	$programs = array();
@@ -157,6 +167,18 @@
 		array_push( $stations, $arr );
 	}
 	$weekofdays["$weekofday"]["selected"] = "selected" ;
+	
+	// 絽
+	$prgtimes = array();
+	for( $i=0; $i < 25; $i++ ) {
+		array_push( $prgtimes, 
+			array(  "name" => ( $i == 24  ? "" : sprintf("%0d鐔",$i) ),
+					"value" => $i,
+					"selected" =>  ( $i == $prgtime ? "selected" : "" ) )
+		);
+	}
+
+
 
 	$smarty = new Smarty();
 	$smarty->assign("sitetitle","腟罎膣");
@@ -177,6 +199,8 @@
 	$smarty->assign( "weekofday", $weekofday );
 	$smarty->assign( "weekofdays", $weekofdays );
 	$smarty->assign( "autorec_modes", $autorec_modes );
+	$smarty->assign( "prgtimes", $prgtimes );
+	$smarty->assign( "prgtime", $prgtime );
 	$smarty->display("programTable.html");
 }
 catch( exception $e ) {
--- a/templates/keywordTable.html	Wed Mar 03 00:02:15 2010 +0900
+++ b/templates/keywordTable.html	Mon Mar 08 18:07:19 2010 +0900
@@ -87,6 +87,7 @@
   <th>絮</th>
   <th>眼</th>
   <th></th>
+  <th>紮</ht>
   <th>牙祉≪若</th>
   <th></th>
  </tr>
@@ -100,6 +101,7 @@
   <td>{$keyword.channel}</td>
   <td>{$keyword.category}</td>
   <td>{$keyword.weekofday}</td>
+  <td>{$keyword.prgtime}</td>
   <td>{$keyword.autorec_mode}</td>
   <td><input type="button" value="" onClick="javascript:PRG.delkey('{$keyword.id}')" /></td>
  </tr>
--- a/templates/programTable.html	Wed Mar 03 00:02:15 2010 +0900
+++ b/templates/programTable.html	Mon Mar 08 18:07:19 2010 +0900
@@ -160,7 +160,7 @@
 腟莨若随
 <form method="post" action="programTable.php">
 <input type="hidden" name="do_search" value="1" />
-罎膣∵<input type="text" size="20" name="search" value="{$search}" />
+罎膣∵<input type="text" size="20" name="search" value="{$search}" /><br />
 罩h頫憘戎<input type="checkbox" name="use_regexp" value="1" {if $use_regexp}checked{/if} />
 腮<select name="type">
   {foreach from=$types item=type}
@@ -177,6 +177,12 @@
   <option value="{$cat.id}" {$cat.selected}>{$cat.name}</option>
   {/foreach}
   </select>
+紮<select name="prgtime">
+  {foreach from=$prgtimes item=prgt}
+  <option value="{$prgt.value}" {$prgt.selected}>{$prgt.name}</option>
+  {/foreach}
+  </select>
+
 <select name='weekofday'>
   {foreach from=$weekofdays item=day}
   <option value="{$day.id}" {$day.selected}>{$day.name}</option>
@@ -228,7 +234,8 @@
   <b>腮:</b>{if $k_type == "*"}鴻{else}{$k_type}{/if}
   <b>絮:</b>{if $k_station == 0}鴻{else}{$k_station_name}{/if}
   <b>眼:</b>{if $k_category == 0}鴻{else}{$k_category_name}{/if}
-  <b>:</b>{if $weekofday == 7}{else}{$k_weekofday}{/if}
+  <b>:</b>{if $weekofday == 7}{else}{$k_weekofday}{/if}
+  <b>:</b>{if $prgtime == 24}{else}{$prgtime}鐔{/if}
   <b>篁倶:</b>{$programs|@count}
   <input type="hidden" name="add_keyword" value="{$do_keyword}" />
   <input type="hidden" name="k_use_regexp" value="{$use_regexp}" />
@@ -237,6 +244,7 @@
   <input type="hidden" name="k_category" value="{$k_category}" />
   <input type="hidden" name="k_station" value="{$k_station}" />
   <input type="hidden" name="k_weekofday" value={$weekofday} />
+  <input type="hidden" name="k_prgtime" value={$prgtime} />
   <b>牙祉≪若:</b><select name="autorec_mode" >
   {foreach from=$autorec_modes item=mode name=recmode }
      <option value="{$smarty.foreach.recmode.index}" {$mode.selected} >{$mode.name}</option>
--- a/upgrade_to_201002.php	Wed Mar 03 00:02:15 2010 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-#!/usr/bin/php
-<?php
-include_once('config.php');
-include_once(INSTALL_PATH . '/Settings.class.php' );
-
-
-// mysqli::multi_query篏障<т戎
-
-function multi_query( $sqlstrs, $dbh ) {
-	$error = false;
-	
-	foreach( $sqlstrs as $sqlstr ) {
-		$res = mysql_query( $sqlstr );
-		if( $res === FALSE ) {
-			echo "failed: ". $sqlstr . "\n";
-			$error = true;
-		}
-	}
-	return $error;
-}
-
-
-$settings = Settings::factory();
-$dbh = mysql_connect( $settings->db_host, $settings->db_user, $settings->db_pass );
-if( $dbh !== FALSE ) {
-
-	$sqlstr = "use ".$settings->db_name;
-	mysql_query( $sqlstr );
-
-	$sqlstr = "set NAMES 'utf8'";
-	mysql_query( $sqlstr );
-	
-	// RESERVE_TBL
-
-	$sqlstrs = array (
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  channel_disc varchar(128) not null default 'none';",	// channel disc
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  channel_id integer not null  default '0';",			// channel ID
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  program_id integer not null default '0';",				// Program ID
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  type varchar(8) not null default 'GR';",				// 腮ワGR/BS/CS鐚
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  channel varchar(10) not null default '0';",			// c潟
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  title varchar(512) not null default 'none';",			// 帥ゃ
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  description varchar(512) not null default 'none';",		// 茯 text->varchar
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  category_id integer not null default '0';",			// 眼ID
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  starttime datetime not null default '1970-01-01 00:00:00';",	// 紮
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  endtime datetime not null default '1970-01-01 00:00:00';",		// 腟篋
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  job integer not null default '0';",					// job
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  path blob default null;",								// 牙祉<ゃ
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  complete boolean not null default '0';",				// 絎篋
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  reserve_disc varchar(128) not null default 'none';",	// 茘ョhash
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  autorec integer not null default '0';",				// 若若ID
-	 "alter table ".$settings->tbl_prefix.RESERVE_TBL." modify  mode integer not null default '0';",					//牙祉≪若
-	);
-	
-	if( multi_query( $sqlstrs, $dbh ) ) {
-		echo "篋膣若≪若紊掩\n";
-	}
-	
-	$sqlstrs = array(
-	 "create index reserve_ch_idx on ".$settings->tbl_prefix.RESERVE_TBL."  (channel_disc);",
-	 "create index reserve_st_idx on ".$settings->tbl_prefix.RESERVE_TBL."  (starttime);",
-	);
-	
-	if( multi_query( $sqlstrs, $dbh ) ) {
-		echo "篋膣若ゃ潟鴻篏с障\n";
-	}
-	
-	// PROGRAM_TBL
-	
-	$sqlstrs = array (
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify channel_disc varchar(128) not null default 'none';",	// channel disc
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify channel_id integer not null default '0';",				// channel ID
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify type varchar(8) not null default 'GR';",				// 腮ワGR/BS/CS鐚
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify channel varchar(10) not null default '0';",			// c潟
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify title varchar(512) not null default 'none';",			// 帥ゃ
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify description varchar(512) not null default 'none';",	// 茯 text->varchar
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify category_id integer not null default '0';",			// 眼ID
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify starttime datetime not null default '1970-01-01 00:00:00';",	// 紮
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify endtime datetime not null default '1970-01-01 00:00:00';",		// 腟篋
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify program_disc varchar(128) not null default 'none';",	 		// 茘ョhash
-		"alter table ".$settings->tbl_prefix.PROGRAM_TBL." modify autorec boolean not null default '1';",					// 牙紙合≦
-	);
-	
-	if( multi_query( $sqlstrs, $dbh ) ) {
-		echo "腟若≪若紊掩\n";
-	}
-	
-	$sqlstrs = array(
-	 "create index program_ch_idx on ".$settings->tbl_prefix.PROGRAM_TBL." (channel_disc);",		// ゃ潟
-	 "create index program_st_idx on ".$settings->tbl_prefix.PROGRAM_TBL." (starttime);",			// ゃ潟
-	);
-	
-	if( multi_query( $sqlstrs, $dbh ) ) {
-		echo "腟若ゃ潟鴻篏с障\n";
-	}
-	
-	// CHANNEL_TBL
-	
-	$sqlstrs = array(
-	"alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify type varchar(8) not null default 'GR';",				// 腮
-	"alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify channel varchar(10) not null default '0';",			// channel
-	"alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify name varchar(512) not null default 'none';",			// 茵腓阪
-	"alter table ".$settings->tbl_prefix.CHANNEL_TBL." modify channel_disc varchar(128) not null default 'none';",	// 茘ョhash
-	"alter table ".$settings->tbl_prefix.CHANNEL_TBL." add sid varchar(64) not null default 'hd'",				// 泣若ID02/23/2010菴遵
-	);
-	
-	if( multi_query( $sqlstrs, $dbh ) ) {
-		echo "c潟若≪若紊掩\n";
-	}
-	
-	// CATEGORY_TBL
-	
-	$sqlstrs  = array(
-	"alter table ".$settings->tbl_prefix.CATEGORY_TBL." modify name_jp varchar(512) not null default 'none';",		// 茵腓阪
-	"alter table ".$settings->tbl_prefix.CATEGORY_TBL." modify name_en varchar(512) not null default 'none';",		// 筝
-	"alter table ".$settings->tbl_prefix.CATEGORY_TBL." modify category_disc varchar(128) not null default 'none'",	// 茘ョhash
-	);
-	if( multi_query( $sqlstrs, $dbh ) ) {
-		echo "眼若≪若紊掩\n";
-	}
-	
-	// KEYWORD_TBL
-	
-	$sqlstrs = array(
-	 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify keyword varchar(512) not null default '*';",			// 茵腓阪
-	 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify type varchar(8) not null default '*';",				// 腮
-	 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify channel_id integer not null default '0';",				// channel ID
-	 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify category_id integer not null default '0';",			// 眼ID
-	 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." modify use_regexp boolean not null default '0';",				// 罩h頫憗篏睡1
-	 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add autorec_mode integer not null default '0';",						// 牙祉≪若02/23/2010菴遵
-	 "alter table ".$settings->tbl_prefix.KEYWORD_TBL." add weekofday enum ('0','1','2','3','4','5','6','7' ) default '7'",		// ャ菴遵
-	);
-	if( multi_query( $sqlstrs, $dbh ) ) {
-		echo "若若若≪若紊掩\n";
-	}
-}
-else
-	exit( "DB・膓紊掩\n" );
-?>
\ No newline at end of file