public function indexAction() { $request = $this->getRequest(); $this->setViewChange('../search/index'); $tag = $request->getParam('tags'); /* CRUMBS */ $this->view->crumbs = array(array('name' => $this->view->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Search'))); if ($tag) { $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 ($sort == 'username') { $prefix = 'users.'; } else { $prefix = 'items.'; } $tag = trim(urldecode($tag)); $this->view->searchText = $this->translate('Tag') . ': ' . $tag; $this->getLayout()->meta_title = $this->translate('Items by tag') . ' ' . $tag; $this->getLayout()->meta_description = $this->translate('Items by tag') . ' ' . $tag; $all_cats_link = $link = $request->getBaseUrl() . '?controller=tags&tag=' . urlencode($tag); $category = $request->getRequest('category'); if ($category) { $link .= '&category=' . $category; } $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), array('name' => $this->view->translate('author name'), 'href' => WM_Router::create($link . '&sort=username'), 'is_selected' => $sort == 'username' ? 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)); $link .= '&order=' . $order; $total_records = Model_Tags::getAllSearchItems($tag, ($sort == 'price' ? 'rprice' : $sort) . ' ' . $order, $category); if ($total_records) { $this->view->total_result = $cnt_total_records = count($total_records); $this->view->categories = array(); $categories = Model_Tags::getCategories($tag, $category); if ($categories) { if ($category) { $this->view->all_cats_link = WM_Router::create($all_cats_link); $exists = array(); foreach ($categories as $cat) { if (substr_count($cat['categories'], '|||') > 1) { continue; } $cat_parts = explode('|||', $cat['categories']); foreach ($cat_parts as $part) { $sub_parts = explode('@@@', $part); if (in_array($sub_parts[0], $exists)) { continue; } $exists[] = $sub_parts[0]; $this->view->categories[] = array('name' => $sub_parts[1], 'href' => WM_Router::create($link . '&category=' . $sub_parts[0])); } } $this->view->categories[0] = array('name' => $this->view->categories[0]['name']); $this->view->cnt_categories = count($this->view->categories) - 1; $this->view->subcategories = $this->view->cnt_categories == 1 ? $this->translate('Subcategory') : $this->translate('Subcategories'); } else { foreach ($categories as $cat) { if (strpos($cat['categories'], '|||')) { continue; } $cat_parts = explode('@@@', $cat['categories']); $this->view->categories[] = array('name' => $cat_parts[1], 'href' => WM_Router::create($link . '&category=' . $cat_parts[0])); } $this->view->cnt_categories = count($this->view->categories); $this->view->subcategories = $this->view->cnt_categories == 1 ? $this->translate('Category') : $this->translate('Categories'); } } $start = $page * $limit - $limit; if ($start > $cnt_total_records) { $page = max(ceil($cnt_total_records / $limit), 1); $start = $page * $limit - $limit; } elseif ($start < 0) { $start = 0; } $items = array_slice($total_records, $start, $limit); $this->view->items = array(); foreach ($items as $n => $item) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $item['categories'] = trim($item['categories'], ','); $item['categories'] = explode(',', $item['categories']); $item['categories'] = JO_Array::multi_array_to_single_uniq($item['categories']); $item['categories'] = array_filter($item['categories'], create_function('$a', 'return $a!="";')); $this->view->items[] = Helper_Items::returnViewIndex($item, 'category'); } $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($cnt_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'; } else { $this->redirect($request->getBaseUrl() . '?controller=categories&action=recent'); } }
public function viewAction() { $request = $this->getRequest(); $collectionID = $request->getRequest('view'); $collection = Model_Collections::get($collectionID); $this->view->my_profil = $collection['username'] == JO_Session::get('username'); if (!$collection || $collection['public'] == 'false' && !$this->view->my_profil) { 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 ($sort == 'username') { $prefix = 'users.'; } else { $prefix = 'items.'; } $this->getLayout()->meta_title = $collection['name']; $this->getLayout()->meta_description = isset($collection['description']) ? substr(strip_tags($collection['description']), 0, 255) : $this->translate('Collection'); $collection['without_bt'] = true; $this->view->collection_name = $collection['name']; $this->view->collection = Helper_Collection::returnViewIndex($collection, true); $this->view->rate_link = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=rate_collection&collection_id=' . $collection['id']); /* CRUMBS */ $this->view->crumbs = array(array('name' => $this->view->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->view->translate('Public Collections'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=collections'))); $total_records = Model_Items::CountByCollection($collectionID); $start = $page * $limit - $limit; if ($start > $total_records) { $last_page = max(ceil($total_records / $limit), 1); $start = $last_page * $limit - $limit; } elseif ($start < 0) { $start = 0; } $items = Model_Items::getAllByCollection($collectionID, $start, $limit, $prefix . $sort . ' ' . $order); if ($items) { $link = $request->getBaseUrl() . '?&controller=collections&action=view&collection_id=' . $collectionID . '&name=' . WM_Router::clearName($collection['name']); $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->items = array(); foreach ($items as $item) { $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, 'category'); } $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 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 view_collectionAction() { $request = $this->getRequest(); $collection_id = $request->getRequest('view_collection'); if (!$collection_id) { return $this->forward('error', 'error404'); } $collection = Model_Collections::get($collection_id); $this->view->my_profil = $collection['username'] == JO_Session::get('username'); if (!$collection || $collection['public'] == 'false' && !$this->view->my_profil) { 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'); } else { if (JO_Session::get('msg_error')) { $this->view->msg_error = JO_Session::get('msg_error'); JO_Session::clear('msg_error'); } } $this->getLayout()->meta_title = $collection['firstname'] . ' ' . $collection['lastname'] . ' - ' . $collection['username'] . ' - ' . $collection['name']; $this->getLayout()->meta_description = $collection['firstname'] . ' ' . $collection['lastname'] . ' - ' . $collection['username'] . ' - ' . $collection['name']; $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 ($sort == 'username') { $prefix = 'users.'; } else { $prefix = 'items.'; } $user = $this->view->users = Model_Users::getByUsername($collection['username']); $this->view->author_header = Helper_Author::authorHeader($user); $this->view->form_name = $this->translate('Edit Collection'); $this->view->form_data = $collection; $this->view->upload_link = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=change&collection_id=' . $collection['id']); $collection['without_bt'] = true; $this->view->collection_name = $collection['name']; if ($this->view->my_profile) { $collection['delete_href'] = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=delete&collection_id=' . $collection['id']); $collection['delete_txt'] = $this->translate('Are you sure you want to delete the collection? Once deleted it can not ne restored again!'); $collection['edit_public_href'] = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=change&collection_id=' . $collection['id']); } $this->view->rate_link = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=rate_collection&collection_id=' . $collection['id']); $this->view->collection = Helper_Collection::returnViewIndex($collection, true); /* CRUMBS */ $this->view->crumbs = array(array('name' => $this->view->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $collection['username'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username'])), array('name' => $this->view->translate('Collections'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=collections&username='******'username']))); $total_records = Model_Items::CountByCollection($collection_id); $start = $page * $limit - $limit; if ($start > $total_records) { $last_page = max(ceil($total_records / $limit), 1); $start = $last_page * $limit - $limit; } elseif ($start < 0) { $start = 0; } $items = Model_Items::getAllByCollection($collection_id, $start, $limit, $prefix . $sort . ' ' . $order); if ($items) { $link = $request->getBaseUrl() . '?&controller=users&action=view_collection&collection_id=' . $collection_id . '&name=' . $collection['name']; $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->items = array(); foreach ($items as $item) { $item['delete_txt'] = $this->translate('Are you sure you want to delete the item?'); $item['delete_href'] = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=delete&collection_id=' . $collection['id'] . '&item=' . $item['id']); $this->view->items[] = Helper_Items::returnViewIndex($item, 'category'); } $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 popularAction() { $request = $this->getRequest(); $category_id = $request->getParam('category_id'); $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 = 'sales'; } if ($sort == 'username') { $prefix = 'users.'; } else { $prefix = 'items.'; } $date = $request->getRequest('date'); if (empty($date)) { $date = date("m-Y", strtotime("-1 month")); } $date_parts = explode('-', $date); $where = 'MONTH(`paid_datetime`) = \'' . $date_parts[0] . '\' AND YEAR(`paid_datetime`) = \'' . $date_parts[1] . '\''; $this->view->category['name'] = $this->view->translate('Popular Items'); $this->getLayout()->meta_title = $this->view->category['name']; $this->getLayout()->meta_description = $this->view->category['name']; $link = $request->getBaseUrl() . '?controller=categories&action=popular&page_id=date/' . $date; $this->view->sort_by = array(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), array('name' => $this->view->translate('author name'), 'href' => WM_Router::create($link . '&sort=username'), 'is_selected' => $sort == 'username' ? 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)); /* CRUMBS */ $this->view->crumbs = array(); $this->view->crumbs[] = array('name' => $this->view->translate('Home'), 'href' => $request->getBaseUrl()); $total_records = Model_Items::getTopSellersCount($where); $start = $page * $limit - $limit; if ($start > $total_records) { $last_page = max(ceil($total_records / $limit), 1); $start = $last_page * $limit - $limit; } elseif ($start < 0) { $start = 0; } $items = Model_Items::getTopSellers($start, $limit, $where, $prefix . $sort . ' ' . $order); $categories = Model_Items::getPopularFilesDates(); if ($categories) { $this->view->all_categories_name = $this->translate('Period'); $this->view->categories = array(); foreach ($categories as $k => $v) { $this->view->categories[$k] = array('name' => $v['paid_date'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=popular&page_id=date/' . str_replace(' ', '', $v['paid_date']))); } } /* PAGENATION */ $link .= '&order=' . $order; $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 (!empty($item['demo_url'])) { $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'; $this->setViewChange('index'); }
public function top_sellersAction() { $this->getLayout()->meta_title = $this->translate('Top sellers'); $this->getLayout()->meta_description = $this->translate('Top sellers'); $this->getLayout()->placeholder('checkItemsType', true); $model_images = new Model_Images(); $year = $this->getRequest()->getRequest('top_sellers'); $month = $this->getRequest()->getRequest($year); $day = $this->getRequest()->getRequest($month); if (!checkdate(intval($month), intval($day), intval($year))) { $year = date('Y'); $month = date('m'); $day = date('d'); } $dayOfWeek = date('N', mktime(0, 0, 0, $month, $day, $year)); $dayOfWeek = 7 - $dayOfWeek; if ($dayOfWeek > 0) { $endDate = date('Y-m-d', mktime(0, 0, 0, $month, $day + $dayOfWeek, $year)); } else { if (strlen($month) == 1) { $month = '0' . $month; } if (strlen($day) == 1) { $day = '0' . $day; } $endDate = $year . '-' . $month . '-' . $day; } $startDate = date('Y-m-d', strtotime($endDate) - 604800); $this->view->endDate = $endDate; #GENERATE PREV AND NEXT if (strtotime($endDate) < strtotime(date('Y-m-d'))) { $this->view->nextDate = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=items&action=top_sellers/' . date('Y/m/d', strtotime($endDate) + 604800)); } $this->view->prevDate = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=items&action=top_sellers/' . date('Y/m/d', strtotime($startDate))); $month = date('m', strtotime($endDate)) - 1; $endMonthlyDate = date('Y-m-d', mktime(0, 0, 0, $month, date('t', mktime(0, 0, 0, $month, 1, date('Y'))), date('Y'))); $startMonthlyDate = date('Y-m-d', mktime(0, 0, 0, $month - 3, 1, date('Y'))); $this->view->endMonthlyDate = $endMonthlyDate; $endMonthlyDate2 = date('Y-m-d', mktime(0, 0, 0, $month, date('t', mktime(0, 0, 0, $month, 1, date('Y'))), date('Y'))); $startMonthlyDate2 = date('Y-m-d', mktime(0, 0, 0, $month, 1, date('Y'))); $this->view->month = $month; #GET ITEMS $topSellItems = Model_Items::getTopSellers(0, 50, "`paid_datetime` > '{$startDate} 23:59:59' AND `paid_datetime` < '{$endDate} 23:59:59' "); $this->view->topSellItems = array(); if ($topSellItems) { $position = 1; foreach ($topSellItems as $n => $item) { $item['position'] = $position++; $this->view->topSellItems[] = Helper_Items::returnViewIndex($item, 'category'); } } $topMonthlyItems = Model_Items::getTopSellers(0, 50, "`paid_datetime` > '{$startMonthlyDate} 00:00:00' AND `paid_datetime` < '{$endMonthlyDate} 23:59:59' "); $this->view->topMonthlyItems = array(); if ($topMonthlyItems) { $position = 1; foreach ($topMonthlyItems as $n => $item) { $item['position'] = $position++; $this->view->topMonthlyItems[] = Helper_Items::returnViewIndex($item, 'category'); } } $authors = Model_Users::getTopAuthors("AND `paid_datetime` > '{$startMonthlyDate2} 00:00:00' AND `paid_datetime` < '{$endMonthlyDate2} 23:59:59'"); if ($authors) { foreach ($authors as $v => $aut) { $authors[$v]['avatar'] = $model_images->resize($aut['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); $authors[$v]['href'] = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&username='******'username'])); } } $this->view->monthList = array(); for ($i = 1; $i <= 12; $i++) { $this->view->monthList[] = JO_Date::getInstance(date('Y') . '-' . sprintf('%02d', $i) . '-01', 'MM', true)->toString(); } $this->view->featuredAuthors = $authors; $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'); }