changeset 27:a34f2ff49097

add: editable title & description
author yoneda <epgrec@park.mda.or.jp>
date Sun, 26 Jul 2009 18:00:11 +0900
parents 82c1375ddb4a
children 9238c1d9e060
files changeReservation.php recomplete.php templates/recordedTable.html
diffstat 3 files changed, 70 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/changeReservation.php	Sat Jul 25 23:07:02 2009 +0900
+++ b/changeReservation.php	Sun Jul 26 18:00:11 2009 +0900
@@ -1,21 +1,47 @@
 <?php
 include_once('config.php');
 include_once(INSTALL_PATH."/DBRecord.class.php");
+include_once(INSTALL_PATH."/reclib.php");
 
 if( !isset( $_POST['reserve_id'] ) ) {
 	exit("Error: IDが指定されていません" );
 }
 $reserve_id = $_POST['reserve_id'];
 
+$dbh = false;
+if( defined("MEDIATOMB_UPDATE") ) {
+	if( MEDIATOMB_UPDATE ) {
+		$dbh = @mysql_connect( DB_HOST, DB_USER, DB_PASS );
+		if( $dbh !== false ) {
+			$sqlstr = "use ".DB_NAME;
+			@mysql_query( $sqlstr );
+			$sqlstr = "set NAME utf8";
+			@mysql_query( $sqlstr );
+		}
+	}
+}
+
 try {
 	$rec = new DBRecord(TBL_PREFIX.RESERVE_TBL, "id", $reserve_id );
 	
 	if( isset( $_POST['title'] ) ) {
 		$rec->title = trim( $_POST['title'] );
+		if( ($dbh !== false) && ($rec->complete == 1) ) {
+			$title = trim( mysql_real_escape_string($_POST['title']));
+			$title .= "(".date("Y/m/d", toTimestamp($rec->starttime)).")";
+			$sqlstr = "update mt_cds_object set dc_title='".$title."' where metadata regexp 'epgrec:id=".$reserve_id."$'";
+			mysql_query( $sqlstr );
+		}
 	}
 	
 	if( isset( $_POST['description'] ) ) {
 		$rec->description = trim( $_POST['description'] );
+		if( ($dbh !== false) && ($rec->complete == 1) ) {
+			$desc = "dc:description=".trim( mysql_real_escape_string($_POST['description']));
+			$desc .= "&epgrec:id=".$reserve_id;
+			$sqlstr = "update mt_cds_object set metadata='".$desc."' where metadata regexp 'epgrec:id=".$reserve_id."$'";
+			@mysql_query( $sqlstr );
+		}
 	}
 }
 catch( Exception $e ) {
@@ -24,4 +50,4 @@
 
 exit("complete");
 
-?>
+?>
\ No newline at end of file
--- a/recomplete.php	Sat Jul 25 23:07:02 2009 +0900
+++ b/recomplete.php	Sun Jul 26 18:00:11 2009 +0900
@@ -23,7 +23,7 @@
 					// 別にやらなくてもいいが
 					$sqlstr = "set NAME utf8";
 					mysql_query( $sqlstr );
-					$sqlstr = "update mt_cds_object set metadata='dc:description=".mysql_real_escape_string($rrec->description)."' where dc_title='".$rrec->path."'";
+					$sqlstr = "update mt_cds_object set metadata='dc:description=".mysql_real_escape_string($rrec->description)."&epgrec:id=".$reserve_id."' where dc_title='".$rrec->path."'";
 					mysql_query( $sqlstr );
 					$sqlstr = "update mt_cds_object set dc_title='".mysql_real_escape_string($rrec->title)."(".date("Y/m/d").")' where dc_title='".$rrec->path."'";
 					mysql_query( $sqlstr );
--- a/templates/recordedTable.html	Sat Jul 25 23:07:02 2009 +0900
+++ b/templates/recordedTable.html	Sun Jul 26 18:00:11 2009 +0900
@@ -40,8 +40,45 @@
 					$('#resid_' + id ).hide();
 				}
 			});
+		},
+		editdialog:function(id) {
+			$('#floatBox4Dialog').dialog({title:'変更',width:500});
+			var str;
+			str  = '<div class="prg_title">録画ID:' + id + '</div>';
+			str += '<input type="hidden" name="reserve_id" id="id_reserve_id" value="' + id +  '" />';
+			str += '<div><span class="labelLeft">タイトル</span><input name="title" id="id_title" size="30"  value="'+ $('#tid_' + id ).html() + '" /></div>';
+			str += '<div><span class="labelLeft">概要</span><textarea name="description" id="id_description" cols="30" rows="5" >' + $('#did_' + id ).html() + '</textarea></div>';
+			str += '<div style="margin:2em 0 1em 0;text-align:center;"><a href="javascript:PRG.edit()" class="ui-state-default ui-corner-all ui-dialog-buttonpane button">変更する</a></div>';
+			
+			$('#floatBox4Dialog').html(str);
+			$('#floatBox4Dialog').dialog('open','center');
+		},
+		edit:function() {
+			var id_reserve_id = $('#id_reserve_id').val();
+			var id_title = $('#id_title').val();
+			var id_description = $('#id_description').val();
+
+			$.post('changeReservation.php', { reserve_id: id_reserve_id,
+							  title: id_title,
+							  description: id_description }, function( data ) {
+				if(data.match(/^error/i)){
+					alert(data);
+					$('#floatBox4Dialog').dialog('close');
+
+				}
+				else {
+					$('#tid_' + id_reserve_id ).html( id_title );
+					$('#did_' + id_reserve_id ).html( id_description );
+					$('#floatBox4Dialog').dialog('close');
+				}
+			});
 		}
 	}
+	$(document).ready(function () {
+		var DG = $('#floatBox4Dialog');
+		DG.dialog({title:'あれ?',width:500});
+		DG.dialog('close');
+	});
 -->
 </script>
 <style type="text/css">
@@ -136,7 +173,8 @@
   {if $use_thumbs}<th>サムネール</th>{/if}
   <th>タイトル</th>
   <th>内容</th>
-  <th>情報削除</th>
+  <th>変更</th>
+  <th>削除</th>
  </tr>
 
 {foreach from=$records item=rec }
@@ -145,8 +183,9 @@
   <td>{$rec.station_name}</td>
   <td>{$rec.mode}</td>
   {if $use_thumbs}<td><a href="{$rec.asf}">{$rec.thumb}</a></td>{/if}
-  <td><a href="{$rec.asf}">{$rec.title}</a></td>
-  <td><a href="{$rec.asf}">{$rec.description}</a></td>
+  <td><a href="{$rec.asf}" id="tid_{$rec.id}">{$rec.title}</a></td>
+  <td><a href="{$rec.asf}" id="did_{$rec.id}">{$rec.description}</a></td>
+  <td><input type="button" value="変更" onClick="javascript:PRG.editdialog('{$rec.id}')" /></td>
   <td><input type="button" value="削除" onClick="javascript:PRG.dialog('{$rec.id}','{$rec.title}')" /></td>
  </tr>
 {/foreach}