Browse Source

updated procesEditor

Piotr Labudda 8 years ago
parent
commit
2cf6e44899
3 changed files with 752 additions and 325 deletions
  1. 153 45
      SE/se-lib/Route/UrlAction/ProcesEditor.php
  2. 562 266
      SE/static/procesEditor.js
  3. 37 14
      SE/static/videoPlayer.js

+ 153 - 45
SE/se-lib/Route/UrlAction/ProcesEditor.php

@@ -1,25 +1,7 @@
 <?php
 
-/*
-CREATE TABLE IF NOT EXISTS `CRM_VIDEO` (
-  `VIDEO_ID` int(11) NOT NULL,
-  `REMOTE_TABLE` int(11) NOT NULL,
-  `REMOTE_ID` int(11) NOT NULL,
-  `PARENT_ID` int(11) NOT NULL,
-  `THUMBNAIL_ID` int(11) NOT NULL,
-  `NAME` varchar(255) NOT NULL,
-  `VIDEO_START` int(11) NOT NULL,
-  `VIDEO_END` int(11) NOT NULL,
-  `PATH` varchar(255) NOT NULL
-) ENGINE=InnoDB DEFAULT CHARSET=latin2;
 
 
-ALTER TABLE `CRM_VIDEO`
-  ADD PRIMARY KEY (`VIDEO_ID`);
-
-
-*/
-
 
 Lib::loadClass('RouteBase');
 Lib::loadClass('ProcesHelper');
