From: <pre...@us...> - 2002-09-05 03:38:05
|
Update of /cvsroot/mantisbt/manual In directory usw-pr-cvs1:/tmp/cvs-serv22398 Modified Files: core.php tags.php Log Message: added Wiki style linking Index: core.php =================================================================== RCS file: /cvsroot/mantisbt/manual/core.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- core.php 5 Sep 2002 01:48:36 -0000 1.3 +++ core.php 5 Sep 2002 03:38:00 -0000 1.4 @@ -84,8 +84,10 @@ } # --- --- function get_static_menu_parents( $p_id ) { + global $g_table_name; + $query = "SELECT * - FROM item_table + FROM $g_table_name WHERE item_id='$p_id'"; $result = mysql_query( $query ); $row = mysql_fetch_array( $result ); @@ -96,7 +98,7 @@ while ( 0 != $parent_id ) { $p_id = $parent_id; $query = "SELECT * - FROM item_table + FROM $g_table_name WHERE item_id='$p_id'"; $result = mysql_query( $query ); $row = mysql_fetch_array( $result ); @@ -114,6 +116,8 @@ } # --- --- function get_static_menu_siblings( $p_id ) { + global $g_table_name; + if ( 1 == $p_id ) { return ''; } @@ -121,7 +125,7 @@ $parent_id = get_parent_id( $p_id ); $query = "SELECT * - FROM item_table + FROM $g_table_name WHERE parent_id='$parent_id'"; $result = mysql_query( $query ); $sibling_count = mysql_num_rows( $result ); @@ -147,8 +151,10 @@ # creates the filename # @@@ HACK: we use the item_title if the filename is blank. function create_filename( $p_id ) { + global $g_table_name; + $query = "SELECT * - FROM item_table + FROM $g_table_name WHERE item_id='$p_id'"; $result = mysql_query( $query ); $row = mysql_fetch_array( $result ); @@ -163,7 +169,7 @@ while ( 0 != $parent_id ) { $p_id = $parent_id; $query = "SELECT * - FROM item_table + FROM $g_table_name WHERE item_id='$p_id'"; $result = mysql_query( $query ); $row = mysql_fetch_array( $result ); @@ -183,6 +189,7 @@ return $t_file; } # --- --- + # print the option list to select the parent function parent_option_list( $p_parent_id ) { global $g_table_name; @@ -204,7 +211,6 @@ } } - # --- algorithm to bump the id list when a new one is inserted --- function update_item_order( $p_parent_id, $p_item_order, $p_item_id ) { global $g_table_name; @@ -216,12 +222,37 @@ parent_id='$p_parent_id'"; $result = mysql_query( $query ); } + # --- wiki link detector --- + function item_exists( $p_text ) { + global $g_table_name; + $query = "SELECT * + FROM $g_table_name + WHERE item_title='$p_text' OR + item_id='$p_text'"; + $result = mysql_query( $query ); + $item_count = mysql_num_rows( $result ); + if ( $item_count > 0 ) { + return mysql_fetch_array( $result ); + } else { + return 0; + } + } + # --- wiki link detector --- + function process_wiki_link( $p_text ) { + $t_row = item_exists( $p_text ); + if ( 0 != $t_row ) { + extract( $t_row ); + $t_filename = create_filename( $item_id ); + return '<a href="$t_filename">'.$item_title.'</a>'; + } else { + return ''; + } + } # --- helper function for our regexes --- function process_tag_output( $p_text, $p_tag ) { return "<".$p_tag." ".str_replace( """, "\"", $p_text ).">"; } - # --- all the main work is done here --- function process_output( $p_text ) { $p_text = stripslashes( $p_text ); @@ -270,6 +301,8 @@ $p_text = str_replace( "\t", ' ', $p_text ); # tables + $p_text = preg_replace( "/\[\[(.*)\]\]/Ue", "process_wiki_link('\\1')", $p_text ); + $p_text = preg_replace( "/\[table\]/U", '<table>', $p_text ); $p_text = preg_replace( "/\[table (.*)\]/Ue", "process_tag_output('\\1','table')", $p_text ); $p_text = preg_replace( "/\[\/table\]/U", '</table>', $p_text ); Index: tags.php =================================================================== RCS file: /cvsroot/mantisbt/manual/tags.php,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tags.php 31 Aug 2002 23:02:23 -0000 1.2 +++ tags.php 5 Sep 2002 03:38:00 -0000 1.3 @@ -219,6 +219,17 @@ </td> </tr> <tr> + <td class="markup1"> + <a href="appendix.php">Appendix</a> + </td> + <td class="markup2"> + [[Appendix]] + </td> + <td class="markup3"> + This is Wiki style linking for linking to other items in the manual. Note that this means Item Titles should always be unique. Use the double square brackets to link by Item Title or by Item ID. + </td> +</tr> +<tr> <th colspan="3" class='subcategory'>Blocks</th> </tr> <tr> @@ -306,7 +317,7 @@ </div> </td> <td class="markup3"> - Basically you just create tables like nroma except use [ and ] insttead of < and >. + Basically you just create tables like normal except use [ and ] insttead of < and >. </td> </tr> </table> |