4 // Lucarella, Schein, Arena
\r
6 // Creado: Sebastian Arena
\r
9 require_once 'Item.php';
\r
10 require_once 'file.php';
\r
11 require_once 'file.log.php';
\r
13 class Info extends Item
\r
23 var $autor_apellido;
\r
26 var $infoCSVConst = 'data/infos.csv';
\r
29 id | tema | url | autor | comentario | ranking | fecha
\r
32 function Info($param, $loadFromRecord) {
\r
33 if (!$loadFromRecord) {
\r
39 $this->id = $param[0];
\r
40 $this->tema = $param[1];
\r
41 $this->url = $param[2];
\r
42 $this->autor = $param[3];
\r
43 $this->comentario = $param[4];
\r
44 $this->ranking = $param[5];
\r
45 $this->fecha = $param[6];
\r
52 if (is_file($this->infoCSVConst)) {
\r
53 $record_info = fsearchcsv($this->infoCSVConst, $this->id);
\r
55 $this->id = $record_info[0];
\r
56 $this->tema = $record_info[1];
\r
57 $this->url = $record_info[2];
\r
58 $this->autor = $record_info[3];
\r
59 $this->comentario = $record_info[4];
\r
60 $this->ranking = $record_info[5];
\r
61 $this->fecha = $record_info[6];
\r
67 function saveNew() {
\r
68 return fappendcsv($this->infoCSVConst, array($this->id, $this->tema, $this->url, $this->autor, $this->comentario, $this->ranking, $this->fecha));
\r
71 function saveExisting() {
\r
72 if (($f = fopen($this->infoCSVConst, 'r+')) == false) return false; // error
\r
77 $d = fgetcsv($f, 4096);
\r
78 if ($d[0] == $this->id)
\r
81 fputcsv($f, array($this->id, $this->tema, $this->url, $this->autor, $this->comentario, $this->ranking, $this->fecha));
\r
90 function saveLoadThis( $pId, $pTema, $pURL, $pAutor, $pComentario ) {
\r
92 $this->tema = $pTema;
\r
94 $this->autor = $pAutor;
\r
95 $this->comentario = preg_replace('[\n|\r\n]','<br/>',$pComentario);
\r
97 $this->fecha = time();
\r
101 function ingresar( $pId, $pTema, $pURL, $pAutor, $pComentario ) {
\r
102 $this->saveLoadThis( $pId, $pTema, $pURL, $pAutor, $pComentario );
\r
104 if (!$this->saveNew()) {
\r
105 $resultado = "<strong>ERROR</strong> al agregar la informacion. Revise que los parametros sean los adecuados";
\r
106 file_log_add($pAutor,$resultado);
\r
108 file_log_add($pAutor,"Se agregó la información");
\r
113 function toHTML() {
\r
115 <td><img src="<?php echo $this->tema_icono;?>" border="0" alt="icono tema"/></td>
\r
116 <td><img src="<?php echo $this->autor_foto;?>" border="0" alt="icono usuario"/></td>
\r
117 <td><a href="<?php echo $this->url;?>" onclick="location.href='<?php echo $_SERVER['PHP_SELF'] ?>/../info.agregarRanking.php?id=<?php echo $this->id;?>';return false;"><?php echo $this->url;?></a></td>
\r
118 <td><?php echo $this->comentario;?></td>
\r
119 <td><?php echo $this->ranking;?></td>
\r
120 <td><a href="info.listarComentarios.php?id=<?php echo $this->id; ?>">Ver Comentarios</a></td>
\r
125 function incrementarRanking() {
\r
126 //file_log_add($_SESSION['user']->getId(),"Se visitó una informacion (" . $this->url . ")");
\r
127 $this->ranking = $this->ranking + 1;
\r
128 return $this->saveExisting();
\r