L'idée de ce mod est de pouvoir choisir un thème différent pour certaines catégories de votre galerie. Exactement comme le proposent tous les systèmes de forums modernes.
Ajoutez un champ theme dans votre table "categories".
<coppermine>/include/init.inc.php
Trouvez
// Process theme selection if present in URI or in user profile
if (!empty($_GET['theme'])) {
$USER['theme'] = $_GET['theme'];
}
// Load theme file
if (isset($USER['theme']) && !strstr($USER['theme'], '/') && is_dir('themes/' . $USER['theme'])) {
$CONFIG['theme'] = strtr($USER['theme'], '$/\\:*?"\'<>|`', '____________');
} else {
unset($USER['theme']);
}
Si vous ne voulez pas que les visiteurs puissent choisir eux-même le thème (en ajoutant &theme=blabla à la fin de l'URL), supprimez cette section ou mettez-la en commentaire.
Ajoutez avant
// Looks if there's a sub-theme for that category
if (!empty($_GET['cat'])) {
$result = cpg_db_query("SELECT parent,theme FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '{$_GET['cat']}'");
$row = mysql_fetch_array($result);
if (!empty($row['theme']) && !isset($theme_temp))
$theme_temp = $row['theme'];
mysql_free_result($result);
while($row['parent'] != 0)
{
$result = cpg_db_query("SELECT parent,theme FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '{$row['parent']}'");
$row = mysql_fetch_array($result);
mysql_free_result($result);
if (isset($row['theme']) && !isset($theme_temp))
$theme_temp = $row['theme'];
} // while
if (isset($theme_temp))
$CONFIG['theme'] = $theme_temp;
}
// Looks if there's a sub-theme for that album
if (!empty($_GET['album'])) {
$result = cpg_db_query("SELECT category FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '{$_GET['album']}'");
$row = mysql_fetch_array($result);
mysql_free_result($result);
$row['parent'] = $row['category'];
while($row['parent'] != 0)
{
$result = cpg_db_query("SELECT parent,theme FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '{$row['parent']}'");
$row = mysql_fetch_array($result);
mysql_free_result($result);
if (isset($row['theme']) && !isset($theme_temp))
$theme_temp = $row['theme'];
} // while
if (isset($theme_temp))
$CONFIG['theme'] = $theme_temp;
}
<coppermine>/catmgr.php
Trouvez
function display_cat_list() {
Ajoutez avant
function form_sub_theme() {
global $CONFIG, $lang_catmgr_php, $current_category;
$theme_dir = 'themes/';
$dir = opendir($theme_dir);
while ($file = readdir($dir)) {
if (is_dir($theme_dir . $file) && $file != "." && $file != "..") {
$theme_array[] = $file;
}
}
closedir($dir);
natcasesort($theme_array);
echo <<<EOT
<tr>
<td class="tableb" width="60%">
{$lang_catmgr_php['cat_theme']}
</td>
<td class="tableb" valign="top">
<select name="theme" class="listbox">
EOT;
echo " <option value=\"\"></option>\n";
foreach ($theme_array as $theme) {
echo " <option value=\"$theme\" " . ($theme == $current_category['theme'] ? 'selected="selected"' : '') . ">" . strtr(ucfirst($theme), '_', ' ') . "</option>\n";
}
echo <<<EOT
</select>
</td>
</tr>
EOT;
}
Trouvez
$current_category = array('cid' => '0', 'name' => '', 'parent' => '0', 'description' => '');
Remplacez par
$current_category = array('cid' => '0', 'name' => '', 'parent' => '0', 'description' => '', 'theme' => '');
Trouvez
$result = cpg_db_query("SELECT cid, name, parent, description, thumb FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cid' LIMIT 1");
Remplacez par
$result = cpg_db_query("SELECT cid, name, parent, description, thumb, theme FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cid' LIMIT 1");
Trouvez 2 fois
if (!isset($_POST['cid']) || !isset($_POST['parent']) || !isset($_POST['name']) || !isset($_POST['description']))
Remplacez par
if (!isset($_POST['cid']) || !isset($_POST['parent']) || !isset($_POST['name']) || !isset($_POST['description']) || !isset($_POST['theme']))
Trouvez 2 fois
$description = addslashes($_POST['description']);
Ajoutez après
$theme = addslashes($_POST['theme']);
Trouvez
cpg_db_query("UPDATE {$CONFIG['TABLE_CATEGORIES']} SET parent='$parent', name='$name', description='$description', thumb='$thumb' WHERE cid = '$cid' LIMIT 1");
}else{
cpg_db_query("UPDATE {$CONFIG['TABLE_CATEGORIES']} SET name='$name', description='$description', thumb='$thumb' WHERE cid = '$cid' LIMIT 1");
Remplacez par
cpg_db_query("UPDATE {$CONFIG['TABLE_CATEGORIES']} SET parent='$parent', name='$name', description='$description', thumb='$thumb', theme='$theme' WHERE cid = '$cid' LIMIT 1");
}else{
cpg_db_query("UPDATE {$CONFIG['TABLE_CATEGORIES']} SET name='$name', description='$description', thumb='$thumb', theme='$theme' WHERE cid = '$cid' LIMIT 1");
Trouvez
cpg_db_query("INSERT INTO {$CONFIG['TABLE_CATEGORIES']} (pos, parent, name, description) VALUES ('10000', '$parent', '$name', '$description')");
Remlacez par
cpg_db_query("INSERT INTO {$CONFIG['TABLE_CATEGORIES']} (pos, parent, name, description, theme) VALUES ('10000', '$parent', '$name', '$description', '$theme')");
Trouvez
form_alb_thumb();
Ajoutez avant
form_sub_theme();
<coppermine>/lang/french.php (et toutes les langues qui sont utilisées par des administrateurs)
Trouvez
'cat_desc' => 'Description de la catégorie',
Ajoutez après
'cat_theme' => 'Thème de la catégorie',
Et voilà !