示例#1
0
}

.medium-cell {
\tbackground-color: #C2AE8E;
}

.dark-cell {
\tbackground-color: #8C4B22;
}

div table.hot-pink {
\tbackground-color: #F433ff;
}

PAGE_STYLES;
$displayExamples = new Silkworm();
$displayExamples->doctype("html");
$displayExamples["head"] = $displayExamples->head($displayExamples->meta("charset", "UTF-8"), $displayExamples->title("Silkworm (tables example)"), $displayExamples->newline(), $displayExamples->meta("name", "description", "content", "This demostrates how to use tables."), $displayExamples->meta("name", "viewport", "content", "width=device-width"), $displayExamples->newline(), $displayExamples->comment("page styles"), $displayExamples->style($style));
$displayExamples["body"] = $displayExamples->body($displayExamples->newline(), $displayExamples->comment("example 1"), $displayExamples->div($displayExamples->p("Example 1 (basic)"), (string) $example1), $displayExamples->newline(), $displayExamples->comment("example 2"), $displayExamples->div($displayExamples->p("Example 2 (autoTable no attributes)"), (string) $example2), $displayExamples->newline(), $displayExamples->comment("example 3"), $displayExamples->div($displayExamples->p("Example 3 (autoTable with attributes)"), (string) $example3), $displayExamples->newline(), $displayExamples->comment("example 4"), $displayExamples->div($displayExamples->p("Example 4 (nested tables)"), (string) $example4), $displayExamples->newline(), $displayExamples->comment("example 5"), $displayExamples->div($displayExamples->p("Example 5 (alternating attributes)"), (string) $example5), $displayExamples->newline(), $displayExamples->comment("example 6"), $displayExamples->div($displayExamples->p("Example 6 (cell attributes)"), $displayExamples->autoTable($tableCellAttributes)), $displayExamples->newline(), $displayExamples->comment("example 7???"), $displayExamples->div($displayExamples->p("Example 7 (???)"), $displayExamples->repeat($displayExamples->autoTable($forReal, "class", "hot-pink"), rand(1, 40))));
$displayExamples["page"] = $displayExamples->html((string) $displayExamples["head"], (string) $displayExamples["body"]);
//let's see how it looks
print $displayExamples->stringWithDocumentHeader((string) $displayExamples["page"]);
////////////////////////////////////////////////////////////////////////////////
// The MIT License (MIT)
//
// Copyright (c) 2013 Dodzi Dzakuma (http://www.nexocentric.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
示例#2
0
TEXT2;
$text3 = <<<TEXT3
Example 3 is available to show that this library is fairly  
Dynamic and the only thing holding you back is creativity
TEXT3;
$table = array(array("Example 1", "Example 2", "Example 3"), array($text1, $text2, $text3));
$rowAttributes = array(array("class", "table-header"));
//this is for our head block
$head = new Silkworm();
$head->head($head->comment("start standard header block"), $head->meta("charset", "UTF-8"), $head->title("Silkworm (quick start example)"), $head->newline(), $head->meta("name", "description", "content", "This is just a quick example on how to get started."), $head->meta("name", "viewport", "content", "width=device-width"), $head->comment("end standard header block"), $head->newline(), $head->comment("a stylesheet for some flair?"), $head->comment("just passing a parameter makes it easier"), $head->style($style));
//this is for the body
$body = new Silkworm();
$divAttributes = array("class" => "content");
$body->body($body->div($body->div($divAttributes, $body->p("This is a short and sweet example to demonstrate Silkworm's usage.")), $body->newline(), $body->autoTable($table, $rowAttributes)));
//you can also define a doctype this way if you like
$example2 = new Silkworm();
$example2->doctype("HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"");
$example2->html($head, $body);
#-----------------------------------------------------------
# advanced example (probably the way that you might use it)
#-----------------------------------------------------------
//for a deeper understanding of how this works, please see
//the modular.php for more information
$example3 = new Webpage();
#-----------------------------------------------------------
# remove the comment mark from an example and see how it works :)
#-----------------------------------------------------------
#print((string)$example1);
#print((string)$example2);
#print($example3->display());
////////////////////////////////////////////////////////////////////////////////
示例#3
0
 /**
  * @test
  * @depends retrieveNonexistantFragment
  */
 public function fragmentOfFragmentsInHtmlTag()
 {
     $html = new Silkworm();
     $html->doctype("html");
     $html[0] = $html->h1("hello");
     $html["zebra"] = $html->span($html->p("stripes"));
     $html["comment"] = $html->comment("this works");
     $html["content"] = $html->div((string) $html[0], (string) $html["comment"], (string) $html["zebra"]);
     $this->assertSame("<html>\n" . "\t<div>\n" . "\t\t<h1>hello</h1>\n" . "\t\t<!-- this works -->\n" . "\t\t<span>\n" . "\t\t\t<p>stripes</p>\n" . "\t\t</span>\n" . "\t</div>\n" . "</html>\n", (string) $html->html($html["content"]), "Failed to return div tag as parent.");
 }
示例#4
0
 private function getPageContent()
 {
     $content = new Silkworm();
     $content->div($content->p("Just a crappy example. " . "This can be improved."));
     return $content;
 }
示例#5
0
// Copyright: (c) 2013 Dodzi Y. Dzakuma (http://www.nexocentric.com)
//                See copyright at footer for more information.
// Version  : 1.00
////////////////////////////////////////////////////////////////////////////////
require_once "../Silkworm.php";
#-----------------------------------------------------------
# example 1 (completely manual - tedious, but has uses)
#-----------------------------------------------------------
$xmlDrinks = new Silkworm("xml");
//this sets silkworm to default to xml styles
$xmlDrinks->xmlVersion("1.0");
$xmlDrinks->drinks($xmlDrinks->cdata("This contains a lot of data about drinks that don't really matter."), $xmlDrinks->hot($xmlDrinks->alcohols($xmlDrinks->drink("wine"), $xmlDrinks->drink("coffee"), $xmlDrinks->drink("rum")), $xmlDrinks->teas($xmlDrinks->drink("green"), $xmlDrinks->drink("oolong"), $xmlDrinks->drink("white")), $xmlDrinks->coffees($xmlDrinks->drink("espresso"), $xmlDrinks->drink("milk"), $xmlDrinks->drink("black")), $xmlDrinks->juices($xmlDrinks->drink("apple"), $xmlDrinks->drink("orange"), $xmlDrinks->drink("tomato")), $xmlDrinks->sodas($xmlDrinks->drink("ginger ale"), $xmlDrinks->drink("apple hop"), $xmlDrinks->drink("caramel"))), $xmlDrinks->cold($xmlDrinks->alcohols($xmlDrinks->drink("vodka"), $xmlDrinks->drink("beer"), $xmlDrinks->drink("wine")), $xmlDrinks->teas($xmlDrinks->drink("green"), $xmlDrinks->drink("corn"), $xmlDrinks->drink("white")), $xmlDrinks->coffees($xmlDrinks->drink("frappuccino"), $xmlDrinks->drink("iced"), $xmlDrinks->drink("espresso")), $xmlDrinks->juices($xmlDrinks->drink("grapefruit"), $xmlDrinks->drink("apple"), $xmlDrinks->drink("orange")), $xmlDrinks->sodas($xmlDrinks->drink("cola"), $xmlDrinks->drink("root beer"), $xmlDrinks->drink("punch"))));
#-----------------------------------------------------------
# example 2 (just to reiterate on the modular example)
#-----------------------------------------------------------
$xmlData = new Silkworm("xml");
//this sets silkworm to default to xml styles
$xmlData->xmlVersion("1.0", array("encoding" => "utf-8"));
//XML version definition
$xmlData->doctype("HTML");
//doctype definition
#same object, different structure
$xmlData["novels"] = $xmlData->writtenMedia($xmlData->horror($xmlData->work("death"), $xmlData->work("pain"), $xmlData->work("suffering")), $xmlData->fantasy($xmlData->work("dragons"), $xmlData->work("magic"), $xmlData->work("fire wildthings")), $xmlData->scienceFiction($xmlData->work("L.A.S.E.R.s"), $xmlData->work("hyper warp"), $xmlData->work("time parameter")));
#same object, different structure
$xmlData["magazines"] = $xmlData->writtenMedia($xmlData->fashion($xmlData->work("shirts"), $xmlData->work("suits"), $xmlData->work("blouses")), $xmlData->tech($xmlData->work("gigakeys"), $xmlData->work("random access keyboards"), $xmlData->work("laundry and lint")), $xmlData->cooking($xmlData->work("vegetables"), $xmlData->work("bagels"), $xmlData->work("mexican")));
#same object, different structure
$xmlData["newspapers"] = $xmlData->writtenMedia($xmlData->local($xmlData->work("farmer bill"), $xmlData->work("effington daily"), $xmlData->work("high school")), $xmlData->national($xmlData->work("tabloid central"), $xmlData->work("politics the right way"), $xmlData->work("security and you")), $xmlData->scientific($xmlData->work("relativity"), $xmlData->work("obscurity"), $xmlData->work("obtuse")));
#same object, different structure
$xmlData["comics"] = $xmlData->writtenMedia($xmlData->superhero($xmlData->work("superpunch"), $xmlData->work("maggot person"), $xmlData->work("vunerable human")), $xmlData->manga($xmlData->work("squids and octopus"), $xmlData->work("ninjas and cowboys"), $xmlData->work("firballs and school girls")), $xmlData->strip($xmlData->work("the cashews"), $xmlData->work("kalvin cline"), $xmlData->work("diesel powered")));
#same object, different structure
$xmlData["blogs"] = $xmlData->writtenMedia($xmlData->news($xmlData->work("the post"), $xmlData->work("the site"), $xmlData->work("the post site")), $xmlData->photo($xmlData->work("mine"), $xmlData->work("my friend"), $xmlData->work("my dad")), $xmlData->video($xmlData->work("nsfw"), $xmlData->work("nsfw x 2"), $xmlData->work("nsfw duplicated x 4")));