File: D:/web/itpartnership.net (cms)/modules/FeedbackForm/classes/TextInput.class.php
<?php
// Feedback Form. 02/2005 SjG <feedbackform_cmsmodule@fogbound.net>
// A Module for CMS Made Simple, (c)2005 by Ted Kulp (wishy@cmsmadesimple.org)
// This project's homepage is: http://www.cmsmadesimple.org
class ffTextInput extends ffInput {
function ffTextInput(&$mod_globals, $formRef, &$params)
{
$this->ffInput($mod_globals, $formRef, $params);
$this->Type = 'TextInput';
$this->DisplayType = $this->mod_globals->Lang('field_type_text_input');
if ($this->Length == -1)
{
$this->Length = 255;
}
$this->ValidationTypes = array(
$this->mod_globals->Lang('validation_none')=>'none',
$this->mod_globals->Lang('validation_not_empty')=>'nonempty',
$this->mod_globals->Lang('validation_numeric')=>'numeric',
$this->mod_globals->Lang('validation_integer')=>'integer',
$this->mod_globals->Lang('validation_email_address')=>'email'
);
}
function WriteToPublicForm($id, &$params, $return_id)
{
$module =& $this->mod_globals->selfptr;
if (strlen($this->CSSClass)>0)
{
echo "<div class=\"".$this->CSSClass."\">";
}
echo $module->CreateInputText($id, $this->Alias, $this->NerfHTML($this->Value),
$this->Length<$this->DisplayLength?$this->Length:$this->DisplayLength,
$this->Length,$this->mod_globals->UseIDAndName?'id="'.$this->Alias.'"':'');
if (strlen($this->CSSClass)>0)
{
echo "</div>";
}
}
function StatusInfo()
{
$ret = $this->mod_globals->Lang('abbreviation_length').$this->Length;
if (ffUtilityFunctions::def($this->ValidationType))
{
$ret .= ", ".array_search($this->ValidationType,$this->ValidationTypes);
}
return $ret;
}
function RenderAdminForm($formDescriptor)
{
$module =& $this->mod_globals->selfptr;
return array($this->mod_globals->Lang('title_maximum_length').':'=>
$module->CreateInputText($formDescriptor, 'length', $this->Length,25,25));
}
function Validate()
{
$result = true;
$message = '';
switch ($this->ValidationType)
{
case 'none':
break;
case 'nonempty':
if (! ffUtilityFunctions::def($this->Value))
{
$result = false;
$message = $this->mod_globals->Lang('please_enter_a_value').' "'.$this->Name.'"';
}
break;
case 'numeric':
if (ffUtilityFunctions::def($this->Value) &&
! preg_match("/^([\d\.\,])+$/i", $this->Value))
{
$result = false;
$message = $this->mod_globals->Lang('please_enter_a_number').' "'.$this->Name.'"';
}
break;
case 'integer':
if (ffUtilityFunctions::def($this->Value) &&
intval($this->Value) != $this->Value)
{
$result = false;
$message = $this->mod_globals->Lang('please_enter_an_integer').' "'.$this->Name.'"';
}
break;
case 'email':
if (ffUtilityFunctions::def($this->Value) &&
! preg_match("/^([\w\d\.\-\_])+\@([\w\d\.\-\_]+)\.(\w+)$/i", $this->Value))
{
$result = false;
$message = $this->mod_globals->Lang('please_enter_an_email').' "'.$this->Name.'"';
}
break;
}
if ($this->Length > 0 && strlen($this->Value) > $this->Length)
{
$result = false;
$message = $this->mod_globals->Lang('please_enter_no_longer').$this->Length." ".
$this->mod_globals->Lang('characters') . "!";
}
return array($result, $message);
}
}
?>