~yoboy-leguesh/ubuntu-fr-doc/maj20150810a

« back to all changes in this revision

Viewing changes to lib/plugins/tag/action.php

  • Committer: YoBoY
  • Date: 2012-10-24 19:05:18 UTC
  • mfrom: (114.1.3 maj-AdoraBelle)
  • Revision ID: yoboy.leguesh@gmail.com-20121024190518-bgtic5m3dt8gnzfn
Mise à jour de Dokuwiki 2012-10-13 "Adora Belle"
Application des patch ubuntu-fr d'optimisation
Ajout des thèmes ubuntu-fr
Ajout des plugins
Mise à jour des plugins box, orphanswanted, pageredirect, tag, cloud, forcepreview, pagelist
Désactivation de la nouvelle option d'envoie de notifications mail en html
Application des derniers patchs correctifs de Dokuwiki.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
if(!defined('DOKU_INC')) die();
9
9
 
10
10
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11
 
require_once(DOKU_PLUGIN.'action.php');
12
11
 
 
12
/**
 
13
 * Action part of the tag plugin, handles tag display, technorati ping and index updates
 
14
 */
13
15
class action_plugin_tag extends DokuWiki_Action_Plugin {
14
16
 
15
17
    /**
16
 
     * return some info
17
 
     */
18
 
    function getInfo() {
19
 
        return array(
20
 
                'author' => 'Gina Häußge, Michael Klier, Esther Brunner',
21
 
                'email'  => 'dokuwiki@chimeric.de',
22
 
                'date'   => '2011-03-20',
23
 
                'name'   => 'Tag Plugin (ping component)',
24
 
                'desc'   => 'Ping technorati when a new page is created',
25
 
                'url'    => 'http://www.dokuwiki.org/plugin:tag',
26
 
                );
27
 
    }
28
 
 
29
 
    /**
30
18
     * register the eventhandlers
 
19
     *
 
20
     * @param Doku_Event_Handler $contr
31
21
     */
32
22
    function register(&$contr) {
33
23
        $contr->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'ping', array());
44
34
     * whenever the stored data format changes.
45
35
     */
46
36
    function _indexer_version($event, $param) {
47
 
        $event->data['plugin_tag'] = '0.1';
 
37
        global $conf;
 
38
        $event->data['plugin_tag'] = '0.2.deaccent='.$conf['deaccent'];
48
39
    }
49
40
 
50
41
    /**
51
42
     * Add all data of the subject metadata to the metadata index.
52
43
     */
53
44
    function _indexer_index_tags($event, $param) {
54
 
        $event->data['metadata']['subject'] = p_get_metadata($event->data['page'], 'subject');
 
45
        /* @var helper_plugin_tag $helper */
 
46
        if ($helper =& plugin_load('helper', 'tag')) {
 
47
            // make sure the tags are cleaned and no duplicate tags are added to the index
 
48
            $tags = p_get_metadata($event->data['page'], 'subject');
 
49
            if (!is_array($tags)) {
 
50
                $event->data['metadata']['subject'] = array();
 
51
            } else {
 
52
                $event->data['metadata']['subject'] = $helper->_cleanTagList($tags);
 
53
            }
 
54
        }
55
55
    }
56
56
 
57
57
    /**
91
91
     *
92
92
     * @author Michael Klier <chi@chimeric.de>
93
93
     */
94
 
    function _handle_act(&$event, $param) {
 
94
    function _handle_act(Doku_Event &$event, $param) {
95
95
        if($event->data != 'showtag') return;
96
96
        $event->preventDefault();
97
97
    }
98
98
 
99
 
    function _handle_tpl_act(&$event, $param) {
 
99
    /**
 
100
     * Display the tag page
 
101
     *
 
102
     * @param Doku_Event $event The TPL_ACT_UNKNOWN event
 
103
     * @param array      $param optional parameters (unused)
 
104
     */
 
105
    function _handle_tpl_act(Doku_Event &$event, $param) {
100
106
        global $lang;
101
107
 
102
108
        if($event->data != 'showtag') return;
108
114
        $tag   = trim(str_replace($this->getConf('namespace').':', '', $_REQUEST['tag']));
109
115
        $ns    = trim($_REQUEST['ns']);
110
116
 
 
117
        /* @var helper_plugin_tag $helper */
111
118
        if ($helper =& plugin_load('helper', 'tag')) $pages = $helper->getTopic($ns, '', $tag);
112
119
 
113
120
        if(!empty($pages)) {
115
122
            // let Pagelist Plugin do the work for us
116
123
            if (plugin_isdisabled('pagelist') || (!$pagelist = plugin_load('helper', 'pagelist'))) {
117
124
                msg($this->getLang('missing_pagelistplugin'), -1);
118
 
                return false;
 
125
                return;
119
126
            }
120
127
 
 
128
            /* @var helper_plugin_pagelist $pagelist */
121
129
            $pagelist->setFlags($flags);
122
130
            $pagelist->startList();
123
131
            foreach ($pages as $page) {
137
145
        /**
138
146
         * Inserts the tag toolbar button
139
147
         */
140
 
        function insert_toolbar_button(&$event, $param) {
 
148
        function insert_toolbar_button(Doku_Event &$event, $param) {
141
149
            $event->data[] = array (
142
150
                'type' => 'format',
143
151
                'title' => $this->getLang('toolbar_icon'),
150
158
        /**
151
159
         * Prevent displaying underscores instead of blanks inside the page keywords
152
160
         */
153
 
        function _handle_keywords(&$data) {
 
161
        function _handle_keywords(Doku_Event &$event) {
154
162
            global $ID;
155
163
 
156
164
            // Fetch tags for the page; stop proceeding when no tags specified
158
166
            if(is_null($tags)) true;
159
167
 
160
168
            // Replace underscores with blanks
161
 
            foreach($data->data['meta'] as &$meta) {
 
169
            foreach($event->data['meta'] as &$meta) {
162
170
                if($meta['name'] == 'keywords') {
163
171
                    $meta['content'] = str_replace('_', ' ', $meta['content']);
164
172
                }