Ejemplo n.º 1
0
<?php

require_once "config-site.php";
use Bootsole as BS;
$header_content = ["author" => "Alex Weissman", "site_title" => SITE_TITLE, "page_title" => "Simple, nested templating for rendering Bootstrap themed pages with PHP", "description" => "A sample page for Bootsole", "favicon_path" => BS\URI_PUBLIC_ROOT . "css/favicon.ico"];
$content = ["@header" => $header_content, "@name" => "test", "heading_main" => "Welcome to Bootsole", "content" => ["@template" => "<h2>Horizontal Form</h2>\n            {{horizontal}}\n             <h2>Vertical Form</h2>\n            {{vertical}}", "@content" => []]];
// Load validation schema (requires the Fortress package)
$vs = new Fortress\ClientSideValidator(BS\PATH_SCHEMA . "forms/philosophers.json", "en_US");
$fb = new BS\FormBuilder(["@layout" => "horizontal", "@components" => ['user_name' => ['@type' => 'text', '@display' => 'disabled', '@label' => 'Username', '@placeholder' => 'Please enter the user name'], 'title' => ['@type' => 'select', '@label' => 'Title', '@multiple' => true, '@items' => ['ta' => ['@label' => 'Teaching Assistant'], 'street_lord' => ['@label' => 'Street Lord'], 'adjunct' => ['@label' => 'Adjunct Instructor'], 'assistant' => ['@label' => 'Assistant Professor'], 'associate' => ['@label' => 'Associate Professor'], 'professor' => ['@label' => 'Professor'], 'emeritus' => ['@label' => 'Professor Emeritus']], '@default' => 'emeritus', '@prepend' => "<span class='input-group-addon'><i class='fa fa-fw fa-mortar-board'></i></span>"], 'email' => ['@type' => 'email', '@label' => 'Email', '@prepend' => "<span class='input-group-addon'><a href='mailto: blah@blah.com'><i class='fa fa-fw fa-envelope'></i></a></span>", '@placeholder' => 'Email goes here'], 'password' => ['@type' => 'password', '@label' => 'Password', '@placeholder' => 'Pick a good one', '@default' => 'dumb'], 'bio' => ['@type' => 'textarea', '@label' => 'Bio', '@placeholder' => "What's your deal?", '@rows' => '10'], 'bunnies' => ['@template' => "\n                <div class='row'>\n                    <div class='col-sm-8'>\n                        <input type='number' class='form-control' name='{{_name}}' autocomplete='off' value='{{_value}}' placeholder='{{_placeholder}}' {{_validator}} {{_display}}>\n                    </div>\n                    <div class='col-sm-4'>\n                        {{stuff}}\n                    </div>\n                </div>", '@type' => 'number', '@label' => 'Bunnies', '@placeholder' => 'So many...', 'stuff' => "bunnies left to pet"], 'beard' => ['@type' => 'toggle', '@label' => 'Beard', '@multiple' => true, '@prepend' => "<span class='input-group-addon'><i class='fa fa-fw fa-trophy'></i></span>", '@item_classes' => ['btn-primary'], '@items' => ['fluffy' => ['@label' => 'Fluffy'], 'scraggly' => ['@label' => 'Scraggly'], 'pointy' => ['@label' => 'Pointy']]], 'wakeup' => ['@type' => 'selecttime', '@label' => 'Wakeup Call', '@label_width' => "4", '@prepend' => "<span class='input-group-addon'><i class='fa fa-fw fa-clock-o'></i></span>", '@time_start' => '5:00 am', '@time_end' => '12:00 pm', '@time_increment' => 30, '@placeholder' => 'When?', '@default' => '10:30 am'], 'school' => ['@type' => 'bootstrapradio', '@label' => 'School', '@items' => ['epicurist' => ['@title' => 'Epicurist.  Relax and enjoy life.', '@label' => "<i class='fa fa-cutlery'></i>"], 'futurist' => ['@title' => 'Futurist.  Cyborgs unite!', '@label' => "<i class='fa fa-space-shuttle'></i>"], 'stoic' => ['@title' => 'Stoic.  Grin and bear it.', '@label' => "<i class='fa fa-tree'></i>"]]], 'tos' => ['@type' => 'switch', '@label' => "TOS", '@text' => "I agree to the Terms and Conditions", '@text_on' => "Yes", '@text_off' => "No", '@item_value' => "yessir"], 'special_offers' => ['@type' => 'checkbox', '@label' => "Offers", '@display' => "disabled", '@text' => "Send me special offers", '@item_value' => "yessir"], 'btn_submit' => new BS\FormButtonBuilder(["@type" => "submit", "@label" => "Submit", "@css_classes" => ["btn-success", "btn-lg"]])], "@values" => ['email' => "*****@*****.**", 'wakeup' => "11:00 am", 'beard' => 'pointy', 'password' => "yo", 'school' => 'epicurist', 'tos' => "yessir"], "@validators" => $vs->clientRules()], "forms/form-philosophers.html");
$fb2 = clone $fb;
$fb2->layout("vertical");
$fb2->getComponent("user_name")->display("show");
$pb = new BS\PageBuilder($content);
$pb->getContent("content")->setContent("horizontal", $fb);
$pb->getContent("content")->setContent("vertical", $fb2);
echo $pb->render();
Ejemplo n.º 2
0
<?php

