<?php
// +----------------------------------------------------------------------+
// | Copyright (C) 2004,2005 Jairo Pereira da Conceicao - Brazil |
// | |
// | This program is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public License |
// | as published by the Free Software Foundation; either version 2 |
// | of the License, or (at your option) any later version. |
// | |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
// | 02111-1307, USA. |
// | |
// | Author: Jairo Pereira da Conceicao - hide@address.com |
// | |
// +----------------------------------------------------------------------+
// | http://www.liberware.com.br |
// +----------------------------------------------------------------------+
/**********************************************************************
* +++ ToolBar.php +++
*
* Cria uma barra de ferramentas com acoes Adicionar, Editar, Remover e
* Imprimir para cada Formulario.
* Retorna uma DIV contendo as Imagens e HREF's informados.
*
*---------------------------------------------------------------------
* Make a Toolbar with actions add, edit, remove and print for forms.
*
* Usage:
* -----
*
* $bar = & new ToolBar();
* $bar->addAction('add.php', imgMouseOut, imgMouseOver, 'hint', 'janela');
* $bar->addAction('edit.php', imgMouseOut, imgMouseOver, 'hint', 'janela');
* $bar->addAction('remove.php', imgMouseOut, imgMouseOver, 'hint' );
* $bar->addAction('print.php', imgMouseOut, imgMouseOver, 'hint', 'print');
*
* $bar->printToolBar();
*
**********************************************************************
* Liberware - Solucoes em Software Livre Ltda
* Agosto, 2004
**********************************************************************
*/
class ToolBar
{
var $aImgNorm = array();
var $aImgOver = array();
var $aModules = array();
var $aHints = array();
var $midia = array();
/* Adiciona uma acao a Toolbar */
function addAction($actionModule, $imgNorm, $imgOver, $Hint="", $midia=""){
$this->aImgNorm[] = $imgNorm;
$this->aImgOver[] = $imgOver;
$this->aModules[] = $actionModule;
$this->aHints[] = $Hint;
$this->midia[] = $midia;
}
/* Remove uma acao apontada por um indice */
function deleteAction($id){
$this->aImgNorm[$id] = "";
$this->aImgOver[$id] = "";
$this->aModules[$id] = "";
$this->aHints[] = "";
}
function showToolbar(){
$output = "<SPAN id='toolbar'>\n";
for( $i=0; $i < count($this->aModules); $i++ ){
if(strtolower($this->midia[$i]) == "janela"){
$output.= "<a href='#' onClick=\"javascript:window.open('".$this->aModules[$i]."', 'winItem','width=400, height=400, toolbar=no, scrollbars=no, status=no, location=no, menubar=no resizable=yes')\" ";
}
elseif(strtolower($this->midia[$i]) == "print"){
$output.= "<a href='#' onClick=\"javascript:window.open('".$this->aModules[$i]."', 'winPrint','width=600, height=400, toolbar=yes, scrollbars=auto, status=no, location=no, menubar=no resizable=yes')\" ";
}
else{
$output.= "<a href='".$this->aModules[$i]."'";
}
$output.= " title='".$this->aHints[$i]."'>";
$output.= "<img src='".$this->aImgNorm[$i]."' onMouseOver=\"javascript:this.src='".$this->aImgOver[$i]."'\" onMouseOut=\"javascript:this.src='".$this->aImgNorm[$i]."'\" border=0 >";
$output.= "</a>\n";
}
$output.= "</SPAN>";
return $output;
}
function printToolBar(){
print $this->showToolBar();
}
}
?>