aboutsummaryrefslogtreecommitdiffhomepage
path: root/plugins/addlink_toolbar/addlink_toolbar.php
blob: 80b1dd95bee836214e1c29f796b1f7a1e37a1721 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php

/**
 * Plugin addlink_toolbar.
 * Adds the addlink input on the linklist page.
 */

use Shaarli\Render\TemplatePage;

/**
 * When linklist is displayed, add play videos to header's toolbar.
 *
 * @param array $data - header data.
 *
 * @return mixed - header data with addlink toolbar item.
 */
function hook_addlink_toolbar_render_header($data)
{
    if ($data['_PAGE_'] == TemplatePage::LINKLIST && $data['_LOGGEDIN_'] === true) {
        $form = [
            'attr' => [
                'method' => 'GET',
                'action' => $data['_BASE_PATH_'] . '/admin/shaare',
                'name'   => 'addform',
                'class'  => 'addform',
            ],
            'inputs' => [
                [
                    'type' => 'text',
                    'name' => 'post',
                    'placeholder' => t('URI'),
                ],
                [
                    'type' => 'submit',
                    'value' => t('Add link'),
                    'class' => 'bigbutton',
                ],
            ],
        ];
        $data['fields_toolbar'][] = $form;
    }

    return $data;
}

/**
 * This function is never called, but contains translation calls for GNU gettext extraction.
 */
function addlink_toolbar_dummy_translation()
{
    // meta
    t('Adds the addlink input on the linklist page.');
}