require_once "config-site.php";
use Bootsole as BS;
$header_content = ["author" => "Alex Weissman", "site_title" => SITE_TITLE, "page_title" => "Simple, nested templating for rendering Bootstrap themed pages with PHP", "description" => "A sample page for Bootsole", "favicon_path" => BS\URI_PUBLIC_ROOT . "css/favicon.ico"];
$content = ["@header" => $header_content, "@name" => "test", "heading_main" => "Welcome to Bootsole", "content" => "Hey, I'm the content!"];
$pb = new BS\PageBuilder($content);
echo $pb->render();
Ejemplo n.º 3
0
<?php

require_once "config-site.php";
use Bootsole as BS;
$header_content = ["author" => "Alex Weissman", "site_title" => SITE_TITLE, "page_title" => "Button components", "description" => "Button components for Bootsole", "favicon_path" => BS\URI_PUBLIC_ROOT . "css/favicon.ico"];
$content = ["@header" => $header_content, "@name" => "test", "heading_main" => "Buttons", "content" => ["@template" => "<h2>Dropdown Button</h2>\n            {{dropdown_button}}\n            <h2>Combo button</h2>\n            {{combo_button}}\n            ", "@content" => ["combo_button" => new BS\ButtonGroupBuilder(["@items" => [["@type" => "button", "@label" => "Do it!", "@css_classes" => ["btn-warning"], "@name" => "action1", "@display" => "disabled"], ["@type" => "button", "@label" => "Do it again!", "@css_classes" => ["btn-danger"], "@name" => "action2"], ["@type" => "button", "@css_classes" => ["btn-danger"], "@name" => "dropdown_addon", "@align" => "inherit", "@items" => ["algebra" => ["@label" => "Algebra", "@url" => BS\URI_PUBLIC_ROOT . "courses/algebra"], "calculus" => ["@label" => "Calculus", "@url" => BS\URI_PUBLIC_ROOT . "courses/calculus", "@display" => "disabled"]]]]])]]];
// Build a dropdown:
$dropdown_content = ["@align" => "right", "@label" => "Press me!", "@css_classes" => ["btn-success"], "@items" => ["algebra" => ["@label" => "Algebra", "@url" => BS\URI_PUBLIC_ROOT . "courses/algebra"], "calculus" => ["@label" => "Calculus", "@url" => BS\URI_PUBLIC_ROOT . "courses/calculus"]]];
$dropdown = new BS\DropdownButtonBuilder($dropdown_content);
$pb = new BS\PageBuilder($content);
$pb->getContent("content")->setContent("dropdown_button", $dropdown);
//$pb->setContent("content", $dropdown);
echo $pb->render();
Ejemplo n.º 4
0
<?php

