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:
loadFile(“base.html”);
//Gets element by css selector and sets it’s HTML content.
$t->SE(“body”)->setHTML(“”);
//Selected ellement: body adopts new element
$t->SE(“body”)->adopt( $t->element(“div”, array(“id”=>”header”) ,”Hello world!”) );
//Body adopts
$t->SE(“body”)->newLine();
$picked = “”;
if (isset( $_GET[“cd”] )) {
$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()
$select = $t->element(“select”, array(“name”=>”cd”), “”);
//Body adopts new element of type form
$t->SE(“body”)->adopt( $t->element(“form”, array(“id”=>”newForm”,”method”=>”get”) ) );
//Selects new element by ID and adopts previously defined element $select
$t->S(“newForm”)->adopt( $select );
// #newForm adopts new Element input
$t->S(“newForm”)->adopt( $t->element(“input”, array(“type”=>”submit”, “value”=>”CLICK!”) ) );
for ($i=1; $i<=20; $i++) {
//$newOption is new option element
$newOption = $t->element(“option”, array(“value”=>$i), “Count down: ” . $i );
//$select adopt as it’s first child the $newOption element
$select->adoptTop( $newOption );
if ( isset($_GET[“cd”]) && $_GET[“cd”] == $i ) {
//Setting an attribute to an element
$newOption->setProperty(“selected”,”selected”);
}
}
//Body accepts new style rules
$t->SE(“body”)->setStyle(“margin”,”10px”);
//Body adopts
$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”) );
if (!isset( $_GET[“cd”] )) {
//Make simple alert with javascript
$t->alert(“Hello and welcome to mooHP”);
}
//Setting the
$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
$newCss->setStyles(array(“font-weight”=>”bold”,”font-size”=>”24px” ));
//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);
?>
[/code]
– Demo mooHP
– Descargar mooHP
– Mas información
Vía: Dzone