summaryrefslogtreecommitdiffstats
path: root/usr/local/www
diff options
context:
space:
mode:
Diffstat (limited to 'usr/local/www')
-rwxr-xr-xusr/local/www/pkg.php256
1 files changed, 191 insertions, 65 deletions
diff --git a/usr/local/www/pkg.php b/usr/local/www/pkg.php
index 24651d4..c71fde1 100755
--- a/usr/local/www/pkg.php
+++ b/usr/local/www/pkg.php
@@ -45,7 +45,7 @@ function gentitle_pkg($pgname) {
return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
}
-$xml = htmlspecialchars($_GET['xml']);
+$xml = htmlspecialchars($_REQUEST['xml']);
if($xml == "") {
print_info_box_np(gettext("ERROR: No package defined."));
@@ -67,6 +67,9 @@ $section = $pkg['menu'][0]['section'];
$config_path = $pkg['configpath'];
$title = $pkg['title'];
+if($_REQUEST['startdisplayingat'])
+ $startdisplayingat = $_REQUEST['startdisplayingat'];
+
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
if ($_GET['act'] == "del") {
@@ -113,7 +116,8 @@ include("head.inc");
<?php
include("fbegin.inc");
?>
-<form action="pkg.php" method="post">
+<form action="pkg.php" name='pkgform' method="post">
+<input type='hidden' name='xml' value='<?=$_REQUEST['xml']?>'>
<? if($_GET['savemsg'] <> "") $savemsg = htmlspecialchars($_GET['savemsg']); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
@@ -144,72 +148,187 @@ if ($pkg['tabs'] <> "") {
echo '</td></tr>';
}
?>
+<script>
+ function setFilter(filtertext) {
+ $('pkg_filter').value = '^' + filtertext + '.*$';
+ document.pkgform.submit();
+ }
+</script>
<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <?php
- $cols = 0;
- if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
- foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
- echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
- $cols++;
- }
- }
- echo "</tr>";
- $i=0;
- if($evaledvar)
- foreach ($evaledvar as $ip) {
- echo "<tr valign=\"top\">\n";
- if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
- foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
- ?>
- <td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
- <?php
- $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
- if($column['type'] == "checkbox") {
- if($fieldname == "") {
- echo gettext("No");
- } else {
- echo gettext("Yes");
+ <tr>
+ <td class="tabcont">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+<?php
+ /* Handle sorting bar A-Z and filtering */
+ $include_filtering_inputbox = false;
+ $colspan = 0;
+ if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column)
+ $colspan++;
+ }
+ if($pkg['fields']['field']) {
+ // First find the sorting type field if it exists
+ foreach($pkg['fields']['field'] as $field) {
+ if($field['type'] == "sorting") {
+ if(isset($field['include_filtering_inputbox']))
+ $include_filtering_inputbox = true;
+ if($field['display_maximum_rows'])
+ $display_maximum_rows = $field['display_maximum_rows'];
+ echo "<tr><td class='listhdrr' colspan='$colspan'><center>";
+ echo "Sorting: ";
+ $isfirst = true;
+ for($char = 65; $char < 91; $char++) {
+ if(!$isfirst)
+ echo " | ";
+ echo "<a href=\"#\" onClick=\"setFilter('" . chr($char) . "');\">" . chr($char) . "</a>";
+ $isfirst = false;
}
- } else if ($column['type'] == "interface") {
- echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
- } else {
- echo $column['prefix'] . $fieldname . $column['suffix'];
- }
- ?>
- </td>
- <?php
+ echo "</td></tr>";
+ echo "<tr><td class='listhdrr' colspan='$colspan'><center>";
+ if($field['sortablefields']) {
+ echo "Filter by: <select name='pkg_filter_type'>";
+ foreach($field['sortablefields']['item'] as $si) {
+ if($si['name'] == $_REQUEST['pkg_filter_type'])
+ $SELECTED = "SELECTED";
+ else
+ $SELECTED = "";
+ echo "<option value='{$si['name']}' {$SELECTED}>{$si['name']}</option>";
+ }
+ echo "</select>";
+ }
+ if($include_filtering_inputbox)
+ echo "&nbsp;&nbsp;Filter text: <input id='pkg_filter' name='pkg_filter' value='" . $_REQUEST['pkg_filter'] . "'> <input type='submit' value='Filter'>";
+ echo "</td></tr><tr><td>&nbsp;</td></tr>";
+ }
+ }
+ }
+?>
+ <tr>
+<?php
+ $cols = 0;
+ if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
+ echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
+ $cols++;
+ }
+ }
+ echo "</tr>";
+ $i=0;
+ $pagination_startingrow=0;
+ $pagination_counter=0;
+ if($evaledvar)
+ foreach ($evaledvar as $ip) {
+ if($startdisplayingat) {
+ if($i < $startdisplayingat) {
+ $i++;
+ continue;
+ }
+ }
+ if($_REQUEST['pkg_filter']) {
+ // Handle filterered items
+ if($pkg['fields']['field'] && !$filter_regex) {
+ // First find the sorting type field if it exists
+ foreach($pkg['fields']['field'] as $field) {
+ if($field['type'] == "sorting") {
+ if($field['sortablefields']['item']) {
+ foreach($field['sortablefields']['item'] as $sf) {
+ if($sf['name'] == $_REQUEST['pkg_filter_type']) {
+ $filter_fieldname = $sf['fieldname'];
+ $filter_regex = str_replace("%FILTERTEXT%", $_REQUEST['pkg_filter'], trim($sf['regex']));
+ }
+ }
+ }
+ }
+ }
+ }
+ // Do we have something to filter on?
+ unset($filter_matches);
+ if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
+ $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
+ if($column['fieldname'] == $filter_fieldname) {
+ if($filter_regex) {
+ //echo "$filter_regex - $fieldname<p/>";
+ preg_match($filter_regex, $fieldname, $filter_matches);
+ break;
+ }
+ }
+ }
+ }
+ if(!$filter_matches) {
+ $i++;
+ continue;
+ }
+ }
+ echo "<tr valign=\"top\">\n";
+ if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
+ foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
+?>
+ <td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
+ <?php
+ $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
+ if($column['type'] == "checkbox") {
+ if($fieldname == "") {
+ echo gettext("No");
+ } else {
+ echo gettext("Yes");
+ }
+ } else if ($column['type'] == "interface") {
+ echo $column['prefix'] . $iflist[$fieldname] . $column['suffix'];
+ } else {
+ echo $column['prefix'] . $fieldname . $column['suffix'];
+ }
+ ?>
+ </td>
+<?php
+ }
+?>
+ <td valign="middle" class="list" nowrap>
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td valign="middle"><a href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this item?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+<?php
+ echo "</tr>\n";
+ // Handle pagination and display_maximum_rows
+ if($display_maximum_rows) {
+ if($pagination_counter == $display_maximum_rows) {
+ $nbsp = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
+ echo "<tr><td colspan='$colspan'><center>";
+ $startingat = $startdisplayingat - $display_maximum_rows;
+ if($startingat > -1) {
+ echo "<font size='2'><a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat={$startingat}'><< Previous page</a>";
+ } else {
+ if($startingnat > 1)
+ echo "<font size='2'><a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=0'><< Previous page</a>{$nbsp}";
+ }
+ echo "{$nbsp}Displaying {$pagination_counter}/" . count($evaledvar) . " records";
+ if($i < count($evaledvar))
+ echo "{$nbsp}<font size='2'><a href='pkg.php?xml=" . $_REQUEST['xml'] . "&startdisplayingat=" . ($startdisplayingat + $display_maximum_rows) . "'>Next page >></a>";
+ echo "</td></tr>";
+ break;
+ }
}
- ?>
- <td valign="middle" class="list" nowrap>
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
- <td valign="middle"><a href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this item?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
- </td>
- <?php
- echo "</tr>\n";
- $i++;
- }
- ?>
- <tr>
- <td colspan="<?=$cols?>"></td>
- <td>
- <table border="0" cellspacing="0" cellpadding="1">
- <tr>
- <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&id=<?=$i?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
+ $i++;
+ $pagination_counter++;
+ }
+?>
+ <tr>
+ <td colspan="<?=$cols?>"></td>
+ <td>
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&id=<?=$i?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+</tr>
</table>
</div></tr></td></table>
@@ -223,3 +342,10 @@ Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
</body>
</html>
+
+<?php
+
+echo "<!-- filter_fieldname: {$filter_fieldname} -->";
+echo "<!-- filter_regex: {$filter_regex} -->";
+
+?> \ No newline at end of file
OpenPOWER on IntegriCloud