Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-08-04 15:46:04 +02:00
commit 45621af4c7
2 changed files with 42 additions and 62 deletions

View File

@ -1617,45 +1617,6 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo
else return 'BadParam3CallingDolTrunc'; else return 'BadParam3CallingDolTrunc';
} }
/**
* Show a picto called object_picto (generic function)
*
* @param string $alt Text of alt on image
* @param string $picto Name of image to show object_picto (example: user, group, action, bill, contract, propal, product, ...)
* For external modules use imagename@mymodule to search into directory "img" of module.
* @param string $options Add more attribute on img tag (ie: class="datecallink")
* @param int $pictoisfullpath If 1, image path is a full path
* @return string Return img tag
* @see #img_picto, #img_picto_common
*/
function img_object($alt, $picto, $options='', $pictoisfullpath=0)
{
global $conf;
// Clean parameters
if (! preg_match('/(\.png|\.gif)$/i',$picto) && ! preg_match('/^([^@]+)@([^@]+)$/i',$picto)) $picto.='.png';
// Define fullpathpicto to use into src
if (! empty($pictoisfullpath)) $fullpathpicto=$picto;
else
{
// By default, we search into theme directory
$url = DOL_URL_ROOT;
$path = 'theme/'.$conf->theme;
if (! empty($conf->global->MAIN_FORCETHEMEDIR)) $path=preg_replace('/^\//','',$conf->global->MAIN_FORCETHEMEDIR).'/'.$path;
// If we ask an image into module/img (not into a theme path)
if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) { $picto = $regs[1]; $path=$regs[2]; } // If image into a module/img path
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto.='.png';
// If img file not into standard path, we use alternate path
if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.'/'.$path.'/img/object_'.$picto)) $url = DOL_URL_ROOT_ALT;
$fullpathpicto=$url.'/'.$path.'/img/object_'.$picto;
}
return '<img src="'.$fullpathpicto.'" border="0" alt="'.dol_escape_htmltag($alt).'" title="'.dol_escape_htmltag($alt).'"'.($options?' '.$options:'').'>';
}
/** /**
* Show picto whatever it's its name (generic function) * Show picto whatever it's its name (generic function)
* *
@ -1670,31 +1631,57 @@ function img_object($alt, $picto, $options='', $pictoisfullpath=0)
* @return string Return img tag * @return string Return img tag
* @see #img_object, #img_picto_common * @see #img_object, #img_picto_common
*/ */
function img_picto($alt, $picto, $options='', $pictoisfullpath=0) function img_picto($alt, $picto, $options = '', $pictoisfullpath = false)
{ {
global $conf; global $conf;
// Clean parameters
if (! preg_match('/(\.png|\.gif)$/i',$picto) && ! preg_match('/^([^@]+)@([^@]+)$/i',$picto)) $picto.='.png';
// Define fullpathpicto to use into src // Define fullpathpicto to use into src
if (! empty($pictoisfullpath)) $fullpathpicto=$picto; if ($pictoisfullpath) {
// Clean parameters
if (! preg_match('/(\.png|\.gif)$/i',$picto))
$picto .= '.png';
$fullpathpicto = $picto;
}
else else
{ {
// By default, we search into theme directory // By default, we search into theme directory
$url = DOL_URL_ROOT; $url = DOL_URL_ROOT;
$path = 'theme/'.$conf->theme; $path = 'theme/'.$conf->theme;
if (! empty($conf->global->MAIN_FORCETHEMEDIR)) $path=preg_replace('/^\//','',$conf->global->MAIN_FORCETHEMEDIR).'/'.$path; if (! empty($conf->global->MAIN_FORCETHEMEDIR))
$path = preg_replace('/^\//', '', $conf->global->MAIN_FORCETHEMEDIR).'/'.$path;
// If we ask an image into module/img (not into a theme path) // If we ask an image into module/img (not into a theme path)
if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) { $picto = $regs[1]; $path=$regs[2]; } // If image into a module/img path if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs))
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto.='.png'; {
$picto = $regs[1];
$path = $regs[2];
}
// Clean parameters
if (! preg_match('/(\.png|\.gif)$/i',$picto))
$picto .= '.png';
// If img file not into standard path, we use alternate path // If img file not into standard path, we use alternate path
if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.'/'.$path.'/img/'.$picto)) $url = DOL_URL_ROOT_ALT; if (defined('DOL_URL_ROOT_ALT') && DOL_URL_ROOT_ALT && ! file_exists(DOL_DOCUMENT_ROOT.'/'.$path.'/img/'.$picto))
$url = DOL_URL_ROOT_ALT;
$fullpathpicto=$url.'/'.$path.'/img/'.$picto; $fullpathpicto = $url.'/'.$path.'/img/'.$picto;
} }
return '<img src="'.$fullpathpicto.'" border="0" alt="'.dol_escape_htmltag($alt).'" title="'.dol_escape_htmltag($alt).'"'.($options?' '.$options:'').'>'; return '<img src="'.$fullpathpicto.'" border="0" alt="'.dol_escape_htmltag($alt).'" title="'.dol_escape_htmltag($alt).'"'.(! empty($options)?' '.$options:'').'>';
}
/**
* Show a picto called object_picto (generic function)
*
* @param string $alt Text of alt on image
* @param string $picto Name of image to show object_picto (example: user, group, action, bill, contract, propal, product, ...)
* For external modules use imagename@mymodule to search into directory "img" of module.
* @param string $options Add more attribute on img tag (ie: class="datecallink")
* @param int $pictoisfullpath If 1, image path is a full path
* @return string Return img tag
* @see #img_picto, #img_picto_common
*/
function img_object($alt, $picto, $options = '', $pictoisfullpath = false)
{
return img_picto($alt, 'object_'.$picto, $options, $pictoisfullpath);
} }
/** /**
@ -1722,7 +1709,7 @@ function img_picto_common($alt, $picto, $options = '', $pictoisfullpath = 0)
{ {
$themepath = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto; $themepath = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/'.$picto;
if (file_exists($themepath)) return img_picto($alt, $themepath, $options, 1); if (file_exists($themepath)) $path = $themepath;
} }
} }

View File

@ -42,13 +42,6 @@ $(function () {
// Initialize the jQuery File Upload widget: // Initialize the jQuery File Upload widget:
$('#fileupload').fileupload(); $('#fileupload').fileupload();
// Options
$('#fileupload').fileupload('option', {
// Enable iframe cross-domain access via redirect option
redirect: window.location.href.replace(/\/[^\/]*$/,'<?php echo DOL_URL_ROOT; ?>/includes/jquery/plugins/fileupload/cors/result.html?%s'),
maxFileSize: '<?php echo $max_file_size; ?>'
});
// Events // Events
$('#fileupload').fileupload({ $('#fileupload').fileupload({
completed: function (e, data) { completed: function (e, data) {