<?php
/**
* WebTemplate Core
*
* @version 2.0
* @module WebTemplate Core
*/
/**
* A HTML Control
*
* @class WTControl
*/
class WTControl
{
/**
* Get the value from a form request which used the control
*
* @method getControlFormValue
* @static
* @param {string} formFieldName The name of the control in the form
* @param {Array} attributeInfo An associative array of information about the control, should contain the key "Attribute Type"
* @param {Array} formValues An associative array of the values sent in the request from the form
* @return {String} The value for the control
*/
public static function getControlFormValue($formFieldName, $attributeInfo, $formValues)
{
$attributeSettings = Array();
parse_str($attributeInfo["Attribute Settings"], $attributeSettings);
if(get_magic_quotes_gpc()) {
$attributeSetting = array_map("stripslashes", $attributeSettings);
}
switch($attributeInfo["Attribute Type"]) {
case "Multiple Choice Options":
if(array_key_exists($formFieldName, $formValues)) { // && $formValues[$formFieldName] != "") {
$selectedOptions = "";
if(array_key_exists("extraOptions", $attributeSettings)) {
$extraOptions = $GLOBALS["WT"]->getOptionsFromString($attributeSettings["extraOptions"]);
foreach($extraOptions as $id => $value) {
if(array_key_exists($formFieldName . "_" . $id, $formValues)) {
if($selectedOptions != "") {
$selectedOptions .= ",";
}
$selectedOptions .= $id;
}
}
}
if(array_key_exists("options", $attributeSettings)) {
$options = $GLOBALS["WT"]->getOptions($attributeSettings["options"]);
foreach($options as $id => $value) {
if(array_key_exists($formFieldName . "_" . $id, $formValues)) {
if($selectedOptions != "") {
$selectedOptions .= ",";
}
$selectedOptions .= $id;
}
}
}
return $selectedOptions;
}
break;
case "Date":
if(array_key_exists($formFieldName . "Day", $formValues)) {
$day = sprintf("%02d", $formValues[$formFieldName . "Day"]);
$month = sprintf("%02d", $formValues[$formFieldName . "Month"]);
$year = $formValues[$formFieldName . "Year"];
return "$year-$month-$day";
}
break;
default:
if(array_key_exists($formFieldName, $formValues)) {
if(get_magic_quotes_gpc()) {
return stripslashes($formValues[$formFieldName]);
} else {
return $formValues[$formFieldName];
}
}
break;
}
return false;
}
/**
* Return the HTML for a control<br/>
* Example:<br/>
* print WTControl::getControlHTML("date", Array("Attribute Type" => "Date"), "2012-01-01");
*
* @method getControlHTML
* @static
* @param {String} formFieldName The name of the control
* @param {Array} attributeInfo An associative array of information about the control, should contain the key "Attribute Type", can contain "Attribute Settings"
* @param {String} value The value of the control
* @return {String} the HTML for the control
*
*/
public static function getControlHTML($formFieldName, $attributeInfo, $value)
{
$attributeSettings = Array();
parse_str($attributeInfo["Attribute Settings"], $attributeSettings);
if(get_magic_quotes_gpc()) {
$attributeSettings = array_map("stripslashes", $attributeSettings);
}
if(array_key_exists("hidden", $attributeSettings)) {
return "";
}
$html = "";
//print_r($attributeInfo);
if(array_key_exists("Information", $attributeInfo)) {
if($attributeInfo["Information"] != "") {
$html .= $attributeInfo["Information"];
}
}
switch($attributeInfo["Attribute Type"]) {
case "File":
$singleFile = "no";
if(array_key_exists("singleFile", $attributeSettings) && ($attributeSettings["singleFile"] == "yes" || $attributeSettings["singleFile"] == "true")) {
$singleFile = "yes";
}
$html .= '<input name="' . $formFieldName . '" id="' . $formFieldName . '" type="hidden" value="' . $value . '"/>';
$html .= '<div id="' .$formFieldName . 'files"></div>';
$html .= '<span id="' . $formFieldName . 'addLabel">Add File:</span>';
$html .= '<input type="button" value="Browse Library..." onclick="window.open(\'' . $GLOBALS["WTURL"] . 'code/wtBrowser.php?formFieldName=' . $formFieldName . '&path=/Files&type=wtFile&attributeType=file&singleFile=' . $singleFile . '\', \'wtBrowser\', \'width=720,height=620\')"/>';
// if($GLOBALS["WTSITEID"] == 11201) {
if($GLOBALS["WTSITEID"] != 11473) {
$html .= '<input type="button" value="Upload a File..." onclick="window.open(\'' . $GLOBALS["WTURL"] . 'code/wtUpload3.php?formFieldName=' . $formFieldName . '&attributeType=file&singleFile=' . $singleFile . '\', \'\', \'width=420,height=450, status=0, toolbar=0,location=0,menubar=0,resizable=0\')"/>';
} else {
$html .= '<input type="button" value="Upload a File..." onclick="window.open(\'' . $GLOBALS["WTURL"] . 'code/wtUpload.php?formFieldName=' . $formFieldName . '&attributeType=file&singleFile=' . $singleFile . '\', \'\', \'width=420,height=450, status=0, toolbar=0,location=0,menubar=0,resizable=0\')"/>';
}
$fileGuidArray = explode(",", $value);
$html .= '<script language="javascript">' . "\n";
$html .= 'g_wtFiles["' . $formFieldName . '"] = new Array();' . "\n";
foreach($fileGuidArray as $fileGuid) {
if(trim($fileGuid) != "") {
$file = $GLOBALS["WT"]->getNode($fileGuid);
if($file != NULL) {
$title = str_replace("'", "\\'", $file->getAttribute("Title"));
$extension = $file->getAttribute("Extension");
if(file_exists($GLOBALS["WTDIRECTORY"] . "include/images/doctypes/16/_$extension.gif")) {
$icon = $GLOBALS["WTINCLUDEURL"] . "images/doctypes/16/_$extension.gif";
} else {
$icon = $GLOBALS["WTINCLUDEURL"] . "images/doctypes/16/_blank.gif";
}
$html .= 'g_wtFiles["' . $formFieldName . '"][g_wtFiles["' . $formFieldName . '"].length] = new WTFile(' . $file->m_guid . ', \'' . $title . '\', \'' . $icon . '\');' . "\n";
}
}
}
$html .= 'wtDisplayFiles(\'' . $formFieldName . '\');' . "\n";
$html .= '</script>' . "\n";
break;
case "Image":
$imagePath = "";
if($value != "" && $value != 0) {
$file = $GLOBALS["WT"]->getNode($value);
if($file != NULL && $file->m_typeName == "wtFile") {
$imagePath = $file->getFilename(Array("width" => 100, "height" => 100));
$imagePath = $GLOBALS["WT"]->getSiteSetting("Site Base") . "files/$imagePath";
}
}
$html .= '<table><tr><td style="width: 105px; height: 105px; background-color: white; border: 1px solid black;" align="center" valign="middle"><img src="' . $imagePath . '" name="' . $formFieldName . 'img" id="' . $formFieldName . 'img"/></td></tr></table>';
$html .= '<input type="hidden" name="' . $formFieldName . '" id="' . $formFieldName . '" value="' . $value . '"/>';
$html .= '<input type="button" value="Browse Library..." onclick="window.open(\'' . $GLOBALS["WTURL"] . 'code/wtBrowser.php?formFieldName=' . $formFieldName . '&path=/Files&type=wtFile&attributeType=image\', \'wtBrowser\', \'width=720,height=620\')"/>';
// if($GLOBALS["WTSITEID"] == 11201) {
if($GLOBALS["WTSITEID"] != 11473) {
$html .= '<input type="button" value="Upload a File..." onclick="window.open(\'' . $GLOBALS["WTURL"] . 'code/wtUpload3.php?formFieldName=' . $formFieldName . '&attributeType=image\', \'\', \'width=420,height=450, status=0, toolbar=0,location=0,menubar=0,resizable=0\')"/>';
} else {
$html .= '<input type="button" value="Upload a File..." onclick="window.open(\'' . $GLOBALS["WTURL"] . 'code/wtUpload.php?formFieldName=' . $formFieldName . '&attributeType=image\', \'\', \'width=420,height=450, status=0, toolbar=0,location=0,menubar=0,resizable=0\')"/>';
}
$html .= '<input type="button" value="Clear" onclick="wtClearImage(\'' . $formFieldName . '\')"/>';
break;
case "Rich Text":
/*
$value = str_replace("\r", "", $value);
$value = str_replace("\n", "", $value);
$value = str_replace("\"", "\\\"", $value);
*/
/* $value = str_replace('<script>', '', $value);
$value = str_replace('</script>', '', $value);
*/
$value = str_replace('<SCRIPT>', '<SCRI" + "PT>', $value);
$value = str_replace('</SC" + "RIPT>', '', $value);
$controlWidth = 400;
$controlHeight = 240;
if(array_key_exists("ControlWidth", $attributeSettings)) {
$controlWidth = $attributeSettings["ControlWidth"];
}
if(array_key_exists("ControlHeight", $attributeSettings)) {
$controlHeight = $attributeSettings["ControlHeight"];
}
$configWidth = WTConfig::get("Content Manager/FCK Width");
if($configWidth) {
$controlWidth = $configWidth;
}
$configHeight = WTConfig::get("Content Manager/FCK Height");
if($configHeight) {
$controlHeight = $configHeight;
}
$toolbarset = WTConfig::get("Content Manager/FCK Toolbar Set");
if($toolbarset == "") {
$toolbarset = "Basic";
}
if(array_key_exists("ControlToolbar", $attributeSettings)) {
$toolbarset = $attributeSettings["ControlToolbar"];
}
$clientDirectory = WTConfig::get("Site Details/Site Directory");
$value = str_replace('"__files', '"' . $clientDirectory . "__files", $value);
$html .= '<textarea id="' . $formFieldName . '" name="' . $formFieldName . '">';
$html .= htmlspecialchars($value);
$html .= '</textarea>';
$browser = $GLOBALS["WT"]->getWTValue("wt.browser");
if(WTConfig::get("Content Manager/CKEditor") == "Yes" || $browser == "chrome") {
$html .= '<script type="text/javascript">' . "\n";
$html .= 'CKEDITOR.editorConfig = function( config )' . "\n";
$html .= '{' . "\n";
$html .= "config.extraPlugins = 'wtlink';\n";
$html .= "config.toolbar = 'MyToolbarSet';\n";
$html .= "config.resize_minWidth = 100;\n";
if(array_key_exists("ControlWidth", $attributeSettings)) {
$html .= "config.width = $controlWidth;\n";
}
if(array_key_exists("ControlHeight", $attributeSettings)) {
$html .= "config.height = $controlHeight;\n";
}
$toolbar = WTConfig::get("Content Manager/CKEditor/Toolbar");
if($toolbar) {
$html .= "config.toolbar_MyToolbarSet = " . $toolbar . ";\n";
} else {
$html .= "config.toolbar_MyToolbarSet =\n";
$html .= "[\n";
$html .= " ['Source', '-', 'Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker'],\n";
$html .= " ['Undo','Redo','-','Find','Replace'],\n";
$html .= " ['wtlink', 'Unlink'],\n";
$html .= " '/',\n";
$html .= " ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],\n";
$html .= " ['NumberedList','BulletedList', 'Outdent', 'Indent', '-', 'Table', 'HorizontalRule']\n";
// $html .= " ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],\n";
// $html .= " ['FitWindow','ShowBlocks']\n";
$html .= "];\n";
}
$html .= "};\n";
$html .= 'CKEDITOR.replace(\'' . $formFieldName . '\');' . "\n";
$html .= '</script>' . "\n";
} else {
$html .= '<script type="text/javascript">' . "\n";
$html .= 'var oFCKeditor = new FCKeditor(\'' . $formFieldName . '\', "' . $controlWidth . '", "' . $controlHeight . '");' . "\n";
$html .= 'oFCKeditor.ToolbarSet = \'' . $toolbarset . '\';' . "\n";
$html .= 'oFCKeditor.BasePath = "' . $GLOBALS["WTFCKEDITORURL"] . "\";\n";
$html .= 'oFCKeditor.ReplaceTextarea();' . "\n";
$html .= 'function FCKeditor_OnComplete(editorInstance) {' . "\n";
$html .= 'editorInstance.Config.SpellChecker = "SpellerPages";';
if ( array_key_exists('buttons',$attributeSettings) ) {
$buttons = explode(',',$attributeSettings['buttons']);
ob_start();
?>
editorInstance.Config['ToolbarSets']['Custom'] = [["<?=implode('","',$buttons)?>"]];
editorInstance.ToolbarSet.Load('Custom');
<?php
$html .= ob_Get_clean();
}
$toolbar = WTConfig::get("Content Manager/FCK Toolbar");
if($toolbar) {
$toolbarset = "Custom";
$html .= "editorInstance.Config['ToolbarSets']['Custom'] = " . $toolbar . ";\n";
$html .= "editorInstance.ToolbarSet.Load('Custom');\n";
}
$html .= '}';
$html .= '</script>' . "\n";
}
break;
case "Single Choice Options":
case "Multiple Choice Options":
if(array_key_exists("options", $attributeSettings)) {
$optionQuery = Array();
if(array_key_exists("optionCriteria", $attributeSettings)) {
$optionQuery["Criteria"] = $attributeSettings["optionCriteria"];
}
if(array_key_exists("optionType", $attributeSettings)) {
$optionQuery["Node Type"] = $attributeSettings["optionType"];
}
if(array_key_exists("optionOrderBy", $attributeSettings)) {
$optionQuery["Order By"] = $attributeSettings["optionOrderBy"];
}
if(array_key_exists("optionSelect", $attributeSettings)) {
$optionQuery["Select"] = $attributeSettings["optionSelect"];
}
$options = $GLOBALS["WT"]->getOptions($attributeSettings["options"], $optionQuery);
$extraOptions = Array();
if(array_key_exists("extraOptions", $attributeSettings)) {
$extraOptions = $GLOBALS["WT"]->getOptionsFromString($attributeSettings["extraOptions"]);
}
if($attributeInfo["Attribute Type"] == "Single Choice Options") {
$html .= '<select name="' . $formFieldName .'" id="' . $formFieldName . '"';
if(array_key_exists("onchange", $attributeSettings)) {
$html .= ' onchange="' . $attributeSettings["onchange"] . '" ';
} else {
$name = str_replace("'", "\\'", $attributeInfo["Attribute Name"]);
$html .= ' onchange="wtOptionChanged(\'' . $formFieldName . '\')" ';
}
$html .= '>';
if($value == "") {
$html .= '<option value="0">Please Select</option>';
}
foreach($options as $optionValue => $name) {
$selected = '';
if($optionValue == $value || $name == $value) {
$selected = ' selected="selected" ';
}
$html .= '<option value="' . $optionValue . '"' . $selected . '>' . $name . '</option>';
}
foreach($extraOptions as $optionValue => $name) {
$selected = '';
if($optionValue == $value || $name == $value) {
$selected = ' selected="selected" ';
}
$html .= '<option value="' . $optionValue . '"' . $selected . '>' . $name . '</option>';
}
$html .= '</select>';
} else {
$html .= '<input type="hidden" id="' . $formFieldName . '" name="' . $formFieldName . '" value="' . $value . '"/>';
if($value != "") {
$valueArray = explode(",", $value);
} else {
$valueArray = Array();
}
foreach($extraOptions as $optionValue => $name) {
$checked = "";
if(in_array($optionValue, $valueArray)) {
$checked = 'checked="checked"';
}
$optionID = $formFieldName . '_' . $optionValue;
$html .= '<input onclick="wtCheckboxClick(this, \'' . $formFieldName . '\')" type="checkbox" id="' . $optionID . '" value="' . $optionValue . '" name="' . $optionID . '" '. $checked . '/>';
$html .= '<label for="' . $optionID . '">' . $name . '</label><br/>';
}
foreach($options as $optionValue => $name) {
$checked = "";
if(in_array($optionValue, $valueArray)) {
$checked = 'checked="checked"';
}
$optionID = $formFieldName . '_' . $optionValue;
$html .= '<input onclick="wtCheckboxClick(this, \'' . $formFieldName . '\')" type="checkbox" id="' . $optionID . '" value="' . $optionValue . '" name="' . $optionID . '" '. $checked . '/>';
$html .= '<label for="' . $optionID . '">' . $name . '</label><br/>';
}
}
}
break;
case "Date":
$year = "";
$month = "";
$day = "";
if($value != "") {
if(strtolower($value) == "now") {
$value = date("Y-m-d H:i");
}
list($date, $time) = explode(" ", $value);
list($year, $month, $day) = explode("-", $date);
}
$html .= '<select name="' . $formFieldName . 'Day" id="' . $formFieldName . 'Day">';
$dd = 'DD';
if(WTConfig::get("Multilingual") == "Yes") {
$dd = wtTranslation(Array("text" => $dd, "returntext" => "yes"));
}
$html .= '<option value="">' . $dd . '</option>';
for($i = 1; $i <= 31; $i++) {
$selected = "";
if($i == (int)$day) {
$selected = 'selected="selected"';
}
$html .= '<option ' . $selected . ' value="' . $i . '">' . $i . '</option>';
}
$html .= '</select>';
$mm = 'MM';
if(WTConfig::get("Multilingual") == "Yes") {
$mm = wtTranslation(Array("text" => $mm, "returntext" => "yes"));
}
$html .= '<select name="' . $formFieldName . 'Month" id="' . $formFieldName . 'Month">';
$html .= '<option value="">' . $mm . '</option>';
for($i = 1; $i <= 12; $i++) {
$selected = "";
if($i == (int)$month) {
$selected = 'selected="selected"';
}
$text = $GLOBALS["WTBUILTINOPTIONS"]["wtMonths"][$i];
if(WTConfig::get("Multilingual") == "Yes") {
$text = wtTranslation(Array("text" => $text, "returntext" => "yes"));
}
$html .= '<option ' . $selected . ' value=' . $i . '>' . $text . '</option>';
}
$html .= '</select>';
if(array_key_exists("year", $attributeSettings) && $attributeSettings["year"] == "dropdown") {
$html .= '<select name="' . $formFieldName . 'Year" id="' . $formFieldName . 'Month">';
$html .= '<option value="">YYYY</option>';
for($i = date("Y") - 10; $i <= date("Y") + 10; $i++) {
$selected = "";
if($i == $year) {
$selected = ' selected="selected" ';
}
$html .= '<option value="' . $i . '" ' . $selected . '>' . $i . '</option>';
}
$html .= '</select>';
} else {
$minDate = "";
if(array_key_exists("mindate", $attributeSettings)) {
$min = strtotime(WTTemplate::compileAndEvaluate($attributeSettings["mindate"], Array()));
if($min) {
$minDate = "minDate: new Date(" . date("Y,n,j", $min) . "),\n";
}
}
$maxDate = "";
if(array_key_exists("maxdate", $attributeSettings)) {
$max = strtotime(WTTemplate::compileAndEvaluate($attributeSettings["maxdate"], Array()));
if($max) {
$maxDate = "maxDate: new Date(" . date("Y,n,j", $max) . "),\n";
}
}
$html .= '<input value="' . $year . '" name="' . $formFieldName . 'Year" size="4" id="' . $formFieldName . 'Year" onkeypress="return wtCheckKeys(event, \'0123456789\')" maxlength="4"/>';
/*
$html .= '<script language="javascript" src="' . $GLOBALS["WTURL"] . 'external//jquery/datepicker/ui.datepicker.js"></script>';
$html .= '<link type="text/css" rel="stylesheet" href="' . $GLOBALS["WTURL"] . 'external//jquery/datepicker/datepicker.css"/>';
*/
$html .= '<script language="javascript" src="?wtInclude=jquery.datepicker.js"></script>';
$html .= '<link type="text/css" rel="stylesheet" href="?wtInclude=jquery.datepicker.css"/>';
$html .= '<script language="javascript">' . "\n";
$html .= 'function wtSetDateValue(attribute, value) {' . "\n";
$html .= ' var datetimeparts = value.split(" ");' . "\n";
$html .= ' var dateparts = datetimeparts[0].split("-");' . "\n";
$html .= ' if(dateparts.length == 3) {' . "\n";
$html .= ' var year = dateparts[0];' . "\n";
$html .= ' var month = parseInt(dateparts[1], 10);' . "\n";
$html .= ' var day = parseInt(dateparts[2], 10);' . "\n";
$html .= ' $("#" + attribute + "Year").val(year);' . "\n";
$html .= ' $("#" + attribute + "Month").val(month);' . "\n";
$html .= ' $("#" + attribute + "Day").val(day);' . "\n";
$html .= ' }' . "\n";
$html .= '}' . "\n";
$functionId = str_replace(" ", "", $formFieldName);
$html .= 'function wtShowDatePicker' . $functionId . '(attribute) {' . "\n";
$html .= 'var datepicker = $("#" + attribute + "button").datepicker({' . "\n";
$html .= ' onSelect: function(date, datepick) {' . "\n";
$html .= ' wtSetDateValue(attribute, date);' . "\n";
$html .= ' },' . "\n";
$html .= $minDate;
$html .= $maxDate;
$html .= ' dateFormat: "yy-mm-dd"' . "\n";
$html .= ' });' . "\n";
$html .= ' $("#" + attribute + "button").datepicker("show");';
$html .= "}\n";
$html .= "</script>\n";
$html .= '<input type="hidden" value="c" id="' . $formFieldName . 'button"/>';
$html .= ' <img src="?wtInclude=jquery.datepicker.calendar.png" onclick="wtShowDatePicker' . $functionId . '(\'' . $formFieldName . '\')">';
}
//DEH:20080102: added here for alternate date control...
if ( array_key_exists('alternateDateControl',$attributeSettings) ) {
if ( $attributeSettings['alternateDateControl'] == 'true' ) {
ob_start();
?>
<script type="text/javascript">
$(document).ready(function(){
var initialValue = [
$('select[name=<?=$formFieldName?>Day]').val(),
$('select[name=<?=$formFieldName?>Month]').val(),
$('input[name=<?=$formFieldName?>Year]').val()
];
$('select,input',$('select.<?=$formFieldName?>daydate').parent('td')).hide();
$('.<?=$formFieldName?>daydate').click(function(){
$('select[name=<?=$formFieldName?>Day]').val($(this).val());
});
$('select[name=<?=$formFieldName?>monthyear]').click(function(){
$('.<?=$formFieldName?>daydate').hide();
var yearmon = String($(this).val());
$('select[name=<?=$formFieldName?>'+yearmon+']').show().click();
yearmon = yearmon.match(/(.{2})(.*)/);
for ( i in yearmon )
yearmon[i] = Number(yearmon[i]);
$('select[name=<?=$formFieldName?>Month]').val(yearmon[1]);
$('input[name=<?=$formFieldName?>Year]').val(yearmon[2]);
});
{{{
$('select[name=<?=$formFieldName?>monthyear]').show();
var yearmon = String($('select[name=<?=$formFieldName?>monthyear]').val());
$('select[name=<?=$formFieldName?>'+yearmon+']').show();
$('select[name=<?=$formFieldName?>'+yearmon+']').val(initialValue[0]);
}}}
/*
//$('select[name=<?=$formFieldName?>monthyear]').show().click();
//$('select[name=<?=$formFieldName?>monthyear]').show();
//set the initial values...
var monyearval = (initialValue[1]<10?'0':'')+String(initialValue[1])+String(initialValue[2]);
//$('select[name=<?=$formFieldName?>monthyear]').val(monyearval).click();
//$('select[name=<?=$formFieldName?>'+monyearval+']').val(initialValue[0]).click();*/
});
</script>
<select name="<?=$formFieldName?>monthyear"><?php
$days = array();
$daysofweek = array('Mon','Tue','Wed','Thu','Fri','Sat','Sun');
$curmonth = (int)date('n');
$curyear = (int)date('Y');
$value = strtotime("$year/$month/$day");
$today = date('M YD j');
if ( $value > 0 )
$today = date('M YD j',$value);
$processedPast = false;
for ( $i=-12; $i<12; ++$i ) {
//$date = strtotime('+'.$i.' months');
$date = gmmktime(1,1,1,$curmonth+$i,1,$curyear);
$k = date('mY',$date);
$mon = date('M Y',$date);
$days[$k] = array();
//see if the current value is in the past...
if ( false && !$processedPast ) {
$processedPast = true;
if ( $value < $date ) {
echo '<option value="',date('mY',$value),'">',date('M Y',$value),'</option>';
$m=explode(',',date('t,D',$value));
$daykey=array_search($m[1],$daysofweek);
$days[$k][] = '<option value="'.$x.'"'.(($mon.$daysofweek[$daykey].' '.$x)==$today?' selected="selected"':'').'>'.$daysofweek[$daykey].' '.$x.'</option>';
}
}
echo '<option value="',$k,'"',(date('Y/m',$date)=="$year/$month"?' selected="selected"':''),'>',$mon,'</option>';
for ( $x=1,$m=explode(',',date('t,D',$date)),$daykey=array_search($m[1],$daysofweek); $x<=$m[0]; ++$x,++$daykey ) {
if ( $daykey < 0 )
$daykey = 6;
if ( $daykey > 6 )
$daykey = 0;
$days[$k][] = '<option value="'.$x.'"'.(($mon.$daysofweek[$daykey].' '.$x)==$today?' selected="selected"':'').'>'.$daysofweek[$daykey].' '.$x.'</option>';
}
}
?></select>
<?php
for ( $i=0,$s=sizeof($days),$k=array_keys($days); $i<$s; ++$i ) {
echo '<select name="',$formFieldName,$k[$i],'" class="',$formFieldName,'daydate">',implode('',$days[$k[$i]]),'</select>';
}
?>
<?php
$html .= ob_get_clean();
}
}
/* $html .= '<div style="position: relative"><div id="calContainer" style="display: none; position: absolute; left: 100px; top: 0"></div></div>';
$html .= '<script language="javascript">' . "\n";
$html .= 'var cal = new YAHOO.widget.Calendar("cal", "calContainer", { title: "Choose a date:", close: true } );' . "\n";
$html .= 'cal.render();' . "\n";
$html .= '</script>' . "\n";
$html .= '<input type="button" onclick="cal.show(true)"/>';
*/
break;
case "Number":
$html .= '<input name="' . $formFieldName . '" value="' . htmlspecialchars($value) . '" onkeypress="return wtCheckKeys(event, \'0123456789\')" size="5" />';
if(array_key_exists("postfix", $attributeSettings)) {
$html .= " " . $attributeSettings["postfix"];
}
break;
case "Money":
$html .= '<input name="' . $formFieldName . '" value="' . htmlspecialchars($value) . '" onkeypress="return wtCheckKeys(event, \'0123456789.\')" size="5" />';
break;
case "Static":
$message = $attributeSettings["message"];
$message = WTTemplate::compileAndEvaluate($message, Array());
$html .= $message;
break;
default:
$size = "";
if(array_key_exists("size", $attributeSettings)) {
$size = ' size="' . $attributeSettings["size"] . '" ';
} else {
$size = ' size="50" ';
}
$direction = "";
if(WTConfig::get("Multilingual") == "Yes") {
$languageID = $GLOBALS["WTLANGUAGEID"];
if($languageID != 0) {
$languageNode = $GLOBALS["WT"]->getNode($languageID);
if($languageNode && $languageNode->m_typeName == "wtLanguage") {
$direction = $languageNode->getAttribute("Direction");
if($direction == "rtl") {
$direction = ' dir="rtl" ';
}
}
}
}
$maxlength = "";
if(array_key_exists("maxlength", $attributeSettings)) {
$maxlength = ' maxlength="' . $attributeSettings["maxlength"] . '" ';
}
$html .= '<input name="' . $formFieldName . '" id="' . $formFieldName . '" value="' . htmlspecialchars($value) . '"' . $size . $maxlength . $direction . '/>';
break;
}
return $html;
}
};