Skip to content

Instantly share code, notes, and snippets.

@nautilebleu
Created March 31, 2011 11:07
Show Gist options
  • Save nautilebleu/896184 to your computer and use it in GitHub Desktop.
Save nautilebleu/896184 to your computer and use it in GitHub Desktop.
<?php
// in application/app/php/lib/app_manager/app_manager.class.php
class AppManager extends WebApplication
// ...
/**
* render the component
*/
public function render($template, $params)
{
$this->display_header($trail);
$path = sprintf('%s/../templates/%s.php',
dirname(__FILE__),
$template);
foreach ($params as $name => $value) {
$$name = $value;
}
include($path);
$this->display_footer();
}
?>
<?php
// in application/app/php/lib/app_manager/component/browser.class.php
class AppManagerBrowserComponent extends AppManager
{
function run()
{
$form = new AppForm($this->get_view_url());
$form->build();
if (Request::post('test') !== null) {
if ($form->validate()) {
$form->save();
$this->redirect('Message', false);
}
}
$this->render('browse',
array('form' => $form)) ;
}
}
?>
// in application/app/php/lib/templates/browse.html.php
<h2>Hello world</h2>
<a href="<?php echo $this->get_browse_url(); ?>">Link</a>
<?php echo $form->toHtml(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment