From: Buddhika <bu...@us...> - 2005-01-31 06:10:18
|
Update of /cvsroot/sahana/peoplereg/src/php/dataclean In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8473 Added Files: dataclean.php dataclean_top.php inc_dataclean.php index.html main.css Log Message: Added frame support to increase usability and soundex support to group similar words. Enhanced look and feel. --- NEW FILE: dataclean_top.php --- <?php # dataclean_top.php - Clean attribute data. # Copyright : Virtusa Corporation # License : GPL # Author : Buddhika Siddhisena [Bu...@ba...] # Created: 27/01/2005 # Updated: 31/01/2005 # Dont allow directcall. Uses mambo variable #defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); // Site configuration require_once("../common/si...@co...p"); // Database support require_once ("$webroot/common/db...@co...p"); require_once ("inc_dataclean.php"); $db=0;$xdb=1; #local debug options ?> <html> <head><title>Clean up data</title> <link rel="stylesheet" href="main.css" type="text/css"> </head> <body> <table border="0" class="tableASH1_padding"> <form action="dataclean.php" method="post" target="datarea" name="updatefrm"> <tr><td>Please select an attribute to clean data for : </td> <td> <select name="attr" onchange="document.forms[0].submit()"> <option value="">Select one</option> <?=get_attribute($_REQUEST['attr'])?> </select> </td> <td> </td> <td><!-- replace value--> Replace with : <input type="text" name="replace_value"> </td> <td> <input type="submit" value="Modify" onClick="parent.frames['datarea'].document.forms['updatefrm'].replace_value.value=document.forms[0].replace_value.value;parent.frames['datarea'].document.forms['updatefrm'].submit();return false;"></td> </tr> <tr class="tableASH2_padding blk_12px"> <td colspan="5"><a href="dataclean.php#a" target="datarea">A</a> | <a href="dataclean.php#b" target="datarea">B</a> | <a href="dataclean.php#c" target="datarea">C</a> | <a href="dataclean.php#d" target="datarea">D</a> | <a href="dataclean.php#e" target="datarea">E</a> | <a href="dataclean.php#f" target="datarea">F</a> | <a href="dataclean.php#g" target="datarea">G</a> | <a href="dataclean.php#h" target="datarea">H</a> | <a href="dataclean.php#i" target="datarea">I</a> | <a href="dataclean.php#j" target="datarea">J</a> | <a href="dataclean.php#k" target="datarea">K</a> | <a href="dataclean.php#l" target="datarea">L</a> | <a href="dataclean.php#m" target="datarea">M</a> | <a href="dataclean.php#n" target="datarea">N</a> | <a href="dataclean.php#o" target="datarea">O</a> | <a href="dataclean.php#p" target="datarea">P</a> | <a href="dataclean.php#q" target="datarea">Q</a> | <a href="dataclean.php#r" target="datarea">R</a> | <a href="dataclean.php#s" target="datarea">S</a> | <a href="dataclean.php#t" target="datarea">T</a> | <a href="dataclean.php#u" target="datarea">U</a> | <a href="dataclean.php#w" target="datarea">W</a> | <a href="dataclean.php#x" target="datarea">X,Y,Z</a></td> </tr> </form> </table> </body> </html> --- NEW FILE: dataclean.php --- <?php # dataclean.php - Clean attribute data. # Copyright : Virtusa Corporation # License : GPL # Author : Buddhika Siddhisena [Bu...@ba...] # Created: 27/01/2005 # Updated: 30/01/2005 # Dont allow directcall. Uses mambo variable #defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); // Site configuration require_once("../common/si...@co...p"); // Database support require_once ("$webroot/common/db...@co...p"); require_once ("inc_dataclean.php"); $db=0;$xdb=1; #local debug options if(count($_REQUEST['value_string'])>0){ # Call update_data if data is passed update_data($_REQUEST['attr']); } ?> <html> <head><title>Clean up data</title> <link rel="stylesheet" href="main.css" type="text/css"> </head> <body> <?php if($_REQUEST['attr']): ?> <table border=0 width="100%"> <form action="<?=$_SERVER[PHP_SELF]?>" name="updatefrm" method="post"> <tr><td> <!-- attribute value data --> <table border=0 class="bordertext" width="50%"> <tr><th>seq #</th><th>Attribute value</th></tr> <?=list_attr_values($_REQUEST['attr'])?> </table> </td> </tr> <!-- replace value--> <input type="hidden" name="replace_value"><br> <input type="hidden" name="attr" value="<?=$_REQUEST['attr']?>"> </form> </table> <?php endif?> </body> </html> --- NEW FILE: index.html --- <frameset rows="75,*"> <frame name="topbar" src="dataclean_top.php" frameborder="0"> <frame name="datarea" src="dataclean.php" frameborder="0"> </frameset> --- NEW FILE: main.css --- a:link {font-family: Verdana, Tahoma, Arial; text-decoration: none; color: #000000} a:visited {font-family: Verdana, Tahoma, Arial; text-decoration: none; color: #000000} a:hover{font-family: Verdana, Tahoma, Arial; text-decoration: underline} a:active { font-family: Verdana, Tahoma, Arial; text-decoration:underline; color: #CC0000} a:link.rollmnu { font-family: Verdana, Tahoma, Arial; color:#333333; text-decoration: none} a:visited.rollmnu { font-family: Verdana, Tahoma, Arial; color:#333333; text-decoration: none} a:active.rollmnu { font-family: Verdana, Tahoma, Arial; color:#990000; text-decoration: none} a:hover.rollmnu { font-family: Verdana, Tahoma, Arial; color:#990000; text-decoration: none} a:link.rollnews { font-family: Verdana, Tahoma, Arial; color:#333333; text-decoration: none} a:visited.rollnews { font-family: Verdana, Tahoma, Arial; color:#333333; text-decoration: none} a:active.rollnews { font-family: Verdana, Tahoma, Arial; color:#333333; text-decoration: underline} a:hover.rollnews { font-family: Verdana, Tahoma, Arial; color:#333333; text-decoration: underline} a:link.rollreg { font-family: Verdana, Tahoma, Arial; font-size:12px; font-weight:bold; color:#990000; text-decoration: none} a:visited.rollreg { font-family: Verdana, Tahoma, Arial; font-size:12px; font-weight:bold; color:#990000; text-decoration: none} a:active.rollreg { font-family: Verdana, Tahoma, Arial; font-size:12px; font-weight:bold; color:#990000; text-decoration: underline} a:hover.rollreg { font-family: Verdana, Tahoma, Arial; font-size:12px; font-weight:bold; color:#990000; text-decoration: underline} .stylenewshead { font-family: Verdana, Tahoma, Arial; color: #333333;font-size:12px;font-weight:bold; height:20 } .stylemenu_blk { font-family: Verdana, Tahoma, Arial; color: #333333;font-size:11px; font-weight:bold } .stylemenu_rd { font-family: Verdana, Tahoma, Arial; color: #990000;font-size:11px; font-weight:bold } .stylecopyrt_wht { font-family: Verdana, Tahoma, Arial; color: #F3F3F3;font-size:11px; font-weight:bold; height:20 } .stylecopyrt_wht { font-family: Verdana, Tahoma, Arial; color: #CCCCCC;font-size:10px; font-weight:normal; height:20 } .blk_11px { font-family: Verdana,Arial, Helvetica, sans-serif; color:#333333; font-size: 11px; font-style: normal; line-height: normal; } .blk_12px { font-family: Verdana; color:#333333; font-size: 12px } .blk_14px { font-family: Verdana; color:#333333; font-size: 14px } body { font-family: Verdana,Arial, Helvetica, sans-serif; color:#333333; font-size: 11px; } .blk_10 { font-family: Verdana; color:#333333; font-size: 10px} .text10 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-style: normal; line-height: normal; color: #000000; text-decoration: none} .tableASH1_padding { padding:1px; padding-bottom:1px; background-color:#EBEBEB; border-color:#a4a4a4 #a4a4a4 #333333 #333333; border-style:solid; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px} .tableASH2_padding { background-color:#D8D8D8; border-style:solid; border-width:1px;border-color:#333333 #333333 #999999 #999999;} .tableASH3_padding { padding:1px; background-color:#B5B5B5; border-style:solid; border-width:1px;border-color:#999999 #999999 #000000 #000000;} .bordertext { border: 1px solid #B5B5B5; } .linksstyle { padding:1px; padding-bottom:1px; background-color:#EBEBEB; border-color:#a4a4a4 #a4a4a4 #333333 #333333; border-style:solid; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px} --- NEW FILE: inc_dataclean.php --- <?php # inc_dataclean.php - Clean attribute data [include file]. # Copyright : Virtusa Corporation # License : GPL # Author : Buddhika Siddhisena [Bu...@ba...] # Created: 27/01/2005 # Updated: 31/01/2005 function get_attribute($value){ # Get a list of attributes global $conn,$attrtable,$attrtable_fields,$attrvaltable,$attrvaltable_fields; global $attroptiontable,$attroptiontable_fields; $cont=''; $crit="name IN('city','country','race','religion','division','gs_division','village','occupation')"; $sql="select $attrtable_fields from $attrtable where data_type=1 AND $crit order by name"; $rs=mysql_query($sql,$conn); for ($i=0;$i<mysql_num_rows($rs);$i++){ $row=mysql_fetch_array($rs); if($value==$row['id']){ $cont.="<option value=\"$row[id]\" selected>$row[caption]</option>\n"; }else{ $cont.="<option value=\"$row[id]\">$row[caption]</option>\n"; } } return $cont; } function list_attr_values($attrid){ global $conn,$attrtable,$attrtable_fields,$attrvaltable,$attrvaltable_fields; global $attroptiontable,$attroptiontable_fields; $sql="select distinct value_string,soundex(value_string) as soundex_string from $attrvaltable where attribute_id=$attrid order by soundex_string, value_string"; #echo "<br>sql=$sql"; $rs=mysql_query($sql,$conn); if(mysql_num_rows($rs)==0){ print "<tr><td colspan=2>No results found!</td></tr>"; } $rowaltcolor='#EBEBEB'; # Used to alternate colors between rows for ($i=0;$i<mysql_num_rows($rs);$i++){ $row=mysql_fetch_array($rs); if($lastsoundex_string!=$row['soundex_string']){$rowaltcolor=($rowaltcolor=='#D8D8D8')?'#FFFFFF':'#D8D8D8';} $name_value=$row['value_string']; $curstartswith=strtolower(substr($row['value_string'],0,1)); if($startswith!=$curstartswith){$name_value="<a name=\"$curstartswith\">$name_value</a>";} print "<tr class=\"blk_14px \" bgcolor=\"$rowaltcolor\"><td><input type=\"checkbox\" name=\"value_string[]\" value=\"$row[value_string]\"></td><td>$name_value <a href=\"\" onclick=\"parent.frames['topbar'].document.forms['updatefrm'].replace_value.value='$row[value_string]';return false;\" class=\"blk_11px\">copy</a></td></tr>\n"; $startswith=strtolower(substr($row['value_string'],0,1)); # Keep track of when start letter changes to generate index $lastsoundex_string=$row['soundex_string']; } } function update_data($attrid){ global $conn,$attrtable,$attrtable_fields,$attrvaltable,$attrvaltable_fields; global $attroptiontable,$attroptiontable_fields; foreach ($_REQUEST['value_string'] as $value_string){ $sql="update $attrvaltable set value_string='$_REQUEST[replace_value]' where value_string='$value_string' and attribute_id=$attrid"; #print "<br>sql=$sql"; mysql_query($sql); } } ?> |