public function collectionsAction() { $request = $this->getRequest(); $username = $request->getRequest('collections'); if (!$username) { return $this->forward('error', 'error404'); } $user = $this->view->users = Model_Users::getByUsername($username); if (!$user) { return $this->forward('error', 'error404'); } if (JO_Session::get('msg_success')) { $this->view->msg_success = JO_Session::get('msg_success'); JO_Session::clear('msg_success'); } elseif (JO_Session::get('msg_error')) { $this->view->msg_error = JO_Session::get('msg_error'); JO_Session::clear('msg_error'); } $page = (int) $request->getRequest('page', 1); if ($page < 1) { $page = 1; } $limit = JO_Registry::get('front_limit'); $order = $request->getRequest('order'); if (is_null($order)) { $order = 'desc'; } $sort = $request->getRequest('sort'); if (is_null($sort)) { $sort = 'datetime'; } $this->view->public = $request->getRequest('public'); if (is_null($this->view->public)) { $this->view->public = 1; } $oredr = $request->getRequest('order'); if (!$order) { $order = 'desc'; } if ($user['user_id'] == JO_Session::get('user_id')) { $this->view->my_profile = true; } $this->getLayout()->meta_title = $user['firstname'] . ' ' . $user['lastname'] . ' - ' . $user['username'] . ' - ' . $this->translate('Collections'); $this->getLayout()->meta_description = $user['firstname'] . ' ' . $user['lastname'] . ' - ' . $user['username'] . ' - ' . $this->translate('Collections'); $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Authors'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=authors')), array('name' => $user['username'])); $this->view->author_header = Helper_Author::authorHeader($user); $this->view->form_name = $this->translate('New Collection'); $link = $request->getBaseUrl() . '?controller=users&action=collections&username='******'username']; $link .= $this->view->public ? '/public/1' : '/public/0'; $this->view->sort_by = array(array('name' => $this->view->translate('date'), 'href' => WM_Router::create($link . '&sort=datetime'), 'is_selected' => $sort == 'datetime' ? true : false), array('name' => $this->view->translate('title'), 'href' => WM_Router::create($link . '&sort=name'), 'is_selected' => $sort == 'name' ? true : false), array('name' => $this->view->translate('rating'), 'href' => WM_Router::create($link . '&sort=rating'), 'is_selected' => $sort == 'rating' ? true : false)); /* ORDER */ $link .= '&sort=' . $sort; $this->view->orders = array(array('name' => '»', 'href' => WM_Router::create($link . '&order=desc'), 'is_selected' => $order == 'desc' ? true : false), array('name' => '«', 'href' => WM_Router::create($link . '&order=asc'), 'is_selected' => $order == 'asc' ? true : false)); $this->view->public_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=collections&username='******'username'] . '/public/1'); $this->view->private_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=collections&username='******'username'] . '/public/0'); $this->view->upload_link = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=upload'); $total_records = Model_Collections::countByUser($user['user_id'], $this->view->public); $start = $page * $limit - $limit; if ($start > $total_records) { $page = max(ceil($total_records / $limit), 1); $start = $page * $limit - $limit; } elseif ($start < 0) { $start = 0; } $collections = Model_Collections::getByUser($start, $limit, $user['user_id'], 'collections.' . $sort . ' ' . $order, $this->view->public); if ($collections) { foreach ($collections as $collection) { if ($this->view->my_profile) { $collection['delete_txt'] = $this->translate('Are you sure you want to delete the collection? Once deleted it can not ne restored again!'); $collection['delete_href'] = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=delete&collection_id=' . $collection['id']); $collection['edit_public_href'] = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=change&collection_id=' . $collection['id']); } $collection['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=view_collection&collection_id=' . $collection['id'] . '&name=' . $collection['name']); $this->view->items[] = Helper_Collection::returnViewIndex($collection); } } $pagination = new Model_Pagination(); $pagination->setLimit($limit); $pagination->setPage($page); $pagination->setText(array('text_prev' => $this->view->translate('Prev'), 'text_next' => $this->view->translate('Next'))); $pagination->setTotal($total_records); $pagination->setUrl(WM_Router::create($link . '&page={page}')); $this->view->pagination = $pagination->render(); if (!empty($this->view->pagination)) { $this->view->pagination = str_replace('{of}', $this->view->translate('OF'), $this->view->pagination); } $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function rightsideAction() { $request = $this->getRequest(); $model_images = new Helper_Images(); if ($request->getRequest('item_id')) { $itemID = $request->getRequest('item_id'); } elseif ($request->getRequest('comments')) { $itemID = $request->getRequest('comments'); } else { $itemID = $request->getRequest('faq'); } $item = Model_Items::get($itemID); $user = Model_Users::getUser($item['user_id']); if ($user['avatar']) { $user['avatar'] = $model_images->resize($user['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $user['avatar'] = 'data/themes/images/noavatar.png'; } if (JO_Session::get('user_id')) { if ($item['user_id'] != JO_Session::get('user_id')) { if (Model_Orders::isBuyed($item['id'], JO_Session::get('user_id'))) { $item['is_buyed'] = $this->translate('You have already bought this item. You can download it from <a href="#">here</a>, but if you like you can buy it again.'); $replace = WM_Router::create($request->getBaseUrl() . '?controller=users&action=downloads'); $item['is_buyed'] = str_replace('#', $replace, $item['is_buyed']); } } else { $item['is_buyed'] = $this->translate('This is one of your files'); } } if (JO_Session::get('user_id') && JO_Session::get('user_id') == $item['user_id']) { $this->view->owner = true; } $item['price'] = WM_Currency::format($item['price']); if ($item['extended_price']) { $item['extended_price'] = WM_Currency::format($item['extended_price']); } $item['datetime'] = JO_Date::getInstance($item['datetime'], 'd M yy')->getDate(); $this->view->attributes = Model_Items::getAttributes($item['id']); $this->view->attributes_pic = array(); if ($this->view->attributes) { foreach ($this->view->attributes as $k => $v) { if ($v['search'] == 'true') { $this->view->attributes[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=search&action=attributes/' . urlencode(mb_strtolower($v['category'], 'UTF-8')) . '/' . urlencode(mb_strtolower($v['name'], 'UTF-8'))); } if (!empty($v['photo'])) { $this->view->attributes[$k]['photo'] = 'uploads/attributes/' . $v['photo']; $this->view->attributes_pic[] = $this->view->attributes[$k]; } if (empty($v['name'])) { $this->view->attributes[$k]['name'] = $v['attribute_id']; } } } $user['homeimage'] = $model_images->resize($user['homeimage'], JO_Registry::forceGet('user_profile_photo_width'), JO_Registry::forceGet('user_profile_photo_height'), true); $user['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username'])); $comments = Model_Comments::getTotal("item_id=" . $item['id'] . ' AND reply_to = 0'); $item['comments'] = (int) $comments; $this->view->user_badges = Helper_Author::userBadges($user); if ($item['prepaid_price'] == '0.00') { $this->view->prepaid_price = false; } else { $this->view->prepaid_price = WM_Currency::format($item['prepaid_price']); } #COLLECTIONS $this->view->bookmark_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=add_to_collection'); $this->view->upload_link = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=upload'); $this->view->base_url = urlencode($request->getBaseUrl()); $this->view->full_url = urlencode($request->getFullUrl()); if (JO_Session::get('user_id')) { $this->view->bookcollections = Model_Collections::getByUser(0, 0, JO_Session::get('user_id')); } $this->view->tags = array(); if (isset($item['tags'])) { foreach ($item['tags'] as $key => $tag) { if ($tag) { $this->view->tags[] = array('name' => $tag, 'href' => WM_Router::create($request->getBaseUrl() . '?controller=tags&tag=' . $tag)); } } } if ($request->getAction() != 'comments') { $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } if ($request->getAction() == 'index') { $this->view->is_index = true; } $this->view->free_link = WM_Router::create($request->getBaseUrl() . '?controller=users&action=downloads&item_id=' . $item['id']); $this->view->login_link = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); $user['license'] = unserialize($user['license']); $this->view->user = $user; $this->view->item = $item; }