From: <vb...@us...> - 2002-09-09 11:24:33
|
Update of /cvsroot/webnotes/webnotes/themes/phpnet In directory usw-pr-cvs1:/tmp/cvs-serv29798/themes/phpnet Modified Files: theme_api.php Log Message: Committed changes supplied by rmetira: - Added the note id to the variables sent to the theme. - Added the first version of phpnet theme. - Change the sample files/doc to require_once() rather than include the API. Index: theme_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/themes/phpnet/theme_api.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- theme_api.php 5 Sep 2002 03:19:35 -0000 1.1 +++ theme_api.php 9 Sep 2002 11:24:31 -0000 1.2 @@ -1,4 +1,4 @@ -<?php +<? # phpWebNotes - a php based note addition system # Copyright (C) 2000 Kenzaburo Ito - ke...@30... # 2002 Webnotes Team - web...@so... @@ -9,39 +9,141 @@ # $Id$ # -------------------------------------------------------- + ######################################################################### + # This is an empty template to be used to create new themes. + # To create a new theme, please follow the following steps: + # - Create a directory under the themes directory with the theme name. + # - Make a copy of this file under the new theme directory + # - Assign $g_theme to the theme name (not the full path) in + # core/custom_config_inc.php + ######################################################################### + + # The path to the api.php is calculated assume this file resides in a sub-directory + # under themes. For example, themes/phpnet/. + require_once ( dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR . + 'core' . DIRECTORY_SEPARATOR . 'api.php' ); + + # Identifies the version of the theme. This will allow the phpWebNotes + # engine in the future to support themes that are designed for older + # versions of phpWebNotes. + function theme_version() { + return (1); + } + # This function is called before printing any notes to the page. function theme_notes_start( $p_page ) { -?> - <table border="0" cellpadding="4" cellspacing="0" width="100%"> - <tr bgcolor="#d0d0d0" valign="top"> - <td><small>User Contributed Notes</small><br /><b><?php echo $p_page; ?></b></td> - </tr> -<? + global $g_note_add_page, $s_add_note_link, $s_manage, $s_admin, $g_web_directory, $g_theme; + + if ( isset( $p_page ) ) { + $t_page = basename( $p_page ); + } else { + $t_page = "Test Page"; + } + + $c_url = urlencode( $p_page ); + $t_page_id = get_page_id( $p_page ); + + #$path = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR; + #$image = $path .'notes_add.gif'; + + $url = $g_web_directory . '/themes/' . $g_theme . '/images/'; + $add_picture = $url . 'notes_add.gif'; + + echo <<<EOT + <table border="0" cellpadding="4" cellspacing="0" width="100%"> + <tr bgcolor="#d0d0d0" valign="top"> + <td>User Contributed Notes<br /><b>$p_page</b></td> + <td align="right"><a href="$g_note_add_page?f_page_id=$t_page_id&f_url=$c_url"> + <img src="$add_picture" border="0" width="13" height="13" ALT="add a note"/></a> + </td> + </tr> +EOT; } + # This function is called for every note. The note information # are all included in the associative array that is passed to the # function. The theme should check that a field is defined in # the array before using it. - function theme_notes_echo( $p_page, $p_note_info_array ) { - echo '<hr />'; - #echo '<table border="0" cellpadding="2" cellspacing="0" width="100%">'; - echo '<tr align="top" bgcolor="#e0e0e0">'; - echo '<td><b>'.$p_note_info_array['email'].'</b><br />'.$p_note_info_array['submit_date']; - echo '</td></tr>'; - echo '<tr bgcolor="#f0f0f0">'; - echo '<td colspan="2">'.nl2br($p_note_info_array['note']); - echo '</td></tr>'; + function theme_notes_echo( $p_page, $p_note_info_array ) { + + if ( isset( $p_note_info_array['id'] ) ) { + $t_id = (integer)$p_note_info_array['id']; + } else { + $t_id = ''; + } + + if ( isset( $p_note_info_array['email'] ) ) { + $t_email = $p_note_info_array['email']; + } else { + $t_email = ''; + } + + if ( isset( $p_note_info_array['date'] ) ) { + $t_date = $p_note_info_array['date']; + } else { + $t_date = ''; + } + + if ( isset( $p_note_info_array['note'] ) ) { + $t_note = $p_note_info_array['note']; + } else { + $t_note = ''; + } + + echo <<<EOT + <tr valign="top"> + <td bgcolor="#e0e0e0" colspan="2"> + <a name="#$t_id"></a> + + <table border="0" cellpadding="2" cellspacing="0" width="100%"> + <tr align="top" bgcolor="#e0e0e0"> + <td><b>$t_email</b><br/>$t_date</td> + <td align="right">#$t_id</td> + </tr> + <tr bgcolor="#f0f0f0"> + <td colspan="2"><code class="note">$t_note</code></td> + </tr> + </table> + </td> + </tr> +EOT; } # This function is called after all notes are echo'ed. function theme_notes_end( $p_page ) { - echo '</table>'; + global $g_note_add_page, $g_web_directory, $g_theme; + + if ( isset( $p_page ) ) { + $t_page = basename( $p_page ); + } else { + $t_page = "Test Page"; + } + + $c_url = urlencode( $p_page ); + $t_page_id = get_page_id( $p_page ); + + $url = $g_web_directory . '/themes/' . $g_theme . '/images/'; + $add_picture = $url . 'notes_add.gif'; + + echo <<<EOT + <tr bgcolor="#d0d0d0" valign="top"> + <td colspan="2" align="right"><a href="$g_note_add_page?f_page_id=$t_page_id&f_url=$c_url"> + <img src="$add_picture" border="0" width="13" height="13" ALT="add a note"/> + </a></td> + </tr> + </table> +EOT; } # This function is called if the current page has no notes associated # with it. In this case theme_notes_start() and theme_notes_end() # APIs are not called. function theme_notes_none( $p_page ) { - echo "Notes_none"; + theme_notes_start( $p_page ); + theme_notes_end( $p_page ); } -?> + + # This function is called if the current page was not indexed + function theme_not_indexed( $p_page ) { + } +?> \ No newline at end of file |