コード例 #1
0
ファイル: tables.php プロジェクト: nexocentric/silkworm
\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
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
コード例 #2
0
ファイル: modular.php プロジェクト: nexocentric/silkworm
 private function getPageContent()
 {
     $content = new Silkworm();
     $content->div($content->p("Just a crappy example. " . "This can be improved."));
     return $content;
 }
コード例 #3
0
ファイル: basic.php プロジェクト: nexocentric/silkworm
<?php

////////////////////////////////////////////////////////////////////////////////
// Work     : (ml)Silkworm (basic example)
// Copyright: (c) 2013 Dodzi Y. Dzakuma (http://www.nexocentric.com)
//                See copyright at footer for more information.
// Version  : 1.00
////////////////////////////////////////////////////////////////////////////////
require_once "../Silkworm.php";
require_once "./modular.php";
#-----------------------------------------------------------
# basic example (brute force???)
#-----------------------------------------------------------
$example1 = new Silkworm();
$example1->doctype("html");
$example1->html($example1->head($example1->comment("start standard header block"), $example1->meta("charset", "UTF-8"), $example1->title("Silkworm (basic example)"), $example1->newline(), $example1->meta("name", "description", "content", "This is just a quick example on how to get started."), $example1->meta("name", "viewport", "content", "width=device-width"), $example1->comment("end standard header block"), $example1->newline(), $example1->comment("a stylesheet for some flair?"), $example1->comment("there's a better way to do this, please see the next tutorial"), $example1->style("")), $example1->body($example1->div($example1->div("class", "content", $example1->p("This is a short and sweet example to demonstrate Silkworm usage.")), $example1->newline(), $example1->table($example1->tr("class", "table-header", $example1->th("Example 1"), $example1->th("Example 2"), $example1->th("Example 3")), $example1->tr($example1->td("Example 1 shows you that you can write out everything " . "directly as a set of tags if you like. If you want to make " . "a standard template that you plug every thing into, this " . "is one method that you might want to employ."), $example1->td("Example 2 shows that you can break everything up into " . "more manageable parts, that you can then toss into Silkworm " . "for some quick formatting and parsing before you display it. " . "This allows you to divide web page creation into parts that " . "can be managed by classes that you define yourself. " . "This also introduces the autoTable() function which " . "accepts a multidimensional array and turns it into an " . "HTML table."), $example1->td("Example 3 is available to show that this library is fairly " . "Dynamic and the only thing holding you back is creativity."))))));
#-----------------------------------------------------------
# organized example (easier to work with)
#-----------------------------------------------------------
$style = "";
//the table that we did in example 1
$text1 = <<<TEXT1
Example 1 shows you that you can write out everything directly 
as a set of tags if you like. If you want to make a standard 
template that you plug every thing into, this is one method 
that you might want to employ.
TEXT1;
$text2 = <<<TEXT2
Example 2 shows that you can break everything up into  
more manageable parts, that you can then toss into Silkworm  
for some quick formatting and parsing before you display it  
コード例 #4
0
ファイル: SilkwormTest.php プロジェクト: nexocentric/silkworm
 /**
  * @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.");
 }