[aur-dev] [PATCH 1/2] Move package comments to a template.
Change layout in the process. Signed-off-by: Loui Chang <louipc.ist@gmail.com> --- web/lib/pkgfuncs.inc | 69 ++++++---------------------------------- web/template/pkg_comments.php | 38 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 58 deletions(-) create mode 100644 web/template/pkg_comments.php diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 9535f18..b6e93c5 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -524,71 +524,24 @@ function package_details($id=0, $SID="") { } echo " </form>\n"; + echo "<br />\n"; + + # Add Comments + echo "<form action='pkgedit.php' method='post'>\n"; + echo "<input type='hidden' name='ID' value='".$row["ID"]."'>\n"; + echo "<input type='submit' class='button' name='add_Comment' value=\""; + echo __("Add Comment")."\">\n"; + echo "</form>\n"; echo " </div>\n"; echo "</div>\n"; - echo "\n<br />\n\n"; + echo "\n<br />"; } - # Comments - # - echo "<div class=\"pgbox\">\n"; - echo " <div class=\"pgboxtitle\"><span class=\"f3\">".__("Comments")."</span></div>\n"; - echo " <div class=\"pgboxbody-comment\">\n"; - echo " <table width='100%'>\n"; - if (isset($_COOKIE['AURSID'])) { - echo "<tr><td>"; - echo " <form action='pkgedit.php' method='post'>\n"; - echo " <input type='hidden' name='ID' value='".$row["ID"]."'>\n"; - echo " <input type='submit' class='button' name='add_Comment' value=\""; - echo __("Add Comment")."\">\n"; - echo " </form>\n"; - echo "</tr></td>"; - //echo "<br />\n"; - } + # Print Comments $comments = package_comments($row["ID"]); if (!empty($comments)) { - while (list($indx, $carr) = each($comments)) { - - echo " <tr>\n"; - echo " <td valign='top' style='padding-right: 10' colspan='2'>\n"; - echo " <table class='boxSoft' width='100%'>\n"; - echo " <tr>\n"; - echo " <td class='boxSoftTitle'><span class='f3'>"; - if (canDeleteComment($carr["ID"], $atype, $SID)) { - $durl = "<a href='pkgedit.php?del_Comment=1"; - $durl.= "&comment_id=".$carr["ID"]."&ID=".$row["ID"]; - $durl.= "'><img src='/images/x.png' border='0'"; - $durl.= " alt=\"".__("Delete comment")."\"></a>"; - - echo $durl . " "; - } - if ($SID) { - echo __("Comment by: %h%s%h on %h%s%h", - array("<a href='account.php?Action=AccountInfo&ID=".$carr["UsersID"]."'><b>",$carr["UserName"],"</b></a>", - "<i>",gmdate("Ymd [H:i:s]",$carr["CommentTS"]),"</i>")); - } else { - echo __("Comment by: %h%s%h on %h%s%h", - array("<b>",$carr["UserName"],"</b>", - "<i>",gmdate("Ymd [H:i:s]",$carr["CommentTS"]),"</i>")); - } - echo "</span></td>\n"; - echo " </tr>\n"; - echo " <tr>\n"; - echo " <td class='boxSoft'>"; - echo "<code>\n"; - echo nl2br(htmlspecialchars($carr["Comments"])); - echo "</code></td>\n"; - echo " </tr>\n"; - echo " </table>\n"; - echo " </td>\n"; - echo " </tr>\n"; - } - } else { - print "<tr><td>None</td></tr>\n"; + include('pkg_comments.php'); } - echo " </table>\n"; - echo " </div>\n"; - echo "</div>\n"; } } return; diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php new file mode 100644 index 0000000..7bcf708 --- /dev/null +++ b/web/template/pkg_comments.php @@ -0,0 +1,38 @@ +<div class="pgbox"> +<table width="100%"> +<?php while (list($indx, $carr) = each($comments)) { ?> + <tr class='boxSoft'> + <td class='boxSoftTitle' valign='top' style='padding-right: 10' colspan='2'> + <span class='f3'> +<?php + if (canDeleteComment($carr['ID'], $atype, $SID)) { + $durl = '<a href="pkgedit.php?del_Comment=1'; + $durl.= '&comment_id=' . $carr['ID'] . '&ID=' . $row['ID']; + $durl.= '"><img src="images/x.png" border="0"'; + $durl.= ' alt="' . __("Delete comment") . '"></a> '; + + echo $durl; + } + if ($SID) { + echo __("Comment by: %h%s%h on %s", + "<a href='account.php?Action=AccountInfo&ID=".$carr["UsersID"]."'><b>", + $carr["UserName"], "</b></a>", gmdate("Y m d [H:i:s]", $carr["CommentTS"])); + } else { + echo __("Comment by: %h%s%h on %s", + "<b>", $carr["UserName"], "</b>", + gmdate("Y m d [H:i:s]", $carr["CommentTS"])); + } +?> + </span> + </td> + </tr> + <tr> + <td class="boxSoft"> + <pre><?php echo htmlspecialchars($carr["Comments"]) ?></pre> + </td> + </tr> +<?php +} +?> +</table> +</div> -- 1.6.1
Signed-off-by: Loui Chang <louipc.ist@gmail.com> --- web/html/css/arch.css | 11 ++------- web/template/pkg_search_form.php | 40 +++++++++++++++---------------------- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/web/html/css/arch.css b/web/html/css/arch.css index 37997c0..499660e 100644 --- a/web/html/css/arch.css +++ b/web/html/css/arch.css @@ -452,15 +452,10 @@ textarea.vLargeTextField { border-collapse: separate; border-spacing: 0 15px; } -#search_box { - margin: 5px; - text-align: center; +#advanced-search li { font-size: 11px; -} -#advanced li { - background-color: #f3f3f3; list-style: none; display: inline; - padding: 15px; + padding-right: 15px; text-decoration: none; -} \ No newline at end of file +} diff --git a/web/template/pkg_search_form.php b/web/template/pkg_search_form.php index 289f8b4..90feb37 100644 --- a/web/template/pkg_search_form.php +++ b/web/template/pkg_search_form.php @@ -1,23 +1,21 @@ <?php include_once('pkgfuncs.inc') ?> +<div class='pgbox'> <form action='packages.php' method='get'> -<input type='hidden' name='O' value='0'> -<center> -<table cellspacing='3' class='boxSoft'> -<tr> - <td class='boxSoftTitle' align='right'> - <span class='f3'><?php print __("Search Criteria"); ?></span> - </td> -</tr> -<tr> - <td class='boxSoft'> - <div id="search_box" class="blue"> - <label><?php print __("Keywords"); ?></label> - <input type='text' name='K' size='20' value="<?php print stripslashes(trim(htmlspecialchars($_REQUEST["K"], ENT_QUOTES))); ?>" maxlength='35' /> - <?php if (!$_GET['detail']): ?><input type='submit' style='width:80px' class='button' name='do_Search' value='<?php print __("Go"); ?>' /><?php endif; ?> - <a href="?<?php print mkurl('detail=' . (($_GET['detail']) ? 0 : 1) ) ?>">Advanced</a> - <?php if ($_GET['detail']): ?> - <div id="advanced"> +<div class='pgboxtitle' align='right'> + <span class='f3'><?php print __("Search Criteria"); ?></span> + <input type='text' name='K' size='30' value="<?php print stripslashes(trim(htmlspecialchars($_REQUEST["K"], ENT_QUOTES))); ?>" maxlength='35' /> + <input type='submit' style='width:80px' class='button' name='do_Search' value='<?php print __("Go"); ?>' /> + <?php if (!empty($_GET['detail'])): ?> + <input type='submit' style='width:80px' class='button' name='do_Orphans' value='<?php print __("Orphans"); ?>' /> + +<?php endif; ?> + <a href="?<?php print mkurl('detail=' . ((!empty($_GET['detail'])) ? 0 : 1) ) ?>">Advanced</a> +</div> + +<input type='hidden' name='O' value='0' /> + <?php if (!empty($_GET['detail'])): ?> + <div id="advanced-search" class="blue"> <input type="hidden" name="detail" value="1" /> <ul> <li> @@ -123,14 +121,8 @@ </select> </li> </ul> - <input type='submit' style='width:80px' class='button' name='do_Search' value='<?php print __("Go"); ?>' /> - <input type='submit' style='width:80px' class='button' name='do_Orphans' value='<?php print __("Orphans"); ?>' /> </div> <?php endif; ?> - </div> - </td> -</tr> -</table> -</center> </form> +</div> <br /> -- 1.6.1
Index: web/html/packages.php =================================================================== --- web/html/packages.php (revision 277) +++ web/html/packages.php (working copy) @@ -301,26 +301,30 @@ # $field = ""; # } $field = "MaintainerUID"; - if ($field) { - # NOTE: Only "orphaned" packages can be adopted at a particular - # user class (TU/Dev or User). - # - $q = "UPDATE Packages "; - $q.= "SET ".$field." = ".uid_from_sid($_COOKIE["AURSID"])." "; - $q.= "WHERE ID IN (" . $adopt . ") "; - if ($atype == "User") - { - # Regular users may only adopt orphan packages from unsupported - # FIXME: We assume that LocationID for unsupported is "2" - $q.= "AND ".$field." = 0"; - $q.= " AND LocationID = 2"; - } - db_query($q, $dbh); + # NOTE: Only "orphaned" packages can be adopted at a particular + # user class (TU/Dev or User). + # + $q = "UPDATE Packages "; + $q.= "SET ".$field." = ".uid_from_sid($_COOKIE["AURSID"])." "; + $q.= "WHERE ID IN (" . $adopt . ") "; + if ($atype == "User") + { + # Regular users may only adopt orphan packages from unsupported + # FIXME: We assume that LocationID for unsupported is "2" + $q.= "AND ".$field." = 0"; + $q.= " AND LocationID = 2"; } - - print "<p>\n"; - print __("The selected packages have been adopted."); - print "</p>\n"; + if(db_query($q, $dbh)) + { + print "<p>\n"; + printf ("%d of the selected packages have been adopted.\n<br>", mysql_affected_rows()); + print ("Note that you can only adopt orphaned packages and that ordinary users can only adopt unsupported packages.\n<br>"); + print "</p>\n"; + } else { + print "<p>\n"; + print __("The selected packages could not be adopted because if an error."); + print "</p>\n"; + } } else { print "<p>\n"; print __("You did not select any packages to adopt.");
participants (1)
-
Loui Chang