Ver Mensaje Individual
  #34 (permalink)  
Antiguo 06/10/2005, 16:54
esteno
 
Fecha de Ingreso: marzo-2005
Mensajes: 57
Antigüedad: 19 años, 1 mes
Puntos: 0
Buenas,

Me gusta Firefox asi que intentaré ayudaros un poco

He hecho una clase para simplificar el incorporar el script a una web, teniendo que incluir tan sólo un archivo e instanciando la clase. Además he dado la posibilidad de poner estilos personalizados.

Los temas por defecto los he copiado de la versión de papixulooo.

A seguir mejorando el script para ayudar a Firefox!!

Espero sugerencias y comentarios

Archivo a incluir:

Código PHP:
<?php

class DifundeFirefox
{
  var 
$navegadores = array(
                           
"firefox",
                           
"opera",
                           
"msie"
                          
);
                          
  var 
$estiloDefecto = array("firefox" => "
        <div align='center'>
          <p align='center'>Veo que utilizas<em> Mozilla Firefox</em></p>
          <p align='center'>¿Sab&iacute;as que puedes ponerle <a href='https://addons.mozilla.org/themes/?application=firefox' target='_blank'>skins</a> y <a href='https://addons.mozilla.org/extensions/?application=firefox' target='_blank'>extensiones</a>?</p>
          <p align='center'>&iexcl;Nosotros tambien utilizamos <a href='http://www.mozilla-europe.org/es/products/firefox/' target='_blank'><strong>Mozilla Firefox</strong></a>!</p>
          <p align='center'><a href='http://www.mozilla-europe.org/es/products/firefox/' target='_blank'><img src='http://sfx-images.mozilla.org/affiliates/Buttons/80x15/blue_1.gif' alt='' border='0'></p>
        </div>
                                          "
,
                             
"opera" => "
        <div align='center'>
          <p align='center'>Sabemos que utilizas Opera</p>
          <p align='center'>Pero...<em></em></p>
          <p align='center'>¿Conoces las ventajas de un navegador de codigo abierto?</p>
          <p align='center'><a target='_blank' href='http://www.mozilla-europe.org/es/products/firefox/'><strong>Mozilla Firefox</strong></a> es de codigo abierto ¡Pru&eacute;balo!</p>
          <p align='center'><a target='_blank' href='http://www.mozilla-europe.org/es/products/firefox/'><img src='http://sfx-images.mozilla.org/affiliates/Buttons/80x15/blue_1.gif' alt='' border='0'></a></p>
        </div>
                                          "
,
                             
"msie" => "
        <div align='center'>
          <p align='center'>Veo que utilizas<em> Microsoft Internet Explorer</em></p>
          <p align='center'>¿Sab&iacute;as de la inseguridad de este navegador?</p>
          <p align='center'>Nosotros utilizamos <a target='_blank' href='http://www.mozilla-europe.org/es/products/firefox/'><strong>Mozilla Firefox</strong></a> ¡Pru&eacute;balo!</p>
          <p align='center'><a target='_blank' href='http://www.mozilla-europe.org/es/products/firefox/'><img src='http://sfx-images.mozilla.org/affiliates/Buttons/80x15/blue_1.gif' alt='' border='0'></a></p>
        </div>
                                          "
,
                             
"defecto" => "
        <div align='center'>
          <p align='center'>No sabemos que navegador usas</p>
          <p align='center'>Pero...</p>
          <p align='center'>¿Tiene navegaci&oacute;n con pesta&ntilde;as?</p>
          <p align='center'>&iquest;Es de c&oacute;digo abierto? </p>
          <p align='center'><a target='_blank' href='http://www.mozilla-europe.org/es/products/firefox/'><strong>Mozilla Firefox</strong></a> si tiene todo esto y m&aacute;s&iexcl;Pru&eacute;balo!</p>
          <p align='center'><a target='_blank' href='http://www.mozilla-europe.org/es/products/firefox/'><img src='http://sfx-images.mozilla.org/affiliates/Buttons/80x15/blue_1.gif' alt='' border='0'></a></p>
        </div>
                                          "
                             
);

  var 
$navegador;
  var 
$nestilo;
  var 
$estilo;
  
  function 
DifundeFirefox($nestilo "-1",$estilos NULL)
  {
    
$this->navegador $this->comprobarNavegador();
    
    
$this->nestilo $nestilo;
    
    if(
$this->nestilo 0)
    {
      
$this->estilo $this->estiloDefecto[$this->navegador];
    }
    else
    {
      
$this->estilos $estilos;
      
$this->estilo $this->comprobarEstilo();
    }
    
    echo 
$this->estilo;
  }
  
  function 
comprobarNavegador()
  {
    foreach(
$this->navegadores as $v)
    {
      if(
eregi($v,$_SERVER['HTTP_USER_AGENT']))
      {
        return 
$v;
      }
    }
    
    return 
"defecto";
  }
  
  function 
comprobarEstilo()
  {
    if(!empty(
$this->estilos[$this->navegador][$this->nestilo]))
    {
      return 
$this->estilos[$this->navegador][$this->nestilo];
    }
    else
    {
      return 
$this->estiloDefecto[$this->navegador];
    }
  }
}

?>
Ahora sólo instanciar la clase donde queremos que se ejecute el script:

Código PHP:
new DifundeFirefox(); 
Saludos!!
__________________
Alpa cine - Películas de cine con estrenos de cartelera
Compuntoes - Como es y punto

Última edición por esteno; 08/05/2006 a las 08:07