NEW Can filter modules on publisher

This commit is contained in:
Laurent Destailleur 2016-04-06 16:45:22 +02:00
parent 1a1dc39a6b
commit ee53a8b1a8
3 changed files with 213 additions and 26 deletions

View File

@ -112,6 +112,7 @@ $_SESSION["mode"]=$mode;
$help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; $help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
llxHeader('',$langs->trans("Setup"),$help_url); llxHeader('',$langs->trans("Setup"),$help_url);
$arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers"));
// Search modules dirs // Search modules dirs
$modulesdir = dolGetModulesDirs(); $modulesdir = dolGetModulesDirs();
@ -166,26 +167,37 @@ foreach ($modulesdir as $dir)
} }
$j = $objMod->numero; $j = $objMod->numero;
$modulequalified=true; $modulequalified=1;
// We discard modules according to features level (PS: if module is activated we always show it) // We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod))); $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=false; if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0;
if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=false; if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=false; if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0;
if ($search_version)
{
if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') $modulequalified=false;
if ($objMod->version != 'development' && ($search_version == 'development')) $modulequalified=false;
if ($objMod->version != 'experimental' && ($search_version == 'experimental')) $modulequalified=false;
if (! preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) $modulequalified=false;
}
// We discard modules according to property disabled // We discard modules according to property disabled
if (! empty($objMod->hidden)) $modulequalified=false; if (! empty($objMod->hidden)) $modulequalified=0;
if ($modulequalified > 0)
{
$publisher=dol_escape_htmltag($objMod->getPublisher());
$external=($objMod->isCoreOrExternalModule() == 'external');
if ($external)
{
if ($publisher)
{
$arrayofnatures['external_'.$publisher]=$langs->trans("External").' - '.$publisher;
}
else
{
$arrayofnatures['external_']=$langs->trans("External").' - '.$langs->trans("UnknownPublishers");
}
}
ksort($arrayofnatures);
}
// Define array $categ with categ with at least one qualified module // Define array $categ with categ with at least one qualified module
if ($modulequalified) if ($modulequalified > 0)
{ {
$modules[$i] = $objMod; $modules[$i] = $objMod;
$filename[$i]= $modName; $filename[$i]= $modName;
@ -313,7 +325,7 @@ if ($mode != 'marketplace')
$moreforfilter.= $langs->trans('Status') . ': '.$form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, 1); $moreforfilter.= $langs->trans('Status') . ': '.$form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, 1);
$moreforfilter.= '</div>'; $moreforfilter.= '</div>';
$moreforfilter.='<div class="divsearchfield">'; $moreforfilter.='<div class="divsearchfield">';
$moreforfilter.= $langs->trans('Origin') . ': '.$form->selectarray('search_nature', array('standard'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External")), $search_nature, 1); $moreforfilter.= $langs->trans('Origin') . ': '.$form->selectarray('search_nature', $arrayofnatures, $search_nature, 1);
$moreforfilter.= '</div>'; $moreforfilter.= '</div>';
if (! empty($conf->global->MAIN_FEATURES_LEVEL)) if (! empty($conf->global->MAIN_FEATURES_LEVEL))
{ {
@ -379,6 +391,8 @@ if ($mode != 'marketplace')
$moduledesc=$objMod->getDesc(); $moduledesc=$objMod->getDesc();
$moduledesclong=$objMod->getDescLong(); $moduledesclong=$objMod->getDescLong();
$moduleauthor=$objMod->getPublisher(); $moduleauthor=$objMod->getPublisher();
// We discard showing according to filters
if ($search_keyword) if ($search_keyword)
{ {
$qualified=0; $qualified=0;
@ -396,8 +410,22 @@ if ($mode != 'marketplace')
} }
if ($search_nature) if ($search_nature)
{ {
if ($search_nature == 'external' && $objMod->isCoreOrExternalModule() != 'external') continue; if (preg_match('/^external/',$search_nature) && $objMod->isCoreOrExternalModule() != 'external') continue;
if ($search_nature == 'standard' && $objMod->isCoreOrExternalModule() == 'external') continue; if (preg_match('/^external_(.*)$/',$search_nature, $reg))
{
//print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher());
$publisher=dol_escape_htmltag($objMod->getPublisher());
if ($reg[1] && $reg[1] != $publisher) continue;
if (! $reg[1] && ! empty($publisher)) continue;
}
if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') continue;
}
if ($search_version)
{
if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') continue;
if ($objMod->version != 'development' && ($search_version == 'development')) continue;
if ($objMod->version != 'experimental' && ($search_version == 'experimental')) continue;
if (! preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) continue;
} }
// Load all lang files of module // Load all lang files of module
@ -415,7 +443,7 @@ if ($mode != 'marketplace')
if ($familykey!=$oldfamily) if ($familykey!=$oldfamily)
{ {
print '<tr class="liste_titre">'."\n"; print '<tr class="liste_titre">'."\n";
print '<td colspan="5">'; print '<td colspan="6">';
$familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label']; $familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
print $familytext; print $familytext;
print "</td>\n"; print "</td>\n";
@ -463,18 +491,159 @@ if ($mode != 'marketplace')
print nl2br($objMod->getDesc()); print nl2br($objMod->getDesc());
print "</td>\n"; print "</td>\n";
// Help
print '<td align="center" valign="top" class="nowrap">';
$text='';
if ($objMod->getDescLong()) $text.=$objMod->getDesc().'<br>'.$objMod->getDescLong().'<br>';
else $text.=$objMod->getDesc().'<br>';
if ($objMod->isCoreOrExternalModule() == 'external')
{
$text.='<br><strong>'.$langs->trans("Origin").':</strong> '.$langs->trans("ExternalModule",$dirofmodule);
if (! empty($objMod->editor_name) && $objMod->editor_name != 'dolibarr') $text.='<br><strong>'.$langs->trans("Author").':</strong> '.$objMod->editor_name;
if (! empty($objMod->editor_url) && $objMod->editor_url != 'www.dolibarr.org') $text.='<br><strong>'.$langs->trans("Url").':</strong> '.$objMod->editor_url;
$text.='<br>';
}
else
{
$text.='<br><strong>'.$langs->trans("Origin").':</strong> '.$langs->trans("Core").'<br>';
}
$text.='<br><strong>'.$langs->trans("AddRemoveTabs").':</strong> ';
if (isset($objMod->tabs) && is_array($objMod->tabs) && count($objMod->tabs))
{
$i=0;
foreach($objMod->tabs as $val)
{
$tmp=explode(':',$val,3);
$text.=($i?', ':'').$tmp[0].':'.$tmp[1];
$i++;
}
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddDictionaries").':</strong> ';
if (isset($objMod->dictionaries) && isset($objMod->dictionaries['tablib']) && is_array($objMod->dictionaries['tablib']) && count($objMod->dictionaries['tablib']))
{
$i=0;
foreach($objMod->dictionaries['tablib'] as $val)
{
$text.=($i?', ':'').$val;
$i++;
}
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddBoxes").':</strong> ';
if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes))
{
$i=0;
foreach($objMod->boxes as $val)
{
$text.=($i?', ':'').($val['file']?$val['file']:$val[0]);
$i++;
}
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddModels").':</strong> ';
if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models'])
{
$text.=$langs->trans("Yes");
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddSubstitutions").':</strong> ';
if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions'])
{
$text.=$langs->trans("Yes");
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddSheduledJobs").':</strong> ';
if (isset($objMod->cronjobs) && is_array($objMod->cronjobs) && count($objMod->cronjobs))
{
$i=0;
foreach($objMod->cronjobs as $val)
{
$text.=($i?', ':'').($val['label']);
$i++;
}
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddTriggers").':</strong> ';
if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers'])
{
$text.=$langs->trans("Yes");
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddHooks").':</strong> ';
if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks']))
{
$i=0;
foreach($objMod->module_parts['hooks'] as $val)
{
$text.=($i?', ':'').($val);
$i++;
}
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddPermissions").':</strong> ';
if (isset($objMod->rights) && is_array($objMod->rights) && count($objMod->rights))
{
$i=0;
foreach($objMod->rights as $val)
{
$text.=($i?', ':'').($val[1]);
$i++;
}
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddMenus").':</strong> ';
if (isset($objMod->menu) && is_array($objMod->menu) && $objMod->menu)
{
$text.=$langs->trans("Yes");
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddExportProfiles").':</strong> ';
if (isset($objMod->export_label) && is_array($objMod->export_label) && count($objMod->export_label))
{
$i=0;
foreach($objMod->export_label as $val)
{
$text.=($i?', ':'').($val);
$i++;
}
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddImportProfiles").':</strong> ';
if (isset($objMod->import_label) && is_array($objMod->import_label) && count($objMod->import_label))
{
$i=0;
foreach($objMod->import_label as $val)
{
$text.=($i?', ':'').($val);
$i++;
}
}
else $text.=$langs->trans("No");
$text.='<br><strong>'.$langs->trans("AddOtherPagesOrServices").':</strong> ';
$text.=$langs->trans("DetectionNotPossible");
print $form->textwithpicto('', $text, 1, 'help');
print '</td>';
// Version // Version
print '<td align="center" valign="top" class="nowrap">'; print '<td align="center" valign="top" class="nowrap">';
$version=$objMod->getVersion(); $version=$objMod->getVersion();
$dirofmodule=$dirmod[$key]; $dirofmodule=$dirmod[$key];
if ($objMod->isCoreOrExternalModule() == 'external') print $version;
{
$text=$langs->trans("ExternalModule",$dirofmodule);
if (! empty($objMod->editor_name) && $objMod->editor_name != 'dolibarr') $text.=' - '.$objMod->editor_name;
if (! empty($objMod->editor_web) && $objMod->editor_web != 'www.dolibarr.org') $text.=' - '.$objMod->editor_web;
print $form->textwithpicto($version, $text, 1, 'help');
}
else print $version;
print "</td>\n"; print "</td>\n";
// Activate/Disable and Setup (2 columns) // Activate/Disable and Setup (2 columns)

View File

@ -469,6 +469,8 @@ class DolibarrModules // Can not be abstract, because we need to insta
global $langs; global $langs;
$langs->load("admin"); $langs->load("admin");
if (empty($this->descriptionlong)) return '';
// If module description translation does not exist using its unique id, we can use its name to find translation // If module description translation does not exist using its unique id, we can use its name to find translation
if (is_array($this->langfiles)) if (is_array($this->langfiles))
{ {

View File

@ -1721,3 +1721,19 @@ MultiPriceRuleDesc=When option "Several level of prices per product/service" is
ModelModulesProduct=Templates for product documents ModelModulesProduct=Templates for product documents
ToGenerateCodeDefineAutomaticRuleFirst=To be able to generate automatically codes, you must first define a manager to auto define barcode number. ToGenerateCodeDefineAutomaticRuleFirst=To be able to generate automatically codes, you must first define a manager to auto define barcode number.
SeeSubstitutionVars=See * note for list of possible substitution variables SeeSubstitutionVars=See * note for list of possible substitution variables
AllPublishers=All publishers
UnknownPublishers=Unknown publishers
AddRemoveTabs=Add or remove tabs
AddDictionaries=Add dictionaries
AddBoxes=Add boxes
AddSheduledJobs=Add scheduled jobs
AddHooks=Add hooks
AddTriggers=Add triggers
AddMenus=Add menus
AddPermissions=Add permissions
AddExportProfiles=Add export profiles
AddImportProfiles=Add import profiles
AddOtherPagesOrServices=Add other pages or services
AddModels=Add document or numbering templates
AddSubstitutions=Add keys substitutions
DetectionNotPossible=Detection not possible