<?php
/**
 * Authenticate
 *
 * @author Eduardo Bonfandini [eduardo@solis.coop.br]
 *
 * @version $Id$
 *
 * \b Maintainers \n
 * Eduardo Bonfandini [eduardo@solis.coop.br]
 * Jamiel Spezia [jamiel@solis.coop.br]
 * Luiz Gregory Filho [luiz@solis.coop.br]
 * Moises Heberle [moises@solis.coop.br]
 *
 * @since
 * Class created on 01/10/2008
 *
 * \b Organization: \n
 * SOLIS - Cooperativa de Solucoes Livres \n
 * The Gnuteca3 Development Team
 *
 * \b CopyLeft: \n
 * CopyLeft (L) 2008 SOLIS - Cooperativa de Solucoes Livres \n
 *
 * \b License: \n
 * Licensed under GPL (for further details read the COPYING file or http://www.gnu.org/copyleft/gpl.html )
 *
 * \b History: \n
 * See history in SVN repository: http://gnuteca.solis.coop.br
 */


class FrmVerifyLinks extends GnutecaForm
{
    public function __construct($args)
    {
        parent::__construct( _M('Verify Links', $this->module) );
        $this->setFocus('time');
        $this->setIcon($this->MIOLO->getUI()->getImage($this->module, 'myLibrary-16x16.png'));
        $this->eventHandler();
    }


    public function createFields()
    {
    	$fields   = null;
        $fields[] = new MTextField('timeOut', ini_get('default_socket_timeout'), _M('Tempo limite, em segundos, para testar cada link', $this->module));
        $fields[] = new MTextField('tag', MARC_NAME_SERVER, _M('Tag a verificar', $this->module));
        $fields[] = new MButton('btnVerifyLinks',_M('Verify Links', $this->module));
        $fields[] = new MLabel( _M('Aumentar o tempo limite para testar cada link, aumenta a probabilidade de encontrar o link, mas faz com que o teste demore mais a acontecer.', $this->module) );
        $fields[] = new MDiv('divResult');
        $this->setFields( $fields );
    }


    public function btnVerifyLinks_click($args)
    {
        $busMaterial = $this->MIOLO->getBusiness( $this->module, 'BusMaterial');
        $data = $busMaterial->verifyLinks($args->tag, $args->timeOut);

        $fields[] = new MTableRaw( _M('Relação de links com problemas - Total :', $this->module). count($data) , $data, array(_M('Control number', $this->module), _M('Link', $this->module) ) );

        $this->setResponse( $fields ,'divResult');
    }
}
?>
