|
Živjo, rabim pomoč
Za vzdrževanje ene izmed mojih spletnih strani uporabljam CMS Made Simple. Ker pripravljam neko foro, sem uporabil zelo priročen plugin Form Builder. Vse kul, dokler ne ugotovim, da uporabnik v Email "From Address" Field lahko vpiše samo TLD domene, se pravi .si odpade, kar pa ni dobro, ker večina je iz SLO. Šel sem pogledat datoteke in med lang našel en_US.php ter vrstico:
$lang['title_relaxed_regex_long']='Use relaxed email address validation (e.g., allow "x@y" instead of requiring "x@y.tld")'
Četudi sem tist tld popravil na ccTLD (country code Top List Domain), se situacija ne izboljša. Bi znal kdo rešiti problem, kljuka, podtalje :D Dankišn ful NikMan ti pa uredi naslov, ker nism našu boljšega )
LP
spremenil: Matej V. (2.1.2011 ob 18.03.24)
|
|
|
Am ... To je premalo kode. Daj več ...
|
|
|
Kar se tiče forme za email je tole vse v angleškem prevodu:
$lang['title_email_from_name']='"From name" for email';
$lang['title_relaxed_email_regex']='Use relaxed email validation';
$lang['title_relaxed_regex_long']='Use relaxed email address validation (e.g., allow "x@y" instead of requiring "x@y.ccTLD")';
$lang['title_email_from_address']='"From address" for email';
$lang['title_email_encoding']='Email character set encoding';
Tole je pa FromEmailAdressField.class.php:
<?php
/*
FormBuilder. Copyright (c) 2005-2006 Samuel Goldstein <sjg@cmsmodules.com>
More info at http://dev.cmsmadesimple.org/project....
A Module for CMS Made Simple, Copyright (c) 2006 by Ted Kulp (wishy@cmsmadesimple.org)
This project's homepage is: http://www.cmsmadesimple.org
*/
class fbFromEmailAddressField extends fbFieldBase {
function fbFromEmailAddressField(&$form_ptr, &$params)
{
$this->fbFieldBase($form_ptr, $params);
$mod = $form_ptr->module_ptr;
$this->Type = 'FromEmailAddressField';
$this->DisplayInForm = true;
$this->ValidationTypes = array(
$mod->Lang('validation_email_address')=>'email',
);
$this->ValidationType = 'email';
$this->modifiesOtherFields = true;
}
function GetFieldInput($id, &$params, $returnid)
{
$mod = $this->form_ptr->module_ptr;
$js = $this->GetOption('javascript','');
return $mod->fbCreateInputText($id, 'fbrp__'.$this->Id,
htmlspecialchars($this->Value, ENT_QUOTES),
25,128,$js.$this->GetCSSIdTag());
}
function PrePopulateAdminForm($formDescriptor)
{
$mod = $this->form_ptr->module_ptr;
$main = array();
$adv = array();
$hopts = array($mod->Lang('option_from')=>'f', $mod->Lang('option_reply')=>'r', $mod->Lang('option_both')=>'b');
array_push($main,array($mod->Lang('title_headers_to_modify'),
$mod->CreateInputDropdown($formDescriptor, 'fbrp_opt_headers_to_modify', $hopts, -1, $this->GetOption('headers_to_modify','f'))));
return array('main'=>$main,'adv'=>$adv);
}
function ModifyOtherFields()
{
$mod = $this->form_ptr->module_ptr;
$others = $this->form_ptr->GetFields();
$htm = $this->GetOption('headers_to_modify','f');
if ($this->Value !== false)
{
for($i=0;$i<count($others);$i++)
{
$replVal = '';
if ($others[$i]->IsDisposition()
&& is_subclass_of($others[$i],'fbDispositionEmailBase'))
{
if ($htm == 'f' || $htm == 'b')
{
$others[$i]->SetOption('email_from_address',$this->Value);
}
if ($htm == 'r' || $htm == 'b')
{
$others[$i]->SetOption('email_reply_to_address',$this->Value);
}
}
}
}
}
function StatusInfo()
{
return '';
}
function Validate()
{
$this->validated = true;
$this->validationErrorText = '';
$mod = $this->form_ptr->module_ptr;
switch ($this->ValidationType)
{
case 'email':
if ($this->Value !== false &&
! preg_match(($mod->GetPreference('relaxed_email_regex','0')==0?
$mod->email_regex:$mod->email_regex_relaxed), $this->Value))
{
$this->validated = false;
$this->validationErrorText = $mod->Lang('please_enter_an_email',$this->Name);
}
break;
}
return array($this->validated, $this->validationErrorText);
}
}
?>
spremenil: podtalje (2.1.2011 ob 18.56.39)
|
|
|
Na omenjeni način to res ne bo šlo.
To, kar si ti popravljal ($lang['title_relaxed_regex_long']), je samo navadno besedilo, ki nima nobenega vpliva na izvajanje kode.
Tisto, kar je bistveno, je GetPreference('relaxed_email_regex','0' )
Po vsej verjetnosti mora biti nekje v vmesniku nastavitev za relaxed_email_regex, zraven pa se verjetno izpiše besedilo, ki si ga ti popravljal.
En trik, ki pa na najlepši, je, da popraviš vrstico:
preg_match(($mod->GetPreference('relaxed_email_regex','0')==0? $mod->email_regex:$mod->email_regex_relaxed), $this->Value))
in namesto nje napišeš
preg_match(($mod->GetPreference('relaxed_email_regex','0')==0? $mod->email_regex_relaxed:$mod->email_regex_relaxed), $this->Value))
Tako bo negleda na nastavitve uporabil email_regex_relaxed.
Čeprav sam bi raje pripročal, da pogledaš po nastavitvah v vmesniku, kje se vklopi email_regex_relaxed.
spremenil: podtalje (2.1.2011 ob 18.59.17)
|
|
Prikazujem 1 od skupno 1 strani |
|