1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace jumper423\decaptcha\core; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class DeCaptchaWikiMain. |
7
|
|
|
*/ |
8
|
|
|
class DeCaptchaWikiMain extends DeCaptchaWiki |
9
|
|
|
{ |
10
|
|
|
protected $classes = []; |
11
|
|
|
|
12
|
|
|
public function __construct($class) |
13
|
|
|
{ |
14
|
|
|
parent::__construct($class); |
15
|
|
|
$this->texts['slug_menu_desc'] = [ |
16
|
|
|
'ru' => 'Описание', |
17
|
|
|
'en' => 'Description', |
18
|
|
|
]; |
19
|
|
|
$this->texts['readme_main_desc'] = [ |
20
|
|
|
'ru' => 'Пакет создан для стандартизации всех сервисов по разгадыванию капч. |
21
|
|
|
У каждого сервиса есть свои особенности и теперь Вам надо будет всего лишь взглянуть на документацию конкретного сервиса чтобы правильно всё сделать. |
22
|
|
|
Так же пакет покрывает всю функциональсть сервисов. Если же Вам будет чего-то нехватать или будут предложения, я буду только рад их услышать.', |
23
|
|
|
'en' => 'Package created to standardize all services for solving captcha. |
24
|
|
|
Each service has its own features and now You will have to look at the documentation for the specific service to do everything right. |
25
|
|
|
The package covers the entire functionality services. If You will be something lacking or suggestions, I\'ll be glad to hear them.', |
26
|
|
|
]; |
27
|
|
|
$this->texts['slug_menu_services'] = [ |
28
|
|
|
'ru' => 'Сервисы', |
29
|
|
|
'en' => 'Services', |
30
|
|
|
]; |
31
|
|
|
$this->texts['readme_main_services'] = [ |
32
|
|
|
'ru' => 'Распознавание капч для всех популярных сервисов', |
33
|
|
|
'en' => 'Recognition captchas for all popular services', |
34
|
|
|
]; |
35
|
|
|
$this->texts['slug_menu_features'] = [ |
36
|
|
|
'ru' => 'Особенности', |
37
|
|
|
'en' => 'Features', |
38
|
|
|
]; |
39
|
|
|
$this->texts['readme_main_features'] = [ |
40
|
|
|
'ru' => [ |
41
|
|
|
'+ Подходит для всех сервисов по распознаванию капч', |
42
|
|
|
'+ Можно легко добавить новый сервис, используя уже готовый движок', |
43
|
|
|
'+ Быстрая и интуительно понятная настройка', |
44
|
|
|
'+ Распознавание как по пути до файла, так и по ссылки', |
45
|
|
|
'+ ReCaptcha v2 без браузера', |
46
|
|
|
'+ Полная документация', |
47
|
|
|
'+ Покрыт тестами', |
48
|
|
|
], |
49
|
|
|
'en' => [ |
50
|
|
|
'+ Suitable for all recognition services captcha', |
51
|
|
|
'+ You can easily add a new service using the existing engine', |
52
|
|
|
'+ Intuitable fast and straightforward setup', |
53
|
|
|
'+ Recognition as the path to the file and links', |
54
|
|
|
'+ ReCaptcha v2 without a browser', |
55
|
|
|
'+ Full documentation', |
56
|
|
|
'+ Covered by tests', |
57
|
|
|
], |
58
|
|
|
]; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function addClass($class) |
62
|
|
|
{ |
63
|
|
|
$this->classes[] = $class; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
protected function viewHeader() |
67
|
|
|
{ |
68
|
|
|
return 'DeCaptcha |
69
|
|
|
================ |
70
|
|
|
[](https://packagist.org/packages/jumper423/decaptcha) |
71
|
|
|
[](https://packagist.org/packages/jumper423/decaptcha) |
72
|
|
|
[](https://packagist.org/packages/jumper423/decaptcha) |
73
|
|
|
|
74
|
|
|
[](https://travis-ci.org/jumper423/decaptcha) |
75
|
|
|
[](https://www.versioneye.com/user/projects/5849f365a662a5004c110a29) |
76
|
|
|
[](https://scrutinizer-ci.com/g/jumper423/decaptcha/?branch=master) |
77
|
|
|
[](https://scrutinizer-ci.com/g/jumper423/decaptcha/build-status/master) |
78
|
|
|
[](https://codeclimate.com/github/jumper423/decaptcha) |
79
|
|
|
[](https://codeclimate.com/github/jumper423/decaptcha) |
80
|
|
|
[](https://codecov.io/gh/jumper423/decaptcha) |
81
|
|
|
[](http://hhvm.h4cc.de/package/jumper423/decaptcha) |
82
|
|
|
[](https://insight.sensiolabs.com/projects/d485629c-1830-440d-82ab-a567bfa5ddc5) |
83
|
|
|
[](https://styleci.io/repos/75013766)'.PHP_EOL; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
protected function viewMenu($master = '') |
87
|
|
|
{ |
88
|
|
|
$str = "+ [{$this->getText(['slug', 'menu', 'another'])}](../{$master}docs/".$this->getFileName($this->lang == 'ru' ? 'en' : 'ru').')'.PHP_EOL; |
89
|
|
|
foreach ([ |
90
|
|
|
['slug', 'menu', 'desc'], |
91
|
|
|
['slug', 'menu', 'features'], |
92
|
|
|
['slug', 'menu', 'services'], |
93
|
|
|
['install'], |
94
|
|
|
['example'], |
95
|
|
|
] as $anchor) { |
96
|
|
|
$str .= "+ [{$this->getText($anchor)}](#".implode('-', explode(' ', ($this->lang === 'en' ? mb_strtolower($this->getText($anchor)) : $this->getText($anchor)))).')'.PHP_EOL; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return $str; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function viewServices($master = '') |
103
|
|
|
{ |
104
|
|
|
$str = ''; |
105
|
|
|
$tt = []; |
106
|
|
|
foreach ($this->classes as $class) { |
107
|
|
|
if (isset($tt[$class->getWiki($this->lang)->getFileName()])) { |
108
|
|
|
continue; |
109
|
|
|
} |
110
|
|
|
$tt[$class->getWiki($this->lang)->getFileName()] = true; |
111
|
|
|
$fromServiceObjectWiki = $class->getWiki($this->lang); |
112
|
|
|
$str .= "+ [{$fromServiceObjectWiki->getText(['service', 'name'])}](../{$master}docs/{$fromServiceObjectWiki->getFileName()})".PHP_EOL; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
return $str; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
public function view($master = '') |
119
|
|
|
{ |
120
|
|
|
$str = $this->viewHeader().PHP_EOL; |
121
|
|
|
|
122
|
|
|
$str .= "{$this->getText(['slug', 'menu'])}".PHP_EOL; |
123
|
|
|
$str .= '--------------'.PHP_EOL; |
124
|
|
|
$str .= $this->viewMenu($master).PHP_EOL.PHP_EOL; |
125
|
|
|
|
126
|
|
|
$str .= "{$this->getText(['slug', 'menu', 'desc'])}".PHP_EOL; |
127
|
|
|
$str .= '--------------'.PHP_EOL; |
128
|
|
|
$str .= $this->getText(['readme', 'main', 'desc']).PHP_EOL.PHP_EOL; |
129
|
|
|
|
130
|
|
|
$str .= "{$this->getText(['slug', 'menu', 'features'])}".PHP_EOL; |
131
|
|
|
$str .= '--------------'.PHP_EOL; |
132
|
|
|
$str .= $this->getText(['readme', 'main', 'features'], PHP_EOL).PHP_EOL.PHP_EOL; |
133
|
|
|
|
134
|
|
|
$str .= "{$this->getText(['slug', 'menu', 'services'])}".PHP_EOL; |
135
|
|
|
$str .= '--------------'.PHP_EOL; |
136
|
|
|
$str .= "{$this->getText(['readme', 'main', 'services'])}".PHP_EOL.PHP_EOL; |
137
|
|
|
$str .= "{$this->viewServices($master)}".PHP_EOL.PHP_EOL; |
138
|
|
|
|
139
|
|
|
$str .= "{$this->getText(['install'])}".PHP_EOL; |
140
|
|
|
$str .= '--------------'.PHP_EOL; |
141
|
|
|
$str .= "{$this->viewInstall()}".PHP_EOL.PHP_EOL; |
142
|
|
|
$str .= "{$this->getText(['example'])}".PHP_EOL; |
143
|
|
|
$str .= '--------------'.PHP_EOL; |
144
|
|
|
$str .= "{$this->viewExamples()}".PHP_EOL.PHP_EOL; |
145
|
|
|
|
146
|
|
|
return $str; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function getFileName($lang = null) |
150
|
|
|
{ |
151
|
|
|
if (is_null($lang)) { |
152
|
|
|
$lang = $this->lang; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
return 'README-'.$lang.'.md'; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function save() |
159
|
|
|
{ |
160
|
|
|
file_put_contents(__DIR__.'/../../docs/'.$this->getFileName(), $this->view()); |
161
|
|
|
file_put_contents(__DIR__.'/../../README.md', $this->view('master/')); |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
|