--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Rec10 Simple Web Interface ver.0.7.0 iEPGデータ追加</title>
+ <script src="./dojo/dojo/dojo.js" djConfig="parseOnLoad:true">
+ </script>
+ <!-- テーマの読み込み -->
+ <style type="text/css">
+ @import "./dojo/dojo/resources/dojo.css";
+ @import "./dojo/dijit/themes/tundra/tundra.css";
+
+
+ </style>
+ <script type="text/javascript">
+
+ dojo.require("dojo.parser");
+ // ※ ここで、使用するウィジェットの読み込みを行う
+ dojo.require("dijit.form.Button");
+ dojo.require("dijit.form.TextBox");
+ dojo.require("dijit.form.Form");
+ </script>
+ </head>
+ <body class="tundra">
+ <div dojoType="dijit.form.Form" action="rec10web.py" onExecute="this.submit()">
+ <h1>Rec10 Simple Web Interface ver.0.7.0 iEPGデータ追加</h1><br>
+ <input type="text"
+ length="40"
+ dojoType="dijit.form.TextBox"
+ value="<!--iepg_title-value//-->"
+ id="iepg_station"
+ name="iepg_station">
+ <select name="iepg_chtxt"
+ dojoType="dijit.form.FilteringSelect"
+ autocomplete="false"
+ value="<!--ch-value//-->"
+ onChange="setType">
+ <!--text_for_replace_chtxt_input//-->
+ </select>
+ <div dojoType="dijit.form.Button" type="submit">追加</div>
+ <div name="exec"
+ dojoType="dijit.form.ValidationTextBox"
+ value="iepg-add_yes"
+ style="display:none">
+ </div>
+ </div>
+ </body>
+</html>
import rec10web_dbSQLite
import ConfigParser
import time
+
path=str(os.path.dirname(os.path.abspath(__file__)))+"/"
confp=ConfigParser.SafeConfigParser()
Conf='config.ini'
confp.read(path+Conf)
+global f
+f=cgi.FieldStorage()
def getpath(string):
global confp
return confp.get('path',string)
def getdbpath(string):
global confp
return confp.get('db',string)
-
def getdb():
retdb=""
if getdbpath('db')=='MySQL':
def edit_date(id):
ret=database.select_by_id_rectime(id)
return ret[0]
-
def reserv_recday(keyword,chtxt,btime,etime,deltatime,opt,deltaday,day):
"""
dayは月曜日を1日曜日を7とした数字
return rett
def station2chtxt(station):
ret=""
- for bctype, ontv, chtxt, ch, csch ,updatetime in database.select_by_station_chdata(station):
- ret=chtxt
- return ret
-def station_name2chtxt(station):
- ret=""
- for bctype, ontv, chtxt, ch, csch ,updatetime in database.select_by_station_name_chdata(station):
- ret=chtxt
+ sta=database.select_by_station_iepg(station):
+ if len(sta)>0:
+ ret=sta[0][1]
+ else:
+ ret="n\/a"
return ret
def readHtmlSrcSimple():
f = open(path+'rswi.htm')
ret=f.read()
f.close()
return ret
+def readiEPGadd():
+ f = open(path+'iepg_add.htm')
+ ret=f.read()
+ f.close()
+ return ret
+def readiEPGfin():
+ f = open(path+'iepg_fin.htm')
+ ret=f.read()
+ f.close()
+ return ret
+def readiEPGshow():
+ f = open(path+'iepg_show.htm')
+ ret=f.read()
+ f.close()
+ return ret
+def mode_iepg_add(station):
+ htmdate=readiEPGadd()
+ htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
+ htmdate=htmdate.replace("<!--ch-value//-->","")
+ htmdate=htmdate.replace("<!--iepg_title-value//-->",station)
+ return htmdate
+def mode_iepg_fin():
+ htmdate=readiEPGfin()
+ return htmdate
+def mode_iepg_show():
+ htmdate=readiEPGshow()
+ lsts=database.select_all_iepg()
+ s=""
+ for lst in lsts:
+ s=s+"{name:\""+lst[0]+"\",chtxt:\""+lst[1]+"\"},\n"
+ return htmdate
+def mode_schedule():
+ htmdate=readRecSchedule()
+ return htmdate
+def mode_edit():
+ editnum=exect.replace("edit:","")
+ htmdate= readHtmlEdit()
+ iddata=edit_date(editnum)
+ htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
+ htmdate=htmdate.replace("<!--ch-value//-->",iddata['chtxt'])
+ htmdate=htmdate.replace("<!--btime-value//-->",iddata['btime'])
+ htmdate=htmdate.replace("<!--etime-value//-->",iddata['etime'])
+ htmdate=htmdate.replace("<!--type-value//-->",iddata['type'])
+ htmdate=htmdate.replace("<!--ch-value//-->",iddata['chtxt'])
+ htmdate=htmdate.replace("<!--title-value//-->",iddata['title'])
+ htmdate=htmdate.replace("<!--size-value//-->",size)
+ htmdate=htmdate.replace("<!--opts-value//-->",iddata["opt"])
+ htmdate=htmdate.replace("<!--exec-value//-->","edit-exec:"+editnum)
+ return htmdate
dbpath=path+"ch.db"
database=getdb()
-f=cgi.FieldStorage()
-
btime=""
etime=""
title=""
chtxt=""
type="res"
bt=""
+station_name=""
+mode=""
getRecDate()
if f.getfirst('mode')=="schedule":
getRecDate()
-
###ここからiEPG用の読み出し
if f.getfirst('station_name'):
station=f.getfirst('station_name')
- chtxt=station_name2chtxt(station)
+ chtxt=station2chtxt(station)
+ if chtxt=="n\/a":
+ mode="iepg-add"
+ station_name=station
+ exect="iepg-add"
if f.getfirst('station'):
station=f.getfirst('station')
chtxt=station2chtxt(station)
+ if chtxt=="n\/a":
+ mode="iepg-add"
+ station_name=station
+ exect="iepg-add"
###ここから外部からの読み出しの場合
if f.getfirst('type'):
type=f.getfirst('type')
chtxt=f.getfirst('chtxt')
if f.getfirst('btime'):
btime=f.getfirst('btime')
- #bt=datetime.datetime.strptime(btime,"%Y-%m-%d %H:%M:%S")
bt=datetime.datetime(*time.strptime(btime,"%Y-%m-%d %H:%M:%S")[:-3])
if f.getfirst('etime'):
etime=f.getfirst('etime')
- #et=datetime.datetime.strptime(etime,"%Y-%m-%d %H:%M:%S")
et=datetime.datetime(*time.strptime(etime,"%Y-%m-%d %H:%M:%S")[:-3])
if bt !="":
delt=et-bt
exect=""
if f.getfirst('exec',""):
exect=f.getfirst('exec',"")
+if exect=="schedule":
+ mode="schedule"
+elif re.search('edit:',exect):
+ mode="edit"
+elif exect=="iepg-add":
+ mode="iepg-add"
+elif exect=="iepg-show":
+ mode="iepg-show"
+elif exect=="iepg-add_yes"
+ mode="iepg-add-yes"
htmdate= readHtmlSrcSimple()
htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
htmdate=htmdate.replace("<!--btime-value//-->",btime)
elif restxt=="over":
htmdate=readRecFinisOver()
exect=""
-#
if (chtxt != "")and(title != "")and(btime!="")and(etime!="")and(opts!="")and(re.search('edit-exec:',exect)):
editnum=exect.replace("edit-exec:","")
#restxt=change_reserv(id, type, keyword, chtxt, btime, etime, deltatime, opt, deltaday)
elif restxt=="over":
htmdate=readRecFinisOver()
exect=""
-if exect=="schedule":
- htmdate=readRecSchedule()
-if re.search('edit:',exect):
- editnum=exect.replace("edit:","")
- htmdate= readHtmlEdit()
- iddata=edit_date(editnum)
- htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
- htmdate=htmdate.replace("<!--ch-value//-->",iddata['chtxt'])
- htmdate=htmdate.replace("<!--btime-value//-->",iddata['btime'])
- htmdate=htmdate.replace("<!--etime-value//-->",iddata['etime'])
- htmdate=htmdate.replace("<!--type-value//-->",iddata['type'])
- htmdate=htmdate.replace("<!--ch-value//-->",iddata['chtxt'])
- htmdate=htmdate.replace("<!--title-value//-->",iddata['title'])
- htmdate=htmdate.replace("<!--size-value//-->",size)
- htmdate=htmdate.replace("<!--opts-value//-->",iddata["opt"])
- htmdate=htmdate.replace("<!--exec-value//-->","edit-exec:"+editnum)
+if mode=="schedule":
+ htmdate=mode_normal()
+elif mode=="edit":
+ htmdate=mode_edit()
+elif mode=="iepg-add":
+ htmdate=mode_iepg_add(f.getfirst('iepg_station'))
+elif mode=="iepg-add-yes":
+ if f.getfirst('iepg_station') and f.getfirst('iepg_chtxt'):
+ database.add_iepg(f.getfirst('iepg_station'),f.getfirst('iepg_chtxt'))
+ htmdate=mode_iepg_fin()
+elif mode=="iepg-show":
+ htmdate=mode_iepg_show()
print "Content-Type: text/html\n"
print htmdate
+