public function indexAction() { $request = $this->getRequest(); $model_images = new Model_Images(); $this->view->usersCount = Model_Users::countUsers(); $this->view->itemsCount = Model_Items::countItems(); /* LAST ITEM */ $lastItem = Model_Items::getLastItem(); if ($lastItem) { $thumb = $model_images->resizeWidth($lastItem['theme_preview_thumbnail'], 200); $thumb_size = getimagesize($thumb); if ($thumb_size[1] > 161) { $image = new JO_GDThumb($thumb); $image->crop(0, 0, $thumb_size[0], 161); $image->save($thumb); } $this->view->lastItem = array('name' => $lastItem['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $lastItem['module'] . '&controller=items&item_id=' . $lastItem['id'] . '&name=' . $lastItem['name']), 'thumb' => $thumb); } /* FREE ITEM */ $this->view->freeItems = ''; $freeItems = Model_Items::getFreeFiles(); if ($freeItems) { foreach ($freeItems as $fi) { $cats = explode(',', $fi['categories']); $cat_name = Helper_Items::getCategory($cats[1]); $thumb = $model_images->resizeWidth($fi['theme_preview_thumbnail'], JO_Registry::forceGet($fi['module'] . '_items_thumb_width')); $thumb_size = getimagesize($thumb); if ($thumb_size[1] > JO_Registry::forceGet($fi['module'] . '_items_thumb_height')) { $image = new JO_GDThumb($thumb); $image->crop(0, 0, $thumb_size[0], JO_Registry::forceGet($fi['module'] . '_items_thumb_height')); $image->save($thumb); } $this->view->freeItems[] = array('href' => WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $fi['id'] . '&name=' . WM_Router::clearName($fi['name'])), 'thumb' => $thumb, 'cat_name' => $cat_name['name'], 'name' => $fi['name']); } } /* ITEMS */ $this->view->items = array(); $listType = $request->getParam('list_type'); if (is_null($listType)) { $listType = 'recent'; } $this->view->all_items = array('name' => $this->view->translate('View all items'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=categories&action=' . $listType)); switch ($listType) { case 'featured': JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri()); $this->view->title_items = $this->view->translate('Featured Items'); $featuredItems = Model_Items::getWeekly($request->getParam('category_filter')); if ($featuredItems) { foreach ($featuredItems as $n => $item) { if (!empty($item['demo_url'])) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $this->view->items[] = Helper_Items::returnViewIndex($item); } } break; case 'author': JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri()); $this->view->title_items = $this->view->translate('Featured Author'); $this->view->author = Model_Users::getFeatUser(); if ($this->view->author) { $this->view->author['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']); $this->view->author['userhref_pf'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']); if ($this->view->author['avatar']) { $this->view->author['avatar'] = $model_images->resize($this->view->author['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $this->view->author['avatar'] = 'data/themes/images/avatar-author.png'; } $this->view->items = array(); $items = Model_Items::getByUser($this->view->author['user_id'], 0, 11, false); if (empty($items)) { $items = array(0 => array('no_items' => true, 'thumbnail' => 'data/themes/images/missing-item.png', 'module' => 'themes')); } if ($items) { foreach ($items as $n => $item) { if (!empty($item['demo_url'])) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $this->view->items[] = Helper_Items::returnViewIndex($item); } } } $this->view->all_items = array('name' => $this->view->translate('View portfolio'), 'href' => $this->view->author['userhref_pf']); break; default: /* RECENT ITEMS */ JO_Session::set('redirect', $request->getBaseUrl()); $this->view->title_items = $this->view->translate('Recent Items'); $recentItems = Model_Items::getRecent($request->getParam('category_filter')); if ($recentItems) { foreach ($recentItems as $n => $item) { if (!empty($item['demo_url'])) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $this->view->items[] = Helper_Items::returnViewIndex($item); } } shuffle($this->view->items); } $this->view->listType = $listType; $this->view->recent_items = WM_Router::create($request->getBaseUrl() . '?controller=recent'); $this->view->featured = WM_Router::create($request->getBaseUrl() . '?controller=featured'); $this->view->featuredAuthor = WM_Router::create($request->getBaseUrl() . '?controller=author'); /* CATEGORIES */ $this->view->categories = Model_Categories::getMain(); $this->view->top_categories = $this->view->categories; if ($this->view->categories) { if ($this->view->categories) { foreach ($this->view->categories as $k => $v) { $this->view->categories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=' . $listType . '&category_filter=' . $v['id']); } } } if ($this->view->top_categories) { foreach ($this->view->top_categories as $k => $v) { $this->view->top_categories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $v['id'] . '&name=' . $v['name']); } shuffle($this->view->top_categories); $this->view->top_categories = array_slice($this->view->top_categories, 0, 4); } $this->view->all_categories = WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $listType); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function indexAction() { if (JO_Session::get('order_id')) { JO_Session::clear('order_id'); } $request = $this->getRequest(); $image_model = new Helper_Images(); JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri()); $this->view->currency = WM_Currency::getCurrency(); $itemID = $request->getRequest('item_id'); $item = Model_Items::get($itemID); if (!is_array($item) || $item['status'] == 'deleted' || JO_Session::get('username') && $item['status'] == 'unapproved' && $item['user_id'] != $_SESSION['user']['user_id'] || $item['status'] == 'queue' || $item['status'] == 'extended_buy') { return $this->forward('error', 'error404'); } if (JO_Session::get('order_id')) { Model_Orders::delete(JO_Session::get('order_id')); JO_Session::clear('order_id'); } if (JO_Session::get('msg_success')) { $this->view->msg_success = JO_Session::get('msg_success'); JO_Session::clear('msg_success'); } if (JO_Session::get('msg_error')) { $this->view->msg_error = JO_Session::get('msg_error'); JO_Session::clear('msg_error'); } $user = Model_Users::getUser($item['user_id']); $user['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username'])); $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Portfolio'), 'href' => $user['userhref']), array('name' => $item['name'])); $this->view->item_href = $this->view->form_action = $this->view->item_link = WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $faqs_data = Model_Faq::getAll($itemID); if (JO_Session::get('user_id') == $item['user_id'] || $faqs_data) { $this->view->faq_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=faq&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } if (JO_Session::get('user_id') == $item['user_id']) { $this->view->edit_link = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=edit&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $this->view->delete_link = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=delete&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $this->view->screenshots = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=screenshots&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); if (!empty($item['demo_url'])) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $item['description'] = strip_tags(html_entity_decode($item['description']), '<br><p><span><h1><h2><h3><a><img><big><small><ul><ol><li>'); $this->getLayout()->meta_title = $item['name']; $meta_description = substr(strip_tags(html_entity_decode($item['description'], ENT_QUOTES, 'utf-8')), 0, 255); $this->getLayout()->meta_description = $meta_description; if ((int) JO_Registry::get($item['module'] . '_items_screenshots_width') && (int) JO_Registry::get($item['module'] . '_items_screenshots_height')) { $item['big_image'] = $image_model->resize($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_screenshots_width'), JO_Registry::forceGet($item['module'] . '_items_screenshots_height'), true); } elseif ((int) JO_Registry::get($item['module'] . '_items_screenshots_width')) { $item['big_image'] = $image_model->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_screenshots_width')); } elseif ((int) JO_Registry::get($item['module'] . '_items_screenshots_height')) { $item['big_image'] = $image_model->resizeHeight($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_screenshots_height')); } else { $item['big_image'] = false; } $this->view->otherItems = array(); $otherItems = Model_Items::getByUser($item['user_id'], 0, 4, false, 'id <> ' . (int) $item['id']); if ($otherItems) { foreach ($otherItems as $i => $ot) { $this->view->otherItems[] = Helper_Items::returnViewIndex($ot); } } $files = glob(dirname(__FILE__) . '/Payments/*.php'); if ($files) { $payments_data = $sort_order = $order_obj = array(); foreach ($files as $row => $file) { if (preg_match('/^([\\w]{1,})Controller$/i', basename($file, '.php'), $match)) { $key = mb_strtolower($match[1], 'utf-8'); if (JO_Registry::forceGet($key . '_status')) { JO_Loader::loadFile($file); $sort_order[$row] = (int) JO_Registry::forceGet($key . '_sort_order'); $logo = JO_Registry::forceGet($key . '_logo'); if ($logo) { list($width) = getimagesize('uploads/' . $logo); if ($width > 70) { $logo = $image_model->resizeWidth($logo, 70); } else { $logo = 'uploads/' . $logo; } } else { $logo = ''; } $payments_data[$row] = array('name' => $this->translate($match[1]), 'sort' => (int) JO_Registry::forceGet($key . '_sort_order'), 'logo' => $logo); } } } array_multisort($sort_order, SORT_ASC, $payments_data); $this->view->payments = $payments_data; } $this->view->your_profit = WM_Currency::format($item['your_profit']); $this->view->usertotal = WM_Currency::format(JO_Session::get('total')); $item['price'] = WM_Currency::format($item['price']); $this->view->user = $user; $this->view->item = $item; $membership = Model_Membership::getAll(); if ($membership) { $this->view->membership_link = WM_Router::create($request->getBaseUrl() . '?controller=users&action=membership'); $this->view->membership_pay_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=pay_membership'); } $this->view->deposit = WM_Router::create($request->getBaseUrl() . '?controller=users&action=deposit'); $this->view->deposit_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=pay_deposit'); $this->view->payment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=payment'); $this->view->children = array(); $this->view->children['rightside'] = 'items/rightside'; $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function indexAction() { $request = $this->getRequest(); $username = $request->getRequest('username'); $action_method = $username . 'Action'; if (method_exists('UsersController', $action_method)) { return $this->forward('users', $username); } $user = $this->view->users = Model_Users::getByUsername($username); if (!$user) { return $this->forward('error', 'error404'); } $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'; } if (JO_Session::get('msg_success')) { $this->view->msg_success = JO_Session::get('msg_success'); JO_Session::clear('msg_success'); } $this->getLayout()->meta_title = $user['firstname'] . ' ' . $user['lastname'] . ' - ' . $user['username']; $this->getLayout()->meta_description = $user['firstname'] . ' ' . $user['lastname'] . ' - ' . $user['username']; $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'])); if (JO_Session::get('user_id') == $user['user_id']) { $my_profile = true; } else { $my_profile = false; } $this->view->author_header = Helper_Author::authorHeader($user); $link = $request->getBaseUrl() . '?controller=users&username='******'username']; $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), array('name' => $this->view->translate('sales'), 'href' => WM_Router::create($link . '&sort=sales'), 'is_selected' => $sort == 'sales' ? true : false), array('name' => $this->view->translate('price'), 'href' => WM_Router::create($link . '&sort=price'), 'is_selected' => $sort == 'price' ? 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)); $total_records = Model_Items::countByUser($user['user_id']); $start = $page * $limit - $limit; if ($start > $total_records) { $page = max(ceil($total_records / $limit), 1); $start = $page * $limit - $limit; } elseif ($start < 0) { $start = 0; } $items = Model_Items::getByUser($user['user_id'], $start, $limit, ($sort == 'price' ? 'rprice' : 'items.' . $sort) . ' ' . $order, isset($where) ? $where : ''); $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); } /* ITEMS */ if ($items) { $this->view->items = array(); foreach ($items as $n => $item) { if ($my_profile) { $item['delete_txt'] = $this->translate('Are you sure you want to delete the item? Once deleted it can not ne restored again!'); $item['delete_href'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=delete&item_id=' . $item['id']); } $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $this->view->items[] = Helper_Items::returnViewIndex($item, 'category'); } } $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public static function returnFollowing($follower, $owner, $followers = false) { $view = JO_View::getInstance(); $model_images = new Helper_Images(); $request = JO_Request::getInstance(); $list_type = $request->getParam('list_type'); $user = Model_Users::getByUsername($follower['username']); $view->badges = self::userBadges($user); 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'; } $user['portfolio_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'&', '-', $user['username'])); $log_user = JO_Session::get('user_id'); if ($log_user) { $following = JO_Array::multi_array_search(JO_Session::get('following'), 'follow_id', $user['user_id']); if ($following) { $user['follow_href_name'] = $view->translate('Unfollow'); $user['follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=unfollow&username='******'&', '-', $user['username'])); } elseif ($log_user != $user['user_id']) { $user['follow_href_name'] = $view->translate('Follow'); $user['follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&username='******'&', '-', $user['username'])); } } $view->user = $user; $user_items = Model_Items::getByUser($user['user_id'], 0, 3, 'rand()'); if (empty($user_items)) { $user_items = array(array('no_items' => true, 'thumbnail' => 'data/themes/images/missing-item.png', 'module' => 'themes')); } $view->user_items = array(); if ($user_items) { foreach ($user_items as $item) { if (isset($item['demo_url'])) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?controller=demo&href=' . $item['demo_url']); } $view->user_items[] = Helper_Items::returnViewIndex($item); } } return $view->renderByModule('single_user/following', 'users', 'themes'); }