<?php echo Materialize::ico('keyboard_arrow_up', "?por=$columna&sentido=ASC"); ?>
<?php echo Materialize::orb('check', 'guardar_registro'); ?>
<?php echo Materialize::orb('clear', "$url?accion=borrar_registro"); ?>
Last active
February 4, 2016 12:27
-
-
Save demonio/c12c46f46be2314fcb64 to your computer and use it in GitHub Desktop.
Librería para generar código HTML son la sintaxis del framework MarerializeCSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Clase que genera HTML del framework CSS "Materialize" | |
* Actualmente se encuentra en desarrollo y se pretende tener una compilación de recursos decente para uso y disfute de todos. | |
*/ | |
class Materialize | |
{ | |
/** | |
* ESTABLECEMOS LOS VALORES POR DEFECTO POR ICONO | |
*/ | |
public static function createLink( $type, $icon, $action='', $user_attrs=array() ) | |
{ | |
$shape = ($type == 'orb') ? ' btn-floating' : ''; | |
$default = array | |
( | |
'add'=>array('color'=>'green', 'data-tooltip'=>'Crear'), | |
'check'=>array('color'=>'orange', 'data-tooltip'=>'Guardar'), | |
'clear'=>array('color'=>'red', 'data-tooltip'=>'Eliminar'), | |
'close'=>array('color'=>'grey', 'data-tooltip'=>'Cerrar'), | |
'mode_edit'=>array('color'=>'grey', 'data-tooltip'=>'Editar'), | |
'people'=>array('color'=>'blue', 'data-tooltip'=>'Buscar'), | |
'person_add'=>array('color'=>'green', 'data-tooltip'=>'Nuevo'), | |
'remove'=>array('color'=>'red', 'data-tooltip'=>'Eliminar'), | |
'search'=>array('color'=>'blue', 'data-tooltip'=>'Buscar'), | |
'web_asset'=>array('color'=>'green', 'data-tooltip'=>'Nuevo'), | |
); | |
$color = empty( $default[$icon]['color'] ) ? '' : " {$default[$icon]['color']} darken-1"; | |
if ( empty( $default[$icon]['data-tooltip'] ) ) | |
{ | |
$tooltip = ''; | |
} | |
else | |
{ | |
$a['attrs']['data-delay'] = 500; | |
$a['attrs']['data-position'] = 'left'; | |
$a['attrs']['data-tooltip'] = $default[$icon]['data-tooltip']; | |
$tooltip = ' tooltipped'; | |
} | |
$a['attrs']['class'] = "$icon$shape$color$tooltip waves-effect waves-light"; | |
if ( preg_match( '/[\/#\?]+/', $action ) ) | |
{ | |
$a['attrs']['href'] = $action; | |
$a['tag'] = 'a'; | |
} | |
else | |
{ | |
$a['attrs']['name'] = 'accion'; | |
$a['attrs']['type'] = 'submit'; | |
$a['attrs']['value'] = $action; | |
$a['tag'] = 'button'; | |
} | |
foreach($user_attrs as $k=>$v) | |
{ | |
$attrs[$k] = $v; | |
} | |
$a['content'] = self::icon($icon); | |
$s = self::tt($a); | |
return $s; | |
} | |
/** | |
* CREAMOS UN BOTON CUADRADO | |
*/ | |
public static function btn( $icon='add', $action='', $attrs=array() ) | |
{ | |
return self::createLink('btn', $icon, $action, $attrs, $test); | |
} | |
/** | |
* CREAMOS UN ICONO CON ENLACE | |
*/ | |
public static function ico( $icon='add', $action='', $attrs=array() ) | |
{ | |
return self::createLink('ico', $icon, $action, $attrs, $test); | |
} | |
/** | |
* CREAMOS UN BOTON REDONDO QUE LLAMAREMOS ORBE | |
*/ | |
public static function orb( $icon='add', $action='', $attrs=array() ) | |
{ | |
return self::createLink('orb', $icon, $action, $attrs, $test); | |
} | |
/** | |
* ESTE METODO CREA UN ICONO | |
*/ | |
public static function icon($name='add') | |
{ | |
$a['tag'] = 'i'; | |
$a['attrs']['class'] = 'material-icons'; | |
$a['content'] = $name; | |
return self::tt($a); | |
} | |
/** | |
* LA TOSTADORA HACE TOSTADAS | |
*/ | |
public static function toasts( $toasts=array() ) | |
{ | |
$s = "<script>" . PHP_EOL; | |
foreach($toasts as $toast) | |
{ | |
$s .= "Materialize.toast('$toast', 4000, 'rounded');" . PHP_EOL; | |
} | |
$s .= "</script>" . PHP_EOL; | |
return $s; | |
} | |
/** | |
* CREAMOS UNA ETIQUETA SIMPLE | |
*/ | |
public static function t( $a=array() ) | |
{ | |
$tag = $a['tag']; | |
$attrs = self::attrs($a['attrs']); | |
return "<$tag$attrs />"; | |
} | |
/** | |
* CREAMOS UNA ETIQUETA CON CIERRE | |
*/ | |
public static function tt( $a=array() ) | |
{ | |
$tag = $a['tag']; | |
$attrs = self::attrs($a['attrs']); | |
$content = empty($a['content']) ? '' : $a['content']; | |
return "<$tag$attrs>$content</$tag>"; | |
} | |
/** | |
* CREAMOS LOS ATRIBUTOS | |
*/ | |
public static function attrs($a) | |
{ | |
$s = ''; | |
foreach($a as $k => $v) | |
{ | |
if ( is_array($v) ) $v = implode(' ', $v); | |
$s .= " $k=\"$v\""; | |
} | |
return $s; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment