function getFeedData($category, $remote_category, $file_name, $saved_feed = null) { $this->logActivity('Initializing...'); global $message; global $pfcore; $providers = new PProviderList(); $this->logActivity('Loading paths...'); if (!$this->checkFolders()) { return; } $file_url = PFeedFolder::uploadFolder() . $this->providerName . '/' . $file_name . '.' . $this->fileformat; $file_path = PFeedFolder::uploadURL() . $this->providerName . '/' . $file_name . '.' . $this->fileformat; //Special (WordPress): where admin is https and site is http, path to wp-uploads works out incorrectly as https // we check the content_url() for https... if not present, patch the file_path if ($pfcore->cmsName == 'WordPress' && strpos($file_path, 'https://') !== false && strpos(content_url(), 'https') === false) { $file_path = str_replace('https://', 'http://', $file_path); } //Create the Feed $this->logActivity('Creating feed data'); $this->filename = $file_url; $this->productCount = 0; $content = 'Place-Holder File, This file will be replaced next refresh, To manually fill this data, go to manage feeds and click [Update Now]'; file_put_contents($this->filename, $content); $this->logActivity('Updating Feed List'); PFeedActivityLog::updateFeedList($category, $remote_category, $file_name, $file_path, $this->providerName, $this->productCount); //Save the feedlist $id = PFeedActivityLog::feedDataToID($file_name, $this->providerName); $pfcore->settingSet('cpf_aggrfeedlist_' . $id, implode(',', $this->feed_list)); if ($this->productCount == 0) { //$this->message .= '<br>No products returned'; //return; } $this->success = true; }
function initializeAggregateFeed($id, $file_name) { $this->filename = PFeedFolder::uploadFolder() . $this->providerName . '/' . $file_name . '.' . $this->fileformat; $this->file_url = PFeedFolder::uploadURL() . $this->providerName . '/' . $file_name . '.' . $this->fileformat; $this->productCount = 0; $this->file_name_short = $file_name; if (!isset($this->feeds) || count($this->feeds) == 0) { global $pfcore; $data = $pfcore->settingGet('cpf_aggrfeedlist_' . $id); $data = explode(',', $data); $this->feeds = array(); foreach ($data as $datum) { $this->feeds[$datum] = true; } } }
function get_feed_main() { $requestCode = safeGetPostData('provider'); $local_category = safeGetPostData('local_category'); $remote_category = safeGetPostData('remote_category'); $file_name = safeGetPostData('file_name'); $feedIdentifier = safeGetPostData('feed_identifier'); $saved_feed_id = safeGetPostData('feed_id'); $feed_list = safeGetPostData('feed_ids'); //For Aggregate Feed Provider $output = new stdClass(); $output->url = ''; if (strlen($requestCode) * strlen($local_category) == 0) { $output->errors = 'Error: error in AJAX request. Insufficient data or categories supplied.'; doOutput($output); return; } if (strlen($remote_category) == 0) { $output->errors = 'Error: Insufficient data. Please fill in "' . $requestCode . ' category"'; doOutput($output); return; } // Check if form was posted and select task accordingly $dir = PFeedFolder::uploadRoot(); if (!is_writable($dir)) { $output->errors = "Error: {$dir} should be writeable"; doOutput($output); return; } $dir = PFeedFolder::uploadFolder(); if (!is_dir($dir)) { mkdir($dir); } if (!is_writable($dir)) { $output->errors = "Error: {$dir} should be writeable"; doOutput($output); return; } $providerFile = 'feeds/' . strtolower($requestCode) . '/feed.php'; if (!file_exists(dirname(__FILE__) . '/../../' . $providerFile)) { if (!class_exists('P' . $requestCode . 'Feed')) { $output->errors = 'Error: Provider file not found.'; doOutput($output); return; } } $providerFileFull = dirname(__FILE__) . '/../../' . $providerFile; if (file_exists($providerFileFull)) { require_once $providerFileFull; } //Load form data $file_name = sanitize_title_with_dashes($file_name); if ($file_name == '') { $file_name = 'feed' . rand(10, 1000); } $saved_feed = null; if (strlen($saved_feed_id) > 0 && $saved_feed_id > -1) { require_once dirname(__FILE__) . '/../../data/savedfeed.php'; $saved_feed = new PSavedFeed($saved_feed_id); } $providerClass = 'P' . $requestCode . 'Feed'; $x = new $providerClass(); $x->feed_list = $feed_list; //For Aggregate Provider only if (strlen($feedIdentifier) > 0) { $x->activityLogger = new PFeedActivityLog($feedIdentifier); } $x->getFeedData($local_category, $remote_category, $file_name, $saved_feed); if ($x->success) { $output->url = PFeedFolder::uploadURL() . $x->providerName . '/' . $file_name . '.' . $x->fileformat; } $output->errors = $x->getErrorMessages(); doOutput($output); }