require_once "config-site.php";
use Bootsole as BS;
// Declaring a menu item OOPishly
$home = new BS\MenuItemBuilder(["@label" => "Home", "@url" => BS\URI_PUBLIC_ROOT]);
$nb = new BS\NavbarBuilder(["brand_label" => "Bootsole is Great!", "brand_url" => "http://github.com/alexweissman/bootsole", "@components" => ["btn1" => ["@type" => "button", "@css_classes" => ["btn-danger"], "@label" => "Self-Destruct!"], "message" => ["@type" => "text", "@text" => "Whazzup!!!"], "link" => ["@type" => "link", "@label" => "UserFrosting", "@url" => "https://www.userfrosting.com"], "search-form" => ["@type" => "form", "@align" => "right", "@form" => "\n                <form role='search'>\n                    <div class='form-group'>\n                      <input type='search' class='form-control' placeholder='Search'>\n                    </div>*\n                    <button type='submit' name='search' class='btn btn-default'>Submit</button>\n                </form>"], "main-menu" => ["@type" => "nav", "@align" => "right", "@items" => ["home" => $home, "about" => ["@display" => "disabled", "@label" => "About", "@url" => BS\URI_PUBLIC_ROOT . "about"], "courses" => ["@active" => true, "@label" => "Courses", "@url" => BS\URI_PUBLIC_ROOT . "courses", "@align" => "left", "@items" => ["algebra" => ["@label" => "Algebra", "@url" => BS\URI_PUBLIC_ROOT . "courses/algebra"], "calculus" => ["@label" => "Calculus", "@url" => BS\URI_PUBLIC_ROOT . "courses/calculus"]]]]]]]);
// You can add a component like this, too
$new_component = ["@type" => "nav", "@align" => "right", "@items" => ["contact" => ["@label" => "<i class='fa fa-paper-plane'></i>", "@url" => BS\URI_PUBLIC_ROOT . "contact"]]];
$nb->addComponent("side-menu", $new_component);
// ..and set an active item
//$nb->getComponent("main-menu")->setActiveItem("about");
$header_content = ["author" => "Alex Weissman", "site_title" => SITE_TITLE, "page_title" => "Simple, nested templating for rendering Bootstrap themed pages with PHP", "description" => "A sample page for Bootsole", "favicon_path" => BS\URI_PUBLIC_ROOT . "css/favicon.ico"];
$content = ["@header" => $header_content, "@name" => "test", "main-nav" => $nb, "heading_main" => "Welcome to Bootsole", "content" => "Hey, I'm the content!", "@footer" => ["@source" => "pages/footers/footer-default.html", "@content" => []]];
$pb = new BS\PageBuilder($content, "pages/page-jumbotron.html");
// ...or set it later!
//$pb->header($header);
$template = "\n<div class='media'>\n  <a class='media-left' href='#'>\n    <img src='{{img_src}}' alt='{{img_alt}}' width='64' height='64'>\n  </a>\n  <div class='media-body'>\n    <h4 class='media-heading'>{{heading}}</h4>\n    {{body}}\n  </div>\n</div>";
$content = ["img_src" => "http://avatars1.githubusercontent.com/u/5004534?v=3&s=400", "img_alt" => "Lord of the Fries", "heading" => "Alex Weissman", "body" => "Alex has many years of experience in software development, including web development using MySQL, PHP, and Javascript frameworks including jQuery and Twitter Bootstrap. Alex maintains the frontend website for Bloomington Tutors..."];
$hb1 = new BS\HtmlBuilder($content);
$hb1->setTemplate($template);
$hb2 = new BS\HtmlBuilder(["img_src" => "http://ww2.hdnux.com/photos/02/25/67/613833/3/gallery_thumb.jpg", "img_alt" => "Rambo", "heading" => "Sylvester Stallone", "body" => "Sylvester Gardenzio Stallone, nicknamed Sly Stallone, is an American actor, screenwriter and film director.  Stallone is well known for his Hollywood action roles..."]);
$hb2->setTemplate($template);
$hb3 = new BS\HtmlBuilder(["img_src" => "http://cdn.akamai.steamstatic.com/steamcommunity/public/images/avatars/d0/d0877f614b8bb52813a63915be4da611cfa0ac2e_medium.jpg", "img_alt" => "John McClane", "heading" => "Bruce Willis", "body" => "Walter Bruce Willis, better known as Bruce Willis, is an American actor, producer, and singer. His career began on the Off-Broadway stage and then in television in the 1980s, most notably as David Addison in Moonlighting..."]);
$hb3->setTemplate($template);
$jumbotron_template = "\n    <div class='jumbotron'>\n        <h1>{{heading}}</h1>\n        {{body}}\n    </div>";
$jumbotron_content = ["heading" => "Developers", "body" => ["@template" => $template, "@array" => [["img_src" => "http://avatars1.githubusercontent.com/u/5004534?v=3&s=400", "img_alt" => "Lord of the Fries", "heading" => "Alex Weissman", "body" => "Alex has many years of experience in software development, including web development using MySQL, PHP, and Javascript frameworks including jQuery and Twitter Bootstrap. Alex maintains the frontend website for Bloomington Tutors..."], ["img_src" => "http://ww2.hdnux.com/photos/02/25/67/613833/3/gallery_thumb.jpg", "img_alt" => "Rambo", "heading" => "Sylvester Stallone", "body" => "Sylvester Gardenzio Stallone, nicknamed Sly Stallone, is an American actor, screenwriter and film director.  Stallone is well known for his Hollywood action roles..."], ["img_src" => "http://cdn.akamai.steamstatic.com/steamcommunity/public/images/avatars/d0/d0877f614b8bb52813a63915be4da611cfa0ac2e_medium.jpg", "img_alt" => "John McClane", "heading" => "Bruce Willis", "body" => "Walter Bruce Willis, better known as Bruce Willis, is an American actor, producer, and singer. His career began on the Off-Broadway stage and then in television in the 1980s, most notably as David Addison in Moonlighting..."]]]];
$jumbotron = new BS\HtmlBuilder($jumbotron_content);
$jumbotron->setTemplate($jumbotron_template);
//echo $jumbotron->render();
$pb->setContent("content", $jumbotron);
Ejemplo n.º 5
0
<?php

