dolibarr  18.0.0-alpha
Public Member Functions | List of all members
FormFile Class Reference

Class to offer components to list and upload files. More...

Public Member Functions

 __construct ($db)
 Constructor. More...
 
 form_attach_new_file ($url, $title='', $addcancel=0, $sectionid=0, $perm=1, $size=50, $object='', $options='', $useajax=1, $savingdocmask='', $linkfiles=1, $htmlname='formuserfile', $accept='', $sectiondir='', $usewithoutform=0, $capture=0, $disablemulti=0, $nooutput=0)
 Show form to upload a new file. More...
 
 show_documents ($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed=0, $modelselected='', $allowgenifempty=1, $forcenomultilang=0, $iconPDF=0, $notused=0, $noform=0, $param='', $title='', $buttonlabel='', $codelang='')
 Show the box with list of available documents for object. More...
 
 showdocuments ($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed=0, $modelselected='', $allowgenifempty=1, $forcenomultilang=0, $iconPDF=0, $notused=0, $noform=0, $param='', $title='', $buttonlabel='', $codelang='', $morepicto='', $object=null, $hideifempty=0, $removeaction='remove_file', $tooltipontemplatecombo='')
 Return a string to show the box with list of available documents for object. More...
 
 getDocumentsLink ($modulepart, $modulesubdir, $filedir, $filter='', $morecss='valignmiddle', $allfiles=0)
 Show a Document icon with link(s) You may want to call this into a div like this: print '. More...
 
 list_of_documents ($filearray, $object, $modulepart, $param='', $forcedownload=0, $relativepath='', $permonobject=1, $useinecm=0, $textifempty='', $maxlength=0, $title='', $url='', $showrelpart=0, $permtoeditline=-1, $upload_dir='', $sortfield='', $sortorder='ASC', $disablemove=1, $addfilterfields=0, $disablecrop=-1, $moreattrondiv='')
 Show list of documents in $filearray (may be they are all in same directory but may not) This also sync database if $upload_dir is defined. More...
 
 list_of_autoecmfiles ($upload_dir, $filearray, $modulepart, $param, $forcedownload=0, $relativepath='', $permissiontodelete=1, $useinecm=0, $textifempty='', $maxlength=0, $url='', $addfilterfields=0)
 Show list of documents in a directory of ECM module. More...
 
 listOfLinks ($object, $permissiontodelete=1, $action=null, $selected=null, $param='')
 Show array with linked files. More...
 
 showPreview ($file, $modulepart, $relativepath, $ruleforpicto=0, $param='')
 Show detail icon with link for preview. More...
 

Detailed Description

Class to offer components to list and upload files.

Definition at line 36 of file html.formfile.class.php.

Constructor & Destructor Documentation

◆ __construct()

FormFile::__construct (   $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

Definition at line 54 of file html.formfile.class.php.

References db.

Member Function Documentation

◆ form_attach_new_file()

FormFile::form_attach_new_file (   $url,
  $title = '',
  $addcancel = 0,
  $sectionid = 0,
  $perm = 1,
  $size = 50,
  $object = '',
  $options = '',
  $useajax = 1,
  $savingdocmask = '',
  $linkfiles = 1,
  $htmlname = 'formuserfile',
  $accept = '',
  $sectiondir = '',
  $usewithoutform = 0,
  $capture = 0,
  $disablemulti = 0,
  $nooutput = 0 
)

Show form to upload a new file.

Parameters
string$urlUrl
string$titleTitle zone (Title or '' or 'none')
int$addcancel1=Add 'Cancel' button
int$sectionidIf upload must be done inside a particular ECM section (is sectionid defined, sectiondir must not be)
int$permValue of permission to allow upload
int$sizeLength of input file area. Deprecated.
Object$objectObject to use (when attachment is done on an element)
string$optionsAdd an option column
integer$useajaxUse fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). Deprecated 2 should never be used and if 1 is used, option should not be enabled.
string$savingdocmaskMask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
integer$linkfiles1=Also add form to link files, 0=Do not show form to link files
string$htmlnameName and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
string$acceptSpecifies the types of files accepted (This is not a security check but an user interface facility. eg '.pdf,image/*' or '.png,.jpg' or 'video/*')
string$sectiondirIf upload must be done inside a particular directory (if sectiondir defined, sectionid must not be)
int$usewithoutform0=Default, 1=Disable <form> and <input hidden> to use in existing form area, 2=Disable the tag <form> only
int$capture1=Add tag capture="capture" to force use of micro or video recording to generate file. When setting this to 1, you must also provide a value for $accept.
int$disablemulti0=Default, 1=Disable multiple file upload
int$nooutput0=Output result with print, 1=Return result
Returns
int|string <0 if KO, >0 if OK, or string if $noouput=1

Definition at line 86 of file html.formfile.class.php.

◆ getDocumentsLink()

