Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

// Load Dolibarr libraries
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';

// Load EasyURL libraries
require_once __DIR__ . '/../lib/easyurl.lib.php';
Expand Down Expand Up @@ -75,6 +76,15 @@
exit;
}

if ($action == 'set_shortener_label') {
$shortenerSetLabel = GETPOST('EASYURL_SHORTENER_SET_LABEL', 'none');
dolibarr_set_const($db, 'EASYURL_SHORTENER_SET_LABEL', $shortenerSetLabel, 'chaine', 0, '', $conf->entity);

setEventMessage('SavedConfig');
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}

/*
* View
*/
Expand Down Expand Up @@ -142,5 +152,41 @@
print $form->buttonsSaveCancel('Save', '');
print '</form>';

print load_fiche_titre($langs->trans('Config'), '', '');

print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
print '<input type="hidden" name="token" value="' .newToken(). '">';
print '<input type="hidden" name="action" value="set_shortener_label">';

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Parameters') . '</td>';
print '<td>' . $langs->trans('Value') . '</td>';
print '</tr>';

$substitutionArray = getCommonSubstitutionArray($langs);
complete_substitutions_array($substitutionArray, $langs);

// Substitution array/string
$helpForSubstitution = '';
if (is_array($substitutionArray) && count($substitutionArray)) {
$helpForSubstitution .= $langs->trans('AvailableVariables') . ' : <br>';
}
foreach ($substitutionArray as $key => $val) {
$helpForSubstitution .= $key . ' -> '. $langs->trans(dol_string_nohtmltag(dolGetFirstLineOfText($val))) . '<br>';
}

// Shortener set label
$shortenerSetLabel = $langs->transnoentities($conf->global->EASYURL_SHORTENER_SET_LABEL) ?: $langs->transnoentities('ShortenerSetLabel');
print '<tr class="oddeven"><td>' . $form->textwithpicto($langs->transnoentities('ShortenerSetLabelTitle'), $helpForSubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody');
print '</td><td>';
$dolEditor = new DolEditor('EASYURL_SHORTENER_SET_LABEL', $shortenerSetLabel, '100%', 120, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$dolEditor->Create();
print '</td></tr>';

print '</table>';
print $form->buttonsSaveCancel('Save', '');
print '</form>';

$db->close();
llxFooter();
3 changes: 2 additions & 1 deletion core/modules/modEasyURL.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function __construct($db)
$this->hidden = false;

// List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...)
$this->depends = ['modAgenda', 'modSaturne'];
$this->depends = ['modAgenda', 'modSaturne', 'modFckeditor'];
$this->requiredby = []; // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...)
$this->conflictwith = []; // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...)

Expand Down Expand Up @@ -184,6 +184,7 @@ public function __construct($db)

// CONST SHORTENER
$i++ => ['EASYURL_SHORTENER_ADDON', 'chaine', 'mod_shortener_standard', '', 0, 'current'],
$i++ => ['EASYURL_SHORTENER_SET_lABEL', 'chaine', $langs->trans('ShortenerSetLabel'), '', 0, 'current'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EASYURL_SHORTENER_SET_lABEL il manque une majuscule à LABEL


// CONST DOLIBARR
$i++ => ['CONTRACT_ALLOW_ONLINESIGN', 'integer', 1, '', 0, 'current'],
Expand Down
9 changes: 9 additions & 0 deletions core/substitutions/functions_easyurl.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,13 @@ function easyurl_completesubstitutionarray(&$substitutionarray, $langs, $object)
$substitutionarray['__EASY_URL_PAYMENT_LINK__'] = $langs->trans('EasyUrlPaymentLink');
break;
}

$shortenerLabel = dol_strlen(getDolGlobalString('EASYURL_SHORTENER_SET_LABEL')) > 0 ? getDolGlobalString('EASYURL_SHORTENER_SET_LABEL') : $langs->transnoentities('ShortenerSetLabel');
if (strpos($shortenerLabel, '__EASYURL_SHA_') !== false) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php';

$SHAshortenerLabel = explode('__EASYURL_SHA_', $shortenerLabel);
$SHAshortenerLabel = explode('__', $SHAshortenerLabel[1]);
$substitutionarray['__EASYURL_SHA_' . $SHAshortenerLabel[0] . '__'] = generate_random_id($SHAshortenerLabel[0]);
}
}
28 changes: 15 additions & 13 deletions langs/fr_FR/easyurl.lang
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ AutomaticEasyUrlGeneration = Génération automatique des URLs raccou
AutomaticEasyUrlGenerationDescription = Crée automatiquement l'URL raccourcie lors de la validation d'un objet <br> (proposition commerciale, commande, facture)
ManualEasyUrlGeneration = Génération manuelle des URLs raccourcies
ManualEasyUrlGenerationDescription = Ajout d'un bouton pour créer une URL raccourcie sur un objet <br> (proposition commerciale, commande, facture)
ShortenerSetLabel = __MYCOMPANY_NAME__-__REF__-__EASYURL_SHA_8__
ShortenerSetLabelTitle = Libellé dans l'URL raccourcie



Expand All @@ -67,19 +69,19 @@ GetEasyURLErrors = Erreur : URL raccourcie non trouvée
#

