コード例 #1
0
    public function render()
    {
        $oper = isset($_POST['op']) ? $_POST['op'] : '';
        switch ($oper) {
            case 'save':
                #--------------------------
                # Guardar comments
                #--------------------------
                $comment = new db_record($this->table);
                // Crea dbRecord para la tabla Comentario
                $comment->fields[$this->comment_field] = $_POST['comment'];
                $comment->fields[$this->code_field] = $_POST['code'];
                $comment->fields[$this->id_table2coment_field] = $_POST['id-t-val'];
                $comment->fields[$this->name_field] = $_POST['name'];
                $comment->fields[$this->email_field] = $_POST['email'];
                $comment->fields[$this->webpage_field] = $_POST['web'];
                $comment->save();
                // Encentra el ultimo y muestralo
                //$comment->findLast() :: crear esta function
                $db = new db();
                $db->connect();
                $sql = 'SELECT *,now() as ahora FROM ' . $this->table . ' WHERE ' . $this->code_field . ' =  "' . $this->code . '"
		             AND  ' . $this->id_table2coment_field . ' = "' . $this->id_tab_val . '"
					 ORDER BY ' . $this->table_id_field . ' DESC LIMIT 1 ;
					 ';
                $db->query($sql);
                if ($rec = $db->next()) {
                    $this->printOneComent($rec);
                }
                break;
            default:
                #--------------------------
                # Load Comments
                #--------------------------
                ?>
<ul id="fk-commenter-<?php 
                echo $this->id_obj;
                ?>
" class="fk-comments">
	<div id="comments-<?php 
                echo $this->id_obj;
                ?>
"><?php 
                $this->printComments();
                ?>
</div>
	<div id="new-comments-<?php 
                echo $this->id_obj;
                ?>
"></div>
	<div id="leave-<?php 
                echo $this->id_obj;
                ?>
"><?php 
                $this->leaveAComment();
                ?>
</div>
</ul>
<script language="javascript" type="text/javascript">
 fkComments('<?php 
                echo $this->id_obj;
                ?>
','<?php 
                echo $this->page;
                ?>
','<?php 
                echo $this->code;
                ?>
','<?php 
                echo $this->id_tab_val;
                ?>
');
 
</script>
				<?php 
                break;
        }
    }
コード例 #2
0
    public function render()
    {
        $oper = isset($_POST['op']) ? $_POST['op'] : '';
        switch ($oper) {
            case 'save':
                #--------------------------
                # Guardar comments
                #--------------------------
                $comment = new db_record($this->table);
                // Crea dbRecord para la tabla Comentario
                $comment->fields[$this->comment_field] = $_POST['comment'];
                $comment->fields[$this->code_field] = $_POST['code'];
                $comment->fields[$this->id_table2coment_field] = $_POST['id-t-val'];
                $comment->fields[$this->name_field] = $_POST['name'];
                $comment->fields[$this->email_field] = $_POST['email'];
                $comment->fields[$this->webpage_field] = $_POST['web'];
                $comment->fields['id_usuario'] = $this->id_usuario;
                $comment->save();
                // Encentra el ultimo y muestralo
                //$comment->findLast() :: crear esta function
                $db = new db();
                $sql = 'SELECT *,now() as ahora FROM ' . $this->table . ' c
				left join usuarios usr on usr.id_usuario = c.id_usuario
				left join uploads upl on upl.id_upload = usr.imagen
				
				     WHERE ' . $this->code_field . ' =  "' . $this->code . '"
		             AND  ' . $this->id_table2coment_field . ' = "' . $this->id_tab_val . '"
					 ORDER BY ' . $this->table_id_field . ' DESC LIMIT 1 ;
					 ';
                $db->query($sql);
                if ($rec = $db->next()) {
                    $this->printOneComent($rec);
                }
                break;
            default:
                #--------------------------
                # Load Comments
                #--------------------------
                ?>
<ul id="fk-commenter-<?php 
                echo $this->id_obj;
                ?>
" class="fk-comments">
	
	<div id="new-comments-<?php 
                echo $this->id_obj;
                ?>
"></div>
	<?php 
                if ($this->readonly == false) {
                    ?>
<div id="leave-<?php 
                    echo $this->id_obj;
                    ?>
"><?php 
                    $this->leaveAComment();
                    ?>
</div><?php 
                } else {
                    // si muestra form de envio aunque no este logeado
                    if ($this->must_login == true) {
                        ?>
<div id="leave-<?php 
                        echo $this->id_obj;
                        ?>
"><?php 
                        $this->leaveACommentDisabled();
                        ?>
</div><?php 
                    }
                }
                ?>
	<div id="comments-<?php 
                echo $this->id_obj;
                ?>
"><?php 
                $this->printComments();
                ?>
</div>
</ul>
<script language="javascript" type="text/javascript">
$(function(){
	fkComments('<?php 
                echo $this->id_obj;
                ?>
','<?php 
                echo $this->page;
                ?>
','<?php 
                echo $this->code;
                ?>
','<?php 
                echo $this->id_tab_val;
                ?>
');	
});
 
 
</script>
				<?php 
                break;
        }
    }