public function endWidget(RequestContext $context) { $w = Widget::getByOwnerAndID($this->user, $context->takeNextPathComponent()); if ($this->isPostRequest()) { Widgets\endWidget($w); return $this->redirect('/dashboard/'); } else { return $this->render('end-widget.diet-php', array('widget' => $w)); } }
private function getWidget() { if (isset($_GET['w'])) { # Looks like we're editing a widget... $user = $this->getActiveUser(); if (empty($user)) { $_SESSION['authenticationRequired'] = true; return $this->redirect("/account/signin"); } else { $w = Widget::getByOwnerAndID($user, $_GET['w']); $this->storeWidgetInSession($w); return $w; } } else { $w = at($_SESSION, 'unsaved-widget', null); if (isset($w) && isset($w->ownerID) && empty($this->user)) { $this->clearWidgetInSession(); $w = null; } if (empty($w)) { $w = new Widget(); } $w->color = Widgets\defaultColor(); $w->width = Widgets\defaultSize()->width; $w->height = Widgets\defaultSize()->height; return $w; } }