# Data - Donnée
GenerateUrlManagement = Gestion de la génération des raccourcissements d'URLs
NbUrl = Nombre d'URL
NbUrlDescription = Cette option permet de choisir le nombre d'URL à générée
OriginalUrl = URL d'origine
OriginalUrlDescription = Cette option permet de choisir l'URL d'origine
OriginalUrlMoreDescription = <br> (par défaut si aucune URL n'est renseignée alors l'URL par défaut est : <b>%s</b>)
UrlParameters = Paramètre d'URL supplémentaire
UrlParametersDescription = Cette option permet d'ajouter des paramètres d'URLs supplémentaires <br> (exemple : un tiret/une valeur)
UrlMethode = Méthode d'API URL
UrlMethodeDescription = Cette option permet de choisir la méthode d'API URL utilisée dans le raccourcissement des URLs <br> (deux valeurs possibles : YOURLS ou WordPress)
GenerateUrlSuccess = Génération réussie des %d raccourcissements d'URLs
OriginalUrlFail = Erreur(s) possible(s) : <br> - Nombre d'URL est vide <br> - l'URL d'origine est vide <br> - l'URL d'origine par défaut n'as pas été configurée
DefaultOriginalUrlConfiguration = Vous n'avez pas configuré d'URL d'origine par défaut, veuillez cliquer ici pour vous rendre sur la page de configuration
GenerateUrlManagement = Gestion de la génération des raccourcissements d'URLs
NbUrl = Nombre d'URL
NbUrlDescription = Cette option permet de choisir le nombre d'URL à générée
OriginalUrl = URL d'origine
OriginalUrlDescription = Cette option permet de choisir l'URL d'origine
OriginalUrlMoreDescription = <br> (par défaut si aucune URL n'est renseignée alors l'URL par défaut est : <b>%s</b>)
OriginalUrlParameters = Paramètre d'URL d'origine supplémentaire
OriginalUrlParametersDescription = Cette option permet d'ajouter des paramètres d'URLs d'origine supplémentaires <br> (exemple : un tiret/une valeur)
UrlMethode = Méthode d'API URL
UrlMethodeDescription = Cette option permet de choisir la méthode d'API URL utilisée dans le raccourcissement des URLs <br> (deux valeurs possibles : YOURLS ou WordPress)
GenerateUrlSuccess = Génération réussie des %d raccourcissements d'URLs
OriginalUrlFail = Erreur(s) possible(s) : <br> - Nombre d'URL est vide <br> - l'URL d'origine est vide <br> - l'URL d'origine par défaut n'as pas été configurée
DefaultOriginalUrlConfiguration = Vous n'avez pas configuré d'URL d'origine par défaut, veuillez cliquer ici pour vous rendre sur la page de configuration


#
Expand Down
6 changes: 5 additions & 1 deletion lib/easyurl_function.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ function set_easy_url_link(CommonObject $object, string $urlType, string $urlMet
break;
}

$title = dol_sanitizeFileName(dol_strtolower($conf->global->MAIN_INFO_SOCIETE_NOM . '-' . $object->ref) . (getDolGlobalInt('EASYURL_USE_SHA_URL') ? '-' . generate_random_id(8) : ''));
$substitutionArray = getCommonSubstitutionArray($langs, 0, null, $shortener);
complete_substitutions_array($substitutionArray, $langs, $shortener);
$shortenerSetLabel = make_substitutions($langs->transnoentities($conf->global->EASYURL_SHORTENER_SET_LABEL), $substitutionArray);

$title = dol_sanitizeFileName(dol_strtolower(dol_strlen($shortenerSetLabel) > 0 ? $shortenerSetLabel : $langs->transnoentities('ShortenerSetLabel')));

// Init the CURL session
$ch = curl_init();
Expand Down
20 changes: 10 additions & 10 deletions view/easyurltools.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@
*/

if ($action == 'generate_url' && $permissionToAdd) {
$error = 0;
$urlMethode = GETPOST('url_methode');
$NbUrl = GETPOST('nb_url');
$originalUrl = GETPOST('original_url');
$urlParameters = GETPOST('url_parameters');
$error = 0;
$urlMethode = GETPOST('url_methode');
$NbUrl = GETPOST('nb_url');
$originalUrl = GETPOST('original_url');
$originalUrlParameters = GETPOST('original_url_parameters');
if ((dol_strlen($originalUrl) > 0 || dol_strlen(getDolGlobalString('EASYURL_DEFAULT_ORIGINAL_URL')) > 0) && $NbUrl > 0) {
for ($i = 1; $i <= $NbUrl; $i++) {
$shortener = new Shortener($db);
$shortener->ref = $shortener->getNextNumRef();
if (dol_strlen($originalUrl) > 0) {
$shortener->original_url = $originalUrl . $urlParameters;
$shortener->original_url = $originalUrl . $originalUrlParameters;
} else {
$shortener->original_url = getDolGlobalString('EASYURL_DEFAULT_ORIGINAL_URL') . $urlParameters;
$shortener->original_url = getDolGlobalString('EASYURL_DEFAULT_ORIGINAL_URL') . $originalUrlParameters;
}
$shortener->methode = $urlMethode;

Expand Down Expand Up @@ -144,9 +144,9 @@
print '<td><input class="minwidth300" type="text" name="original_url"></td>';
print '</tr>';

print '<tr class="oddeven"><td><label for="url_parameters">' . $langs->trans('UrlParameters') . '</label></td>';
print '<td>' . $langs->trans('UrlParametersDescription') . '</td>';
print '<td><input class="minwidth300" type="text" name="url_parameters"></td>';
print '<tr class="oddeven"><td><label for="original_url_parameters">' . $langs->trans('OriginalUrlParameters') . '</label></td>';
print '<td>' . $langs->trans('OriginalUrlParametersDescription') . '</td>';
print '<td><input class="minwidth300" type="text" name="original_url_parameters"></td>';
print '</tr>';

print '</table>';
Expand Down