David
dimanche 21 août 2005 à 16:54
Voici un addon fait par BLC29 pour etendre au bloc de statistique
tout d'abord creer le fichier skin pour l'addon
(j'ai créé un fichier skin add-on car les preg_replace et autre je comprends rien

et qu'en essayant de rajouter la fonction dans le skin addon déjà existant j'ai des erreurs)
1/ code du fichier : mod_collapsestat_skin.php
CODE
<?
class mod_collapsestat_skin {
function StatHeader_Expanded_Show($Data) {
global $ibforums;
return <<<EOF
<!-- Board Stats -->
<!--IBF.QUICK_LOG_IN-->
<br />
<div align='center'>
<a href='{$ibforums->base_url}act=Stats&CODE=leaders'>{$ibforums->lang['sm_forum_leaders']}</a> |
<a href='{$ibforums->base_url}act=Search&CODE=getactive'>{$ibforums->lang['sm_todays_posts']}</a> |
<a href='{$ibforums->base_url}act=Stats'>{$ibforums->lang['sm_today_posters']}</a> |
<a href='{$ibforums->base_url}act=Members&max_results=10&sort_key=posts&sort_order=desc'>{$ibforums->lang['sm_all_posters']}</a>
</div>
<br />
<div class="tableborder">
<div class='maintitle'>
<table width="100%">
<tr>
<td align="left">{$ibforums->lang['board_stats']}</td>
<td align="right"><a href="{$Data['collapse_url']}">{$Data['collapse_img']}</a></td>
</tr>
</table>
</div>
<table width="100%" border="0" cellspacing="1" cellpadding="4">
EOF;
}
}
?>
PS: Si vous avez un problème de couleur avec le titre
modifier <td align="left"> en <td style="text-align:left;color: #fff;">
avec color #fff; correpondant à la couleur souhaitée
copier se fichier dans skin/s*/ de tous vos skins
2/ ouvrir le fichier Boards.php2.1 - rechercherCODE
$stats_html = "";
Ajouter au dessus
CODE
//-- mod_collapse begin
$this->use_skin = false;
if (file_exists(ROOT_PATH."Skin/{$ibforums->skin_id}/mod_collapsestat_skin.php")) {
$this->collapse_html = $std->load_template('mod_collapsestat_skin');
$this->use_skin = true;
$this->hide_cats = $std->my_getcookie("collapse");
if (!empty($this->hide_cats)) {
$this->hide_cats = explode(",", $std->my_getcookie("collapse"));
}
else {
$this->hide_cats = array();
}
if (isset($ibforums->input['collapse_s'])) {
$key = array_search($ibforums->input['collapse_s'], $this->hide_cats);
if ($key !== FALSE) {
array_splice($this->hide_cats, $key, 1);
$std->my_setcookie("collapse", implode(",",$this->hide_cats), 1);
}
}
if (isset($ibforums->input['collapse_h'])) {
$key = array_search($ibforums->input['collapse_h'], $this->hide_cats);
if (!$key) {
$this->hide_cats[] = $ibforums->input['collapse_h'];
$std->my_setcookie("collapse", implode(",", $this->hide_cats), 1);
}
}
$url = $ibforums->vars['board_url'].'/index.'.$ibforums->vars['php_ext']."?".$_SERVER['QUERY_STRING'];
$url = preg_replace("`\&collapse_.=stat\d*`", "", $url);
$pic = "<{WARN_ADD}>";
}
$cat_id = 'stat';
$hide_this_cat = in_array($cat_id, $this->hide_cats);
$this->output .= "<a href='' name='col".$cat_id."'></a>";
if ($hide_this_cat) {
$cat_data['collapse_url'] = $url."&collapse_s=".$cat_id."#col".$cat_id;
$cat_data['collapse_img'] = "<{WARN_ADD}>";
$this->output .= $this->collapse_html->StatHeader_Expanded_Show($cat_data);
$this->output .= $this->html->end_this_cat();
}
else {
//-- mod_collapse end
2.2 - rechercherCODE
if ($stats_html != "")
{
ajouter en dessous
CODE
//-- mod_collapse begin
if ($this->use_skin) {
$cat_data['collapse_url'] = $url."&collapse_h=".$cat_id."#col".$cat_id;
$cat_data['collapse_img'] = "<{WARN_MINUS}>";
$this->output .= $this->collapse_html->StatHeader_Expanded_Show($cat_data);
}
else {
//-- mod_collapse end
2.3 - rechercherCODE
$this->output .= $this->html->stats_header();
ajouter en dessous
CODE
//-- mod_collapse begin
}
//-- mod_collapse end
2.4 - rechercherCODE
$this->output .= $stats_html;
ajouter en dessous
CODE
//-- mod_collapse begin
}
//-- mod_collapse end
2.5 - rechercher (ajout de la mod collapse dans la fonction process_all_cats(..) )
CODE
$url = preg_replace("`\&collapse_.=\d*`", "", $url);
$url = preg_replace("`\#col\d*$`", "", $url);
remplacer par
CODE
$url = preg_replace("`\&collapse_.=stat\d*`", "", $url);
$url = preg_replace("`\&collapse_.=\d*`", "", $url);
$url = preg_replace("`\#col\d*`", "", $url);
sauvegardez et uploadez le fichier
C'est fini

Remarque si le fichier de skin est supprimé le bloc de statistique s'affiche comme sans l'addon