示例#1
0
 /** ************************************************************************
  * REQUIRED! This is where you prepare your data for display. This method will
  * usually be used to query the database, sort and filter the data, and generally
  * get it ready to be displayed. At a minimum, we should set $this->items and
  * $this->set_pagination_args(), although the following properties and methods
  * are frequently interacted with here...
  * 
  * @uses $this->_column_headers
  * @uses $this->items
  * @uses $this->get_columns()
  * @uses $this->get_sortable_columns()
  * @uses $this->get_pagenum()
  * @uses $this->set_pagination_args()
  **************************************************************************/
 function prepare_items()
 {
     // init model
     $templatesModel = new TemplatesModel();
     // get all items
     $this->db_items = $templatesModel->getAll();
     /**
      * First, lets decide how many records per page to show
      */
     $per_page = $this->get_items_per_page('templates_per_page', 20);
     $data = $this->db_items;
     /**
      * REQUIRED. Finally, we build an array to be used by the class for column 
      * headers. The $this->_column_headers property takes an array which contains
      * 3 other arrays. One for all columns, one for hidden columns, and one
      * for sortable columns.
      */
     // $this->_column_headers = array($columns, $hidden, $sortable);
     $this->_column_headers = $this->get_column_info();
     /**
      * Optional. You can handle your bulk actions however you see fit. In this
      * case, we'll handle them within our package just to keep things clean.
      */
     $this->process_bulk_action();
     /**
      * This checks for sorting input and sorts the data in our array accordingly.
      * 
      */
     function usort_reorder($a, $b)
     {
         $orderby = !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'template_name';
         //If no sort, default to title
         $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc';
         //If no order, default to asc
         $result = strcmp($a[$orderby], $b[$orderby]);
         //Determine sort order
         return $order === 'asc' ? $result : -$result;
         //Send final sort direction to usort
     }
     usort($data, 'usort_reorder');
     /**
      * REQUIRED for pagination. Let's figure out what page the user is currently 
      * looking at. We'll need this later, so you should always include it in 
      * your own package classes.
      */
     $current_page = $this->get_pagenum();
     /**
      * REQUIRED for pagination. Let's check how many items are in our data array. 
      * In real-world use, this would be the total number of items in your database, 
      * without filtering. We'll need this later, so you should always include it 
      * in your own package classes.
      */
     $total_items = count($data);
     /**
      * The WP_List_Table class does not handle pagination for us, so we need
      * to ensure that the data is trimmed to only the current page. We can use
      * array_slice() to 
      */
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     /**
      * REQUIRED. Now we can add our *sorted* data to the items property, where 
      * it can be used by the rest of the class.
      */
     $this->items = $data;
     /**
      * REQUIRED. We also have to register our pagination options & calculations.
      */
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
示例#2
0
 public function checkSetup($page = false)
 {
     global $pagenow;
     // check if safe mode is enabled
     $this->isPhpSafeMode();
     // check if incomatible plugins are active
     $this->checkPlugins();
     // check if a recent version of WooCommerce is installed
     $this->checkWooCommerce();
     // check if cURL is loaded
     if (!$this->isCurlLoaded()) {
         return false;
     }
     // check for windows server
     // if ( $this->isWindowsServer() ) return false;
     $this->isWindowsServer($page);
     // create folders if neccessary
     if ($this->checkFolders()) {
         return false;
     }
     // check for updates
     $this->checkForUpdates();
     // check if cron is working properly
     $this->checkCron();
     // check if any sites need to be refreshed
     $this->checkSites();
     // check database after migration
     // $this->checkDatabase();
     // $this->checkDbForInvalidAccounts();
     // check for multisite installation
     // if ( $this->checkMultisite() ) return false;
     $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : false;
     // setup wizard
     // if ( self::getOption('ebay_token') == '' ) {
     if ('1' == self::getOption('setup_next_step') && $current_tab != 'accounts') {
         $msg1 = __('You have not linked WP-Lister to your eBay account yet.', 'wplister');
         $msg2 = __('To complete the setup procedure go to %s and follow the instructions.', 'wplister');
         $accounts_page = get_option('wplister_enable_accounts_page') ? 'wplister-settings-accounts' : 'wplister-settings&tab=accounts';
         $link = sprintf('<a href="admin.php?page=%s">%s</a>', $accounts_page, __('Account Settings', 'wplister'));
         $msg2 = sprintf($msg2, $link);
         $msg = "<b>{$msg1}</b></p><p>{$msg2}";
         wple_show_message($msg, 'info');
     } elseif ('2' == self::getOption('setup_next_step')) {
         $title = __('Setup - Step 2', 'wplister');
         $msg1 = __('Before creating your first profile, we need to download certain information which are specific to the eBay site you selected.', 'wplister');
         $msg2 = __('This includes shipping options, payment methods, your custom store categories as well as the whole eBay category tree, which might take a while.', 'wplister');
         // old button
         // $button = '<a href="#" id="btn_update_ebay_data" onclick="return false;" class="button-primary">'.__('Update eBay details','wplister').'</a>';
         // new button - use site_id of default (first) account
         $account = WPLE()->accounts[get_option('wplister_default_account_id')];
         $button = '<a href="#" data-site_id="' . $account->site_id . '" data-account_id="' . $account->id . '" class="btn_update_ebay_data_for_site button-primary">' . __('Refresh eBay details', 'wplister') . '</a>';
         $msg = "<p><b>{$title}</b></p><p>{$msg1}</p><p>{$msg2}</p>";
         $msg .= $button;
         wple_show_message($msg, 'info');
         // // remember when WP-Lister was connected to an eBay account for the first time
         // update_option( 'ignore_orders_before_ts', time() );
     } elseif ('3' == self::getOption('setup_next_step')) {
         $tm = new TemplatesModel();
         $templates = $tm->getAll();
         if (sizeof($templates) > 0) {
             self::updateOption('setup_next_step', '4');
         } else {
             $title = __('Setup - Step 3', 'wplister');
             $msg1 = __('Create a default listing template.', 'wplister');
             $msg2 = __('To create your first listing template click on %s.', 'wplister') . '<br>';
             if (@$_GET['action'] == 'add_new_template') {
                 $msg2 = __('Replace the default text according to your requirements and save your template to continue.', 'wplister');
             }
             $link = '<a href="admin.php?page=wplister-templates&action=add_new_template">' . __('New Template', 'wplister') . '</a>';
             $msg2 = sprintf($msg2, $link);
             $msg = "<p><b>{$title}</b></p><p><b>{$msg1}</b></p><p>{$msg2}</p>";
             wple_show_message($msg, 'info');
         }
     } elseif ('4' == self::getOption('setup_next_step')) {
         $pm = new ProfilesModel();
         $profiles = $pm->getAll();
         if (sizeof($profiles) > 0) {
             self::updateOption('setup_next_step', '0');
         } else {
             $title = __('Setup - Step 4', 'wplister');
             $msg1 = __('The final step: create your first listing profile.', 'wplister');
             $msg2 = __('Click on %s and start defining your listing options.<br>After saving your profile, visit your Products page and select the products to list on eBay.', 'wplister');
             $link = '<a href="admin.php?page=wplister-profiles&action=add_new_profile">' . __('New Profile', 'wplister') . '</a>';
             $msg2 = sprintf($msg2, $link);
             $msg = "<b>{$msg1}</b></p><p>{$msg2}";
             wple_show_message($msg, 'info');
         }
     } elseif ('5' == self::getOption('setup_next_step')) {
         $title = __('Setup is complete.', 'wplister');
         $msg1 = __('You are ready now to list your first items.', 'wplister');
         $msg2 = __('Visit your Products page, select a few items and select "List on eBay" from the bulk actions menu.', 'wplister');
         $msg = "<b>{$msg1}</b></p><p>{$msg2}";
         wple_show_message($msg, 'info');
         update_option('wplister_setup_next_step', '0');
     }
     // db upgrade
     WPLE_UpgradeHelper::upgradeDB();
     // check token expiration date
     self::checkToken();
     // check if all db tables exist
     self::checkDatabaseTables($page);
     // // fetch user details if not done yet
     // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_user') ) ) {
     // 	$this->initEC();
     // 	$UserID = $this->EC->GetUser();
     // 	$this->EC->closeEbay();
     // }
     // // fetch user details if not done yet
     // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_seller_profiles_enabled') ) ) {
     // 	$this->initEC();
     // 	$this->EC->GetUserPreferences();
     // 	$this->EC->closeEbay();
     // }
     // // fetch token expiration date if not done yet
     // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_token_expirationtime') ) ) {
     // 	$this->initEC();
     // 	$expdate = $this->EC->GetTokenStatus();
     // 	$this->EC->closeEbay();
     // }
 }
示例#3
0
 public function displayEditPage()
 {
     // get item
     $item = ListingsModel::getItem($_REQUEST['auction']);
     // unserialize details
     $this->initEC($item['account_id']);
     // $item['details'] = maybe_unserialize( $item['details'] );
     // echo "<pre>";print_r($item);echo"</pre>";die();
     // get ebay data
     $countries = EbayShippingModel::getEbayCountries();
     // $template_files 		= $this->getTemplatesList();
     $templatesModel = new TemplatesModel();
     $templates = $templatesModel->getAll();
     $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'item' => $item, 'countries' => $countries, 'template_files' => $templates, 'form_action' => 'admin.php?page=' . self::ParentMenuId . (isset($_REQUEST['paged']) ? '&paged=' . $_REQUEST['paged'] : ''));
     $this->display('listings_edit_page', array_merge($aData, $item));
 }
示例#4
0
 public function getTemplatesList()
 {
     $templatesModel = new TemplatesModel();
     $templates = $templatesModel->getAll();
     return $templates;
 }
示例#5
0
 private function displayListPage()
 {
     // handle upload template
     if ($this->requestAction() == 'wpl_upload_template') {
         $this->uploadTemplate();
     }
     // init model
     $templatesModel = new TemplatesModel();
     // get all items
     $templates = $templatesModel->getAll();
     //Create an instance of our package class...
     $templatesTable = new TemplatesTable();
     //Fetch, prepare, sort, and filter our data...
     // $templatesTable->db_items = $templates; // no effect on WP4.2
     $templatesTable->prepare_items();
     // refresh cache of template names and descriptions
     $this->refreshTemplatesCache($templates);
     // process errors
     #if ($this->IC->message) $this->showMessage( $this->IC->message,1 );
     $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'templatesTable' => $templatesTable, 'form_action' => 'admin.php?page=' . self::ParentMenuId . '-templates');
     $this->display('templates_page', $aData);
 }