'', 'label' => __('Link management'), ], ] ); if (isset($_POST['create'])) { // If create $name = get_parameter_post('name'); $link = get_parameter_post('link'); $result = false; if ($name != '') { $result = db_process_sql_insert('tlink', ['name' => $name, 'link' => $link]); } if (! $result) { ui_print_error_message(__('There was a problem creating link')); } else { $id_link = $result; ui_print_result_message( $id_link, __('Successfully created'), __('Could not be created') ); } } if (isset($_POST['update'])) { // if update $id_link = io_safe_input($_POST['id_link']); $name = io_safe_input($_POST['name']); $link = io_safe_input($_POST['link']); $result = false; if ($name != '') { $result = db_process_sql_update('tlink', ['name' => $name, 'link' => $link], ['id_link' => $id_link]); } if (! $result) { ui_print_error_message(__('There was a problem modifying link')); } else { ui_print_success_message(__('Successfully updated')); } } if (isset($_GET['borrar'])) { // if delete $id_link = io_safe_input($_GET['borrar']); $result = db_process_sql_delete('tlink', ['id_link' => $id_link]); if (! $result) { ui_print_error_message(__('There was a problem deleting link')); } else { ui_print_success_message(__('Successfully deleted')); } } // Main form view for Links edit if ((isset($_GET['form_add'])) or (isset($_GET['form_edit']))) { if (isset($_GET['form_edit'])) { $creation_mode = 0; $id_link = io_safe_input($_GET['id_link']); $row = db_get_row('tlink', 'id_link', $id_link); if ($row !== false) { $nombre = $row['name']; $link = $row['link']; } else { ui_print_error_message(__('Name error')); } } else { // form_add $creation_mode = 1; $nombre = ''; $link = ''; } echo '
'; } else { // Main list view for Links editor. $rows = db_get_all_fields_in_table('tlink', '', '', 'name'); if ($rows === false) { $rows = []; } if (empty($rows)) { ui_print_info_message(['no_close' => true, 'message' => __("There isn't links") ]); } else { echo "".__('Link name').' | '; echo "".__('Delete').' | '; echo '
---|---|
".$row['name'].' | '; echo ''.html_print_image( 'images/delete.svg', true, [ 'class' => 'invert_filter main_menu_icon', 'title' => __('Delete'), ] ).' |
"; echo " |