2
0
forked from Wavyzz/dolibarr

Fix document_preview is possible on files with + chars inside.

This commit is contained in:
Laurent Destailleur
2017-03-24 17:32:38 +01:00
parent cb0eb26faa
commit d1a988a0be
6 changed files with 49 additions and 32 deletions

View File

@@ -673,6 +673,7 @@ else
print "</table><br>"; print "</table><br>";
print '<hr style="margin-bottom: 20px">';
// Add personnal information // Add personnal information
print load_fiche_titre('<div class="comboperso">'.$langs->trans("PersonalInformations").'</div>','',''); print load_fiche_titre('<div class="comboperso">'.$langs->trans("PersonalInformations").'</div>','','');

View File

@@ -867,9 +867,9 @@ class FormFile
// Preview // Preview
$urladvanced = getAdvancedPreviewUrl($modulepart, $relativepath); $urladvanced = getAdvancedPreviewUrl($modulepart, $relativepath);
if ($urladvanced) $tmpout.= '<li><a data-ajax="false" href="'.$urladvanced.'">'.img_picto('','detail').' '.$langs->trans("Preview").' '.$ext.'</a></li>'; if ($urladvanced) $tmpout.= '<li><a href="'.$urladvanced.'">'.img_picto('','detail').' '.$langs->trans("Preview").' '.$ext.'</a></li>';
// Download // Download
$tmpout.= '<li><a data-ajax="false" class="pictopreview" href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'"'; $tmpout.= '<li><a class="pictopreview" href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'"';
$mime=dol_mimetype($relativepath,'',0); $mime=dol_mimetype($relativepath,'',0);
if (preg_match('/text/',$mime)) $tmpout.= ' target="_blank"'; if (preg_match('/text/',$mime)) $tmpout.= ' target="_blank"';
$tmpout.= '>'; $tmpout.= '>';
@@ -1679,10 +1679,11 @@ class FormFile
$out=''; $out='';
if ($conf->browser->layout != 'phone') if ($conf->browser->layout != 'phone')
{ {
$urladvancedpreview=getAdvancedPreviewUrl($modulepart, $relativepath); // Return if a file is qualified for preview $urladvancedpreview=getAdvancedPreviewUrl($modulepart, $relativepath, 1); // Return if a file is qualified for preview.
if ($urladvancedpreview) if (count($urladvancedpreview))
{ {
$out.= '<a data-ajax="false" class="pictopreview" href="'.$urladvancedpreview.'">'; $out.= '<a class="pictopreview '.$urladvancedpreview['css'].'" href="'.$urladvancedpreview['url'].'"'.(empty($urladvancedpreview['mime'])?'':' mime="'.$urladvancedpreview['mime'].'"').' '.(empty($urladvancedpreview['target'])?'':' target="'.$urladvancedpreview['target'].'"').'>';
//$out.= '<a class="pictopreview">';
if (empty($ruleforpicto)) $out.= img_picto($langs->trans('Preview').' '.$file['name'], 'detail'); if (empty($ruleforpicto)) $out.= img_picto($langs->trans('Preview').' '.$file['name'], 'detail');
else $out.= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']); else $out.= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']);
$out.= '</a>'; $out.= '</a>';

View File

@@ -693,7 +693,6 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
$colspan=9; $colspan=9;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre('');
print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"p.lastname","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"p.lastname","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Poste"),$_SERVER["PHP_SELF"],"p.poste","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Poste"),$_SERVER["PHP_SELF"],"p.poste","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
@@ -728,21 +727,16 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
{ {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
// Photo // Photo - Name
print '<td class="liste_titre">';
print '</td>';
// Name - Position
print '<td class="liste_titre">'; print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_name" size="20" value="'.$search_name.'">'; print '<input type="text" class="flat" name="search_name" size="20" value="'.$search_name.'">';
print '</td>'; print '</td>';
// Address / Phone // Position
print '<td class="liste_titre">'; print '<td class="liste_titre">';
//print '<input type="text" class="flat" name="search_addressphone" size="20" value="'.$search_addressphone.'">';
print '</td>'; print '</td>';
// Email // Address - Phone - Email
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
// Status // Status
@@ -797,13 +791,9 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
// Photo // Photo - Name
print '<td width="50px">';
print $form->showphoto('contact',$contactstatic,0,0,0,'photorefnoborder','small',1,0,1);
print '</td>';
// Name
print '<td>'; print '<td>';
print $form->showphoto('contact',$contactstatic,0,0,0,'photorefnoborder valignmiddle marginrightonly','small',1,0,1);
print $contactstatic->getNomUrl(0,'',0,'&backtopage='.urlencode($backtopage)); print $contactstatic->getNomUrl(0,'',0,'&backtopage='.urlencode($backtopage));
print '</td>'; print '</td>';
@@ -812,7 +802,7 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
if ($obj->poste) print $obj->poste; if ($obj->poste) print $obj->poste;
print '</td>'; print '</td>';
// Address and phone // Address - Phone - Email
print '<td>'; print '<td>';
print $contactstatic->getBannerAddress('contact', $object); print $contactstatic->getBannerAddress('contact', $object);
print '</td>'; print '</td>';

View File

@@ -5855,10 +5855,11 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
* Return URL we can use for advanced preview links * Return URL we can use for advanced preview links
* *
* @param string $modulepart propal, facture, facture_fourn, ... * @param string $modulepart propal, facture, facture_fourn, ...
* @param string $relativepath Relative path of docs * @param string $relativepath Relative path of docs.
* @return string Output string with HTML * @param int $alldata Return array with all components (1 is recommended)
* @return string|array Output string with href link or array with all components of link
*/ */
function getAdvancedPreviewUrl($modulepart, $relativepath) function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0)
{ {
global $conf, $langs; global $conf, $langs;
@@ -5869,7 +5870,14 @@ function getAdvancedPreviewUrl($modulepart, $relativepath)
//$mime_preview[]='archive'; //$mime_preview[]='archive';
$num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview); $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview);
if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&amp;attachment=0&amp;file='.$relativepath).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')'; if ($alldata == 1)
{
if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath), 'mime'=>dol_mimetype($relativepath), );
else return array();
}
// old behavior
if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath)).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')';
else return ''; else return '';
} }

