Blame view

frontend/modules/map/Map.php 1.59 KB
d1f8bd40   Alexey Boroda   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  <?php
  
  namespace frontend\modules\map;
  
  
  use Yii;
  use yii\helpers\ArrayHelper;
  use yii\helpers\Url;
  
  /**
   * Class Library
   *
   * @package frontend\modules\map
   * @author Alla Kuzmenko
   * @copyright (c) 2017
   */
  class Map extends \common\modules\map\Map
  {
      /**
       * Number of elements in list
       * @var int
       */
      public $itemOnPage = 30;
  
      /**
       * @param $type
       * @return string
       */
      public static function getUrlListByType($type)
      {
          return Url::toRoute(["/map/list/map", 'type' => $type]);
      }
  
      /**
       * @param $file_name
       * @return null|string
       */
      public static function getImageLink($file_name)
      {
          $module = Yii::$app->getModule('map');;
          $path = $module->getItemUploadPath();
          $url = $module->getItemUploadUrl();
  
          return (!empty($file_name) && is_file($path . '/' . $file_name))
              ? $url . '/' . $file_name
              : null;
      }
  
      /**
       * @param $alias
       * @return null|string
       */
      /**
       * @param bool|false $scheme
       * @return string
       */
      public static function getItemUrl($alias, $scheme = false)
      {
          return Url::toRoute(['/map/item/view', 'alias' => $alias], $scheme);
      }
  
      /**
       * @param $params
       * @return string
       */
      public static function getUrlList($params = [])
      {
          return Url::toRoute(ArrayHelper::merge(['/map/list/list'], $params));
      }
  
      /**
       * @param $type
       * @return string
       */
      public static function getUrlTypeObjectListPage($type)
      {
          return Url::toRoute(['/map/list/type', 'type' => $type]);
      }
  
  }