예제 #1
0
 public function render()
 {
     // TODO Do not use global
     global $microblogTemplates, $pageTitle, $pageAuthor, $post;
     $postView = new PostView();
     $activitiesView = new ActivitiesView();
     $profileView = new ProfileView();
     $followView = new FollowView();
     $tpl = new \rubisco\text\SimpleTemplate($microblogTemplates);
     $tpl->pageAuthor = $pageAuthor;
     $tpl->pageTitle = $pageTitle;
     $tpl->showLog = '';
     $tpl->login = "******";
     $tpl->infoMessage = $this->m->getLastInfoMessagesAsHTML();
     $tpl->postView = '';
     $tpl->activities = $activitiesView->html();
     $tpl->profile = $profileView->html();
     $tpl->follow = $followView->html();
     if ($this->m->isLogin()) {
         $tpl->showLog = '<li><a href="?showLog=1">Show Log</a></li>';
         $tpl->login = "******";
         $tpl->postView = $postView->html($post['message'], $post['to']);
     }
     $this->m->clearLastInfoMessages();
     $content = $tpl->render('head') . $tpl->render('main') . $tpl->render('foot');
     header('Content-Type: text/html; charset=utf-8');
     header('Content-Length: ' . strlen($content));
     echo $content;
 }
 /**
  *
  */
 public function testAddLastInfoMessage()
 {
     $infoMessage = 'Last info message';
     $expected1 = array(array('type' => 'error', 'message' => 'Failed'));
     $expected2 = array(array('type' => 'error', 'message' => 'Failed 2'), array('type' => 'warn', 'message' => 'Warn'));
     $this->m->addLastInfoMessage('error', 'Failed');
     $lastInfoMessages = $this->m->getLastInfoMessages();
     $this->assertEquals($expected1, $lastInfoMessages);
     $this->m->clearLastInfoMessages();
     $lastInfoMessages = $this->m->getLastInfoMessages();
     $this->assertEquals(array(), $lastInfoMessages);
     $this->m->addLastInfoMessage('error', 'Failed 2');
     $this->m->addLastInfoMessage('warn', 'Warn');
     $lastInfoMessages = $this->m->getLastInfoMessages();
     $this->assertEquals($expected2, $lastInfoMessages);
 }
예제 #3
0
    public function render()
    {
        // TODO Do not use global
        global $microblogTemplates, $pageTitle, $pageAuthor, $post;
        $content = '';
        $tpl = new \rubisco\text\SimpleTemplate($microblogTemplates);
        $tpl->pageAuthor = $pageAuthor;
        $tpl->pageTitle = $pageTitle;
        $tpl->showLog = '';
        $tpl->login = '';
        $content = $tpl->render('head');
        $content .= $this->m->getLastInfoMessagesAsHTML();
        // TODO Dont print if already in lastInfoMessage
        if (!isset($_COOKIE['PHPSESSID'])) {
            $content .= "<p class='note'>Note: For login cookies must be enabled.</p>\n";
        }
        $content .= <<<HTML
<form action="" method="post">
  <p>
    <label for="name">Username</label>
    <input type="text" id="username" name="username" size="20" maxlength="20" value="" />
    <br />

    <label for="name">Password</label>
    <input type="password" id="password" name="password" size="20" maxlength="256" value="" />
    <br />

    <input type="submit" name="loginCancel" value="Cancel" />
    <input type="submit" name="login" value="Login" />
  </p>
</form>
HTML;
        $content .= $tpl->render('foot');
        $this->m->clearLastInfoMessages();
        header('Content-Type: text/html; charset=utf-8');
        header('Content-Length: ' . strlen($content));
        echo $content;
    }