Plugin Directory

Changeset 1061624


Ignore:
Timestamp:
01/06/2015 08:45:58 PM (11 years ago)
Author:
2kblater.com
Message:

1.1.0

Location:
2kb-amazon-affiliates-store/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • 2kb-amazon-affiliates-store/trunk/KbAmazonController.php

    r993771 r1061624  
    128128        $data = array();
    129129        $importer = new KbAmazonImporter;
    130         if (isset($_POST['search']) && (!empty($_POST['category']) || !empty($_POST['categoryName']))) {
    131             $category = !empty($_POST['categoryName'])
    132                         ? $_POST['categoryName']
    133                         : $importer->getAmazonCategory($_POST['category']);
     130        if (isset($_GET['search']) && (!empty($_GET['category']) || !empty($_GET['categoryName']))) {
     131            $category = !empty($_GET['categoryName'])
     132                        ? $_GET['categoryName']
     133                        : $importer->getAmazonCategory($_GET['category']);
    134134           
    135135            $resultSet = $importer->search(
    136                 $_POST['search'],
    137                 $category
     136                $_GET['search'],
     137                $category,
     138                null,
     139                (isset($_GET['kbpage']) ? $_GET['kbpage'] : null)
    138140            );
    139141 
    140142            if ($resultSet->isValid()) {
     143                $data['resultSet'] = $resultSet;
    141144                $data['items'] = $resultSet->getItems();
    142145                $data['addItemsTemplate'] = $this->getTemplatePath('importItemsWithGallery');
  • 2kb-amazon-affiliates-store/trunk/KbAmazonImporter.php

    r1007437 r1061624  
    369369     * @return \KbAmazonItems
    370370     */
    371     public function search($search, $category, $nodeId = null)
     371    public function search($search, $category, $nodeId = null, $page = null)
    372372    {
    373373        $result = getKbAmazonApi()
    374374                  ->responseGroup('Large')
    375                   ->optionalParameters(array('MerchantId' => 'All'))
     375                  ->optionalParameters(array('MerchantId' => 'All', 'ItemPage' => $page))
    376376                  ->category($category)
    377377                  ->search($search, $nodeId);
     378       
    378379        $this->countAmazonRequest();
    379380        return new KbAmazonItems($result, true);
     
    850851    public function getUrlItems($url)
    851852    {
     853        set_time_limit(90);
    852854        $asins = $this->getUrlAsins($url);
    853855        $items = array();
  • 2kb-amazon-affiliates-store/trunk/lib/KbAmazonItems.php

    r920982 r1061624  
    3535    }
    3636   
     37    public function getTotalResults()
     38    {
     39        return isset($this->result['Items']['TotalResults']) ? $this->result['Items']['TotalResults'] : 0;
     40    }
     41   
     42    public function getTotalPages()
     43    {
     44        return isset($this->result['Items']['TotalPages']) ? $this->result['Items']['TotalPages'] : 0;
     45    }
     46   
    3747    public function getItems()
    3848    {
  • 2kb-amazon-affiliates-store/trunk/plugin.php

    r1040414 r1061624  
    44 * Plugin URI: http://www.2kblater.com/?p=8318
    55 * Description: Amazon Affiliate Store Plugin With Cart, Checkout, Custom Themes. Easy to manage and setup. Sell wide range of physical and digital products imported from Amazon Affiliate API using 90 days cookie reference. This plugin is released with GPL2 license.
    6  * Version: 1.0.10
     6 * Version: 1.1.0
    77 * Author: 2kblater.com
    88 * Author URI: http://www.2kblater.com
     
    1616}
    1717
    18 define('KbAmazonVersion', '1.0.10');
    19 define('KbAmazonVersionNumber', 1010);
     18define('KbAmazonVersion', '1.1.0');
     19define('KbAmazonVersionNumber', 110);
    2020define('KbAmazonStoreFolderName',  pathinfo(dirname(__FILE__), PATHINFO_FILENAME));
    2121define('KbAmazonStorePluginPath',  dirname(__FILE__) . '/');
  • 2kb-amazon-affiliates-store/trunk/query.php

    r920982 r1061624  
    44&& isset($_GET['check'])
    55&& $_GET['check'] == getKbAmz()->getSecret()) {
    6    
     6    set_time_limit(90);
    77    require_once KbAmazonStorePluginPath . 'lib/phpQuery-onefile.php';
    88   
  • 2kb-amazon-affiliates-store/trunk/readme.txt

    r1040414 r1061624  
    33Requires at least: 4.0
    44Tested up to: 4.0
    5 Stable tag: 1.0.10
     5Stable tag: 1.1.0
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3636
    3737== Changelog ==
    38 = 1.0.10 =
    39 isProductAvailable now only checks for new and free products to determine availability
     38= 1.1.0 =
     39Import timeout increased from default 30sec. to 90 sec.
     40Added pagination on the search page.
    4041= 1.0.9 =
    4142kb_amz_list_products shortcode accept short code parameters with php code. Ex. [kb_amz_list_products attribute_value="<? date('Y-m-d', time() - 3600); ?>"].
  • 2kb-amazon-affiliates-store/trunk/store_functions.php

    r1004924 r1061624  
    371371    return implode(array_slice($parts, 0, $last_part));
    372372}
     373
     374function kbAmzBootstrapPagination($count, $perPage)
     375{
     376    $query = $_GET;
     377
     378    $curPage = isset($_GET['kbpage']) ? $_GET['kbpage'] : 1;
     379    $data = array();
     380    if($count){
     381        $pages = ceil($count / $perPage);
     382        if($pages > 1){
     383
     384            $page = $curPage == 1 ? 1 : $curPage - 1;
     385            $query['kbpage'] = $page;
     386            $data[] = \sprintf(
     387                '<li%s><a href="?%s">%s</a></li>' . PHP_EOL,
     388                $curPage == 1 ? ' class="disabled"' : '',
     389                http_build_query($query),
     390                '&laquo;'
     391            );
     392            $query['kbpage'] = 1;
     393            $data[] = \sprintf(
     394                '<li%s><a href="?%s">%s</a></li>' . PHP_EOL,
     395                $curPage == 1 ? ' class="disabled first"' : ' class="first"',
     396                http_build_query($query),
     397                __('First')
     398            );
     399
     400            for($i = 1; $i <= $pages; $i++) {
     401                $canAdd = false;
     402                if ($i >= $curPage - 5 && $i <= $curPage + 5) {
     403                    $canAdd = true;
     404                }
     405
     406                if (!$canAdd) {
     407                    continue;
     408                }
     409               
     410                $query['kbpage'] = $i;
     411                $data[] = \sprintf(
     412                    '<li%s><a href="?%s">%s</a></li>' . PHP_EOL,
     413                    $i == $curPage ? ' class="active"' : '',
     414                     http_build_query($query),
     415                    $i
     416                ); 
     417
     418
     419            }
     420           
     421            $query['kbpage'] = $pages;
     422            $data[] = \sprintf(
     423                '<li%s><a href="?%s">%s</a></li>' . PHP_EOL,
     424                $curPage == $pages ? ' class="disabled last"' : ' class="last"',
     425                http_build_query($query),
     426                __('Last')
     427            );
     428
     429            $page = $curPage == $pages ? $pages : $curPage + 1;
     430            $query['kbpage'] = $page;
     431            $data[] = \sprintf(
     432                '<li%s><a href="?%s">%s</a></li>' . PHP_EOL,
     433                $curPage == $pages ? ' class="disabled"' : '',
     434                http_build_query($query),
     435                '&raquo;'
     436            );
     437        }
     438    }
     439   
     440    if (!empty($data)) {
     441        return \sprintf(
     442            '<ul class="pagination">%s</ul>' . PHP_EOL,
     443            join('', $data)
     444        );
     445    }
     446}
     447
     448function kbAmzHiddenInput()
     449{
     450    if (!empty($_GET)) {
     451        $data = array();
     452        foreach ($_GET as $name => $val) {
     453            $data[] = sprintf(
     454                '<input type="hidden" name="%s" value="%s"/>',
     455                $name,
     456                $val
     457            );
     458        }
     459        return implode(PHP_EOL, $data);
     460    }
     461}
  • 2kb-amazon-affiliates-store/trunk/template/admin/css/default.css

    r1004924 r1061624  
    2727    height: 180px;
    2828    overflow: hidden;
     29    text-align: center;
    2930}
    3031.kb-amz-product-attributes #sortable2 input{
  • 2kb-amazon-affiliates-store/trunk/template/admin/importBySearch.phtml

    r1007437 r1061624  
    1 <form role="form" method="post">
     1<form role="form" method="get">
    22    <div class="alert alert-success">Use Category from the select or write down your own. <a href="http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeIDs.html" target="_blank">Check this link for amazon categories</a></div>
    33    <div class="row">
     
    1313            <div class="form-group">
    1414                <label for="category" class="control-label">
    15                     <?php echo __('Category'); ?>
     15                    <?php echo __('Select Category'); ?>
    1616                </label>
    1717                <select name="category" class="form-control"  value="<?php echo getKbPostVar('category');?>">
     
    2323            <div class="form-group">
    2424                <label for="categoryName" class="control-label">
    25                     <?php echo __('Category Name'); ?>
     25                    <?php echo __('Or Write a Category Name'); ?>
    2626                </label>
    2727                <input type="text" name="categoryName" class="form-control" value="<?php echo getKbPostVar('categoryName');?>" />
     
    3232        <button type="submit" class="btn btn-primary" name="submit" value="load"><?php echo __('Search'); ?></button>
    3333    </div>
     34    <?php echo kbAmzHiddenInput(); ?>
    3435</form>
     36
     37<?php
     38if ($this->resultSet) {
     39    echo '<div class="form-group">';
     40    echo sprintf(
     41        '<span class="label label-default">%s %s %s %s %s</span>',
     42        $this->resultSet->getTotalResults(),
     43        __('Items'),
     44        __('in'),
     45        $this->resultSet->getTotalPages(),
     46        __('Pages')
     47    );
     48    echo sprintf(
     49        '&nbsp;<span class="label label-info">%s</span>',
     50        __('Amazon is allowing to browse up to 10 pages of results.')
     51    );
     52    echo '</div>';
     53}
     54?>
    3555
    3656<?php
  • 2kb-amazon-affiliates-store/trunk/template/admin/importItemsWithGallery.phtml

    r920982 r1061624  
    55    <div class="row kb-amz-url-upload" id="kb-amz-categories-products">
    66        <?php foreach ($this->items as $item): ?>
    7         <label class="col-sm-3 col-md-2">
     7        <label class="col-sm-2 col-md-2">
    88            <div class="thumbnail">
    99                <div class="import-image">
     
    2020        <?php endforeach; ?>
    2121    </div>
     22   
     23    <?php
     24    if ($this->resultSet && $this->resultSet->getTotalResults() > 10) {
     25        $number = $this->resultSet->getTotalResults();
     26        echo kbAmzBootstrapPagination($number, 10);
     27    }
     28    ?>
    2229   
    2330    <div class="row">
  • 2kb-amazon-affiliates-store/trunk/template/admin/layout.phtml

    r920982 r1061624  
    88        <ul class="nav nav-tabs">
    99        <?php
     10            $query = array(
     11                'page' => $_GET['page'],
     12                'kbAction' => $_GET['kbAction']
     13            );
    1014            $i = 0;
    1115            foreach($this->actions as $action):
     
    2125                            '<li class="%s"><a href="?%s">%s</a></li>',
    2226                            $subPageAction ? 'active' : '',
    23                             http_build_query(array_merge($_GET, array('kbAction' => $page['action']))),
     27                            http_build_query(array_merge($query, array('kbAction' => $page['action']))),
    2428                            $page['label']
    2529                        );
     
    4347                        '<li class="%s"><a href="?%s">%s %s</a></li>',
    4448                        $isActive ? 'active' : '',
    45                         http_build_query(array_merge($_GET, array('kbAction' => $action['action']))),
     49                        http_build_query(array_merge($query, array('kbAction' => $action['action']))),
    4650                        (isset($action['icon']) ? '<span class="glyphicon '.$action['icon'].'"></span>' : ''),
    4751                        $action['label']
     
    7579    </div>
    7680</div>
     81<script>
     82    (function ($, params) {
     83        $.each(params, function (name, value) {
     84            $('[name="'+name+'"]').val(value);
     85        });
     86    })(jQuery, <?php echo json_encode($_GET); ?>);
     87</script>
  • 2kb-amazon-affiliates-store/trunk/template/admin/version.phtml

    r1040414 r1061624  
    11<div class="row" id="kb-amz-version">
    22    <div class="col-sm-12">
    3         <h4>1.0.10</h4>
     3        <h4>1.1.0</h4>
    44        <ul style="list-style-type: disc;">
    5             <li>isProductAvailable now only checks for new and free products to determine availability</li>
     5            <li>Import timeout increased from default 30sec. to 90 sec.</li>
     6            <li>Added pagination on the <a href="?page=kbAmz&kbAction=importBySearch">search page</a>.</li>
    67        </ul>
    78        <h4>1.0.9</h4>
Note: See TracChangeset for help on using the changeset viewer.