[Jaws-project-developers] Parche del blog para agregar links a glossary
Status: Alpha
Brought to you by:
ionmx
|
From: Jordi <jo...@jo...> - 2003-11-26 18:09:42
|
Lo que hace este parche es limpiar el contenido de signos de puntuación (, .
! etc) y compara cada palabra con la tabla term, si encuentra coicidencia
cambia esa ocurrencia de "palabra" en $content y genera el link, pero en vez
de utilizar glossary.php...&term=termino tuve que hacer
glossary.php...&term_id=term.id asi que también modifique glossary.php
La bronca que encontré fue que al hacer el
link a glossary.php si ponías dos veces el mismo término que estaba en la
tabla term pues era algo como term=jordi entonces esta madre volvia a
sustituir ese jordi por <a href=...term=jordi y lo volvía a hacer... así y
se
hacía un desmadre
entonces también le metí mano a glosarry.php
está medio puerco esto, pero seguro se puede mejorar y crear una estructura
de
plugins para el blog
diff de blog.php
jordi@jadame:~/pgz/jaws/html/gadgets$ diff blog.php blog.php.viejo
497,525d496
<
< $content_pre = $content;
< //$content_pre = strtolower($content_pre);
< $content_pre = str_replace(',','',$content_pre);
< $content_pre = str_replace('.','',$content_pre);
< $content_pre = str_replace('?','',$content_pre);
< $content_pre = str_replace('¿','',$content_pre);
< $content_pre = str_replace('!','',$content_pre);
< $content_pre = str_replace('¡','',$content_pre);
< $content_pre = str_replace(':','',$content_pre);
< $content_pre = str_replace(';','',$content_pre);
<
< $palabras = explode(" ", $content_pre);
<
<
<
< foreach($palabras as $a){
< $b = strtolower($a);
< $sql_palabras = "select * from term where term = '$b'";
<
< $rs_palabras = $GLOBALS["app"]->db->query($sql_palabras);
<
< if($row_palabras = $rs_palabras->fetch_row())
< {
< $content = str_replace($a, "<a href=
\"index.php?gadget=glossary&action=view&term_id=".$row_palabras["id"]."\"
title=\"".$row_palabras["description"]."\">$a</a>", $content);
< }
<
< }
<
en glossary lo que hice fue ponerle un if al query nadamás...
DIFF de glossary.php
================================================
<
< if($_REQUEST["term"]){
< $sql = "select category.name as type, term.term,
term.description,
< term.createtime, term.updatetime from term,
category
< where term.category_id = category.id
< and term.term = '".$_REQUEST["term"]."'";
< }elseif($_REQUEST["term_id"]){
< $sql = "select category.name as type, term.term,
term.description,
< term.createtime, term.updatetime from term,
category
< where term.category_id = category.id
< and term.id = '".$_REQUEST["term_id"]."'";
< }
---
> $sql = "select category.name as type, term.term,
term.description,
> term.createtime, term.updatetime from term, category
> where term.category_id = category.id
> and term.term = '".$_REQUEST["term"]."'";
________________________________________________
Message sent using UebiMiau 2.7.2
|