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 view 28 * https://www.dokuwiki.org/devel:event:indexer_tasks_run 29 * Called on every page write 30 * https://www.dokuwiki.org/devel:event:io_wikipage_write 31 * On update to an existing page this event is called twice, 32 * once for the transfer of the old version to the attic (rev will have a value) 33 * and once to write the new version of the page into the wiki (rev is false) 34 */ 35 if (false) { 36 $controller->register_hook('INDEXER_TASKS_RUN', 'AFTER', $this, 'handle_update_analytics', array()); 37 } 38 } 39 40 public function handle_new_page(Doku_Event $event, $param){ 41 42 global $ID; 43 $page = new Page($ID); 44 $canonical = $page->getCanonical(); 45 $event->data["tpl"] = <<<EOF 46---json 47{ 48 "canonical":"{$canonical}", 49 "title":"A title to show on the Search Engine Result Pages", 50 "description":"A description show on the Search Engine Result Pages" 51} 52--- 53This content was created by the [[https://combostrap.com/frontmatter|frontmatter component]]. 54EOF; 55 56 57 } 58} 59 60 61 62