mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Documentation, formatting (#7630)
* Documentation, formatting * Updated formatting to remove alignment * Updated spacing in the quoted script
This commit is contained in:
@@ -24,18 +24,34 @@
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate pagination links and controls.
|
||||
*
|
||||
* @param int $num_rows Total number of rows.
|
||||
* @param string $param URL parameters to sanitize.
|
||||
* @param int $rows_per_page Number of rows per page.
|
||||
* @param bool $mini Whether to display mini pagination (default: false).
|
||||
* @param int $result_count Result count for last page handling.
|
||||
*
|
||||
* @return array Array containing pagination links and controls.
|
||||
*/
|
||||
function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count = 0) {
|
||||
|
||||
//validate the data
|
||||
if (!is_numeric($num_rows)) { $num_rows = 0; }
|
||||
if (!is_numeric($rows_per_page)) { $rows_per_page = 100; }
|
||||
if (!is_numeric($result_count)) { $result_count = 0; }
|
||||
if (!is_numeric($num_rows)) {
|
||||
$num_rows = 0;
|
||||
}
|
||||
if (!is_numeric($rows_per_page)) {
|
||||
$rows_per_page = 100;
|
||||
}
|
||||
if (!is_numeric($result_count)) {
|
||||
$result_count = 0;
|
||||
}
|
||||
|
||||
// if $_get['page'] defined, use it as page number
|
||||
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
|
||||
$page_number = $_GET['page'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$page_number = 0;
|
||||
}
|
||||
|
||||
@@ -51,8 +67,7 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
if ($key === 'order_by' && !empty($value)) {
|
||||
//validate order by
|
||||
$sanitized_parameters .= "&order_by=" . preg_replace('#[^a-zA-Z0-9_\-]#', '', $value);
|
||||
}
|
||||
else if ($key == 'order' && !empty($value)) {
|
||||
} elseif ($key == 'order' && !empty($value)) {
|
||||
//validate order
|
||||
switch ($value) {
|
||||
case 'asc':
|
||||
@@ -62,11 +77,9 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
$sanitized_parameters .= "&order=desc";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!empty($value) && is_numeric($value)) {
|
||||
} elseif (!empty($value) && is_numeric($value)) {
|
||||
$sanitized_parameters .= "&" . $key . "=" . $value;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sanitized_parameters .= "&" . $key . "=" . urlencode($value ?? '');
|
||||
}
|
||||
}
|
||||
@@ -76,8 +89,7 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
//how many pages we have when using paging
|
||||
if ($num_rows > 0) {
|
||||
$max_page = ceil($num_rows / $rows_per_page);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$max_page = 1;
|
||||
}
|
||||
|
||||
@@ -91,8 +103,7 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
for ($page = 1; $page <= $max_page; $page++) {
|
||||
if ($page == $page_number) {
|
||||
$nav .= " $page "; // no need to create a link to current page
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$nav .= " <a href='" . $self . "?page=" . $page . "'>" . $page . "</a> \n";
|
||||
}
|
||||
}
|
||||
@@ -101,8 +112,7 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
$page = $page_number - 1;
|
||||
$prev = button::create(['type' => 'button', 'label' => $text['button-back'], 'icon' => 'chevron-left', 'link' => $self . "?page=" . $page . $sanitized_parameters, 'title' => $text['label-page'] . ' ' . ($page + 1)]);
|
||||
$first = button::create(['type' => 'button', 'label' => $text['button-next'], 'icon' => 'chevron-left', 'link' => $self . "?page=1" . $sanitized_parameters]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$prev = button::create(['type' => 'button', 'label' => $text['button-back'], 'icon' => 'chevron-left', 'onclick' => "return false;", 'title' => '', 'style' => 'opacity: 0.4; -moz-opacity: 0.4; cursor: default;']);
|
||||
}
|
||||
|
||||
@@ -110,8 +120,7 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
$page = $page_number + 1;
|
||||
$next = button::create(['type' => 'button', 'label' => $text['button-next'], 'icon' => 'chevron-right', 'link' => $self . "?page=" . $page . $sanitized_parameters, 'title' => $text['label-page'] . ' ' . ($page + 1)]);
|
||||
$last = button::create(['type' => 'button', 'label' => $text['button-back'], 'icon' => 'chevron-right', 'link' => $self . "?page=" . $max_page . $sanitized_parameters]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$last = button::create(['type' => 'button', 'label' => $text['button-next'], 'icon' => 'chevron-right', 'link' => $self . "?page=" . $max_page . $sanitized_parameters]);
|
||||
$next = button::create(['type' => 'button', 'label' => $text['button-next'], 'icon' => 'chevron-right', 'onclick' => "return false;", 'title' => '', 'style' => 'opacity: 0.4; -moz-opacity: 0.4; cursor: default;']);
|
||||
}
|
||||
@@ -121,7 +130,7 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
$next = button::create(['type' => 'button', 'label' => (!$mini ? $text['button-next'] : null), 'icon' => 'chevron-right', 'onclick' => "return false;", 'title' => '', 'style' => 'opacity: 0.4; -moz-opacity: 0.4; cursor: default;']);
|
||||
}
|
||||
|
||||
$array = array();
|
||||
$array = [];
|
||||
$code = '';
|
||||
if ($max_page > 1) {
|
||||
//define javascript to include
|
||||
@@ -154,7 +163,7 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
" }\n" .
|
||||
|
||||
" if (do_action) {\n" .
|
||||
"// action to peform when enter is hit\n".
|
||||
" // action to perform when enter is hit\n" .
|
||||
" if (page_num < 1) { page_num = 1; }\n" .
|
||||
" if (page_num > " . $max_page . ") { page_num = " . $max_page . "; }\n" .
|
||||
" document.location.href = '" . $self . "?page='+(--page_num)+'" . $sanitized_parameters . "';\n" .
|
||||
@@ -165,8 +174,7 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
//determine size
|
||||
if ($mini) {
|
||||
$code = "<span style='white-space: nowrap;'>" . $prev . $next . "</span>\n" . $script;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$code .= "<center style='white-space: nowrap;'>";
|
||||
$code .= " " . $prev;
|
||||
$code .= " ";
|
||||
@@ -181,8 +189,7 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
|
||||
//add to array
|
||||
$array[] = $code;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$array[] = "";
|
||||
}
|
||||
$array[] = $rows_per_page;
|
||||
@@ -190,5 +197,3 @@ function paging($num_rows, $param, $rows_per_page, $mini = false, $result_count
|
||||
return $array;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user