api = [
'trading' => new Trading_API(),
'finding' => new Finding_API(),
'shopping' => new Shopping_API()
];
$this->db = new Database();
}
public function form_new()
{
$step = ( isset( $_GET[ 'step' ] ) ) ? $_GET[ 'step' ] : '1';
if( $step < 1 || $step > 1 ) {
return;
}
switch( $step ) {
case 1:
$this->form_new_step_1();
break;
}
}
public function form_edit()
{
$step = ( isset( $_GET[ 'step' ] ) ) ? $_GET[ 'step' ] : '1';
if( $step < 1 || $step > 1 ) {
return;
}
switch( $step ) {
case 1:
$this->form_edit_step_1();
break;
}
}
public function form_cats()
{
$step = ( isset( $_GET[ 'step' ] ) ) ? $_GET[ 'step' ] : '1';
$token = $this->api[ 'trading' ]->get_token();
if( $step < 1 || $step > 1 ) {
return;
}
switch( $step ) {
case 1:
if ( $token === '' ) {
$this->form_cats_get_auth();
} else {
$this->form_cats_step_1();
}
break;
}
}
public function form_delete()
{
$step = ( isset( $_GET[ 'step' ] ) ) ? $_GET[ 'step' ] : '1';
if( $step < 1 || $step > 1 ) {
return;
}
switch( $step ) {
case 1:
$this->form_delete_step_1();
break;
}
}
private function form_new_step_1()
{
$categories = $this->categories_as_options( $this->api[ 'trading' ]->get_categories() );
$conditions = $this->conditions_as_options();
?>
categories_as_options( $this->api[ 'trading' ]->get_categories(), $this->settings[ 'default_categories' ] );
$conditions = $this->conditions_as_options( $this->settings[ 'default_condition' ] );
?>
api[ 'trading' ]->get_session_id();
?>
get_local_category_list_version();
$ebay_version = $this->api[ 'trading' ]->make_call( 'get_ebay_category_list_version' );
$ebay_version = $ebay_version->get_payload();
if ( $local_version != $ebay_version ) {
$download = true;
$title = 'Step 1';
$action = 'cats';
$step = '2';
} else {
$download = false;
$title = 'Up-To-Date';
$action = '';
$step = '';
}
?>
'trading',
'call' => 'GetSessionID',
];
$this->api->call( $args );
return;
}
private function get_categories()
{
$args = [
'call-type' => 'trading',
'call' => 'GetCategories',
];
$this->api->call( $args );
return;
}
public function get_categories_as_options( $input = [] )
{
$selected = ( $input !== [] ) ? $input[ 'shortcode-categories' ] : $this->settings[ 'default_categories' ];
return $this->categories_as_options( $this->api[ 'trading' ]->get_categories(), $selected );
}
private function categories_as_options( $cats, $selected_cats = [] )
{
if ( is_null( $selected_cats ) ) {
$selected_cats = [];
}
$opts = '';
$cur_lvl = 0;
foreach( $cats as $cat ) {
if ( $cat->category_level !== $cur_lvl ) {
$cur_lvl = $cat->category_level;
if ( $cur_lvl === '1' ) {
$label = 'Top-Level Categories';
} else {
$opts .= '';
$label = 'Level ' . $cur_lvl . ' Categories';
}
$opts .= '