public function showAction() { $this->logger->entering(); $this->logger->info('Loading the item by id'); $items = new Item(); $item = $items->find($this->_getParam('id'))->current(); if ($item == null) { $this->logger->warn('Tried to show an non-existant item'); $this->flash->notice = 'Invalid Action'; $this->_redirect('/'); } $this->logger->info('Find all the tags for the item'); $tags = $items->findTags($item->id); $this->logger->info('Find owner'); $users = new User(); $owner = $item->findParentUser(); $user = $users->find($this->session->user_id)->current(); $this->logger->info('Calculating price total'); $shipping = Item::shippingCharge($item->weight); $total = $item->points + $shipping; $this->logger->info('Loading existing conversations'); $conversation = null; $conversations = null; if (isset($user)) { $conversationTable = new Conversation(); if ($owner->id == $user->id) { $conversationRows = $conversationTable->findAllByItem($item); foreach ($conversationRows as $conversationRow) { $convo = $conversationRow->toArray(); $convo['user'] = $conversationRow->findParentUser()->toArray(); $conversations[] = $convo; } } else { $conversation = $conversationTable->findByUserAndItem($user, $item); } } $this->logger->info('Loading the view parameters'); $this->view->assign(array('title' => "Item: {$item->name}", 'item' => $item, 'owner' => $owner, 'tags' => $tags, 'shipping' => $shipping, 'total' => $total, 'conversations' => $conversations, 'conversation' => $conversation)); $this->logger->info('Rendering the application template'); $this->render(); $this->logger->exiting(); }