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:
-
<?php
-
include(“mooHP2/dom.class.php”);
-
include(“mooHP2/element.class.php”);
-
include(“mooHP2/css.class.php”);
-
include(“mooHP2/utility.class.php”);
-
-
//New instance of the dom class
-
$t = new dom();
-
-
//Loads a template from file
-
$t->loadFile(“base.html”);
-
-
//Gets element by css selector and sets it’s HTML content.
-
$t->SE(“body”)->setHTML(“”);
-
-
//Selected ellement: body adopts new element
-
-
//Body adopts <br />
-
$t->SE(“body”)->newLine();
-
-
-
$picked = “”;
-
$picked = ” you have selected #”.$_GET[“cd”];
-
}
-
-
//Body adopts new element div: with assigned properties as second argument and text as content;
-
$t->SE(“body”)->adopt( $t->element(“div”, array(“style”=>“margin:10px; padding:10px; border:1px solid #444;”), “Counting down:”.$picked) );
-
-
// $select = new Element()
-
-
//Body adopts new element of type form
-
//Selects new element by ID and adopts previously defined element $select
-
$t->S(“newForm”)->adopt( $select );
-
// #newForm adopts new Element input
-
-
-
for ($i=1; $i<=20; $i++) {
-
//$newOption is new option element
-
//$select adopt as it’s first child the $newOption element
-
$select->adoptTop( $newOption );
-
//Setting an attribute to an element
-
$newOption->setProperty(“selected”,“selected”);
-
}
-
}
-
-
//Body accepts new style rules
-
$t->SE(“body”)->setStyle(“margin”,“10px”);
-
-
//Body adopts <br/>
-
$t->SE(“body”)->newLine();
-
-
//Appending text to the body
-
$t->SE(“body”)->appendText(“and here comes the appended text”);
-
-
//Body is adopting the inc.html contents
-
$t->SE(“body”)->adopt( $t->includeFile(“inc.html”) );
-
-
//Make simple alert with javascript
-
$t->alert(“Hello and welcome to mooHP”);
-
}
-
-
//Setting the <title> tah innerHTML
-
$t->setPageTitle(“..:: Hello and welcome to mooHP ::..”);
-
-
-
//Creating new instance of the css class
-
$newCss = new css();
-
//Setting rule in css
-
$newCss->setStyle(“color”,“#ff9900″);
-
//Setting rules in css
-
//Writing the defined css to element
-
$newCss->writeToElement( $t->S(“header”) );
-
-
-
//Creating new instance of the css class
-
$newCss2 = new css();
-
//Setting rule in css
-
$newCss2->setStyle(“border”,“10px solid #DDD”);
-
//Setting rule in css
-
$newCss2->setStyle(“padding”,“10px”);
-
//Writing the defined css as #newForm selector in $t dom instance
-
$newCss2->writeToDom(“#newForm”, $t);
-
-
//Writing the page if true is passed as argument the page will be compresed
-
$t->writePage(true);
-
-
?>
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.





Noviembre 1st, 200712:08 am
[...] (more…) Compártelo [...]