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 dashboardAction() { $request = $this->getRequest(); $model_images = new Model_Images(); if (!JO_Session::get('user_id')) { JO_Session::set('msg_error', $this->translate('You must be logged to view your dashboard')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } $this->getLayout()->meta_title = $this->translate('Dashboard'); $this->getLayout()->meta_description = $this->translate('Dashboard'); $page = (int) $request->getRequest('page', 1); if ($page < 1) { $page = 1; } $limit = JO_Registry::get('front_limit'); 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'); } $username = JO_Session::get('username'); $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $username, 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'name' => $this->translate('Dashboard'))); $user = Model_Users::getByUsername($username); $this->view->author_header = Helper_Author::authorHeader($user); $where = "`items_comments`.`user_id` = '" . $user['user_id'] . "' AND `items_comments`.`reply_to` = 0"; $total_records = Model_Comments::getTotal($where); $start = $page * $limit - $limit; if ($start > $total_records) { $page = max(ceil($total_records / $limit), 1); $start = $page * $limit - $limit; } elseif ($start < 0) { $start = 0; } $bayers = Model_Orders::getClients($user['user_id']); $comments = Model_Comments::getAll($start, $limit, $where, true, "datetime DESC"); $this->view->comments = array(); if ($comments) { $bbcode_parser = new WM_BBCode_Parser(); $bbcode_parser->loadDefaultCodes(); foreach ($comments as $comment) { if ($comment['avatar']) { $comment['avatar'] = $model_images->resize($comment['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $comment['avatar'] = 'data/themes/images/noavatar.png'; } $bbcode_parser->parse($comment['comment']); $comment['comment'] = Model_Comments::replaceEmoticons($bbcode_parser->getAsHtml()); $comment['datetime'] = WM_Date::format($comment['datetime'], 'dd M yy'); $comment['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'username'])); $comment['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=report/' . $comment['id']); $comment['replyhref'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=reply&c_id=' . $comment['id']); $comment['item_href'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $comment['item_id'] . '&name=' . WM_Router::clearName($comment['name'])) . '#c_' . $comment['id']; foreach ($comment['reply'] as $key => $reply) { if ($comment['reply'][$key]['avatar']) { $comment['reply'][$key]['avatar'] = $model_images->resize($comment['reply'][$key]['avatar'], 50, 50, true); } else { $comment['reply'][$key]['avatar'] = 'data/themes/images/small_noavatar.png'; } $bbcode_parser->parse($comment['reply'][$key]['comment']); $comment['reply'][$key]['comment'] = Model_Comments::replaceEmoticons($bbcode_parser->getAsHtml()); $comment['reply'][$key]['datetime'] = WM_Date::format($reply['datetime'], 'dd M yy'); $comment['reply'][$key]['is_buy'] = $bayers && in_array($reply['user_id'], $bayers); $comment['reply'][$key]['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'reply'][$key]['username'])); $comment['reply'][$key]['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=report/' . $comment['reply'][$key]['id']); } $this->view->comments[] = $comment; } } $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($request->getBaseUrl() . '?action=users&action=dashboard&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->add_comment_link = WM_Router::create($request->getBaseUrl() .'?controller=items&action=add_comment&item_id='. $item['id'] .'&name='. WM_Router::clearName($item['name'])); $this->view->mainCategories = array(); $categories = Model_Categories::getMain(); if ($categories) { $this->view->mainCategories = array(array('href' => '', 'name' => $this->translate('Please select category'))); foreach ($categories as $category) { $this->view->mainCategories[] = array('href' => WM_Router::create($request->getBaseUrl() . '?controller=upload&action=form&category_id=' . $category['id']), 'name' => $category['name']); } } $this->view->total_balance = WM_Currency::format($user['total']); $this->view->total_sales_cnt = JO_Session::get('sales'); $this->view->percent = Model_Percentes::getPercentRow($user); $help = Model_Pages::get(JO_Registry::forceGet('page_upload_item')); if ($help) { $this->view->page_upload_item = array('name' => $help['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $help['id'] . '&name=' . WM_Router::clearName($help['name']))); } $weekStats = Model_Orders::getWeekStats($user['user_id']); $this->view->weekStats_earning = WM_Currency::format($weekStats['earning']); $this->view->weekStats_sold = $weekStats['sold']; $user['total'] = WM_Currency::format($user['total']); $this->view->user = $user; $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(); JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri()); $category_id = $request->getParam('category_id'); if (!$category_id) { 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.'; } if (is_numeric($category_id)) { $this->view->category = Model_Categories::get($category_id); $this->getLayout()->meta_title = $this->view->category['name']; $this->getLayout()->meta_description = $this->view->category['name']; if ($this->view->category['sub_of'] == 0) { $categories = Model_Categories::getMain(); } else { $categories = Model_Categories::getCategories($this->view->category['sub_of']); $crumbs_categories = Model_Categories::get_all(); if ($crumbs_categories) { $parents = Model_Categories::getCategoryParents($crumbs_categories, $category_id); $parents = explode(',', $parents); $parents = array_reverse($parents); $cnt = count($parents) - 1; $crumbs = array(); for ($i = 1; $i < $cnt; $i++) { $crumbs[$i] = array('name' => $crumbs_categories[$parents[$i]]['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $parents[$i] . '&name=' . WM_Router::clearName($crumbs_categories[$parents[$i]]['name']))); } } } /* SORT */ $link = $request->getBaseUrl() . '?&controller=categories&category_id=' . $category_id; $total_records = Model_Items::CountItems($category_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::getAll($category_id, $start, $limit, ($sort == 'price' ? 'rprice' : $prefix . $sort) . ' ' . $order); } else { if (in_array($category_id, array('recent', 'featured', 'popular'))) { switch ($category_id) { case 'featured': $where = 'items.weekly_to >= \'' . date('Y-m-d') . '\''; $this->view->category['name'] = $this->view->translate('Featured Items'); $total_records = Model_Items::countWeekly(); break; default: $this->view->category['name'] = $this->view->translate('Recent Items'); $total_records = Model_Items::countItems(); } $this->getLayout()->meta_title = $this->view->category['name']; $this->getLayout()->meta_description = $this->view->category['name']; /* SORT */ $link = $request->getBaseUrl() . '?controller=categories&action=' . $category_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::getAll($category_id, $start, $limit, ($sort == 'price' ? 'rprice' : $prefix . $sort) . ' ' . $order, !empty($where) ? $where : ''); $categories = Model_Categories::getMain(); } } $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)); /* CRUMBS */ $this->view->crumbs = array(); $this->view->crumbs[] = array('name' => $this->view->translate('Home'), 'href' => $request->getBaseUrl()); if (isset($crumbs)) { $this->view->crumbs += $crumbs; } /* CATEGORIES */ if ($categories) { $this->view->all_categories_name = $this->translate('All Categories'); $this->view->categories = array(); foreach ($categories as $k => $v) { $this->view->categories[$k] = array('name' => $v['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name']))); } } /* 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() . '?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'); } } $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function editAction() { $request = $this->getRequest(); if (!JO_Session::get('user_id')) { JO_Session::set('msg_error', $this->translate('You must be logged to access that page')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } $itemID = $request->getRequest('edit'); $item = Model_Items::get($itemID); if (JO_Session::get('user_id') != $item['user_id']) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name']))); } $this->getLayout()->meta_title = $item['name']; $this->getLayout()->meta_description = substr(strip_tags(html_entity_decode($item['description'], ENT_QUOTES, 'utf-8')), 0, 255); $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() . '?controller=items&action=edit&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $this->view->delete_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=delete&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Portfolio'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username')))), array('name' => $item['name'], 'href' => $this->view->item_link), array('name' => $this->translate('Edit'))); $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $categories = Model_Categories::getMain(); if ($categories) { foreach ($categories as $category) { $this->view->categories[] = array('id' => $category['id'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=upload&action=get_categories&category_id=' . $category['id']), 'name' => $category['name']); } } $this->view->mainCategories = $categories; 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->error = JO_Session::get('msg_error'); $data = JO_Session::get('data'); JO_Session::clear('msg_error'); JO_Session::clear('data'); } $this->view->sel_category = isset($data) ? $data['category_id'] : reset($item['categories'][0]); $allCategories = Model_Categories::getWithChilds(); $this->view->categoriesSelect = array(); $categoriesSelect = Model_Categories::generateSelect($allCategories, $this->view->sel_category, $this->view->sel_category); if ($categoriesSelect) { $categories = explode('|', $categoriesSelect); foreach ($categories as $category) { if (!empty($category)) { $c = explode('>', $category); $this->view->categoriesSelect[] = array('id' => $c[0], 'name' => $c[1]); } } } $this->view->attributes = Model_Attributes::getAllWithCategories("attributes_categories.categories LIKE '%," . (int) $this->view->sel_category . ",%'"); $this->view->total_sales_cnt = JO_Session::get('sales'); $this->view->total_balance = WM_Currency::format(JO_Session::get('total')); $user = array('user_id' => JO_Session::get('user_id'), 'sold' => JO_Session::get('sold')); $this->view->percent = Model_Percentes::getPercentRow($user); if (isset($data)) { $item['name'] = $data['name']; $item['description'] = $data['description']; $item['theme_preview'] = $data['theme_preview']; $item['theme_preview_zip'] = $data['theme_preview_zip']; $item['main_file'] = $data['main_file']; $item['reviewer_comment'] = $data['reviewer_comment']; $item['attributes'] = $data['attributes']; isset($data['source_license']) && ($item['source_license'] = $data['source_license']); isset($data['free_request']) && ($item['free_file'] = true); } $item['suggested_price'] = isset($data['suggested_price']) ? $data['suggested_price'] : $item['price']; $item['selected_categories'] = isset($data['category']) ? $data['category'] : JO_Array::multi_array_to_single_uniq($item['categories']); $item['selected_attributes'] = isset($data['attributes']) ? JO_Array::multi_array_to_single_uniq($data['attributes']) : JO_Array::multi_array_to_single_uniq($item['attributes']); $item['selected_tags'] = isset($data['tags']) ? $data['tags'] : implode(', ', JO_Array::multi_array_to_single_uniq($item['tags'])); $help = Model_Pages::get(JO_Registry::forceGet('page_upload_item')); if ($help) { $this->view->page_upload_item = array('name' => $help['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $help['id'])); } $this->view->uploaded_files = JO_Session::get('uploaded_files'); $this->view->uploaded_arhives = JO_Session::get('uploaded_arhives'); $this->view->file_upload = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=upload&action=doupload'); $this->view->action_upload = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=doedit'); $this->view->d = $item; $this->view->autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=items&action=auto'); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function formAction() { $request = $this->getRequest(); if (!JO_Session::get('user_id')) { JO_Session::set('msg_error', $this->translate('You must be logged to upload an item')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } if (JO_Session::get('quiz') != 'true') { JO_Session::set('msg_error', $this->translate('In order to upload your files for sale first you have to pass our quiz.')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=quiz')); } if ($request->getRequest('form')) { $category_id = $request->getRequest('form'); } $redir_link = WM_Router::create($request->getBaseUrl() . '?controller=upload'); if (!$category_id) { $this->redirect($redir_link); } $this->getLayout()->meta_title = $this->translate('Item upload'); $this->getLayout()->meta_description = $this->translate('Item upload'); $mainCategories = Model_Categories::getMain(); $cnt = count($mainCategories); for ($i = 0; $i < $cnt; $i++) { $mainCategories[$i]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=upload&action=get_categories&category_id=' . $mainCategories[$i]['id']); } $category_info = Model_Categories::get($category_id); $has_category = JO_Array::multi_array_search($mainCategories, 'id', $category_id); if (!$category_info) { JO_Session::set('msg_error', $this->translate('You have choosen a non existing category')); $this->redirect($redir_link); } elseif (empty($has_category)) { JO_Session::set('msg_error', $this->translate('You have choosen a non existing category')); $this->redirect($redir_link); } if (JO_Session::get('msg_error')) { $this->view->error = JO_Session::get('msg_error'); JO_Session::clear('msg_error'); } if (JO_Session::get('data')) { $this->view->d = JO_Session::get('data'); JO_Session::clear('data'); } $fileTypes = JO_Registry::get('upload_theme'); $types = ''; if ($fileTypes) { foreach ($fileTypes as $type) { $tp = explode(',', $type); foreach ($tp as $t) { $types .= '*.' . $t . ';'; } } } $this->view->sel_category = $category_id; $this->view->mainCategories = $mainCategories; $allCategories = Model_Categories::getWithChilds(); $categoriesSelect = Model_Categories::generateSelect($allCategories, $category_id, $category_id); if ($categoriesSelect) { $categories = explode('|', $categoriesSelect); foreach ($categories as $category) { if (!empty($category)) { $c = explode('>', $category); $this->view->categoriesSelect[] = array('id' => $c[0], 'name' => trim($c[1])); } } } $this->view->fileTypes = $types; $this->view->attributes = Model_Attributes::getAllWithCategories("attributes_categories.categories LIKE '%," . (int) $category_id . ",%'"); $fileTypes_allow = JO_Registry::get('upload_theme'); $allow_archives = array(); if (isset($fileTypes_allow['archives'])) { $ew = explode(',', $fileTypes_allow['archives']); foreach ($ew as $ar) { $allow_archives[] = '.' . strtolower($ar); } } $allow_images = array(); if (isset($fileTypes_allow['images'])) { $ew = explode(',', $fileTypes_allow['images']); foreach ($ew as $ar) { $allow_images[] = '.' . strtolower($ar); } } $this->view->uploaded_files = JO_Session::get('uploaded_files'); $this->view->uploaded_arhives = JO_Session::get('uploaded_arhives'); $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Upload'))); $user = Model_Users::getByUsername(JO_Session::get('username')); $this->view->author_header = Helper_Author::authorHeader($user); $this->view->action_upload = WM_Router::create($request->getBaseUrl() . '?controller=upload&action=upload'); $this->view->autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=items&action=auto'); $this->view->total_sales_cnt = JO_Session::get('sales'); $this->view->total_balance = WM_Currency::format(JO_Session::get('total')); $this->view->percent = Model_Percentes::getPercentRow($user); $help = Model_Pages::get(JO_Registry::forceGet('page_upload_item')); if ($help) { $this->view->page_upload_item = array('name' => $help['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $help['id'] . '&name=' . WM_Router::clearName($help['name']))); } $this->view->file_upload = WM_Router::create($request->getBaseUrl() . '?module=themes&controller=upload&action=doupload'); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
private function getCategories() { $request = $this->getRequest(); $mainCategories = Model_Categories::getMain(); if ($mainCategories) { $i = 0; $this->view->mainCategories = array(); foreach ($mainCategories as $k => $v) { if ($i < 6) { $this->view->mainCategories[$i] = array('name' => $v['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name'])), 'sub_cats' => Model_Categories::getCategories($v['id'])); $v['sub_cats'] = Model_Categories::getCategories($v['id']); if ($v['sub_cats']) { foreach ($v['sub_cats'] as $sk => $sv) { $this->view->mainCategories[$i]['sub_cats'][$sk]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $sv['id'] . '&name=' . WM_Router::clearName($sv['name'])); } } } else { if ($i == 6) { $this->view->mainCategories[6] = array('name' => $this->view->translate('More'), 'href' => '#', 'no_link' => 1); } $this->view->mainCategories[6]['sub_cats'][] = array('name' => $v['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name']))); } $i++; } } }