[aur-dev] [PATCH 1/4] Split out the search form from pkg_search_page()
This makes it easier to display search results without showing the search form. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/packages.php | 3 ++- web/lib/pkgfuncs.inc.php | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/web/html/packages.php b/web/html/packages.php index 1b89278..8fd3266 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -80,8 +80,9 @@ $(document).ready(function() { </script> <?php +include('pkg_search_form.php'); + if (isset($pkgid)) { - include('pkg_search_form.php'); if ($pkgid) { if (isset($_COOKIE["AURSID"])) { pkg_display_details($pkgid, $details, $_COOKIE["AURSID"]); diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 8ca8835..8a5cf57 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -888,8 +888,6 @@ function pkg_search_page($SID="") { $templ_pages[__('Last') . ' »'] = ($pages - 1) * $per_page; } - include('pkg_search_form.php'); - $searchresults = array(); if ($result) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) { -- 2.11.1
* Pass search parameters using an associative array instead of $_GET. * Add a boolean parameter to enable and disable headers/footers. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/packages.php | 4 +- web/lib/pkgfuncs.inc.php | 130 +++++++++++++----------------------- web/template/pkg_search_results.php | 8 ++- 3 files changed, 55 insertions(+), 87 deletions(-) diff --git a/web/html/packages.php b/web/html/packages.php index 8fd3266..ec6fc75 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -99,9 +99,9 @@ if (isset($pkgid)) { $_GET['SO'] = 'd'; } if (isset($_COOKIE["AURSID"])) { - pkg_search_page($_COOKIE["AURSID"]); + pkg_search_page($_GET, true, $_COOKIE["AURSID"]); } else { - pkg_search_page(); + pkg_search_page($_GET, true); } } diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 8a5cf57..ee4ca52 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -642,53 +642,16 @@ function pkg_display_details($id=0, $row, $SID="") { } } -/* pkg_search_page(SID) - * outputs the body of search/search results page - * - * parameters: - * SID - current Session ID - * preconditions: - * package search page has been accessed - * request variables have not been sanitized - * - * request vars: - * O - starting result number - * PP - number of search hits per page - * K - package search string - * SO - search hit sort order: - * values: a - ascending - * d - descending - * SB - sort search hits by: - * values: n - package name - * v - number of votes - * m - maintainer username - * SeB- property that search string (K) represents - * values: n - package name - * nd - package name & description - * b - package base name - * N - package name (exact match) - * B - package base name (exact match) - * k - package keyword(s) - * m - package maintainer's username - * c - package co-maintainer's username - * s - package submitter's username - * do_Orphans - boolean. whether to search packages - * without a maintainer - * - * - * These two are actually handled in packages.php. - * - * IDs- integer array of ticked packages' IDs - * action - action to be taken on ticked packages - * values: do_Flag - Flag out-of-date - * do_UnFlag - Remove out-of-date flag - * do_Adopt - Adopt - * do_Disown - Disown - * do_Delete - Delete - * do_Notify - Enable notification - * do_UnNotify - Disable notification +/** + * Output the body of the search results page + * + * @param array $params Search parameters + * @param bool $show_headers True if statistics should be included + * @param string $SID The session ID of the visitor + * + * @return void */ -function pkg_search_page($SID="") { +function pkg_search_page($params, $show_headers=true, $SID="") { $dbh = DB::connect(); /* @@ -699,16 +662,16 @@ function pkg_search_page($SID="") { $myuid = uid_from_sid($SID); /* Sanitize paging variables. */ - if (isset($_GET['O'])) { - $_GET['O'] = max(intval($_GET['O']), 0); + if (isset($params['O'])) { + $params['O'] = max(intval($params['O']), 0); } else { - $_GET['O'] = 0; + $params['O'] = 0; } - if (isset($_GET["PP"])) { - $_GET["PP"] = bound(intval($_GET["PP"]), 50, 250); + if (isset($params["PP"])) { + $params["PP"] = bound(intval($params["PP"]), 50, 250); } else { - $_GET["PP"] = 50; + $params["PP"] = 50; } /* @@ -742,67 +705,67 @@ function pkg_search_page($SID="") { $q_where = 'WHERE PackageBases.PackagerUID IS NOT NULL '; - if (isset($_GET['K'])) { - if (isset($_GET["SeB"]) && $_GET["SeB"] == "m") { + if (isset($params['K'])) { + if (isset($params["SeB"]) && $params["SeB"] == "m") { /* Search by maintainer. */ - $q_where .= "AND Users.Username = " . $dbh->quote($_GET['K']) . " "; + $q_where .= "AND Users.Username = " . $dbh->quote($params['K']) . " "; } - elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "c") { + elseif (isset($params["SeB"]) && $params["SeB"] == "c") { /* Search by co-maintainer. */ $q_where .= "AND EXISTS (SELECT * FROM PackageComaintainers "; $q_where .= "INNER JOIN Users ON Users.ID = PackageComaintainers.UsersID "; $q_where .= "WHERE PackageComaintainers.PackageBaseID = PackageBases.ID "; - $q_where .= "AND Users.Username = " . $dbh->quote($_GET['K']) . ")"; + $q_where .= "AND Users.Username = " . $dbh->quote($params['K']) . ")"; } - elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "s") { + elseif (isset($params["SeB"]) && $params["SeB"] == "s") { /* Search by submitter. */ - $q_where .= "AND SubmitterUID = " . intval(uid_from_username($_GET['K'])) . " "; + $q_where .= "AND SubmitterUID = " . intval(uid_from_username($params['K'])) . " "; } - elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "n") { + elseif (isset($params["SeB"]) && $params["SeB"] == "n") { /* Search by name. */ - $K = "%" . addcslashes($_GET['K'], '%_') . "%"; + $K = "%" . addcslashes($params['K'], '%_') . "%"; $q_where .= "AND (Packages.Name LIKE " . $dbh->quote($K) . ") "; } - elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "b") { + elseif (isset($params["SeB"]) && $params["SeB"] == "b") { /* Search by package base name. */ - $K = "%" . addcslashes($_GET['K'], '%_') . "%"; + $K = "%" . addcslashes($params['K'], '%_') . "%"; $q_where .= "AND (PackageBases.Name LIKE " . $dbh->quote($K) . ") "; } - elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "k") { + elseif (isset($params["SeB"]) && $params["SeB"] == "k") { /* Search by keywords. */ - $q_where .= construct_keyword_search($dbh, false); + $q_where .= construct_keyword_search($dbh, $params['K'], false); } - elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "N") { + elseif (isset($params["SeB"]) && $params["SeB"] == "N") { /* Search by name (exact match). */ - $q_where .= "AND (Packages.Name = " . $dbh->quote($_GET['K']) . ") "; + $q_where .= "AND (Packages.Name = " . $dbh->quote($params['K']) . ") "; } - elseif (isset($_GET["SeB"]) && $_GET["SeB"] == "B") { + elseif (isset($params["SeB"]) && $params["SeB"] == "B") { /* Search by package base name (exact match). */ - $q_where .= "AND (PackageBases.Name = " . $dbh->quote($_GET['K']) . ") "; + $q_where .= "AND (PackageBases.Name = " . $dbh->quote($params['K']) . ") "; } else { /* Keyword search (default). */ - $q_where .= construct_keyword_search($dbh, true); + $q_where .= construct_keyword_search($dbh, $params['K'], true); } } - if (isset($_GET["do_Orphans"])) { + if (isset($params["do_Orphans"])) { $q_where .= "AND MaintainerUID IS NULL "; } - if (isset($_GET['outdated'])) { - if ($_GET['outdated'] == 'on') { + if (isset($params['outdated'])) { + if ($params['outdated'] == 'on') { $q_where .= "AND OutOfDateTS IS NOT NULL "; } - elseif ($_GET['outdated'] == 'off') { + elseif ($params['outdated'] == 'off') { $q_where .= "AND OutOfDateTS IS NULL "; } } - $order = (isset($_GET["SO"]) && $_GET["SO"] == 'd') ? 'DESC' : 'ASC'; + $order = (isset($params["SO"]) && $params["SO"] == 'd') ? 'DESC' : 'ASC'; $q_sort = "ORDER BY "; - $sort_by = isset($_GET["SB"]) ? $_GET["SB"] : ''; + $sort_by = isset($params["SB"]) ? $params["SB"] : ''; switch ($sort_by) { case 'v': $q_sort .= "NumVotes " . $order . ", "; @@ -835,7 +798,7 @@ function pkg_search_page($SID="") { } $q_sort .= " Packages.Name " . $order . " "; - $q_limit = "LIMIT ".$_GET["PP"]." OFFSET ".$_GET["O"]; + $q_limit = "LIMIT ".$params["PP"]." OFFSET ".$params["O"]; $q = $q_select . $q_from . $q_from_extra . $q_where . $q_sort . $q_limit; $q_total = "SELECT COUNT(*) " . $q_from . $q_where; @@ -851,7 +814,7 @@ function pkg_search_page($SID="") { } if ($result && $total > 0) { - if (isset($_GET["SO"]) && $_GET["SO"] == "d"){ + if (isset($params["SO"]) && $params["SO"] == "d"){ $SO_next = "a"; } else { @@ -860,10 +823,10 @@ function pkg_search_page($SID="") { } /* Calculate the results to use. */ - $first = $_GET['O'] + 1; + $first = $params['O'] + 1; /* Calculation of pagination links. */ - $per_page = ($_GET['PP'] > 0) ? $_GET['PP'] : 50; + $per_page = ($params['PP'] > 0) ? $params['PP'] : 50; $current = ceil($first / $per_page); $pages = ceil($total / $per_page); $templ_pages = array(); @@ -904,17 +867,18 @@ function pkg_search_page($SID="") { * Construct the WHERE part of the sophisticated keyword search * * @param handle $dbh Database handle - * @param boolean $namedesc Search name and description fields + * @param string $keywords The search term + * @param bool $namedesc Search name and description fields * * @return string WHERE part of the SQL clause */ -function construct_keyword_search($dbh, $namedesc) { +function construct_keyword_search($dbh, $keywords, $namedesc) { $count = 0; $where_part = ""; $q_keywords = ""; $op = ""; - foreach (str_getcsv($_GET['K'], ' ') as $term) { + foreach (str_getcsv($keywords, ' ') as $term) { if ($term == "") { continue; } diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index 37a9032..7b6b00a 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -5,6 +5,7 @@ if (!$result): ?> <div class="box"><p><?= __("No packages matched your search criteria.") ?></p></div> <?php else: ?> <div id="pkglist-results" class="box"> + <?php if ($show_headers): ?> <div class="pkglist-stats"> <p> <?= _n('%d package found.', '%d packages found.', $total) ?> @@ -24,12 +25,13 @@ if (!$result): ?> </p> <?php endif; ?> </div> + <?php endif; ?> <form id="pkglist-results-form" method="post" action="<?= get_uri('/pkgbase/'); ?>?<?= htmlentities($_SERVER['QUERY_STRING']) ?>"> <table class="results"> <thead> <tr> - <?php if ($SID): ?> + <?php if ($SID && $show_headers): ?> <th> </th> <?php endif; ?> <th><a href="?<?= mkurl('SB=n&SO=' . $SO_next) ?>"><?= __("Name") ?></a></th> @@ -48,7 +50,7 @@ if (!$result): ?> <?php while (list($indx, $row) = each($searchresults)): ?> <tr class="<?= ($indx % 2 == 0) ? 'odd' : 'even' ?>"> - <?php if ($SID): ?> + <?php if ($SID && $show_headers): ?> <td><input type="checkbox" name="IDs[<?= $row["PackageBaseID"] ?>]" value="1" /></td> <?php endif; ?> <td><a href="<?= htmlspecialchars(get_pkg_uri($row["Name"]), ENT_QUOTES); ?>"><?= htmlspecialchars($row["Name"]) ?></a></td> @@ -85,6 +87,7 @@ if (!$result): ?> </tbody> </table> + <?php if ($show_headers): ?> <div class="pkglist-stats"> <p> <?= _n('%d package found.', '%d packages found.', $total) ?> @@ -127,6 +130,7 @@ if (!$result): ?> <input type="submit" class="button" style="width: 80px" value="<?= __("Go") ?>" /> </p> <?php endif; # if ($SID) ?> + <?php endif; ?> </form> </div> <?php endif; # search was successful and returned multiple results ?> -- 2.11.1
Do not print the wrapper div container when calling pkg_search_page(). Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/packages.php | 2 + web/template/pkg_search_results.php | 174 ++++++++++++++++++------------------ 2 files changed, 88 insertions(+), 88 deletions(-) diff --git a/web/html/packages.php b/web/html/packages.php index ec6fc75..113a114 100644 --- a/web/html/packages.php +++ b/web/html/packages.php @@ -98,11 +98,13 @@ if (isset($pkgid)) { $_GET['SB'] = 'p'; $_GET['SO'] = 'd'; } + echo '<div id="pkglist-results" class="box">'; if (isset($_COOKIE["AURSID"])) { pkg_search_page($_GET, true, $_COOKIE["AURSID"]); } else { pkg_search_page($_GET, true); } + echo '</div>'; } html_footer(AURWEB_VERSION); diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index 7b6b00a..d596ec2 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -1,52 +1,51 @@ <?php if (!$result): ?> - <div class="box"><p><?= __("Error retrieving package list.") ?></p></div> + <p><?= __("Error retrieving package list.") ?></p> <?php elseif ($total == 0): ?> - <div class="box"><p><?= __("No packages matched your search criteria.") ?></p></div> + <p><?= __("No packages matched your search criteria.") ?></p> <?php else: ?> - <div id="pkglist-results" class="box"> - <?php if ($show_headers): ?> - <div class="pkglist-stats"> - <p> - <?= _n('%d package found.', '%d packages found.', $total) ?> - <?= __('Page %d of %d.', $current, $pages) ?> - </p> - <?php if (count($templ_pages) > 1): ?> - <p class="pkglist-nav"> - <?php foreach ($templ_pages as $pagenr => $pagestart): ?> - <?php if ($pagestart === false): ?> - <span class="page"><?= $pagenr ?></span> - <?php elseif ($pagestart + 1 == $first): ?> - <span class="page"><?= $pagenr ?></span> - <?php else: ?> - <a class="page" href="<?= get_uri('/packages/'); ?>?<?= mkurl('O=' . $pagestart) ?>"><?= $pagenr ?></a> - <?php endif; ?> - <?php endforeach; ?> - </p> - <?php endif; ?> - </div> + <?php if ($show_headers): ?> + <div class="pkglist-stats"> + <p> + <?= _n('%d package found.', '%d packages found.', $total) ?> + <?= __('Page %d of %d.', $current, $pages) ?> + </p> + <?php if (count($templ_pages) > 1): ?> + <p class="pkglist-nav"> + <?php foreach ($templ_pages as $pagenr => $pagestart): ?> + <?php if ($pagestart === false): ?> + <span class="page"><?= $pagenr ?></span> + <?php elseif ($pagestart + 1 == $first): ?> + <span class="page"><?= $pagenr ?></span> + <?php else: ?> + <a class="page" href="<?= get_uri('/packages/'); ?>?<?= mkurl('O=' . $pagestart) ?>"><?= $pagenr ?></a> + <?php endif; ?> + <?php endforeach; ?> + </p> <?php endif; ?> + </div> + <?php endif; ?> - <form id="pkglist-results-form" method="post" action="<?= get_uri('/pkgbase/'); ?>?<?= htmlentities($_SERVER['QUERY_STRING']) ?>"> - <table class="results"> - <thead> - <tr> - <?php if ($SID && $show_headers): ?> - <th> </th> - <?php endif; ?> - <th><a href="?<?= mkurl('SB=n&SO=' . $SO_next) ?>"><?= __("Name") ?></a></th> - <th><?= __("Version") ?></th> - <th><a href="?<?= mkurl('SB=v&SO=' . $SO_next) ?>"><?= __("Votes") ?></a></th> - <th><a href="?<?= mkurl('SB=p&SO=' . $SO_next) ?>"><?= __("Popularity") ?></a><span title="<?= __('Popularity is calculated as the sum of all votes with each vote being weighted with a factor of %.2f per day since its creation.', 0.98) ?>" class="hover-help"><sup>?</sup></span></th> - <?php if ($SID): ?> - <th><a href="?<?= mkurl('SB=w&SO=' . $SO_next) ?>"><?= __("Voted") ?></a></th> - <th><a href="?<?= mkurl('SB=o&SO=' . $SO_next) ?>"><?= __("Notify") ?></a></th> - <?php endif; ?> - <th><?= __("Description") ?></th> - <th><a href="?<?= mkurl('SB=m&SO=' . $SO_next) ?>"><?= __("Maintainer") ?></a></th> - </tr> - </thead> - <tbody> + <form id="pkglist-results-form" method="post" action="<?= get_uri('/pkgbase/'); ?>?<?= htmlentities($_SERVER['QUERY_STRING']) ?>"> + <table class="results"> + <thead> + <tr> + <?php if ($SID && $show_headers): ?> + <th> </th> + <?php endif; ?> + <th><a href="?<?= mkurl('SB=n&SO=' . $SO_next) ?>"><?= __("Name") ?></a></th> + <th><?= __("Version") ?></th> + <th><a href="?<?= mkurl('SB=v&SO=' . $SO_next) ?>"><?= __("Votes") ?></a></th> + <th><a href="?<?= mkurl('SB=p&SO=' . $SO_next) ?>"><?= __("Popularity") ?></a><span title="<?= __('Popularity is calculated as the sum of all votes with each vote being weighted with a factor of %.2f per day since its creation.', 0.98) ?>" class="hover-help"><sup>?</sup></span></th> + <?php if ($SID): ?> + <th><a href="?<?= mkurl('SB=w&SO=' . $SO_next) ?>"><?= __("Voted") ?></a></th> + <th><a href="?<?= mkurl('SB=o&SO=' . $SO_next) ?>"><?= __("Notify") ?></a></th> + <?php endif; ?> + <th><?= __("Description") ?></th> + <th><a href="?<?= mkurl('SB=m&SO=' . $SO_next) ?>"><?= __("Maintainer") ?></a></th> + </tr> + </thead> + <tbody> <?php while (list($indx, $row) = each($searchresults)): ?> <tr class="<?= ($indx % 2 == 0) ? 'odd' : 'even' ?>"> @@ -84,53 +83,52 @@ if (!$result): ?> </tr> <?php endwhile; ?> - </tbody> - </table> + </tbody> + </table> - <?php if ($show_headers): ?> - <div class="pkglist-stats"> - <p> - <?= _n('%d package found.', '%d packages found.', $total) ?> - <?= __('Page %d of %d.', $current, $pages) ?> - </p> - <?php if (count($templ_pages) > 1): ?> - <p class="pkglist-nav"> - <?php foreach ($templ_pages as $pagenr => $pagestart): ?> - <?php if ($pagestart === false): ?> - <span class="page"><?= $pagenr ?></span> - <?php elseif ($pagestart + 1 == $first): ?> - <span class="page"><?= $pagenr ?></span> - <?php else: ?> - <a class="page" href="<?= get_uri('/packages/'); ?>?<?= mkurl('O=' . $pagestart) ?>"><?= $pagenr ?></a> - <?php endif; ?> - <?php endforeach; ?> - </p> - <?php endif; ?> - </div> + <?php if ($show_headers): ?> + <div class="pkglist-stats"> + <p> + <?= _n('%d package found.', '%d packages found.', $total) ?> + <?= __('Page %d of %d.', $current, $pages) ?> + </p> + <?php if (count($templ_pages) > 1): ?> + <p class="pkglist-nav"> + <?php foreach ($templ_pages as $pagenr => $pagestart): ?> + <?php if ($pagestart === false): ?> + <span class="page"><?= $pagenr ?></span> + <?php elseif ($pagestart + 1 == $first): ?> + <span class="page"><?= $pagenr ?></span> + <?php else: ?> + <a class="page" href="<?= get_uri('/packages/'); ?>?<?= mkurl('O=' . $pagestart) ?>"><?= $pagenr ?></a> + <?php endif; ?> + <?php endforeach; ?> + </p> + <?php endif; ?> + </div> - <?php if ($SID): ?> - <p> - <select name="action"> - <option><?= __("Actions") ?></option> - <option value="do_UnFlag"><?= __("Unflag Out-of-date") ?></option> - <option value="do_Adopt"><?= __("Adopt Packages") ?></option> - <option value="do_Disown"><?= __("Disown Packages") ?></option> - <?php if (has_credential(CRED_PKGBASE_DELETE)): ?> - <option value="do_Delete"><?= __("Delete Packages") ?></option> - <?php endif; ?> - <option value="do_Notify"><?= __("Notify") ?></option> - <option value="do_UnNotify"><?= __("UnNotify") ?></option> - </select> + <?php if ($SID): ?> + <p> + <select name="action"> + <option><?= __("Actions") ?></option> + <option value="do_UnFlag"><?= __("Unflag Out-of-date") ?></option> + <option value="do_Adopt"><?= __("Adopt Packages") ?></option> + <option value="do_Disown"><?= __("Disown Packages") ?></option> <?php if (has_credential(CRED_PKGBASE_DELETE)): ?> - <label for="merge_Into"><?= __("Merge into") ?></label> - <input type="text" id="merge_Into" name="merge_Into" /> + <option value="do_Delete"><?= __("Delete Packages") ?></option> <?php endif; ?> - <label class="confirmation"><input type="checkbox" name="confirm" value="1" /> <?= __("Confirm") ?></label> - <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" /> - <input type="submit" class="button" style="width: 80px" value="<?= __("Go") ?>" /> - </p> - <?php endif; # if ($SID) ?> - <?php endif; ?> - </form> - </div> + <option value="do_Notify"><?= __("Notify") ?></option> + <option value="do_UnNotify"><?= __("UnNotify") ?></option> + </select> + <?php if (has_credential(CRED_PKGBASE_DELETE)): ?> + <label for="merge_Into"><?= __("Merge into") ?></label> + <input type="text" id="merge_Into" name="merge_Into" /> + <?php endif; ?> + <label class="confirmation"><input type="checkbox" name="confirm" value="1" /> <?= __("Confirm") ?></label> + <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" /> + <input type="submit" class="button" style="width: 80px" value="<?= __("Go") ?>" /> + </p> + <?php endif; # if ($SID) ?> + <?php endif; ?> + </form> <?php endif; # search was successful and returned multiple results ?> -- 2.11.1
For logged in users, the home page is replaced with an overview of the packages the user maintains or co-maintains. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/home.php | 34 +++++++++++++++++++++++++++++++++- web/template/header.php | 7 ++++--- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/web/html/home.php b/web/html/home.php index 475370b..8d6884b 100644 --- a/web/html/home.php +++ b/web/html/home.php @@ -8,13 +8,42 @@ check_sid(); include_once('stats.inc.php'); -html_header( __("Home") ); +if ($_COOKIE["AURSID"]) { + html_header( __("Dashboard") ); +} else { + html_header( __("Home") ); +} ?> <div id="content-left-wrapper"> <div id="content-left"> <div id="intro" class="box"> + <?php if ($_COOKIE["AURSID"]): ?> + <h2><?= __("Dashboard"); ?></h2> + <h3><?= __("My Packages"); ?></h3> + <?php + $params = array( + 'PP' => 50, + 'SeB' => 'm', + 'K' => username_from_sid($_COOKIE["AURSID"]), + 'SB' => 'l', + 'SO' => 'd' + ); + pkg_search_page($params, false, $_COOKIE["AURSID"]); + ?> + <h3><?= __("Co-Maintained Packages"); ?></h3> + <?php + $params = array( + 'PP' => 50, + 'SeB' => 'c', + 'K' => username_from_sid($_COOKIE["AURSID"]), + 'SB' => 'l', + 'SO' => 'd' + ); + pkg_search_page($params, false, $_COOKIE["AURSID"]); + ?> + <?php else: ?> <h2>AUR <?= __("Home"); ?></h2> <p> <?php @@ -42,7 +71,9 @@ html_header( __("Home") ); <?= __('AUR packages are user produced content. Any use of the provided files is at your own risk.'); ?> </p> <p class="readmore"><a href="https://wiki.archlinux.org/index.php/AUR"><?= __('Learn more...') ?></a></p> + <?php endif; ?> </div> + <?php if (!$_COOKIE["AURSID"]): ?> <div id="news"> <h3><a><?= __('Support') ?></a><span class="arrow"></span></h3> <h4><?= __('Package Requests') ?></h4> @@ -122,6 +153,7 @@ html_header( __("Home") ); </p> </div> </div> + <?php endif; ?> </div> </div> <div id="content-right"> diff --git a/web/template/header.php b/web/template/header.php index 874109a..7343575 100644 --- a/web/template/header.php +++ b/web/template/header.php @@ -53,10 +53,9 @@ </div> <div id="archdev-navbar"> <ul> - <li><a href="<?= get_uri('/'); ?>">AUR <?= __("Home"); ?></a></li> - <li><a href="<?= get_uri('/packages/'); ?>"><?= __("Packages"); ?></a></li> <?php if (isset($_COOKIE['AURSID'])): ?> - <li><a href="<?= get_uri('/packages/'); ?>?SeB=m&K=<?= username_from_sid($_COOKIE["AURSID"]); ?>"><?= __("My Packages"); ?></a></li> + <li><a href="<?= get_uri('/'); ?>"><?= __("Dashboard"); ?></a></li> + <li><a href="<?= get_uri('/packages/'); ?>"><?= __("Packages"); ?></a></li> <?php if (has_credential(CRED_PKGREQ_LIST)): ?> <li><a href="<?= get_uri('/requests/') ; ?>"><?= __("Requests"); ?></a></li> <?php endif; ?> @@ -67,6 +66,8 @@ <?php if (has_credential(CRED_TU_LIST_VOTES)): ?><li><a href="<?= get_uri('/tu/'); ?>"><?= __("Trusted User"); ?></a></li><?php endif; ?> <li><a href="<?= get_uri('/logout/'); ?>"><?= __("Logout"); ?></a></li> <?php else: ?> + <li><a href="<?= get_uri('/'); ?>">AUR <?= __("Home"); ?></a></li> + <li><a href="<?= get_uri('/packages/'); ?>"><?= __("Packages"); ?></a></li> <li><a href="<?= get_uri('/register/'); ?>"><?= __("Register"); ?></a></li> <?php if (config_get_bool('options', 'disable_http_login') && empty($_SERVER['HTTPS'])): ?> <li><a href="<?= get_uri('/login/', true); ?>"><?= __("Login"); ?></a></li> -- 2.11.1
On Sat, 04 Feb 2017 at 00:50:32, Lukas Fleischer wrote:
For logged in users, the home page is replaced with an overview of the packages the user maintains or co-maintains.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- web/html/home.php | 34 +++++++++++++++++++++++++++++++++- web/template/header.php | 7 ++++--- 2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/web/html/home.php b/web/html/home.php index 475370b..8d6884b 100644 --- a/web/html/home.php +++ b/web/html/home.php @@ -8,13 +8,42 @@ check_sid();
include_once('stats.inc.php');
-html_header( __("Home") ); +if ($_COOKIE["AURSID"]) {
There was a missing isset() call here and in several other places below. I pushed an updated version to pu; thanks to Mark Weiman for letting me know.
+ html_header( __("Dashboard") ); +} else { + html_header( __("Home") ); +} [...]
participants (1)
-
Lukas Fleischer