version 3.1.9

This commit is contained in:
Alchemy
2011-04-07 11:31:37 +02:00
parent 045562d3f5
commit 006602a463
9 changed files with 456 additions and 295 deletions

View File

@@ -170,6 +170,30 @@ class collection
return $new_bas;
}
public static function activate_collection($sbas_id, $base_id)
{
$conn = connection::getInstance();
$session = session::getInstance();
if(!$conn)
{
throw new Exception('Impossible de se connecter a la base');
}
$sql = "UPDATE bas SET active='1' WHERE base_id = '".$conn->escape_string($base_id)."'" ;
if(!$conn->query($sql))
{
throw new Exception('Impossible dactiver la collection');
}
$cache_appbox = cache_appbox::getInstance();
$cache_appbox->delete('list_bases');
cache_databox::update($sbas_id,'structure');
return true;
}
public static function duplicate_right_from_bas($base_id_from, $base_id_dest)
{
$conn = connection::getInstance();

View File

@@ -115,6 +115,25 @@ class databox extends base
return $mountable_colls;
}
public function get_activable_colls()
{
$conn = connection::getInstance();
$base_ids = array();
$sql = 'SELECT base_id FROM bas
WHERE sbas_id="' . $conn->escape_string($this->id) . '"
AND active = "0"';
if ($rs = $conn->query($sql))
{
while ($row = $conn->fetch_assoc($rs))
$base_ids[] = $row['base_id'];
$conn->free_result($rs);
}
return $base_ids;
}
public function list_colls()
{
$lb = phrasea::bases();

View File

@@ -154,12 +154,17 @@ class exportorder extends export
if(!$conn->query($sql))
$commit = false;
$cache_user = cache_user::getInstance();
foreach($admins as $admin)
{
$sql = 'INSERT INTO order_masters (id, usr_id, base_id) VALUES (null, "'.$conn->escape_string($admin).'", "'.$conn->escape_string($base_id).'")';
if(!$conn->query($sql))
$commit = false;
else
$cache_user->delete ($admin);
}
if($commit)

View File

@@ -91,7 +91,7 @@ class order
try
{
$basket = basket::getInstance($this->ssel_id);
$basket = basket::getInstance($this->ssel_id, $this->user->id);
}
catch(Exception $e)
{

View File

@@ -272,7 +272,7 @@ class user
}
public function __isset($name)
{
if(isset($this->data[$name]))
if(array_key_exists($name, $this->data))
return true;
return false;
}

View File

@@ -72,7 +72,7 @@ function getPreviewWindow($usr,$ses,$lng,$env,$pos,$contId,$roll)
$bas = $mypreview[0]["base_id"];
$rec = $mypreview[0]["record_id"];
$xmlMAIN = $mypreview[0]["xml"];
$isFullyPublic = true;
// $isFullyPublic = true;
$title = sprintf(_('preview:: resultat numero %s / '),'<span id="current_result_n">'.($pos+1).'</span>');
break;
case "REG":

View File

@@ -560,6 +560,9 @@ function get_fields_from_unknown(&$baseprefs, &$propfile, &$tfields)
function get_fields_from_jpg(&$baseprefs, &$propfile, &$tfields)
{
// (8x except 85, 8C) + (9x except 9C) + (BC, BD, BE)
static $macchars = "\x81\x82\x83\x84\x86\x87\x88\x89\x8A\x8B\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9D\x9E\x9F\xBC\xBD\xBE";
if($size = getimagesize($propfile['hotfolderfile'], $info))
{
$propfile['width'] = $size[0];
@@ -571,7 +574,6 @@ function get_fields_from_jpg(&$baseprefs, &$propfile, &$tfields)
}
$cmd = NULL;
$system = p4utils::getSystem();
if($system == 'DARWIN' )
@@ -594,30 +596,20 @@ function get_fields_from_jpg(&$baseprefs, &$propfile, &$tfields)
$s = @shell_exec($cmd);
if($s!='')
{
$domrdf = new DOMDocument();
$domrdf->recover = true;
$domrdf->preserveWhiteSpace = false;
if($domrdf->loadXML($s))
{
$xptrdf = new DOMXPath($domrdf);
$xptrdf->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') ;
$pattern = "(xmlns:([a-zA-Z-_0-9]+)=[']{1}(https?:[/{2,4}|\\{2,4}][\w:#%/;$()~_?/\-=\\\.&]*)[']{1})";
preg_match_all($pattern, $s, $matches, PREG_PATTERN_ORDER, 0);
foreach($matches[2] as $key=>$value)
{
$xptrdf->registerNamespace($matches[1][$key], $value) ;
}
$macchars = "\x81\x82\x83\x84\x86\x87\x88\x89\x8A\x8B\x8D\x8E\x8F"; // 8x except 85, 8C
$macchars .= "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9D\x9E\x9F"; // 9x except 9C
$macchars .= "\xBC\xBD\xBE";
$descriptionNode = @$xptrdf->query('/rdf:RDF/rdf:Description')->item(0);
if($descriptionNode)
@@ -806,7 +798,6 @@ function kill_ctrlchars($s) // ok en utf8 !
function makeSubdefs($sbas_id, $hdDoc)
{
$zdate = time();
$debug = false;
@@ -1015,7 +1006,6 @@ function getVideoInfos($hdPath)
{
$props = explode('=',$property);
if(array_key_exists($props[0], $docProps))
$propfile[$docProps[$props[0]]] = $props[1];
}
@@ -1029,7 +1019,7 @@ function getVideoInfos($hdPath)
return $retour;
}
/*
function getImageInfos($hdPath)
{
$retour = array('width'=>0, 'height'=>0, 'CMYK'=>false);
@@ -1045,14 +1035,122 @@ function getImageInfos($hdPath)
if(array_key_exists('Orientation', $ex))
$retour['Orientation'] = $ex['Orientation'];
}
var_dump($retour);
return $retour;
}
*/
/*
* return width, height, Orientation, CMYK for a (image) file, using exiftool
*/
function getImageInfos($hdPath)
{
$ret = array();
$cmd = NULL;
$system = p4utils::getSystem();
if($system == 'DARWIN' || $system == 'LINUX')
$cmd = GV_exiftool.' -X -n -fast ' . escapeshellarg($hdPath) . '';
elseif(chdir(GV_RootPath.'tmp/')) // WINDOWS
$cmd = 'start /B /LOW ' . GV_exiftool.' -X -n -fast ' . escapeshellarg($hdPath) . '';
if($cmd && ($s = @shell_exec($cmd)) != '')
{
$domrdf = new DOMDocument();
$domrdf->recover = true;
$domrdf->preserveWhiteSpace = false;
if($domrdf->loadXML($s))
{
$xptrdf = new DOMXPath($domrdf);
$xptrdf->registerNamespace('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#') ;
$pattern = "(xmlns:([a-zA-Z-_0-9]+)=[']{1}(https?:[/{2,4}|\\{2,4}][\w:#%/;$()~_?/\-=\\\.&]*)[']{1})";
preg_match_all($pattern, $s, $matches, PREG_PATTERN_ORDER, 0);
foreach($matches[2] as $key=>$value)
$xptrdf->registerNamespace($matches[1][$key], $value) ;
$descriptionNode = @$xptrdf->query('/rdf:RDF/rdf:Description')->item(0);
if($descriptionNode)
{
// exiftool fields giving tech infos, in order of 'reliability'
$fpri = array(
'File:ColorComponents' => array('f'=>'channels', 'v'=>NULL)
, 'Composite:ImageWidth' => array('f'=>'width', 'v'=>NULL)
, 'Composite:ImageHeight' => array('f'=>'height', 'v'=>NULL)
, 'Composite:ImageSize' => array('f'=>'imageSize', 'v'=>NULL)
, 'ExifIFD:ExifImageWidth' => array('f'=>'width', 'v'=>NULL)
, 'ExifIFD:ExifImageHeight' => array('f'=>'height', 'v'=>NULL)
, 'XMP-exif:ExifImageWidth' => array('f'=>'width', 'v'=>NULL)
, 'XMP-exif:ExifImageHeight' => array('f'=>'height', 'v'=>NULL)
, 'XMP-tiff:Orientation' => array('f'=>'Orientation', 'v'=>NULL)
, 'IFD0:ImageWidth' => array('f'=>'width', 'v'=>NULL)
, 'IFD0:ImageHeight' => array('f'=>'height', 'v'=>NULL)
, 'IFD0:Orientation' => array('f'=>'Orientation', 'v'=>NULL)
, 'IFD0:SamplesPerPixel' => array('f'=>'channels', 'v'=>NULL)
, 'IFD0:BitsPerSample' => array('f'=>'bits', 'v'=>NULL)
// last chanche values
, '*:ImageWidth' => array('f'=>'width', 'v'=>NULL)
, '*:ImageHeight' => array('f'=>'height', 'v'=>NULL)
, '*:BitsPerSample' => array('f'=>'bits', 'v'=>NULL)
, '*:Orientation' => array('f'=>'Orientation', 'v'=>NULL)
);
for($x = $descriptionNode->firstChild; $x; $x=$x->nextSibling)
{
if($x->nodeType==XML_ELEMENT_NODE)
{
$nodeName = $x->nodeName;
if(!array_key_exists($nodeName, $fpri))
{
// if not a well known field, try (rename) it as a last chance one
if( count($tmp = explode(':', $nodeName)) == 2)
$nodeName = '*:'.$tmp[1];
}
if(array_key_exists($nodeName, $fpri) && $fpri[$nodeName]['v'] === NULL)
{
$fpri[$nodeName]['v'] = trim($x->textContent);
}
}
}
// fill result with the most reliable found values
foreach($fpri as $f)
{
if($f['v'] !== NULL && !array_key_exists($f['f'], $ret))
$ret[$f['f']] = $f['v'];
}
// patch some values
if(array_key_exists('channels', $ret))
$ret['CMYK'] = ((int)($ret['channels']) == 4);
if( (!array_key_exists('width', $ret) || !array_key_exists('height', $ret)) && array_key_exists('imageSize', $ret))
{
if( count($tmp = explode('x', $ret['imageSize'])) == 2 )
{
$ret['width'] = $tmp[0];
$ret['height'] = $tmp[1];
}
}
foreach(array('width', 'height', 'channels', 'bits', 'Orientation') as $f)
{
if(array_key_exists($f, $ret))
$ret[$f] = (int)($ret[$f]);
}
}
}
}
// create some default values to unfound fields
$ret = array_merge(array('width'=>0, 'height'=>0, 'CMYK'=>false), $ret);
return($ret);
}
function isRaw($mime)
{
$raws = array(
'3fr' => 'image/x-tika-hasselblad'
,'arw' => 'image/x-tika-sony'
,'bay' => 'image/x-tika-casio'
@@ -1430,7 +1528,6 @@ function giveMeDocType($mime)
case 'image/x-tika-sigma':
case 'image/x-tika-sony':
case 'image/x-portable-pixmap':
$return = 'image';
break;
@@ -1510,7 +1607,6 @@ function giveMeDocType($mime)
function make1flashsubdef($infile, $sd, $physdpath, $infos)
{
$debug = false;
if($debug)
@@ -1558,7 +1654,6 @@ function make1flashsubdef($infile, $sd, $physdpath, $infos)
fclose($pipes[1]);
proc_close($process);
$lines = explode("\n",$stdout);
foreach($lines as $l)
{
@@ -1574,13 +1669,10 @@ function make1flashsubdef($infile, $sd, $physdpath, $infos)
$ext = '.png';
break;
}
}
}
if($id)
{
if($debug)
{
echo "jai bien le type de fichier : $id\n";
@@ -1613,7 +1705,6 @@ function make1flashsubdef($infile, $sd, $physdpath, $infos)
if(!$file_extracted)
return false;
if(($subdefs = make1subdef($infile_tmp,$sd, $physdpath, $infos)) != false)
{
unlink($infile_tmp);
@@ -1777,10 +1868,8 @@ function make1subdef($infile, $sd, $physdpath, $infos)
unlink($file);
}
if(is_file($tmpFile) && filesize($tmpFile) > 0)
{
$sdsize = (int)$sd->size;
$recalc = getimagesize($tmpFile);
@@ -2006,7 +2095,6 @@ function make1subdef($infile, $sd, $physdpath, $infos)
$return_value['height'] = 666;
$return_value['mime'] = 'image/jpeg';
}
}
return($return_value);
}
@@ -2056,7 +2144,6 @@ function pdf_from_document($infile)
function swf_from_document($infile, $outfile)
{
$infile = pdf_from_document($infile);
if(!$infile)
@@ -2185,10 +2272,8 @@ function make1Documentsubdef($infile, $sd, $physdpath, $infos)
function make1AudioSubdef($infile, &$sd, $physdpath, &$infos)
{
$debug = false;
$retour = false;
$sdtype = trim(mb_strtolower($sd->mediatype)); //MP3/JPG
$sdname = $sd->attributes()->name;
@@ -2199,7 +2284,6 @@ function make1AudioSubdef($infile, &$sd, $physdpath, &$infos)
if(!in_array($sdtype,$sdtypeOK))
return $retour;
if($sdtype == 'audio')
{
if($debug)
@@ -2321,8 +2405,6 @@ function make1AudioSubdef($infile, &$sd, $physdpath, &$infos)
function make1VideoSubdef($infile, &$sd, $physdpath, &$infos)
{
$debug = false;
$system = p4utils::getSystem();
@@ -2415,20 +2497,14 @@ function make1VideoSubdef($infile, &$sd, $physdpath, &$infos)
if($debug)
echo "\nLa sortie est ".$newWidth."x".$newHeight."....\n";
if($sdtype == 'video' && $ffmpeg)
{
$cwd = getcwd();
chdir(GV_RootPath.'tmp/');
if($debug)
echo "\nGENERATING " . $sdname . " ".$sdtype."....\n";
$fps = 25;
if(isset($sd->fps) && is_numeric((int)$sd->fps))
$fps = (int)$sd->fps;
@@ -2500,7 +2576,6 @@ function make1VideoSubdef($infile, &$sd, $physdpath, &$infos)
if($debug)
echo "\n\n\n\nEXECUTION COMMANDE :::: ".$cmd_pass1."\n\n\n\n";
if(is_file($dest))
unlink($dest);
@@ -2531,7 +2606,6 @@ function make1VideoSubdef($infile, &$sd, $physdpath, &$infos)
$audioEnc = ' -ar ' . $srcAR . ' -ab ' . $srcAB .'k -acodec libmp3lame ';
}
$fps = 15;
if(isset($sd->fps) && is_numeric((int)$sd->fps))
$fps = (int)$sd->fps;
@@ -2546,7 +2620,6 @@ function make1VideoSubdef($infile, &$sd, $physdpath, &$infos)
' -r '.$fps.//$srcFPS.
' -b 270k -me_range '.$srcFPS.' -i_qfactor 0.71 -g 500 ' . $dest ;
if($debug)
echo "\n\n\n\nEXECUTION COMMANDE :::: ".$cmd."\n\n\n\n";
@@ -2573,7 +2646,6 @@ function make1VideoSubdef($infile, &$sd, $physdpath, &$infos)
if($debug)
echo "\nGENERATING " . $sdname . " ".$sdtype."....\n";
$newname = $infos['recordid'] . '_' . $sdname . '.jpg';
$dest = $physdpath.$newname;
@@ -2633,8 +2705,6 @@ function make1VideoSubdef($infile, &$sd, $physdpath, &$infos)
p4::fullmkdir($tmpDir);
$tmpDir = p4string::addEndSlash($tmpDir);
if($system == 'WINDOWS')
$cmd = GV_ffmpeg.' -s '.$newWidth.'x'.$newHeight.' -i '.str_replace('/', "\\", $infile).' -r 1 -f image2 '.$tmpDir.'images%05d.jpg';
else
@@ -2660,7 +2730,6 @@ function make1VideoSubdef($infile, &$sd, $physdpath, &$infos)
$inter = round(count($files) / 10);
$i = 0;
foreach($files as $k=>$file)
{
@@ -2722,7 +2791,6 @@ function make_mp4_progressive($mp4_file)
echo "\nchecking mp4 box for mp4 progressive video ....\n";
if(defined('GV_mp4box') && is_executable(GV_mp4box))
{
if($debug)
echo "\nmp4 box OK, doing it\n";
@@ -2759,7 +2827,6 @@ function make_mp4_progressive($mp4_file)
}
}
if($debug)
echo "\nfichier en sortie : $mp4_file : ".filesize($mp4_file)." \n";

View File

@@ -1,2 +1,2 @@
<?php
define('GV_version','3.1.8');
define('GV_version','3.1.9');

View File

@@ -11,7 +11,8 @@ $parm = $request->get_parms("act",
"srt", // trier les colonnes de stats par collection (col) ou objet (obj)
"nvn", // New ViewName ( lors de l'UPD
"othcollsel",
"coll_id"
"coll_id",
"base_id"
);
$lng = isset($session->locale)?$session->locale:GV_default_lng;
@@ -92,6 +93,16 @@ switch($parm["act"])
catch(Exception $e)
{
}
break;
case 'ACTIVATE':
try
{
$base_id = collection::activate_collection($parm['p0'], $parm['base_id']);
}
catch(Exception $e)
{
}
break;
}
@@ -335,6 +346,11 @@ else
$('#mount_coll').toggle();
}
function activateColl()
{
$('#activate_coll').toggle();
}
function umountBase()
{
if(confirm("<?php echo _('admin::base: Confirmer vous l\'arret de la publication de la base')?>"))
@@ -761,6 +777,36 @@ if(isset($tcoll["bases"]["b".$parm["p0"]])) // ok si p0=base_id (local) ok
</div>
<?php
}
$activable_colls = $databox->get_activable_colls();
if(count($activable_colls) > 0)
{
?>
<div style='margin:20px 0 3px 10px;'>
<a href="#" onclick="activateColl();">
<img src='/skins/icons/create_coll.png' style='vertical-align:middle'/>
<?php echo(_('Activer une collection'));?>
</a>
</div>
<div id="activate_coll" style="display:none;">
<form method="post" action="database.php" target="_self">
<select name="base_id">
<?php
foreach($activable_colls as $base_id)
{
?>
<option value="<?php echo $base_id?>"><?php echo phrasea::bas_names($base_id)?></option>
<?php
}
?>
</select>
<input type="hidden" name="p0" value="<?php echo $parm['p0'];?>"/>
<input type="hidden" name="act" value="ACTIVATE"/>
<button type="submit"><?php echo _('Activer');?></button>
</form>
</div>
<?php
}
?>
<div style='margin:20px 0 3px 10px;'>
<a href="javascript:void(0);return(false);" onclick="clearAllLog();return(false);">