mirror of https://github.com/MISP/MISP
new: [widgets] button for link (#6489)
parent
b9eeee4808
commit
5896081f5f
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
class ButtonWidget
|
||||
{
|
||||
public $title = 'Button Widget';
|
||||
public $render = 'Button';
|
||||
public $width = 3;
|
||||
public $height = 2;
|
||||
public $cacheLifetime = false;
|
||||
public $autoRefreshDelay = false;
|
||||
public $params = array(
|
||||
'url' => 'URL (after base url) to redirect to',
|
||||
'text' => 'Text to display on the button'
|
||||
);
|
||||
public $description = 'Simple button to allow shortcuts';
|
||||
public $placeholder =
|
||||
'{
|
||||
"url": "/events/index",
|
||||
"text": "Go to events"
|
||||
}';
|
||||
|
||||
public function handler($user, $options = array())
|
||||
{
|
||||
$data = array();
|
||||
if(isset($options['url'])) {
|
||||
$data['url'] = $options['url'];
|
||||
}
|
||||
if(isset($options['text'])) {
|
||||
$data['text'] = $options['text'];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<div>
|
||||
<?php
|
||||
/*
|
||||
* A simple button to add a link to a specific section
|
||||
*
|
||||
* Expected input:
|
||||
* { url: <relative url>, text: <text to be displayed on the button>}
|
||||
*
|
||||
* Example:
|
||||
* {url: "/events/index", text: "To the list of events"}
|
||||
*
|
||||
*/
|
||||
echo '<a href="'.$baseurl.h($data['url']).'">';
|
||||
echo '<button class="btn btn-primary widget-button">';
|
||||
echo h($data['text']);
|
||||
echo '</button></a>';
|
||||
?>
|
||||
</div>
|
||||
|
||||
<style widget-scoped>
|
||||
.widget-button {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: large;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue