Repository Access Links:

This URL has Read-Only access.
Statistics
| Branch: | Revision:

dolibarr-module-template / class / ParsedownDolibarr.php @ ef37f43f

History | View | Annotate | Download (1.5 kB)

1
<?php
2
/*
3
 * Copyright (C) 2016  Rapha?l Doursenaud <rdoursenaud@gpcsolutions.fr>
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18

    
19
/**
20
 * \file    class/ParsedownDolibarr.php
21
 * \ingroup mymodule
22
 * \brief   Custom Parsedown class to display inline images from the README.md in the about page
23
 */
24

    
25
/** Includes */
26
require __DIR__ . '/../vendor/autoload.php';
27

    
28
/**
29
 * Class ParsedownDolibarr
30
 */
31
class ParsedownDolibarr extends Parsedown
32
{
33
    /**
34
     * Resolve inline images relative URLs to the module's path
35
     *
36
     * @param $Excerpt
37
     * @return array|void
38
     */
39
    protected function inlineImage($Excerpt)
40
    {
41
        $image = parent::inlineImage($Excerpt);
42
        $path = new \Enrise\Uri($image['element']['attributes']['src']);
43
        if ($path->isRelative()) {
44
            $image['element']['attributes']['src'] = dol_buildpath('/mymodule/' . $path, 1);
45
        }
46
        return $image;
47
    }
48
}