Repository navigation
Expand file tree
/
Copy pathitems-list.php
More file actions
65 lines (56 loc) · 2.17 KB
/
Copy pathitems-list.php
File metadata and controls
65 lines (56 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
function jotdm_fill_list_page($id, $options, &$db)
{
global $jotdm_ajax_nonce;
$db_fields = jotdm_get_fields_from_table($options['dataTable'], $db);
$order_field = $options['order'] ? $options['orderBy'] : null;
$image_field = $options['image'] ? $options['imageSource'] : null;
$split_field = $options['split'] ? $options['splitBy'] : null;
//$filter = isset($_GET['filter']) ? sanitize_text_field($_GET['filter']) : null;
?>
<div class="wrap" data-id="<?php echo esc_attr($id) ?>" data-name="<?php echo esc_attr($id) ?>">
<?php
foreach ($options['displayColumns'] as $value) {
assert(in_array($value, $db_fields));
}
?>
<h1 class="wp-heading-inline"><?php echo esc_html($options['name']) ?></h1>
<a href=<?php esc_url(menu_page_url('db-edit/' . $id . '-add.php'))?> class="page-title-action">Add New</a>
<form action="admin.php" method="get" >
<p class="search-box">
<input type="hidden" name="page" value="<?php echo esc_attr("db-edit/".$id."-list.php") ?>"/>
<input type="search" name="filter"/>
<input class="button-secondary" type="submit" value="Search"/>
</p>
</form>
<form class="ajax-form">
<input type="hidden" name="security" value="<?php echo $jotdm_ajax_nonce ?>"/>
<div class="tablenav top">
<select name="action">
<option selected value="-1">Bulk Actions</option>
<option value="row_delete">Delete</option>
</select>
<input type="hidden" name="menu-id" value="<?php echo esc_attr($id) ?>"/>
<input class="button-secondary" type="submit" value="Apply" />
</div>
<?php
$sql_str = $options['split'] ?
"SELECT DISTINCT `" . $options['splitBy'] . "` FROM `" . $options['dataTable'] . "`" :
"SELECT * FROM `" . $options['dataTable'] . "` LIMIT 1";
$statement = $db->prepare($sql_str);
$statement->execute();
$statement->setFetchMode(PDO::FETCH_ASSOC);
while ($row = $statement->fetch()) {
echo jotdm_generate_table(
$id,
$options,
$db,
$options['split'] ? $row[$options['splitBy']] : NULL
);
}
?>
</form>
</div>
<?php
}
?>