');
}
}
return $o;
}
function js($s) {
switch($s) {
case 'jquery':
$path = 'view/js/jquery.js';
break;
case 'bootstrap':
$path = 'library/bootstrap/js/bootstrap.min.js';
break;
case 'foundation':
$path = 'library/foundation/js/foundation.min.js';
$init = "\r\n" . '';
break;
}
$ret = '';
if($init)
$ret .= $init;
return $ret;
}
function css($s) {
switch($s) {
case 'bootstrap':
$path = 'library/bootstrap/css/bootstrap.min.css';
break;
case 'foundation':
$path = 'library/foundation/css/foundation.min.css';
break;
}
$ret = '';
return $ret;
}
// This doesn't really belong in Comanche, but it could also be argued that it is the perfect place.
// We need to be able to select what kind of template and decoration to use for the webpage at the heart of our content.
// For now we'll allow an '[authored]' element which defaults to name and date, or 'none' to remove these, and perhaps
// 'full' to provide a social network style profile photo.
// But leave it open to have richer templating options and perhaps ultimately discard this one, once we have a better idea
// of what template and webpage options we might desire.
function webpage(&$a,$s) {
$ret = array();
$matches = array();
$cnt = preg_match_all("/\[authored\](.*?)\[\/authored\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$ret['authored'] = $mtch[1];
}
}
return $ret;
}
/**
* Widgets will have to get any operational arguments from the session, the
* global app environment, or config storage until we implement argument passing
*
* @param string $name
* @param string $text
*/
function widget($name, $text) {
$vars = array();
$matches = array();
$cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $text, $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
$vars[$mtch[1]] = $mtch[2];
}
}
$func = 'widget_' . trim($name);
if(! function_exists($func)) {
if(file_exists('widget/' . trim($name) . '.php'))
require_once('widget/' . trim($name) . '.php');
elseif(file_exists('widget/' . trim($name) . '/' . trim($name) . '.php'))
require_once('widget/' . trim($name) . '/' . trim($name) . '.php');
}
else {
$theme_widget = $func . '.php';
if((! function_exists($func)) && theme_include($theme_widget))
require_once(theme_include($theme_widget));
}
if (function_exists($func))
return $func($vars);
}
function region($s) {
$matches = array();
$cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$s = str_replace($mtch[0], $this->menu(trim($mtch[1])), $s);
}
}
// menu class e.g. [menu=horizontal]my_menu[/menu] or [menu=tabbed]my_menu[/menu]
// allows different menu renderings to be applied
$cnt = preg_match_all("/\[menu=(.*?)\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$s = str_replace($mtch[0],$this->menu(trim($mtch[2]),$mtch[1]),$s);
}
}
$cnt = preg_match_all("/\[block\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$s = str_replace($mtch[0],$this->block(trim($mtch[1])),$s);
}
}
$cnt = preg_match_all("/\[block=(.*?)\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$s = str_replace($mtch[0],$this->block(trim($mtch[2]),trim($mtch[1])),$s);
}
}
$cnt = preg_match_all("/\[js\](.*?)\[\/js\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$s = str_replace($mtch[0],$this->js(trim($mtch[1])),$s);
}
}
$cnt = preg_match_all("/\[css\](.*?)\[\/css\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$s = str_replace($mtch[0],$this->css(trim($mtch[1])),$s);
}
}
// need to modify this to accept parameters
$cnt = preg_match_all("/\[widget=(.*?)\](.*?)\[\/widget\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$s = str_replace($mtch[0],$this->widget(trim($mtch[1]),$mtch[2]),$s);
}
}
return $s;
}
/*
* @function register_page_template($arr)
* Registers a page template/variant for use by Comanche selectors
* @param array $arr
* 'template' => template name
* 'variant' => array(
* 'name' => variant name
* 'desc' => text description
* 'regions' => array(
* 'name' => name
* 'desc' => text description
* )
* )
*/
function register_page_template($arr) {
\App::$page_layouts[$arr['template']] = array($arr['variant']);
return;
}
}