Pass exportStructure around so that it can be used to put the right filename to the jpg in the html. Fix flat zips. Fix video files being included if exportMisc is true.
This commit is contained in:
parent
105851b70c
commit
eecf568041
|
@ -570,14 +570,14 @@ else if (document.layers) window.onload=start_slider;
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
} # end function exportEventImages($event, $exportDetail, $exportFrames, $myfilelist)
|
} # end function exportEventImages($event, $exportDetail, $exportFrames, $myfilelist)
|
||||||
|
|
||||||
function eventlist_html($Event, $exportDetail, $exportFrames) {
|
function eventlist_html($Event, $exportDetail, $exportFrames, $exportStructure) {
|
||||||
$html = '<div class="event">
|
$html = '<div class="event">
|
||||||
';
|
';
|
||||||
if ( $Event->SaveJPEGs() ) {
|
if ( $Event->SaveJPEGs() ) {
|
||||||
$html .= '<a href="#" onclick="switchevent(\''.$Event->Id().'/zmEventImages.html\');return false;">
|
$html .= '<a href="#" onclick="switchevent(\''.$Event->Id().'/zmEventImages.html\');return false;">
|
||||||
';
|
';
|
||||||
if ( ZM_WEB_LIST_THUMBS ) {
|
if ( ZM_WEB_LIST_THUMBS ) {
|
||||||
$html .= '<img width="'.ZM_WEB_LIST_THUMB_WIDTH.'" src="'. $Event->Id().'/snapshot.jpg" alt="'.$Event->Id().'"/>
|
$html .= '<img width="'.ZM_WEB_LIST_THUMB_WIDTH.'" src="'. $Event->Id().($exportStructure=='flat'?'_':'/').'snapshot.jpg" alt="'.$Event->Id().'"/>
|
||||||
';
|
';
|
||||||
} else {
|
} else {
|
||||||
$html .= $Event->Id();
|
$html .= $Event->Id();
|
||||||
|
@ -588,7 +588,7 @@ function eventlist_html($Event, $exportDetail, $exportFrames) {
|
||||||
if ( $Event->DefaultVideo() ) {
|
if ( $Event->DefaultVideo() ) {
|
||||||
if ( ZM_WEB_LIST_THUMBS ) {
|
if ( ZM_WEB_LIST_THUMBS ) {
|
||||||
$html .= '<a href="'.$Event->Id().'/'.$Event->DefaultVideo() .'">';
|
$html .= '<a href="'.$Event->Id().'/'.$Event->DefaultVideo() .'">';
|
||||||
$html .= '<img width="'.ZM_WEB_LIST_THUMB_WIDTH.'" src="'. $Event->Id().'/snapshot.jpg" alt="'.$Event->Id().'"/>';
|
$html .= '<img width="'.ZM_WEB_LIST_THUMB_WIDTH.'" src="'. $Event->Id().($exportStructure=='flat'?'_':'/').'snapshot.jpg" alt="'.$Event->Id().'"/>';
|
||||||
$html .= '</a><br/>
|
$html .= '</a><br/>
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ function eventlist_html($Event, $exportDetail, $exportFrames) {
|
||||||
return $html;
|
return $html;
|
||||||
} // end function eventlist_html
|
} // end function eventlist_html
|
||||||
|
|
||||||
function exportEventImagesMaster($eids, $exportDetail, $exportFrames) {
|
function exportEventImagesMaster($eids, $exportDetail, $exportFrames, $exportStructure) {
|
||||||
ob_start();
|
ob_start();
|
||||||
exportHeader(translate('Images').' Master');
|
exportHeader(translate('Images').' Master');
|
||||||
?>
|
?>
|
||||||
|
@ -648,7 +648,7 @@ function exportEventImagesMaster($eids, $exportDetail, $exportFrames) {
|
||||||
<h2> All </h2>
|
<h2> All </h2>
|
||||||
<?php
|
<?php
|
||||||
foreach($events as $event) {
|
foreach($events as $event) {
|
||||||
echo eventlist_html($event, $exportDetail, $exportFrames);
|
echo eventlist_html($event, $exportDetail, $exportFrames, $exportStructure);
|
||||||
} # end foreach event
|
} # end foreach event
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -658,7 +658,7 @@ function exportEventImagesMaster($eids, $exportDetail, $exportFrames) {
|
||||||
echo '<h2>Monitor: '.$monitorNames[$monitor_id].'</h2>';
|
echo '<h2>Monitor: '.$monitorNames[$monitor_id].'</h2>';
|
||||||
foreach ( $events as $event ) {
|
foreach ( $events as $event ) {
|
||||||
if ( $event->MonitorId() == $monitor_id ) {
|
if ( $event->MonitorId() == $monitor_id ) {
|
||||||
echo eventlist_html($event, $exportDetail, $exportFrames);
|
echo eventlist_html($event, $exportDetail, $exportFrames, $exportStructure);
|
||||||
} # end if its the right monitor
|
} # end if its the right monitor
|
||||||
} # end foreach event
|
} # end foreach event
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
@ -772,8 +772,8 @@ function exportFileList(
|
||||||
$exportVideo,
|
$exportVideo,
|
||||||
$exportMisc
|
$exportMisc
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (!canView('Events') or !$event) {
|
if (!canView('Events') or !$event) {
|
||||||
|
ZM\Error("Can't view events or !event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,6 +788,7 @@ function exportFileList(
|
||||||
}
|
}
|
||||||
closedir($dir);
|
closedir($dir);
|
||||||
}
|
}
|
||||||
|
ZM\Debug(print_r($files, true));
|
||||||
|
|
||||||
$exportFileList = array();
|
$exportFileList = array();
|
||||||
|
|
||||||
|
@ -798,8 +799,10 @@ function exportFileList(
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
$exportFileList[$file] = $file;
|
$exportFileList[$file] = $file;
|
||||||
} else {
|
} else {
|
||||||
ZM\Error("Can't open event detail export file '$file'");
|
ZM\Error("Can't open event detail export file '$eventPath/$file'");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ZM\Debug('Not including detail');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($exportFrames) {
|
if ($exportFrames) {
|
||||||
|
@ -809,8 +812,10 @@ function exportFileList(
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
$exportFileList[$file] = $file;
|
$exportFileList[$file] = $file;
|
||||||
} else {
|
} else {
|
||||||
ZM\Error("Can't open event frames export file '$file'");
|
ZM\Error("Can't open event frames export file '$eventPath/$file' is writable? ".is_writable($eventPath));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ZM\Debug('Not including frames');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($exportImages) {
|
if ($exportImages) {
|
||||||
|
@ -836,26 +841,31 @@ function exportFileList(
|
||||||
ZM\Error("Can't open event images export file '$file'");
|
ZM\Error("Can't open event images export file '$file'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ZM\Debug('Not including frame images');
|
||||||
} # end if exportImages
|
} # end if exportImages
|
||||||
|
|
||||||
if ( $exportVideo ) {
|
|
||||||
$filesLeft = array();
|
$filesLeft = array();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (preg_match('/\.(?:mpg|mpeg|mov|swf|mp4|mkv|avi|asf|3gp)$/', $file)) {
|
if (preg_match('/\.(?:mpg|mpeg|mov|swf|mp4|mkv|avi|asf|3gp)$/', $file)) {
|
||||||
|
if ($exportVideo) {
|
||||||
$exportFileList[$file] = $file;
|
$exportFileList[$file] = $file;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$filesLeft[$file] = $file;
|
$filesLeft[$file] = $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$files = $filesLeft;
|
$files = $filesLeft;
|
||||||
} # end if exportVideo
|
|
||||||
|
|
||||||
if ($exportMisc) {
|
if ($exportMisc) {
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$exportFileList[$file] = $file;
|
$exportFileList[$file] = $file;
|
||||||
}
|
}
|
||||||
$files = array();
|
$files = array();
|
||||||
|
} else {
|
||||||
|
ZM\Debug('Not including misc');
|
||||||
}
|
}
|
||||||
|
ZM\Debug(print_r($exportFileList, true));
|
||||||
return array_values($exportFileList);
|
return array_values($exportFileList);
|
||||||
} # end exportFileList()
|
} # end exportFileList()
|
||||||
|
|
||||||
|
@ -898,7 +908,6 @@ function exportEvents(
|
||||||
ZM\Error("Can't create exports dir at '$export_dir'");
|
ZM\Error("Can't create exports dir at '$export_dir'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ZM\Debug("Successfully created dir '$export_dir'");
|
|
||||||
chmod($export_dir, 0700);
|
chmod($export_dir, 0700);
|
||||||
if (!chdir($export_dir)) {
|
if (!chdir($export_dir)) {
|
||||||
ZM\Error("Can't chdir to $export_dir");
|
ZM\Error("Can't chdir to $export_dir");
|
||||||
|
@ -923,14 +932,23 @@ function exportEvents(
|
||||||
foreach ($event_exportFileList as $file) {
|
foreach ($event_exportFileList as $file) {
|
||||||
#if ( preg_match('/\.html$/', $file) )
|
#if ( preg_match('/\.html$/', $file) )
|
||||||
#continue;
|
#continue;
|
||||||
|
if ($exportStructure == 'flat') {
|
||||||
|
$cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$event->Id().'_'.$file. ' 2>&1';
|
||||||
|
} else {
|
||||||
$cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$event->Id().'/'.$file. ' 2>&1';
|
$cmd = 'cp -as '.$event->Path().'/'.$file.' '.$export_dir.'/'.$event->Id().'/'.$file. ' 2>&1';
|
||||||
|
}
|
||||||
exec($cmd, $output, $return);
|
exec($cmd, $output, $return);
|
||||||
ZM\Debug($cmd.' return code: '.$return.' output: '.print_r($output,true));
|
ZM\Debug($cmd.' return code: '.$return.' output: '.print_r($output,true));
|
||||||
} # end foreach event_exportFile
|
} # end foreach event_exportFile
|
||||||
} # end foreach event
|
} # end foreach event
|
||||||
|
|
||||||
if ( !symlink(ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/jquery.min.js', $export_dir.'/jquery.min.js') )
|
if (!(
|
||||||
|
symlink(ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/jquery.min.js', $export_dir.'/jquery.min.js')
|
||||||
|
or
|
||||||
|
file_exists($export_dir.'/jquery.min.js')
|
||||||
|
)) {
|
||||||
ZM\Error('Failed linking '.ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/jquery.min.js to '.$export_dir.'/jquery.min.js');
|
ZM\Error('Failed linking '.ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/jquery.min.js to '.$export_dir.'/jquery.min.js');
|
||||||
|
}
|
||||||
//if ( !symlink(ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/video.js', $export_dir.'/video.js') )
|
//if ( !symlink(ZM_PATH_WEB.'/'.ZM_SKIN_PATH.'/js/video.js', $export_dir.'/video.js') )
|
||||||
//Error("Failed linking video.js");
|
//Error("Failed linking video.js");
|
||||||
|
|
||||||
|
@ -938,7 +956,7 @@ function exportEvents(
|
||||||
$html_eventMaster_path = $export_dir.'/'.$html_eventMaster_file;
|
$html_eventMaster_path = $export_dir.'/'.$html_eventMaster_file;
|
||||||
|
|
||||||
if (($fp = fopen($html_eventMaster_path, 'w'))) {
|
if (($fp = fopen($html_eventMaster_path, 'w'))) {
|
||||||
fwrite($fp, exportEventImagesMaster($eids, $exportDetail, $exportFrames));
|
fwrite($fp, exportEventImagesMaster($eids, $exportDetail, $exportFrames, $exportStructure));
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
$exportFileList[] = $html_eventMaster_file;
|
$exportFileList[] = $html_eventMaster_file;
|
||||||
} else {
|
} else {
|
||||||
|
@ -960,7 +978,6 @@ function exportEvents(
|
||||||
chdir(ZM_DIR_EXPORTS);
|
chdir(ZM_DIR_EXPORTS);
|
||||||
$archive = '';
|
$archive = '';
|
||||||
if ($exportFormat == 'tar') {
|
if ($exportFormat == 'tar') {
|
||||||
|
|
||||||
$archive = $export_root.($connkey?'_'.$connkey:'').'.tar';
|
$archive = $export_root.($connkey?'_'.$connkey:'').'.tar';
|
||||||
$version = shell_exec('tar -v');
|
$version = shell_exec('tar -v');
|
||||||
|
|
||||||
|
@ -982,8 +999,8 @@ function exportEvents(
|
||||||
} else if ($exportFormat == 'zip') {
|
} else if ($exportFormat == 'zip') {
|
||||||
$archive = $export_root.($connkey?'_'.$connkey:'').'.zip';
|
$archive = $export_root.($connkey?'_'.$connkey:'').'.zip';
|
||||||
$archive_path = ZM_DIR_EXPORTS.'/'.$archive;
|
$archive_path = ZM_DIR_EXPORTS.'/'.$archive;
|
||||||
$command = 'zip ';
|
$command = 'zip -r ';
|
||||||
$command .= ($exportStructure == 'flat' ? ' -j ' : ' -r ' ).escapeshellarg($archive_path);
|
$command .= ($exportStructure == 'flat' ? ' -j ' : '').escapeshellarg($archive_path);
|
||||||
$command .= $exportCompressed ? ' -9' : ' -0';
|
$command .= $exportCompressed ? ' -9' : ' -0';
|
||||||
} // if $exportFormat
|
} // if $exportFormat
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue