xref: /template/strap/action/analytics.php (revision e06795b827169c10ddd5ff1b09798a0da1d963f3)
1<?php
2
3use ComboStrap\Page;
4
5/**
6 * Copyright (c) 2021. ComboStrap, Inc. and its affiliates. All Rights Reserved.
7 *
8 * This source code is licensed under the GPL license found in the
9 * COPYING  file in the root directory of this source tree.
10 *
11 * @license  GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html)
12 * @author   ComboStrap <support@combostrap.com>
13 *
14 */
15
16/**
17 * Class action_plugin_combo_analytics
18 * Update the analytics data
19 */
20class action_plugin_combo_analytics extends DokuWiki_Action_Plugin
21{
22
23
24    public function register(Doku_Event_Handler $controller)
25    {
26        /**
27         * Called on every page write
28         * https://www.dokuwiki.org/devel:event:io_wikipage_write
29         * On update to an existing page this event is called twice,
30         * once for the transfer of the old version to the attic (rev will have a value)
31         * and once to write the new version of the page into the wiki (rev is false)
32         */
33        if (false) {
34            $controller->register_hook('INDEXER_TASKS_RUN', 'AFTER', $this, 'handle_update_analytics', array());
35        }
36    }
37
38    public function handle_new_page(Doku_Event $event, $param){
39
40        global $ID;
41        $page = new Page($ID);
42        $canonical = $page->getCanonical();
43        $event->data["tpl"] = <<<EOF
44---json
45{
46    "canonical":"{$canonical}",
47    "title":"A title to show on the Search Engine Result Pages",
48    "description":"A description show on the Search Engine Result Pages"
49}
50---
51This content was created by the [[https://combostrap.com/frontmatter|frontmatter component]].
52EOF;
53
54
55    }
56}
57
58
59
60