require_once "config-site.php";
use Bootsole as BS;
$header_content = ["author" => "Alex Weissman", "site_title" => SITE_TITLE, "page_title" => "Sample Tablesorter table", "description" => "A sample page for Bootsole", "favicon_path" => BS\URI_PUBLIC_ROOT . "css/favicon.ico"];
$content = ["@header" => $header_content, "@name" => "test", "heading_main" => "A Tablesorter Table", "@footer" => ["@source" => "pages/footers/footer-default.html", "@content" => []]];
$pb = new BS\PageBuilder($content);
// Generate teachers
$teachers = ["1" => ["teacher_id" => "1", "user_name" => "socrizzle", "display_name" => "Socrates", "title" => "Big Cheese", "email" => "*****@*****.**", "num_students" => "2", "students" => ["@template" => "<a class='btn btn-success' href='student_details.php?student_id={{student_id}}'>{{display_name}}</a>", "@array" => ["A" => ["student_id" => "1", "display_name" => "Xenophon"], "B" => ["student_id" => "2", "display_name" => "Plato"]]]], "2" => ["teacher_id" => "2", "user_name" => "seamus", "display_name" => "Seamus", "title" => "Beanmaster", "email" => "*****@*****.**", "num_students" => "0", "students" => []], "3" => ["teacher_id" => "3", "user_name" => "plato", "display_name" => "Plato", "title" => "Idealist", "email" => "*****@*****.**", "num_students" => "1"]];
// Build custom menus
foreach ($teachers as $teacher_id => $teacher) {
    if ($teacher['num_students'] == 0) {
        $show_change = "show";
    } else {
        $show_change = "hidden";
    }
    if ($teacher['display_name'] == "Socrates") {
        $show_poison = "show";
    } else {
        $show_poison = "disabled";
    }
    $menu = new BS\DropdownButtonBuilder(["@type" => "button", "@label" => "Actions", "@css_classes" => ["btn-primary"], "@items" => ['get_podcast' => ['@label' => "<i class='fa fa-headphones'></i> Get podcast", '@css_classes' => ['btn-get-podcast'], '@data' => ["id" => $teacher_id]], 'poison' => ['@label' => "<i class='fa fa-flask'></i> Poison", '@css_classes' => ['btn-poison'], '@data' => ["id" => $teacher_id], '@display' => $show_poison], 'change' => ['@label' => "<i class='fa fa-money'></i> Give change for the bus", '@css_classes' => ['btn-give-change'], '@data' => ["id" => $teacher_id], '@display' => $show_change]]]);
    $teachers[$teacher_id]['menu'] = $menu;
}
$table_content = ["@columns" => ["info" => ["@label" => "Teacher", "@sorter" => "metatext", "@sort_field" => "user_name", "@initial_sort_direction" => "asc", "@cell_template" => "\n                    <div class='h4'>\n                        <a href='user_details.php?id={{teacher_id}}'>{{display_name}} ({{user_name}})</a>\n                    </div>\n                    <div>\n                        <i>{{title}}</i>\n                    </div>\n                    <div>\n                        <i class='fa fa-envelope'></i> <a href='mailto:{{email}}'>{{email}}</a>\n                    </div>"], "num_students" => ["@label" => "Students", "@sorter" => "metanum", "@sort_field" => "num_students", "@cell_template" => "<a class='btn btn-success' href='students.php?teacher_id={{teacher_id}}'>{{num_students}}</a>", "@empty_field" => "num_students", "@empty_value" => "0", "@empty_template" => "Zero"], "students" => ["@label" => "Student List", "@sorter" => "metanum", "@sort_field" => "num_students", "@cell_template" => "{{students}}", "@empty_field" => "students", "@empty_value" => [], "@empty_template" => "<i>None</i>"], "actions" => ["@label" => "Actions", "@cell_template" => "{{menu}}"]], "@rows" => $teachers];
$table = new BS\TableBuilder($table_content);
$pb->setContent("content", $table);
echo $pb->render();