Wikini

ActionActiviteProjet

PagePrincipale :: DerniersChangements :: DerniersCommentaires :: ParametresUtilisateur :: Vous êtes ec2-3-92-84-196.compute-1.amazonaws.com
ListeActions

utilise la librairie tooltip.js de walterzorn http://www.walterzorn.com/tooltip/tooltip_e.htm
exemple: http://overcrowded.anoptique.org/VisualisationActiviteProjet

<?php
// ex: {{activiteprojet projet="Autograph" type="dates"}}

if(!defined('ACTIVITY_PLUGIN')) {
    
define("ACTIVITY_PLUGIN","test");
    echo 
"<script type=\"text/javascript\" src=\"/tooltip/tooltip.js\"></script>
<div id=\"tooltip\" style=\"position:absolute; visibility:hidden; z-index:100; background-color:#dedede; border:1px solid black; padding:0.2em; font-size:0.8em;\"></div>"
;
}

//tables wikini
$tp $this->config["table_prefix"]."pages";
$tu $this->config["table_prefix"]."users";
$tl $this->config["table_prefix"]."links";

$verif 0;

if( !
$type $this->getParameter("type") ) {
     echo 
"Veuillez renseigner le paramètre <i>type</i>, les valeurs possibles sont <code>acteurs</code> ou <code>dates</code>."
} else {
    
$verif 1;
}

if( !
$projet $this->getParameter("projet") ) {
     echo 
"Veuillez renseigner le paramètre <i>projet</i>, la valeur doit être un mot contenu dans les noms de pages du projet.";
    
$verif 0;
}
    
