Prepair to display within a custom place

This commit is contained in:
Grand Philippe 2012-04-05 11:46:56 +02:00
parent 03cfec7904
commit d3068e0ba5

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -35,8 +36,8 @@ $langs->load("projects");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$value=GETPOST('value','action'); $value=GETPOST('value','alpha');
$action=GETPOST('action','action'); $action=GETPOST('action','alpha');
/* /*
@ -69,17 +70,28 @@ if ($action == 'specimen')
$project = new Project($db); $project = new Project($db);
$project->initAsSpecimen(); $project->initAsSpecimen();
// Charge le modele // Search template files
$dir = DOL_DOCUMENT_ROOT . "/core/modules/project/pdf/"; $file=''; $classname=''; $filefound=0;
$file = "pdf_".$modele.".modules.php"; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
if (file_exists($dir.$file)) foreach($dirmodels as $reldir)
{ {
$classname = "pdf_".$modele; $file=dol_buildpath($reldir."core/modules/project/pdf/pdf_".$modele.".modules.php",0);
require_once($dir.$file); if (file_exists($file))
{
$filefound=1;
$classname = "pdf_".$modele;
break;
}
}
$obj = new $classname($db);
if ($filefound)
{
require_once($file);
if ($obj->write_file($project,$langs) > 0) $module = new $classname($db);
if ($module->write_file($project,$langs) > 0)
{ {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=project&file=SPECIMEN.pdf");
return; return;
@ -172,6 +184,8 @@ if ($action == 'setmod')
* View * View
*/ */
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
$form=new Form($db); $form=new Form($db);
llxHeader(); llxHeader();
@ -199,80 +213,89 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$handle = opendir($dir); foreach ($dirmodels as $reldir)
if (is_resource($handle))
{ {
$var=true; $dir = dol_buildpath($reldir."core/modules/project/");
while (($file = readdir($handle))!==false) if (is_dir($dir))
{ {
if (substr($file, 0, 12) == 'mod_project_' && substr($file, dol_strlen($file)-3, 3) == 'php') $handle = opendir($dir);
if (is_resource($handle))
{ {
$file = substr($file, 0, dol_strlen($file)-4); $var=true;
require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$file.".php"); while (($file = readdir($handle))!==false)
$module = new $file;
if ($module->isEnabled())
{ {
// Show modules according to features level if (preg_match('/^(mod_.*)\.php$/i',$file,$reg))
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
print '<td align="center">';
if ($conf->global->PROJECT_ADDON == "$file")
{ {
print img_picto($langs->trans("Activated"),'switch_on'); $file = $reg[1];
} $classname = substr($file,4);
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
}
print '</td>';
$project=new Project($db); require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$file.".php");
$project->initAsSpecimen();
// Info $module = new $file;
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; if ($module->isEnabled())
$nextval=$module->getNextValue($mysoc,$project);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{ {
$htmltooltip.=$nextval.'<br>'; // Show modules according to features level
} if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
{
$htmltooltip.=$langs->trans($module->error).'<br>'; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
print $module->info();
print '</td>';
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
print '<td align="center">';
if ($conf->global->PROJECT_ADDON == "$file")
{
print img_picto($langs->trans("Activated"),'switch_on');
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
}
print '</td>';
$project=new Project($db);
$project->initAsSpecimen();
// Info
$htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$nextval=$module->getNextValue($mysoc,$project);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{
$htmltooltip.=''.$langs->trans("NextValue").': ';
if ($nextval)
{
$htmltooltip.=$nextval.'<br>';
}
else
{
$htmltooltip.=$langs->trans($module->error).'<br>';
}
}
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print '</tr>';
} }
} }
print '<td align="center">';
print $form->textwithpicto('',$htmltooltip,1,0);
print '</td>';
print '</tr>';
} }
closedir($handle);
} }
} }
closedir($handle);
} }
print '</table><br>'; print '</table><br>';
@ -282,7 +305,7 @@ print '</table><br>';
* Modeles documents for projects * Modeles documents for projects
*/ */
$dir = DOL_DOCUMENT_ROOT.'/core/modules/project/pdf/'; //$dir = DOL_DOCUMENT_ROOT.'/core/modules/project/pdf/';
print_titre($langs->trans("ProjectsModelModule")); print_titre($langs->trans("ProjectsModelModule"));
@ -323,76 +346,83 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
$handle=opendir($dir);
$var=true; $var=true;
if (is_resource($handle)) foreach ($dirmodels as $reldir)
{ {
while (($file = readdir($handle))!==false) $dir = dol_buildpath($reldir."core/modules/project/pdf/");
{
if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
$var=!$var; if (is_dir($dir))
print "<tr ".$bc[$var].">\n <td>$name"; {
print "</td>\n <td>\n"; $handle=opendir($dir);
require_once($dir.$file); if (is_resource($handle))
$module = new $classname($db); {
print $module->description; while (($file = readdir($handle))!==false)
print "</td>\n"; {
if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_')
{
$name = substr($file, 4, dol_strlen($file) -16);
$classname = substr($file, 0, dol_strlen($file) -12);
// Active $var=!$var;
if (in_array($name, $def)) print "<tr ".$bc[$var].">\n <td>$name";
{ print "</td>\n <td>\n";
print "<td align=\"center\">\n"; require_once($dir.$file);
//if ($conf->global->PROJECT_ADDON_PDF != "$name") $module = new $classname($db);
//{ print $module->description;
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print "</td>\n";
print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>';
//}
//else
//{
// print img_picto($langs->trans("Enabled"),'on');
//}
print "</td>";
}
else
{
print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>";
}
// Defaut // Active
print "<td align=\"center\">"; if (in_array($name, $def))
if ($conf->global->PROJECT_ADDON_PDF == "$name") {
{ print "<td align=\"center\">\n";
print img_picto($langs->trans("Default"),'on'); //if ($conf->global->PROJECT_ADDON_PDF != "$name")
} //{
else print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
{ print img_picto($langs->trans("Enabled"),'switch_on');
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '</a>';
} //}
print '</td>'; //else
//{
// print img_picto($langs->trans("Enabled"),'on');
//}
print "</td>";
}
else
{
print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>";
}
// Info // Defaut
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; print "<td align=\"center\">";
$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); if ($conf->global->PROJECT_ADDON_PDF == "$name")
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; {
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; print img_picto($langs->trans("Default"),'on');
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); }
print '<td align="center">'; else
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>'; {
print $form->textwithpicto(' &nbsp; &nbsp; '.$link,$htmltooltip,-1,0); print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
print '</td>'; }
print '</td>';
print "</tr>\n"; // Info
} $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
} $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
closedir($handle); $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
print '<td align="center">';
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
print $form->textwithpicto(' &nbsp; &nbsp; '.$link,$htmltooltip,-1,0);
print '</td>';
print "</tr>\n";
}
}
closedir($handle);
}
}
} }
print '</table><br/>'; print '</table><br/>';
@ -402,4 +432,4 @@ dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();
?> ?>