@@ -90,7 +72,7 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 
 	private function addWatermark($url){
 
-		$watermark_file = "/Library/Server/Web/Data/Sites/Default/SE/stuff/images/play.png";
+		$watermark_file = "/Library/Server/Web/Data/Sites/Default/SE/stuff/images/play.png"; //to change
 
 		$image = new Imagick();
 		$image->readImage($url);
@@ -133,7 +115,7 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 				VALUES(:NAME, :TYPE, :REMOTE_TABLE, :REMOTE_ID, :IMAGE, :SIZE)");
 
 		if(in_array($type, $imgExtList)){
-			$content = 'data:'.$type.';base64,'.base64_encode(file_get_contents($url));
+			$content = 'data:'.$type.';base64,'.base64_encode(file_get_contents($url));//
 
 
 			$statement->execute(array(
@@ -147,11 +129,21 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 
 			$info->statusCode = 0;
 			$info->statusText = "Plik załadowany pomyślnie" ;
-		}elseif(in_array($type, $vidExtList)){
+		}else if(false && in_array($type, $vidExtList)){ //Only image files
+
+
+			$statement_video = DB::getPDO()->prepare("INSERT INTO CRM_VIDEO(NAME, TYPE, REMOTE_TABLE, REMOTE_ID, PARENT_ID, HAS_FILE, EXT, VIDEO_START, VIDEO_END)
+				VALUES(:NAME, :TYPE, :REMOTE_TABLE, :REMOTE_ID, :PARENT_ID, :HAS_FILE, :EXT, :VIDEO_START, :VIDEO_END)");
+
 
+			$cmd_duration = "/usr/local/bin/ffmpeg -i ".$url." 2>&1 | grep \"Duration\" | cut -d, -f1 | sed 's#Duration\:##'  | sed 's#   ##' | cut -d. -f1";
 
-			$statement_video = DB::getPDO()->prepare("INSERT INTO CRM_VIDEO(NAME, TYPE, REMOTE_TABLE, REMOTE_ID, PARENT_ID, HAS_FILE, EXT)
-				VALUES(:NAME, :TYPE, :REMOTE_TABLE, :REMOTE_ID, :PARENT_ID, :HAS_FILE, :EXT)");
+			$str_time = exec($cmd_duration);
+			$str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", $str_time);
+
+			sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
+
+			$time_seconds = $hours * 3600 + $minutes * 60 + $seconds;
 
 			$statement_video->execute(array(
 				":NAME" => $name,
@@ -161,14 +153,16 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 				":REMOTE_ID"  => User::getID(),
 				":EXT" => $ext,
 				":HAS_FILE"  => 1,
+				":VIDEO_START"  => 0,
+				":VIDEO_END"  => $time_seconds,
 			));
 			$id = DB::getPDO()->lastInsertId();
-			echo $url."\n";
-			echo $CRM_VIDEO.$id.$ext;
 
 			$temp_file = tempnam(sys_get_temp_dir(), 'thumbnail_');
 			rename($temp_file, $temp_file .= '.png');
 			$cmd = '/usr/local/bin/ffmpeg -y -i '.$url.' -ss 00:00:1 -vframes 1 '.$temp_file.' 2>&1';
+
+
 			shell_exec($cmd);
 
 
@@ -185,13 +179,15 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 				":SIZE"  => $img_size
 			));
 			move_uploaded_file ( $url, $CRM_VIDEO.$id.".".$ext );
+			$info->statusCode = 0;
+			$info->statusText = "Plik załadowany pomyślnie" ;
 		}else{
 			$info->statusCode = 1;
 			$info->statusText = "Nieobsługiwany format pliku ".$type ;
 		}
 
 
-		echo json_encode($info);
+		Response::sendJsonExit($info);
 
 
 	}
@@ -212,9 +208,18 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 				JOIN CRM_VIDEO f ON tmp2._id = f.VIDEO_ID
 				WHERE f.HAS_FILE = 1 and f.TYPE = 'video/mp4'
 			");
+
+			$rows_time = DB::getPDO()->fetchAll("
+				SELECT `VIDEO_START`, `VIDEO_END` FROM `CRM_VIDEO` WHERE `VIDEO_ID` = {$sqlVideoId}
+			");
+
+
+
 			$id = $rows[0]["VIDEO_ID"];
 			$CRM_VIDEO = "/PLIKI/bartosz_procesy5_pl/CRM_VIDEO/";
 			$result["src"] = $CRM_VIDEO.$id.".mp4";
+			$result["VIDEO_START"] = $rows_time[0]["VIDEO_START"];
+			$result["VIDEO_END"] = $rows_time[0]["VIDEO_END"];
 			Response::sendJsonExit($result);
 
 		} catch (Exception $e) {
@@ -303,6 +308,30 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 		}
 	}
 
+	public function getResTreeAjaxAction() {
+		try {
+			$id = V::get('id', '', $_GET);
+			$sql = "
+				select p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
+				from CRM_LISTA_ZASOBOW g
+					left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
+					left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
+					left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
+				where g.`A_STATUS` not in ('DELETED')
+					and (p1.ID is null or p1.`A_STATUS` not in ('DELETED'))
+					and (p2.ID is null or p2.`A_STATUS` not in ('DELETED'))
+					and (p3.ID is null or p3.`A_STATUS` not in ('DELETED'))
+					and g.ID = {$id}
+				limit 1
+			";
+			DBG::_('DBG_SQL', '>1', 'sql', $sql, __CLASS__, __FUNCTION__, __LINE__);
+			$rows = DB::getPDO()->fetchAll($sql);
+			Response::sendJsonExit($rows);
+		} catch (Exception $e) {
+			UI::alert('danger', "Error: " . $e->getMessage());
+		}
+	}
+
 	public function getResAjaxAction() {
 		try {
 			$word = V::get('word', '', $_GET);
@@ -373,6 +402,39 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 		// zapisać jsona w sesji
 	}
 
+	public function reinstallAction(){
+
+		DB::getPDO()->execSql("
+			CREATE TABLE IF NOT EXISTS `CRM_IMAGE` (
+		  `ID` int(11) NOT NULL,
+		  `NAME` varchar(50) NOT NULL,
+		  `SIZE` int(11) NOT NULL,
+		  `TYPE` varchar(25) NOT NULL,
+		  `IMAGE` mediumblob NOT NULL,
+		  `ICON` tinyblob,
+		  `WIDTH` int(11) NOT NULL,
+		  `HEIGHT` int(11) NOT NULL,
+		  `REMOTE_TABLE` enum('CRM_LISTA_ZASOBOW','CRM_PROCES','CRM_WSKAZNIK','ADMIN_USERS','CRM_VIDEO') NOT NULL,
+		  `REMOTE_ID` int(11) NOT NULL,
+		  `DEST` varchar(16) NOT NULL,
+		  `A_CREATE_DATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+		  `A_RECORD_CREATE_AUTHOR` varchar(100) NOT NULL,
+		  `SYNC_SQIX_STATUS` varchar(255) NOT NULL,
+		  `A_RECORD_CREATE_DATE` varchar(20) NOT NULL DEFAULT '0000-00-00 00:00:00',
+		  `A_RECORD_UPDATE_DATE` varchar(255) NOT NULL,
+		  `A_RECORD_UPDATE_AUTHOR` varchar(50) NOT NULL
+		) ENGINE=MyISAM DEFAULT CHARSET=latin2
+		");
+		try {
+			DB::getPDO()->execSql("
+				ALTER table `CRM_IMAGE` CHANGE `REMOTE_TABLE` `REMOTE_TABLE` enum('CRM_LISTA_ZASOBOW','CRM_PROCES','CRM_WSKAZNIK','ADMIN_USERS','CRM_VIDEO') NOT NULL
+			");
+		} catch (Exception $e) {
+			DBG::log($e);
+		}
+
+	}
+
 	public function defaultAction() {
 		UI::gora();
 		UI::menu();
@@ -405,7 +467,7 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 
 					<button class='lButton btn btn-default' id="btnZasoby" style="top:150px"><p>Zasoby</p></button>
 					<button class='lButton btn btn-default' style="top:315px" id="btnProcesy"><p>Procesy</p></button>
-					<!--<button class='lButton btn btn-default' id="btnPhotos" style="top:480px"><p>Media</p></button>-->
+					<button class='lButton btn btn-default' id="btnPhotos" style="top:480px"><p>Media</p></button>
 				</div>
 				<div class=col-md-12 >
 				<div class=col-md-12 ><a id=toggleMenu style=cursor:pointer;>Przełącz menu</a>
@@ -423,9 +485,10 @@ class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @se
 		<script src="static/sweetalert2.min.js"></script>
 		<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/9.8.1/bootstrap-slider.min.js" crossorigin="anonymous"></script>
 
-		<script src="static/videoPlayer.js?v=19<?php echo "&_time=" . time(); ?>"></script>
+		<script src="static/videoPlayer.js?v=?<?php echo time(); if (V::get('DBG', '', $_GET)) echo "&_time=" . time(); ?>"></script>
 		<script src="static/jquery.fileupload.js"></script>
-		<script src="static/procesEditor.js?v=21<?php if (V::get('DBG', '', $_GET)) echo "&_time=" . time(); ?>"></script>
+		<script src="static/procesEditor.js?<?php echo time();  if (V::get('DBG', '', $_GET)) echo "&_time=" . time(); ?>"></script>
+
 <?php
 	}
 
@@ -566,24 +629,33 @@ color:#e74c3c;
 	color:black;
 }
 
-.attImg, .attVid{
+.no-draggable .dragIcon{
+	display:none;
+}
 
-	border-style:solid;
+.no-draggable .imgTitle{
+	cursor:auto !important;
+}
+
+.attImg, .attVid{
+	position:relative;
 	display:inline-block;
 	margin-top:5px;
 	margin-left:10px;
 }
 
 .attImg .img, .attVid .img{
-	height:165px;
+	height:100%;
+	display: flex;
+	position:relative;
 	background-color:black;
-	display: table-cell;
     vertical-align: middle;
 }
 
 .attImg img, .attVid img{
-  max-width:165px;
-  max-height:165px;
+align-items: stretch;
+  max-width:100%;
+
   width: auto;
   height: auto;
 }
@@ -597,14 +669,21 @@ color:#e74c3c;
 .remImg{
 
 	cursor:pointer;
+	padding-left:2px;
+	padding-right:3px;
+
+}
+
+.noRemove .remImg{
+	display:none;
+
+
+}
+
+.remImg:hover{
+
 	color:red;
-	padding:2px;
 
-	background-color:white;
-	border-bottom-style:solid;
-	border-right-style:solid;
-	border-color:black;
-	border-width:1px;
 }
 
 .attImg div, .attVid div{
@@ -722,6 +801,16 @@ ul {
 	border-width:1px;
 }
 
+.incorrect{
+	border-style:solid !important;
+	border-color:#e74c3c !important;
+}
+
+.focused{
+	border-style:solid !important;
+	border-color:#3498db !important;
+}
+
 
 /* skin.css Style*/
 #inp {
@@ -876,6 +965,19 @@ width:290px;
 
 }
 
+.imagesDrop{
+	border-style:dashed;
+	border-width:1px;
+	border-color:#bdc3c7;
+
+
+}
+
+.sdesc{
+
+	min-height:20px;
+}
+
 #side .tabelaName {
     white-space: nowrap;
     margin-right: 10px;
@@ -1036,15 +1138,15 @@ width:290px;
 }
 .slider .slider-handle {} .p5VideoPlayer_vid {
     background-color: black;
-    height: calc(100% - 20px);
+    height: 100%;
     width: 100%;
 }
 
 
 .p5VideoPlayer {
+	width:100%;
+	height:calc(100% - 18px);
 
-	width:165px;
-	height:165px;
 
 }
 
@@ -1060,7 +1162,12 @@ width:290px;
 }
 .p5VideoPlayer_video-controls {
     background-color: powderblue;
-	margin-top:-5px;
+	position:relative;
+
+}
+
+.p5VideoPlayer_video-controls:not(.p5VideoPlayer_video-controls-fs) {
+	top:-25px;
 
 }
 
@@ -1073,6 +1180,7 @@ width:290px;
 }
 .p5VideoPlayer_video-controls-fs {
     opacity: 0;
+
     position: absolute;
     bottom: 0;
     left: 0;

File diff suppressed because it is too large
+ 562 - 266
SE/static/procesEditor.js


+ 37 - 14
SE/static/videoPlayer.js

@@ -17,7 +17,7 @@ function secondsToTime(secs) {
 }
 
 $(document).on("change", ".p5VideoPlayer_zakres", function(slideEvt) {
-    console.log("test");
+    //console.log("test");
     var player = $(this).closest(".p5VideoPlayer")
     var start = $(player).data("start")
     var end = $(player).find('.p5VideoPlayer_vid')[0].duration - $(player).data("end")
@@ -25,7 +25,15 @@ $(document).on("change", ".p5VideoPlayer_zakres", function(slideEvt) {
 });
 
 
-function videoPlayer_updateProgress(player) {
+
+
+function videoPlayer_updateProgress(player, id) {
+	if(!jQuery.contains(document, $(player)[0])){
+
+		clearInterval(instances[id]["INTERVAL"])
+		return
+	}
+
     var start = $(player).data("start")
     var end = $(player).data("end")
     var current = $(player).find('.p5VideoPlayer_vid')[0].currentTime - start;
@@ -50,16 +58,20 @@ function videoPlayer_updateProgress(player) {
         $(el).removeClass("glyphicon-pause")
         $(el).addClass("glyphicon-play")
     }
+	$( player ).trigger( "videoProgress" );
 }
 
-
-$(document).on("click", ".img", function() {
-    if (!$(this).parent().hasClass("p5VideoPlayer")) return false;
-    var player = $(this).parent();
+function p5VideoPlayer_init(imgEl){
+ if (!$(imgEl).parent().hasClass("p5VideoPlayer")) return false;
+    var player = $(imgEl).parent();
     var id = $(player).data("videoid");
     var link = BASE_URL + "index.php?_route=UrlAction_ProcesEditor&_task=getVideoFileAjax&id=" + id;
     $.get(link, function(data) {
-        $(player).html(`
+		if($(player).data("start") === true)
+			$(player).data("start", data["VIDEO_START"]);
+		if($(player).data("end") === true)
+			$(player).data("end", data["VIDEO_END"]);
+        $(player).append(`
 				<video class="p5VideoPlayer_vid">
 	 		   <source src="` + data["src"] + `" type="video/mp4">
 	 		 Your browser does not support the video tag.
@@ -82,6 +94,7 @@ $(document).on("click", ".img", function() {
 
 	 		   </div>
 				`)
+		$(player).find(".img").hide()
         $(player).find('.p5VideoPlayer_vid')[0].currentTime = $(player).data("start");
         $('.p5VideoPlayer_zakres').slider({
 
@@ -95,17 +108,22 @@ $(document).on("click", ".img", function() {
                 return value + "%";
             }
         });
-        videoPlayer_updateProgress(player);
+        //videoPlayer_updateProgress(player);
 		var temp = {}
-		temp["vid"] = $(player).find('.p5VideoPlayer_vid')[0];
-        temp["INTERVAL"] = setInterval(function() {
-            videoPlayer_updateProgress(player);
-        }, 500);
+		temp["vid"] = $(player).find('.p5VideoPlayer_vid');
+		//console.log("instances ", instances.length)
 		instances.push(temp);
+		
+        instances[instances.length-1]["INTERVAL"] = setInterval(function() {
+            videoPlayer_updateProgress(player, instances.length-1);
+        }, 500);
+		
     });
 
+}
 
-
+$(document).on("click", ".img", function() {
+   p5VideoPlayer_init(this);
 });
 
 function videoPlayer_play(el) {
@@ -114,6 +132,11 @@ function videoPlayer_play(el) {
     var video = $(player).find(".p5VideoPlayer_vid");
     el = $(player).find(".p5VideoPlayer_play");
     if ($(video).prop("paused")) {
+		$.each(instances, function(i,e){
+			if(!$(e["vid"]).prop("paused")){
+				videoPlayer_play(e["vid"]);
+			}
+		})
         $(video).trigger('play');
         $(el).removeClass("glyphicon-play")
         $(el).addClass("glyphicon-pause")
@@ -125,7 +148,7 @@ function videoPlayer_play(el) {
         $(el).addClass("glyphicon-play")
 
     }
-    videoPlayer_updateProgress(player);
+    //videoPlayer_updateProgress(player);
 }
 
 $('.p5VideoPlayer_vid').on('canplay canplaythrough', function() {

Some files were not shown because too many files changed in this diff