관리-도구
편집 파일: function.php
<?php function getFeatures($arrFeatures=null){ global $db ; $tbl_start = "<table width=\"527\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> \n"; $tbl_end = "\n</table>\n" ; $tbl_detail =<<<layout <td align="left" valign="top" class="normaltext"> <label> <input type="checkbox" name="chek[]" value="\$valueid" id="checkbox\$valueid" \$checked/> </label> \$description </td> layout; $sql = "select * from features order by featureid asc" ; $rs = $db->Execute($sql); $outdetail = ""; $i = 1 ; while (!$rs->EOF) { $template = $tbl_detail ; $template = str_replace("\$valueid", $rs->fields['featureid'], $template); $template = str_replace("\$description", $rs->fields['description'], $template); $template = str_replace("\$checked", "", $template); //echo $template ; if( $i % 2 ) { $outdetail .= "\n<tr>\n" . $template ; } else { $outdetail .= $template ."\n</tr>\n" ; } $i++; $rs->MoveNext(); } echo $tbl_start.$outdetail.$tbl_end; } /* getFeaturesByVenue takes the saved array of features retrieved by the venue ID and renders it on the page for editing */ function getFeaturesByVenue($arrFeatures ){ global $db ; $tbl_start = "<table width=\"527\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> \n"; $tbl_end = "\n</table>\n" ; $tbl_detail =<<<layout <td align="left" valign="top" class="normaltext"> <label> <input type="checkbox" name="chek[]" value="\$valueid" id="checkbox\$valueid" \$checked/> </label> \$description </td> layout; $sql = "select * from features order by featureid asc" ; $rs = $db->Execute($sql); $outdetail = ""; $i = 1 ; while (!$rs->EOF) { $template = $tbl_detail ; $template = str_replace("\$valueid", $rs->fields['featureid'], $template); $template = str_replace("\$description", $rs->fields['description'], $template); if (in_array($rs->fields['featureid'], $arrFeatures)) { $template = str_replace("\$checked", "CHECKED", $template); }else{ $template = str_replace("\$checked", "", $template); } //echo $template ; if( $i % 2 ) { $outdetail .= "\n<tr>\n" . $template ; } else { $outdetail .= $template ."\n</tr>\n" ; } $i++; $rs->MoveNext(); } echo $tbl_start.$outdetail.$tbl_end; } /** * word-sensitive substring function with html tags awareness * @param text The text to cut * @param len The maximum length of the cut string * @returns string **/ function substrws( $text, $len=180 ) { if( (strlen($text) > $len) ) { $whitespaceposition = strpos($text," ",$len)-1; if( $whitespaceposition > 0 ) $text = substr($text, 0, ($whitespaceposition+1)); // close unclosed html tags if( preg_match_all("|<([a-zA-Z]+)>|",$text,$aBuffer) ) { if( !empty($aBuffer[1]) ) { preg_match_all("|</([a-zA-Z]+)>|",$text,$aBuffer2); if( count($aBuffer[1]) != count($aBuffer2[1]) ) { foreach( $aBuffer[1] as $index => $tag ) { if( empty($aBuffer2[1][$index]) || $aBuffer2[1][$index] != $tag) $text .= '</'.$tag.'>'; } } } } } if (strlen($text) > $len) { return $text."..."; }else{ return $text; } } function getVenues(){ global $db ; $tbl_start = "<table class=\"tbvenue\" width=\"575\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\"> \n"; $tbl_end =<<<layout <tr> <td width="140" align="left" valign="top"><label></label></td> <td align="left" valign="top"><label></label></td> </tr> <tr> <td width="140" align="left" valign="top"><label></label></td> <td align="left" valign="top"><label></label></td> </tr> </table> layout; $tbl_detail =<<<layout <tr> <td width="140" align="left" valign="top"><label> </label><img src="\$venueimagepath" width="144" height="180" /> </td> <td width="435" align="left" valign="top" class="normaltext"><label> </label> <a href="\$venueurl">\$venuename</a><br /> \$briefdesc <br><br> <a href="#" onclick="venueupdate('\$venueid'); return false;">view</a> | <a href="#" onclick="venuedelete('\$venueid'); return false;">delete</a> </td> </tr> layout; $sql = "select * from venues order by venueid" ; $rs = $db->Execute($sql); $outdetail = ""; while (!$rs->EOF) { $template = $tbl_detail ; $template = str_replace("\$venueimagepath", "http://www.finestweddingsites.com/admin/venueimg/" . $rs->fields['venueimg'], $template); $template = str_replace("\$venuename", $rs->fields['venuename'], $template); $template = str_replace("\$venueurl", $rs->fields['venueurl'], $template); $template = str_replace("\$briefdesc", substrws($rs->fields['venuedesc']), $template); $template = str_replace("\$venueid", $rs->fields['venueid'], $template); $outdetail .= "\n<tr>".$template ."\n</tr>\n" ; $rs->MoveNext(); } echo $tbl_start.$outdetail.$tbl_end; } function getVenueById($venueid){ global $db ; $sql = "select * from venues where venueid = " .$venueid ; $rs = $db->Execute($sql); return $rs ; } ?>