if (
$verif == 1
{    
    
//nombre de modifications par dates
    
if ($type == "dates")
    {
        
$query "SELECT DATE_FORMAT(time,'%Y %m %d') as d, COUNT(*) as nb FROM $tp WHERE tag LIKE '%".mysql_escape_string($projet)."%' GROUP BY d ORDER BY d ASC";
        if (
$pages $this->LoadAll($query))
        {
            echo 
"<div style=\"padding:1em;border:1px #000 solid;float:right;font-size:0.8em;margin:1em;background-color:#fff\">";
            foreach (
$pages as $page
            {
                
$h $page['nb'];
                
$title $page['d']."<br/>".$page['nb']." modifications";
                echo 
"<div onmouseover=\"tooltip.show(this)\" onmouseout=\"tooltip.hide(this)\"  style=\"float:left;width:10px;height:".$h."px;background-color:#ff0000;border-right:1px #000 solid;\" title=\"".$title."\"></div>";
            }
            echo 
"<div style=\"clear:both;\"></div>Activité du projet ".$projet."</div>";
        }
    }
    else if(
$type == "acteurs")
    {
        
//nombre de modifications par acteurs
        
$query "SELECT DISTINCT user as auteur, COUNT(*) as nb FROM $tp WHERE tag LIKE '%".mysql_escape_string($projet)."%' GROUP BY user ORDER BY nb DESC";
        if (
$pages $this->LoadAll($query))
        {
            echo 
"<div style=\"padding:1em;border:1px #000 solid;font-size:0.8em;float:right;margin:1em;background-color:#fff\">";
            foreach (
$pages as $page)
            {
                
$h $page['nb'];
                
$title $page['auteur']."<br/>".$page['nb']." modifications";
                echo 
"<div onmouseover=\"tooltip.show(this)\" onmouseout=\"tooltip.hide(this)\"  style=\"float:left;width:10px;height:".$h."px;background-color:#ff0000;border-right:1px #000 solid;\" title=\"".$title."\"></div>";
            }
            echo 
"<div style=\"clear:both;\"></div>Contributeurs du projet ".$projet."</div>";
        }
    }
}
?>


Que représentent ces graphes exactement ? Que fait cette action ? -- DidierLoiseau

<?php
// ex: {{activiteprojet projet="Autograph" type="dates"}}

if(!defined('ACTIVITY_PLUGIN')) {
    
define("ACTIVITY_PLUGIN","test");
    echo 
"<script type=\"text/javascript\" src=\"/wiki_perso/tooltip/tooltip.js\"></script>
<div id=\"tooltip\" style=\"position:absolute; visibility:hidden; z-index:100; background-color:#dedede; border:1px solid black; padding:0.2em; font-size:0.8em;\"></div>"
;
}

//tables wikini
$tp $this->config["table_prefix"]."pages";
$tu $this->config["table_prefix"]."users";
$tl $this->config["table_prefix"]."links";

$verif 0;

if( !
$type $this->getParameter("type") ) {
    echo 
"Veuillez renseigner le paramètre <i>type</i>, les valeurs possibles sont <code>acteurs</code> ou <code>dates</code>."
} else {
    
$verif 1;
}

if( !
$projet $this->getParameter("projet") ) {
    echo 
"Veuillez renseigner le paramètre <i>projet</i>, la valeur doit être un mot contenu dans les noms de pages du projet.";
    
$verif 0;
}
    
if (
$verif == 1
{    
    
//nombre de modifications par dates
    
if ($type == "dates")
    {
        
$query "SELECT DATE_FORMAT(time,'%Y %m %d') as d, COUNT(*) as nb FROM $tp WHERE tag LIKE '%".mysql_escape_string($projet)."%' GROUP BY d ORDER BY d ASC";
        if (
$pages $this->LoadAll($query))
        {
            echo 
"<div style=\"padding: 0 2px 2px;border:1px #000 solid;float:right;font-size:0.8em;margin:0.5em;background-color:#fff\">";
            echo 
"<div style=\"padding: 0 2px 2px;clear:both;font-weight: bold;text-align:center;\">activité du projet &laquo; ".$projet." &raquo;</div>";
            
$pages array_reverse ($pages); //inversion de l'affichage des dates
            
foreach ($pages as $page)
            {
                
$h $page['nb'];
                
$title $page['d']."<br />".$page['nb']." modifications";
                echo 
"<div onmouseover=\"tooltip.show(this)\" onmouseout=\"tooltip.hide(this)\"    style=\"float:left;width:10px;height:".$h."px;background-color:#ff0000;border-right:1px #000 solid;\" title=\"".$title."\"></div>";
            }
            echo 
"</div>";
        }
    }
    else if(
$type == "acteurs")
    {
        
//nombre de modifications par acteurs
        
$query "SELECT DISTINCT user as auteur, COUNT(*) as nb FROM $tp WHERE tag LIKE '%".mysql_escape_string($projet)."%' GROUP BY user ORDER BY nb DESC";
        if (
$pages $this->LoadAll($query))
        {
            echo 
"<div style=\"padding: 0 2px 2px;border:1px #000 solid;font-size:0.8em;float:right;margin:0.5em;background-color:#fff\">";
            echo 
"<div style=\"padding: 0 2px 2px;clear:both;font-weight: bold;text-align:center;\">contributeurs du projet &laquo; ".$projet." &raquo;</div>";
            foreach (
$pages as $page)
            {
                
$h $page['nb'];
                
$title $page['auteur']."<br />".$page['nb']." modifications";
                echo 
"<div onmouseover=\"tooltip.show(this)\" onmouseout=\"tooltip.hide(this)\"    style=\"float:left;width:10px;height:".$h."px;background-color:#ff0000;border-right:1px #000 solid;\" title=\"".$title."\"></div>";
            }
            echo 
"</div>";
        }
    }
}
?>
contient une modif dans la présentation et l'inversion de l'affichage des pages avec l'option date pour mettre en premier les dates les plus récentes ($pages = array_reverse ($pages);) --Xf75013?

Fichier "tooltip.js" qui fonctionne :
/**
 *
 * Can show a tooltip over an element
 * Content of tooltip is the title attribute value of the element
 * copyright 2004 Laurent Jouanneau. http://ljouanneau.com/soft/javascript
 * release under LGPL Licence
 * works with dom2 compliance browser, and IE6. perhaps IE5 or IE4.. not Nestcape 4
 *
 * To use it :
 * 1.include this script on your page
 * 2.insert this element somewhere in your page
 *       <div id="tooltip"></div>
 * 3. style it in your CSS stylesheet (set color, background etc..). You must set
 * this two style too :
 *     div#tooltip { position:absolute; visibility:hidden; ... }
 * 4.the end. test it ! :-)
 *
 */


// create the tooltip object
function tooltip(){}

// setup properties of tooltip object
tooltip.id="tooltip";
tooltip.offsetx = 10;
tooltip.offsety = 10;
tooltip.x = 0;
tooltip.y = 0;
tooltip.snow = 0;
tooltip.tooltipElement=null;
tooltip.title_saved='';
tooltip.saveonmouseover=null;
tooltip.ie4 = (document.all)? true:false;		// check if ie4
tooltip.ie5 = false;
if(tooltip.ie4) tooltip.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0 || navigator.userAgent.indexOf('MSIE 6')>0);
tooltip.dom2 = ((document.getElementById) && !(tooltip.ie4||tooltip.ie5))? true:false; // check the W3C DOM level2 compliance. ie4, ie5, ns4 are not dom level2 compliance !! grrrr >:-(


/**
* Open ToolTip. The title attribute of the htmlelement is the text of the tooltip
* Call this method on the mouseover event on your htmlelement
* ex :  <div id="myHtmlElement" onmouseover="tooltip.show(this)"...></div>
*/
tooltip.show = function (htmlelement) {

   if ( this.ie4 || this.dom2 ) {
      // we save text of title attribute to avoid the showing of tooltip generated by browser
      text=htmlelement.getAttribute("title");
      this.title_saved=text;
      htmlelement.setAttribute("title","");
   }
	if(this.dom2){
		this.tooltipElement = document.getElementById(this.id);
      this.saveonmouseover=document.onmousemove;
		document.onmousemove = this.mouseMove;
	}else if ( this.ie4 ) {
      this.tooltipElement = document.all[this.id].style;
      this.saveonmouseover=document.onmousemove;
      document.onmousemove = this.mouseMove;
	}

   if ( this.ie4 || this.dom2 ) {
      if(this.ie4) document.all[this.id].innerHTML = text;
      else if(this.dom2) document.getElementById(this.id).innerHTML=text;

      this.moveTo(this.x + this.offsetx , this.y + this.offsety);

      if(this.ie4) this.tooltipElement.visibility = "visible";
      else if(this.dom2) this.tooltipElement.style.visibility ="visible";
   }
   return false;
}

/**
* hide tooltip
* call this method on the mouseout event of the html element
* ex : <div id="myHtmlElement" ... onmouseout="tooltip.hide(this)"></div>
*/
tooltip.hide = function (htmlelement) {
	if ( this.ie4 || this.dom2 ) {
      htmlelement.setAttribute("title",this.title_saved);
      this.title_saved="";

		if(this.ie4) this.tooltipElement.visibility = "hidden";
      else if(this.dom2) this.tooltipElement.style.visibility = "hidden";

      document.onmousemove=this.saveonmouseover;
	}
}



// Moves the tooltip element
tooltip.mouseMove = function (e) {
   // we don't use "this", but tooltip because this method is assign to an event of document
   // and so is dreferenced

   if(tooltip.ie4 || tooltip.dom2){

      if(tooltip.dom2){
         tooltip.x = e.pageX;
         tooltip.y = e.pageY;
      }else{
         if(tooltip.ie4) { tooltip.x = event.x; tooltip.y = event.y; }
         if(tooltip.ie5) { tooltip.x = event.x + document.body.scrollLeft;
               tooltip.y = event.y + document.body.scrollTop; }
      }
      tooltip.moveTo( tooltip.x +tooltip.offsetx , tooltip.y + tooltip.offsety);
   }
}

// Move the tooltip element
tooltip.moveTo = function (xL,yL) {
	if(this.dom2){
		this.tooltipElement.style.left = xL +"px";
      this.tooltipElement.style.top = yL +"px";
	}else if(this.ie4){
      this.tooltipElement.left = xL;
      this.tooltipElement.top = yL;
   }
}
(remarque : dommage que les fonctionnalités de "geshi" ne soient pas implantées pour tous les langages ici du javascript).
Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]