function get_view($template) { return ViewFactory::make_view(strtolower($template)); }
function render_partial($action, $object = false, $collect = false, $controller = false) { #if the controller is an array, use it and ignore the rest if (is_array($action)) { if (array_key_exists('object', $action)) { $object = $action['object']; } if (array_key_exists('collect', $action)) { $collect = $action['collect']; } if (array_key_exists('controller', $action)) { $controller = $action['controller']; } if (array_key_exists('action', $action)) { $action = $action['action']; } } else { if ($controller == false) { $controller = params('controller'); } } # set the template and object name $slashloc = strrpos($action, '/'); if ($slashloc !== false) { $objectname = substr($action, $slashloc + 1); if ($action[0] == '/') { $template = substr(substr($action, 0, $slashloc) . '/_' . $objectname, 1); } else { $template = url_name($controller) . '/' . substr($action, 0, $slashloc) . '/_' . $objectname; } } else { $template = url_name($controller) . '/_' . $action; $objectname = $action; } $view = ViewFactory::make_view($template); # include the helpers if (file_exists(PROJECT_ROOT . '/app/helpers/app.php')) { include_once PROJECT_ROOT . '/app/helpers/app.php'; } if (file_exists(PROJECT_ROOT . '/app/helpers/' . $controller . '.php')) { include_once PROJECT_ROOT . '/app/helpers/' . $controller . '.php'; } # if it's a collection, call it for each item in the obj $objectname = var_name(class_name($objectname)); if ($collect === true) { foreach ($object as $k => $v) { echo $view->parse_partial($objectname, $v); } } else { echo $view->parse_partial($objectname, $object); } }