ALTER TABLE `phpboost_forum_cats` ADD `icon` VARCHAR( 255 ) NOT NULL AFTER `url` ;
$LANG['icon_forum'] = 'Icône de la catégorie'; $LANG['icon_forum_explain'] = 'A placer dans le répertoire /forum';
$icon = retrieve(POST, 'icon', ''); $icon_path = retrieve(POST, 'icon_path', ''); if (!empty($icon_path)) $icon = $icon_path;
$Sql->query_inject("UPDATE " . PREFIX . "forum_cats SET name = '" . $name . "', subname = '" . $subname . "', url = '" . $url . "', status = '" . $status . "', aprob = '" . $aprob . "', auth = '" . addslashes(serialize($array_auth_all)) . "' WHERE id = '" . $id . "'", __LINE__, __FILE__);
$Sql->query_inject("UPDATE " . PREFIX . "forum_cats SET name = '" . $name . "', subname = '" . $subname . "', url = '" . $url . "', status = '" . $status . "', aprob = '" . $aprob . "', auth = '" . addslashes(serialize($array_auth_all)) . "',icon = '" . $icon . "' WHERE id = '" . $id . "'", __LINE__, __FILE__);
$forum_info = $Sql->query_array(PREFIX . "forum_cats", "id_left", "id_right", "level", "name", "subname", "url", "status", "aprob", "auth", "WHERE id = '" . $id . "'", __LINE__, __FILE__);
$forum_info = $Sql->query_array(PREFIX . "forum_cats", "id_left", "id_right", "level", "name", "subname", "url", "status", "aprob", "auth", "icon", "WHERE id = '" . $id . "'", __LINE__, __FILE__);
$img_direct_path = (strpos($forum_info['icon'], '/') !== false); $rep = './'; $image_list = '<option value=""' . ($img_direct_path ? ' selected="selected"' : '') . '>--</option>'; if (is_dir($rep)) //Si le dossier existe { $img_array = array(); $dh = @opendir( $rep); while (! is_bool($lang = readdir($dh))) { if (preg_match('`\.(gif|png|jpg|jpeg|tiff)+$`i', $lang)) $img_array[] = $lang; //On crée un tableau, avec les different fichiers. } closedir($dh); //On ferme le dossier foreach ($img_array as $key => $img_path) { $selected = $img_path == $forum_info['icon'] ? ' selected="selected"' : ''; $image_list .= '<option value="' . $img_path . '"' . ($img_direct_path ? '' : $selected) . '>' . $img_path . '</option>'; } }
'IMG_ICON' => !empty($forum_info['icon']) ? '<img src="' . $forum_info['icon'] . '" alt="" class="valign_middle" />' : '', 'IMG_LIST' => $image_list, 'IMG_PATH' => $img_direct_path ? $forum_info['icon'] : '', 'L_ICON' => $LANG['icon_forum'], 'L_ICON_EXPLAIN' => $LANG['icon_forum_explain'], 'L_OR_DIRECT_PATH' => $LANG['or_direct_path'],
'L_ICON' => $LANG['icon_forum'], 'L_ICON_EXPLAIN' => $LANG['icon_forum_explain'], 'L_OR_DIRECT_PATH' => $LANG['or_direct_path'],
$icon = retrieve(POST, 'icon', '');
$Sql->query_inject("INSERT INTO " . PREFIX . "forum_cats (id_left, id_right, level, name, subname, url, nbr_topic, nbr_msg, last_topic_id, status, aprob, auth) VALUES('" . $id_left . "', '" . ($id_left + 1) . "', '" . $level . "', '" . $name . "', '" . $subname . "', '" . $url . "', 0, 0, 0, '" . $status . "', '" . $aprob . "', '" . addslashes(serialize($array_auth_all)) . "')", __LINE__, __FILE__);
$Sql->query_inject("INSERT INTO " . PREFIX . "forum_cats (id_left, id_right, level, name, subname, url, nbr_topic, nbr_msg, last_topic_id, status, aprob, auth, icon) VALUES('" . $id_left . "', '" . ($id_left + 1) . "', '" . $level . "', '" . $name . "', '" . $subname . "', '" . $url . "', 0, 0, 0, '" . $status . "', '" . $aprob . "', '" . addslashes(serialize($array_auth_all)) . "')", __LINE__, __FILE__);
$rep = './';//Images disponibles $image_list = ''; if (is_dir($rep)) //Si le dossier existe { $img_array = array(); $dh = @opendir( $rep); while (! is_bool($lang = @readdir($dh))) { if (preg_match('`\.(gif|png|jpg|jpeg|tiff)+$`i', $lang)) $img_array[] = $lang; //On crée un tableau, avec les different fichiers. } @closedir($dh); //On ferme le dossier foreach ($img_array as $key => $img_path) $image_list .= '<option value="' . $img_path . '">' . $img_path . '</option>'; }
'IMG_LIST' => $image_list, 'L_ICON' => $LANG['icon_forum'], 'L_ICON_EXPLAIN' => $LANG['icon_forum_explain'], 'L_OR_DIRECT_PATH' => $LANG['or_direct_path'],
$forum_cats .= '$CAT_FORUM[\'' . $row['id'] . '\'][\'icon\'] = ' . var_export($row['icon'], true) . ';' . "\n";
t.idcat, t.title, t.last_timestamp, t.last_user_id, t.last_msg_id, t.nbr_msg AS t_nbr_msg, t.display_msg, m.user_id, m.login, m.level as user_level, m.user_groups, v.last_view_id
t.idcat, t.title, t.last_timestamp, t.last_user_id, t.last_msg_id, t.nbr_msg AS t_nbr_msg, t.display_msg, m.user_id, m.login, m.level as user_level, m.user_groups, v.last_view_id, c.icon
'ICON' => !empty($row['icon']) ? '<a href="forum' . url('.php?id=' . $row['cid'], '-' . $row['cid'] . '+' . Url::encode_rewrite($row['name']) . '.php') . '"><img src="' . $row['icon'] . '" alt="" class="valign_middle" /></a><br />' : '',
function change_icon(img_path)
{
document.getElementById('icon_img').innerHTML = '<img src="' + img_path + '" alt="" class="valign_middle" />';
}
<div class="form-element"> <label for="icon">{L_ICON}<br /><span class="field-description">{L_ICON_EXPLAIN}</span></label> <div class="form-field"> <label> <select name="icon" id="icon" onchange="change_icon(this.options[this.selectedIndex].value)" onclick="change_icon(this.options[this.selectedIndex].value)"> {IMG_LIST} </select> <span id="icon_img">{IMG_ICON}</span> </label> <br /> <label> <span class="text_small">{L_OR_DIRECT_PATH}</span> <input type="text" class="text" name="icon_path" value="{IMG_PATH}" onblur="if( this.value != '' )change_icon(this.value);" onclick="document.getElementById('img_default_select').selected = 'selected';" /> </label> </div> </div>
function change_icon(img_path)
{
document.getElementById('icon_img').innerHTML = '<img src="' + img_path + '" alt="" class="valign_middle" />';
}
<div class="form-element"> <label for="icon">{L_ICON}<br /><span class="field-description">{L_ICON_EXPLAIN}</span></label> <div class="form-field"> <label> <select name="icon" id="icon" onchange="change_icon(this.options[this.selectedIndex].value)" onclick="change_icon(this.options[this.selectedIndex].value)"> {IMG_LIST} </select> <span id="icon_img">{IMG_ICON}</span> </label> <br /> <label> <span class="text_small">{L_OR_DIRECT_PATH}</span> <input type="text" class="text" name="icon_path" value="{IMG_PATH}" onblur="if( this.value != '' )change_icon(this.value);" onclick="document.getElementById('img_default_select').selected = 'selected';" /> </label> </div> </div>
td.forum-sous-cat-icon { width: 50px; text-align: center; }