1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
agent.php
См. документацию.
1<?php
9
13
14Loc::loadMessages(__FILE__);
15
20class Agent extends ClassConstant
21{
22 const UNDEFINED = 0;
23 const GMAIL = 1;
24 const IPHONE = 2;
25 const IPAD = 3;
26 const ANDROID = 4;
27 const OUTLOOK = 5;
28 const THUNDERBIRD = 6;
29 const YANDEX = 7;
30
37 public static function detect($string = null)
38 {
39 if (!$string)
40 {
41 $string = Context::getCurrent()->getRequest()->getUserAgent();
42 }
43
44 $string = mb_strtolower($string);
45 $rules = self::getRules();
46 foreach ($rules as $id => $searchList)
47 {
48 foreach ($searchList as $search)
49 {
50 if (mb_strpos($string, $search) === false)
51 {
52 continue;
53 }
54
55 return $id;
56 }
57 }
58
59 return self::UNDEFINED;
60 }
61
68 public static function getName($id)
69 {
70 $code = self::getCode($id);
71 $name = Loc::getMessage('SENDER_AGENT_CAPTION_' . $code) ?: $code;
72 return $name;
73 }
74
80 protected static function getRules()
81 {
82 $rules = array(
83 self::GMAIL => array('googleimageproxy'),
84 self::IPHONE => array('iphone'),
85 self::IPAD => array('ipad'),
86 self::ANDROID => array('android'),
87 self::OUTLOOK => array('outlook'),
88 self::THUNDERBIRD => array('thunderbird'),
89 self::YANDEX => array('yandex'),
90 );
91
92 return $rules;
93 }
94}
const ANDROID
Определения agent.php:26
const IPAD
Определения agent.php:25
static detect($string=null)
Определения agent.php:37
const IPHONE
Определения agent.php:24
static getName($id)
Определения agent.php:68
const YANDEX
Определения agent.php:29
static getRules()
Определения agent.php:80
const THUNDERBIRD
Определения agent.php:28
const UNDEFINED
Определения agent.php:22
const GMAIL
Определения agent.php:23
const OUTLOOK
Определения agent.php:27
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
$name
Определения menu_edit.php:35
Определения culture.php:9
Определения agent.php:8