1 | <?php |
||||
2 | |||||
3 | /* |
||||
4 | * @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps |
||||
5 | * @noinspection AutoloadingIssuesInspection |
||||
6 | */ |
||||
7 | |||||
8 | /** |
||||
9 | * Description action plugin. |
||||
10 | * |
||||
11 | * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
||||
12 | * @author Ikuo Obataya <[email protected]> |
||||
13 | * @author Matthias Schulte <[email protected]>. |
||||
14 | * @author Mark C. Prins <[email protected]> |
||||
15 | * |
||||
16 | */ |
||||
17 | |||||
18 | use dokuwiki\Extension\ActionPlugin; |
||||
1 ignored issue
–
show
|
|||||
19 | use dokuwiki\Extension\Event; |
||||
1 ignored issue
–
show
The type
dokuwiki\Extension\Event was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
20 | use dokuwiki\Extension\EventHandler; |
||||
1 ignored issue
–
show
The type
dokuwiki\Extension\EventHandler was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
21 | |||||
22 | const KEYWORD_SOURCE_ABSTRACT = 'abstract'; |
||||
23 | const KEYWORD_SOURCE_GLOBAL = 'global'; |
||||
24 | const KEYWORD_SOURCE_SYNTAX = 'syntax'; |
||||
25 | |||||
26 | class action_plugin_description extends ActionPlugin |
||||
27 | { |
||||
28 | final public function register(EventHandler $controller): void |
||||
29 | { |
||||
30 | $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'description', []); |
||||
31 | } |
||||
32 | |||||
33 | /** |
||||
34 | * Add an abstract, global value or a specified string to meta header |
||||
35 | */ |
||||
36 | final public function description(Event $event, $param): void |
||||
37 | { |
||||
38 | if (empty($event->data) || empty($event->data['meta'])) { |
||||
39 | return; |
||||
40 | } |
||||
41 | |||||
42 | global $ID; |
||||
43 | $source = $this->getConf('keyword_source'); |
||||
44 | if (empty($source)) { |
||||
45 | $source = 'abstract'; |
||||
46 | } |
||||
47 | |||||
48 | if ($source === KEYWORD_SOURCE_ABSTRACT) { |
||||
49 | if (auth_quickaclcheck($ID) < AUTH_READ) { |
||||
1 ignored issue
–
show
The function
auth_quickaclcheck was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
50 | // don't add meta header when user has no read permissions |
||||
51 | return; |
||||
52 | } |
||||
53 | |||||
54 | $d = p_get_metadata($ID, 'description'); |
||||
1 ignored issue
–
show
The function
p_get_metadata was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
55 | if (empty($d)) { |
||||
56 | return; |
||||
57 | } |
||||
58 | |||||
59 | $a = str_replace("\n", " ", $d['abstract']); |
||||
60 | if (empty($a)) { |
||||
61 | return; |
||||
62 | } |
||||
63 | } |
||||
64 | |||||
65 | if ($source === KEYWORD_SOURCE_GLOBAL) { |
||||
66 | $a = $this->getConf('global_description'); |
||||
67 | if (empty($a)) { |
||||
68 | return; |
||||
69 | } |
||||
70 | } |
||||
71 | |||||
72 | if ($source === KEYWORD_SOURCE_SYNTAX) { |
||||
73 | if (auth_quickaclcheck($ID) < AUTH_READ) { |
||||
74 | // don't add meta header when user has no read permissions |
||||
75 | return; |
||||
76 | } |
||||
77 | $metadata = p_get_metadata($ID); |
||||
78 | $a = $metadata['plugin_description']['keywords']; |
||||
79 | if (empty($a)) { |
||||
80 | return; |
||||
81 | } |
||||
82 | } |
||||
83 | |||||
84 | $m = ["name" => "description", "content" => $a]; |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
85 | $event->data['meta'][] = $m; |
||||
86 | } |
||||
87 | } |
||||
88 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths