aps_functions = $aps_functions; $this->auth = $auth; $this->config = $config; $this->config_text = $config_text; $this->helper = $helper; $this->language = $language; $this->operator_cat = $operator_cat; $this->router = $router; $this->template = $template; $this->user = $user; } /** * Check whether the shop is enabled and active. * * @return void * @throws http_exception * @throws shop_inactive_exception * @access public */ public function check_shop() { if (!$this->config['ass_enabled']) { throw new http_exception(404, 'PAGE_NOT_FOUND'); } $this->language->add_lang('ass_common', 'phpbbstudio/ass'); $this->language->add_lang('aps_display', 'phpbbstudio/aps'); if (!$this->config['ass_active'] && !$this->auth->acl_get('u_ass_can_view_inactive_shop')) { throw new shop_inactive_exception(409, 'ASS_SHOP_INACTIVE'); } } /** * Create and set up the shop. * * @param string $mode The shop mode (shop|inventory|history) * @param category|null $category The category entity * @param item|null $item The item entity * @return void * @access public */ public function create_shop($mode, category $category = null, item $item = null) { $this->create_shop_crumbs($mode, $category, $item); $this->create_shop_navbar($mode, $category); $this->template->assign_vars([ 'S_ASS_INVENTORY' => $mode === 'inventory', 'S_ASS_SHOP' => $mode === 'shop', 'S_CAN_GIFT' => $this->auth->acl_get('u_ass_can_gift') && $this->config['ass_gift_enabled'], 'S_CAN_PURCHASE' => $this->auth->acl_get('u_ass_can_purchase') && $this->user->data['is_registered'], 'S_RECEIVE_GIFT' => $this->auth->acl_get('u_ass_can_receive_gift'), ]); } /** * Create and set up the shop navigation. * * @param string $mode The shop mode (shop|inventory|history) * @param category|null $category The category entity * @return void * @access public */ public function create_shop_navbar($mode, category $category = null) { $categories = $this->operator_cat->get_categories(true); $title = $mode === 'shop' ? 'ASS_SHOP_INDEX' : 'ASS_INVENTORY'; $route = $mode === 'shop' ? 'phpbbstudio_ass_shop' : 'phpbbstudio_ass_inventory'; $this->template->assign_block_vars('ass_shop_categories', [ 'ID' => 0, 'TITLE' => $this->language->lang($title), 'ICON' => 'fa-bookmark', 'S_SELECTED' => $category === null, 'U_VIEW' => $this->helper->route($route), ]); /** @var category $cat */ foreach ($categories as $cat) { $this->template->assign_block_vars('ass_shop_categories', [ 'ID' => $cat->get_id(), 'TITLE' => $cat->get_title(), 'ICON' => $cat->get_icon(), 'S_SELECTED' => $category !== null && $cat->get_id() === $category->get_id(), 'U_VIEW' => $this->router->category($cat->get_slug(), $mode), ]); } } /** * Create and set up the shop breadcrumbs. * * @param string $mode The shop mode (shop|inventory|history) * @param category|null $category The category entity * @param item|null $item The item entity * @return void * @access public */ public function create_shop_crumbs($mode, category $category = null, item $item = null) { $title = $mode === 'shop' ? 'ASS_SHOP_INDEX' : 'ASS_INVENTORY'; $route = $mode === 'shop' ? 'phpbbstudio_ass_shop' : 'phpbbstudio_ass_inventory'; $this->template->assign_block_vars_array('navlinks', [ [ 'FORUM_NAME' => $this->aps_functions->get_name(), 'U_VIEW_FORUM' => $this->helper->route('phpbbstudio_aps_display'), ], [ 'FORUM_NAME' => $this->language->lang($title), 'U_VIEW_FORUM' => $this->helper->route($route), ], ]); if ($mode === 'history') { $this->template->assign_block_vars('navlinks', [ 'FORUM_NAME' => $this->language->lang('ASS_HISTORY'), 'U_VIEW_FORUM' => $this->helper->route('phpbbstudio_ass_history'), ]); } if ($category instanceof category) { $this->template->assign_block_vars('navlinks', [ 'FORUM_NAME' => $category->get_title(), 'U_VIEW_FORUM' => $this->router->category($category->get_slug(), $mode), ]); } if ($item instanceof item) { $this->template->assign_block_vars('navlinks', [ 'FORUM_NAME' => $item->get_title(), 'U_VIEW_FORUM' => $this->router->item($item->get_category_slug(), $item->get_slug()), ]); } } /** * Set up and assign carousel variables. * * @return void * @access public */ public function setup_carousel() { $this->template->assign_vars([ 'SHOP_CAROUSEL_ARROWS' => (bool) $this->config['ass_carousel_arrows'], 'SHOP_CAROUSEL_DOTS' => (bool) $this->config['ass_carousel_dots'], 'SHOP_CAROUSEL_FADE' => (bool) $this->config['ass_carousel_fade'], 'SHOP_CAROUSEL_PLAY' => (bool) $this->config['ass_carousel_play'], 'SHOP_CAROUSEL_PLAY_SPEED' => (int) $this->config['ass_carousel_play_speed'], 'SHOP_CAROUSEL_SPEED' => (int) $this->config['ass_carousel_speed'], ]); } /** * Set up and assign panel variables. * * @return void * @access public */ public function setup_panels() { $panels = ['featured', 'sale', 'featured_sale', 'recent', 'limited', 'random']; $options = [ 'icon' => '', 'icon_colour' => 'icon-', 'banner_colour' => 'shop-panel-icon-', 'banner_size' => 'shop-panel-icon-', ]; foreach ($panels as $panel) { if ($this->config["ass_panel_{$panel}_icon"]) { $icon = ''; foreach ($options as $option => $prefix) { $icon .= " {$prefix}{$this->config["ass_panel_{$panel}_{$option}"]}"; } $this->template->assign_var('SHOP_PANEL_' . utf8_strtoupper($panel) . '_ICON', $icon); } } } }