From: <vb...@us...> - 2002-09-20 02:48:50
|
Update of /cvsroot/webnotes/webnotes/themes/phpnet In directory usw-pr-cvs1:/tmp/cvs-serv20300/themes/phpnet Modified Files: theme_api.php Log Message: - Changed the way the schemes are structure to accept one array which has all information rather than header, note, footer. - Remove the handling of finding out the prev / next page names/urls from the theme to the core. - Added page_prepare_theme_data() which prepares all the information to be used by the scheme into one array. The theme should never need to access the database. - Removed the row which has the add / help icons from the footer when there is no notes in the page. - Added source forge logo to the XHTML sample. Index: theme_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/themes/phpnet/theme_api.php,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- theme_api.php 19 Sep 2002 22:50:39 -0000 1.16 +++ theme_api.php 20 Sep 2002 02:48:47 -0000 1.17 @@ -29,195 +29,186 @@ return (1); } - # This function is called before printing any notes to the page. - function theme_notes_start( $p_page, $p_url, $p_preview = false ) { - global $g_note_add_page, $s_add_note_link, $s_manage, $s_admin, $g_web_directory, $g_theme; + # This function is called if the current page was not indexed + function theme_not_indexed( $p_page ) { + } - $c_url = urlencode( $p_url ); - $t_page_id = page_get_id( $p_page ); + function theme_output( $p_page_data ) { + global $g_note_add_page, $s_add_note_link, $s_manage, $s_admin, $g_web_directory, +$g_theme; + + $t_notes = $p_page_data['notes']; + $t_page = $p_page_data['page']; + $t_url = $p_page_data['url']; + + $c_url = urlencode( $t_url ); + $t_page_id = $p_page_data['id']; $t_images_base = $g_web_directory . 'themes/' . $g_theme . '/images/'; $add_picture = $t_images_base . 'notes_add.gif'; $help_picture = $t_images_base . 'notes_about.gif'; - - if ( !$p_preview ) { + $prev_picture = $t_images_base . 'caret_left.gif'; + $next_picture = $t_images_base . 'caret_right.gif'; + + if ( false === $p_page_data['preview'] ) { $t_link_start = "<a href=\"$g_note_add_page?f_page_id=$t_page_id&f_url=$c_url\">"; $t_link_end = '</a>'; } else { $t_link_start = $t_link_end = ''; } + # + # HEADER + # + echo <<<EOT <table summary="" border="0" cellpadding="4" cellspacing="0" width="100%"> <tr bgcolor="#d0d0d0" valign="top"> - <td><small>User Contributed Notes</small><br /><strong>$p_page</strong></td> + <td><small>User Contributed Notes</small><br /><strong>$t_page</strong></td> <td align="right"> $t_link_start<img src="$add_picture" border="0" width="13" height="13" alt="Add Notes" />$t_link_end <img src="$help_picture" border="0" width="13" height="13" alt="About Notes" /> </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_url, $p_note_info_array, $p_preview = false ) { - $t_moderation = ''; - - if ( false === $p_preview ) { - if ( access_check_action( ACTION_NOTES_MODERATE ) ) { - $t_url = $p_url; # . "#" . $p_note_info_array['id']; - $t_moderation = '<small>'; + # + # NOTES + # - $t_moderation .= link_note_action( $p_note_info_array['id'], 'accept', $t_url, - access_check_action( ACTION_NOTES_MODERATE_ACCEPT ) ) . ' '; + if ( 0 === count( $t_notes ) ) { + echo <<<EOT + <tr valign="top"> + <td bgcolor="#e0e0e0" colspan="2">There are no user contributed notes for this page.</td> + </tr> + </table> +EOT; + } else { + for ( $i = 0; $i < count( $t_notes ); $i++ ) { + $t_moderation = ''; + $t_note_info = $t_notes[$i]; - $t_moderation .= link_note_action( $p_note_info_array['id'], 'decline', $t_url, - access_check_action( ACTION_NOTES_MODERATE_DECLINE ) ) . ' '; + if ( false === $p_page_data['preview'] ) { + if ( access_check_action( ACTION_NOTES_MODERATE ) ) { + $t_url = $p_url; # . "#" . $p_note_info_array['id']; + $t_moderation = '<small>'; - $t_moderation .= link_note_action( $p_note_info_array['id'], 'archive', $t_url, - access_check_action( ACTION_NOTES_MODERATE_ARCHIVE ) ) . ' '; + $t_moderation .= link_note_action( $t_note_info['id'], 'accept', $t_url, + access_check_action( ACTION_NOTES_MODERATE_ACCEPT ) ) . ' '; - $t_moderation .= link_note_action( $p_note_info_array['id'], 'delete', $t_url, - access_check_action( ACTION_NOTES_MODERATE_DELETE ) ); + $t_moderation .= link_note_action( $t_note_info['id'], 'decline', $t_url, + access_check_action( ACTION_NOTES_MODERATE_DECLINE ) ) . ' '; - $t_moderation .= '</small>'; - } - } + $t_moderation .= link_note_action( $t_note_info['id'], 'archive', $t_url, + access_check_action( ACTION_NOTES_MODERATE_ARCHIVE ) ) . ' '; - if ( isset( $p_note_info_array['id'] ) && ( $p_note_info_array['id'] != 0 ) ) { - $t_id = '#' . (integer)$p_note_info_array['id']; - $t_visibility = ''; - if ( NOTE_VISIBLE_ACCEPTED != $p_note_info_array['visible'] ) { - $t_visibility = '(' . note_get_visibility_str( $p_note_info_array['visible'] ) . ') - '; - } - $t_id_view = "<pre>$t_visibility$t_id<br />$t_moderation</pre>"; - $t_id_bookmark = "<a name=\"$t_id\"></a>"; - } else { - $t_id_view = ' '; - $t_id_bookmark = ''; - } + $t_moderation .= link_note_action( $t_note_info['id'], 'delete', $t_url, + access_check_action( ACTION_NOTES_MODERATE_DELETE ) ); - if ( isset( $p_note_info_array['email'] ) ) { - $t_email = $p_note_info_array['email']; - } else { - $t_email = ''; - } + $t_moderation .= '</small>'; + } + } - if ( isset( $p_note_info_array['date'] ) ) { - $t_date = $p_note_info_array['date']; - } else { - $t_date = ''; - } + if ( isset( $t_note_info['id'] ) && ( $t_note_info['id'] != 0 ) ) { + $t_id = '#' . (integer)$t_note_info['id']; + $t_visibility = ''; + if ( NOTE_VISIBLE_ACCEPTED != $t_note_info['visible'] ) { + $t_visibility = '(' . note_get_visibility_str( $t_note_info['visible'] ) . ') - '; + } + $t_id_view = "<pre>$t_visibility$t_id<br />$t_moderation</pre>"; + $t_id_bookmark = "<a name=\"$t_id\"></a>"; + } else { + $t_id_view = ' '; + $t_id_bookmark = ''; + } - if ( isset( $p_note_info_array['note'] ) ) { - $t_note = '<pre>' . $p_note_info_array['note'] . '</pre>'; - } else { - $t_note = ' '; - } + if ( isset( $t_note_info['email'] ) ) { + $t_email = $t_note_info['email']; + } else { + $t_email = ''; + } - echo <<<EOT - <tr valign="top"> - <td bgcolor="#e0e0e0" colspan="2"> - $t_id_bookmark + if ( isset( $t_note_info['date'] ) ) { + $t_date = $t_note_info['date']; + } else { + $t_date = ''; + } - <table summary="" border="0" cellpadding="2" cellspacing="0" width="100%"> - <tr valign="top" bgcolor="#e0e0e0"> - <td><strong>$t_email</strong><br />$t_date</td> - <td align="right">$t_id_view</td> - </tr> - <tr bgcolor="#f0f0f0"> - <td colspan="2">$t_note</td> - </tr> - </table> - </td> - </tr> -EOT; - } + if ( isset( $t_note_info['note'] ) ) { + $t_note = '<pre>' . $t_note_info['note'] . '</pre>'; + } else { + $t_note = ' '; + } - # This function is called after all notes are echo'ed. - function theme_notes_end( $p_page, $p_url, $p_preview = false ) { - global $g_note_add_page, $g_web_directory, $g_theme; + echo <<<EOT + <tr valign="top"> + <td bgcolor="#e0e0e0" colspan="2"> + $t_id_bookmark - $c_url = urlencode( $p_url ); - $t_page_id = page_get_id( $p_page ); + <table summary="" border="0" cellpadding="2" cellspacing="0" width="100%"> + <tr valign="top" bgcolor="#e0e0e0"> + <td><strong>$t_email</strong><br />$t_date</td> + <td align="right">$t_id_view</td> + </tr> + <tr bgcolor="#f0f0f0"> + <td colspan="2">$t_note</td> + </tr> + </table> + </td> + </tr> +EOT; + } + } - $t_images_base = $g_web_directory . 'themes/' . $g_theme . '/images/'; - $add_picture = $t_images_base . 'notes_add.gif'; - $help_picture = $t_images_base . 'notes_about.gif'; - $prev_picture = $t_images_base . 'caret_left.gif'; - $next_picture = $t_images_base . 'caret_right.gif'; - - # @@@@ Should move outside the theme - $t_page = page_get_info( page_where_id_equals( $t_page_id ) ); - $t_prev_page = page_get_info( page_where_id_equals( $t_page['prev_id'] ) ); - $t_next_page = page_get_info( page_where_id_equals( $t_page['next_id'] ) ); + # + # FOOTER + # - if ( false === $t_prev_page ) { - $t_prev_text = ''; + if ( empty( $p_page_data['prev_page'] ) ) { + $t_prev_text = ''; } else { - $t_prev_text = "<img src=\"$prev_picture\" border=\"0\" width=\"11\" height=\"7\" alt=\"" . $t_prev_page['page'] . "\" />" . - link_create( $t_prev_page['url'], $t_prev_page['page'], true, '', '' ); + $t_prev_text = "<img src=\"$prev_picture\" border=\"0\" width=\"11\" height=\"7\" alt=\"" . $p_page_data['prev_page'] . "\" />" . + link_create( $p_page_data['prev_url'], $p_page_data['prev_page'], true, '', '' ); } - if ( false === $t_next_page ) { - $t_next_text = ''; + if ( empty( $p_page_data['next_page' ] ) ) { + $t_next_text = ''; } else { - $t_next_text = link_create( $t_next_page['url'], $t_next_page['page'], true, '', '' ) . - "<img src=\"$next_picture\" border=\"0\" width=\"11\" height=\"7\" alt=\"" . $t_next_page['page'] . "\" />"; + $t_next_text = link_create( $p_page_data['next_url'], $p_page_data['next_page'], true, '', '' ) . + "<img src=\"$next_picture\" border=\"0\" width=\"11\" height=\"7\" alt=\"" . $p_page_data['next_page'] . "\" />"; } if ( empty( $t_prev_text ) && empty( $t_next_text ) ) { - $t_navigation_row = ''; + $t_navigation_row = ''; } else { $t_navigation_row = "<tr><td>$t_prev_text</td><td align=\"right\">$t_next_text</td></tr>"; } - if ( !$p_preview ) { + if ( !$p_page_data['preview'] ) { $t_link_start = "<a href=\"$g_note_add_page?f_page_id=$t_page_id&f_url=$c_url\">"; $t_link_end = '</a>'; } else { $t_link_start = $t_link_end = ''; } + if ( 0 !== count( $t_notes ) ) { + echo <<<EOT + <tr bgcolor="#d0d0d0" valign="top"> + <td colspan="2" align="right"> + $t_link_start<img src="$add_picture" border="0" width="13" height="13" alt="Add Notes" />$t_link_end + <img src="$help_picture" border="0" width="13" height="13" alt="About Notes" /> + </td> + </tr> + </table> +EOT; + } + echo <<<EOT - <tr bgcolor="#d0d0d0" valign="top"> - <td colspan="2" align="right"> - $t_link_start<img src="$add_picture" border="0" width="13" height="13" alt="Add Notes" />$t_link_end - <img src="$help_picture" border="0" width="13" height="13" alt="About Notes" /> - </td> - </tr> - </table> <table border="0" width="100%" bgcolor="#e0e0e0" cellpadding="0" cellspacing="4"> $t_navigation_row <tr bgcolor="#cccccc"><td colspan="2"></td></tr> <tr><td align="right" colspan="2"><small>Last updated: Tue, 17 Sep 2002</small></td></tr> </table> EOT; -# </td></tr></table></td></tr></table> -# <img src="/gifs/caret-r.gif" border="0" width="11" height="7" ALT="next" /> -# <img src="/gifs/spacer.gif" width="1" height="1" border="0" alt="" /> - } - - # 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, $p_url ) { - theme_notes_start( $p_page, $p_url ); - - echo <<<EOT - <tr valign="top"> - <td bgcolor="#e0e0e0" colspan="2">There are no user contributed notes for this page. - </td> - </tr> - </table> -EOT; - theme_notes_end( $p_page, $p_url ); - } - - # This function is called if the current page was not indexed - function theme_not_indexed( $p_page ) { } ?> |