From c7b4c712d8cd1903bfcafc19bcfd922e9adb4d8b Mon Sep 17 00:00:00 2001 From: Hussein Al Hammad Date: Thu, 2 Apr 2020 13:19:06 +0400 Subject: [PATCH] Republish, smartbar --- pipit_catalog/modes/list.smartbar.php | 41 ++++++++++++++++++-------- pipit_catalog/modes/reorder.post.php | 18 ++--------- pipit_catalog/modes/reorder.pre.php | 2 +- pipit_catalog/modes/republish.post.php | 15 ++++++++++ pipit_catalog/modes/republish.pre.php | 33 +++++++++++++++++++++ pipit_catalog/republish/index.php | 26 ++++++++++++++++ 6 files changed, 105 insertions(+), 30 deletions(-) create mode 100644 pipit_catalog/modes/republish.post.php create mode 100644 pipit_catalog/modes/republish.pre.php create mode 100644 pipit_catalog/republish/index.php diff --git a/pipit_catalog/modes/list.smartbar.php b/pipit_catalog/modes/list.smartbar.php index 852e841..78242c6 100644 --- a/pipit_catalog/modes/list.smartbar.php +++ b/pipit_catalog/modes/list.smartbar.php @@ -6,33 +6,48 @@ $ParentSmartbar->add_item([ 'active' => $smartbar_selection=='products', 'title' => $Lang->get('Products'), - 'link' => $URL, + 'link' => $API->app_nav(), 'icon' => 'ext/o-shirt', ]); - if(!$Settings->get('pipit_catalog_hideSearch')->val()) { + + + if($smartbar_selection == 'products') { + if(!$Settings->get('pipit_catalog_hideSearch')->val()) { + $ParentSmartbar->add_item([ + 'active' => false, + 'type' => 'search', + 'title' => 'Search', + 'arg' => 'q', + 'icon' => 'core/search', + 'position' => 'end', + ]); + } + $ParentSmartbar->add_item([ - 'active' => false, - 'type' => 'search', - 'title' => 'Search', - 'arg' => 'q', - 'icon' => 'core/search', + 'title' => $Lang->get('Clear filters'), + 'link' => $API->app_nav(), + 'icon' => 'core/circle-delete', 'position' => 'end', ]); } - $ParentSmartbar->add_item([ - 'title' => $Lang->get('Clear filters'), - 'link' => $URL, - 'icon' => 'core/circle-delete', - 'position' => 'end', - ]); + $ParentSmartbar->add_item([ + 'active' => $smartbar_selection=='reorder', 'title' => $Lang->get('Reorder'), 'link' => $API->app_nav().'/reorder/', 'icon' => 'core/menu', 'position' => 'end', + ]); + + $ParentSmartbar->add_item([ + 'active' => $smartbar_selection=='republish', + 'title' => $Lang->get('Republish'), + 'link' => $API->app_nav().'/republish/', + 'icon' => 'core/documents', + 'position' => 'end', ]); echo $ParentSmartbar->render(); \ No newline at end of file diff --git a/pipit_catalog/modes/reorder.post.php b/pipit_catalog/modes/reorder.post.php index 6a5ffdc..b395eaf 100644 --- a/pipit_catalog/modes/reorder.post.php +++ b/pipit_catalog/modes/reorder.post.php @@ -6,24 +6,10 @@ 'heading' => $Lang->get('Listing all Products'), ], $CurrentUser); - $Smartbar = new PerchSmartbar($CurrentUser, $HTML, $Lang); + include(__DIR__.'/list.smartbar.php'); - $Smartbar->add_item([ - 'active' => false, - 'title' => $Lang->get('Products'), - 'link' => $API->app_nav(), - 'icon' => 'ext/o-shirt', - ]); - $Smartbar->add_item([ - 'active' => true, - 'title' => $Lang->get('Reorder'), - 'link' => $API->app_nav().'/reorder/', - 'icon' => 'core/menu', - 'position' => 'end', - ]); - - echo $Smartbar->render(); + if (PerchUtil::count($products)) { diff --git a/pipit_catalog/modes/reorder.pre.php b/pipit_catalog/modes/reorder.pre.php index ae39e98..d7e8372 100644 --- a/pipit_catalog/modes/reorder.pre.php +++ b/pipit_catalog/modes/reorder.pre.php @@ -4,9 +4,9 @@ $Products = new PerchShop_Products($ShopAPI); $Settings = $API->get('Settings'); - $Template = $ShopAPI->get('Template'); $Template->set('shop/products/product.html', 'shop'); + $smartbar_selection = 'reorder'; $Form = $API->get('Form'); diff --git a/pipit_catalog/modes/republish.post.php b/pipit_catalog/modes/republish.post.php new file mode 100644 index 0000000..50df2df --- /dev/null +++ b/pipit_catalog/modes/republish.post.php @@ -0,0 +1,15 @@ +title_panel([ + 'heading' => $Lang->get('Republishing Products'), + ], $CurrentUser); + + include(__DIR__.'/list.smartbar.php'); + + + echo $Form->form_start(); + echo $HTML->info_block('Republish Products?', $Lang->get('Are you sure you wish to republish all Products?')); + echo $HTML->submit_bar([ + 'button' => $Form->submit('btnsubmit', 'Republish', 'button'), + 'cancel_link' => '/core/apps/content/' + ]); + echo $Form->form_end(); \ No newline at end of file diff --git a/pipit_catalog/modes/republish.pre.php b/pipit_catalog/modes/republish.pre.php new file mode 100644 index 0000000..5cd71a5 --- /dev/null +++ b/pipit_catalog/modes/republish.pre.php @@ -0,0 +1,33 @@ +get('Template'); + $Template->set('shop/products/product.html', 'shop'); + + $smartbar_selection = 'republish'; + $sort_id = 'productOrder'; + $sort_order = 'ASC'; + $listing_opts = ['return-objects' => true,]; + + $where_callback = function (PerchQuery $Query) { + $Query->where[] = 'productDeleted IS NULL'; + $Query->where[] = 'parentID IS NULL'; + return $Query; + }; + + + + + $Form = $API->get('Form'); + if ($Form->submitted()) { + $products = $Products->get_filtered_listing($listing_opts, $where_callback, true); + + if (PerchUtil::count($products)) { + foreach($products as $Product) { + if (is_object($Product)) $Product->index($Template); + } + + $Alert->set('success', $Lang->get('Products successfully republished. Return to %s Product List %s', '', '')); + } + } \ No newline at end of file diff --git a/pipit_catalog/republish/index.php b/pipit_catalog/republish/index.php new file mode 100644 index 0000000..18a9cab --- /dev/null +++ b/pipit_catalog/republish/index.php @@ -0,0 +1,26 @@ +get('Lang'); + $HTML = $API->get('HTML'); + $Paging = $API->get('Paging'); + + # Set the page title + $Perch->page_title = $Lang->get('Products: Republish Products'); + + # Do anything you want to do before output is started + include('../modes/_subnav.php'); + include('../modes/republish.pre.php'); + $Perch->add_css($API->app_path().'/assets/css/styles.css'); + + # Top layout + include(PERCH_CORE . '/inc/top.php'); + + # Display your page + include('../modes/republish.post.php'); + + + # Bottom layout + include(PERCH_CORE . '/inc/btm.php');