function index()
{
    global $_controller, $_action;
    $alias = isset($params['alias']) ? $params['alias'] : 'index';
    $data = array('goods' => getGoodsList());
    $path = TEMPLATES_PATH . "/{$_controller}/{$_action}.ctp";
    return renderTemplate($path, $data);
}
function renderAccountPageHeader($hooks = array())
{
    global $master_account;
    if (isset($_SESSION["userCakeUser"]) && is_object($_SESSION["userCakeUser"]) and $_SESSION["userCakeUser"]->user_id == $master_account) {
        $hooks["#SB_STYLE#"] = 'sb-admin-master.css';
    } else {
        $hooks["#SB_STYLE#"] = 'sb-admin.css';
    }
    return renderTemplate(ACCOUNT_HEAD_FILE, $hooks);
}
Exemple #3
0
function generateModel($table, $allColumns, $foreignKeys, $modelsPath)
{
    $columns = $allColumns[$table];
    $params = ['table' => $table, 'class_name' => Inflector::classify($table), 'validations' => generateValidationRules($columns), 'columns' => getPrettyColumns($columns), 'display_col' => getDisplayColumn($columns), 'auto_joins' => !empty($foreignKeys['foreign_keys'][$table]) ? getAutoJoins($foreignKeys['foreign_keys'][$table], $allColumns) : ''];
    $output = renderTemplate($params);
    //$associations  = '';//static::generateAssociations($table, $foreignKeys, $columns);
    $file = $modelsPath . $params['class_name'] . '.php';
    $keep = file_exists($file) ? StringUtils::between('//START', '//END', file_get_contents($file)) : '';
    $keep = trim($keep);
    $tpl = str_replace('//START//END', "//START\n\n\t{$keep}\n\n    //END", $output);
    FileUtils::createDirectoriesAndSaveFile($file, $tpl);
}
function renderTemplate($__basedir, $template, array $__templateData = array())
{
    $render = function ($__path, array $__templateData = array()) use($__basedir) {
        $render = function ($template, array $data = array()) use($__basedir) {
            return renderTemplate($__basedir, $template, $data);
        };
        ob_start();
        extract($__templateData);
        unset($__templateData);
        include $__basedir . '/../templates/' . $__path . '.php';
        return ob_get_clean();
    };
    return $render($template, $__templateData);
}
Exemple #5
0
 * Generate the EnlighterJS Documentation Pages
 * @author Andi Dittrich
 * @license MIT Style X11
 */
