@@ -1514,168 +1514,5 @@
}
}else{
usage("?PROPERTY? ?VALUE?");
}
-}
-
-/*
-** SQL function to render a UUID as a hyperlink to a page describing
-** that UUID.
-*/
-static void hyperlinkUuidFunc(
- sqlite3_context *pCxt, /* function context */
- int argc, /* number of arguments to the function */
- sqlite3_value **argv /* values of all function arguments */
-){
- const char *zUuid; /* The UUID to render */
- char *z; /* Rendered HTML text */
-
- zUuid = (const char*)sqlite3_value_text(argv[0]);
- if( g.okHistory && zUuid && strlen(zUuid)>=10 ){
- z = mprintf("<tt><a href='%s/info/%t'><span style='font-size:1.5em'>"
- "%#h</span>%h</a></tt>",
- g.zBaseURL, zUuid, 10, zUuid, &zUuid[10]);
- sqlite3_result_text(pCxt, z, -1, free);
- }else{
- sqlite3_result_text(pCxt, zUuid, -1, SQLITE_TRANSIENT);
- }
-}
-
-/*
-** SQL function to render a TAGID as a hyperlink to a page describing
-** that tag.
-*/
-static void hyperlinkTagidFunc(
- sqlite3_context *pCxt, /* function context */
- int argc, /* number of arguments to the function */
- sqlite3_value **argv /* values of all function arguments */
-){
- int tagid; /* The tagid to render */
- char *z; /* rendered html text */
-
- tagid = sqlite3_value_int(argv[0]);
- if( g.okHistory ){
- z = mprintf("<a href='%s/tagview?tagid=%d'>%d</a>",
- g.zBaseURL, tagid, tagid);
- }else{
- z = mprintf("%d", tagid);
- }
- sqlite3_result_text(pCxt, z, -1, free);
-}
-
-/*
-** SQL function to render a TAGNAME as a hyperlink to a page describing
-** that tag.
-*/
-static void hyperlinkTagnameFunc(
- sqlite3_context *pCxt, /* function context */
- int argc, /* number of arguments to the function */
- sqlite3_value **argv /* values of all function arguments */
-){
- const char *zTag; /* The tag to render */
- char *z; /* rendered html text */
-
- zTag = (const char*)sqlite3_value_text(argv[0]);
- if( g.okHistory ){
- z = mprintf("<a href='%s/tagview?name=%T&raw=y'>%h</a>",
- g.zBaseURL, zTag, zTag);
- }else{
- z = mprintf("%h", zTag);
- }
- sqlite3_result_text(pCxt, z, -1, free);
-}
-
-/*
-** SQL function to escape all characters in a string that have special
-** meaning to HTML.
-*/
-static void htmlizeFunc(
- sqlite3_context *pCxt, /* function context */
- int argc, /* number of arguments to the function */
- sqlite3_value **argv /* values of all function arguments */
-){
- const char *zText; /* Text to be htmlized */
- char *z; /* rendered html text */
-
- zText = (const char*)sqlite3_value_text(argv[0]);
- z = htmlize(zText, -1);
- sqlite3_result_text(pCxt, z, -1, free);
-}
-
-/*
-** This routine is a helper to run an SQL query and table-ize the
-** results.
-**
-** The zSql parameter should be a single, complete SQL statement.
-** Tableized output of the SQL statement is rendered back to the client.
-**
-** The isSafe flag is true if all query results have been processed
-** by routines such as
-**
-** linkuuid()
-** linktagid()
-** linktagname()
-** htmlize()
-**
-** and are therefore safe for direct rendering. If isSafe is false,
-** then all characters in the query result that have special meaning
-** to HTML are escaped.
-**
-** Returns SQLITE_OK on success and any other value on error.
-*/
-int db_generic_query_view(const char *zSql, int isSafe){
- sqlite3_stmt *pStmt;
- int rc;
- int nCol, i;
- int nRow;
- const char *zRow;
- static int once = 1;
-
- /* Install the special functions on the first call to this routine */
- if( once ){
- once = 0;
- sqlite3_create_function(g.db, "linkuuid", 1, SQLITE_UTF8, 0,
- hyperlinkUuidFunc, 0, 0);
- sqlite3_create_function(g.db, "linktagid", 1, SQLITE_UTF8, 0,
- hyperlinkTagidFunc, 0, 0);
- sqlite3_create_function(g.db, "linktagname", 1, SQLITE_UTF8, 0,
- hyperlinkTagnameFunc, 0, 0);
- sqlite3_create_function(g.db, "htmlize", 1, SQLITE_UTF8, 0,
- htmlizeFunc, 0, 0);
- }
-
- /*
- ** Use sqlite3_stmt directly rather than going through db_prepare(),
- ** so that we can treat errors a non-fatal.
- */
- rc = sqlite3_prepare(g.db, zSql, -1, &pStmt, 0);
- if( SQLITE_OK != rc ){
- @ <span style='color:red'>db_generic_query_view() SQL error:
- @ %h(sqlite3_errmsg(g.db))</span>
- return rc;
- }
- nCol = sqlite3_column_count(pStmt);
- @ <table class='fossil_db_generic_query_view'><tbody>
- @ <tr class='header'>
- for(i=0; i<nCol; ++i){
- @ <td>%h(sqlite3_column_name(pStmt,i))</td>
- }
- @ </tr>
-
- nRow = 0;
- while( SQLITE_ROW==sqlite3_step(pStmt) ){
- const char *azClass[] = { "even", "odd" };
- @ <tr class='%s(azClass[(nRow++)&1])'>
- for(i=0; i<nCol; i++){
- zRow = (char const*)sqlite3_column_text(pStmt,i);
- if( isSafe ){
- @ <td>%s(zRow)</td>
- }else{
- @ <td>%h(zRow)</td>
- }
- }
- @ </tr>
- }
- @ </tbody></table>
- sqlite3_finalize(pStmt);
- return SQLITE_OK;
}