Skip to content

Instantly share code, notes, and snippets.

@nautilebleu
Created March 31, 2011 11:07

Revisions

  1. nautilebleu created this gist Mar 31, 2011.
    48 changes: 48 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    <?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(); ?>