/*
keywords handler
*/
function split_date($d){
$ret["year"] = 0 + substr($d,0,4);
$ret["month"] = 0 + substr($d,5,2);
$ret["day"] = 0 + substr($d,8,2);
return $ret;
}
if(isset($_GET["k"])){
?>
$mon = array(
1 => "enero",
2 => "febrero",
3 => "marzo",
4 => "abril",
5 => "mayo",
6 => "junio",
7 => "julio",
8 => "agosto",
9 => "septiembre",
10 => "octubre",
11 => "noviembre",
12 => "diciembre"
);
$sql = "select a.id, a.titulo, a.fecha, c.nombre from blog_articles as a, blog_categories as c ";
$sql .= "where (tipo = 1 or tipo = 2) and a.categoria = c.id and ";
$sql .= "(a.keywords like '% ".$_GET['k']." %' or a.keywords like '".$_GET['k']." %' or a.keywords like '% ".$_GET['k']."')";
$sql .= "group by a.id order by fecha desc, hora desc";
$res = mysql_query($sql);
if(mysql_affected_rows() == 0){
echo "| No hay entradas publicas con ".$_GET['k']." como tag |
";
}else{
$month = "";
while($row = mysql_fetch_array($res)){
$date = split_date($row[2]);
if($date["month"]!=$month){
echo "
";
$month = $date["month"];
}
$sql1 = "select count(id) from blog_coments where article = $row[0] group by article";
$res1 = mysql_query($sql1);
$row1 = mysql_fetch_array($res1);
echo "
";
}
}
?>
}else{
$max_font = 45;
$min_font = 15;
$kw = array();
$keys = array();
$sql = "select keywords from blog_articles where keywords <> ''";
$res = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($res)){
$art_keys = explode(" ",$row['keywords']);
foreach($art_keys as $key){
if(isset($kw[$key])){
$kw[$key]++;
}else{
$kw[$key] = 1;
$keys[count($keys)] = $key;
}
}
}
?>
Estas son los tags que hay actualmente, al pasar el mouse por encima de cada uno
aparece el numero de posts que contienen tal tag.
//se ordena alfabeticamente el arreglo de nombres de llaves
sort($keys);
//se determina la maxima y minima repeticion de tags
$max = max($kw);
$min = min($kw);
//se deterina el paso de cada fuente
$step = round($max_font - $min_font)/($max - $min);
$step = $step < 1?1:$step;
$i = 0;
foreach($keys as $key){
$size = (($kw[$key] - $min)*$step) + $min_font;
$size = ($size > $max_font)?$max_font:$size;
echo "".$key." ";
}
}
?>