// Get Build Version
define('EJS_VERSION', count($argv) >= 3 ? $argv[2] : 'unknown');
define('EJS_PACKAGE_ZIP', 'https://github.com/AndiDittrich/EnlighterJS/archive/v' . EJS_VERSION . '.zip');
define('EJS_PACKAGE_TGZ', 'https://github.com/AndiDittrich/EnlighterJS/archive/v' . EJS_VERSION . '.tar.gz');
require 'global.php';
// === GETTING STARTED ============================================================
renderTemplate($outputDir . 'index.html', array('PAGE' => 'Resources/Pages/GettingStarted.phtml', 'title' => 'EnlighterJS', 'subtitle' => 'An OpenSource Syntax Highlighter'));
// === Changelog ============================================================
renderTemplate($outputDir . 'Changelog.html', array('PAGE' => 'Resources/Pages/Changelog.phtml', 'title' => 'Changelog', 'subtitle' => 'The History of EnlighterJS'));
// === Documentation ============================================================
renderTemplate($outputDir . 'Documentation.html', array('PAGE' => 'Resources/Pages/Documentation.phtml', 'title' => 'Documentation', 'subtitle' => 'Feature Reference'));
// === Languages ============================================================
foreach ($languageExamples as $currentLanguage) {
    renderTemplate($outputDir . 'Language.' . $currentLanguage . '.html', array('PAGE' => 'Resources/Pages/Languages.phtml', 'title' => 'Languages', 'subtitle' => 'Build-In Support', 'currentLanguage' => $currentLanguage, 'languageExamples' => $languageExamples, 'themes' => $themes));
}
// === Themes ============================================================
foreach ($themes as $theme) {
    renderTemplate($outputDir . 'Theme.' . $theme . '.html', array('PAGE' => 'Resources/Pages/Themes.phtml', 'title' => 'Themes', 'subtitle' => 'Enlighter`s Appearance', 'theme' => $theme, 'themes' => $themes));
}
// === Builder ============================================================
renderTemplate($outputDir . 'Builder.html', array('PAGE' => 'Resources/Pages/Builder.phtml', 'title' => 'Builder', 'subtitle' => 'Customized EnlighterJS Packages', 'languages' => $languageDescriptions));
// === Plugins ============================================================
renderTemplate($outputDir . 'Plugins.html', array('PAGE' => 'Resources/Pages/Plugins.phtml', 'title' => 'Plugins', 'subtitle' => 'Extend, Integrate'));
function renderTemplate($destination, $vars = array())
{
    file_put_contents($destination, captureTemplate('Resources/Web.phtml', $vars));
}
function generarPDF()
{
    $request = \Slim\Slim::getInstance()->request();
    $val = $request->params();
    $idproyecto = $val["idproyecto"];
    //obtener datos del alcance
    $con = getConnection();
    $pstmt = $con->prepare("SELECT *  FROM ALCANCE  WHERE id_proyecto= ?");
    $pstmt->execute(array($idproyecto));
    $alcance = $pstmt->fetch(PDO::FETCH_ASSOC);
    $pstmt = $con->prepare("SELECT nombre_proyecto \n\t\t\tFROM PROYECTO\n\t\t\tWHERE id_proyecto = ? \n\t\t");
    $pstmt->execute(array($idproyecto));
    if ($id = $pstmt->fetch(PDO::FETCH_ASSOC)) {
        $alcance["proyecto"] = $id["nombre_proyecto"];
    }
    //obtener el archivo plantilla
    $html = file_get_contents('../views/alcance/plantillaPDFAlcance.html');
    //reemplazar las variables de la plantilla
    $outputHtml = renderTemplate($html, $alcance);
    //crear el pdf
    $dompdf = new DOMPDF();
    $dompdf->load_html($outputHtml);
    $dompdf->render();
    //setear el response como stream de bytes
    \Slim\Slim::getInstance()->response->headers->set('Content-Type', 'application/pdf');
    //devolver el archivo COMO STREAM
    return $dompdf->stream("Alcance.pdf");
}
			</div>
		  </div>
		  <div class="form-group">
			<div class="col-md-offset-3 col-md-6">
			  <input type="email" class="form-control" placeholder="Email" name='email'>
			</div>
		  </div>
		  <div class="form-group">
			<div class="col-md-12">
			  <button type="submit" class="btn btn-success submit" value='Resend'>Resend Activation</button>
			</div>
		  </div>
		</form>
      </div>	
      <?php 