FormFile::getDocumentsLink (   $modulepart,
  $modulesubdir,
  $filedir,
  $filter = '',
  $morecss = 'valignmiddle',
  $allfiles = 0 
)

Show a Document icon with link(s) You may want to call this into a div like this: print '.

'.$formfile->getDocumentsLink($element_doc, $filename, $filedir).'

';

Parameters
string$modulepart'propal', 'facture', 'facture_fourn', ...
string$modulesubdirSub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
string$filedirFull path to directory to scan
string$filterFilter filenames on this regex string (Example: '.pdf$')
string$morecssAdd more css to the download picto
string$allfiles0=Only generated docs, 1=All files
Returns
string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles

Definition at line 996 of file html.formfile.class.php.

◆ list_of_autoecmfiles()

FormFile::list_of_autoecmfiles (   $upload_dir,
  $filearray,
  $modulepart,
  $param,
  $forcedownload = 0,
  $relativepath = '',
  $permissiontodelete = 1,
  $useinecm = 0,
  $textifempty = '',
  $maxlength = 0,
  $url = '',
  $addfilterfields = 0 
)

Show list of documents in a directory of ECM module.

Parameters
string$upload_dirDirectory that was scanned. This directory will contains files into subdirs REF/files
array$filearrayArray of files loaded by dol_dir_list function before calling this function
string$modulepartValue for modulepart used by download wrapper. Value can be $object->table_name (that is 'myobject' or 'mymodule_myobject') or $object->element.'-'.$module (for compatibility purpose)
string$paramParameters on sort links
int$forcedownloadForce to open dialog box "Save As" when clicking on file
string$relativepathRelative path of docs (autodefined if not provided)
int$permissiontodeletePermission to delete
int$useinecmChange output for use in ecm module
int$textifemptyText to show if filearray is empty
int$maxlengthMaximum length of file name shown
string$urlFull url to use for click links ('' = autodetect)
int$addfilterfieldsAdd line with filters
Returns
int <0 if KO, nb of files shown if OK
See also
list_of_documents()

Definition at line 1572 of file html.formfile.class.php.

◆ list_of_documents()

FormFile::list_of_documents (   $filearray,
  $object,
  $modulepart,
  $param = '',
  $forcedownload = 0,
  $relativepath = '',
  $permonobject = 1,
  $useinecm = 0,
  $textifempty = '',
  $maxlength = 0,
  $title = '',
  $url = '',
  $showrelpart = 0,
  $permtoeditline = -1,
  $upload_dir = '',
  $sortfield = '',
  $sortorder = 'ASC',
  $disablemove = 1,
  $addfilterfields = 0,
  $disablecrop = -1,
  $moreattrondiv = '' 
)

Show list of documents in $filearray (may be they are all in same directory but may not) This also sync database if $upload_dir is defined.

Parameters
array$filearrayArray of files loaded by dol_dir_list('files') function before calling this.
Object$objectObject on which document is linked to.
string$modulepartValue for modulepart used by download or viewimage wrapper.
string$paramParameters on sort links (param must start with &, example &aaa=bbb&ccc=ddd)
int$forcedownloadForce to open dialog box "Save As" when clicking on file.
string$relativepathRelative path of docs (autodefined if not provided), relative to module dir, not to MAIN_DATA_ROOT.
int$permonobjectPermission on object (so permission to delete or crop document)
int$useinecmChange output for use in ecm module: 0 or 6: Add a preview column. Show also a rename button. Show also a crop button for some values of $modulepart (must be supported into hard coded list in this function + photos_resize.php + restrictedArea + checkUserAccessToObject) 1: Add link to edit ECM entry 2: Add rename and crop link 4: Add a preview column 5: Add link to edit ECM entry and Add a preview column
string$textifemptyText to show if filearray is empty ('NoFileFound' if not defined)
int$maxlengthMaximum length of file name shown.
string$titleTitle before list. Use 'none' to disable title.
string$urlFull url to use for click links ('' = autodetect)
int$showrelpart0=Show only filename (default), 1=Show first level 1 dir
int$permtoeditlinePermission to edit document line (You must provide a value, -1 is deprecated and must not be used any more)
string$upload_dirFull path directory so we can know dir relative to MAIN_DATA_ROOT. Fill this to complete file data with database indexes.
string$sortfieldSort field ('name', 'size', 'position', ...)
string$sortorderSort order ('ASC' or 'DESC')
int$disablemove1=Disable move button, 0=Position move is possible.
int$addfilterfieldsAdd the line with filters
int$disablecropDisable crop feature on images (-1 = auto, prefer to set it explicitely to 0 or 1)
string$moreattrondivMore attributes on the div for responsive. Example 'style="height:280px; overflow: auto;"'
Returns
int <0 if KO, nb of files shown if OK
See also
list_of_autoecmfiles()

