Index: trunk/globals.php =================================================================== diff -u -N -r3330 -r3534 --- trunk/globals.php (.../globals.php) (revision 3330) +++ trunk/globals.php (.../globals.php) (revision 3534) @@ -2051,5 +2051,14 @@ return defined($const_name) && constant($const_name); } } + + function &recallObject($var_name, $class_name) + { + if (!isset($GLOBALS[$var_name]) || !is_object($GLOBALS[$var_name])) + { + $GLOBALS[$var_name] = new $class_name(); + } + return $GLOBALS[$var_name]; + } ?> Index: trunk/kernel/include/language.php =================================================================== diff -u -N -r3330 -r3534 --- trunk/kernel/include/language.php (.../language.php) (revision 3330) +++ trunk/kernel/include/language.php (.../language.php) (revision 3534) @@ -66,14 +66,14 @@ } - function &AddPhrase($Phrase,$LangId,$Translation,$Type) + function &AddPhrase($Phrase,$LangId,$Translation,$Type, $Module = 'In-Portal') { $tmpphrase = $this->GetPhrase($Phrase, $LangId); if (!$tmpphrase) { $p = new clsPhrase(); $p->tablename = $this->SourceTable; - $p->Set(array("Phrase","LanguageId","Translation","PhraseType"), - array($Phrase,$LangId,$Translation,$Type)); + $p->Set(array("Phrase","LanguageId","Translation","PhraseType", 'Module', 'LastChanged', 'LastChangeIP'), + array($Phrase,$LangId,$Translation,$Type, $Module, time(), $_SERVER['REMOTE_ADDR'] )); $p->Dirty(); $p->Create(); return $p; @@ -90,11 +90,11 @@ } } - function &EditPhrase($id,$Phrase,$LangId,$Translation,$Type) + function &EditPhrase($id,$Phrase,$LangId,$Translation,$Type, $Module = 'In-Portal') { $p = $this->GetItem($id); - $p->Set(array("Phrase","LanguageId","Translation","PhraseType"), - array($Phrase,$LangId,$Translation,$Type)); + $p->Set(array("Phrase","LanguageId","Translation","PhraseType", 'Module', 'LastChanged', 'LastChangeIP'), + array($Phrase,$LangId,$Translation,$Type, $Module, time(), $_SERVER['REMOTE_ADDR'] )); $p->Dirty(); $p->Update(); return $p; Index: trunk/kernel/include/searchconfig.php =================================================================== diff -u -N -r1566 -r3534 --- trunk/kernel/include/searchconfig.php (.../searchconfig.php) (revision 1566) +++ trunk/kernel/include/searchconfig.php (.../searchconfig.php) (revision 3534) @@ -269,7 +269,7 @@ function GetNextDisplayOrder($mod) { $ret = 0; - $sql = "SELECT max(DisplayOrder) as do FROM ".$this->SourceTable." WHERE ModuleName='$mod'"; + $sql = "SELECT MAX(DisplayOrder) AS do FROM ".$this->SourceTable." WHERE ModuleName = '$mod'"; $rs = $this->adodbConnection->Execute($sql); if($rs && !$rs->EOF) $ret = $rs->fields["do"]+1; @@ -381,9 +381,9 @@ return $f; } - function &AddSearchField($Table,$FieldName,$Module,$Simple,$Adv,$Description,$DisplayName,$ConfigHeader,$DisplayOrder=0, - $Priority=0,$FieldType="text",$JoinClause=NULL,$IsWhere=NULL,$IsNotWhere=NULL,$ContainsWhere=NULL,$NotContainsWhere=NULL,$CustomId=0, $ForeignField = NULL) + function &AddSearchField($Table,$FieldName,$Module,$Simple,$Adv,$Description,$DisplayName,$ConfigHeader,$DisplayOrder=0,$Priority=0,$FieldType="text",$JoinClause=NULL,$IsWhere=NULL,$IsNotWhere=NULL,$ContainsWhere=NULL,$NotContainsWhere=NULL,$CustomId=0, $ForeignField = NULL) { + $f = new clsSearchConfig(); if($DisplayOrder==0) $DisplayOrder = $this->GetNextDisplayOrder($Module); Index: trunk/admin/config/addcustomfield.php =================================================================== diff -u -N -r2853 -r3534 --- trunk/admin/config/addcustomfield.php (.../addcustomfield.php) (revision 2853) +++ trunk/admin/config/addcustomfield.php (.../addcustomfield.php) (revision 3534) @@ -157,12 +157,14 @@ Index: trunk/kernel/include/customfield.php =================================================================== diff -u -N -r1346 -r3534 --- trunk/kernel/include/customfield.php (.../customfield.php) (revision 1346) +++ trunk/kernel/include/customfield.php (.../customfield.php) (revision 3534) @@ -188,12 +188,13 @@ $Table = GetTablePrefix()."CustomField"; $Header = "la_text_".strtolower($Item->Get("ItemName")); $Module = $Item->Get("Module"); - $Desc = $FieldLabel; +// $Desc = $FieldLabel; if(!is_object($objSearchConfig)) { $objSearchConfig = new clsSearchConfigList(); } + $NextOrder = $objSearchConfig->GetNextDisplayOrder($Module); $desc = "lu_fieldcustom__".strtolower($FieldName); if(!strlen($FieldLabel)) @@ -203,31 +204,42 @@ $l = $objLanguages->GetPrimary(); $phrases = new clsPhraseList(); - $phrases->AddPhrase($desc,$l,$FieldLabel,2); + $phrases->AddPhrase($desc,$l,$FieldLabel,2, $Item->Get('Module') ); $dtable = GetTablePrefix()."CustomMetaData"; $Join = "($dtable.ResourceId={Table}.ResourceId)"; $objSearchConfig->AddSearchField($Table,$FieldName,$Module,0,0, $FieldLabel,$desc,$Header,$NextOrder,0, - "text",$Join, NULL, NULL, NULL, NULL, + $ElementType,$Join, NULL, NULL, NULL, NULL, $f->Get("CustomFieldId"), "CustomMetaData.Value"); } return $f; //} //else // return FALSE; } - - function EditField($FieldId,$Type,$FieldName,$FieldLabel,$ShowGeneral=0,$Heading="", $Prompt="", - $ElementType="",$ValueList="") + + function EditField($FieldId,$Type,$FieldName,$FieldLabel,$ShowGeneral=0,$Heading="", $Prompt="",$ElementType="",$ValueList="") { - $f = $this->GetItem($FieldId); - $f->Set(array("Type","FieldName","FieldLabel","OnGeneralTab","Heading","Prompt", - "ElementType","ValueList"), - array($Type,$FieldName,$FieldLabel,$ShowGeneral,$Heading,$Prompt, - $ElementType,$ValueList)); - $f->Update(); - return $f; + global $objSearchConfig; + + $f = $this->GetItem($FieldId); + $f->Set(array("Type","FieldName","FieldLabel","OnGeneralTab","Heading","Prompt","ElementType","ValueList"), + array($Type,$FieldName,$FieldLabel,$ShowGeneral,$Heading,$Prompt,$ElementType,$ValueList)); + $f->Update(); + + $db =& $this->adodbConnection; + + if (!$FieldLabel) $FieldLabel = $FieldName; + $sql = 'UPDATE '.GetTablePrefix().'SearchConfig + SET FieldType = '.$db->qstr($ElementType).', + DisplayName = '.$db->qstr('lu_fieldcustom__'.strtolower($FieldName)).', + FieldName = '.$db->qstr($FieldName).', + Description = '.$db->qstr($FieldLabel).' + WHERE CustomFieldId = '.$FieldId; + $this->adodbConnection->Execute($sql); + + return $f; } function DeleteField($FieldId) @@ -247,14 +259,12 @@ $objSearchConfig = new clsSearchConfigList($Module); } - if (is_object($objSearchConfig)) { - $s = $objSearchConfig->GetItemByName($table,$f->Get("FieldName")); - //echo "$table ".$f->Get("FieldName")."
"; print_r($s); echo "
"; - if(is_object($s)) - { - $s->Delete(); - } - } + $sql = 'DELETE FROM '.$objSearchConfig->SourceTable.' WHERE CustomFieldId = '.$FieldId; + $this->adodbConnection->Execute($sql); + + $phrase_name = 'lu_fieldcustom__'.strtolower($f->Get('FieldName')); + $sql = 'DELETE FROM '.GetTablePrefix().'Phrase WHERE Phrase = '.$this->adodbConnection->qstr($phrase_name); + $this->adodbConnection->Execute($sql); } $f->Delete(); }