mooHP Framework PHP Que Utiliza La Sintaxis de MooTools

Suena un poco extraña la combinación pero supongo a los que utilizan mootools les agradará y les parecerá algo familiar. mooHP es un framework en PHP que utiliza la sintaxis del framework javascript mooTools. Funciona en PHP 5.2.1 y superiores.

Ejemplo de mooHP:

  1. <?php
  2. include(“mooHP2/dom.class.php”);
  3. include(“mooHP2/element.class.php”);
  4. include(“mooHP2/css.class.php”);
  5. include(“mooHP2/utility.class.php”);
  6.  
  7. //New instance of the dom class
  8. $t = new dom();
  9.  
  10. //Loads a template from file
  11. $t->loadFile(“base.html”);
  12.  
  13. //Gets element by css selector  and sets it’s HTML content.
  14. $t->SE(“body”)->setHTML(“”);
  15.  
  16. //Selected ellement: body adopts  new element
  17. $t->SE(“body”)->adopt( $t->element(“div”, array(“id”=>“header”) ,“Hello world!”) );
  18.  
  19. //Body adopts  <br />
  20. $t->SE(“body”)->newLine();
  21.  
  22.  
  23. $picked = “”;
  24. if (isset( $_GET[“cd”] )) {
  25.  $picked = ” you have selected #”.$_GET[“cd”];
  26. }
  27.  
  28. //Body adopts new element div: with assigned properties as second argument and text as content;
  29. $t->SE(“body”)->adopt( $t->element(“div”, array(“style”=>“margin:10px; padding:10px; border:1px solid #444;”), “Counting down:”.$picked) );
  30.  
  31. // $select  = new Element()
  32. $select = $t->element(“select”, array(“name”=>“cd”), “”);
  33.  
  34. //Body adopts new element of type form
  35. $t->SE(“body”)->adopt( $t->element(“form”, array(“id”=>“newForm”,“method”=>“get”) ) );
  36. //Selects new element by ID and adopts previously defined element $select
  37. $t->S(“newForm”)->adopt( $select );
  38. // #newForm adopts new Element input
  39. $t->S(“newForm”)->adopt( $t->element(“input”, array(“type”=>“submit”, “value”=>“CLICK!”) ) );
  40.  
  41.  
  42. for ($i=1; $i<=20; $i++) {
  43.         //$newOption is new option element
  44.         $newOption = $t->element(“option”, array(“value”=>$i), “Count down: “ . $i );
  45.         //$select adopt as it’s first child the $newOption element
  46.         $select->adoptTop( $newOption );
  47.         if ( isset($_GET[“cd”]) && $_GET[“cd”] == $i ) {
  48.                 //Setting an attribute to an element
  49.                 $newOption->setProperty(“selected”,“selected”);
  50.         }
  51. }
  52.  
  53. //Body accepts  new style rules
  54. $t->SE(“body”)->setStyle(“margin”,“10px”);
  55.  
  56. //Body adopts <br/>
  57. $t->SE(“body”)->newLine();
  58.  
  59. //Appending text to the body
  60. $t->SE(“body”)->appendText(“and here comes the appended text”);
  61.  
  62. //Body is adopting the inc.html contents
  63. $t->SE(“body”)->adopt( $t->includeFile(“inc.html”) );
  64.  
  65. if (!isset( $_GET[“cd”] )) {
  66.         //Make simple alert with javascript
  67.         $t->alert(“Hello and welcome to mooHP”);
  68. }
  69.  
  70. //Setting the <title> tah innerHTML
  71. $t->setPageTitle(“..:: Hello and welcome to mooHP ::..”);
  72.  
  73.  
  74. //Creating new instance of the css class
  75. $newCss = new css();
  76. //Setting rule in css
  77. $newCss->setStyle(“color”,“#ff9900″);
  78. //Setting rules in css
  79. $newCss->setStyles(array(“font-weight”=>“bold”,“font-size”=>“24px” ));
  80. //Writing the defined css to element
  81. $newCss->writeToElement( $t->S(“header”) );
  82.  
  83.  
  84. //Creating new instance of the css class
  85. $newCss2 = new css();
  86. //Setting rule in css
  87. $newCss2->setStyle(“border”,“10px solid #DDD”);
  88. //Setting rule in css
  89. $newCss2->setStyle(“padding”,“10px”);
  90. //Writing the defined css as #newForm selector in $t dom instance
  91. $newCss2->writeToDom(“#newForm”, $t);
  92.  
  93. //Writing the page   if true is passed as argument the page will be compresed
  94. $t->writePage(true);
  95.  
  96. ?>

- Demo mooHP

- Descargar mooHP

- Mas información

Vía: Dzone

¿Te pareció interesante la nota?, registrate a nuestro Feed para que estes al dia con las últimas notas que publicamos en WebAdictos, tambien te invitamos a explorar nuestros archivos tal vez encuentres notas y recursos que te sean de utilidad.

Si lo prefieres puedes utilizar el botón de post aleatorio para ir saltando entre nuestros contenidos.
Gracias por visitarnos.

Un comentario para “mooHP Framework PHP Que Utiliza La Sintaxis de MooTools”

  1. Actualidad, Entretenimiento y Humor » mooHP Framework PHP Que Utiliza La Sintaxis de MooTools

    [...] (more…) Compártelo [...]

Leave a Reply


Tu banner aquí

Recibir Artículos Por Email