From d3068e0ba56e292ed93f3cc206dd6004fc74b3c7 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Thu, 5 Apr 2012 11:46:56 +0200 Subject: [PATCH] Prepair to display within a custom place --- htdocs/admin/project.php | 298 +++++++++++++++++++++------------------ 1 file changed, 164 insertions(+), 134 deletions(-) diff --git a/htdocs/admin/project.php b/htdocs/admin/project.php index 1a7bc3b37f7..4dd4702a115 100644 --- a/htdocs/admin/project.php +++ b/htdocs/admin/project.php @@ -2,6 +2,7 @@ /* Copyright (C) 2010 Regis Houssin * Copyright (C) 2011 Laurent Destailleur * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2011-2012 Philippe Grand * * 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 @@ -35,8 +36,8 @@ $langs->load("projects"); if (!$user->admin) accessforbidden(); -$value=GETPOST('value','action'); -$action=GETPOST('action','action'); +$value=GETPOST('value','alpha'); +$action=GETPOST('action','alpha'); /* @@ -69,17 +70,28 @@ if ($action == 'specimen') $project = new Project($db); $project->initAsSpecimen(); - // Charge le modele - $dir = DOL_DOCUMENT_ROOT . "/core/modules/project/pdf/"; - $file = "pdf_".$modele.".modules.php"; - if (file_exists($dir.$file)) + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) { - $classname = "pdf_".$modele; - require_once($dir.$file); + $file=dol_buildpath($reldir."core/modules/project/pdf/pdf_".$modele.".modules.php",0); + 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"); return; @@ -172,6 +184,8 @@ if ($action == 'setmod') * View */ +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + $form=new Form($db); llxHeader(); @@ -199,80 +213,89 @@ print "\n"; clearstatcache(); -$handle = opendir($dir); -if (is_resource($handle)) +foreach ($dirmodels as $reldir) { - $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"); - - $module = new $file; - - if ($module->isEnabled()) + while (($file = readdir($handle))!==false) { - // Show modules according to features level - 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 ''.$module->nom."\n"; - print $module->info(); - print ''; - - // Show example of numbering module - print ''; - $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; - - print ''; - if ($conf->global->PROJECT_ADDON == "$file") + if (preg_match('/^(mod_.*)\.php$/i',$file,$reg)) { - print img_picto($langs->trans("Activated"),'switch_on'); - } - else - { - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; - } - print ''; + $file = $reg[1]; + $classname = substr($file,4); - $project=new Project($db); - $project->initAsSpecimen(); + require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$file.".php"); - // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc,$project); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) + $module = new $file; + + if ($module->isEnabled()) { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; + // Show modules according to features level + 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 ''.$module->nom."\n"; + print $module->info(); + print ''; + + // Show example of numbering module + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; + + print ''; + if ($conf->global->PROJECT_ADDON == "$file") + { + print img_picto($langs->trans("Activated"),'switch_on'); + } + else + { + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; + } + print ''; + + $project=new Project($db); + $project->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval=$module->getNextValue($mysoc,$project); + if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval + { + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) + { + $htmltooltip.=$nextval.'
'; + } + else + { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + + print ''; } } - - print ''; - print $form->textwithpicto('',$htmltooltip,1,0); - print ''; - - print ''; } + closedir($handle); } } - closedir($handle); } print '
'; @@ -282,7 +305,7 @@ print '
'; * 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")); @@ -323,76 +346,83 @@ print "\n"; clearstatcache(); -$handle=opendir($dir); - $var=true; -if (is_resource($handle)) +foreach ($dirmodels as $reldir) { - while (($file = readdir($handle))!==false) - { - 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); + $dir = dol_buildpath($reldir."core/modules/project/pdf/"); - $var=!$var; - print "\n $name"; - print "\n \n"; - require_once($dir.$file); - $module = new $classname($db); - print $module->description; - print "\n"; + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + 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 - if (in_array($name, $def)) - { - print "\n"; - //if ($conf->global->PROJECT_ADDON_PDF != "$name") - //{ - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'switch_on'); - print ''; - //} - //else - //{ - // print img_picto($langs->trans("Enabled"),'on'); - //} - print ""; - } - else - { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; - print ""; - } + $var=!$var; + print "\n $name"; + print "\n \n"; + require_once($dir.$file); + $module = new $classname($db); + print $module->description; + print "\n"; - // Defaut - print ""; - if ($conf->global->PROJECT_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; + // Active + if (in_array($name, $def)) + { + print "\n"; + //if ($conf->global->PROJECT_ADDON_PDF != "$name") + //{ + print 'scandir.'&label='.urlencode($module->name).'">'; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + //} + //else + //{ + // print img_picto($langs->trans("Enabled"),'on'); + //} + print ""; + } + else + { + print "\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print ""; + } - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - print ''; - $link=''.img_object($langs->trans("Preview"),'order').''; - print $form->textwithpicto('     '.$link,$htmltooltip,-1,0); - print ''; + // Defaut + print ""; + if ($conf->global->PROJECT_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; - print "\n"; - } - } - closedir($handle); + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + print ''; + $link=''.img_object($langs->trans("Preview"),'order').''; + print $form->textwithpicto('     '.$link,$htmltooltip,-1,0); + print ''; + + print "\n"; + } + } + closedir($handle); + } + } } print '
'; @@ -402,4 +432,4 @@ dol_htmloutput_mesg($mesg); $db->close(); llxFooter(); -?> +?> \ No newline at end of file