public function sdkLoader() { // Variables $category = []; $cart = []; unset($_SESSION); // Load the SDK $moltin = new \Moltin\SDK\SDK(new \Moltin\SDK\Storage\Session(), new \Moltin\SDK\Request\CURL(), ['url' => isset($this->config['moltin_api_url']) ? $this->config['moltin_api_url'] : null, 'auth_url' => isset($this->config['moltin_api_auth_url']) ? $this->config['moltin_api_auth_url'] : null, 'version' => isset($this->config['moltin_api_version']) ? $this->config['moltin_api_version'] : null]); \Moltin::Authenticate('ClientCredentials', ['client_id' => $this->config['api_client_id'], 'client_secret' => $this->config['api_client_secret']]); try { // Get categories $categories = \Category::Tree(['status' => 1]); } catch (\Exception $e) { exit($e->getMessage()); } try { // Get cart contents $cart = \Cart::Contents()['result']; } catch (\Exception $e) { exit($e->getMessage()); } try { // Get pages $pages = \Entry::Find('page', ['status' => 1])['result']; } catch (\Exception $e) { exit($e->getMessage()); } // add cart to app - so it can be accessed in controllers $this->app->cart = $cart; // Assign to view $this->app->view()->appendData(['categories' => $categories['result'], 'cart' => $cart]); }
public function cache_ping_counts($entry_list) { $ids = array(); foreach ($entry_list as $entry_id) { if (!isset($this->_ping_count_cache[$entry_id])) { $ids[] = $entry_id; $this->_ping_count_cache[$entry_id] = 0; } } if (empty($ids)) { return; } $id_list = implode(",", $ids); if (empty($id_list)) { return; } $where = "entry_id in ({$id_list})"; require_once 'class.mt_entry.php'; $entry = new Entry(); $entries = $entry->Find($where); if (!empty($results)) { foreach ($entries as $e) { $this->_ping_count_cache[$e->id] = $e->ping_count; } } return true; }
protected function get_archive_list_data($args) { $mt = MT::get_instance(); $blog_id = $args['blog_id']; $order = $args['sort_order'] == 'ascend' ? 'asc' : 'desc'; $sql = "\n entry_blog_id = {$blog_id}\n and entry_status = 2\n and entry_class = 'entry'\n order by entry_authored_on {$order}"; $extras = array(); $extras['limit'] = isset($args['lastn']) ? $args['lastn'] : -1; $extras['offset'] = isset($args['offset']) ? $args['offset'] : -1; require_once 'class.mt_entry.php'; $entry = new Entry(); $results = $entry->Find($sql, false, false, $extras); return empty($results) ? null : array($results, null, null); }