예제 #1
0
 function index()
 {
     $widgets = Widget::getManyByOwner($this->user);
     $active = array();
     $ended = array();
     foreach ($widgets as $w) {
         if ($w->hasEnded()) {
             $ended[] = $w;
         } else {
             $active[] = $w;
         }
     }
     return $this->render('dashboard.diet-php', array('allWidgets' => $widgets, 'activeWidgets' => $active, 'endedWidgets' => $ended, 'successMessage' => $this->takeFromSession('successMessage')));
 }
예제 #2
0
 function u(RequestContext $context)
 {
     $username = $context->takeNextPathComponent();
     $uriID = $context->takeNextPathComponentOrNull();
     try {
         if (empty($uriID)) {
             $user = User::loadFromUsername($username);
             return $this->render('widgets-for-user.diet-php', array('user' => $user, 'widgets' => Widget::getManyByOwner($user)));
         } else {
             $widget = Widget::getByURI(User::loadFromUsername($username), $uriID);
             return $this->renderWidgetObj($widget);
         }
     } catch (\Chipin\NoSuchUser $_) {
         return $this->pageNotFound("No such user");
     } catch (\Chipin\Widgets\NoSuchWidget $_) {
         return $this->pageNotFound("No such widget");
     }
 }
예제 #3
0
 /**
  * Attempting to add two widgets used to cause problems due to the URI component of the
  * widgets not being unique...
  */
 function testAddingTwoWidgetsWithTheSameName()
 {
     foreach (array('First one...', 'Second one..') as $about) {
         $this->createWidget(array('title' => 'Help Me Out', 'about' => $about), $useNewUser = false);
     }
     $widgets = Widget::getManyByOwner($this->user);
     assertEqual(2, count($widgets));
 }