| | @@ -570,11 +570,10 @@ |
| 570 | 570 | */ |
| 571 | 571 | unsigned int search_restrict(unsigned int srchFlags){ |
| 572 | 572 | if( g.perm.Read==0 ) srchFlags &= ~(SRCH_CKIN|SRCH_DOC); |
| 573 | 573 | if( g.perm.RdTkt==0 ) srchFlags &= ~(SRCH_TKT); |
| 574 | 574 | if( g.perm.RdWiki==0 ) srchFlags &= ~(SRCH_WIKI); |
| 575 | | - if( search_index_exists() ) return srchFlags; |
| 576 | 575 | if( (srchFlags & SRCH_CKIN)!=0 && db_get_boolean("search-ci",0)==0 ){ |
| 577 | 576 | srchFlags &= ~SRCH_CKIN; |
| 578 | 577 | } |
| 579 | 578 | if( (srchFlags & SRCH_DOC)!=0 && db_get_boolean("search-doc",0)==0 ){ |
| 580 | 579 | srchFlags &= ~SRCH_DOC; |
| | @@ -824,50 +823,85 @@ |
| 824 | 823 | } |
| 825 | 824 | return nRow; |
| 826 | 825 | } |
| 827 | 826 | |
| 828 | 827 | /* |
| 829 | | -** WEBPAGE: /search |
| 828 | +** Generate some HTML for doing search. At a minimum include the |
| 829 | +** Search-Text entry form. If the "s" query parameter is present, also |
| 830 | +** show search results. |
| 831 | +** |
| 832 | +** The srchFlags parameter is used to customize some of the text of the |
| 833 | +** form and the results. srchFlags should be either a single search |
| 834 | +** category or all categories. Any srchFlags with two or more bits set |
| 835 | +** is treated like SRCH_ALL for display purposes. |
| 830 | 836 | ** |
| 831 | | -** Search for check-in comments, documents, tickets, or wiki that |
| 832 | | -** match a user-supplied pattern. |
| 837 | +** The entry box is shown disabled if srchFlags is 0. |
| 833 | 838 | */ |
| 834 | | -void search_page(void){ |
| 835 | | - const char *zPattern = PD("s",""); |
| 836 | | - unsigned srchFlags = 0; |
| 839 | +void search_screen(unsigned srchFlags, const char *zAction){ |
| 840 | + const char *zType = 0; |
| 841 | + const char *zClass = 0; |
| 837 | 842 | const char *zDisable; |
| 838 | | - const char *zOnly = P("only"); |
| 839 | | - |
| 840 | | - login_check_credentials(); |
| 841 | | - srchFlags = search_restrict(SRCH_ALL); |
| 842 | | - if( zOnly ){ |
| 843 | | - if( strchr(zOnly,'c') ) srchFlags &= SRCH_CKIN; |
| 844 | | - if( strchr(zOnly,'d') ) srchFlags &= SRCH_DOC; |
| 845 | | - if( strchr(zOnly,'t') ) srchFlags &= SRCH_TKT; |
| 846 | | - if( strchr(zOnly,'w') ) srchFlags &= SRCH_WIKI; |
| 847 | | - } |
| 843 | + const char *zPattern; |
| 844 | + switch( srchFlags ){ |
| 845 | + case SRCH_CKIN: zType = " Check-ins"; zClass = "Ckin"; break; |
| 846 | + case SRCH_DOC: zType = " Docs"; zClass = "Doc"; break; |
| 847 | + case SRCH_TKT: zType = " Tickets"; zClass = "Tkt"; break; |
| 848 | + case SRCH_WIKI: zType = " Wiki"; zClass = "Wiki"; break; |
| 849 | + } |
| 850 | + srchFlags = search_restrict(srchFlags); |
| 848 | 851 | if( srchFlags==0 ){ |
| 849 | 852 | zDisable = " disabled"; |
| 850 | 853 | zPattern = ""; |
| 851 | 854 | }else{ |
| 852 | 855 | zDisable = ""; |
| 853 | 856 | zPattern = PD("s",""); |
| 854 | 857 | } |
| 855 | | - style_header("Search"); |
| 856 | | - @ <form method="GET" action="search"><center> |
| 858 | + @ <form method='GET' action='%s(zAction)'> |
| 859 | + if( zClass ){ |
| 860 | + @ <div class='searchForm searchForm%s(zClass)'> |
| 861 | + }else{ |
| 862 | + @ <div class='searchForm'> |
| 863 | + } |
| 857 | 864 | @ <input type="text" name="s" size="40" value="%h(zPattern)"%s(zDisable)> |
| 858 | | - @ <input type="submit" value="Search"%s(zDisable)> |
| 865 | + @ <input type="submit" value="Search%s(zType)"%s(zDisable)> |
| 859 | 866 | if( srchFlags==0 ){ |
| 860 | 867 | @ <p class="generalError">Search is disabled</p> |
| 861 | 868 | } |
| 862 | | - @ </center></form> |
| 869 | + @ </div></form> |
| 863 | 870 | while( fossil_isspace(zPattern[0]) ) zPattern++; |
| 864 | 871 | if( zPattern[0] ){ |
| 872 | + if( zClass ){ |
| 873 | + @ <div class='searchResult searchResult%s(zClass)'> |
| 874 | + }else{ |
| 875 | + @ <div class='searchResult'> |
| 876 | + } |
| 865 | 877 | if( search_run_and_output(zPattern, srchFlags)==0 ){ |
| 866 | | - @ <p><i>No matches for: "%h(zPattern)"</i></p> |
| 878 | + @ <p class='searchEmpty'>No matches for: <span>%h(zPattern)</span></p> |
| 867 | 879 | } |
| 880 | + @ </div> |
| 881 | + } |
| 882 | +} |
| 883 | + |
| 884 | +/* |
| 885 | +** WEBPAGE: /search |
| 886 | +** |
| 887 | +** Search for check-in comments, documents, tickets, or wiki that |
| 888 | +** match a user-supplied pattern. |
| 889 | +*/ |
| 890 | +void search_page(void){ |
| 891 | + unsigned srchFlags = SRCH_ALL; |
| 892 | + const char *zOnly = P("only"); |
| 893 | + |
| 894 | + login_check_credentials(); |
| 895 | + if( zOnly ){ |
| 896 | + if( strchr(zOnly,'c') ) srchFlags &= SRCH_CKIN; |
| 897 | + if( strchr(zOnly,'d') ) srchFlags &= SRCH_DOC; |
| 898 | + if( strchr(zOnly,'t') ) srchFlags &= SRCH_TKT; |
| 899 | + if( strchr(zOnly,'w') ) srchFlags &= SRCH_WIKI; |
| 868 | 900 | } |
| 901 | + style_header("Search"); |
| 902 | + search_screen(srchFlags, "search"); |
| 869 | 903 | style_footer(); |
| 870 | 904 | } |
| 871 | 905 | |
| 872 | 906 | |
| 873 | 907 | /* |
| 874 | 908 | |