function debut_cadre($style, $icone = "", $fonction = "", $titre = "", $id = "", $class = "", $padding = true) { $style_mapping = array('r' => 'simple', 'e' => 'raccourcis', 'couleur' => 'basic highlight', 'couleur-foncee' => 'basic highlight', 'trait-couleur' => 'important', 'alerte' => 'notice', 'info' => 'info', 'sous_rub' => 'simple sous-rub'); $style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section'); $c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple'; $class = $c . ($class ? " {$class}" : ""); if (!$padding) { $class .= ($class ? " " : "") . "no-padding"; } //($id?"id='$id' ":"") if (strlen($icone) > 1) { if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { list($fond, $fonction) = $icone_renommer($icone, $fonction); } $size = 24; if (preg_match("/-([0-9]{1,3})[.](gif|png)\$/i", $fond, $match)) { $size = $match[1]; } if ($fonction) { // 2 images pour composer l'icone : le fond (article) en background, // la fonction (new) en image $icone = http_img_pack($fonction, "", "class='cadre-icone' width='{$size}' height='{$size}'\n" . http_style_background($fond, "no-repeat center center")); } else { $icone = http_img_pack($fond, "", "class='cadre-icone' width='{$size}' height='{$size}'"); } $titre = $icone . $titre; } return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id); }
function puce_statut_auteur_dist($id, $statut, $id_rubrique, $type, $ajax='') { static $titre_des_statuts =''; static $images_des_statuts =''; // eviter de retraduire a chaque appel if (!$titre_des_statuts) { $titre_des_statuts = array( "info_administrateurs" => _T('titre_image_administrateur'), "info_redacteurs" => _T('titre_image_redacteur_02'), "info_visiteurs" => _T('titre_image_visiteur'), "info_statut_site_4" => _T('titre_image_auteur_supprime') ); $images_des_statuts = array( "info_administrateurs" => 'admin-12.gif', "info_redacteurs" =>'redac-12.gif', "info_visiteurs" => 'visit-12.gif', "info_statut_site_4" => 'poubelle.gif' ); } if ($statut == 'nouveau') return ''; $index = array_search($statut, $GLOBALS['liste_des_statuts']); if (!$index) $index = 'info_visiteurs'; $img = $images_des_statuts[$index]; $alt = $titre_des_statuts[$index]; if ($type != 'auteur') { $img2 = "croix-rouge.gif"; $titre = _T('titre_image_redacteur'); $fond = http_style_background($img2, 'top right no-repeat; padding-right: 4px'); } else {$fond = ''; $titre = $alt;} return http_img_pack($img, $alt, $fond, $titre); }
/** * Fonction de base pour une icone dans un squelette * structure html : <span><a><img><b>texte</b></span> * * @param string $type * 'lien' ou 'bouton' * @param string $lien * url * @param string $texte * texte du lien / alt de l'image * @param string $fond * objet avec ou sans son extension et sa taille (article, article-24, article-24.png) * @param string $fonction * new/del/edit * @param string $class * classe supplementaire (horizontale, verticale, ajax ...) * @param string $javascript * "onclick='...'" par exemple * @return string */ function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class = "", $javascript = "") { if (in_array($fonction, array("del", "supprimer.gif"))) { $class .= ' danger'; } elseif ($fonction == "rien.gif") { $fonction = ""; } elseif ($fonction == "delsafe") { $fonction = "del"; } // remappage des icone : article-24.png+new => article-new-24.png if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) { list($fond, $fonction) = $icone_renommer($fond, $fonction); } // ajouter le type d'objet dans la class de l'icone $class .= " " . substr(basename($fond), 0, -4); $alt = attribut_html($texte); $title = " title=\"{$alt}\""; // est-ce pertinent de doubler le alt par un title ? $ajax = ""; if (strpos($class, "ajax") !== false) { $ajax = "ajax"; if (strpos($class, "preload") !== false) { $ajax .= " preload"; } if (strpos($class, "nocache") !== false) { $ajax .= " nocache"; } $ajax = " class='{$ajax}'"; } $size = 24; if (preg_match("/-([0-9]{1,3})[.](gif|png)\$/i", $fond, $match)) { $size = $match[1]; } if ($fonction) { // 2 images pour composer l'icone : le fond (article) en background, // la fonction (new) en image $icone = http_img_pack($fonction, $alt, "width='{$size}' height='{$size}'\n" . http_style_background($fond)); } else { $icone = http_img_pack($fond, $alt, "width='{$size}' height='{$size}'"); } if ($type == 'lien') { return "<span class='icone s{$size} {$class}'>" . "<a href='{$lien}'{$title}{$ajax}{$javascript}>" . $icone . "<b>{$texte}</b>" . "</a></span>\n"; } else { return bouton_action("{$icone}<b>{$texte}</b>", $lien, "icone s{$size} {$class}", $javascript, $alt); } }
function statistiques_par_mois($entrees, $script){ $maxgraph = maxgraph(max($entrees)); $rapport = 200/$maxgraph; $largeur = floor(420 / (count($entrees))); if ($largeur < 1) $largeur = 1; if ($largeur > 50) $largeur = 50; $decal = 0; $tab_moyenne = array(); $all = ''; foreach($entrees as $key=>$value) { $key = substr($key,0,4).'-'.substr($key,4,2); $mois = affdate_mois_annee($key); if ($decal == 30) $decal = 0; $decal ++; $tab_moyenne[$decal] = $value; $moyenne = statistiques_moyenne($tab_moyenne); $hauteur_moyenne = round($moyenne * $rapport) - 1; $hauteur = round($value * $rapport) - 1; $res = ''; $title= attribut_html(supprimer_tags("$mois | " ._T('info_total')." ".$value)); $tagtitle = $script ? '' : $title; if ($hauteur > 0){ if ($hauteur_moyenne > $hauteur) { $difference = ($hauteur_moyenne - $hauteur) -1; $res .= http_img_rien($largeur, 1, 'trait_moyen'); $res .= http_img_rien($largeur, $difference, '', $tagtitle); $res .= http_img_rien($largeur,1,"trait_haut"); if (preg_match(",-01,",$key)){ // janvier en couleur foncee $res .= http_img_rien($largeur,$hauteur,"couleur_janvier", $tagtitle); } else { $res .= http_img_rien($largeur,$hauteur,"couleur_mois", $tagtitle); } } else if ($hauteur_moyenne < $hauteur) { $difference = ($hauteur - $hauteur_moyenne) -1; $res .= http_img_rien($largeur,1,"trait_haut", $tagtitle); if (preg_match(",-01,",$key)){ // janvier en couleur foncee $couleur = 'couleur_janvier'; } else { $couleur = 'couleur_mois'; } $res .= http_img_rien($largeur,$difference, $couleur, $tagtitle); $res .= http_img_rien($largeur,1,'trait_moyen',$tagtitle); $res .= http_img_rien($largeur,$hauteur_moyenne, $couleur, $tagtitle); } else { $res .= http_img_rien($largeur,1,"trait_haut", $tagtitle); if (preg_match(",-01,",$key)){ // janvier en couleur foncee $res .= http_img_rien($largeur, $hauteur, "couleur_janvier", $tagtitle); } else { $res .= http_img_rien($largeur,$hauteur, "couleur_mois", $tagtitle); } } } $res .= http_img_rien($largeur,1,'trait_bas', $tagtitle); if (!$script) { $y = annee($key); $m = mois($key); $href = generer_url_ecrire('calendrier', "type=mois&annee=$y&mois=$m&jour=1"); } else $href = "$script&date=$key"; $all .= "\n<td style='width: ${largeur}px'><a href='" . $href . '\' title="' . $title . '">' . $res . "</a></td>\n"; } return "\n<table cellpadding='0' cellspacing='0' border='0'><tr>" . "\n<td ".http_style_background("fond-stats.gif").">" . "\n<table cellpadding='0' cellspacing='0' border='0' class='bottom'><tr>" . "\n<td class='trait_bas'>" . http_img_rien(1, 200) ."</td>" . $all . "\n<td style='background-color: black'>" . http_img_rien(1, 1) . "</td>" . "</tr></table></td>" . "\n<td ".http_style_background("fond-stats.gif")." valign='bottom'>" . http_img_rien(3, 1, 'trait_bas') ."</td>" . "\n<td>" . http_img_rien(5, 1) ."</td>" . "\n<td valign='top'>" . statistiques_echelle($maxgraph) . "</td></tr></table>"; }
$page = assembler($fond, _request('connect')); if (isset($page['status'])) { include_spip('inc/headers'); http_status($page['status']); } // Content-Type ? if (!isset($page['entetes']['Content-Type'])) { $page['entetes']['Content-Type'] = "text/html; charset=" . $GLOBALS['meta']['charset']; $html = true; } else { $html = preg_match(',^\\s*text/html,', $page['entetes']['Content-Type']); } if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $html) { include_spip('inc/filtres'); // pour http_img_pack $x = "<div class='spip-previsu' " . http_style_background('preview-32.png') . ">" . _T('previsualisation') . "</div>"; if (!($pos = strpos($page['texte'], '</body>'))) { $pos = strlen($page['texte']); } $page['texte'] = substr_replace($page['texte'], $x, $pos, 0); } // Tester si on est admin et il y a des choses supplementaires a dire // type tableau pour y mettre des choses au besoin. $debug = (_request('var_mode') == 'debug' or $tableau_des_temps) ? array(1) : array(); $affiche_boutons_admin = ($html and (isset($_COOKIE['spip_admin']) and (!isset($flag_preserver) or !$flag_preserver) or $debug)); if ($affiche_boutons_admin) { include_spip('balise/formulaire_admin'); } // Execution de la page calculee // traitements sur les entetes avant envoi // peut servir pour le plugin de stats
function http_calendrier_rv($messages, $type) { $total = $date_rv = ''; if (!$messages) return $total; $connect_quand = $GLOBALS['visiteur_session']['quand']; foreach ($messages as $row) { $rv = ($row['location'] == 'oui'); $date = $row['dtstart']; $date_fin = $row['dtend']; if ($row['category']=="pb") $bouton = "pense-bete"; else if ($row['category']=="affich") $bouton = "annonce"; else $bouton = "message"; if ($rv) { $date_jour = affdate_jourcourt($date); $total .= "<tr><td colspan='2'>" . (($date_jour == $date_rv) ? '' : "\n<div class='calendrier-arial11'><b>$date_jour</b></div>") . "</td></tr>"; $date_rv = $date_jour; $rv = ((affdate($date) == affdate($date_fin)) ? ("\n<div class='calendrier-arial9 fond-agenda'>" . heures($date).":".minutes($date)."<br />" . heures($date_fin).":".minutes($date_fin)."</div>") : ( "\n<div class='calendrier-arial9 fond-agenda' style='text-align: center;'>" . heures($date).":".minutes($date)."<br />...</div>" )); } $c = (strtotime($date) <= $connect_quand) ? '' : " color: red;"; $total .= "<tr><td style='width: 24px' valign='middle'>" . http_href($row['url'], ($rv ? http_img_pack("rv.gif", 'rv', http_style_background($bouton . '.gif', "no-repeat;")) : http_img_pack($bouton.".gif", $bouton, ""))) . "</td>\n" . "<td valign='middle'><div style='font-weight: bold;$c'>" . $rv . http_href($row['url'], typo($row['summary']), '', '', 'calendrier-verdana') . "</div></td></tr>"; } if ($type == 'annonces') { $titre = _T('info_annonces_generales'); } else if ($type == 'pb') { $titre = _T('infos_vos_pense_bete'); } else if ($type == 'rv') { $titre = _T('info_vos_rendez_vous'); } return debut_cadre_enfonce("", true, "", $titre) . "\n<table>" . $total . "</table>" . fin_cadre_enfonce(true); }
/** * Insérer au besoin les boutons admins * * Cette fonction est appelée par le pipeline affichage_final * * @param string $texte Contenu de la page envoyée au navigateur * @return string Contenu de la page envoyée au navigateur **/ function f_admin($texte) { if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) { include_spip('inc/filtres'); // pour http_img_pack $x = "<div class='spip-previsu' " . http_style_background('preview-32.png') . ">" . _T('previsualisation') . "</div>"; if (!($pos = stripos($texte, '</body>'))) { $pos = strlen($texte); } $texte = substr_replace($texte, $x, $pos, 0); } if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { include_spip('public/admin'); $texte = affiche_boutons_admin($texte); } if (_request('var_mode') == 'noajax') { $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte); } return $texte; }
/** * un filtre icone mappe sur icone_inline, qui cree une icone a gauche par defaut * le code de icone_inline est grandement reproduit ici car les liens ajax portent simplement une class ajax * lorsque les interfaces sont en squelette, alors que l'implementation d'ajax de des scripts php * est plus complexe * * @param string $lien * @param string $texte * @param string $fond * @param string $align * @param string $fonction * @return string */ function filtre_icone_dist($lien, $texte, $fond, $align="", $fonction="", $class="",$javascript=""){ $align = $align?$align:$GLOBALS['spip_lang_left']; global $spip_display; if ($fonction == "supprimer.gif") { $style = 'icone36 danger'; } else { $style = 'icone36'; if (strlen($fonction) < 3) $fonction = "rien.gif"; } $style .= " " . substr(basename($fond),0,-4); if ($spip_display == 1){ $hauteur = 20; $largeur = 100; $title = $alt = ""; } else if ($spip_display == 3){ $hauteur = 30; $largeur = 30; $title = "\ntitle=\"$texte\""; $alt = $texte; } else { $hauteur = 70; $largeur = 100; $title = ''; $alt = $texte; } $size = 24; if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i",$fond,$match)) $size = $match[1]; if ($spip_display != 1 AND $spip_display != 4){ if ($fonction != "rien.gif"){ $icone = http_img_pack($fonction, $alt, "$title width='$size' height='$size'\n" . http_style_background($fond, "no-repeat center center")); } else { $icone = http_img_pack($fond, $alt, "$title width='$size' height='$size'"); } } else $icone = ''; // cas d'ajax_action_auteur: faut defaire le boulot // (il faudrait fusionner avec le cas $javascript) if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i",$lien,$r)) list($x,$lien,$atts,$texte)= $r; else $atts = ''; if ($align && $align!='center') $align = "float: $align; "; $icone = "<a style='$align' class='$style $class'" . $atts . $javascript . "\nhref='" . $lien . "'>" . $icone . (($spip_display == 3) ? '' : "<span>$texte</span>") . "</a>\n"; if ($align <> 'center') return $icone; $style = " style='text-align:center;'"; return "<div$style>$icone</div>"; }
function icone_bandeau_principal($detail, $lien, $rubrique_icone = "vide", $rubrique = "", $lien_noscript = "", $sous_rubrique_icone = "", $sous_rubrique = "",$largeur,$decal){ global $spip_display, $menu_accesskey, $compteur_survol; $alt = $accesskey = $title = ''; $texte = _T($detail->libelle); if ($spip_display == 3){ $title = " title=\"$texte\""; } if (!$menu_accesskey = intval($menu_accesskey)) $menu_accesskey = 1; if ($menu_accesskey < 10) { $accesskey = " accesskey='$menu_accesskey'"; $menu_accesskey++; } else if ($menu_accesskey == 10) { $accesskey = " accesskey='0'"; $menu_accesskey++; } $class_select = " style='width:"._LARGEUR_ICONES_BANDEAU."px' class='menu-item boutons_admin".($sous_rubrique_icone == $sous_rubrique ? " selection" : "")."'"; if (strncasecmp("javascript:",$lien,11)==0) { $a_href = "\nonclick=\"$lien; return false;\" href='$lien_noscript' "; } else { $a_href = "\nhref=\"$lien\""; } $compteur_survol ++; if ($spip_display != 1 AND $spip_display != 4) { $class ='cellule48'; $texte = "<span class='icon_fond'><span".http_style_background($detail->icone)."></span></span>".($spip_display == 3 ? '' : "<span class='icon_texte'>$texte</span>"); } else { $class = 'cellule-texte'; } return "<li style='width: " . _LARGEUR_ICONES_BANDEAU . "px' class='$class boutons_admin'><a$accesskey$a_href$class_select$title onfocus=\"$(this).parent().siblings('li').find('.bandeau_sec').hide();\" onkeypress=\"$(this).siblings('.bandeau_sec').show();\">" . $texte . "</a>\n" . bandeau_principal2($detail->sousmenu,$rubrique, $sous_rubrique, $largeur, $decal) . "</li>\n"; }
function icone_horizontale($texte, $lien, $fond = "", $fonction = "", $af = true, $javascript='') { global $spip_display; $retour = ''; // cas d'ajax_action_auteur: faut defaire le boulot // (il faudrait fusionner avec le cas $javascript) if (preg_match(",^<a href='([^']*)'([^>]*)>(.*)</a>$,i",$lien,$r)) list($x,$lien,$atts,$texte)= $r; else $atts = ''; $lien = "\nhref='$lien'$atts"; if ($spip_display != 4) { if ($spip_display != 1) { $retour .= "\n<table class='cellule-h-table' cellpadding='0' style='vertical-align: middle'>" . "\n<tr><td><a $javascript$lien class='cellule-h'>" . "<span class='cell-i'>" ; if ($fonction){ $retour .= http_img_pack($fonction, $texte, http_style_background($fond, "center center no-repeat")); } else { $retour .= http_img_pack($fond, $texte, ""); } $retour .= "</span></a></td>" . "\n<td class='cellule-h-lien'><a $javascript$lien class='cellule-h'>" . $texte . "</a></td></tr></table>\n"; } else { $retour .= "\n<div><a class='cellule-h-texte' $javascript$lien>$texte</a></div>\n"; } if ($fonction == "supprimer.gif") $retour = "\n<div class='danger'>$retour</div>"; } else { $retour = "\n<li><a$lien>$texte</a></li>"; } if ($af) echo_log('icone_horizontale',$retour); else return $retour; }
function presenter_message_boucles($row, $afficher_auteurs) { global $connect_id_auteur, $spip_lang_left, $spip_lang_rtl; $vals = array(); $id_message = $row['id_message']; $date = $row["date_heure"]; $date_fin = $row["date_fin"]; $titre = sinon($row['titre'], _T('ecrire:info_sans_titre')); $type = $row["type"]; $rv = $row["rv"]; // // Titre // $s = "<a href='" . generer_url_ecrire("message","id_message=$id_message") . "' style='display: block;'>"; switch ($type) { case 'pb' : $puce = "m_envoi_bleu$spip_lang_rtl.gif"; break; case 'memo' : $puce = "m_envoi_jaune$spip_lang_rtl.gif"; break; case 'affich' : $puce = "m_envoi_jaune$spip_lang_rtl.gif"; break; case 'normal': default: $puce = "m_envoi$spip_lang_rtl.gif"; break; } $s .= http_img_pack("$puce", "", "width='14' height='7'"); $s .= " ".typo($titre)."</a>"; $vals[] = $s; // // Auteurs if ($afficher_auteurs) { $result_auteurs = sql_select("auteurs.id_auteur, auteurs.nom", "spip_auteurs AS auteurs, spip_auteurs_messages AS lien", "lien.id_message=$id_message AND lien.id_auteur!=$connect_id_auteur AND lien.id_auteur=auteurs.id_auteur"); $auteurs = ''; while ($row_auteurs = sql_fetch($result_auteurs)) { $id_auteur = $row_auteurs['id_auteur']; $auteurs[] = "<a href='" . generer_url_ecrire("auteur_infos","id_auteur=$id_auteur") . "'>".typo($row_auteurs['nom'])."</a>"; } if ($auteurs AND $type == 'normal') { $s = "<span class='arial1 spip_x-small'>" . join(', ', $auteurs) . "</span>"; } else $s = " "; $vals[] = $s; } // // Messages de forums $total_forum = sql_countsel('spip_forum', "id_message=$id_message"); if ($total_forum > 0) $vals[] = "($total_forum)"; else $vals[] = ""; // // Date // $s = affdate($date); if ($rv == 'oui') { $jour=journum($date); $mois=mois($date); $annee=annee($date); $heure = heures($date).":".minutes($date); if (affdate($date) == affdate($date_fin)) $heure_fin = heures($date_fin).":".minutes($date_fin); else $heure_fin = "..."; $s = "<div " . http_style_background('rv-12.gif', "$spip_lang_left center no-repeat; padding-$spip_lang_left: 15px") . "><a href='" . generer_url_ecrire("calendrier","type=jour&jour=$jour&mois=$mois&annee=$annee") . "'><b style='color: black;'>$s</b><br />$heure-$heure_fin</a></div>"; } else { $s = "<span style='color: #999999'>$s</span>"; } $vals[] = $s; return $vals; }
function http_calendrier_rv($messages, $type) { global $lcm_lang_rtl; $total = ''; if (!$messages) { return $total; } foreach ($messages as $row) { if (preg_match("/^=([^[:space:]]+)\$/", $row['texte'], $match)) { $url = $match[1]; } else { $url = "message.php3?id_message=" . $row['id_message']; } $rv = $row['rv'] == 'oui'; $date = $row['date_heure']; $date_fin = $row['date_fin']; if ($row['type'] == "pb") { $bouton = "pense-bete"; } else { if ($row['type'] == "annonces") { $bouton = "annonce"; } else { $bouton = "message"; } } if ($rv) { $date_jour = affdate_jourcourt($date); $total .= "<tr><td colspan='2'>" . ($date_jour == $date_rv ? '' : "<div><b>{$date_jour}</b></div>") . "</td></tr>"; } $total .= "<tr><td width='24' valign='middle'>" . http_href($url, $rv ? http_img_pack("rv.gif", '', http_style_background($bouton . '.gif', "no-repeat;' border='0'")) : http_img_pack("{$bouton}.gif", '', "border='0'"), '', '') . "</td>" . "<td valign='middle'>" . (!$rv ? '' : (affdate($date) == affdate($date_fin) ? "<div style='font-size: 9px;'" . http_style_background('fond-agenda.gif', "right center no-repeat; float: left; line-height: 12px; color: #666666; margin-right: 3px; padding-right: 4px;") . heures($date) . ":" . minutes($date) . "<br />" . heures($date_fin) . ":" . minutes($date_fin) . "</div>" : "<div style='font-size: 9px;'" . http_style_background('fond-agenda.gif', "right center no-repeat; float: left; line-height: 12px; color: #666666; margin-right: 3px; padding-right: 4px; text-align: center;") . heures($date) . ":" . minutes($date) . "<br />...</div>")) . "<div><b>" . http_href($url, typo($row['titre']), '', 'font-size: 10px;') . "</b></div>" . "</td>" . "</tr>\n"; $date_rv = $date_jour; } if ($type == 'annonces') { $titre = _T('info_annonces_generales'); $couleur_titre = "ccaa00"; $couleur_texte = "black"; $couleur_fond = "#ffffee"; } else { if ($type == 'pb') { $titre = _T('infos_vos_pense_bete'); $couleur_titre = "#3874B0"; $couleur_fond = "#EDF3FE"; $couleur_texte = "white"; } else { if ($type == 'rv') { $titre = _T('info_vos_rendez_vous'); $couleur_titre = "#666666"; $couleur_fond = "#eeeeee"; $couleur_texte = "white"; } } } return debut_cadre_enfonce("", true, "", $titre) . "<table width='98%' border='0' cellpadding='0' cellspacing='2'>" . $total . "</table>" . fin_cadre_enfonce(true); }