From: <vb...@us...> - 2002-09-09 09:35:14
|
Update of /cvsroot/webnotes/web In directory usw-pr-cvs1:/tmp/cvs-serv15394 Modified Files: cvs_api.php guidelines.php header.php localization.php side_menu.php Log Message: - Added logos and required images. - Added cvs_get_link() API - Updated the guidelines based on Mantis. - Updated the Localisation page. Index: cvs_api.php =================================================================== RCS file: /cvsroot/webnotes/web/cvs_api.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cvs_api.php 8 Sep 2002 12:31:44 -0000 1.1 +++ cvs_api.php 9 Sep 2002 09:35:11 -0000 1.2 @@ -9,8 +9,13 @@ # $Id$ # -------------------------------------------------------- - function cvs_get_file( $p_project, $p_module, $p_file , $p_rev='HEAD' ) { + function cvs_get_link( $p_project, $p_module, $p_file, $p_rev='HEAD' ) { $t_url = "http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/$p_project/$p_module$p_file?rev=$p_rev&content-type=text/vnd.viewcvs-markup"; + return $t_url; + } + + function cvs_get_file( $p_project, $p_module, $p_file , $p_rev='HEAD' ) { + $t_url = cvs_get_link( $p_project, $p_module, $p_file, $p_rev ); $fp = @fopen( $t_url, 'r'); if (!$fp) { Index: guidelines.php =================================================================== RCS file: /cvsroot/webnotes/web/guidelines.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- guidelines.php 8 Sep 2002 06:12:53 -0000 1.3 +++ guidelines.php 9 Sep 2002 09:35:11 -0000 1.4 @@ -1,46 +1,131 @@ -<?php include('header.php') ?> +<?php include( "header.php" ); ?> -<span class="page_title">Coding Conventions</span> -<hr size="1" noshade="noshade" width="100%"> +<span class="page_title">Coding Guidelines</span> +<hr size=1 noshade width="100%" /> -<p>This is the phpWebNotes coding conventions document. It lists all the basic conventions that I have followed in order to make the code easy to read and maintain. ANyone working on the code, adding features, or wanting to send in a patch should take a quick look through this document. Currently the code is very flat and procedure based. A future version may switch to objects at which point some of these conventions may change or be added to.</p> +<p>This is the phpWebNotes coding conventions document. This should assist anyone who wants to modify the code or work on active development. Anyone who wishes to contribute code must adhere to these guidelines. <b>Code not following these conventions will be modified or (in extreme cases) rejected.</b> If you have additional suggestions or a good argument for changing some of these guidelines then <a href="mailto:ke...@30...">send a message</a> or <a href="forums.php">post in the forums</a>.</p> +<p>First, start off by reading the <a href="http://utvikler.start.no/code/php_coding_standard.html"><strong>PHP Coding Standards</strong></a> document. We have deviated in a few places but just about everything in the document applies here as well.</p> +<p>Above all, write code that is easy to read and maintain. Comment blocks of code and functions at all times.</p> -<h3>Naming</h3> +<span class="section">Naming Variables</span> <ul> -<li>Use descriptive names (except loop variables)</li> -<li>Use _ to separate words</li> -<li>Always use lowercase</li> -<li>Use .php for all file extensions. Do not use .inc</li> -<li>Form variables are prefixed with f_</li> -<li>User variables are prefixed with u_</li> -<li>Temporary variables are prefixed with t_M</li> -<li>Function parameters should be prefixed with p_</li> -<li>Global varialbes should be prefixed with g_</li> -<li>Use the v_ prefix for primary purpose variables in a page</li> -<li>$query and $result should be used for SQL query text and results respectively.</li> -<li>Included files should be suffixed by _inc.php</li> -<li>Count variables should follow the format $<what>_count. eg $bug_count.</li> -<li>functions that print should be prefixed with print_.</li> + <li>Use all lower case.</li> + <li>Use _ to separate words. eg. $green_color_value</li> + <li>Use descriptive names (except loop variables).</li> + <li>Loop variables can be of the usual variety: $i, $j, $k, etc.</li> + <li>Count variables should follow the format $*_count. eg $bug_count</li> + <li>Global variables should be prefixed with g_</li> + <li>Temporary variables should be prefixed with t_</li> + <li>Parameters and variables passed from forms that have been cleaned of any special SQL chars (i.e. slashes) should be prefixed with c_</li> + <li>Uncleaned function parameters should be prefixed with p_</li> + <li>Uncleaned variables passed from forms should be prefixed with f_</li> + <li>Other variables are prefixed with v_, v2_, etc</li> + <li>Never prefix with l_ or o_ or q_ (visually confusing)</li> + <li>$query and $result should be used for SQL query and results respectively</li> </ul> -<h3>Formatting</h3> +<span class="section">Naming Functions</span> <ul> -<li>Use TABS with a size of 4 to make the code easily readable while not wasting too much space</li> -<li>Follow the table formatting of existing pages</li> -<li>Break up SQL queries to be easy to read</li> + <li>Use all lower case.</li> + <li>Use _ to separate words. eg. setup_page_breaks()</li> + <li>Keep functions to 5 words or less.</li> + <li>Functions that print should be prefixed with print_.</li> + <li>Try to use prefixes to group functions (i.e., email_, news_, etc)</li> </ul> -<h3>Page Guidelines</h3> +<span class="section">Naming Classes</span> <ul> -<li>The first item should be the copyright notice.</li> -<li>The next line should be a cookie check to see if the user is logged in.</li> -<li>Next should be the majority of the SQL queries for a page.</li> -<li>Next will be the various html print_ functions.</li> -<li>The main body of the page will follow.</li> -<li>At the bottom will be the footer information and closing print_ functions.</li> + <li>Use FirstLetterOfWordIsCaptilized style</li> + <li>Variables that are class objects should have the prefix coo_</li> </ul> -<p><a href="http://utvikler.start.no/code/php_coding_standard.html">PHP Coding Standard</a> has _excellent_ guidelines for php programming style. For the most part I seem to have followed it (except for TABS vs spaces). If something is ambiguous consult this link or email me.</p> -<p>Above all, write code that is easy to read and maintain. Code that is not will be rewritten or deleted. Comment blocks of code and functions at all times. Get onto me if I fail to adhere to my own words.</p> +<span class="section">Naming Files</span> +<ul> + <li>Use all lower case.</li> + <li>Use _ to separate words. eg. view_new_bugs_page.php</li> + <li>Use .php file extensions (previously we used .php or .php3)</li> + <li>Filenames must be less than 32 characters in length. This plays nice with older file systems like MacOS.</li> + <li>Included files should be suffixed by _inc.php</li> +</ul> -<?php include('footer.php') ?> +<span class="section">SQL formatting</span> +<ul> + <li>UPPERCASE all SQL keywords:</li> +<pre> +$query = "SELECT * + FROM $g_my_table + WHERE id='1'"; +</pre> + <li>Always assign a query string to a variable. This makes code easier to debug when problems occur. Do not create the query in the call to the function.</li> + <li>Break up SQL queries over multiple lines to be easy to read.</li> +</ul> + +<span class="section">General Formatting</span> +<ul> + <li>Use TABS with a size of 4 to make the code easily readable while not wasting too much space.</li> + <li>Follow the table formatting of existing pages.</li> + <li>Use <?php ?> for php delimiters.</li> + <li>Try not to print/echo HTML unless it's short or in a function loop</li> + <li>Do not use the EOF construct.</li> +</ul> + +<span class="section">Miscellaneous</span> +<ul> + <li>Don't use the ?: construct. It is confusing and has too much bug potential.</li> + <li>Avoid magic numbers.</li> +</ul> + +<span class="section">Page Guidelines</span> +<ul> + <li>The first item should be the copyright notice</li> + <li>The next line should be a cookie check to see if the user is logged in</li> + <li>Next should be the majority of the SQL queries for a page</li> + <li>Next will be the various thymol print_ functions.</li> + <li>The main body of the page will follow</li> + <li>At the bottom will be the footer information and closing print_ functions.</li> +</ul> + +<span class="section">Braces and Paranthesis</span> +<ul> + <li>Paranthesis should be right after a function name. eg: function() not function ()</li> + <li>Paranthesis should have a space right after a keyword (if, while, for) eg: for (...)</li> + <li>Braces formatting is illustrating below. I don't mind the macthing vertical placement myself but in the interests of conserving some space I have adopted the unmatched placing.</li> +<pre> +for (...) { + blah +} + +or + +if (...) { + blah +} +</pre> + <li>if ... else blocks should be in this format:</li> +<pre> +if (...) { + blah1 +} else { + blah2 +} +</pre> +</ul> + +<span class="section">Comments</span> +<ul> + <li>Use the # symbol for line commenting</li> + <li>Use /* */ for block commenting unless you nest /* */ comments. Generally, only use this during development.</li> + <li>Use @@@ followed by a brief message (BROKEN, TEMPORARY, etc) as a "look at this" indicator. Leaving your name next to it might be a good idea as well. This way critical items can easily be found.</li> +</ul> + +<span class="section">Editor Features</span> +<ul> + <li>Search and replace in multiple files</li> + <li>Goto line number</li> + <li>Syntax highlighting</li> + <li>Adjustable TAB spacing</li> +</ul> + +<span class="section">Credit</span> +<p>These coding conventions were borrowed with minor modifications from <a href="http://mantisbt.sf.net">Mantis</a> project. It was put together mainly by <a href="mailto:ke...@30...">Kenzaburo Ito</a>.</p> +<?php include( "footer.php" ); ?> \ No newline at end of file Index: header.php =================================================================== RCS file: /cvsroot/webnotes/web/header.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- header.php 8 Sep 2002 01:06:41 -0000 1.3 +++ header.php 9 Sep 2002 09:35:11 -0000 1.4 @@ -18,12 +18,12 @@ <body> <table class="outside" cellpadding="0" cellspacing="0"> -<tr class="top"> - <td class="top_left"> +<tr class="top" height="100"> + <td class="top_left" valign="center"> </td> - <td class="top_right"> - <a href="http://webnotes.sourceforge.net/"><img border="0" src="images/banner.gif" alt="" /></a> + <td class="top_right" valign="center"> + <a href="http://webnotes.sourceforge.net/"><img border="0" src="images/banner.gif" alt="phpWebNotes Logo" /></a> </td> <td class="right"> <a href="http://www.google.com/"><img border="0" src="images/google.gif" alt="" /></a> @@ -43,8 +43,8 @@ </td> </tr> <tr valign="top" bgcolor="#ffffff"> - <td class="menu_left"> + <td class="menu_left" width="50"> <? include( "side_menu.php" ); ?> </td> - <td class="main" colspan=2> + <td class="main" colspan="2"> Index: localization.php =================================================================== RCS file: /cvsroot/webnotes/web/localization.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- localization.php 8 Sep 2002 06:12:53 -0000 1.3 +++ localization.php 9 Sep 2002 09:35:11 -0000 1.4 @@ -1,62 +1,35 @@ -<?php include('header.php') ?> <?php + include( 'header.php' ); + require_once( 'cvs_api.php' ); +?> +<?php + function print_lang( $p_language, $p_version, $p_state ) { - $t_file_name = "webnotes/strings_".strtolower( $p_language ).".txt"; - PRINT "<tr bgcolor=#ffffff>"; - PRINT "<td>"; - echo $p_language; - PRINT "</td>"; - PRINT "<td>"; - if ( file_exists( $t_file_name ) ) { - echo date( "M d, Y", filemtime( $t_file_name ) ); - } - PRINT "</td>"; - PRINT "<td>"; - if (( file_exists( $t_file_name ) )&&( $p_state=="active" )) { - PRINT "<a href=\"$t_file_name\">download</a>"; - } else if ( $p_state=="active" ) { - PRINT "in progress"; - } else { - PRINT" "; - } - PRINT "</td>"; + $t_filename = 'strings_' . strtolower( $p_language ) . '.php'; + $t_path = '/lang/' . $t_filename; + $t_link = cvs_get_link( 'webnotes', 'webnotes', $t_path ); + + echo "<li>$p_language (<a href=\"$t_link\" target=\"_new\">$t_filename</a>)</li>"; - PRINT "</tr>"; } ?> <span class="page_title">Localization</span> <hr size="1" noshade="noshade" width="100%"> -<p>Here you can see the latest localization files. Currently we only have English.</p> -<p>What to do if you see some errors? Just <a href="mailto:ke...@30...">send me an email</a> with the corrected strings.</p> +<p>Here you can see the latest localization files.</p> +<p>What to do if you see some errors? Just submit a <a href="bugtracker.php">bug report</a> with the corrected strings.</p> -<div align="center"> -<table width="100%" cellpadding="5" cellspacing="1" bgcolor="#ffffff"> -<tr bgcolor="#ffffff"> - <td> - <strong>Language</strong> - </td> - <td> - <strong>Version</strong> - </td> - <td> - <strong>Date Updated</strong> - </td> - <td> - - </td> -</tr> +<ul> <?php print_lang( "English", "latest", "active" ); print_lang( "French", "latest", "active" ); print_lang( "Italian", "latest", "active" ); ?> -</table> +</ul> +<br /> +<span class="section">Translating</span> +<hr size="1" noshade="noshade" width="100%"> -</div> +<p>Don't see your language? Translate one of the files! It's really quite simple. Just take the strings file and convert away. Then <a href="bugtracker.php">submit it</a> back to me. Also, you can update them when new strings make it in. The file won't change drastically so it shouldn't be too much work to keep the files updated.</p> -<span class="page_title">Translating</span> -<hr size="1" noshade="noshade" width="100%"> -<p>Don't see your language? Translate one of the files! It's really quite simple. Just take the strings file and convert away. Then <a href="mailto:ke...@30...">submit it</a> back to me. Also, you can update them when new strings make it in. The file won't change drastically so it shouldn't be too much work to keep the files updated.</p> -<p>Currently some strings are hard-coded into the database tables or the code. This will be fixed soon.</p> <?php include('footer.php') ?> Index: side_menu.php =================================================================== RCS file: /cvsroot/webnotes/web/side_menu.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- side_menu.php 9 Sep 2002 04:19:57 -0000 1.10 +++ side_menu.php 9 Sep 2002 09:35:11 -0000 1.11 @@ -55,6 +55,7 @@ <br /> <a href="http://sourceforge.net/projects/webnotes/"> <img src="http://sourceforge.net/sflogo.php?group_id=15381" width="88" height="31" border="0" alt="phpWebNotes @ SourceForge"></a><br /> <br /> + <a href="http://sourceforge.net/projects/webnotes/"> <img src="images/phpWebNotes_d8d8ff_icon.gif" width="150" height="39" border="0" alt="phpWebNotes @ SourceForge"></a><br /> </td> </tr> </table> |