View File

@@ -1882,7 +1882,9 @@ if (! function_exists("llxFooter"))
if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent; if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent;
// Wrapper to show tooltips // TODO Move this in lib_head.js
// Wrapper to show tooltips (html or onclick popup)
if (! empty($conf->use_javascript_ajax) && empty($conf->dol_no_mouse_hover)) if (! empty($conf->use_javascript_ajax) && empty($conf->dol_no_mouse_hover))
{ {
print "\n<!-- JS CODE TO ENABLE tipTip on all object with class classfortooltip -->\n"; print "\n<!-- JS CODE TO ENABLE tipTip on all object with class classfortooltip -->\n";
@@ -1902,6 +1904,21 @@ if (! function_exists("llxFooter"))
</script>' . "\n"; </script>' . "\n";
} }
// Wrapper to manage document_preview
if (! empty($conf->use_javascript_ajax))
{
print "\n<!-- JS CODE TO ENABLE document_preview -->\n";
print '<script type="text/javascript">
jQuery(document).ready(function () {
jQuery(".documentpreview").click(function () {
console.log("We click on preview for element with href="+$(this).attr(\'href\')+" mime="+$(this).attr(\'mime\'));
document_preview($(this).attr(\'href\'), $(this).attr(\'mime\'), \''.dol_escape_js($langs->transnoentities("Preview")).'\');
return false;
});
});
</script>' . "\n";
}
// Wrapper to manage dropdown // Wrapper to manage dropdown
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
{ {

View File

@@ -802,7 +802,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
print '<div class="fichecenter">'; print '<div class="nofichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent">';
@@ -845,7 +845,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
} }
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>'; print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
print '<textarea name="domiciliation" rows="'.ROWS_4.'" cols="40" maxlength="255">'; print '<textarea name="domiciliation" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
print GETPOST('domiciliation'); print GETPOST('domiciliation');
print "</textarea></td></tr>"; print "</textarea></td></tr>";
@@ -854,7 +854,7 @@ if ($socid && $action == 'create' && $user->rights->societe->creer)
print "</td></tr>\n"; print "</td></tr>\n";
print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>'; print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
print '<textarea name="owner_address" rows="'.ROWS_4.'" cols="40" maxlength="255">'; print '<textarea name="owner_address" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">';
print GETPOST('owner_address'); print GETPOST('owner_address');
print "</textarea></td></tr>"; print "</textarea></td></tr>";