Passed
Push — master ( 7e6133...d39861 )
by Alexey
11:48
created

showOptions.php ➔ sortDirectionIcon()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 3
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
$query = $_GET;
3
$path = Controller::$cur->method != 'itemList' ? '/ecommerce/itemList' : '';
4
$limit = !empty(App::$cur->Ecommerce->config['default_limit']) ? App::$cur->Ecommerce->config['default_limit'] : 18;
5
6
function sortDirectionIcon($type) {
7
    if (!empty($_GET['sort'][$type])) {
8
        return ' <small class = "glyphicon glyphicon-triangle-' . ($_GET['sort'][$type] == 'asc' ? 'top' : 'bottom') . '"></small>';
9
    }
10
}
11
?>
12
<div class="ecommerce-showoptions">
13
    <div class="row">
14
        <div class="col-xs-6 ecommerce-showoptions-sort">
15
            <span class="caption">Сортировка:</span>
16
            <a href="<?= $path; ?>?<?= http_build_query(array_merge($query, ['sort' => ['price' => 'asc']])); ?>">По цене<?=sortDirectionIcon('price');?></a> 
17
            <a href="<?= $path; ?>?<?= http_build_query(array_merge($query, ['sort' => ['sales' => 'desc']])); ?>">По популярности<?=sortDirectionIcon('sales');?></a>
18
        </div>
19
        <div class="col-xs-6 text-right ecommerce-showoptions-view">
20
            <span class="caption">Вид:</span>
21
            <span class="group">
22
              <?php
23
              for ($i = 2; $i < 5; $i++) {
24
                  $curLimit = $limit * $i;
25
                  $curQuery = http_build_query(array_merge($query, ['limit' => $curLimit]));
26
                  echo " <a href='{$path}?{$curQuery}'>{$curLimit}</a> ";
27
              }
28
              ?>
29
            </span>
30
            <span class="group">
31
                <a href ='#' onclick="inji.onLoad(function () {
32
                        $('.items-icons').show();
33
                        $('.items-table').hide();
34
                      });
35
                      return false;" class="glyphicon glyphicon-th-large"></a>
36
                <a href ='#' onclick="inji.onLoad(function () {
37
                        $('.items-table').show();
38
                        $('.items-icons').hide();
39
                      });
40
                      return false;" class="glyphicon glyphicon-th-list"></a>
41
            </span>
42
        </div>
43
    </div>
44
</div>