New: Accept a maxlength parameter

This commit is contained in:
Laurent Destailleur 2011-06-08 17:37:21 +00:00
parent 3cf65ac780
commit ed06854c0a
3 changed files with 17 additions and 14 deletions

View File

@ -354,14 +354,14 @@ class FormFile
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print_titre($langs->trans("Documents")); print_titre($langs->trans("Documents"));
print '<table class="border" summary="listofdocumentstable" width="100%">'; print '<table class="border formdoc" summary="listofdocumentstable" width="100%">';
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
// Model // Model
if (! empty($modellist)) if (! empty($modellist))
{ {
print '<td align="center">'; print '<td align="center" class="formdoc">';
print $langs->trans('Model').' '; print $langs->trans('Model').' ';
print $html->selectarray('model',$modellist,$modelselected,$showempty,0,0); print $html->selectarray('model',$modellist,$modelselected,$showempty,0,0);
if (sizeof($cgvlist) > 0) if (sizeof($cgvlist) > 0)
@ -372,13 +372,13 @@ class FormFile
} }
else else
{ {
print '<td align="left">'; print '<td align="left" class="formdoc">';
print $langs->trans("Files"); print $langs->trans("Files");
print '</td>'; print '</td>';
} }
// Language code (if multilang) // Language code (if multilang)
print '<td align="center">'; print '<td align="center" class="formdoc">';
if (($allowgenifempty || (is_array($modellist) && sizeof($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && ! $forcenomultilang) if (($allowgenifempty || (is_array($modellist) && sizeof($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && ! $forcenomultilang)
{ {
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php');
@ -393,7 +393,7 @@ class FormFile
print '</td>'; print '</td>';
// Button // Button
print '<td align="center" colspan="'.($delallowed?'2':'1').'">'; print '<td align="center" colspan="'.($delallowed?'2':'1').'" class="formdocbutton">';
print '<input class="button" '; print '<input class="button" ';
//print ((is_array($modellist) && sizeof($modellist))?'':' disabled="true"') // Always allow button "Generate" (even if no model activated) //print ((is_array($modellist) && sizeof($modellist))?'':' disabled="true"') // Always allow button "Generate" (even if no model activated)
print ' type="submit" value="'.$buttonlabel.'"'; print ' type="submit" value="'.$buttonlabel.'"';

View File

@ -38,10 +38,11 @@ class ModeleThirdPartyDoc extends CommonDocGenerator
var $error=''; var $error='';
/** /**
* \brief Return list of active generation modules * Return list of active generation modules
* \param $db Database handler * @param $db Database handler
* @param $maxfilenamelength Max length of value to show
*/ */
function liste_modeles($db) function liste_modeles($db,$maxfilenamelength=0)
{ {
global $conf; global $conf;
@ -49,7 +50,7 @@ class ModeleThirdPartyDoc extends CommonDocGenerator
$liste=array(); $liste=array();
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php'); include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
$liste=getListOfModels($db,$type); $liste=getListOfModels($db,$type,$maxfilenamelength);
return $liste; return $liste;
} }

View File

@ -1003,9 +1003,10 @@ function version_webserver()
* Return list of activated modules usable for document generation. * Return list of activated modules usable for document generation.
* @param $db Database handler * @param $db Database handler
* @param $type Type of models (company, invoice, ...) * @param $type Type of models (company, invoice, ...)
* @param $maxfilenamelength Max length of value to show
* @return int or array 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename". * @return int or array 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename".
*/ */
function getListOfModels($db,$type) function getListOfModels($db,$type,$maxfilenamelength=0)
{ {
global $conf,$langs; global $conf,$langs;
$liste=array(); $liste=array();
@ -1057,7 +1058,8 @@ function getListOfModels($db,$type)
{ {
foreach($listoffiles as $record) foreach($listoffiles as $record)
{ {
$liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'],24,'middle'); $max=($maxfilenamelength?$maxfilenamelength:28);
$liste[$obj->id.':'.$record['fullname']]=dol_trunc($record['name'],$max,'middle');
} }
} }
else else