コード例 #1
0
ファイル: tables.php プロジェクト: nexocentric/silkworm
// Work     : (ml)Silkworm (tables 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";
//////////////////////
//start example data->
$table = array(array("column 1", "column 2", "column 3"), array("Assisted", "text", "markup"), array("definitely", "way", "better!!"));
//<-end example data
//////////////////////
#-----------------------------------------------------------
# example 1 (completely manual - tedious, but has uses)
#-----------------------------------------------------------
$example1 = new Silkworm();
$example1->table("class", "example-table-1", $example1->tr(array("class" => "top-row"), $example1->th("column 1"), $example1->th("column 2"), $example1->th("column 3")), $example1->tr("class", "middle-row", $example1->td("Text"), $example1->td("markup"), $example1->td("manually...")), $example1->tr("class", "bottom-row", array("id" => "table-footer"), $example1->td("assistance"), $example1->td("greatly"), $example1->td("required...")));
#-----------------------------------------------------------
# example 2 (autoTable allows you to use pure PHP arrays)
#-----------------------------------------------------------
$example2 = new Silkworm();
$example2->autoTable($table);
//that's it we have a table
//however... the formatting isn't there... hold on
#-----------------------------------------------------------
# example 3 (with full attributes)
#-----------------------------------------------------------
$rowAttributes = array(array("class" => "top-row"), array("class" => "middle-row"), array("class", "bottom-row"));
$example3 = new Silkworm();
$example3->autoTable($table, true, "class", "example-table-3", $rowAttributes);
//we now have a table that the same as the one above
#-----------------------------------------------------------
コード例 #2
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