Work on ecm module using ajax

This commit is contained in:
Laurent Destailleur 2012-03-24 15:20:49 +01:00
parent 187dc0d762
commit 39ded746dc
13 changed files with 534 additions and 104 deletions

View File

@ -0,0 +1,417 @@
<?php
/* Copyright (C) 2004-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010 Pierre Morin <pierre.morin@auguria.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/filemanager/ajaxshowpreview.php
* \brief Service to return a HTML preview of a file
* Call of this service is made with URL:
* ajaxpreview.php?action=preview&modulepart=repfichierconcerne&file=pathrelatifdufichier
*/
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
// C'est un wrapper, donc header vierge
function llxHeader() { }
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
// Load traductions files
$langs->load("ecm");
$langs->load("companies");
$langs->load("other");
// Security check
if ($user->societe_id > 0) $socid = $user->societe_id;
// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$action=GETPOST("action");
$file=urldecode(GETPOST('file'));
$section=GETPOST("section");
$module=GETPOST("module");
$urlsource=GETPOST("urlsource");
if (! $section)
{
dol_print_error('',"ErrorSectionParamNotDefined");
exit;
}
// Suppression de la chaine de caractere ../ dans $original_file
$original_file = str_replace("../","/", $file);
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
// Security:
// On interdit les remontees de repertoire ainsi que les pipe dans
// les noms de fichiers.
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
{
dol_syslog("Refused to deliver file ".$original_file);
// Do no show plain path in shown error message
dol_print_error(0,$langs->trans("ErrorFileNameInvalid",$_GET["file"]));
exit;
}
// Load ecm object
/*$ecmdir = new EcmDirectory($db);
$result=$ecmdir->fetch(GETPOST("section"));
if (! $result > 0)
{
dol_print_error($db,$ecmdir->error);
exit;
}
$relativepath=$ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
*/
/*
* Action
*/
if ($action == 'remove_file') // Remove a file
{
clearstatcache();
dol_syslog(__FILE__." remove $original_file $urlsource", LOG_DEBUG);
// This test should be useless. We keep it to find bug more easily
if (! file_exists($original_file_osencoded))
{
dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$_GET["file"]));
exit;
}
dol_delete_file($original_file);
dol_syslog(__FILE__." back to ".urldecode($urlsource), LOG_DEBUG);
header("Location: ".urldecode($urlsource));
return;
}
/*
* View
*/
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
$filename = basename($original_file_osencoded);
$sizeoffile = filesize($original_file_osencoded);
if (dol_is_dir($original_file))
{
$type='directory';
}
else
{
// Define mime type
$type = 'application/octet-stream';
if (GETPOST("type") != 'auto') $type=$_GET["type"];
else $type=dol_mimetype($original_file,'text/plain');
//print 'X'.$type.'-'.$original_file;exit;
}
clearstatcache();
// Output file on browser
dol_syslog("document.php download $original_file $filename content-type=$type");
// This test if file exists should be useless. We keep it to find bug more easily
if (! file_exists($original_file_osencoded))
{
dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
exit;
}
print '<!-- TYPE='.$type.' -->'."\n";
print '<!-- SIZE='.$sizeoffile.' -->'."\n";
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
// Les drois sont ok et fichier trouve, et fichier texte, on l'envoie
print '<b><font class="liste_titre">'.$langs->trans("Information").'</font></b><br>';
print '<hr>';
// Dir
if ($type == 'directory')
{
print '<table class="nobordernopadding">';
print '<tr><td>'.$langs->trans("Directory").':</td><td>&nbsp; <b><span class="fmvalue">'.$original_file.'</span></b></td></tr>';
//print $langs->trans("FullPath").': '.$original_file_osencoded.'<br>';
//print $langs->trans("Mime-type").': '.$type.'<br>';
$info=stat($original_file_osencoded);
//print '<br>'."\n";
//print $langs->trans("Owner").": ".$info['udi']."<br>\n";
//print $langs->trans("Group").": ".$info['gdi']."<br>\n";
//print $langs->trans("Size").": ".dol_print_size($info['size'])."<br>\n";
print '<tr><td>'.$langs->trans("DateLastAccess").':</td><td>&nbsp; <span class="fmvalue">'.dol_print_date($info['atime'],'%Y-%m-%d %H:%M:%S')."</span></td></tr>\n";
print '<tr><td>'.$langs->trans("DateLastChange").':</td><td>&nbsp; <span class="fmvalue">'.dol_print_date($info['mtime'],'%Y-%m-%d %H:%M:%S')."</span></td></tr>\n";
//print $langs->trans("Ctime").": ".$info['ctime']."<br>\n";
print '</table>'."\n";
print '<br><br>';
print '<b>'.$langs->trans("Content")."</b><br>\n";
print '<hr><br>';
print '<div class="filedirelem"><ul class="filedirelem">'."\n";
// Return content of dir
$dircontent=dol_dir_list($original_file,'all',0,'','','name',SORT_ASC,0);
foreach($dircontent as $key => $val)
{
if (dol_is_dir($val['name'])) $mimeimg='other.png';
else $mimeimg=dol_mimetype($val['name'],'application/octet-stream',2);
print '<li class="filedirelem">';
print '<br><br>';
print '<img src="'.DOL_URL_ROOT.'/theme/common/mime/'.$mimeimg.'"><br>';
print dol_nl2br(dol_trunc($val['name'],24,'wrap'),1);
print '</li>'."\n";
}
print '</ul></div>'."\n";
}
else {
print '<table class="nobordernopadding" width="100%">';
print '<tr><td>'.$langs->trans("File").':</td><td>&nbsp; <b><span class="fmvalue">'.$original_file.'</span></b></td></tr>';
print '<tr><td>'.$langs->trans("Mime-type").':</td><td>&nbsp; <span class="fmvalue">'.$type.'</span></td>';
print '<td align="right"><a href="'.dol_buildpath('/filemanager/document.php',1).'?modulepart=filemanager&id='.$id.'&rootpath='.$rootpath.'&file='.urlencode($original_file).'">'.$langs->trans("Download").'</a></td>';
print '</tr>';
$info=stat($original_file_osencoded);
//print '<br>'."\n";
//print $langs->trans("Owner").": ".$info['udi']."<br>\n";
//print $langs->trans("Group").": ".$info['gdi']."<br>\n";
print '<tr><td>'.$langs->trans("Size").':</td><td>&nbsp; <span class="fmvalue">'.dol_print_size($info['size'])."</span></td></tr>\n";
print '<tr><td>'.$langs->trans("DateLastAccess").':</td><td>&nbsp; <span class="fmvalue">'.dol_print_date($info['atime'],'%Y-%m-%d %H:%M:%S')."</span></td></tr>\n";
print '<tr><td>'.$langs->trans("DateLastChange").':</td><td>&nbsp; <span class="fmvalue">'.dol_print_date($info['mtime'],'%Y-%m-%d %H:%M:%S')."</span></td></tr>\n";
//print $langs->trans("Ctime").": ".$info['ctime']."<br>\n";
$sizearray=array();
if (preg_match('/image/i',$type))
{
require_once(DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php');
$sizearray=dol_getImageSize($original_file_osencoded);
print '<tr><td>'.$langs->trans("Width").':</td><td>&nbsp; <span class="fmvalue">'.$sizearray['width'].'px</span></td></tr>';
print '<tr><td>'.$langs->trans("Height").':</td><td>&nbsp; <span class="fmvalue">'.$sizearray['height'].'px</span></td></tr>';
}
print '</table>'."\n";
// Flush content before preview generation
flush(); // This send all data to browser. Browser however may wait to have message complete or aborted before showing it.
// Preview
$preview=0;
if (preg_match('/text/i',$type))
{
$minmem=64; // Minimum of memory required to use Geshi (color syntax on text files)
$maxsize=65536; // Max size of data to read for text preview
// Define memmax (memory_limit in bytes)
$memmaxorig=@ini_get("memory_limit");
$memmax=@ini_get("memory_limit");
if ($memmaxorig != '')
{
preg_match('/([0-9]+)([a-zA-Z]*)/i',$memmax,$reg);
if ($reg[2])
{
if (strtoupper($reg[2]) == 'M') $memmax=$reg[1]*1024*1024;
if (strtoupper($reg[2]) == 'K') $memmax=$reg[1]*1024;
}
}
//print "memmax php=".$memmax;
$out='';
$srclang=dol_mimetype($original_file,'text/plain',3);
if (preg_match('/html/i',$type)) // If HTML file
{
print '<br><br>';
print '<b>'.$langs->trans("Preview")."</b><br>\n";
print '<hr>';
readfile($original_file_osencoded);
//$out=file_get_contents($original_file_osencoded);
//print $out;
}
else // If not a HTML file
{
$warn='';
// Check if we have enough memory for Geshi
if ($memmax < $minmem*1024*1024)
{
$warn=img_warning().' '.$langs->trans("NotEnoughMemoryForSyntaxColor");
$warn.=' (Have '.$memmax.' - Need '.$minmem.')';
$srclang=''; // We disable geshi
}
if (empty($conf->global->FILEMANAGER_DISABLE_COLORSYNTAXING))
{
$warn=' ('.$langs->trans("ColoringDisabled").')';
$srclang=''; // We disable geshi
}
// Try to detect srclang using first line
if ($type=='text/plain' && empty($srclang)) // Try to enhance MIME detection with first line content
{
$firstline=file_get_contents($original_file_osencoded,false,null,0,32);
$texts = preg_split("/((\r(?!\n))|((?<!\r)\n)|(\r\n))/", strtolower($firstline));
if (preg_match('/^#!.*\/bin\/(.*)$/',$texts[0],$reg))
{
$converttogeshicode=array('ksh'=>'bash', 'sh'=>'bash', 'bash'=>'bash');
$srclang=$converttogeshicode[$reg[1]]?$converttogeshicode[$reg[1]]:$reg[1];
//print "ee".$srclang;
}
}
if ($srclang=='php') $srclang='php-brief';
//if ($srclang=='perl') $srclang=''; // Perl seems to be bugged
if (! empty($srclang))
{
print '<br><br>';
print '<b>'.$langs->trans("Preview")."</b> (".$srclang.")<br>\n";
print '<hr>';
// Translate with Geshi
include_once('includes/geshi/geshi.php');
$out=file_get_contents($original_file_osencoded,false,null,0,$maxsize);
if (! utf8_check($out)) { $isoutf='iso'; $out=utf8_encode($out); }
$geshi = new GeSHi($out, $srclang);
$geshi->enable_strict_mode(true);
$res='';
$res=$geshi->parse_code();
//print "zzzzzzzz";
print $res;
}
else
{
print '<br><br>';
print '<b>'.$langs->trans("Preview")."</b>";
if ($warn) print ' '.$warn;
print "<br>\n";
print '<hr>';
$maxlines=25;
$i=0;$more=0;
$handle = @fopen($original_file_osencoded, "r");
if ($handle)
{
while (!feof($handle) && $i < $maxlines)
{
$buffer = fgets($handle, $maxsize);
if (utf8_check($buffer)) $out.=$buffer."<br>\n";
else $out.=utf8_encode($buffer)."<br>\n";
$i++;
}
if (!feof($handle)) $more=1;
fclose($handle);
}
else
{
print '<div class="error">'.$langs->trans("ErrorFailedToOpenFile",$original_file).'</div>';
}
print $out;
print '<br>';
if ($more)
{
print '<b>...'.$langs->trans("More").'...</b><br>'."\n";
}
}
}
$preview=1;
}
// Preview if image
if (preg_match('/image/i',$type))
{
print '<br><br>';
print '<b>'.$langs->trans("Preview")."</b><br>\n";
print '<hr><br>';
print '<center><img';
if (! empty($sizearray['width']) && $sizearray['width'] > 500) print ' width="500"';
print ' src="'.dol_buildpath('/filemanager/viewimage.php',1).'?modulepart=filemanager&file='.urlencode($original_file).'"></center>';
$preview=1;
}
// Preview if video
if (preg_match('/video/i',$type))
{
$typecodec='';
if (preg_match('/ogg/i',$type)) $typecodec=' type=\'video/ogg; codecs="theora, vorbis"\''; // This works with HTML5 video
//if (preg_match('/msvideo/i',$type)) $typecodec=' type=\'video/x-msvideo;\''; // AVI
//if (preg_match('/webm/i',$type)) $typecodec=' type=\'video/webm; codecs="vp8, vorbis"\'';
//if (preg_match('/mp4/i',$type)) $typecodec=' type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\'';
if ($typecodec)
{
print '<br><br>';
print '<b>'.$langs->trans("Preview")."</b><br>\n";
print '<hr><br>';
print '<center>';
print '<video id="movie" style="border: 1px solid #BBB;" width="320" height="240"';
print ' preload';
//print ' preload="none"';
print ' controls';
print '>';
print '<source src="'.dol_buildpath('/filemanager/viewimage.php',1).'?modulepart=filemanager&file='.urlencode($original_file).'&type='.urlencode($type).'"';
print $typecodec;
print ' />';
print '</video>';
print '</center>';
/*<video width="320" height="240"';
print ' src="'.dol_buildpath('/filemanager/viewimage.php',1).'?modulepart=filemanager&file='.urlencode($original_file).'"';
print '></center>';*/
$preview=1;
}
}
// No preview
if (empty($preview))
{
print '<br><br>';
print '<b>'.$langs->trans("Preview")."</b><br>\n";
print '<hr>';
print $langs->trans("PreviewNotAvailableForThisType");
}
}
if (is_object($db)) $db->close();
?>

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
*/
/**
* \file htdocs/core/ajax/ajaxFileTree.php
* \file htdocs/core/ajax/ajaxdirtree.php
* \ingroup ecm
* \brief This script returns content of a directory for filetree
* \version $Id: ajaxFileTree.php,v 1.8 2011/07/06 17:03:41 eldy Exp $
@ -36,7 +36,6 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
// C'est un wrapper, donc header vierge
function llxHeader() { }
$res=0;
$res=@include("../../main.inc.php");
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
include_once(DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php');
@ -76,6 +75,7 @@ if ($modulepart == 'ecm')
/*
* View
*/
$userstatic=new User($db);
$form=new Form($db);
$ecmdirstatic = new EcmDirectory($db);
@ -94,6 +94,8 @@ foreach($sqltree as $keycursor => $val)
}
}
//var_dump($sqltree);
if( file_exists($fullpathselecteddir) )
{
$files = @scandir($fullpathselecteddir);
@ -111,27 +113,28 @@ if( file_exists($fullpathselecteddir) )
$nboffilesinsubdir=0;
// Try to find key into $sqltree
$ecmdir_id=-1;
foreach($sqltree as $ecmdir_idcursor => $val)
$val=array();
foreach($sqltree as $key => $tmpval)
{
//print "-- ".$val['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file).'<br>';
if ($val['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file))
{
$ecmdir_id = $ecmdir_idcursor;
$resarray=tree_showpad($sqltree,$ecmdir_id,1);
if ($tmpval['fullrelativename'] == (($selecteddir != '/'?$selecteddir.'/':'').$file))
{
$val=$tmpval;
$resarray=tree_showpad($sqltree,$key,1);
$a=$resarray[0];
$nbofsubdir=$resarray[1];
$nboffilesinsubdir=$resarray[2];
}
break;
}
}
//if (file_exists($fullpathselecteddir . $file) && $file != '.' && $file != '..' && is_dir($fullpathselecteddir . $file))
if ($file != '.' && $file != '..' && ($ecmdir_id >= 0 || dol_is_dir($fullpathselecteddir . $file)))
if ($file != '.' && $file != '..' && ($val['id'] >= 0 || dol_is_dir($fullpathselecteddir . $file)))
{
print '<li class="directory collapsed">';
print "<a class=\"fmdirlia jqft\" href=\"#\" rel=\"" . dol_escape_htmltag($file . '/') . "\"";
print " onClick=\"loadandshowpreview('".dol_escape_js($file)."')\">";
print " onClick=\"loadandshowpreview('".dol_escape_js($val['fullrelativename'])."',".$val['id'].")\">";
print dol_escape_htmltag($file);
print "</a>";
@ -152,7 +155,7 @@ if( file_exists($fullpathselecteddir) )
print '</td>';
// Edit link
print '<td align="right" width="18"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'">'.img_view().'</a></td>';
print '<td align="right" width="18"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'&relativedir='.urlencode($val['fullrelativename']).'">'.img_view().'</a></td>';
// Add link
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create&amp;catParent='.$val['id'].'">'.img_edit_add().'</a></td>';

View File

@ -75,7 +75,7 @@ function is_in_subtree($fulltree,$parentid,$childid)
* Show indent and picto of a tree line. Return array with information of line.
*
* @param array &$fulltree Array of entries in correct order
* @param string $key Key of value to show picto
* @param string $key Key of entry into fulltree to show picto
* @param int $silent Do not output indent and picto, returns only value
* @return array array(0 or 1 if at least one of this level after, 0 or 1 if at least one of higher level after, nbofdirinsub, nbofdocinsub)
*/

View File

@ -111,7 +111,7 @@ class EcmDirectory // extends CommonObject
if ($pathfound)
{
$this->error="ErrorDirAlreadyExists";
dol_syslog("EcmDirectories::create ".$this->error, LOG_WARNING);
dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
return -1;
}
else
@ -137,7 +137,7 @@ class EcmDirectory // extends CommonObject
$sql.= " '".$this->fk_user_c."'";
$sql.= ")";
dol_syslog("EcmDirectories::create sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -167,7 +167,7 @@ class EcmDirectory // extends CommonObject
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("EcmDirectories::create ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
$this->db->rollback();
return -1;
}
@ -204,7 +204,7 @@ class EcmDirectory // extends CommonObject
$sql.= " description='".$this->db->escape($this->description)."'";
$sql.= " WHERE rowid=".$this->id;
dol_syslog("EcmDirectories::update sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
@ -251,12 +251,12 @@ class EcmDirectory // extends CommonObject
$sql.= " cachenbofdoc = cachenbofdoc ".$sign." 1";
$sql.= " WHERE rowid = ".$this->id;
dol_syslog("EcmDirectories::changeNbOfFiles sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::changeNbOfFiles sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("EcmDirectories::changeNbOfFiles ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::changeNbOfFiles ".$this->error, LOG_ERR);
return -1;
}
@ -285,7 +285,7 @@ class EcmDirectory // extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."ecm_directories as t";
$sql.= " WHERE t.rowid = ".$id;
dol_syslog("EcmDirectories::fetch sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -312,7 +312,7 @@ class EcmDirectory // extends CommonObject
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("EcmDirectories::fetch ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1;
}
}
@ -333,20 +333,20 @@ class EcmDirectory // extends CommonObject
$relativepath=$this->getRelativePath(1); // Ex: dir1/dir2/dir3
dol_syslog("EcmDirectories::delete remove directory ".$relativepath);
dol_syslog(get_class($this)."::delete remove directory ".$relativepath);
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_directories";
$sql.= " WHERE rowid=".$this->id;
dol_syslog("EcmDirectories::delete sql=".$sql);
dol_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->db->rollback();
$this->error="Error ".$this->db->lasterror();
dol_syslog("EcmDirectories::delete ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
return -2;
}
@ -360,7 +360,7 @@ class EcmDirectory // extends CommonObject
else
{
$this->error='ErrorFailToDeleteDir';
dol_syslog("EcmDirectories::delete ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
$this->db->rollback();
$error++;
}
@ -487,7 +487,7 @@ class EcmDirectory // extends CommonObject
$sql.= " WHERE fk_parent != 0";
$sql.= " AND entity = ".$conf->entity;
dol_syslog("EcmDirectory::get_full_arbo sql=".$sql);
dol_syslog(get_class($this)."::get_full_arbo sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
@ -551,7 +551,7 @@ class EcmDirectory // extends CommonObject
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " ORDER BY c.label, c.rowid";
dol_syslog("EcmDirectory::get_full_arbo sql=".$sql);
dol_syslog(get_class($this)."::get_full_arbo sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
@ -677,7 +677,7 @@ class EcmDirectory // extends CommonObject
$sql.= " WHERE entity = ".$conf->entity;
}
dol_syslog("EcmDirectories::refreshcachenboffile sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::refreshcachenboffile sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
@ -687,7 +687,7 @@ class EcmDirectory // extends CommonObject
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog("EcmDirectories::refreshcachenboffile ".$this->error, LOG_ERR);
dol_syslog(get_class($this)."::refreshcachenboffile ".$this->error, LOG_ERR);
return -1;
}
}

View File

@ -39,13 +39,17 @@ $langs->load("bills");
$langs->load("contracts");
$langs->load("categories");
// Load permissions
$user->getrights('ecm');
if (!$user->rights->ecm->setup) accessforbidden();
// Get parameters
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
$socid = GETPOST("socid","int");
// Security check
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$section=$_GET["section"];
if (! $section) $section='misc';

View File

@ -39,14 +39,17 @@ $langs->load("bills");
$langs->load("contracts");
$langs->load("categories");
// Load permissions
$user->getrights('ecm');
if (!$user->rights->ecm->setup) accessforbidden();
// Get parameters
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
$socid = GETPOST("socid","int");
// Security check
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');

View File

@ -29,19 +29,11 @@ require_once(DOL_DOCUMENT_ROOT."/ecm/class/ecmdirectory.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/ecm.lib.php");
// Load traductions files
$langs->load("ecm");
$langs->load("companies");
$langs->load("other");
// Load permissions
$user->getrights('ecm');
// Security check
if ($user->societe_id > 0) $socid = $user->societe_id;
// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');

View File

@ -18,13 +18,10 @@ $langs->load("ecm");
$langs->load("companies");
$langs->load("other");
// Load permissions
$user->getrights('ecm');
// Get parameters
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
$socid = GETPOST("socid","int");
// Permissions
// Security check
if ($user->societe_id > 0)
{
$action = '';

View File

@ -46,9 +46,6 @@ $langs->load("contracts");
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'ecm', 0);
// Load permissions
$user->getrights('ecm');
// Get parameters
$socid=GETPOST('socid','int');
$action=GETPOST("action");
@ -84,11 +81,9 @@ $ecmdirstatic = new EcmDirectory($db);
$userstatic = new User($db);
/*******************************************************************
* ACTIONS
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
/*
* Actions
*/
// Upload file
if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC))
@ -290,9 +285,9 @@ if ($action == 'refreshmanual')
/*******************************************************************
* View
********************************************************************/
/*
* View
*/
$userstatic = new User($db);
$ecmdirstatic = new EcmDirectory($db);
@ -389,7 +384,7 @@ if ($conf->use_javascript_ajax)
else
{
print '<table class="border" width="100%">';
print '<tr><td colspan="2" style="background: #FFFFFF" style="height: 24px !important">';
print '<tr><td colspan="2" style="background: #FFFFFF" style="height: 34px !important">';
}
// Start top panel, toolbar
@ -397,19 +392,19 @@ else
// Toolbar
if ($user->rights->ecm->setup)
{
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '<a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create" class="toolbarbutton" title="'.dol_escape_htmltag($langs->trans('ECMAddSection')).'">';
print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
else
{
print '<a href="#" title="'.$langs->trans("NotAllowed").'">';
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '<a href="#" class="toolbarbutton" title="'.$langs->trans("NotAllowed").'">';
print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/folder-new.png">';
print '</a>';
}
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'').'" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
print '<img width="32" height="32" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&amp;module='.$module:'').($section?'&amp;section='.$section:'').'" class="toolbarbutton" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
//print '<img class="toolbarbutton" border="0" src="'.DOL_URL_ROOT.'/theme/common/view-refresh.png">';
print '</a>';
@ -595,12 +590,12 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
<script type="text/javascript">
function loadandshowpreview(filedirname)
function loadandshowpreview(filedirname,section)
{
//alert('filename='+filename);
//jQuery('#fileview').empty();
jQuery('#ecmfileview').empty();
url='<?php echo dol_buildpath('/core/ajax/ajaxshowpreview.php',1); ?>?action=preview&rootpath=<?php echo $filemanagerroots->id ?>&modulepart=filemanager&type=auto&file='+urlencode(filedirname);
url='<?php echo dol_buildpath('/core/ajax/ajaxdirpreview.php',1); ?>?action=preview&module=ecm&section='+section+'&file='+urlencode(filedirname);
jQuery.get(url, function(data) {
//alert('Load of url '+url+' was performed : '+data);
@ -622,7 +617,7 @@ if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$acti
jQuery(document).ready( function() {
jQuery('#filetree').fileTree({ root: '<?php print dol_escape_js($openeddir); ?>',
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxfiletree.php?modulepart=ecm&openeddir='.urlencode($openeddir); ?>',
script: '<?php echo DOL_URL_ROOT.'/core/ajax/ajaxdirtree.php?modulepart=ecm&openeddir='.urlencode($openeddir); ?>',
folderEvent: 'click',
multiFolder: false },
function(file) {

View File

@ -687,15 +687,18 @@ td.photo {
border: 1px solid #BBB !important;
}
.toolbarbutton {
margin-top: 2px;
a.toolbarbutton {
margin-top: 1px;
margin-left: 4px;
margin-right: 4px;
height: 30px;
/* border: solid 1px #AAAAAA;
width: 34px;*/
height: 34px;
/* background: #FFFFFF;*/
width: 32px;
background: #FFFFFF;*/
}
img.toolbarbutton {
height: 28px;
}
/* ============================================================================== */
/* Panes for ECM or Filemanager */

View File

@ -794,13 +794,17 @@ td.photo {
border: 1px solid #BBB !important;
}
.toolbarbutton {
margin-top: 2px;
a.toolbarbutton {
margin-top: 1px;
margin-left: 4px;
margin-right: 4px;
height: 30px;
/* border: solid 1px #AAAAAA;
width: 34px;*/
height: 34px;
/* background: #FFFFFF;*/
width: 32px;
background: #FFFFFF;*/
}
img.toolbarbutton {
height: 28px;
}

View File

@ -813,13 +813,17 @@ td.photo {
border: 1px solid #BBB !important;
}
.toolbarbutton {
margin-top: 2px;
a.toolbarbutton {
margin-top: 1px;
margin-left: 4px;
margin-right: 4px;
height: 30px;
/* border: solid 1px #AAAAAA;
width: 34px;*/
height: 34px;
/* background: #FFFFFF;*/
width: 32px;
background: #FFFFFF;*/
}
img.toolbarbutton {
height: 28px;
}

View File

@ -847,26 +847,36 @@ td.photo {
/* ============================================================================== */
.toolbar {
background-image: linear-gradient(bottom, rgb(<?php echo '240,240,240'; ?>) 15%, rgb(<?php echo '255,255,255'; ?>) 100%) !important;
background-image: -o-linear-gradient(bottom, rgb(<?php echo '240,240,240'; ?>) 15%, rgb(<?php echo '255,255,255'; ?>) 100%) !important;
background-image: -moz-linear-gradient(bottom, rgb(<?php echo '240,240,240'; ?>) 15%, rgb(<?php echo '255,255,255'; ?>) 100%) !important;
background-image: -webkit-linear-gradient(bottom, rgb(<?php echo '240,240,240'; ?>) 15%, rgb(<?php echo '255,255,255'; ?>) 100%) !important;
background-image: -ms-linear-gradient(bottom, rgb(<?php echo '240,240,240'; ?>) 15%, rgb(<?php echo '255,255,255'; ?>) 100%) !important;
/* DYN */
background-image: linear-gradient(bottom, rgb(<?php echo $colorback1; ?>) 15%, rgb(<?php echo $colorback2; ?>) 100%) !important;
background-image: -o-linear-gradient(bottom, rgb(<?php echo $colorback1; ?>) 15%, rgb(<?php echo $colorback2; ?>) 100%) !important;
background-image: -moz-linear-gradient(bottom, rgb(<?php echo $colorback1; ?>) 15%, rgb(<?php echo $colorback2; ?>) 100%) !important;
background-image: -webkit-linear-gradient(bottom, rgb(<?php echo $colorback1; ?>) 15%, rgb(<?php echo $colorback2; ?>) 100%) !important;
background-image: -ms-linear-gradient(bottom, rgb(<?php echo $colorback1; ?>) 15%, rgb(<?php echo $colorback2; ?>) 100%) !important;
border: 1px solid #CCC !important;
border: 1px solid #BBB !important;
-moz-border-radius: 5px 5px 5px 5px !important;
-webkit-border-radius: 5px 5px 5px 5px !important;
border-radius: 5px 5px 5px 5px !important;
-moz-box-shadow: 4px 4px 4px #EEE;
-webkit-box-shadow: 4px 4px 4px #EEE;
box-shadow: 4px 4px 4px #EEE;
padding: 0 4px 0 4px !important;
}
.toolbarbutton {
margin-top: 2px;
a.toolbarbutton {
margin-top: 1px;
margin-left: 4px;
margin-right: 4px;
height: 30px;
/* border: solid 1px #AAAAAA;
width: 34px;*/
height: 34px;
/* background: #FFFFFF;*/
width: 32px;
background: #FFFFFF;*/
}
img.toolbarbutton {
height: 28px;
}
/* ============================================================================== */
/* Panes for ECM or Filemanager */
@ -1039,12 +1049,10 @@ background-image: -ms-linear-gradient(bottom, rgb(<?php echo $colorback1; ?>) 15
}
.ecm-layout-resizer { /* all 'resizer-bars' */
background: #EEEEEE;
border: 1px solid #BBB;
border-width: 0;
}
.ecm-layout-resizer-closed {
background-color: #EEEEEE;
}
.ecm-in-layout-center {