Darathor
Citation :
But : Ce sous-MOD a pour objectif d'inclure automatiquement des fichiers d'un répertoire. Ainsi pour ajouter des cles de langue ou des fonctions, il suffit de rajouter un fichier qui les contient dans le bon répertoire. Ceci permet de réduire le nombre de modifications de fichiers à l'installation de chaque exploitant ce mécanisme.
Auteur : Darathor (darathor@free.fr)
Version : 1.0 DEV - A (08/10/2006)
Compatibilité phpBB : 2.0.21
Créer les répertoires suivants :
- language/lang_***/lang_all/
- language/lang_***/lang_front/
- language/lang_***/lang_back/
- includes/functions_all/
- includes/functions_front/
- includes/functions_back/
- includes/constants/
- includes/classes/
Dans "includes/functions.php"
Code :
#
# Trouver
#
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx);
}
#
# Ajouter après
#
// DEBUT MOD Auto-included files
// Include main files.
foreach (AuIF_getFilesToInclude($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_all', '', '.php', true) as $file)
{
include_once($file);
}
// If we are in admin mode, include admin-specific fles.
if (defined('IN_ADMIN'))
{
foreach (AuIF_getFilesToInclude($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_back', '', '.php', true) as $file)
{
include_once($file);
}
}
// Else, include front-office ones.
else
{
foreach (AuIF_getFilesToInclude($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_front', '', '.php', true) as $file)
{
include_once($file);
}
}
// FIN MOD Auto-included files
#
# Trouver
#
?>
#
# Ajouter avant
#
// DEBUT MOD Auto-included files
/**
* Look for all contained files that have a specified prefix and an specified extension. The files are not included here because of local context problems.
* @param string $directoryPath the directory from where we want to include files.
* @param string $filesPrefix used to filter files according to the begining of their name (give empty string to not filter).
* @param string $filesSuffix used to filter files according to the end of their name (give empty string to not filter).
* @param boolean $recursive say if we want to recursively look into sub-directories.
* @return array an array containing the path to the files to include.
*/
function AuIF_getFilesToInclude($directoryPath, $filesPrefix = '', $filesSuffix = '', $recursive = false)
{
// Complete the path whith a slash if it isn't ended with one.
if(substr($directoryPath, (strlen($directoryPath)-1)) != '/')
{
$directoryPath .= '/';
}
// Get the files only if there is a directory.
$to_include = array();
if (is_dir($directoryPath))
{
$directory = @opendir($directoryPath);
while ($file = @readdir($directory))
{
// Directory case.
if (is_dir($file))
{
if (($file != '.') && ($file != '..') && $recursive)
{
$to_include = array_merge($to_include, AuIF_includeFiles($directoryPath . $file, $filesPrefix, $filesSuffix, $recursive));
}
else
{
continue;
}
}
// File case.
elseif (preg_match("#^" . $filesPrefix . ".*?" . $filesSuffix . "$#", $file))
{
$to_include[] = $directoryPath . $file;
}
}
@closedir($directory);
}
return $to_include;
}
// FIN MOD Auto-included files
Dans "common.php" :
Code :
#
# Trouver
#
//
// Obtain and encode users IP
#
# Ajouter avant
#
// DEBUT MOD Auto-included files
// Include canstants.
foreach (AuIF_getFilesToInclude($phpbb_root_path . 'includes/constants', '', '.php', true) as $file)
{
include_once($file);
}
// Include classes.
foreach (AuIF_getFilesToInclude($phpbb_root_path . 'includes/classes', '', '.php', true) as $file)
{
include_once($file);
}
// Include main files.
foreach (AuIF_getFilesToInclude($phpbb_root_path . 'includes/functions_all', '', '.php', true) as $file)
{
include_once($file);
}
// If we are in admin mode, include admin-specific fles.
if (defined('IN_ADMIN'))
{
foreach (AuIF_getFilesToInclude($phpbb_root_path . 'includes/functions_back', '', '.php', true) as $file)
{
include_once($file);
}
}
// Else, include front-office ones.
else
{
foreach (AuIF_getFilesToInclude($phpbb_root_path . 'includes/functions_front', '', '.php', true) as $file)
{
include_once($file);
}
}
// FIN MOD Auto-included files