Classe Cool Button

Publicado por Valderi 12/01/2005

[ Hits: 6.802 ]

Download menu.php




Classe adaptada da lib CoolButtons (www.dynamicdrives) para geração de Botões.

Exemplo de uso.
<script language="JavaScript1.2" src="lib/js/coolbuttons.js"></script>
<?php
require_once('menu.php');
$mymenu = new button;
$o_menu = array(
   "doc10.gif|Novo|Novo registro de atleta|http://www.google.com",
   "books01.gif|Consulta|Consulta dados de atleta|http://www.globo.com",
   "diskete1.gif|Salvar|Salvar registro do atleta|http://www.globo.com",
);
$mymenu->mount($o_menu,'_parent',0);
$mymenu2 = new button;
$menu2 = array('Novo'=>'http://www.google.com','Consulta'=>'http://www.transamericacuritiba.com.br');
$mymenu2->mount($menu2,'_new',1);
?>

  



Esconder código-fonte

<?php

class button { //Requer a Lib coolbutton.js - www.dynamicdrives.com
   function mount($array,$target,$type) {
   switch($type) {
      /*
      $array = Array com Label do botão e o Link
         Ex.: $array = array('Novo'=>'novo.php','Excluir'=>'excluir.php');
      
      $target = Alvo do link
         Ex.: $target = "_blank";
      
      $type = Determina a posição do(s) botão(ôes)      
         0 - Vertical 
         1 - Horizontal 
      */
      case (int)0: 
         $i = 0;
         foreach($array as $key => $link) {
             $mount_menu  = '<table class="coolBar">'."\n";
            $mount_menu .= "\t".'<tr>'."\n";
            $label = explode("|",$link);
            $mount_menu .= "\t".'<td align="center" valign="middle" onClick="location.href=\''.$label[3].'\'" target="'.$target.'" class="coolButton" width="80" style="cursor:hand; font-family:Trebuchet MS, Arial; font-size=8pt">'."\n";
            $mount_menu .= "\t\t".'<img src="imagens/botoes/'.$label[0].'" width="32" height="32" alt="'.$label[2].'">'."\n<br>";
            $mount_menu .= $label[1].'</td>'."\n";
            $mount_menu .= "\t".'</tr>'."\n";
            $mount_menu .= '</table>'."\n";
            print($mount_menu);
            $i++;
         }
      break; 
      
      case (int)1:
         $i = 0;
         $mount_menu  = '<table class="coolBar">'."\n";   
         $mount_menu .= "\t".'<tr>'."\n";
         foreach($array as $key => $link) {
            $mount_menu .= "\t".'<td height="25" width="80" align="center" valign="middle" onClick="location.href=\''.$link.'\'" target="'.$target.'" class="coolButton" style="cursor:hand;"><font face="Trebuchet MS, Arial" size="2">'."\n";         
            $mount_menu .= $key.'<font></td>'."\n";
            $mount_menu .= '<td><img src="imagens/botoes/pix_h.gif" height="100%" width="2"></td>'."\n";         
            $i++;
         }
         $mount_menu .= "\t".'</tr>'."\n";
         $mount_menu .= '</table>'."\n";      
         print($mount_menu);
      break;
      }
   }
}
?>

Scripts recomendados

evePHP: Classe para desenvolvimento PHP

ThumbNails

Biblioteca de classes para facilitar a criação de formulários e conexão ao MySQL

OpenLDAP seguro

Fast Template CVS revision 1.2.0


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário