Working in the refactoring the code of reports (url).
This commit is contained in:
parent
bc791ad3be
commit
958b9c8ce3
|
@ -173,12 +173,52 @@ function reporting_make_reporting_data($id_report, $date, $time,
|
|||
$report,
|
||||
$content);
|
||||
break;
|
||||
case 'url':
|
||||
$report['contents'][] = reporting_url(
|
||||
$report,
|
||||
$content,
|
||||
$type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return reporting_check_structure_report($report);
|
||||
}
|
||||
|
||||
function reporting_url($report, $content, $type = 'dinamic') {
|
||||
global $config;
|
||||
|
||||
$return = array();
|
||||
$return['type'] = 'url';
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('Url');
|
||||
}
|
||||
|
||||
$return['title'] = $content['name'];
|
||||
$return["description"] = $content["description"];
|
||||
$return["date"] = reporting_get_date_text();
|
||||
|
||||
$return["url"] = $content["external_source"];
|
||||
|
||||
switch ($type) {
|
||||
case 'dinamic':
|
||||
$return["data"] = null;
|
||||
break;
|
||||
case 'data':
|
||||
case 'static':
|
||||
$curlObj = curl_init();
|
||||
curl_setopt($curlObj, CURLOPT_URL, $content['external_source']);
|
||||
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($curlObj);
|
||||
curl_close($curlObj);
|
||||
$return["data"] = $output;
|
||||
break;
|
||||
}
|
||||
|
||||
return reporting_check_structure_content($return);
|
||||
}
|
||||
|
||||
function reporting_text($report, $content) {
|
||||
|
||||
global $config;
|
||||
|
|
|
@ -97,7 +97,7 @@ function reporting_html_header(&$table, $mini, $title, $subtitle,
|
|||
|
||||
function reporting_html_print_report($report, $mini = false) {
|
||||
|
||||
foreach ($report['contents'] as $item) {
|
||||
foreach ($report['contents'] as $key => $item) {
|
||||
$table->size = array ();
|
||||
$table->style = array ();
|
||||
$table->width = '98%';
|
||||
|
@ -140,6 +140,9 @@ function reporting_html_print_report($report, $mini = false) {
|
|||
case 'text':
|
||||
reporting_html_text($table, $item);
|
||||
break;
|
||||
case 'url':
|
||||
reporting_html_url($table, $item, $key);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($item['type'] == 'agent_module')
|
||||
|
@ -152,6 +155,21 @@ function reporting_html_print_report($report, $mini = false) {
|
|||
}
|
||||
}
|
||||
|
||||
function reporting_html_url(&$table, $item, $key) {
|
||||
$table->colspan['data']['cell'] = 3;
|
||||
$table->cellstyle['data']['cell'] = 'text-align: left;';
|
||||
$table->data['data']['cell'] = '
|
||||
<iframe id="item_' . $key . '" src ="' . $item["url"] . '" width="100%" height="100%">
|
||||
</iframe>';
|
||||
// TODO: make this dynamic and get the height if the iframe to resize this item
|
||||
$table->data['data']['cell'] .= '
|
||||
<script type="text/javascript">
|
||||
$(document).ready (function () {
|
||||
$("#item_' . $key . '").height(500);
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
|
||||
function reporting_html_text(&$table, $item) {
|
||||
$table->colspan['data']['cell'] = 3;
|
||||
$table->cellstyle['data']['cell'] = 'text-align: left;';
|
||||
|
@ -4356,34 +4374,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
$data[0] = reporting_alert_reporting_agent ($content['id_agent'], $content['period'], $report["datetime"], true);
|
||||
array_push ($table->data, $data);
|
||||
break;
|
||||
case 'url':
|
||||
if (empty($item_title)) {
|
||||
$item_title = __('Import text from URL');
|
||||
}
|
||||
reporting_header_content($mini, $content, $report, $table, $item_title,
|
||||
ui_print_truncate_text($content["external_source"], 'description', false));
|
||||
|
||||
$next_row = 1;
|
||||
// Put description at the end of the module (if exists)
|
||||
if ($content["description"] != "") {
|
||||
$data_desc = array();
|
||||
$data_desc[0] = $content["description"];
|
||||
array_push ($table->data, $data_desc);
|
||||
$table->colspan[$next_row][0] = 3;
|
||||
$next_row++;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$table->colspan[$next_row][0] = 3;
|
||||
$data[0] = '<iframe id="item_' . $content['id_rc'] . '" src ="' . $content["external_source"] . '" width="100%" height="100%"></iframe>';
|
||||
// TODO: make this dynamic and get the height if the iframe to resize this item
|
||||
$data[0] .= '<script>
|
||||
$(document).ready (function () {
|
||||
$("#item_' . $content['id_rc'] . '").height(500);
|
||||
});</script>';
|
||||
|
||||
array_push ($table->data, $data);
|
||||
break;
|
||||
|
||||
case 'database_serialized':
|
||||
if (empty($item_title)) {
|
||||
$item_title = __('Serialize data');
|
||||
|
|
Loading…
Reference in New Issue