Inte så enkelt tror jag, bifogar kod för jag har fastnat(nerkortad=annars för lång):
<?php
* $columns = Array( "#" => "width=\"20\"",
* "<input type=\"checkbox\" name=\"toggle\" value=\"\" onclick=\"checkAll(".$num_rows.")\" />" => "width=\"20\"",*
* $VM_LANG->_PHPSHOP_PRODUCT_LIST_NAME => '',
* $VM_LANG->_PHPSHOP_PRODUCT_LIST_SKU => '',
* _E_REMOVE => "width=\"5%\""
class vmCommonHTML {
/**
* Writes a "Save Ordering" Button
* @param int the number of rows
*/
function getSaveOrderButton( $num_rows, $funcname='reorder') {
global $mosConfig_live_site;
$n = $num_rows-1;
return '<a href="javascript: document.adminForm.func.value = \''.$funcname.'\'; saveorder( '.$n.' );">
<img src="'.$mosConfig_live_site.'/administrator/images/filesave.png" border="0" width="16" height="16" alt="Save Order" /></a>';
}
function getOrderingField( $ordering ) {
return '<input type="text" name="order[]" size="5" value="'. $ordering .'" class="text_area" style="text-align: center" />';
}
function getYesNoIcon( $condition, $pos_alt = "Published", $neg_alt = "Unpublished" ) {
global $mosConfig_live_site;
if( $condition===true || strtoupper( $condition ) == "Y" )
return '<img src="'.$mosConfig_live_site.'/administrator/images/tick.png" border="0" alt="'.$pos_alt.'" />';
else
return '<img src="'.$mosConfig_live_site.'/administrator/images/publish_x.png" border="0" alt="'.$neg_alt.'" />';
}
/*
* Loads all necessary files for JS Overlib tooltips
*/
function loadOverlib() {
global $mosConfig_live_site;
if( !defined( "_OVERLIB_LOADED" )) {
?>
<script language="Javascript" type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
<?php
define ( "_OVERLIB_LOADED", "1" );
}
}
/**
* Returns a div element of the class "shop_error"
* containing $msg to print out an error
*
* @param string $msg
* @return string HTML code
*/
function getErrorField( $msg ) {
$html = '<div class="shop_error">'.$msg.'</div>';
return $html;
}
/**
* Returns a div element of the class "shop_error"
* containing $msg to print out an error
*
* @param string $msg
* @return string HTML code
*/
function getInfoField( $msg ) {
$html = '<div class="shop_info">'.$msg.'</div>';
return $html;
}
/**
* Prints a JS function to validate all fields
* given in the array $required_fields
* Does only test if non-empty (or if no options are selected)
* Includes a check for a valid email-address
*
* @param array $required_fields The list of form elements that are to be validated
* @param string $formname The name for the form element
* @param string $div_id_postfix The ID postfix to identify the label for the field
*/
function printJS_formvalidation( $required_fields, $formname = 'adminForm', $functioname='submitregistration', $div_id_postfix = '_div' ) {
global $VM_LANG;
echo '
<script language="javascript" type="text/javascript">//<![CDATA[
function '.$functioname.'() {
var form = document.'.$formname.';
var r = new RegExp("[\<|\>|\"|\'|\%|\;|\(|\)|\&|\+|\-]", "i");
var isvalid = true';
foreach ( $required_fields as $fieldname ) {
echo '
if( form.'.$fieldname.'.value == "" ) {
document.getElementById(\''.$fieldname.$div_id_postfix.'\').style.color = "red";
isvalid = false;
}
else {
document.getElementById(\''.$fieldname.$div_id_postfix.'\').style.color = "";
}
';
}
if( in_array( 'email', $required_fields)) {
echo '
if( !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.email.value))) {
alert( \''. html_entity_decode( $VM_LANG->_REGWARN_MAIL ).'\');
return false;
}';
}
if( in_array( 'username', $required_fields )) {
echo '
if (r.exec(form.username.value) || form.username.value.length < 3) {
alert( "'. html_entity_decode( sprintf($VM_LANG->_VALID_AZ09, $VM_LANG->_USERNAME, 2)) .'" );
return false;
}';
}
if( in_array( 'password', $required_fields )) {
echo '
if (form.password.value.length < 6) {
alert( "'. html_entity_decode( $VM_LANG->_REGWARN_PASS ).'" );
return false;
} else if (form.password2.value == "") {
alert( "'.html_entity_decode( $VM_LANG->_REGWARN_VPASS1).'" );
return false;
} else if ((form.password.value != "") && (form.password.value != form.password2.value)){
alert( "'. html_entity_decode( $VM_LANG->_REGWARN_VPASS2).'" );
return false;
} else if (r.exec(form.password.value)) {
alert( "'. html_entity_decode(sprintf( $VM_LANG->_VALID_AZ09, $VM_LANG->_PASSWORD, 6 )) .'" );
return false;
}';
}
if( in_array( 'agreed', $required_fields )) {
echo '
if (!form.agreed.checked) {
alert( "'. $VM_LANG->_PHPSHOP_AGREE_TO_TOS .'" );
return false;
}';
}
// Finish the validation function
echo '
if( !isvalid) {
alert("'.addslashes( html_entity_decode($VM_LANG->_CONTACT_FORM_NC) ).'" );
}
return isvalid;
}
//]]>
</script>';
}
}
/**
* Utility function to provide ToolTips
* @param string ToolTip text
* @param string Box title
* @returns HTML code for ToolTip
*/
function mm_ToolTip( $tooltip, $title='Tip!', $image = "{mosConfig_live_site}/images/M_images/con_info.png", $width='', $text='', $href='#', $link=false ) {
global $mosConfig_live_site, $database;
defined( 'vmToolTipCalled') or define('vmToolTipCalled', 1);
$tooltip = @htmlentities( $database->getEscaped($tooltip), ENT_QUOTES, vmGetCharset() );
if ( !empty($width) ) {
$width = 'this.T_WIDTH=\''.$width .'\';';
}
if ( $title ) {
$title = 'this.T_TITLE=\''.$title .'\';';
}
$image = str_replace( "{mosConfig_live_site}", $mosConfig_live_site, $image);
$text = '<img src="'. $image .'" align="middle" border="10" /> '.$text;
$style = 'style="text-decoration: none; color: #333;"';
if ( $href ) {
$style = '';
}
if ( $link ) {
$tip = "<a href=\"". $href ."\" onmouseover=\"return escape( '$tooltip' );\" ". $style .">". $text ."</a>";
} else {
$tip = "<span onmouseover=\"$width $title return escape( '$tooltip' );\" ". $style .">". $text ."</span>";
}
return $tip;
}
// borrowed from mambo.php
function shopMakeHtmlSafe( $string, $quote_style=ENT_QUOTES, $exclude_keys='' ) {
$string = htmlspecialchars( $string, $quote_style );
return $string;
}
function mm_showMyFileName( $filename ) {
if (DEBUG == '1' ) {
echo mm_ToolTip( '<div class=\'inputbox\'>Begin of File: '. $filename.'</div>');
}
}
/**
* Wraps HTML Code or simple Text into Javascript
* and uses the noscript Tag to support browsers with JavaScript disabled
**/
function mm_writeWithJS( $textToWrap, $noscriptText ) {
$text = "";
if( !empty( $textToWrap )) {
$text = "<script type=\"text/javascript\">//<![CDATA[
document.write('".str_replace("\\\"", "\"", addslashes( $textToWrap ))."');
//]]></script>\n";
}
if( !empty( $noscriptText )) {
$text .= "<noscript>
$noscriptText
</noscript>\n";
}
return $text;
}
/**
* A function to create a XHTML compliant and JS-disabled-safe pop-up link
*/
function vmPopupLink( $link, $text, $popupWidth=640, $popupHeight=480, $target='_blank', $title='' ) {
[red]$jslink = "<a href=\"$link\" title=\"$title\" rel=\"lightbox\">$text</a>";[/red]
return mm_writeWithJS( $jslink, $noscriptlink );
}
?>