Artifact 13bdab07f07c7bd5b8b3566e62e0c9442f56b131:
File
src/tagview.c
part of check-in
[2ae7890060]
- fixed a 2-string memleak in tagview_page_list_tags()
by
stephan on
2008-02-07 18:01:50.
0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20 /*.** Copyright
0010: 28 63 29 20 32 30 30 37 20 44 2e 20 52 69 63 68 (c) 2007 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 20 43 6f 70 79 ard Hipp.** Copy
0030: 72 69 67 68 74 20 28 63 29 20 32 30 30 38 20 53 right (c) 2008 S
0040: 74 65 70 68 61 6e 20 42 65 61 6c 0a 2a 2a 0a 2a tephan Beal.**.*
0050: 2a 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 * This program i
0060: 73 20 66 72 65 65 20 73 6f 66 74 77 61 72 65 3b s free software;
0070: 20 79 6f 75 20 63 61 6e 20 72 65 64 69 73 74 72 you can redistr
0080: 69 62 75 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a ibute it and/or.
0090: 2a 2a 20 6d 6f 64 69 66 79 20 69 74 20 75 6e 64 ** modify it und
00a0: 65 72 20 74 68 65 20 74 65 72 6d 73 20 6f 66 20 er the terms of
00b0: 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 the GNU General
00c0: 50 75 62 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 Public.** Licens
00d0: 65 20 61 73 20 70 75 62 6c 69 73 68 65 64 20 62 e as published b
00e0: 79 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 77 y the Free Softw
00f0: 61 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 3b 20 are Foundation;
0100: 65 69 74 68 65 72 0a 2a 2a 20 76 65 72 73 69 6f either.** versio
0110: 6e 20 32 20 6f 66 20 74 68 65 20 4c 69 63 65 6e n 2 of the Licen
0120: 73 65 2c 20 6f 72 20 28 61 74 20 79 6f 75 72 20 se, or (at your
0130: 6f 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 74 65 option) any late
0140: 72 20 76 65 72 73 69 6f 6e 2e 0a 2a 2a 0a 2a 2a r version..**.**
0150: 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 This program is
0160: 20 64 69 73 74 72 69 62 75 74 65 64 20 69 6e 20 distributed in
0170: 74 68 65 20 68 6f 70 65 20 74 68 61 74 20 69 74 the hope that it
0180: 20 77 69 6c 6c 20 62 65 20 75 73 65 66 75 6c 2c will be useful,
0190: 0a 2a 2a 20 62 75 74 20 57 49 54 48 4f 55 54 20 .** but WITHOUT
01a0: 41 4e 59 20 57 41 52 52 41 4e 54 59 3b 20 77 69 ANY WARRANTY; wi
01b0: 74 68 6f 75 74 20 65 76 65 6e 20 74 68 65 20 69 thout even the i
01c0: 6d 70 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 mplied warranty
01d0: 6f 66 0a 2a 2a 20 4d 45 52 43 48 41 4e 54 41 42 of.** MERCHANTAB
01e0: 49 4c 49 54 59 20 6f 72 20 46 49 54 4e 45 53 53 ILITY or FITNESS
01f0: 20 46 4f 52 20 41 20 50 41 52 54 49 43 55 4c 41 FOR A PARTICULA
0200: 52 20 50 55 52 50 4f 53 45 2e 20 20 53 65 65 20 R PURPOSE. See
0210: 74 68 65 20 47 4e 55 0a 2a 2a 20 47 65 6e 65 72 the GNU.** Gener
0220: 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 al Public Licens
0230: 65 20 66 6f 72 20 6d 6f 72 65 20 64 65 74 61 69 e for more detai
0240: 6c 73 2e 0a 2a 2a 0a 2a 2a 20 59 6f 75 20 73 68 ls..**.** You sh
0250: 6f 75 6c 64 20 68 61 76 65 20 72 65 63 65 69 76 ould have receiv
0260: 65 64 20 61 20 63 6f 70 79 20 6f 66 20 74 68 65 ed a copy of the
0270: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62 GNU General Pub
0280: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61 lic.** License a
0290: 6c 6f 6e 67 20 77 69 74 68 20 74 68 69 73 20 6c long with this l
02a0: 69 62 72 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 ibrary; if not,
02b0: 77 72 69 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20 write to the.**
02c0: 46 72 65 65 20 53 6f 66 74 77 61 72 65 20 46 6f Free Software Fo
02d0: 75 6e 64 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 undation, Inc.,
02e0: 35 39 20 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 59 Temple Place
02f0: 2d 20 53 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20 - Suite 330,.**
0300: 42 6f 73 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 Boston, MA 0211
0310: 31 2d 31 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a 1-1307, USA..**.
0320: 2a 2a 20 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 ** Author contac
0330: 74 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a t information:.*
0340: 2a 20 20 20 64 72 68 40 68 77 61 63 69 2e 63 6f * drh@hwaci.co
0350: 6d 0a 2a 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77 m.** http://ww
0360: 77 2e 68 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f w.hwaci.com/drh/
0370: 0a 2a 2a 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a .**.************
0380: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
0390: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
03a0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
03b0: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a ****************
03c0: 2a 2a 2a 0a 2a 2a 0a 2a 2a 20 49 6d 70 6c 65 6d ***.**.** Implem
03d0: 65 6e 74 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 entation of the
03e0: 54 61 67 20 56 69 65 77 20 70 61 67 65 0a 2a 2f Tag View page.*/
03f0: 0a 23 69 6e 63 6c 75 64 65 20 3c 61 73 73 65 72 .#include <asser
0400: 74 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 22 63 t.h>.#include "c
0410: 6f 6e 66 69 67 2e 68 22 0a 23 69 6e 63 6c 75 64 onfig.h".#includ
0420: 65 20 22 74 61 67 76 69 65 77 2e 68 22 0a 0a 0a e "tagview.h"...
0430: 23 69 66 20 31 0a 23 20 20 64 65 66 69 6e 65 20 #if 1.# define
0440: 54 41 47 56 49 45 57 5f 44 45 46 41 55 4c 54 5f TAGVIEW_DEFAULT_
0450: 46 49 4c 54 45 52 20 22 41 4e 44 20 74 2e 74 61 FILTER "AND t.ta
0460: 67 6e 61 6d 65 20 4e 4f 54 20 47 4c 4f 42 20 27 gname NOT GLOB '
0470: 77 69 6b 69 2d 2a 27 20 22 0a 23 65 6c 73 65 0a wiki-*' ".#else.
0480: 23 20 20 64 65 66 69 6e 65 20 54 41 47 56 49 45 # define TAGVIE
0490: 57 5f 44 45 46 41 55 4c 54 5f 46 49 4c 54 45 52 W_DEFAULT_FILTER
04a0: 0a 23 65 6e 64 69 66 0a 0a 2f 2a 0a 2a 2a 20 4c .#endif../*.** L
04b0: 69 73 74 73 20 61 6c 6c 20 74 61 67 73 20 6d 61 ists all tags ma
04c0: 74 63 68 69 6e 67 20 74 68 65 20 67 69 76 65 6e tching the given
04d0: 20 4c 49 4b 45 20 63 6c 61 75 73 65 20 28 77 68 LIKE clause (wh
04e0: 69 63 68 0a 2a 2a 20 6d 61 79 20 62 65 20 30 29 ich.** may be 0)
04f0: 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 64 ..*/.static void
0500: 20 74 61 67 76 69 65 77 5f 70 61 67 65 5f 6c 69 tagview_page_li
0510: 73 74 5f 74 61 67 73 28 63 6f 6e 73 74 20 63 68 st_tags(const ch
0520: 61 72 20 2a 7a 4c 69 6b 65 29 7b 0a 20 20 63 68 ar *zLike){. ch
0530: 61 72 20 2a 7a 4c 69 6b 65 43 6c 61 75 73 65 20 ar *zLikeClause
0540: 3d 20 30 3b 0a 20 20 63 6f 6e 73 74 20 69 6e 74 = 0;. const int
0550: 20 6c 69 6d 69 74 20 3d 20 31 30 3b 0a 20 20 63 limit = 10;. c
0560: 68 61 72 20 2a 7a 4c 69 6d 69 74 20 3d 20 30 3b har *zLimit = 0;
0570: 0a 20 20 63 68 61 72 20 2a 7a 53 71 6c 3b 0a 0a . char *zSql;..
0580: 20 20 69 66 28 20 7a 4c 69 6b 65 20 26 26 20 7a if( zLike && z
0590: 4c 69 6b 65 5b 30 5d 20 29 7b 0a 20 20 20 20 7a Like[0] ){. z
05a0: 4c 69 6b 65 43 6c 61 75 73 65 20 3d 20 6d 70 72 LikeClause = mpr
05b0: 69 6e 74 66 28 20 22 41 4e 44 20 74 2e 74 61 67 intf( "AND t.tag
05c0: 6e 61 6d 65 20 4c 49 4b 45 20 27 25 25 25 71 25 name LIKE '%%%q%
05d0: 25 27 22 2c 20 7a 4c 69 6b 65 20 29 3b 0a 20 20 %'", zLike );.
05e0: 20 20 7a 4c 69 6d 69 74 20 3d 20 22 22 3b 0a 20 zLimit = "";.
05f0: 20 20 20 40 20 3c 68 32 3e 54 61 67 73 20 6d 61 @ <h2>Tags ma
0600: 74 63 68 69 6e 67 20 5b 25 68 28 7a 4c 69 6b 65 tching [%h(zLike
0610: 43 6c 61 75 73 65 29 5d 3a 3c 2f 68 32 3e 0a 20 Clause)]:</h2>.
0620: 20 7d 65 6c 73 65 7b 0a 20 20 20 20 7a 4c 69 6d }else{. zLim
0630: 69 74 20 3d 20 6d 70 72 69 6e 74 66 28 20 22 4c it = mprintf( "L
0640: 49 4d 49 54 20 25 64 22 2c 20 6c 69 6d 69 74 20 IMIT %d", limit
0650: 29 3b 0a 20 20 20 20 7a 4c 69 6b 65 43 6c 61 75 );. zLikeClau
0660: 73 65 20 3d 20 22 22 3b 0a 20 20 20 20 40 20 3c se = "";. @ <
0670: 68 32 3e 25 64 28 6c 69 6d 69 74 29 20 6d 6f 73 h2>%d(limit) mos
0680: 74 20 72 65 63 65 6e 74 20 74 61 67 73 3a 3c 2f t recent tags:</
0690: 68 32 3e 0a 20 20 7d 0a 20 20 7a 53 71 6c 20 3d h2>. }. zSql =
06a0: 20 6d 70 72 69 6e 74 66 28 20 0a 20 20 20 20 22 mprintf( . "
06b0: 53 45 4c 45 43 54 20 22 0a 20 20 20 20 22 20 20 SELECT ". "
06c0: 20 6c 69 6e 6b 74 61 67 69 64 28 74 2e 74 61 67 linktagid(t.tag
06d0: 69 64 29 20 41 53 20 27 54 61 67 20 49 44 27 2c id) AS 'Tag ID',
06e0: 22 0a 20 20 20 20 22 20 20 20 6c 69 6e 6b 74 61 ". " linkta
06f0: 67 6e 61 6d 65 28 74 2e 74 61 67 6e 61 6d 65 29 gname(t.tagname)
0700: 20 41 53 20 27 4e 61 6d 65 27 2c 22 0a 20 20 20 AS 'Name',".
0710: 20 22 20 20 20 44 41 54 45 54 49 4d 45 28 74 78 " DATETIME(tx
0720: 2e 6d 74 69 6d 65 29 20 41 53 20 27 54 69 6d 65 .mtime) AS 'Time
0730: 73 74 61 6d 70 27 2c 22 0a 20 20 20 20 22 20 20 stamp',". "
0740: 20 6c 69 6e 6b 75 75 69 64 28 62 2e 75 75 69 64 linkuuid(b.uuid
0750: 29 20 41 53 20 27 56 65 72 73 69 6f 6e 27 22 0a ) AS 'Version'".
0760: 20 20 20 20 22 20 20 46 52 4f 4d 20 74 61 67 20 " FROM tag
0770: 74 2c 20 74 61 67 78 72 65 66 20 74 78 2c 20 62 t, tagxref tx, b
0780: 6c 6f 62 20 62 20 22 0a 20 20 20 20 22 20 57 48 lob b ". " WH
0790: 45 52 45 20 74 2e 74 61 67 69 64 3d 74 78 2e 74 ERE t.tagid=tx.t
07a0: 61 67 69 64 20 41 4e 44 20 74 78 2e 73 72 63 69 agid AND tx.srci
07b0: 64 3d 62 2e 72 69 64 22 0a 20 20 20 20 22 20 20 d=b.rid". "
07c0: 20 41 4e 44 20 74 78 2e 74 61 67 74 79 70 65 21 AND tx.tagtype!
07d0: 3d 30 20 25 73 20 22 0a 20 20 20 20 54 41 47 56 =0 %s ". TAGV
07e0: 49 45 57 5f 44 45 46 41 55 4c 54 5f 46 49 4c 54 IEW_DEFAULT_FILT
07f0: 45 52 0a 20 20 20 20 22 20 4f 52 44 45 52 20 42 ER. " ORDER B
0800: 59 20 74 78 2e 6d 74 69 6d 65 20 44 45 53 43 20 Y tx.mtime DESC
0810: 25 73 22 2c 0a 20 20 20 20 7a 4c 69 6b 65 43 6c %s",. zLikeCl
0820: 61 75 73 65 2c 20 7a 4c 69 6d 69 74 0a 20 20 29 ause, zLimit. )
0830: 3b 0a 20 20 64 62 5f 67 65 6e 65 72 69 63 5f 71 ;. db_generic_q
0840: 75 65 72 79 5f 76 69 65 77 28 7a 53 71 6c 2c 20 uery_view(zSql,
0850: 31 29 3b 0a 20 20 66 72 65 65 28 7a 53 71 6c 29 1);. free(zSql)
0860: 3b 0a 20 20 69 66 28 20 73 74 72 6c 65 6e 28 7a ;. if( strlen(z
0870: 4c 69 6b 65 43 6c 61 75 73 65 29 20 29 20 66 72 LikeClause) ) fr
0880: 65 65 28 7a 4c 69 6b 65 43 6c 61 75 73 65 29 3b ee(zLikeClause);
0890: 0a 20 20 69 66 28 20 73 74 72 6c 65 6e 28 7a 4c . if( strlen(zL
08a0: 69 6d 69 74 29 20 29 20 66 72 65 65 28 7a 4c 69 imit) ) free(zLi
08b0: 6d 69 74 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 41 mit);.}../*.** A
08c0: 20 73 6d 61 6c 6c 20 73 65 61 72 63 68 20 66 6f small search fo
08d0: 72 6d 20 77 68 69 63 68 20 66 6f 72 77 61 72 64 rm which forward
08e0: 73 20 74 6f 20 3f 6c 69 6b 65 3d 53 45 41 52 43 s to ?like=SEARC
08f0: 48 5f 53 54 52 49 4e 47 0a 2a 2f 0a 73 74 61 74 H_STRING.*/.stat
0900: 69 63 20 76 6f 69 64 20 74 61 67 76 69 65 77 5f ic void tagview_
0910: 70 61 67 65 5f 73 65 61 72 63 68 5f 6d 69 6e 69 page_search_mini
0920: 66 6f 72 6d 28 76 6f 69 64 29 7b 0a 20 20 63 68 form(void){. ch
0930: 61 72 20 63 6f 6e 73 74 20 2a 20 6c 69 6b 65 20 ar const * like
0940: 3d 20 50 28 22 6c 69 6b 65 22 29 3b 0a 20 20 40 = P("like");. @
0950: 20 3c 64 69 76 20 73 74 79 6c 65 3d 27 66 6f 6e <div style='fon
0960: 74 2d 73 69 7a 65 3a 73 6d 61 6c 6c 65 72 27 3e t-size:smaller'>
0970: 0a 20 20 40 20 3c 66 6f 72 6d 20 61 63 74 69 6f . @ <form actio
0980: 6e 3d 27 2f 74 61 67 76 69 65 77 27 20 6d 65 74 n='/tagview' met
0990: 68 6f 64 3d 27 70 6f 73 74 27 3e 0a 20 20 40 20 hod='post'>. @
09a0: 53 65 61 72 63 68 20 66 6f 72 20 74 61 67 73 3a Search for tags:
09b0: 20 0a 20 20 40 20 3c 69 6e 70 75 74 20 74 79 70 . @ <input typ
09c0: 65 3d 27 74 65 78 74 27 20 6e 61 6d 65 3d 27 6c e='text' name='l
09d0: 69 6b 65 27 20 76 61 6c 75 65 3d 27 25 68 28 28 ike' value='%h((
09e0: 6c 69 6b 65 3f 6c 69 6b 65 3a 22 22 29 29 27 20 like?like:""))'
09f0: 73 69 7a 65 3d 27 31 30 27 2f 3e 0a 20 20 40 20 size='10'/>. @
0a00: 3c 69 6e 70 75 74 20 74 79 70 65 3d 27 73 75 62 <input type='sub
0a10: 6d 69 74 27 2f 3e 0a 20 20 40 20 3c 2f 66 6f 72 mit'/>. @ </for
0a20: 6d 3e 0a 20 20 40 20 3c 2f 64 69 76 3e 0a 7d 0a m>. @ </div>.}.
0a30: 0a 2f 2a 0a 2a 2a 20 74 61 67 76 69 65 77 5f 70 ./*.** tagview_p
0a40: 61 67 65 5f 64 65 66 61 75 6c 74 28 29 20 72 65 age_default() re
0a50: 6e 64 65 72 73 20 74 68 65 20 64 65 66 61 75 6c nders the defaul
0a60: 74 20 70 61 67 65 20 66 6f 72 20 74 61 67 76 69 t page for tagvi
0a70: 65 77 5f 70 61 67 65 28 29 2e 0a 2a 2f 0a 73 74 ew_page()..*/.st
0a80: 61 74 69 63 20 76 6f 69 64 20 74 61 67 76 69 65 atic void tagvie
0a90: 77 5f 70 61 67 65 5f 64 65 66 61 75 6c 74 28 76 w_page_default(v
0aa0: 6f 69 64 29 7b 0a 20 20 74 61 67 76 69 65 77 5f oid){. tagview_
0ab0: 70 61 67 65 5f 6c 69 73 74 5f 74 61 67 73 28 20 page_list_tags(
0ac0: 30 20 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 4c 69 0 );.}../*.** Li
0ad0: 73 74 73 20 61 6c 6c 20 74 61 67 73 20 6d 61 74 sts all tags mat
0ae0: 63 68 69 6e 67 20 74 68 65 20 67 69 76 65 6e 20 ching the given
0af0: 74 61 67 69 64 2e 0a 2a 2f 0a 73 74 61 74 69 63 tagid..*/.static
0b00: 20 76 6f 69 64 20 74 61 67 76 69 65 77 5f 70 61 void tagview_pa
0b10: 67 65 5f 74 61 67 5f 62 79 5f 69 64 28 20 69 6e ge_tag_by_id( in
0b20: 74 20 74 61 67 69 64 20 29 7b 0a 20 20 63 68 61 t tagid ){. cha
0b30: 72 20 2a 7a 53 71 6c 3b 0a 20 20 40 20 3c 68 32 r *zSql;. @ <h2
0b40: 3e 54 61 67 20 23 25 64 28 74 61 67 69 64 29 3a >Tag #%d(tagid):
0b50: 3c 2f 68 32 3e 0a 20 20 7a 53 71 6c 20 3d 20 6d </h2>. zSql = m
0b60: 70 72 69 6e 74 66 28 20 0a 20 20 20 20 22 53 45 printf( . "SE
0b70: 4c 45 43 54 20 44 49 53 54 49 4e 43 54 22 0a 20 LECT DISTINCT".
0b80: 20 20 20 22 20 20 20 20 20 20 20 6c 69 6e 6b 74 " linkt
0b90: 61 67 6e 61 6d 65 28 74 2e 74 61 67 6e 61 6d 65 agname(t.tagname
0ba0: 29 20 41 53 20 27 54 61 67 20 4e 61 6d 65 27 2c ) AS 'Tag Name',
0bb0: 22 0a 20 20 20 20 22 20 20 20 20 20 20 20 44 41 ". " DA
0bc0: 54 45 54 49 4d 45 28 74 78 2e 6d 74 69 6d 65 29 TETIME(tx.mtime)
0bd0: 20 41 53 20 27 54 69 6d 65 73 74 61 6d 70 27 2c AS 'Timestamp',
0be0: 22 0a 20 20 20 20 22 20 20 20 20 20 20 20 6c 69 ". " li
0bf0: 6e 6b 75 75 69 64 28 62 2e 75 75 69 64 29 20 41 nkuuid(b.uuid) A
0c00: 53 20 27 56 65 72 73 69 6f 6e 27 22 0a 20 20 20 S 'Version'".
0c10: 20 22 20 20 46 52 4f 4d 20 74 61 67 20 74 2c 20 " FROM tag t,
0c20: 74 61 67 78 72 65 66 20 74 78 2c 20 62 6c 6f 62 tagxref tx, blob
0c30: 20 62 22 0a 20 20 20 20 22 20 57 48 45 52 45 20 b". " WHERE
0c40: 74 2e 74 61 67 69 64 3d 25 64 20 41 4e 44 20 74 t.tagid=%d AND t
0c50: 2e 74 61 67 69 64 3d 74 78 2e 74 61 67 69 64 20 .tagid=tx.tagid
0c60: 41 4e 44 20 74 78 2e 73 72 63 69 64 3d 62 2e 72 AND tx.srcid=b.r
0c70: 69 64 20 22 0a 20 20 20 20 54 41 47 56 49 45 57 id ". TAGVIEW
0c80: 5f 44 45 46 41 55 4c 54 5f 46 49 4c 54 45 52 0a _DEFAULT_FILTER.
0c90: 20 20 20 20 22 20 4f 52 44 45 52 20 42 59 20 74 " ORDER BY t
0ca0: 78 2e 6d 74 69 6d 65 20 44 45 53 43 22 2c 0a 20 x.mtime DESC",.
0cb0: 20 20 20 74 61 67 69 64 0a 20 20 29 3b 0a 20 20 tagid. );.
0cc0: 64 62 5f 67 65 6e 65 72 69 63 5f 71 75 65 72 79 db_generic_query
0cd0: 5f 76 69 65 77 28 7a 53 71 6c 2c 20 31 29 3b 0a _view(zSql, 1);.
0ce0: 20 20 66 72 65 65 28 7a 53 71 6c 29 3b 0a 7d 0a free(zSql);.}.
0cf0: 0a 2f 2a 0a 2a 2a 20 4c 69 73 74 73 20 61 6c 6c ./*.** Lists all
0d00: 20 74 61 67 73 20 6d 61 74 63 68 69 6e 67 20 74 tags matching t
0d10: 68 65 20 67 69 76 65 6e 20 74 61 67 20 6e 61 6d he given tag nam
0d20: 65 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 76 6f 69 e..*/.static voi
0d30: 64 20 74 61 67 76 69 65 77 5f 70 61 67 65 5f 74 d tagview_page_t
0d40: 61 67 5f 62 79 5f 6e 61 6d 65 28 20 63 68 61 72 ag_by_name( char
0d50: 20 63 6f 6e 73 74 20 2a 20 74 61 67 6e 61 6d 65 const * tagname
0d60: 20 29 7b 0a 20 20 63 68 61 72 20 2a 7a 53 71 6c ){. char *zSql
0d70: 3b 0a 20 20 40 20 3c 68 32 3e 54 61 67 20 27 25 ;. @ <h2>Tag '%
0d80: 73 28 74 61 67 6e 61 6d 65 29 27 3a 3c 2f 68 32 s(tagname)':</h2
0d90: 3e 0a 20 20 7a 53 71 6c 20 3d 20 6d 70 72 69 6e >. zSql = mprin
0da0: 74 66 28 20 0a 20 20 20 20 22 53 45 4c 45 43 54 tf( . "SELECT
0db0: 20 44 49 53 54 49 4e 43 54 22 0a 20 20 20 20 22 DISTINCT". "
0dc0: 20 20 20 20 20 20 20 6c 69 6e 6b 74 61 67 69 64 linktagid
0dd0: 28 74 2e 74 61 67 69 64 29 20 41 53 20 27 54 61 (t.tagid) AS 'Ta
0de0: 67 20 49 44 27 2c 22 0a 20 20 20 20 22 20 20 20 g ID',". "
0df0: 20 20 20 20 44 41 54 45 54 49 4d 45 28 74 78 2e DATETIME(tx.
0e00: 6d 74 69 6d 65 29 20 41 53 20 27 54 69 6d 65 73 mtime) AS 'Times
0e10: 74 61 6d 70 27 2c 22 0a 20 20 20 20 22 20 20 20 tamp',". "
0e20: 20 20 20 20 6c 69 6e 6b 75 75 69 64 28 62 2e 75 linkuuid(b.u
0e30: 75 69 64 29 20 41 53 20 27 56 65 72 73 69 6f 6e uid) AS 'Version
0e40: 27 22 0a 20 20 20 20 22 20 20 46 52 4f 4d 20 74 '". " FROM t
0e50: 61 67 20 74 2c 20 74 61 67 78 72 65 66 20 74 78 ag t, tagxref tx
0e60: 2c 20 62 6c 6f 62 20 62 20 22 0a 20 20 20 20 22 , blob b ". "
0e70: 20 57 48 45 52 45 20 74 2e 74 61 67 6e 61 6d 65 WHERE t.tagname
0e80: 3d 27 25 71 27 20 41 4e 44 20 74 2e 74 61 67 69 ='%q' AND t.tagi
0e90: 64 3d 74 78 2e 74 61 67 69 64 20 41 4e 44 20 74 d=tx.tagid AND t
0ea0: 78 2e 73 72 63 69 64 3d 62 2e 72 69 64 20 22 0a x.srcid=b.rid ".
0eb0: 20 20 20 20 54 41 47 56 49 45 57 5f 44 45 46 41 TAGVIEW_DEFA
0ec0: 55 4c 54 5f 46 49 4c 54 45 52 0a 20 20 20 20 22 ULT_FILTER. "
0ed0: 20 4f 52 44 45 52 20 42 59 20 74 78 2e 6d 74 69 ORDER BY tx.mti
0ee0: 6d 65 20 44 45 53 43 22 2c 0a 20 20 20 20 74 61 me DESC",. ta
0ef0: 67 6e 61 6d 65 29 3b 0a 20 20 64 62 5f 67 65 6e gname);. db_gen
0f00: 65 72 69 63 5f 71 75 65 72 79 5f 76 69 65 77 28 eric_query_view(
0f10: 7a 53 71 6c 2c 20 31 29 3b 0a 20 20 66 72 65 65 zSql, 1);. free
0f20: 28 7a 53 71 6c 29 3b 0a 7d 0a 0a 0a 2f 2a 0a 2a (zSql);.}.../*.*
0f30: 2a 20 57 45 42 50 41 47 45 3a 20 2f 74 61 67 76 * WEBPAGE: /tagv
0f40: 69 65 77 0a 2a 2f 0a 76 6f 69 64 20 74 61 67 76 iew.*/.void tagv
0f50: 69 65 77 5f 70 61 67 65 28 76 6f 69 64 29 7b 0a iew_page(void){.
0f60: 20 20 6c 6f 67 69 6e 5f 63 68 65 63 6b 5f 63 72 login_check_cr
0f70: 65 64 65 6e 74 69 61 6c 73 28 29 3b 0a 20 20 69 edentials();. i
0f80: 66 28 20 21 67 2e 6f 6b 52 64 57 69 6b 69 20 29 f( !g.okRdWiki )
0f90: 7b 0a 20 20 20 20 6c 6f 67 69 6e 5f 6e 65 65 64 {. login_need
0fa0: 65 64 28 29 3b 0a 20 20 7d 0a 20 20 73 74 79 6c ed();. }. styl
0fb0: 65 5f 68 65 61 64 65 72 28 22 54 61 67 73 22 29 e_header("Tags")
0fc0: 3b 0a 20 20 74 61 67 76 69 65 77 5f 70 61 67 65 ;. tagview_page
0fd0: 5f 73 65 61 72 63 68 5f 6d 69 6e 69 66 6f 72 6d _search_miniform
0fe0: 28 29 3b 0a 20 20 40 20 3c 68 72 2f 3e 0a 20 20 ();. @ <hr/>.
0ff0: 63 68 61 72 20 63 6f 6e 73 74 20 2a 20 63 68 65 char const * che
1000: 63 6b 20 3d 20 30 3b 0a 20 20 69 66 28 20 30 20 ck = 0;. if( 0
1010: 21 3d 20 28 63 68 65 63 6b 20 3d 20 50 28 22 74 != (check = P("t
1020: 61 67 69 64 22 29 29 20 29 7b 0a 20 20 20 20 74 agid")) ){. t
1030: 61 67 76 69 65 77 5f 70 61 67 65 5f 74 61 67 5f agview_page_tag_
1040: 62 79 5f 69 64 28 20 61 74 6f 69 28 63 68 65 63 by_id( atoi(chec
1050: 6b 29 20 29 3b 0a 20 20 7d 65 6c 73 65 20 69 66 k) );. }else if
1060: 28 20 30 20 21 3d 20 28 63 68 65 63 6b 20 3d 20 ( 0 != (check =
1070: 50 28 22 6c 69 6b 65 22 29 29 20 29 7b 0a 20 20 P("like")) ){.
1080: 20 20 74 61 67 76 69 65 77 5f 70 61 67 65 5f 6c tagview_page_l
1090: 69 73 74 5f 74 61 67 73 28 20 63 68 65 63 6b 20 ist_tags( check
10a0: 29 3b 0a 20 20 7d 65 6c 73 65 20 69 66 28 20 30 );. }else if( 0
10b0: 20 21 3d 20 28 63 68 65 63 6b 20 3d 20 50 28 22 != (check = P("
10c0: 6e 61 6d 65 22 29 29 20 29 7b 0a 20 20 20 20 74 name")) ){. t
10d0: 61 67 76 69 65 77 5f 70 61 67 65 5f 74 61 67 5f agview_page_tag_
10e0: 62 79 5f 6e 61 6d 65 28 20 63 68 65 63 6b 20 29 by_name( check )
10f0: 3b 0a 20 20 7d 65 6c 73 65 7b 0a 20 20 20 20 74 ;. }else{. t
1100: 61 67 76 69 65 77 5f 70 61 67 65 5f 64 65 66 61 agview_page_defa
1110: 75 6c 74 28 29 3b 0a 20 20 7d 0a 20 20 73 74 79 ult();. }. sty
1120: 6c 65 5f 66 6f 6f 74 65 72 28 29 3b 0a 7d 0a 0a le_footer();.}..
1130: 23 75 6e 64 65 66 20 54 41 47 56 49 45 57 5f 44 #undef TAGVIEW_D
1140: 45 46 41 55 4c 54 5f 46 49 4c 54 45 52 0a EFAULT_FILTER.