def action(self, request):
		global utf8ToLatin
		if utf8ToLatin is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Utf8 import utf8ToLatin
			
		from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.plugin import getSyncInfoInstance
		syncInfo = getSyncInfoInstance()
		isRunning = syncInfo.inProgress
		isFinished = syncInfo.isFinished
		currentProgress = syncInfo.progress
		currentRange = syncInfo.range
		lastPoster = syncInfo.poster
		lastName = syncInfo.name
		lastYear = syncInfo.year
		
		
		finalOutput = WebHelper().getHtmlCore("Sync", True)
		syncStates = """
						<input id="isRunning" type="hidden" name="isRunning" value="%s"></input>
						<input id="isFinished" type="hidden" name="isFinished" value="%s"></input>
						<input id="currentProgress" type="hidden" name="currentProgress" value="%s"></input>
						<input id="currentRange" type="hidden" name="currentRange" value="%s"></input>
						<input id="lastPoster" type="hidden" name="lastPoster" value="%s"></input>
						<input id="lastName" type="hidden" name="lastName" value="%s"></input>
						<input id="lastYear" type="hidden" name="lastYear" value="%s"></input>
					 """ % (isRunning, isFinished, currentProgress, currentRange, lastPoster, lastName, lastYear)
		
		finalOutput = finalOutput.replace("<!-- SYNC_STATES -->", syncStates)
	
		return utf8ToLatin(finalOutput)	
	def action(self, request):
		global MediaInfo
		global utf8ToLatin
		if MediaInfo is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.MediaInfo import MediaInfo
		if utf8ToLatin is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Utf8 import utf8ToLatin
		
		finalOutput = WebHelper().getHtmlCore("Episodes", True)
		finalOutput = finalOutput.replace("<!-- CUSTOM_TITLE -->", " - Episodes")

		tableHeader = WebHelper().readFileContent(u"/DMC_Plugins/DMC_WebInterfaceExtras/content/custom/Episodes/Header.tpl")
		tableBody = u""
		
		# get episodes of serie (parentid)
		ParentId = request.args["ParentId"][0]
		entries = WebData().getData("EpisodesOfSerie", ParentId)
		
		for entry in entries:
			mediaId = entry.Id
			evtEdit = self._editEpisode(entry, "isEpisode")
			evtDelete = self._deleteEpisode(entry, "isEpisode")
			evtStream = self._streamEpisode(mediaId, "isEpisode")
			evtPlay = self._playEpisode(mediaId, "isEpisode")
			evtLoad = self._downloadEpisode(mediaId, "isEpisode")
			evtFailed = self._moveToFailed(entry, "isEpisode")
			
			if WebData().getData("MediaInfo_isSeen", mediaId):
				isSeen = ""
			else:
				isSeen = '<img src="/content/global/img/unseen.png" alt="unseen" title="unseen"></img>'
			
			tableBody += u"""   <tr>
							<td>%s</td>
							<td><img src=\"/media/%s_poster_195x267.png\" width="78" height="107" alt="n/a"></img></td>
							<td>%s</td>
							<td>%s</td>
							<td>%s</td>
							<td>%s</td>
							<td>%s</td>
							<td>%s</td>
							<td>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/edit-grey.png" alt="edit" title="edit" /></a>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/delete-grey.png" alt="delete" title="delete" /></a>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/stream.png" alt="stream Episode" title="stream Episode" /></a>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/play-grey.png" alt="play Episode" title="play Episode" /></a>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/download.png" alt="download Episode" title="download Episode" /></a>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/error.png" alt="move to failed" title="move to failed" /></a>
							</td>
						    </tr>
			""" % (isSeen, entry.TheTvDbId, entry.Title, entry.Season, entry.Episode, entry.Year, entry.ImdbId, entry.TheTvDbId, evtEdit, evtDelete, evtStream, evtPlay, evtLoad, evtFailed)
		
		finalOutput = finalOutput.replace("<!-- CUSTOM_THEAD -->", tableHeader)
		finalOutput = finalOutput.replace("<!-- CUSTOM_TBODY -->", tableBody)
	
		return utf8ToLatin(finalOutput)
	def action(self, request):
		global utf8ToLatin
		if utf8ToLatin is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Utf8 import utf8ToLatin
				
		finalOutput = WebHelper().getHtmlCore("Options" , True, "Global")
		
		tableBody = self.buildTableGlobal("options.global")
		finalOutput = finalOutput.replace("<!-- CUSTOM_TBODY_GLOBAL -->", tableBody)
	
		return utf8ToLatin(finalOutput)	
	def action(self, request):
		global MediaInfo
		global utf8ToLatin
		if MediaInfo is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.MediaInfo import MediaInfo
		if utf8ToLatin is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Utf8 import utf8ToLatin
				
		finalOutput = WebHelper().getHtmlCore("Failed", True)

		tableHeader = WebHelper().readFileContent(u"/DMC_Plugins/DMC_WebInterfaceExtras/content/custom/Failed/Header.tpl")
		tableBody = u""
		
		entries = WebData().getData("failed")

		for entry in entries:
			entryType = self._getEntryType(entry)
			
			evtFunctions = ""

			if entryType is "isMovie":
				evtFunctions += self._editFailedMovie(entry)
			elif entryType is "isEpisode":
				evtFunctions += self._editFailedEpisode(entry)
			elif entryType is "isFailed":
				evtFunctions += self._editFailedMovie(entry)
				evtFunctions += self._editFailedEpisode(entry)
			elif entryType is "isSerie":
				evtFunctions = "" #should not happen
				
			file = entry.Path + u"/" + entry.Filename + u"." + entry.Extension
			if not os.path.exists(str(file)):
				#printl("FILE = " + file, self, "H")
				evtFunctions += self._deleteFailedEntry(entry)	
			else:
				evtFunctions += self._showDeleteInfo(entry)	
				
			tableBody += u"""   <tr>
								<td>%s</td>
								<td>%s</td>
								<td>%s</td>
							    </tr>
						""" % (entry.Path + u"/" + entry.Filename + u"." + entry.Extension, entry.syncFailedCause, evtFunctions)
				
		finalOutput = finalOutput.replace("<!-- CUSTOM_THEAD -->", tableHeader)
		finalOutput = finalOutput.replace("<!-- CUSTOM_TBODY -->", tableBody)
	
		return utf8ToLatin(finalOutput)
	def action(self, request):
		global utf8ToLatin
		if utf8ToLatin is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Utf8 import utf8ToLatin
		
		finalOutput = WebHelper().getHtmlCore("Options" , True, "Sync")
						
		tableBody = self.buildTableSyncFileTypes("options.sync")
		finalOutput = finalOutput.replace("<!-- CUSTOM_TBODY_SYNC_FILETYPES -->", tableBody)
		
		tableBody = self.buildTableSyncPath("options.sync")
		finalOutput = finalOutput.replace("<!-- CUSTOM_TBODY_SYNC_PATH -->", tableBody)
		
		tableBody = self.buildTableSyncPathAdd("options.sync")
		finalOutput = finalOutput.replace("<!-- CUSTOM_TBODY_SYNC_PATH_ADD -->", tableBody)
	
		return utf8ToLatin(finalOutput)
	def action(self, request):
		global MediaInfo
		global utf8ToLatin
		if MediaInfo is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.MediaInfo import MediaInfo
		if utf8ToLatin is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Utf8 import utf8ToLatin
	
		finalOutput = WebHelper().getHtmlCore("TvShows", True)
			
		tableHeader = WebHelper().readFileContent(u"/DMC_Plugins/DMC_WebInterfaceExtras/content/custom/TvShows/Header.tpl")
		tableBody = u""
		
		entries = WebData().getData("tvshows")
		finalOutput = finalOutput.replace("<!-- CUSTOM_TITLE -->", " - Series")

		for entry in entries:
			evtShowEpisodes = self._getEpisodesOfTvShow(entry.Id)
			evtEdit = self._editTvShow(entry, "isTvShow")
			evtAddEpisode = self._addEpisode(entry, "isEpisode")
			evtDelete = self._deleteTvShow(entry, "isTvShow") 
			
			tableBody += u"""   <tr>
							<td><img src=\"/media/%s_poster_195x267.png\" width="78" height="107" alt="n/a"></img></td>
							<td>%s</td>
							<td>%s</td>
							<td>%s</td>
							<td><a href=http://thetvdb.com/index.php?tab=series&id=%s target="_blank">%s</a></td>
							<td>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/showEpisodes.png" alt="show Episodes" title="show Episodes" /></a>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/edit-grey.png" alt="edit" title="edit" /></a>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/add.png" alt="add" title="add" /></a>
								<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/delete-grey.png" alt="delete" title="delete" /></a>						
							</td>
						    </tr>
			""" % (entry.TheTvDbId, entry.Title, entry.Id, entry.ImdbId, entry.TheTvDbId, entry.TheTvDbId, evtShowEpisodes, evtEdit, evtAddEpisode, evtDelete)
		
		finalOutput = finalOutput.replace("<!-- CUSTOM_THEAD -->", tableHeader)
		finalOutput = finalOutput.replace("<!-- CUSTOM_TBODY -->", tableBody)
	
		return utf8ToLatin(finalOutput)
	def action(self, request):
		global utf8ToLatin
		global Manager
		if utf8ToLatin is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Utf8 import utf8ToLatin
		if Manager is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Manager import Manager
			
		finalOutput = WebHelper().getHtmlCore("Home")
		
		currentVersion = Update().getInstalledRevision()
		manager = Manager("WebIf:MainActions")
		movieCount = str(manager.getMoviesCount())
		tvShowCount = str(manager.getSeriesCount())
		episodeCount = str(manager.getEpisodesCount())
		
		updateType = Update().getCurrentUpdateType()
		latestRevision = Update().getLatestRevision()
		
		finalOutput = finalOutput.replace("<!-- MOVIE_COUNT -->", movieCount)
		finalOutput = finalOutput.replace("<!-- TVSHOW_COUNT -->", tvShowCount)
		finalOutput = finalOutput.replace("<!-- EPISODE_COUNT -->", episodeCount)
		
		revisionText = """	<br>
							Your update type => %s.<br>
							The latest release for your update type is %s.<br>
		""" % (updateType, latestRevision)

		finalOutput = finalOutput.replace("<!-- CURRENT_VERSION -->", "Your installed revision => " + currentVersion)
		finalOutput = finalOutput.replace("<!-- LATEST_VERSION -->", revisionText)
		
		return utf8ToLatin(finalOutput)
	def action(self, request):
		global MediaInfo
		if MediaInfo is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.MediaInfo import MediaInfo
		global utf8ToLatin
		if utf8ToLatin is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Utf8 import utf8ToLatin
		global Manager
		if Manager is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Manager import Manager
		
		finalOutput = WebHelper().getHtmlCore("MediaInfo", True)
		
		Id = None
		ParentId = None
		imdbId = u""
		theTvDbId = u""
		currentMode = request.args["mode"][0]
		if "type" in request.args:
			type = request.args["type"][0]
		else:
			type = u""
		
		#######################
		# DONE MODE
		#######################
		if currentMode == "showDoneForm" :
			
			return finalOutput
			
		#######################
		# GET MEDIA DETAILS FOR WEBIF
		#######################
		elif currentMode == "getMediaDetails":
			Id = request.args["Id"][0]
			data = self._getMediaDetails(type, int(Id))
			response = data.Path + "/" + data.Filename + "." + data.Extension
			
			return str(response)
		
		#######################
		# ERROR MODE
		######################
		elif currentMode == "showErrorForm":
			
			return finalOutput
		
		#######################
		# EDIT MODE
		#######################
		elif currentMode == 'showEditForm':
			nextMode = "alterMediaInDb"
			finalOutput = finalOutput.replace("<!-- CUSTOM_TITLE -->", " - Edit Media")
			Id = request.args["Id"][0]
			m = self._getMediaDetails(type, int(Id))
		
		#######################
		# ADDBYIMDB MODE
		#######################
		elif currentMode == 'showAddByImdbForm':
			fileData = None
			if "Id" in request.args:
				if request.args["Id"][0] == "":
					nextMode = "addMediaToDb"
				else:
					printl("ID => " + request.args["Id"][0], self, "D")
					nextMode = "alterMediaInDb"
					fileData = self._getMediaDetails(type, int(request.args["Id"][0]))
			else:
				nextMode = "addMediaToDb"
				
			finalOutput = finalOutput.replace("<!-- CUSTOM_TITLE -->", " - Add Media")
			m = MediaInfo()
			m.ImdbId = "";
			m.SearchString = "";
			if type == "isEpisode":
				type = "isSerie" # we need to do this because Manger.syncelemnts uses this name not the name till now isTvShow
			
			if fileData is not None:
				path = fileData.Path
				filename = fileData.Filename
				extension = fileData.Extension
			else:
				path = u"test"
				filename = u"test"
				extension = u"test"
				
			if type == "isMovie":
				m.ImdbId = request.args["ImdbId"][0]
				printl("showAddByImdbForm: "+str(request.args["ImdbId"][0]) + " " + str(type))
				syncData = Manager("WebIf:SubActions:MediaForm").syncElement(path, filename, extension, m.ImdbId, False)
				m = syncData[0]
			
			if type == "isSerie":
				m.ImdbId = request.args["ImdbId"][0]
				printl("showAddByImdbForm: "+str(request.args["ImdbId"][0]) + " " + str(type))
				syncData = Manager("WebIf:SubActions:MediaForm").syncElement(path, filename, extension, m.ImdbId, True)
				m = syncData[0]
		
		#######################
		# ADDBYTITLE MODE
		#######################				
		elif currentMode == 'showAlternativesForm':
			nextMode = "showAddByImdbForm"
			finalOutput = finalOutput.replace("<!-- CUSTOM_TITLE -->", " - Add Media")	
			mediainfo.SearchString = request.args["Title"][0]
			results = Manager("WebIf:SubActions:MediaForm").searchAlternatives(mediainfo)
		
		#######################
		# MOVETOFAILED
		#######################	
		elif currentMode == 'moveToFailed':
			nextMode = "showAddByImdbForm"
			#hier sollte mehr stehen lol
		
		if "Id" in request.args:
			Id = request.args["Id"][0]
		else:
			Id = u""		
			
		if "ParentId" in request.args:
			ParentId = request.args["ParentId"][0]
		else:
			ParentId = u""

		image = u""
		backdrop = u""
		mediaFolderPath = config.plugins.pvmc.mediafolderpath.value
		
		
		mediaForm = WebHelper().getHtmlForm("mediaForm")
		
		#######################
		# ADD MODE
		#######################	
		if currentMode=="showManualAddForm":
			nextMode = "addMediaToDb"
			mediaForm = mediaForm % (type, nextMode ,u"", ParentId, type, u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", u"", 0)
		else:
			if type == "isMovie":
				if os.path.isfile(mediaFolderPath + m.ImdbId + "_poster_195x267.png"):
					image = """<img id="duck_img" src="%s" width="78" height="107" alt="n/a"></img>""" % ("/media/" + str(m.ImdbId) + "_poster_195x267.png")
				else:
					image = """<img src=\"http://val.duckbox.info/convertImg2/poster/%s_195x267.png\" width="78" height="107" alt="n/a"></img>""" % (str(m.ImdbId))
				
				if os.path.isfile(mediaFolderPath + str(m.ImdbId) + "_backdrop_320x180.png"):
					backdrop = """<img id="duck_backdrop_img" src="%s" width="160" height="90" alt="n/a"></img>""" % ("/media/" + str(m.ImdbId) + "_backdrop_320x180.png")
				else:
					backdrop = """<img src=\"http://val.duckbox.info/convertImg2/backdrop/%s_320x180.png\" width="160" height="90" alt="n/a">""" % (str(m.ImdbId))
				
				
			elif type == "isTvShow" or type == "isEpisode":
				if os.path.isfile(mediaFolderPath + str(m.TheTvDbId) + "_poster_195x267.png"):
					image = """<img id="duck_img" src="%s" width="78" height="107" alt="n/a"></img>""" % ("/media/" + str(m.TheTvDbId) + "_poster_195x267.png")
				else:
					image = """<img src=\"http://val.duckbox.info/convertImg2/poster/%s_195x267.png\" width="78" height="107" alt="n/a"></img>""" % (str(m.TheTvDbId))
				
				if os.path.isfile(mediaFolderPath + str(m.TheTvDbId) + "_backdrop_320x180.png"):			
					backdrop = """<img id="duck_backdrop_img" src="%s" width="160" height="90" alt="n/a"></img>""" % ("/media/" + str(m.TheTvDbId) + "_backdrop_320x180.png")
				else:
					backdrop = """<img src=\"http://val.duckbox.info/convertImg2/backdrop/%s_320x180.png\" width="160" height="90" alt="n/a">""" % (str(m.TheTvDbId))
			
			seenCheck = ""
			
			if WebData().getData("MediaInfo_isSeen", m.Id):
				seenCheck = 'checked'
			printl("nextMode = " + nextMode, self, "W")
			
			if m.ParentId == None:
				m.ParentId = u""

			mediaForm = mediaForm % (type, nextMode, Id, m.ParentId, type, Id, m.ImdbId, m.TheTvDbId, m.Title, m.Tag, m.Season, m.Disc, m.Episode, m.EpisodeLast, m.Plot, m.Runtime, m.Year, m.Genres, self._getPopularity(m.Popularity), m.Path, m.Filename, m.Extension, seenCheck)

		finalOutput = finalOutput.replace("<!-- CUSTOM_IMAGE -->", image)
		finalOutput = finalOutput.replace("<!-- CUSTOM_BACKDROP -->", backdrop)
		finalOutput = finalOutput.replace("<!-- CUSTOM_FORM -->", mediaForm)
	
		return utf8ToLatin(finalOutput)
	def action(self, request):
		global utf8ToLatin
		global MediaInfo
		global MobileImdbComProvider
		
		if utf8ToLatin is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Utf8 import utf8ToLatin
		if MediaInfo is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.MediaInfo import MediaInfo
		if MobileImdbComProvider is None:
			from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.MobileImdbComProvider import MobileImdbComProvider
				
		finalOutput = WebHelper().getHtmlCore("Alternatives", True)
		
		tableHeader = WebHelper().readFileContent(u"/DMC_Plugins/DMC_WebInterfaceExtras/content/custom/Alternatives/Header.tpl")
		tableBody = u""
		
		mediainfo = MediaInfo()
		mediainfo.ImdbId = "";
		mediainfo.SearchString = "";

		mediainfo.SearchString = request.args["searchString"][0]
		entries = MobileImdbComProvider().getAlternatives(mediainfo)
		if entries is not None:
			for entry in entries:
				
				entry.type = request.args["type"][0]
				
				if "Id" in request.args:
					entry.Id = request.args["Id"][0]
				else:
					entry.Id = u""
	
				if "Path" in request.args:
					entry.Path = request.args["Path"][0]
				else:
					entry.Path = u""
				if "Filename" in request.args:
					entry.Filename = request.args["Filename"][0]
				else:
					entry.Filename = u""
				if "Extension" in request.args:
					entry.Extension = request.args["Extension"][0]
				else:
					entry.Extension = u""
			
			
				evtApply = self._getApplyAlternativeString(entry)
				
				tableBody += u"""   <tr>
									<td>%s</td>
									<td><a href=http://www.imdb.com/title/%s/ target="_blank">%s</a></td>
									<td>%s</td>
									<td>%s</td>
									<td>
										<a href="#" onclick="%s"><img class="action_img" src="/content/global/img/apply.png" alt="apply" title="apply" /></a>
									</td>
									</tr>
							""" % (entry.Year, entry.ImdbId, entry.ImdbId, utf8ToLatin(entry.Title), entry.IsTVSeries, evtApply)
			
		
		finalOutput = finalOutput.replace("<!-- CUSTOM_THEAD -->", tableHeader)
		finalOutput = finalOutput.replace("<!-- CUSTOM_TBODY -->", tableBody)
		
		return utf8ToLatin(finalOutput)