dolibarr  7.0.0-beta
Public Member Functions | Private 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='')
 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)
 Return a string to show the box with list of available documents for object. More...
 
 getDocumentsLink ($modulepart, $modulesubdir, $filedir, $filter='')
 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)
 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='', $permtodelete=1, $useinecm=0, $textifempty='', $maxlength=0, $url='', $addfilterfields=0)
 Show list of documents in a directory. More...
 
 listOfLinks ($object, $permtodelete=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...
 

Private Member Functions

 _formAjaxFileUpload ($object)
 Show form to upload a new file with jquery fileupload. More...
 

Detailed Description

Class to offer components to list and upload files.

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

Constructor & Destructor Documentation

FormFile::__construct (   $db)

Constructor.

Parameters
DoliDB$dbDatabase handler

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

Member Function Documentation

FormFile::_formAjaxFileUpload (   $object)
private

Show form to upload a new file with jquery fileupload.

This form use the fileupload.php file.

Parameters
Object$objectObject to use
Returns
void

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

Referenced by 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 = '' 
)

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 no be enabled.
Parameters
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 (is sectiondir defined, sectionid must not be)
Returns
int <0 if KO, >0 if OK

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

References $title, _formAjaxFileUpload(), info_admin(), load_fiche_titre(), and print.

FormFile::getDocumentsLink (   $modulepart,
  $modulesubdir,
  $filedir,
  $filter = '' 
)

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$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$filedirFull path to directory to scan
string$filterFilter filenames on this regex string (Example: '.pdf$')
Returns
string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles

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

References dol_dir_list(), dol_mimetype(), get_exdir(), getAdvancedPreviewUrl(), and img_mime().

Referenced by showdocuments().

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

Show list of documents in a directory.

Parameters
string$upload_dirDirectory that was scanned
array$filearrayArray of files loaded by dol_dir_list function before calling this function
string$modulepartValue for modulepart used by download wrapper
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$permtodeletePermission 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 1275 of file html.formfile.class.php.

References $form, dol_print_size(), dol_syslog(), dol_trunc(), img_mime(), load_fiche_titre(), print, print_liste_field_titre(), and showPreview().

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 
)

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: Add a previw link. Show also rename and crop file 1: Add link to edit ECM entry 2: Add rename and crop file
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 if you want 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 line with filters
Returns
int <0 if KO, nb of files shown if OK
See also
list_of_autoecmfiles

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

References $title, completeFileArrayWithDatabaseInfo(), dol_escape_htmltag(), dol_is_file(), dol_print_size(), dol_sanitizeFileName(), dol_sort_array(), get_exdir(), getAdvancedPreviewUrl(), getImageFileNameForSize(), GETPOST(), image_format_supported(), img_delete(), img_down(), img_edit(), img_mime(), img_picto(), img_up(), img_view(), load_fiche_titre(), print, print_liste_field_titre(), showPreview(), Product\TYPE_PRODUCT, and Product\TYPE_SERVICE.

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

Show array with linked files.

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

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

References dol_escape_htmltag(), dol_now(), dol_print_date(), img_delete(), img_edit(), img_picto(), load_fiche_titre(), print, and print_liste_field_titre().

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 251 of file html.formfile.class.php.

References $title, print, and 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 
)

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_temp', ...)
string$modulesubdirExisting (so sanitized) sub-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 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
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.
Returns
string Output string with HTML array of documents (might be empty string)

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

References $form, $title, ajax_combobox(), dol_buildpath(), dol_dir_list(), dol_escape_js(), dol_filemtime(), dol_filesize(), dol_mimetype(), dol_print_date(), dol_print_error(), dol_syslog(), getDocumentsLink(), img_mime(), ModelePDFSuppliersPayments\liste_modeles(), ModeleExpenseReport\liste_modeles(), ModeleAction\liste_modeles(), ModelePDFProjects\liste_modeles(), ModeleThirdPartyDoc\liste_modeles(), ModelePDFTask\liste_modeles(), ModeleDon\liste_modeles(), ModelePDFSuppliersInvoices\liste_modeles(), ModelePDFFicheinter\liste_modeles(), ModelePDFCards\liste_modeles(), ModelePDFDeliveryOrder\liste_modeles(), ModelePDFSupplierProposal\liste_modeles(), ModeleExports\liste_modeles(), ModelePDFFactures\liste_modeles(), ModelePDFPropales\liste_modeles(), ModelePDFSuppliersOrders\liste_modeles(), ModelePDFContract\liste_modeles(), ModelePDFUserGroup\liste_modeles(), ModelePDFUser\liste_modeles(), ModelePDFCommandes\liste_modeles(), ModelePDFProduct\liste_modeles(), ModeleChequeReceipts\liste_modeles(), load_fiche_titre(), and showPreview().

Referenced by show_documents().

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
string$ruleforpictoRule for picto: 0=Use the generic preview picto, 1=Use the picto of mime type of file)
string$paramMore param on http links
Returns
string $out Output string with HTML

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

References getAdvancedPreviewUrl(), and img_mime().

Referenced by list_of_autoecmfiles(), list_of_documents(), and showdocuments().


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