|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Modules\Extend\Utils\Handler { |
|
4
|
|
|
|
|
5
|
|
|
use Modules\Extend, Modules\Informer, Ajax, Arr, Language, Request, Template; |
|
6
|
|
|
|
|
7
|
|
|
abstract class Addons extends Extend\Utils\Handler { |
|
8
|
|
|
|
|
9
|
|
|
# Process item |
|
10
|
|
|
|
|
11
|
|
|
protected function processItem(Template\Block $item, array $data) { |
|
12
|
|
|
|
|
13
|
|
|
$browsable = ($data['installed'] && ('' !== $data['browse_url'])); |
|
14
|
|
|
|
|
15
|
|
|
$item->getBlock('browse')->class = ($browsable ? 'primary' : 'disabled'); |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
$item->getBlock('browse')->link = $data['browse_url']; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
$item->getBlock($data['installed'] ? 'install' : 'uninstall')->disable(); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
# Process contents |
|
23
|
|
|
|
|
24
|
|
|
protected function processContents(Template\Block $contents) {} |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
# Handle ajax request |
|
27
|
|
|
|
|
28
|
|
|
protected function handleAjax() { |
|
29
|
|
|
|
|
30
|
|
|
$ajax = Ajax::createResponse(); |
|
31
|
|
|
|
|
32
|
|
|
# Process actions |
|
33
|
|
|
|
|
34
|
|
|
if (Request::post('action') === 'install') { |
|
35
|
|
|
|
|
36
|
|
|
$name = Request::post('name'); |
|
37
|
|
|
|
|
38
|
|
|
if (!$this->loader->install($name, true)) return $ajax->setError(Language::get(static::$error_install)); |
|
39
|
|
|
|
|
40
|
|
|
} else if (Request::post('action') === 'uninstall') { |
|
41
|
|
|
|
|
42
|
|
|
$name = Request::post('name'); |
|
43
|
|
|
|
|
44
|
|
|
if (!$this->loader->install($name, false)) return $ajax->setError(Language::get(static::$error_uninstall)); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
# ------------------------ |
|
48
|
|
|
|
|
49
|
|
|
return $ajax; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
# Handle common request |
|
53
|
|
|
|
|
54
|
|
|
public function handle() { |
|
55
|
|
|
|
|
56
|
|
|
$this->loader = new static::$loader_class; |
|
57
|
|
|
|
|
58
|
|
|
if (Request::isAjax()) return $this->handleAjax(); |
|
59
|
|
|
|
|
60
|
|
|
# ------------------------ |
|
61
|
|
|
|
|
62
|
|
|
return $this->getContents(); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.