Skip to content

Commit

Permalink
Republish, smartbar
Browse files Browse the repository at this point in the history
  • Loading branch information
husseinalhammad committed Apr 2, 2020
1 parent ef856c6 commit c7b4c71
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 30 deletions.
41 changes: 28 additions & 13 deletions pipit_catalog/modes/list.smartbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
18 changes: 2 additions & 16 deletions pipit_catalog/modes/reorder.post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
2 changes: 1 addition & 1 deletion pipit_catalog/modes/reorder.pre.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
15 changes: 15 additions & 0 deletions pipit_catalog/modes/republish.post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
echo $HTML->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();
33 changes: 33 additions & 0 deletions pipit_catalog/modes/republish.pre.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
$ShopAPI = new PerchAPI(1, 'perch_shop');
$ProductsAPI = new PerchAPI(1, 'perch_shop_products');
$Products = new PerchShop_Products($ShopAPI);
$Template = $ShopAPI->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', '<a href="'. $API->app_path() .'">', '</a>'));
}
}
26 changes: 26 additions & 0 deletions pipit_catalog/republish/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
# includes
include('../../../../core/inc/api.php');

$API = new PerchAPI(1.0, 'pipit_catalog');
$Lang = $API->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');

0 comments on commit c7b4c71

Please sign in to comment.