1 | <?php |
||
2 | /** |
||
3 | * Description action plugin |
||
4 | * |
||
5 | * @lastmodified 2012-07-02 |
||
6 | * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
||
7 | * @author Ikuo Obataya <[email protected]> |
||
8 | * @author Matthias Schulte <[email protected]> |
||
9 | * @version 2012-07-02 |
||
10 | */ |
||
11 | |||
12 | if(!defined('DOKU_INC')) die(); |
||
13 | if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
14 | |||
15 | require_once(DOKU_PLUGIN.'action.php'); |
||
16 | |||
17 | define('KEYWORD_SOURCE_ABSTRACT', 'abstract'); |
||
18 | define('KEYWORD_SOURCE_GLOBAL', 'global'); |
||
19 | define('KEYWORD_SOURCE_SYNTAX', 'syntax'); |
||
20 | |||
21 | class action_plugin_description extends DokuWiki_Action_Plugin { |
||
1 ignored issue
–
show
The type
DokuWiki_Action_Plugin 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 ![]() |
|||
22 | |||
23 | function register(Doku_Event_Handler $controller) { |
||
1 ignored issue
–
show
The type
Doku_Event_Handler 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 ![]() |
|||
24 | $controller->register_hook('TPL_METAHEADER_OUTPUT','BEFORE',$this,'description',array()); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * Add an abstract, global value or a specified string to meta header |
||
29 | */ |
||
30 | function description(&$event, $param) { |
||
0 ignored issues
–
show
|
|||
31 | if(empty($event->data) || empty($event->data['meta'])) return; |
||
32 | |||
33 | global $ID; |
||
34 | $source = $this->getConf('keyword_source'); |
||
35 | if(empty($source)) $source = 'abstract'; |
||
36 | |||
37 | if($source == KEYWORD_SOURCE_ABSTRACT) { |
||
38 | if (auth_quickaclcheck($ID) < AUTH_READ) { |
||
39 | // don't add meta header when user has no read permissions |
||
40 | return; |
||
41 | } |
||
42 | |||
43 | $d = p_get_metadata($ID, 'description'); |
||
44 | if(empty($d)) return; |
||
45 | |||
46 | $a = str_replace("\n", " ", $d['abstract']); |
||
47 | if(empty($a)) return; |
||
48 | } |
||
49 | |||
50 | if($source == KEYWORD_SOURCE_GLOBAL) { |
||
51 | $a = $this->getConf('global_description'); |
||
52 | if(empty($a)) return; |
||
53 | } |
||
54 | |||
55 | if($source == KEYWORD_SOURCE_SYNTAX) { |
||
56 | if (auth_quickaclcheck($ID) < AUTH_READ) { |
||
57 | // don't add meta header when user has no read permissions |
||
58 | return; |
||
59 | } |
||
60 | $metadata = p_get_metadata($ID); |
||
61 | $a = $metadata['plugin_description']['keywords']; |
||
62 | if(empty($a)) return; |
||
63 | } |
||
64 | |||
65 | $m = array("name" => "description", "content" => $a); |
||
66 | $event->data['meta'][] = $m; |
||
67 | } |
||
68 | } |
||
69 |