예제 #1
0
파일: forms.php 프로젝트: sintoris/Known
<?php

/**
	 * 	Howdy!
	 
		This is a really simple example of how to use forms.
		
		If you haven't already, check out index.php first.
*/
// Load Bonita
require_once dirname(dirname(__FILE__)) . '/start.php';
// Add this directory as an additional path
\Bonita\Main::additionalPath(dirname(__FILE__));
// Instantiate template
$t = new \Bonita\Templates();
// Set the body
$t->body = $t->draw('pages/forms');
// Was the form already submitted?
if (\Bonita\Forms::formSubmitted()) {
    // If so, validate the form token (to prevent nefarious tomfoolery)
    if (\Bonita\Forms::validateToken()) {
        // If the action completed, set the body to our form submission template
        $t->body = $t->draw('pages/example/formsubmitted');
    }
}
// Draw the page
$t->__(array('title' => 'Forms example'))->drawPage();
예제 #2
0
파일: index.php 프로젝트: sintoris/Known
<?php

/**
	 * 	Hello!
	 
	 	This is the simplest of all possible examples (ish). It'll draw a
	 	page of text in two template types.
	Stick ?t=rss on the end of the URL to load the same page in RSS.
*/
// Load Bonita
require_once dirname(dirname(__FILE__)) . '/start.php';
// Add this directory as an additional path
\Bonita\Main::additionalPath(dirname(__FILE__));
// Instantiate template
$t = new \Bonita\Templates();
// For the purposes of this example, some GET line fun to choose which template
// we're using
$t->detectTemplateType();
if (!empty($_GET['t'])) {
    $t->setTemplateType($_GET['t']);
}
// Page contents:
// Page title
$t->title = 'Example page';
// A link back to git
$t->url = 'https://github.com/benwerd/bonita';
// Page body
$t->body = $t->draw('pages/example');
// And finally, draw the page
$t->drawPage();
// Or, we could have done it in one call, this way:
예제 #3
0
 /**
  * Takes some text and runs it through the current template's processor.
  * This is in the form of a template at processors/text, or processors/X where X
  * is a custom processor
  * @param $content Some content
  * @param $processor Optionally, the processor you want to use (default: text)
  * @return string Formatted content (or the input content if the processor doesn't exist)
  */
 function process($content, $processor = 'text')
 {
     $t = new \Bonita\Templates();
     $t->content = $content;
     $t->setTemplateType($this->getTemplateType());
     if (($result = $t->draw('processor/' . $processor, false)) !== false) {
         return $result;
     }
     return $content;
 }