echo renderTemplate("footer.html");
?>

    </div> <!-- /container -->

	<script>
        $(document).ready(function() {          
			// Load the header
			$(".navbar").load("header-loggedout.php", function() {
				$(".navbar .navitem-login").addClass('active');
			});
		  	
			alertWidget('display-alerts');
			  
		  	$("form[name='resend']").submit(function(e){
				var form = $(this);
Exemple #8
0
        $data = $control->_call('on' . $action, '');
    } else {
        exit('Action not found!');
    }
    if (method_exists($control, 'on_afterhandler')) {
        $m = 'on_afterhandler';
        $control->{$m}();
    }
    if (isset($data)) {
        //ob_clean();
        header('Content-Type: application/json; charset=UTF-8');
        $ret = json_encode($data);
    } else {
        header('Content-type: text/html; charset=UTF-8');
    }
} catch (Exception $e) {
    $error_msg = $e->__toString();
    $ret = json_encode(array('status' => 'ERROR', 'error_code' => $e->getCode(), 'error_msg' => $e->getMessage()));
}
$callback = getGPC('callback', 'string');
if (!empty($callback)) {
    $ret = "{$callback}({$ret});";
}
if (!empty($ret)) {
    die($ret);
}
if (!empty($view_datas)) {
    extract($view_datas, EXTR_SKIP);
}
@(include renderTemplate($module, $action));
Exemple #9
0
    public function testXMLTemplates()
    {
        $data = renderTemplate('dates/seminar_xml', $this->testData);
        $compare = '<raumzeit>
    <startwoche>0</startwoche>
    <datum>wöchentlich</datum>
    <wochentag>Montag</wochentag>
    <zeit>10:00-12:00</zeit>
    <raum>
        <gebucht>Hörsaal 1 &lt;br&gt;</gebucht>
        <freitext>&lt;script&gt;alert(&quot;böse&quot;);&lt;/script&gt;</freitext>
    </raum>
</raumzeit>
<raumzeit>
    <datum>12.05.2010</datum>
    <wochentag>Mittwoch</wochentag>
    <zeit>09:00-13:00</zeit>
    <raum>
        <gebucht></gebucht>
        <freitext>&lt;script&gt;alert(&quot;böse&quot;);&lt;/script&gt;</freitext>
    </raum>
</raumzeit>';
        $this->assertEquals($compare, $data);
        $data = renderTemplate('dates/date_xml', $this->testData, array('date' => new SingleDate()));
        $compare = '<date>Mo., 11.11.2010 12:00 - 14:00, Ort: Hörsaal 1 &lt;br&gt;</date>';
        $this->assertEquals($compare, $data);
    }
Exemple #10
0
function makePage($template, $layout)
{
    $result = renderTemplate($template);
    $result = renderLayout($result, $layout);
    return $result;
}
/**
 * Generate the EnlighterJS Example Pages
 * @author Andi Dittrich
 * @license MIT Style X11
 */
function cdnbase($file)
{
    global $argv;
    // Local Examples or Webbuild ?
    if (isset($argv[2]) && trim($argv[2]) == 'www') {
        return basename($file);
    } else {
        return '../' . $file;
    }
}
require 'global.php';
// setup metainit string
$metainit = '<meta name="EnlighterJS" content="Advanced javascript based syntax highlighting" data-language="javascript" data-indent="2" data-selector-block="pre" data-selector-inline="code" />';
// === Basic Examples =================================================
renderTemplate($outputDir . 'Example1.html', array('page' => 'Resources/ExampleData/Example1.phtml', 'pageTitle' => 'Basic EnlighterJS Example', 'header' => $metainit));
renderTemplate($outputDir . 'Example2-jsinit.html', array('page' => 'Resources/ExampleData/Example2-jsinit.phtml', 'pageTitle' => 'Javascript Initialization Example', 'header' => ''));
renderTemplate($outputDir . 'Example3-advanced.html', array('page' => 'Resources/ExampleData/Example3-advanced.phtml', 'pageTitle' => 'Advanced Javascript Example', 'header' => ''));
/**
 * Renders the template file and return HTML
 * @param Array $vars
 */
function renderTemplate($destination, $vars = array())
{
    file_put_contents($destination, captureTemplate('Resources/ExampleTemplate.phtml', $vars));
}
Exemple #12
0
require "admin/moddate.php";
$requestMapping = array("home" => 1, "produkte" => 2, "bestellung" => 3, "projekte" => 4, "links" => 5, "kontakt" => 6, "impressum" => 7, "agb" => 8);
$base = isset($base) ? $base : "home";
$id = $requestMapping[$base];
$res = getPageContents($id);
$viewModel = array("siteBase" => SITE_BASE, "title" => $res["title"], "content" => $res["content"], "lastModification" => getLastModificationDate());
if ($base == "produkte") {
    $viewModel["onProductPage"] = true;
    $viewModel["items"] = loadProducts();
} else {
    if ($base == "bestellung") {
        $viewModel["onOrderPage"] = true;
        $viewModel["items"] = loadProducts();
    }
}
renderTemplate("page-base", $viewModel);
function loadProducts()
{
    global $mysqli;
    $p = array();
    $res = $mysqli->query("select id, title, description, category, price, image from jube_items order by id");
    while ($row = $res->fetch_assoc()) {
        if (!$p[$row["category"]]) {
            $p[$row["category"]] = array();
        }
        $item = array("id" => $row["id"], "title" => $row["title"], "description" => $row["description"], "price" => formatPrice($row["price"]), "category" => $row["category"]);
        if (!empty($row["image"])) {
            $item["thumb"] = PUBLIC_MEDIA_DIR . $row["image"] . "/size_thumb.jpg";
            $item["large"] = PUBLIC_MEDIA_DIR . $row["image"] . "/size_large.jpg";
        }
        $p[$row["category"]][] = $item;
function renderTemplate($template_block, $context)
{
    $renderedHTML = "";
    $foreachIsOpen = false;
    $ifIsOpen = false;
    $ifCondition = false;
    $ifNotIsOpen = false;
    $ifNotCondition = false;
    $innerBlock = array();
    $currentContext = "";
    foreach ($template_block as $node) {
        //buscando si es un cierre de foreach
        if (strpos($node, "{{endfor {$currentContext}}}") !== false) {
            if ($foreachIsOpen) {
                $foreachIsOpen = false;
                if (isset($context[$currentContext])) {
                    foreach ($context[$currentContext] as $forcontext) {
                        $renderedHTML .= renderTemplate($innerBlock, $forcontext);
                    }
                }
                $innerBlock = array();
                $currentContext = "";
                continue;
            }
        }
        //buscando si es un cierre de if
        if (strpos($node, "{{endifnot {$currentContext}}}") !== false) {
            if ($ifNotIsOpen) {
                $ifNotIsOpen = false;
                $renderedHTML .= $ifNotCondition ? renderTemplate($innerBlock, $context) : "";
                $currentContext = "";
                $innerBlock = array();
                $ifNotCondition = false;
                continue;
            }
        }
        if (strpos($node, "{{endif {$currentContext}}}") !== false) {
            if ($ifIsOpen) {
                $ifIsOpen = false;
                $renderedHTML .= $ifCondition ? renderTemplate($innerBlock, $context) : "";
                $currentContext = "";
                $innerBlock = array();
                $ifCondition = false;
                continue;
            }
        }
        if ($foreachIsOpen || $ifIsOpen || $ifNotIsOpen) {
            $innerBlock[] = $node;
            continue;
        }
        //buscando si es una apertura de foreach
        if (strpos($node, "{{foreach") !== false) {
            if (!$foreachIsOpen) {
                $foreachIsOpen = true;
                $currentContext = trim(str_replace("}}", "", str_replace("{{foreach", "", $node)));
                continue;
            }
        }
        //buscando si es un if
        if (strpos($node, "{{ifnot") !== false) {
            if (!$ifNotIsOpen) {
                $ifNotIsOpen = true;
                $currentContext = trim(str_replace("}}", "", str_replace("{{ifnot", "", $node)));
                if (isset($context[$currentContext])) {
                    $ifNotCondition = $context[$currentContext] == false;
                }
                continue;
            }
        }
        if (strpos($node, "{{if") !== false) {
            if (!$ifIsOpen) {
                $ifIsOpen = true;
                $currentContext = trim(str_replace("}}", "", str_replace("{{if", "", $node)));
                if (isset($context[$currentContext])) {
                    $ifCondition = $context[$currentContext] && true;
                }
                continue;
            }
        }
        //remplazando las variables del nodo
        $nodeReplace = preg_split("/(\\{\\{\\w*\\}\\})/", $node, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
        foreach ($nodeReplace as $item) {
            if (strpos($item, "{{") !== false) {
                $index = trim(str_replace("}}", "", str_replace("{{", "", $item)));
                $item = isset($context[$index]) ? $context[$index] : "";
            }
            $renderedHTML .= $item;
        }
    }
    return $renderedHTML;
}
    if (!empty($amount)) {
        $product = $allItems[$id];
        if (!$product) {
            continue;
        }
        $product["amount"] = $amount;
        $totalPrice = $amount * $product["price"];
        $toPay += $totalPrice;
        $product["totalPrice"] = formatPrice($totalPrice);
        $product["price"] = formatPrice($product["price"]);
        $order[] = $product;
    }
}
date_default_timezone_set("Europe/Berlin");
$_POST["orderDate"] = date("d.m.Y H:i:s");
$_POST["itemsOrdered"] = $order;
$_POST["toPay"] = formatPrice($toPay);
$purchaseOrder = renderTemplateToString("purchase-order", $_POST);
$article = getPageContents(9);
$article["siteBase"] = SITE_BASE;
renderTemplate("page-base", array("title" => $article["title"], "content" => $article["content"], "siteBase" => SITE_BASE, "orderData" => json_encode($_POST), "orderDetails" => $purchaseOrder, "onConfirmOrderPage" => true));
function loadProducts()
{
    global $mysqli;
    $p = array();
    $res = $mysqli->query("select id, title, description, category, price from jube_items order by id");
    while ($row = $res->fetch_assoc()) {
        $p[$row["id"]] = array("id" => $row["id"], "title" => $row["title"], "description" => $row["description"], "price" => $row["price"], "category" => $row["category"]);
    }
    return $p;
}
<?php

require "settings.php";
require "mysql-connector.php";
require LIB_DIR . "/core/template.php";
$content = json_decode($_POST["order"]);
$content->{"standalone"} = true;
$headers = "Content-Type: text/html; charset=utf-8\n";
$mailContent = renderTemplateToString("purchase-order", $content);
$name = $content->{"name"};
$time = $content->{"orderDate"};
$subject = "Bestellung von {$name} um {$time}";
mail(ORDER_MAIL_TO, $subject, $mailContent, $headers);
mail($content->{"mail"}, "Kopie ihrer {$subject}", $mailContent, $headers);
$article = getPageContents(10);
$article["siteBase"] = SITE_BASE;
renderTemplate("page-base", $article);
Exemple #16
0
/**
 * Page for the Bookmarklet.
 */
function pageBookmarklet()
{
    global $PIVOTX;
    // check if the user is logged in.
    if (!$PIVOTX['session']->isLoggedIn()) {
        pageLogin('small');
        die;
    }
    $currentuser = $PIVOTX['users']->getUser($PIVOTX['session']->currentUsername());
    $entry = array();
    if ($PIVOTX['config']->get('default_category') != "") {
        $entry['category'] = array($PIVOTX['config']->get('default_category'));
    }
    if ($PIVOTX['config']->get('default_post_status') != "") {
        $entry['status'] = $PIVOTX['config']->get('default_post_status');
    }
    $entry['link'] = makeFileLink(array('date' => date("Y-m-d-H-i-s")), "", "");
    $entry['publish_date'] = date("Y-m-d-H-i-s", strtotime('+1 month'));
    // Set some things, based on referring page..
    $entry['introduction'] = "";
    // Execute the hook, if present..
    $PIVOTX['extensions']->executeHook('begin_bookmarklet', $entry);
    if (!empty($_GET['selection'])) {
        $entry['introduction'] .= "<p>&nbsp;</p>\n\n<blockquote>\n" . $_GET['selection'] . "\n</blockquote>\n\n";
    }
    if (!empty($_GET['title'])) {
        $entry['title'] = sanitizeTitle($_GET['title']);
        $entry['introduction'] .= sprintf("<p><a href='%s'>%s</a></p>", $_GET['url'], $entry['title']);
    } else {
        $entry['introduction'] .= sprintf("<p><a href='%s'>%s</a></p>", $_GET['url'], __("link"));
    }
    $PIVOTX['extensions']->executeHook('end_bookmarklet', $entry);
    // Make sure we only show the allowed categories.. Superadmins can always
    // see and use all categories..
    $categories = $PIVOTX['categories']->getCategories();
    if ($currentuser['userlevel'] < PIVOTX_UL_SUPERADMIN) {
        $allowedcats = $PIVOTX['categories']->allowedCategories($currentuser['username']);
        foreach ($categories as $key => $value) {
            if (!in_array($value['name'], $allowedcats)) {
                unset($categories[$key]);
            }
        }
    }
    if (!isset($_POST['title'])) {
        // Show the screen..
        $PIVOTX['template']->assign('entry', $entry);
        $PIVOTX['template']->assign('categories', $categories);
        $PIVOTX['template']->assign('pivotxsession', $PIVOTX['session']->getCSRF());
        $PIVOTX['template']->assign('entryuser', $PIVOTX['users']->getUser($entry['user']));
        renderTemplate('bookmarklet_entry.tpl');
    } else {
        // Make sure the current user is properly logged in, and that the request is legitimate
        $PIVOTX['session']->checkCSRF($_POST['pivotxsession']);
        // Sanitize the $_POST into an entry we can store
        $entry = sanitizePostedEntry($entry);
        if ($PIVOTX['config']->get('allow_comments') != "") {
            $entry['allow_comments'] = $PIVOTX['config']->get('allow_comments');
        }
        $entry['user'] = $currentuser['username'];
        $PIVOTX['extensions']->executeHook('entry_edit_beforesave', $entry);
        $entry = $PIVOTX['db']->set_entry($entry);
        if ($PIVOTX['db']->save_entry(TRUE)) {
            $message = sprintf(__('Your entry "%s" was successfully saved.'), '<em>' . trimText($entry['title'], 25) . '</em>');
            $PIVOTX['extensions']->executeHook('entry_edit_aftersave', $entry);
        } else {
            $message = sprintf(__('Your entry "%s" was NOT successfully saved.'), '<em>' . trimText($entry['title'], 25) . '</em>');
            $PIVOTX['extensions']->executeHook('entry_edit_aftersave_failed', $entry);
        }
        // Remove the compiled/parsed pages from the cache.
        if ($PIVOTX['config']->get('smarty_cache')) {
            $PIVOTX['template']->clear_cache();
        }
        // Show the screen..
        $PIVOTX['template']->assign('message', $message);
        $PIVOTX['template']->assign('uid', $PIVOTX['db']->entry['uid']);
        renderTemplate('bookmarklet_menu.tpl');
    }
}
Exemple #17
0
<?php

require "../settings.php";
require LIB_DIR . "/core/template.php";
renderTemplate("admin-base", array());
Exemple #18
0
define('INIT', true);
define('PAGE_DIR', __DIR__ . '/page/');
define('CONFIG_DIR', __DIR__ . '/config/');
define('LIB_DIR', __DIR__ . '/lib/');
define('TEMPLATE_DIR', __DIR__ . '/template/');
define('VIEW_DIR', PAGE_DIR . 'view/');
ob_start();
session_start();
function loadLib($name)
{
    require_once LIB_DIR . $name . '.php';
}
loadLib('profiler');
startProfiler();
foreach (array('account', 'auth', 'config', 'database', 'view') as $lib) {
    loadLib($lib);
}
connectDatabase();
/* @var $pages array */
$pages = getConfig('pages');
/* @var $page string */
$page = 'home';
if (isset($_GET['page']) && isset($pages[$_GET['page']])) {
    $page = $_GET['page'];
}
/* @var $content string */
$content = (include_once PAGE_DIR . $pages[$page]);
echo renderTemplate(getConfigValue('main', 'template'), $content);
disconnectDatabase();
finishProfiler();
saveProfilerResult();
Exemple #19
0
        //あいまい検索用(社員名)
        if (emp($name)) {
            $query_name = $name;
        } else {
            $query_name = "%{$name}%";
        }
        $search_result = $search->searchEditAccount($query_staff_cd, $query_name, $query_department_cd, $query_division_cd, $query_section_cd, $query_target_year);
        if (empty($search_result)) {
            $error_message = "該当するアカウントはありません。";
        }
        if (count($search_result) >= SEARCH_LIMIT) {
            $limit_message = "検索結果が上限を超えたので" . SEARCH_LIMIT . "件まで表示しています。";
        }
        $param['form_staff_cd'] = $staff_cd;
        $param['form_name'] = $name;
        $param['form_department_cd'] = $department_cd;
        $param['form_division_cd'] = $division_cd;
        $param['form_section_cd'] = $section_cd;
        $param['form_target_year'] = $target_year;
        $param['result'] = $search_result;
        $param['list_account'] = $list_account;
        $param['error_message'] = $error_message;
        $param['limit_message'] = $limit_message;
        renderTemplate('maintenance/account/index.tpl', $param);
        exit;
    }
} catch (Exception $e) {
    $param['errors'][] = "システムエラーが発生しました。";
    renderTemplate('error.tpl', $param);
    exit;
}
function contact_us($params)
{
    global $_controller, $_action;
    $path = TEMPLATES_PATH . "/{$_controller}/{$_action}.ctp";
    return renderTemplate($path);
}
Exemple #21
0
date_default_timezone_set("America/Denver");
require 'flight/Flight.php';
function renderTemplate($templateName, $selectedTab, $subTitle = '', $pageType = '')
{
    Flight::render('partials/head', array('title' => $subTitle ? " - {$subTitle}" : ''), 'headContent');
    Flight::render('partials/contactDetails', array(), 'contactDetails');
    Flight::render('partials/socialList', array(), 'socialList');
    Flight::render('partials/navigation', array('selectedTab' => $selectedTab), 'navigation');
    Flight::render('partials/footer', array(), 'footer');
    Flight::render($templateName, array('title' => $subTitle !== '' ? " - {$subTitle}" : '', 'subTitle' => $subTitle, 'pageType' => $pageType));
}
Flight::route('/', function () {
    renderTemplate('home', 'home');
});
Flight::route('/about', function () {
    Flight::render('about', array(), 'pageContent');
    renderTemplate('template', 'about', 'About Us', 'page-id-29');
});
Flight::route('/offer', function () {
    Flight::render('what-we-offer', array(), 'pageContent');
    renderTemplate('template', 'offer', 'What We Offer', 'page-id-31');
});
Flight::route('/contact', function () {
    Flight::render('contact', array(), 'pageContent');
    renderTemplate('template', 'contact', 'Contact Us', 'page-id-36');
});
Flight::route('/legal', function () {
    Flight::render('legal', array(), 'pageContent');
    renderTemplate('template', 'legal', 'Legal Disclaimers', 'page-id-36');
});
Flight::start();
function buildOpf($pages)
{
    $data = array('title' => EBOOK_TITLE, 'author' => EBOOK_AUTHOR, 'language' => EBOOK_LANGUAGE, 'items' => map($pages, function ($page) {
        $fileName = pathinfo($page->url, PATHINFO_FILENAME);
        return (object) array('id' => $fileName, 'mediaType' => 'application/xhtml+xml', 'href' => "pages/{$fileName}.html");
    }));
    $opf = renderTemplate(__DIR__ . '/templates/book.opf', $data);
    file_put_contents(BUILD_DIR . '/book.opf', $opf);
    return $opf;
}