Definition at line 1135 of file html.formfile.class.php.

◆ listOfLinks()

FormFile::listOfLinks (   $object,
  $permissiontodelete = 1,
  $action = null,
  $selected = null,
  $param = '' 
)

Show array with linked files.

Parameters
Object$objectObject
int$permissiontodeleteDeletion is allowed
string$actionAction
string$selected???
string$paramMore param to add into URL
Returns
int Number of links

Definition at line 1953 of file html.formfile.class.php.

◆ show_documents()

FormFile::show_documents (   $modulepart,
  $modulesubdir,
  $filedir,
  $urlsource,
  $genallowed,
  $delallowed = 0,
  $modelselected = '',
  $allowgenifempty = 1,
  $forcenomultilang = 0,
  $iconPDF = 0,
  $notused = 0,
  $noform = 0,
  $param = '',
  $title = '',
  $buttonlabel = '',
  $codelang = '' 
)

Show the box with list of available documents for object.

Parameters
string$modulepartpropal, facture, facture_fourn, ...
string$modulesubdirSub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into subdir of module.
string$filedirDirectory to scan
string$urlsourceUrl of origin page (for return)
int$genallowedGeneration is allowed (1/0 or array of formats)
int$delallowedRemove is allowed (1/0)
string$modelselectedModel to preselect by default
integer$allowgenifemptyShow warning if no model activated
integer$forcenomultilangDo not show language option (even if MAIN_MULTILANGS defined)
int$iconPDFShow only PDF icon with link (1/0)
int$notusedNot used
integer$noformDo not output html form tags
string$paramMore param on http links
string$titleTitle to show on top of form
string$buttonlabelLabel on submit button
string$codelangDefault language code to use on lang combo box if multilang is enabled
Returns
int <0 if KO, number of shown files if OK
Deprecated:
Use print xxx->showdocuments() instead.

Definition at line 302 of file html.formfile.class.php.

◆ showdocuments()

FormFile::showdocuments (   $modulepart,
  $modulesubdir,
  $filedir,
  $urlsource,
  $genallowed,
  $delallowed = 0,
  $modelselected = '',
  $allowgenifempty = 1,
  $forcenomultilang = 0,
  $iconPDF = 0,
  $notused = 0,
  $noform = 0,
  $param = '',
  $title = '',
  $buttonlabel = '',
  $codelang = '',
  $morepicto = '',
  $object = null,
  $hideifempty = 0,
  $removeaction = 'remove_file',
  $tooltipontemplatecombo = '' 
)

Return a string to show the box with list of available documents for object.

This also set the property $this->numoffiles

Parameters
string$modulepartModule the files are related to ('propal', 'facture', 'facture_fourn', 'mymodule', 'mymodule:MyObject', 'mymodule_temp', ...)
string$modulesubdirExisting (so sanitized) sub-directory to scan (Example: '0/1/10', 'FA/DD/MM/YY/9999'). Use '' if file is not into a subdir of module.
string$filedirDirectory to scan (must not end with a /). Example: '/mydolibarrdocuments/facture/FAYYMM-1234'
string$urlsourceUrl of origin page (for return)
int | string[]$genallowedGeneration is allowed (1/0 or array list of templates)
int$delallowedRemove is allowed (1/0)
string$modelselectedModel to preselect by default
integer$allowgenifemptyAllow generation even if list of template ($genallowed) is empty (show however a warning)
integer$forcenomultilangDo not show language option (even if MAIN_MULTILANGS defined)
int$iconPDFDeprecated, see getDocumentsLink
int$notusedNot used
integer$noformDo not output html form tags
string$paramMore param on http links
string$titleTitle to show on top of form. Example: '' (Default to "Documents") or 'none'
string$buttonlabelLabel on submit button
string$codelangDefault language code to use on lang combo box if multilang is enabled
string$morepictoAdd more HTML content into cell with picto
Object$objectObject when method is called from an object card.
int$hideifemptyHide section of generated files if there is no file
string$removeaction(optional) The action to remove a file
string$tooltipontemplatecomboText to show on a tooltip after the combo list of templates
Returns
string Output string with HTML array of documents (might be empty string)

Definition at line 337 of file html.formfile.class.php.

◆ showPreview()

FormFile::showPreview (   $file,
  $modulepart,
  $relativepath,
  $ruleforpicto = 0,
  $param = '' 
)

Show detail icon with link for preview.

Parameters
array$fileArray with data of file. Example: array('name'=>...)
string$modulepartpropal, facture, facture_fourn, ...
string$relativepathRelative path of docs
integer$ruleforpictoRule for picto: 0=Use the generic preview picto, 1=Use the picto of mime type of file). Use a negative value to show a generic picto even if preview not available.
string$paramMore param on http links
Returns
string $out Output string with HTML

Definition at line 2097 of file html.formfile.class.php.


The documentation for this class was generated from the following file: