MyShaarli/plugins/addlink_toolbar/addlink_toolbar.php

54 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/**
* Plugin addlink_toolbar.
* Adds the addlink input on the linklist page.
*/
2023-05-24 11:35:15 +02:00
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)
{
2023-05-24 11:35:15 +02:00
if ($data['_PAGE_'] == TemplatePage::LINKLIST && $data['_LOGGEDIN_'] === true) {
$form = [
'attr' => [
'method' => 'GET',
2023-05-24 11:35:15 +02:00
'action' => $data['_BASE_PATH_'] . '/admin/shaare',
'name' => 'addform',
'class' => 'addform',
2023-05-24 11:35:15 +02:00
],
'inputs' => [
[
'type' => 'text',
'name' => 'post',
'placeholder' => t('URI'),
2023-05-24 11:35:15 +02:00
],
[
'type' => 'submit',
'value' => t('Add link'),
'class' => 'bigbutton',
2023-05-24 11:35:15 +02:00
],
],
];
$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.');
}