38. File Comparison Report

Produced on Wed Jun 18 08:01:43 2008 UTC. This report uses XHTML and CSS2, and is best viewed with a reasonably standards compliant browser such as the latest version of Firefox or Internet Explorer. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

38.1 Files compared

# Location File Last Modified
1 Dolphin-v.6.1.1\inc\classes BxDolPFM.php Mon May 12 07:03:58 2008 UTC
2 Dolphin-v.6.1.2\inc\classes BxDolPFM.php Mon Jun 16 05:18:35 2008 UTC

38.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 6 3482
Changed 5 12
Inserted 0 0
Removed 0 0

38.3 Comparison options

Whitespace All differences in whitespace within lines are ignored
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

38.4 Active regular expressions

No regular expressions were active.

38.5 Comparison detail

1   <?   1   <?
2     2  
3   /*   3   /*
4       Profil e Fields M anager   4       Profil e Fields M anager
5   */   5   */
6     6  
7   class BxDo lPFM {   7   class BxDo lPFM {
8       functi on BxDolPF M( $iArea  ) {   8       functi on BxDolPF M( $iArea  ) {
9           $t his -> aCo lNames = a rray (   9           $t his -> aCo lNames = a rray (
10                1  => ar ray( 'Page ' => 'Join ',   'Orde r' => 'Joi nOrder',          'Bl ock' => 'J oinBlock',          ' ShowSysIte ms' => 'Co uple,Captc ha,TermsOf Use', 'Edi tAdd' => a rray( 'Joi nPage' ) ) ,   10                1  => ar ray( 'Page ' => 'Join ',   'Orde r' => 'Joi nOrder',          'Bl ock' => 'J oinBlock',          ' ShowSysIte ms' => 'Co uple,Captc ha,TermsOf Use', 'Edi tAdd' => a rray( 'Joi nPage' ) ) ,
11                   11                
12                2  => ar ray( 'Page ' => 'Edit ',   'Orde r' => 'Edi tOwnOrder' ,      'Bl ock' => 'E ditOwnBloc k' ),   12                2  => ar ray( 'Page ' => 'Edit ',   'Orde r' => 'Edi tOwnOrder' ,      'Bl ock' => 'E ditOwnBloc k' ),
13                3  => ar ray( 'Page ' => 'Edit ',   'Orde r' => 'Edi tAdmOrder' ,      'Bl ock' => 'E ditAdmBloc k',      ' ShowSysIte ms' => 'Fe atured,Sta tus,Member ship' ),   13                3  => ar ray( 'Page ' => 'Edit ',   'Orde r' => 'Edi tAdmOrder' ,      'Bl ock' => 'E ditAdmBloc k',      ' ShowSysIte ms' => 'Fe atured,Sta tus,Member ship' ),
14                4  => ar ray( 'Page ' => 'Edit ',   'Orde r' => 'Edi tModOrder' ,      'Bl ock' => 'E ditModBloc k',      ' ShowSysIte ms' => 'Fe atured,Sta tus,Member ship' ),   14                4  => ar ray( 'Page ' => 'Edit ',   'Orde r' => 'Edi tModOrder' ,      'Bl ock' => 'E ditModBloc k',      ' ShowSysIte ms' => 'Fe atured,Sta tus,Member ship' ),
15                   15                
16                5  => ar ray( 'Page ' => 'View ',   'Orde r' => 'Vie wAdmOrder' ,      'Bl ock' => 'V iewAdmBloc k',      ' ShowSysIte ms' => 'ID ,DateReg,D ateLastEdi t,DateLast Login,Stat us' ),   16                5  => ar ray( 'Page ' => 'View ',   'Orde r' => 'Vie wAdmOrder' ,      'Bl ock' => 'V iewAdmBloc k',      ' ShowSysIte ms' => 'ID ,DateReg,D ateLastEdi t,DateLast Login,Stat us' ),
17                6  => ar ray( 'Page ' => 'View ',   'Orde r' => 'Vie wMembOrder ',     'Bl ock' => 'V iewMembBlo ck',     ' ShowSysIte ms' => 'ID ,DateReg,D ateLastEdi t,DateLast Login,Stat us' ),   17                6  => ar ray( 'Page ' => 'View ',   'Orde r' => 'Vie wMembOrder ',     'Bl ock' => 'V iewMembBlo ck',     ' ShowSysIte ms' => 'ID ,DateReg,D ateLastEdi t,DateLast Login,Stat us' ),
18                7  => ar ray( 'Page ' => 'View ',   'Orde r' => 'Vie wModOrder' ,      'Bl ock' => 'V iewModBloc k',      ' ShowSysIte ms' => 'ID ,DateReg,D ateLastEdi t,DateLast Login,Stat us' ),   18                7  => ar ray( 'Page ' => 'View ',   'Orde r' => 'Vie wModOrder' ,      'Bl ock' => 'V iewModBloc k',      ' ShowSysIte ms' => 'ID ,DateReg,D ateLastEdi t,DateLast Login,Stat us' ),
19                8  => ar ray( 'Page ' => 'View ',   'Orde r' => 'Vie wVisOrder' ,      'Bl ock' => 'V iewVisBloc k',      ' ShowSysIte ms' => 'ID ,DateReg,D ateLastEdi t,DateLast Login,Stat us' ),   19                8  => ar ray( 'Page ' => 'View ',   'Orde r' => 'Vie wVisOrder' ,      'Bl ock' => 'V iewVisBloc k',      ' ShowSysIte ms' => 'ID ,DateReg,D ateLastEdi t,DateLast Login,Stat us' ),
20                   20                
21                9  => ar ray( 'Page ' => 'Sear ch', 'Orde r' => 'Sea rchSimpleO rder', 'Bl ock' => 'S earchSimpl eBlock', ' EditAdd' = > array( ' SearchPara ms' ), 'Sh owSysItems ' => 'ID,K eyword,Loc ation,Coup le' ),   21                9  => ar ray( 'Page ' => 'Sear ch', 'Orde r' => 'Sea rchSimpleO rder', 'Bl ock' => 'S earchSimpl eBlock', ' EditAdd' = > array( ' SearchPara ms' ), 'Sh owSysItems ' => 'ID,K eyword,Loc ation,Coup le' ),
22                10 => ar ray( 'Page ' => 'Sear ch', 'Orde r' => 'Sea rchQuickOr der',  'Bl ock' => 'S earchQuick Block',  ' EditAdd' = > array( ' SearchPara ms' ), 'Sh owSysItems ' => 'ID,K eyword,Loc ation,Coup le' ),   22                10 => ar ray( 'Page ' => 'Sear ch', 'Orde r' => 'Sea rchQuickOr der',  'Bl ock' => 'S earchQuick Block',  ' EditAdd' = > array( ' SearchPara ms' ), 'Sh owSysItems ' => 'ID,K eyword,Loc ation,Coup le' ),
23                11 => ar ray( 'Page ' => 'Sear ch', 'Orde r' => 'Sea rchAdvOrde r',    'Bl ock' => 'S earchAdvBl ock',    ' EditAdd' = > array( ' SearchPara ms' ), 'Sh owSysItems ' => 'ID,K eyword,Loc ation,Coup le' ),   23                11 => ar ray( 'Page ' => 'Sear ch', 'Orde r' => 'Sea rchAdvOrde r',    'Bl ock' => 'S earchAdvBl ock',    ' EditAdd' = > array( ' SearchPara ms' ), 'Sh owSysItems ' => 'ID,K eyword,Loc ation,Coup le' ),
24           );   24           );
25              25           
26           $t his -> sLi nkPref = ' #!'; //pre fix for va lues links   26           $t his -> sLi nkPref = ' #!'; //pre fix for va lues links
27              27           
28           $t his -> aTy pes = arra y(   28           $t his -> aTy pes = arra y(
29                'text'        => 'T ext',   29                'text'        => 'T ext',
30                'area'        => 'T extArea',   30                'area'        => 'T extArea',
31                'pass'        => 'P assword',   31                'pass'        => 'P assword',
32                'date'        => 'D ate',   32                'date'        => 'D ate',
33                'select_ one' => 'S elector',   33                'select_ one' => 'S elector',
34                'select_ set' => 'M ultiple Se lector',   34                'select_ set' => 'M ultiple Se lector',
35                'num'         => 'N umber',   35                'num'         => 'N umber',
36                'range'       => 'R ange',   36                'range'       => 'R ange',
37                'bool'        => 'B oolean (ch eckbox)'   37                'bool'        => 'B oolean (ch eckbox)'
38           );   38           );
39              39           
40           // altering t able prope rties   40           // altering t able prope rties
41           $t his -> aTy pesAlter =  array(   41           $t his -> aTy pesAlter =  array(
42                'text'        => "v archar(255 ) NOT NULL  {default} ",   42                'text'        => "v archar(255 ) NOT NULL  {default} ",
43                'area'        => "t ext NOT NU LL",   43                'area'        => "t ext NOT NU LL",
44                'pass'        => "v archar(32)  NOT NULL" ,   44                'pass'        => "v archar(32)  NOT NULL" ,
45                'date'        => "d ate NOT NU LL {defaul t}",   45                'date'        => "d ate NOT NU LL {defaul t}",
46                'select_ one' => "e num({value s})",   46                'select_ one' => "e num({value s})",
47                'select_ one_linked ' => "varc har(255) N OT NULL de fault ''",   47                'select_ one_linked ' => "varc har(255) N OT NULL de fault ''",
48                'select_ set' => "s et({values }) NOT NUL L default  ''",   48                'select_ set' => "s et({values }) NOT NUL L default  ''",
49                'select_ set_linked ' => "set( {values})  NOT NULL d efault ''" ,   49                'select_ set_linked ' => "set( {values})  NOT NULL d efault ''" ,
50                'num'         => "i nt(10) uns igned NOT  NULL {defa ult}",   50                'num'         => "i nt(10) uns igned NOT  NULL {defa ult}",
51                'range'       => "v archar(255 ) NOT NULL  {default} ",   51                'range'       => "v archar(255 ) NOT NULL  {default} ",
52                'bool'        => "t inyint(1)  NOT NULL { default}"   52                'bool'        => "t inyint(1)  NOT NULL { default}"
53           );   53           );
54              54           
55           $t his -> iAr eaID = (in t)$iArea;   55           $t his -> iAr eaID = (in t)$iArea;
56           if ( !( $this  -> iAreaI D > 0 and  isset( $th is -> aCol Names[$thi s -> iArea ID] ) ) )   56           if ( !( $this  -> iAreaI D > 0 and  isset( $th is -> aCol Names[$thi s -> iArea ID] ) ) )
57                return f alse;   57                return f alse;
58              58           
59           //  retrieve  default la nguage   59           //  retrieve  default la nguage
60           $s LangDfl =  addslashes ( getParam ('lang_def ault') );   60           $s LangDfl =  addslashes ( getParam ('lang_def ault') );
61           $s Query = "S ELECT `ID`  FROM `Loc alizationL anguages`  WHERE `Nam e` = '$sLa ngDfl'";   61           $s Query = "S ELECT `ID`  FROM `Loc alizationL anguages`  WHERE `Nam e` = '$sLa ngDfl'";
62           $t his -> sLa ngID = (in t)db_value ( $sQuery  );   62           $t his -> sLa ngID = (in t)db_value ( $sQuery  );
63              63           
64           if ( !$this - > sLangID  )   64           if ( !$this - > sLangID  )
65                return p rint 'Cann ot continu e. Default  language  not found. ';   65                return p rint 'Cann ot continu e. Default  language  not found. ';
66              66           
67           $t his -> are aPageName     = $this  -> aColNa mes[$this  -> iAreaID ]['Page'];   67           $t his -> are aPageName     = $this  -> aColNa mes[$this  -> iAreaID ]['Page'];
68           $t his -> are aOrderCol     = $this  -> aColNa mes[$this  -> iAreaID ]['Order'] ;   68           $t his -> are aOrderCol     = $this  -> aColNa mes[$this  -> iAreaID ]['Order'] ;
69           $t his -> are aBlockCol     = $this  -> aColNa mes[$this  -> iAreaID ]['Block'] ;   69           $t his -> are aBlockCol     = $this  -> aColNa mes[$this  -> iAreaID ]['Block'] ;
70           $t his -> are aSysItems     = $this  -> aColNa mes[$this  -> iAreaID ]['ShowSys Items'];   70           $t his -> are aSysItems     = $this  -> aColNa mes[$this  -> iAreaID ]['ShowSys Items'];
71              71           
72           $t his -> are aEditAddCo ls = $this  -> aColNa mes[$this  -> iAreaID ]['EditAdd '];   72           $t his -> are aEditAddCo ls = $this  -> aColNa mes[$this  -> iAreaID ]['EditAdd '];
73              73           
74           $t his -> aBl ocks = arr ay();   74           $t his -> aBl ocks = arr ay();
75           $t his -> aIt ems  = arr ay();   75           $t his -> aIt ems  = arr ay();
76              76           
77           $t his -> aBl ocksInac =  array();   77           $t his -> aBl ocksInac =  array();
78           $t his -> aIt emsInac  =  array();   78           $t his -> aIt emsInac  =  array();
79              79           
80       }   80       }
81          81       
82       functi on genJSON () {   82       functi on genJSON () {
83           $t his -> fil lMyArrays( );   83           $t his -> fil lMyArrays( );
84           $t his -> oJS ONObject =  new BxDol PFMAreaJSO NObj( $thi s );   84           $t his -> oJS ONObject =  new BxDol PFMAreaJSO NObj( $thi s );
85           $o JSONConv =  new Servi ces_JSON() ;   85           $o JSONConv =  new Servi ces_JSON() ;
86           re turn $oJSO NConv -> e ncode( $th is -> oJSO NObject );   86           re turn $oJSO NConv -> e ncode( $th is -> oJSO NObject );
87       }   87       }
88          88       
89       functi on fillMyA rrays() {   89       functi on fillMyA rrays() {
90           // collect ac tive field s   90           // collect ac tive field s
91              91           
92           // blocks   92           // blocks
93           $s BlocksQuer y = "   93           $s BlocksQuer y = "
94                SELECT   94                SELECT
95                    `ID` ,   95                    `ID` ,
96                    `Nam e`   96                    `Nam e`
97                FROM `Pr ofileField s`   97                FROM `Pr ofileField s`
98                WHERE   98                WHERE
99                    `{$t his -> are aOrderCol} ` IS NOT N ULL AND   99                    `{$t his -> are aOrderCol} ` IS NOT N ULL AND
100                    `Typ e` = 'bloc k'   100                    `Typ e` = 'bloc k'
101                ORDER BY   101                ORDER BY
102                    `{$t his -> are aOrderCol} `   102                    `{$t his -> are aOrderCol} `
103           ";   103           ";
104              104           
105           $r Blocks = d b_res( $sB locksQuery  );   105           $r Blocks = d b_res( $sB locksQuery  );
106              106           
107           wh ile( $aBlo ck = mysql _fetch_ass oc( $rBloc ks ) ) {   107           wh ile( $aBlo ck = mysql _fetch_ass oc( $rBloc ks ) ) {
108                $iBlockI D = $aBloc k['ID'];   108                $iBlockI D = $aBloc k['ID'];
109                   109                
110                $this ->  aBlocks[  $iBlockID  ] = $aBloc k['Name'];   110                $this ->  aBlocks[  $iBlockID  ] = $aBloc k['Name'];
111                   111                
112                //get it ems of thi s block   112                //get it ems of thi s block
113                $sItemsQ uery = "   113                $sItemsQ uery = "
114                    SELE CT   114                    SELE CT
115                         `ID`,   115                         `ID`,
116                         `Name`   116                         `Name`
117                    FROM  `ProfileF ields`   117                    FROM  `ProfileF ields`
118                    WHER E   118                    WHER E
119                         `Type` !=  'block' AN D   119                         `Type` !=  'block' AN D
120                         `{$this ->  areaOrder Col}` IS N OT NULL AN D   120                         `{$this ->  areaOrder Col}` IS N OT NULL AN D
121                         `{$this ->  areaBlock Col}` = $i BlockID AN D   121                         `{$this ->  areaBlock Col}` = $i BlockID AN D
122                         (   122                         (
123                             `Type`  != 'syste m' OR   123                             `Type`  != 'syste m' OR
124                             (   124                             (
125                                 `T ype` = 'sy stem' AND   125                                 `T ype` = 'sy stem' AND
126                                 FI ND_IN_SET(  `Name`, ' {$this ->  areaSysIte ms}' )   126                                 FI ND_IN_SET(  `Name`, ' {$this ->  areaSysIte ms}' )
127                             )   127                             )
128                         )   128                         )
129                    ORDE R BY   129                    ORDE R BY
130                         `{$this ->  areaOrder Col}`   130                         `{$this ->  areaOrder Col}`
131                ";   131                ";
132                   132                
133                $rItems  = db_res(  $sItemsQue ry );   133                $rItems  = db_res(  $sItemsQue ry );
134                   134                
135                while( $ aItem = my sql_fetch_ assoc( $rI tems ) )   135                while( $ aItem = my sql_fetch_ assoc( $rI tems ) )
136                    $thi s -> aItem s[ $aItem[ 'ID'] ] =  array( $aI tem['Name' ], $iBlock ID );   136                    $thi s -> aItem s[ $aItem[ 'ID'] ] =  array( $aI tem['Name' ], $iBlock ID );
137           }   137           }
138              138           
139           // collect in active fie lds   139           // collect in active fie lds
140              140           
141           // blocks   141           // blocks
142           $s BlocksInac Query = "   142           $s BlocksInac Query = "
143                SELECT   143                SELECT
144                    `ID` ,   144                    `ID` ,
145                    `Nam e`   145                    `Nam e`
146                FROM `Pr ofileField s`   146                FROM `Pr ofileField s`
147                WHERE   147                WHERE
148                    `{$t his -> are aOrderCol} ` IS NULL  AND   148                    `{$t his -> are aOrderCol} ` IS NULL  AND
149                    `Typ e` = 'bloc k'   149                    `Typ e` = 'bloc k'
150           ";   150           ";
151              151           
152           $r BlocksInac  = db_res(  $sBlocksI nacQuery ) ;   152           $r BlocksInac  = db_res(  $sBlocksI nacQuery ) ;
153              153           
154           wh ile( $aBlo ck = mysql _fetch_ass oc( $rBloc ksInac ) )   154           wh ile( $aBlo ck = mysql _fetch_ass oc( $rBloc ksInac ) )
155                $this ->  aBlocksIn ac[ $aBloc k['ID'] ]  = $aBlock[ 'Name'];   155                $this ->  aBlocksIn ac[ $aBloc k['ID'] ]  = $aBlock[ 'Name'];
156              156           
157           // items   157           // items
158           $s ActiveBloc ksList = i mplode( ', ', array_k eys( $this  -> aBlock s ) );   158           $s ActiveBloc ksList = i mplode( ', ', array_k eys( $this  -> aBlock s ) );
159           if ( $sActive BlocksList  == '' )   159           if ( $sActive BlocksList  == '' )
160                $sActive BlocksList  = "NULL";   160                $sActive BlocksList  = "NULL";
161              161           
162           $s ItemsInacQ uery = "   162           $s ItemsInacQ uery = "
163                SELECT   163                SELECT
164                    `ID` ,   164                    `ID` ,
165                    `Nam e`   165                    `Nam e`
166                FROM `Pr ofileField s`   166                FROM `Pr ofileField s`
167                WHERE   167                WHERE
168                    `Typ e` != 'blo ck' AND (   168                    `Typ e` != 'blo ck' AND (
169                         `{$this ->  areaBlock Col}` = 0  OR   169                         `{$this ->  areaBlock Col}` = 0  OR
170                         `{$this ->  areaBlock Col}` NOT  IN ($sActi veBlocksLi st)   170                         `{$this ->  areaBlock Col}` NOT  IN ($sActi veBlocksLi st)
171                    ) AN D (   171                    ) AN D (
172                         `Type` !=  'system' O R (   172                         `Type` !=  'system' O R (
173                             `Type`  = 'system ' AND   173                             `Type`  = 'system ' AND
174                             FIND_I N_SET( `Na me`, '{$th is -> area SysItems}'  )   174                             FIND_I N_SET( `Na me`, '{$th is -> area SysItems}'  )
175                         )   175                         )
176                    )   176                    )
177           ";   177           ";
178              178           
179           $r ItemsInac  = db_res(  $sItemsIna cQuery );   179           $r ItemsInac  = db_res(  $sItemsIna cQuery );
180              180           
181           wh ile( $aIte m = mysql_ fetch_asso c( $rItems Inac ) )   181           wh ile( $aIte m = mysql_ fetch_asso c( $rItems Inac ) )
182                $this ->  aItemsIna c[ $aItem[ 'ID'] ] =  $aItem['Na me'];   182                $this ->  aItemsIna c[ $aItem[ 'ID'] ] =  $aItem['Na me'];
183              183           
184           // echoDbg( $ this );exi t;   184           // echoDbg( $ this );exi t;
185       }   185       }
186          186       
187       functi on savePos itions( $a InArrays )  {   187       functi on savePos itions( $a InArrays )  {
188           db _res( "UPD ATE `Profi leFields`  SET `{$thi s -> areaO rderCol}`  = NULL" );   188           db _res( "UPD ATE `Profi leFields`  SET `{$thi s -> areaO rderCol}`  = NULL" );
189           db _res( "UPD ATE `Profi leFields`  SET `{$thi s -> areaB lockCol}`  = 0" );   189           db _res( "UPD ATE `Profi leFields`  SET `{$thi s -> areaB lockCol}`  = 0" );
190              190           
191           if ( is_array ( $aInArra ys['blocks '] ) ) {   191           if ( is_array ( $aInArra ys['blocks '] ) ) {
192                foreach(  $aInArray s['blocks' ] as $iBlo ckID ) {   192                foreach(  $aInArray s['blocks' ] as $iBlo ckID ) {
193                    $iBl ockID = (i nt)$iBlock ID;   193                    $iBl ockID = (i nt)$iBlock ID;
194                       194                    
195                    $iBl ockOrd = ( int)db_val ue( "   195                    $iBl ockOrd = ( int)db_val ue( "
196                         SELECT MAX ( `{$this  -> areaOrd erCol}` )   196                         SELECT MAX ( `{$this  -> areaOrd erCol}` )
197                         FROM `Prof ileFields`   197                         FROM `Prof ileFields`
198                         WHERE `Typ e` = 'bloc k'   198                         WHERE `Typ e` = 'bloc k'
199                    " )  + 1;   199                    " )  + 1;
200                       200                    
201                    db_r es( "   201                    db_r es( "
202                         UPDATE `Pr ofileField s`   202                         UPDATE `Pr ofileField s`
203                         SET `{$thi s -> areaO rderCol}`  = $iBlockO rd   203                         SET `{$thi s -> areaO rderCol}`  = $iBlockO rd
204                         WHERE `ID`  = $iBlock ID   204                         WHERE `ID`  = $iBlock ID
205                    " );   205                    " );
206                }   206                }
207                   207                
208                if( is_a rray( $aIn Arrays['it ems'] ) an d is_array ( $aInArra ys['items_ blocks'] )  ) {   208                if( is_a rray( $aIn Arrays['it ems'] ) an d is_array ( $aInArra ys['items_ blocks'] )  ) {
209                    fore ach( $aInA rrays['ite ms'] as $i ItemID ) {   209                    fore ach( $aInA rrays['ite ms'] as $i ItemID ) {
210                         $iItemID =  (int)$iIt emID;   210                         $iItemID =  (int)$iIt emID;
211                         $iItemBloc kID = (int )$aInArray s['items_b locks'][$i ItemID];   211                         $iItemBloc kID = (int )$aInArray s['items_b locks'][$i ItemID];
212                           212                        
213                         if( in_arr ay( $iItem BlockID, $ aInArrays[ 'blocks']  ) ) {   213                         if( in_arr ay( $iItem BlockID, $ aInArrays[ 'blocks']  ) ) {
214                             $iItem Ord = db_v alue( "   214                             $iItem Ord = db_v alue( "
215                                 SE LECT MAX(  `{$this ->  areaOrder Col}` )   215                                 SE LECT MAX(  `{$this ->  areaOrder Col}` )
216                                 FR OM `Profil eFields`   216                                 FR OM `Profil eFields`
217                                 WH ERE `Type`  != 'block ' AND `{$t his -> are aBlockCol} ` = $iItem BlockID   217                                 WH ERE `Type`  != 'block ' AND `{$t his -> are aBlockCol} ` = $iItem BlockID
218                             " ) +  1;   218                             " ) +  1;
219                                219                             
220                             db_res ( "   220                             db_res ( "
221                                 UP DATE `Prof ileFields`   221                                 UP DATE `Prof ileFields`
222                                 SE T   222                                 SE T
223                                      `{$this  -> areaOrd erCol}` =  $iItemOrd,   223                                      `{$this  -> areaOrd erCol}` =  $iItemOrd,
224                                      `{$this  -> areaBlo ckCol}` =  $iItemBloc kID   224                                      `{$this  -> areaBlo ckCol}` =  $iItemBloc kID
225                                 WH ERE `ID` =  $iItemID   225                                 WH ERE `ID` =  $iItemID
226                             " );   226                             " );
227                         }   227                         }
228                    }   228                    }
229                }   229                }
230           }   230           }
231              231           
232           ec ho 'OK';   232           ec ho 'OK';
233       }   233       }
234          234       
235       functi on genFiel dEditForm(  $iItemID  ) {   235       functi on genFiel dEditForm(  $iItemID  ) {
236           $s Query = "   236           $s Query = "
237                SELECT   237                SELECT
238                    `Nam e`,   238                    `Nam e`,
239                    `Typ e`,   239                    `Typ e`,
240                    `Con trol`,   240                    `Con trol`,
241                    `Ext ra`,   241                    `Ext ra`,
242                    `Min `,   242                    `Min `,
243                    `Max `,   243                    `Max `,
244                    `Val ues`,   244                    `Val ues`,
245                    `Use LKey`,   245                    `Use LKey`,
246                    `Che ck`,   246                    `Che ck`,
247                    `Uni que`,   247                    `Uni que`,
248                    `Def ault`,   248                    `Def ault`,
249                    `Man datory`,   249                    `Man datory`,
250                    `Del etable`,   250                    `Del etable`,
251                    `Mat chField`,   251                    `Mat chField`,
252                    `Mat chPercent` " .   252                    `Mat chPercent` " .
253                       253                    
254                    ( $t his -> are aEditAddCo ls ?   254                    ( $t his -> are aEditAddCo ls ?
255                         ( ', `' .  implode( ' `, `', $th is -> area EditAddCol s ) . '`'  ) :   255                         ( ', `' .  implode( ' `, `', $th is -> area EditAddCol s ) . '`'  ) :
256                         ''   256                         ''
257                    ) .  "   257                    ) .  "
258                       258                    
259                FROM `Pr ofileField s` WHERE ` ID` = $iIt emID";   259                FROM `Pr ofileField s` WHERE ` ID` = $iIt emID";
260              260           
261           $a Field = db _assoc_arr ( $sQuery  );   261           $a Field = db _assoc_arr ( $sQuery  );
262              262           
263           if ( !$aField  ) {   263           if ( !$aField  ) {
264                echo 'Er ror. Field  not found ';   264                echo 'Er ror. Field  not found ';
265                return;   265                return;
266           }   266           }
267              267           
268           //  field tit le and des cription   268           //  field tit le and des cription
269           $t his -> fie ldCaption  = "_FieldC aption_{$a Field['Nam e']}_{$thi s -> areaP ageName}";  // _Field Caption_Se x_Join   269           $t his -> fie ldCaption  = "_FieldC aption_{$a Field['Nam e']}_{$thi s -> areaP ageName}";  // _Field Caption_Se x_Join
270           $t his -> fie ldDesc     = "_FieldD esc_{$aFie ld['Name'] }_{$this - > areaPage Name}";     // _Field Desc_Sex_J oin   270           $t his -> fie ldDesc     = "_FieldD esc_{$aFie ld['Name'] }_{$this - > areaPage Name}";     // _Field Desc_Sex_J oin
271              271           
272           $t his -> sho wFormTabs  = ( $aFiel d['Type']  != 'block'  and $aFie ld['Type']  != 'syste m' );   272           $t his -> sho wFormTabs  = ( $aFiel d['Type']  != 'block'  and $aFie ld['Type']  != 'syste m' );
273              273           
274              274           
275           ?>   275           ?>
276           <i nput type= "hidden" n ame="actio n" value=" saveItem"  />   276           <i nput type= "hidden" n ame="actio n" value=" saveItem"  />
277           <i nput type= "hidden" n ame="id" v alue="<?=  $iItemID ? >" />   277           <i nput type= "hidden" n ame="id" v alue="<?=  $iItemID ? >" />
278           <i nput type= "hidden" n ame="area"  value="<? = $this ->  iAreaID ? >" />   278           <i nput type= "hidden" n ame="area"  value="<? = $this ->  iAreaID ? >" />
279              279           
280           <?   280           <?
281           if ( $this ->  showFormT abs ) {   281           if ( $this ->  showFormT abs ) {
282                ?>   282                ?>
283           <d iv class=" form_tabs_ cont">   283           <d iv class=" form_tabs_ cont">
284                <ul id=" form_tabs_ switcher">   284                <ul id=" form_tabs_ switcher">
285                    <li> <a href="# f1">Genera l</a></li>   285                    <li> <a href="# f1">Genera l</a></li>
286                    <li> <a href="# f2">Advanc ed</a></li >   286                    <li> <a href="# f2">Advanc ed</a></li >
287                    <li> <a href="# f3">Messag es</a></li >   287                    <li> <a href="# f3">Messag es</a></li >
288                    <li> <a href="# f4">Matchi ng</a></li >   288                    <li> <a href="# f4">Matchi ng</a></li >
289                </ul>   289                </ul>
290           </ div>   290           </ div>
291                <?   291                <?
292           }   292           }
293           ?>   293           ?>
294              294           
295              295           
296           <t able class ="field_ed it_tab" id ="f1"> <!- - General  -->   296           <t able class ="field_ed it_tab" id ="f1"> <!- - General  -->
297                <tr>   297                <tr>
298                    <td  class="lab el">Name:< /td>   298                    <td  class="lab el">Name:< /td>
299                    <td  class="val ue">   299                    <td  class="val ue">
300                         <input typ e="text" m axlength=" 255" class ="input_te xt" name=" Name"   300                         <input typ e="text" m axlength=" 255" class ="input_te xt" name=" Name"
301                           value="< ?= htmlspe cialchars(  $aField[' Name'] );  ?>"   301                           value="< ?= htmlspe cialchars(  $aField[' Name'] );  ?>"
302                           <? if( $ aField['Ty pe'] == 's ystem' or  !$aField[' Deletable' ] ) echo ' readonly=" readonly"' ; ?> />   302                           <? if( $ aField['Ty pe'] == 's ystem' or  !$aField[' Deletable' ] ) echo ' readonly=" readonly"' ; ?> />
303                    </td >   303                    </td >
304                    <td  class="inf o">   304                    <td  class="inf o">
305           <?   305           <?
306           if ( $aField[ 'Type'] !=  'block' a nd $aField ['Type'] ! = 'system'  )   306           if ( $aField[ 'Type'] !=  'block' a nd $aField ['Type'] ! = 'system'  )
307                echo $th is -> getI nfoIcon( ' System nam e used for  database.  It must b egin with  a latin le tter and c ontain onl y latin le tters, num bers or un derscores. ');   307                echo $th is -> getI nfoIcon( ' System nam e used for  database.  It must b egin with  a latin le tter and c ontain onl y latin le tters, num bers or un derscores. ');
308           el se   308           el se
309                echo '&n bsp;';   309                echo '&n bsp;';
310           ?>   310           ?>
311                    </td >   311                    </td >
312                </tr>   312                </tr>
313                <tr>   313                <tr>
314                    <td  class="lab el">Captio n:</td>   314                    <td  class="lab el">Captio n:</td>
315                    <td  class="val ue">   315                    <td  class="val ue">
316                         <input typ e="text" m axlength=" 255" class ="input_te xt" name=" Caption"   316                         <input typ e="text" m axlength=" 255" class ="input_te xt" name=" Caption"
317                           value="< ?= htmlspe cialchars(  $this ->  getLangStr ing( $this  -> fieldC aption ) ) ; ?>" />   317                           value="< ?= htmlspe cialchars(  $this ->  getLangStr ing( $this  -> fieldC aption ) ) ; ?>" />
318                    </td >   318                    </td >
319                    <td  class="inf o">   319                    <td  class="inf o">
320                         <?= $this  -> getInfo Icon( "Tra nslation o f the item  caption o n the {$th is -> area PageName}  page to de fault lang uage. Used  key: <b>{ $this -> f ieldCaptio n}</b>. Do  not type  HTML code  here!" ) ? >   320                         <?= $this  -> getInfo Icon( "Tra nslation o f the item  caption o n the {$th is -> area PageName}  page to de fault lang uage. Used  key: <b>{ $this -> f ieldCaptio n}</b>. Do  not type  HTML code  here!" ) ? >
321                    </td >   321                    </td >
322                </tr>   322                </tr>
323                <tr>   323                <tr>
324                    <td  class="lab el">Descri ption:</td >   324                    <td  class="lab el">Descri ption:</td >
325                    <td  class="val ue">   325                    <td  class="val ue">
326                         <textarea  class="inp ut_text" n ame="Desc" ><?= htmls pecialchar s( $this - > getLangS tring( $th is -> fiel dDesc ) );  ?></texta rea>   326                         <textarea  class="inp ut_text" n ame="Desc" ><?= htmls pecialchar s( $this - > getLangS tring( $th is -> fiel dDesc ) );  ?></texta rea>
327                    </td >   327                    </td >
328                    <td  class="inf o">   328                    <td  class="inf o">
329                         <?= $this  -> getInfo Icon( "Tra nslation o f the item  descripti on on the  {$this ->  areaPageNa me} page t o default  language.  Used key:  <b>{$this  -> fieldDe sc}</b>."  ) ?>   329                         <?= $this  -> getInfo Icon( "Tra nslation o f the item  descripti on on the  {$this ->  areaPageNa me} page t o default  language.  Used key:  <b>{$this  -> fieldDe sc}</b>."  ) ?>
330                    </td >   330                    </td >
331                </tr>   331                </tr>
332           <?   332           <?
333              333           
334           if ( $aField[ 'Type'] ==  'block' )  {   334           if ( $aField[ 'Type'] ==  'block' )  {
335                if( $thi s -> iArea ID == 1 )  { //Join   335                if( $thi s -> iArea ID == 1 )  { //Join
336                    ?>   336                    ?>
337                <tr>   337                <tr>
338                    <td  class="lab el">Join P age:</td>   338                    <td  class="lab el">Join P age:</td>
339                    <td  class="val ue">   339                    <td  class="val ue">
340                         <?= $this  -> getJoin PagesSelec tor( $aFie ld['JoinPa ge'] ) ?>   340                         <?= $this  -> getJoin PagesSelec tor( $aFie ld['JoinPa ge'] ) ?>
341                    </td >   341                    </td >
342                    <td  class="inf o">&nbsp;< /td>   342                    <td  class="inf o">&nbsp;< /td>
343                </tr>   343                </tr>
344                    <?   344                    <?
345                }   345                }
346           }  else {   346           }  else {
347                ?>   347                ?>
348                <tr>   348                <tr>
349                    <td  class="lab el">Type:< /td>   349                    <td  class="lab el">Type:< /td>
350                    <td  class="val ue">   350                    <td  class="val ue">
351                <?   351                <?
352                if( $aFi eld['Type' ] == 'syst em' )   352                if( $aFi eld['Type' ] == 'syst em' )
353                    echo  'System';   353                    echo  'System';
354                else {   354                else {
355                    ?>   355                    ?>
356                         <select na me="Type"  class="sel ect_type"  onchange=" changeFiel dType( thi s.value ); ">   356                         <select na me="Type"  class="sel ect_type"  onchange=" changeFiel dType( thi s.value ); ">
357                             <?= $t his -> get TypeOption s( $aField ['Type'] )  ?>   357                             <?= $t his -> get TypeOption s( $aField ['Type'] )  ?>
358                         </select>   358                         </select>
359                    <?   359                    <?
360                }   360                }
361                ?>   361                ?>
362                    </td >   362                    </td >
363                    <td  class="inf o">&nbsp;< /td>   363                    <td  class="inf o">&nbsp;< /td>
364                </tr>   364                </tr>
365                <?   365                <?
366           }   366           }
367              367           
368           // system fie lds proper ties   368           // system fie lds proper ties
369           if ( $aField[ 'Name'] ==  'Keyword'  ) {   369           if ( $aField[ 'Name'] ==  'Keyword'  ) {
370                ?>   370                ?>
371                <tr>   371                <tr>
372                    <td  class="lab el">Search  in fields :</td>   372                    <td  class="lab el">Search  in fields :</td>
373                    <td  class="val ue">   373                    <td  class="val ue">
374                         <select na me="Keywor dFields[]"  class="se lect_multi ple" multi ple="multi ple">   374                         <select na me="Keywor dFields[]"  class="se lect_multi ple" multi ple="multi ple">
375                             <?= $t his -> get FieldsOpti onsList( $ aField['Ex tra'], 'Ke yword' ) ? >   375                             <?= $t his -> get FieldsOpti onsList( $ aField['Ex tra'], 'Ke yword' ) ? >
376                         </select>   376                         </select>
377                    </td >   377                    </td >
378                    <td  class="inf o">   378                    <td  class="inf o">
379                         <?= $this  -> getInfo Icon( 'Sel ect fields  in which  the Keywor d will be  able to se arch. Use  Ctrl key t o select f ew fields. ' ) ?>   379                         <?= $this  -> getInfo Icon( 'Sel ect fields  in which  the Keywor d will be  able to se arch. Use  Ctrl key t o select f ew fields. ' ) ?>
380                    </td >   380                    </td >
381                </tr>   381                </tr>
382                <?   382                <?
383           }  elseif( $a Field['Nam e'] == 'Co uple' ) {   383           }  elseif( $a Field['Nam e'] == 'Co uple' ) {
384                ?>   384                ?>
385                <tr>   385                <tr>
386                    <td  class="lab el">Mutual  couple fi elds:</td>   386                    <td  class="lab el">Mutual  couple fi elds:</td>
387                    <td  class="val ue">   387                    <td  class="val ue">
388                         <select na me="Couple Fields[]"  class="sel ect_multip le" multip le="multip le">   388                         <select na me="Couple Fields[]"  class="sel ect_multip le" multip le="multip le">
389                             <?= $t his -> get FieldsOpti onsList( $ aField['Ex tra'], 'Co uple' ) ?>   389                             <?= $t his -> get FieldsOpti onsList( $ aField['Ex tra'], 'Co uple' ) ?>
390                         </select>   390                         </select>
391                    </td >   391                    </td >
392                    <td  class="inf o">   392                    <td  class="inf o">
393                         <?= $this  -> getInfo Icon( 'Sel ect fields  which wil l be used  as mutual  for both p ersons in  a couple.  Use Ctrl k ey to sele ct few fie lds.<br /> <b>Note:</ b> NickNam e, Passwor d and Emai l are mand atory mutu al.' ) ?>   393                         <?= $this  -> getInfo Icon( 'Sel ect fields  which wil l be used  as mutual  for both p ersons in  a couple.  Use Ctrl k ey to sele ct few fie lds.<br /> <b>Note:</ b> NickNam e, Passwor d and Emai l are mand atory mutu al.' ) ?>
394                    </td >   394                    </td >
395                </tr>   395                </tr>
396                <?   396                <?
397           }   397           }
398              398           
399           ?>   399           ?>
400           </ table>   400           </ table>
401              401           
402           <?   402           <?
403              403           
404           if ( $this ->  showFormT abs ) {   404           if ( $this ->  showFormT abs ) {
405                $this ->  genFormAd vTab( $aFi eld );   405                $this ->  genFormAd vTab( $aFi eld );
406                $this ->  genFormMi scTab( $aF ield );   406                $this ->  genFormMi scTab( $aF ield );
407                $this ->  genFormMa tchTab( $a Field );   407                $this ->  genFormMa tchTab( $a Field );
408           }   408           }
409              409           
410           ?>   410           ?>
411           <t able class ="field_ed it_tab"> < !--Control s-->   411           <t able class ="field_ed it_tab"> < !--Control s-->
412                <tr>   412                <tr>
413                    <td  class="but tons" cols pan="3">   413                    <td  class="but tons" cols pan="3">
414                         <input typ e="submit"  name="act ion" value ="Save" />   414                         <input typ e="submit"  name="act ion" value ="Save" />
415           <?   415           <?
416              416           
417           if ( $aField[ 'Type'] !=  'system'  and $aFiel d['Deletab le'] ) {   417           if ( $aField[ 'Type'] !=  'system'  and $aFiel d['Deletab le'] ) {
418                ?>   418                ?>
419                         <input typ e="submit"  name="act ion" value ="Delete"  onclick="r eturn conf irm('Are y ou sure wa nt to dele te this it em?\nAtten tion! The  field will  be delete d forever.  This oper ation irre versible!' );" />   419                         <input typ e="submit"  name="act ion" value ="Delete"  onclick="r eturn conf irm('Are y ou sure wa nt to dele te this it em?\nAtten tion! The  field will  be delete d forever.  This oper ation irre versible!' );" />
420                <?   420                <?
421           }   421           }
422           ?>   422           ?>
423                         <input typ e="reset"  value="Can cel" />   423                         <input typ e="reset"  value="Can cel" />
424                    </td >   424                    </td >
425                </tr>   425                </tr>
426           </ table>   426           </ table>
427              427           
428           <s cript type ="text/jav ascript">   428           <s cript type ="text/jav ascript">
429                $(docume nt).ready(  function( ){   429                $(docume nt).ready(  function( ){
430                    $('# form_tabs_ switcher') .tabs();   430                    $('# form_tabs_ switcher') .tabs();
431                    chan geFieldTyp e( '<?= $a Field['Typ e'] ?>' );   431                    chan geFieldTyp e( '<?= $a Field['Typ e'] ?>' );
432                } );   432                } );
433           </ script>   433           </ script>
434           <?   434           <?
435       }   435       }
436          436       
437       functi on getFiel dsOptionsL ist( $sSel ected, $sT ype ) {   437       functi on getFiel dsOptionsL ist( $sSel ected, $sT ype ) {
438           $a Selected =  explode(  "\n", $sSe lected );   438           $a Selected =  explode(  "\n", $sSe lected );
439           fo reach( $aS elected as  $iKey =>  $sValue )   439           fo reach( $aS elected as  $iKey =>  $sValue )
440                $aSelect ed[$iKey]  = trim( $s Value );   440                $aSelect ed[$iKey]  = trim( $s Value );
441              441           
442           sw itch( $sTy pe ) {   442           sw itch( $sTy pe ) {
443                case 'Ke yword': $s Where = "` Type` = 't ext' OR `T ype` = 'ar ea'"; brea k;   443                case 'Ke yword': $s Where = "` Type` = 't ext' OR `T ype` = 'ar ea'"; brea k;
444                case 'Co uple' : $s Where = "` Type` != ' block' AND  `Type` !=  'system'  AND `Delet able` = 1" ; break;   444                case 'Co uple' : $s Where = "` Type` != ' block' AND  `Type` !=  'system'  AND `Delet able` = 1" ; break;
445                default        : $s Where = "0 ";   445                default        : $s Where = "0 ";
446           }   446           }
447              447           
448              448           
449              449           
450           $s Query = "S ELECT `Nam e` FROM `P rofileFiel ds` WHERE  $sWhere";   450           $s Query = "S ELECT `Nam e` FROM `P rofileFiel ds` WHERE  $sWhere";
451           $r Fields = d b_res( $sQ uery );   451           $r Fields = d b_res( $sQ uery );
452              452           
453           $s Ret = '';   453           $s Ret = '';
454           wh ile( $aFie ld = mysql _fetch_ass oc( $rFiel ds ) ) {   454           wh ile( $aFie ld = mysql _fetch_ass oc( $rFiel ds ) ) {
455                $sRet .=  '<option  value="' .  $aField[' Name'] . ' "' .   455                $sRet .=  '<option  value="' .  $aField[' Name'] . ' "' .
456                ( in_arr ay( $aFiel d['Name'],  $aSelecte d ) ? 'sel ected="sel ected"' :  '' ) . '>'  .   456                ( in_arr ay( $aFiel d['Name'],  $aSelecte d ) ? 'sel ected="sel ected"' :  '' ) . '>'  .
457                $aField[ 'Name'] .  '</option> ';   457                $aField[ 'Name'] .  '</option> ';
458           }   458           }
459              459           
460           re turn $sRet ;   460           re turn $sRet ;
461       }   461       }
462          462       
463       functi on getJoin PagesSelec tor( $iCur rent ) {   463       functi on getJoin PagesSelec tor( $iCur rent ) {
464           $s Query = "S ELECT MAX(  `JoinPage ` ) FROM ` ProfileFie lds`";   464           $s Query = "S ELECT MAX(  `JoinPage ` ) FROM ` ProfileFie lds`";
465           $i MaxPage =  (int)db_va lue( $sQue ry );   465           $i MaxPage =  (int)db_va lue( $sQue ry );
466              466           
467           $s Ret = '<se lect name= "JoinPage"  class="se lect_page" >';   467           $s Ret = '<se lect name= "JoinPage"  class="se lect_page" >';
468           fo r( $iPage  = 0; $iPag e <= ( $iM axPage + 1  ); $iPage  ++ ) {   468           fo r( $iPage  = 0; $iPag e <= ( $iM axPage + 1  ); $iPage  ++ ) {
469                $sRet .=     469                $sRet .=  
470                    '<op tion value ="' . $iPa ge . '"' .   470                    '<op tion value ="' . $iPa ge . '"' .
471                    ( (  $iPage ==  $iCurrent  ) ? ' sele cted="sele cted"' : ' ' ) . '>'  .   471                    ( (  $iPage ==  $iCurrent  ) ? ' sele cted="sele cted"' : ' ' ) . '>'  .
472                    $iPa ge . '</op tion>';   472                    $iPa ge . '</op tion>';
473           }   473           }
474           $s Ret .= '</ select>';   474           $s Ret .= '</ select>';
475              475           
476           re turn $sRet ;   476           re turn $sRet ;
477       }   477       }
478          478       
479       functi on genForm MatchTab(  $aField )  {   479       functi on genForm MatchTab(  $aField )  {
480           $a Form = arr ay(   480           $a Form = arr ay(
481                'MatchFi eld' => ar ray(   481                'MatchFi eld' => ar ray(
482                    'lab el' => 'Ma tch with f ield',   482                    'lab el' => 'Ma tch with f ield',
483                    'typ e'  => 'se lect',   483                    'typ e'  => 'se lect',
484                    'inf o'  => 'Se lect a fie ld which w ill be mat ched with  the curren t.<br /> < b>Note:</b > We recom mend using  the same  field.',   484                    'inf o'  => 'Se lect a fie ld which w ill be mat ched with  the curren t.<br /> < b>Note:</b > We recom mend using  the same  field.',
485                    'val ue' => $aF ield['Matc hField'],   485                    'val ue' => $aF ield['Matc hField'],
486                    'val ues' => $t his -> get MatchField s( $aField  )   486                    'val ues' => $t his -> get MatchField s( $aField  )
487                ),   487                ),
488                'MatchPe rcent' =>  array(   488                'MatchPe rcent' =>  array(
489                    'lab el' => 'Ma tch percen t',   489                    'lab el' => 'Ma tch percen t',
490                    'typ e'  => 'te xt',   490                    'typ e'  => 'te xt',
491                    'inf o'  => 'En ter percen tage that  this field  will matc h',   491                    'inf o'  => 'En ter percen tage that  this field  will matc h',
492                    'val ue' => $aF ield['Matc hPercent']   492                    'val ue' => $aF ield['Matc hPercent']
493                )   493                )
494           );   494           );
495              495           
496           $t his -> gen TableEdit(  $aForm, ' f4' );   496           $t his -> gen TableEdit(  $aForm, ' f4' );
497       }   497       }
498          498       
499       functi on getMatc hFields( $ aField ) {   499       functi on getMatc hFields( $ aField ) {
500           $a SelectFiel ds = array ( $aField[ 'Type'] );   500           $a SelectFiel ds = array ( $aField[ 'Type'] );
501              501           
502           sw itch( $aFi eld['Type' ] ) {   502           sw itch( $aFi eld['Type' ] ) {
503                case 'se lect_set':   503                case 'se lect_set':
504                    $aSe lectFields [] = 'sele ct_one';   504                    $aSe lectFields [] = 'sele ct_one';
505                break;   505                break;
506                   506                
507                case 'se lect_one':   507                case 'se lect_one':
508                    $aSe lectFields [] = 'sele ct_set';   508                    $aSe lectFields [] = 'sele ct_set';
509                break;   509                break;
510                   510                
511                case 'ra nge':   511                case 'ra nge':
512                    $aSe lectFields [] = 'num' ;   512                    $aSe lectFields [] = 'num' ;
513                    $aSe lectFields [] = 'date ';   513                    $aSe lectFields [] = 'date ';
514                break;   514                break;
515           }   515           }
516              516           
517           $s Query = "S ELECT `ID` , `Name` F ROM `Profi leFields`  WHERE FIND _IN_SET( ` Type`, '"  . implode(  ',', $aSe lectFields  ) . "' )" ;   517           $s Query = "S ELECT `ID` , `Name` F ROM `Profi leFields`  WHERE FIND _IN_SET( ` Type`, '"  . implode(  ',', $aSe lectFields  ) . "' )" ;
518           $r MyFields =  db_res( $ sQuery );   518           $r MyFields =  db_res( $ sQuery );
519              519           
520           $a MyFields =  array( '0 ' => '-Not  set-' );   520           $a MyFields =  array( '0 ' => '-Not  set-' );
521           wh ile( $aMyF ield = mys ql_fetch_a ssoc( $rMy Fields ) )  {   521           wh ile( $aMyF ield = mys ql_fetch_a ssoc( $rMy Fields ) )  {
522                $aMyFiel ds[ $aMyFi eld['ID']  ] = $aMyFi eld['Name' ];   522                $aMyFiel ds[ $aMyFi eld['ID']  ] = $aMyFi eld['Name' ];
523           }   523           }
524              524           
525           re turn $aMyF ields;   525           re turn $aMyF ields;
526       }   526       }
527          527       
528       functi on genForm AdvTab( $a Field ) {   528       functi on genForm AdvTab( $a Field ) {
529              529           
530           $a Form = arr ay(   530           $a Form = arr ay(
531                'Control _one' => a rray(   531                'Control _one' => a rray(
532                    'lab el'  => 'S elector co ntrol',   532                    'lab el'  => 'S elector co ntrol',
533                    'typ e'   => 's elect',   533                    'typ e'   => 's elect',
534                    'inf o'   => 'T he type of  form inpu t (HTML-el ement).',   534                    'inf o'   => 'T he type of  form inpu t (HTML-el ement).',
535                    'val ue'  => $a Field['Con trol'],   535                    'val ue'  => $a Field['Con trol'],
536                    'row _id' => 'f ield_contr ol_select_ one',   536                    'row _id' => 'f ield_contr ol_select_ one',
537                    'val ues' => ar ray(    537                    'val ues' => ar ray( 
538                         'select' = > 'Select  (Dropdown  box)',   538                         'select' = > 'Select  (Dropdown  box)',
539                         'radio'  = > 'Radio-b uttons'   539                         'radio'  = > 'Radio-b uttons'
540                    )   540                    )
541                ),   541                ),
542                'Control _set' => a rray(   542                'Control _set' => a rray(
543                    'lab el'  => 'M ultiple se lector con trol',   543                    'lab el'  => 'M ultiple se lector con trol',
544                    'typ e'   => 's elect',   544                    'typ e'   => 's elect',
545                    'inf o'   => 'T he type of  form inpu t (HTML-el ement).',   545                    'inf o'   => 'T he type of  form inpu t (HTML-el ement).',
546                    'val ue'  => $a Field['Con trol'],   546                    'val ue'  => $a Field['Con trol'],
547                    'row _id' => 'f ield_contr ol_select_ set',   547                    'row _id' => 'f ield_contr ol_select_ set',
548                    'val ues' => ar ray(    548                    'val ues' => ar ray( 
549                         'select' = > 'Select  (Box)',   549                         'select' = > 'Select  (Box)',
550                         'checkbox'  => 'Check boxes'   550                         'checkbox'  => 'Check boxes'
551                    )   551                    )
552                ),   552                ),
553                'Mandato ry' => arr ay(   553                'Mandato ry' => arr ay(
554                    'lab el'  => 'M andatory',   554                    'lab el'  => 'M andatory',
555                    'typ e'   => 'c heckbox',   555                    'typ e'   => 'c heckbox',
556                    'inf o'   => 'R ed asteris k indicate s a field  which requ ires a man datory ent ry.',   556                    'inf o'   => 'R ed asteris k indicate s a field  which requ ires a man datory ent ry.',
557                    'val ue'  => $a Field['Man datory']   557                    'val ue'  => $a Field['Man datory']
558                ),   558                ),
559                'Min' =>  array(   559                'Min' =>  array(
560                    'lab el'  => 'M inimum val ue',   560                    'lab el'  => 'M inimum val ue',
561                    'typ e'   => 't ext',   561                    'typ e'   => 't ext',
562                    'inf o'   => 'F or "text"  or "passwo rd" - mini mum length , for "num ber" - min imum numbe r, etc. Le ave it emp ty for no  restrictio n.',   562                    'inf o'   => 'F or "text"  or "passwo rd" - mini mum length , for "num ber" - min imum numbe r, etc. Le ave it emp ty for no  restrictio n.',
563                    'val ue'  => $a Field['Min '],   563                    'val ue'  => $a Field['Min '],
564                    'row _id' => 'f ield_minim um'   564                    'row _id' => 'f ield_minim um'
565                ),   565                ),
566                'Max' =>  array(   566                'Max' =>  array(
567                    'lab el'  => 'M aximum val ue',   567                    'lab el'  => 'M aximum val ue',
568                    'typ e'   => 't ext',   568                    'typ e'   => 't ext',
569                    'inf o'   => 'F or "text"  or "passwo rd" - maxi mum length , for "num ber" - max imum numbe r, etc. Le ave it emp ty for no  restrictio n.',   569                    'inf o'   => 'F or "text"  or "passwo rd" - maxi mum length , for "num ber" - max imum numbe r, etc. Le ave it emp ty for no  restrictio n.',
570                    'val ue'  => $a Field['Max '],   570                    'val ue'  => $a Field['Max '],
571                    'row _id' => 'f ield_maxim um'   571                    'row _id' => 'f ield_maxim um'
572                ),   572                ),
573                'Unique'  => array(   573                'Unique'  => array(
574                    'lab el'  => 'U nique',   574                    'lab el'  => 'U nique',
575                    'typ e'   => 'c heckbox',   575                    'typ e'   => 'c heckbox',
576                    'inf o'   => 'D efine if f ield value  for membe r must be  unique. Fo r example,  NickName  or Email.' ,   576                    'inf o'   => 'D efine if f ield value  for membe r must be  unique. Fo r example,  NickName  or Email.' ,
577                    'val ue'  => $a Field['Uni que'],   577                    'val ue'  => $a Field['Uni que'],
578                    'row _id' => 'f ield_uniqu e'   578                    'row _id' => 'f ield_uniqu e'
579                ),   579                ),
580                'Check'  => array(   580                'Check'  => array(
581                    'lab el'  => 'C heck',   581                    'lab el'  => 'C heck',
582                    'typ e'   => 't extarea',   582                    'typ e'   => 't extarea',
583                    'inf o'   => 'S ome specif ic check ( PHP-expres sion). For  example,  for checki ng Email,  etc. Atten tion! Do n ot put her e min/max/ unique che cks. They  are define d above.',   583                    'inf o'   => 'S ome specif ic check ( PHP-expres sion). For  example,  for checki ng Email,  etc. Atten tion! Do n ot put her e min/max/ unique che cks. They  are define d above.',
584                    'val ue'  => $a Field['Che ck'],   584                    'val ue'  => $a Field['Che ck'],
585                    'row _id' => 'f ield_check '   585                    'row _id' => 'f ield_check '
586                ),   586                ),
587                'Values'  => array(   587                'Values'  => array(
588                    'lab el'  => 'P ossible va lues',   588                    'lab el'  => 'P ossible va lues',
589                    'typ e'   => 'v alues',   589                    'typ e'   => 'v alues',
590                    'inf o'   => 'L ist of pos sible valu es for sel ectors. Us e new line  as divide r. Also it  can be li nk to pred efined lis t. Please  do not cha nge it if  in doubt!' ,   590                    'inf o'   => 'L ist of pos sible valu es for sel ectors. Us e new line  as divide r. Also it  can be li nk to pred efined lis t. Please  do not cha nge it if  in doubt!' ,
591                    'val ue'  => $a Field['Val ues'],   591                    'val ue'  => $a Field['Val ues'],
592                    'row _id' => 'f ield_value s'   592                    'row _id' => 'f ield_value s'
593                ),   593                ),
594                'UseLKey ' => array (   594                'UseLKey ' => array (
595                    'lab el'  => 'U sed lang.  key',   595                    'lab el'  => 'U sed lang.  key',
596                    'typ e'   => 's elect',   596                    'typ e'   => 's elect',
597                    'inf o'   => 'F or selecto rs with "l inked" val ues list y ou can use  different  language  keys. We r ecommend t o not chan ge it if y ou are in  doubt. The  default i s "LKey".' ,   597                    'inf o'   => 'F or selecto rs with "l inked" val ues list y ou can use  different  language  keys. We r ecommend t o not chan ge it if y ou are in  doubt. The  default i s "LKey".' ,
598                    'val ue'  => $a Field['Use LKey'],   598                    'val ue'  => $a Field['Use LKey'],
599                    'row _id' => 'f ield_lkey' ,   599                    'row _id' => 'f ield_lkey' ,
600                    'val ues' => ar ray(    600                    'val ues' => ar ray( 
601                         'LKey'  =>  'LKey',   601                         'LKey'  =>  'LKey',
602                         'LKey2' =>  'LKey2',   602                         'LKey2' =>  'LKey2',
603                         'LKey3' =>  'LKey3',   603                         'LKey3' =>  'LKey3',
604                    )   604                    )
605                ),   605                ),
606                'Default ' => array (   606                'Default ' => array (
607                    'lab el'  => 'D efault val ue',   607                    'lab el'  => 'D efault val ue',
608                    'typ e'   => 't ext',   608                    'typ e'   => 't ext',
609                    'inf o'   => 'D efault val ue set int o database (!) if not  set by us er. Non-ma ndatory. F or boolean  fields us e 0 or 1.  For dates  use format : YYYY-MM- DD. Please  do not ch ange it if  in doubt! ',   609                    'inf o'   => 'D efault val ue set int o database (!) if not  set by us er. Non-ma ndatory. F or boolean  fields us e 0 or 1.  For dates  use format : YYYY-MM- DD. Please  do not ch ange it if  in doubt! ',
610                    'val ue'  => $a Field['Def ault'],   610                    'val ue'  => $a Field['Def ault'],
611                    'row _id' => 'f ield_defau lt'   611                    'row _id' => 'f ield_defau lt'
612                )   612                )
613           );   613           );
614              614           
615           $t his -> gen TableEdit(  $aForm, ' f2' );   615           $t his -> gen TableEdit(  $aForm, ' f2' );
616       }   616       }
617          617       
618       functi on genTabl eEdit( $aF orm, $sID  = '' ) {   618       functi on genTabl eEdit( $aF orm, $sID  = '' ) {
619           ?>   619           ?>
620           <t able class ="field_ed it_tab" <? = $sID ? (  'id="' .  $sID . '"'  ) : '' ?> >   620           <t able class ="field_ed it_tab" <? = $sID ? (  'id="' .  $sID . '"'  ) : '' ?> >
621              621           
622           <?   622           <?
623           fo reach( $aF orm as $sI nputName = > $aInput  ) {   623           fo reach( $aF orm as $sI nputName = > $aInput  ) {
624                ?>   624                ?>
625                <tr <?=  $aInput['r ow_id'] ?  ( 'id="' .  $aInput[' row_id'] .  '"' ) : ' ' ?>>   625                <tr <?=  $aInput['r ow_id'] ?  ( 'id="' .  $aInput[' row_id'] .  '"' ) : ' ' ?>>
626                    <td  class="lab el"><?= $a Input['lab el'] ?>:</ td>   626                    <td  class="lab el"><?= $a Input['lab el'] ?>:</ td>
627                    <td  class="val ue">   627                    <td  class="val ue">
628                <?   628                <?
629                switch(  $aInput['t ype'] ) {   629                switch(  $aInput['t ype'] ) {
630                    case  'textarea ':   630                    case  'textarea ':
631                         ?>   631                         ?>
632                         <textarea  name="<?=  $sInputNam e ?>" clas s="input_t ext"><?= h tmlspecial chars( $aI nput['valu e'] ) ?></ textarea>   632                         <textarea  name="<?=  $sInputNam e ?>" clas s="input_t ext"><?= h tmlspecial chars( $aI nput['valu e'] ) ?></ textarea>
633                         <?   633                         <?
634                    brea k;   634                    brea k;
635                    case  'checkbox ':   635                    case  'checkbox ':
636                         ?>   636                         ?>
637                         <input typ e="checkbo x" name="< ?= $sInput Name ?>" v alue="yes"  class="in put_checkb ox"   637                         <input typ e="checkbo x" name="< ?= $sInput Name ?>" v alue="yes"  class="in put_checkb ox"
638                           <?= $aIn put['value '] ? 'chec ked="check ed"' : ''  ?> />   638                           <?= $aIn put['value '] ? 'chec ked="check ed"' : ''  ?> />
639                         <?   639                         <?
640                    brea k;   640                    brea k;
641                    case  'text':   641                    case  'text':
642                         ?>   642                         ?>
643                         <input typ e="text" n ame="<?= $ sInputName  ?>" value ="<?= html specialcha rs( $aInpu t['value']  ) ?>" cla ss="input_ text" />   643                         <input typ e="text" n ame="<?= $ sInputName  ?>" value ="<?= html specialcha rs( $aInpu t['value']  ) ?>" cla ss="input_ text" />
644                         <?   644                         <?
645                    brea k;   645                    brea k;
646                    case  'select':   646                    case  'select':
647                         ?>   647                         ?>
648                         <select na me="<?= $s InputName  ?>" class= "select_ty pe">   648                         <select na me="<?= $s InputName  ?>" class= "select_ty pe">
649                         <?   649                         <?
650                         foreach( $ aInput['va lues'] as  $sKey => $ sValue ) {   650                         foreach( $ aInput['va lues'] as  $sKey => $ sValue ) {
651                             ?>   651                             ?>
652                             <optio n value="< ?= $sKey ? >" <?= ( $ sKey == $a Input['val ue'] ) ? ' selected=" selected"'  : '' ?>>< ?= $sValue  ?></optio n>   652                             <optio n value="< ?= $sKey ? >" <?= ( $ sKey == $a Input['val ue'] ) ? ' selected=" selected"'  : '' ?>>< ?= $sValue  ?></optio n>
653                             <?   653                             <?
654                         }   654                         }
655                         ?>   655                         ?>
656                         </select>   656                         </select>
657                         <?   657                         <?
658                    brea k;   658                    brea k;
659                    case  'values':   659                    case  'values':
660                         if( substr ( $aInput[ 'value'],  0, 2 ) ==  $this -> s LinkPref )  { //it is  link   660                         if( substr ( $aInput[ 'value'],  0, 2 ) ==  $this -> s LinkPref )  { //it is  link
661                             $sLink  = substr(  $aInput[' value'], 2  );   661                             $sLink  = substr(  $aInput[' value'], 2  );
662                             ?>   662                             ?>
663                         <input typ e="hidden"  name="<?=  $sInputNa me ?>" val ue="<?= ht mlspecialc hars( $aIn put['value '] ) ?>" / >   663                         <input typ e="hidden"  name="<?=  $sInputNa me ?>" val ue="<?= ht mlspecialc hars( $aIn put['value '] ) ?>" / >
664                         <a href="p reValues.p hp?list=<? = urlencod e( $sLink  ) ?>" targ et="_blank "   664                         <a href="p reValues.p hp?list=<? = urlencod e( $sLink  ) ?>" targ et="_blank "
665                           onclick= "return !w indow.open ( this.hre f + '&popu p=1', 'pre ValuesEdit ', 'width= 750,height =700,resiz able=yes,s crollbars= yes,toolba r=no,statu s=no,menub ar=no' );"   665                           onclick= "return !w indow.open ( this.hre f + '&popu p=1', 'pre ValuesEdit ', 'width= 750,height =700,resiz able=yes,s crollbars= yes,toolba r=no,statu s=no,menub ar=no' );"
666                           title="E dit list"> <?= $sLink  ?></a>   666                           title="E dit list"> <?= $sLink  ?></a>
667                           667                        
668                         <a href="j avascript: void(0);"  onclick="a ctivateVal uesEdit( t his );" ti tle="Chang e link" st yle="margi n-left:20p x;">   668                         <a href="j avascript: void(0);"  onclick="a ctivateVal uesEdit( t his );" ti tle="Chang e link" st yle="margi n-left:20p x;">
669                             <img s rc="images /edit.gif"  alt="Chan ge" />   669                             <img s rc="images /edit.gif"  alt="Chan ge" />
670                         </a>   670                         </a>
671                             <?   671                             <?
672                         }   672                         }
673                         else { //i t is simpl e list   673                         else { //i t is simpl e list
674                             ?>   674                             ?>
675                         <textarea  class="inp ut_text" n ame="<?= $ sInputName  ?>"><?= h tmlspecial chars( $aI nput['valu e'] ) ?></ textarea>   675                         <textarea  class="inp ut_text" n ame="<?= $ sInputName  ?>"><?= h tmlspecial chars( $aI nput['valu e'] ) ?></ textarea>
676                             <?   676                             <?
677                         }   677                         }
678                    brea k;   678                    brea k;
679                }   679                }
680                ?>   680                ?>
681                    </td >   681                    </td >
682                    <td  class="inf o">   682                    <td  class="inf o">
683                         <?= $this  -> getInfo Icon( $aIn put['info' ] ) ?>   683                         <?= $this  -> getInfo Icon( $aIn put['info' ] ) ?>
684                    </td >   684                    </td >
685                </tr>   685                </tr>
686                <?   686                <?
687           }   687           }
688           ?>   688           ?>
689              689           
690           </ table>   690           </ table>
691           <?   691           <?
692       }   692       }
693          693       
694       //used  for parsi ng extra p arameters   694       //used  for parsi ng extra p arameters
695       functi on parsePa rams( $sPa rams ) {   695       functi on parsePa rams( $sPa rams ) {
696           if ( $sParams  == '' )   696           if ( $sParams  == '' )
697                return a rray();   697                return a rray();
698              698           
699           $a Params = a rray();   699           $a Params = a rray();
700              700           
701           $a ParamLines  = explode ( "\n", $s Params );   701           $a ParamLines  = explode ( "\n", $s Params );
702              702           
703           fo reach( $aP aramLines  as $sLine  ) {   703           fo reach( $aP aramLines  as $sLine  ) {
704                list( $s Key, $sVal ue) = expl ode( ':',  $sLine, 2  );   704                list( $s Key, $sVal ue) = expl ode( ':',  $sLine, 2  );
705                $aParams [$sKey] =  $sValue;   705                $aParams [$sKey] =  $sValue;
706           }   706           }
707              707           
708           re turn $aPar ams;   708           re turn $aPar ams;
709       }   709       }
710          710       
711       functi on genForm MiscTab( $ aField ) {   711       functi on genForm MiscTab( $ aField ) {
712           $a Form = arr ay(   712           $a Form = arr ay(
713                'Mandato ry_msg' =>  array(   713                'Mandato ry_msg' =>  array(
714                    'lab el'  => 'M andatory e rror messa ge',   714                    'lab el'  => 'M andatory e rror messa ge',
715                    'typ e'   => 't extarea',   715                    'typ e'   => 't extarea',
716                    'inf o'   => 'E rror messa ge returne d if user  didn\'t sp ecify valu e when fie ld is mand atory. Tra nslated to  default l anguage (f or other l anguages -  use key:  _FieldErro r_' . $aFi eld['Name' ] . '_Mand atory). Th is texts i s non-mand atory fiel d is non-m andatory.' ,   716                    'inf o'   => 'E rror messa ge returne d if user  didn\'t sp ecify valu e when fie ld is mand atory. Tra nslated to  default l anguage (f or other l anguages -  use key:  _FieldErro r_' . $aFi eld['Name' ] . '_Mand atory). Th is texts i s non-mand atory fiel d is non-m andatory.' ,
717                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Mandato ry" ),   717                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Mandato ry" ),
718                    /*'r ow_id' =>  'field_man datory_msg '*/   718                    /*'r ow_id' =>  'field_man datory_msg '*/
719                ),   719                ),
720                'Min_msg ' => array (   720                'Min_msg ' => array (
721                    'lab el'  => 'M inimum exc eed error  message',   721                    'lab el'  => 'M inimum exc eed error  message',
722                    'typ e'   => 't extarea',   722                    'typ e'   => 't extarea',
723                    'inf o'   => 'E rror messa ge returne d when fie ld minimum  limit exc eeded. Tra nslated to  default l anguage (f or other l anguages -  use key:  _FieldErro r_' . $aFi eld['Name' ] . '_Min) . Non-mand atory if m inimum lim it is not  defined.',   723                    'inf o'   => 'E rror messa ge returne d when fie ld minimum  limit exc eeded. Tra nslated to  default l anguage (f or other l anguages -  use key:  _FieldErro r_' . $aFi eld['Name' ] . '_Min) . Non-mand atory if m inimum lim it is not  defined.',
724                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Min" ),   724                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Min" ),
725                    'row _id' => 'f ield_minim um_msg'   725                    'row _id' => 'f ield_minim um_msg'
726                ),   726                ),
727                'Max_msg ' => array (   727                'Max_msg ' => array (
728                    'lab el'  => 'M aximum exc eed error  message',   728                    'lab el'  => 'M aximum exc eed error  message',
729                    'typ e'   => 't extarea',   729                    'typ e'   => 't extarea',
730                    'inf o'   => 'E rror messa ge returne d when fie ld maximum  limit exc eeded. Tra nslated to  default l anguage (f or other l anguages -  use key:  _FieldErro r_' . $aFi eld['Name' ] . '_Max) . Non-mand atory if m aximum lim it is not  defined.',   730                    'inf o'   => 'E rror messa ge returne d when fie ld maximum  limit exc eeded. Tra nslated to  default l anguage (f or other l anguages -  use key:  _FieldErro r_' . $aFi eld['Name' ] . '_Max) . Non-mand atory if m aximum lim it is not  defined.',
731                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Max" ),   731                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Max" ),
732                    'row _id' => 'f ield_maxim um_msg'   732                    'row _id' => 'f ield_maxim um_msg'
733                ),   733                ),
734                'Unique_ msg' => ar ray(   734                'Unique_ msg' => ar ray(
735                    'lab el'  => 'N on-unique  error mess age',   735                    'lab el'  => 'N on-unique  error mess age',
736                    'typ e'   => 't extarea',   736                    'typ e'   => 't extarea',
737                    'inf o'   => 'E rror messa ge returne d if user  entered no n-unique v alue. Tran slated to  default la nguage (fo r other la nguages -  use key: _ FieldError _' . $aFie ld['Name']  . '_Uniqu e). Non-ma ndatory if  Unique is  not set.' ,   737                    'inf o'   => 'E rror messa ge returne d if user  entered no n-unique v alue. Tran slated to  default la nguage (fo r other la nguages -  use key: _ FieldError _' . $aFie ld['Name']  . '_Uniqu e). Non-ma ndatory if  Unique is  not set.' ,
738                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Unique"  ),   738                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Unique"  ),
739                    'row _id' => 'f ield_uniqu e_msg'   739                    'row _id' => 'f ield_uniqu e_msg'
740                ),   740                ),
741                'Check_m sg' => arr ay(   741                'Check_m sg' => arr ay(
742                    'lab el'  => 'C heck error  message',   742                    'lab el'  => 'C heck error  message',
743                    'typ e'   => 't extarea',   743                    'typ e'   => 't extarea',
744                    'inf o'   => 'E rror messa ge returne d if field  Check is  failed (fo r other la nguages -  use key: _ FieldError _' . $aFie ld['Name']  . '_Check ). Transla ted to def ault langu age. Non-m andatory i f Check is  not defin ed.',   744                    'inf o'   => 'E rror messa ge returne d if field  Check is  failed (fo r other la nguages -  use key: _ FieldError _' . $aFie ld['Name']  . '_Check ). Transla ted to def ault langu age. Non-m andatory i f Check is  not defin ed.',
745                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Check"  ),   745                    'val ue'  => $t his -> get LangString ( "_FieldE rror_{$aFi eld['Name' ]}_Check"  ),
746                    'row _id' => 'f ield_check _msg'   746                    'row _id' => 'f ield_check _msg'
747                )   747                )
748           );   748           );
749                   749                
750           $t his -> gen TableEdit(  $aForm, ' f3' );   750           $t his -> gen TableEdit(  $aForm, ' f3' );
751       }   751       }
752          752       
753       functi on getInfo Icon( $sTe xt ) {   753       functi on getInfo Icon( $sTe xt ) {
754           re turn '   754           re turn '
755           <i mg src="im ages/info. gif" class ="info_ico n"   755           <i mg src="im ages/info. gif" class ="info_ico n"
756              onmouseove r="showFlo atDesc(\''  . htmlspe cialchars(  $sText )  . '\');"   756              onmouseove r="showFlo atDesc(\''  . htmlspe cialchars(  $sText )  . '\');"
757              onmousemov e="moveFlo atDesc( ev ent )"   757              onmousemov e="moveFlo atDesc( ev ent )"
758              onmouseout ="hideFloa tDesc();"  />   758              onmouseout ="hideFloa tDesc();"  />
759           ';   759           ';
760       }   760       }
761          761       
762       functi on getType Options( $ sActive )  {   762       functi on getType Options( $ sActive )  {
763           $s Ret = '';   763           $s Ret = '';
764              764           
765           fo reach( $th is -> aTyp es as $sKe y => $sVal ue ) {   765           fo reach( $th is -> aTyp es as $sKe y => $sVal ue ) {
766                $sRet .=  '<option  value="' .  $sKey . ' " ' . ( $s Active ==  $sKey ? 's elected="s elected"'  : '') . '> ' . $sValu e . '</opt ion>';   766                $sRet .=  '<option  value="' .  $sKey . ' " ' . ( $s Active ==  $sKey ? 's elected="s elected"'  : '') . '> ' . $sValu e . '</opt ion>';
767           }   767           }
768              768           
769           re turn $sRet ;   769           re turn $sRet ;
770       }   770       }
771          771       
772       functi on getLang String( $s Key ) {   772       functi on getLang String( $s Key ) {
773           if ( $sKey ==  '' )   773           if ( $sKey ==  '' )
774                return ' ';   774                return ' ';
775              775           
776           $s Key_db     = addslash es( $sKey  );   776           $s Key_db     = addslash es( $sKey  );
777           $s String_db  = addslash es( $sStri ng );   777           $s String_db  = addslash es( $sStri ng );
778              778           
779           $s Query = "S ELECT `ID`  FROM `Loc alizationK eys` WHERE  `Key` = ' $sKey_db'" ;   779           $s Query = "S ELECT `ID`  FROM `Loc alizationK eys` WHERE  `Key` = ' $sKey_db'" ;
780           $i KeyID = (i nt)db_valu e( $sQuery  );   780           $i KeyID = (i nt)db_valu e( $sQuery  );
781              781           
782           if ( !$iKeyID  )   782           if ( !$iKeyID  )
783                return ' ';   783                return ' ';
784              784           
785           $s Query = "   785           $s Query = "
786                SELECT ` String` FR OM `Locali zationStri ngs`   786                SELECT ` String` FR OM `Locali zationStri ngs`
787                WHERE `I DKey` = $i KeyID AND  `IDLanguag e` = {$thi s -> sLang ID}";   787                WHERE `I DKey` = $i KeyID AND  `IDLanguag e` = {$thi s -> sLang ID}";
788              788           
789           re turn (stri ng)db_valu e( $sQuery  );   789           re turn (stri ng)db_valu e( $sQuery  );
790       }   790       }
791          791       
792       functi on saveIte m( $aData  ) {   792       functi on saveIte m( $aData  ) {
793           $t his -> gen SaveItemHe ader();   793           $t his -> gen SaveItemHe ader();
794           $t his -> isH aveErrors  = false;   794           $t his -> isH aveErrors  = false;
795           // echoDbg( $ aData );   795           // echoDbg( $ aData );
796           $i ItemID = ( int)$aData ['id'];   796           $i ItemID = ( int)$aData ['id'];
797              797           
798           $a Item = db_ assoc_arr(  "SELECT *  FROM `Pro fileFields ` WHERE `I D` = $iIte mID" );   798           $a Item = db_ assoc_arr(  "SELECT *  FROM `Pro fileFields ` WHERE `I D` = $iIte mID" );
799              799           
800           if ( !$aItem  ) {   800           if ( !$aItem  ) {
801                $this ->  genSaveIt emError( ' Warning! F ield not f ound.' );   801                $this ->  genSaveIt emError( ' Warning! F ield not f ound.' );
802                $this ->  genSaveIt emFooter() ;   802                $this ->  genSaveIt emFooter() ;
803                return f alse;   803                return f alse;
804           }   804           }
805              805           
806           //  just a fl ag   806           //  just a fl ag
807           $b HaveErrors  = false;   807           $b HaveErrors  = false;
808              808           
809           //  this arra y will be  put into d b   809           //  this arra y will be  put into d b
810           $a Update = a rray();   810           $a Update = a rray();
811              811           
812           //  check nam e   812           //  check nam e
813           if ( $aItem[' Type'] !=  'system' a nd $aItem[ 'Deletable '] ) { //w e can chan ge the nam e   813           if ( $aItem[' Type'] !=  'system' a nd $aItem[ 'Deletable '] ) { //w e can chan ge the nam e
814                   814                
815                $sName =  trim( str ip_tags( p rocess_pas s_data( $a Data['Name '] ) ) );   815                $sName =  trim( str ip_tags( p rocess_pas s_data( $a Data['Name '] ) ) );
816                   816                
817                if( $sNa me === ''  ) {   817                if( $sNa me === ''  ) {
818                    $thi s -> genSa veItemErro r( 'You mu st enter t he name.',  'Name' );   818                    $thi s -> genSa veItemErro r( 'You mu st enter t he name.',  'Name' );
819                    $bHa veErrors =  true;   819                    $bHa veErrors =  true;
820                } elseif ( $aItem[' Type'] !=  'block' an d !preg_ma tch( '/^[a -z][a-z0-9 _]*$/i', $ sName ) )  {   820                } elseif ( $aItem[' Type'] !=  'block' an d !preg_ma tch( '/^[a -z][a-z0-9 _]*$/i', $ sName ) )  {
821                    $thi s -> genSa veItemErro r( 'The na me must be gin with a  latin let ter and co ntain only  latin let ters, numb ers or und erscores.' , 'Name' ) ;   821                    $thi s -> genSa veItemErro r( 'The na me must be gin with a  latin let ter and co ntain only  latin let ters, numb ers or und erscores.' , 'Name' ) ;
822                    $bHa veErrors =  true;   822                    $bHa veErrors =  true;
823                } elseif ( db_value ( "SELECT  COUNT(*) F ROM `Profi leFields`  WHERE `Nam e` = '$sNa me' and `I D` != $iIt emID" ) )  {   823                } elseif ( db_value ( "SELECT  COUNT(*) F ROM `Profi leFields`  WHERE `Nam e` = '$sNa me' and `I D` != $iIt emID" ) )  {
824                    $thi s -> genSa veItemErro r( 'A fiel d with suc h name alr eady exist s. Please  select ano ther.', 'N ame' );   824                    $thi s -> genSa veItemErro r( 'A fiel d with suc h name alr eady exist s. Please  select ano ther.', 'N ame' );
825                    $bHa veErrors =  true;   825                    $bHa veErrors =  true;
826                } elseif ( $sName = = $aItem[' Name'] ) {   826                } elseif ( $sName = = $aItem[' Name'] ) {
827                    // a ll ok. don 't change   827                    // a ll ok. don 't change
828                } else   828                } else
829                    $aUp date['Name '] = $sNam e; //chang e   829                    $aUp date['Name '] = $sNam e; //chang e
830           }   830           }
831              831           
832           $s NewName =  isset( $aU pdate['Nam e'] ) ? $a Update['Na me'] : $aI tem['Name' ];   832           $s NewName =  isset( $aU pdate['Nam e'] ) ? $a Update['Na me'] : $aI tem['Name' ];
833              833           
834           $t his -> fie ldCaption  = "_FieldC aption_{$s NewName}_{ $this -> a reaPageNam e}"; // _F ieldCaptio n_Sex_Join   834           $t his -> fie ldCaption  = "_FieldC aption_{$s NewName}_{ $this -> a reaPageNam e}"; // _F ieldCaptio n_Sex_Join
835           $t his -> fie ldDesc     = "_FieldD esc_{$sNew Name}_{$th is -> area PageName}" ;    // _F ieldDesc_S ex_Join   835           $t his -> fie ldDesc     = "_FieldD esc_{$sNew Name}_{$th is -> area PageName}" ;    // _F ieldDesc_S ex_Join
836              836           
837           //  check Cap tion   837           //  check Cap tion
838           $s Caption =  trim( proc ess_pass_d ata( $aDat a['Caption '] ) );   838           $s Caption =  trim( proc ess_pass_d ata( $aDat a['Caption '] ) );
839              839           
840           if ( $sCaptio n === '' )  {   840           if ( $sCaptio n === '' )  {
841                $this ->  genSaveIt emError( ' You must e nter the c aption.',  'Caption'  );   841                $this ->  genSaveIt emError( ' You must e nter the c aption.',  'Caption'  );
842                $bHaveEr rors = tru e;   842                $bHaveEr rors = tru e;
843           }  elseif( $t his -> get LangString ( $this ->  fieldCapt ion ) == $ sCaption )  {   843           }  elseif( $t his -> get LangString ( $this ->  fieldCapt ion ) == $ sCaption )  {
844                // all o k dont cha nge   844                // all o k dont cha nge
845           }  else   845           }  else
846                $this ->  updateLan gString( $ this -> fi eldCaption , $sCaptio n );   846                $this ->  updateLan gString( $ this -> fi eldCaption , $sCaptio n );
847              847           
848           //  check Des cription   848           //  check Des cription
849           $s Desc = tri m( process _pass_data ( $aData[' Desc'] ) ) ;   849           $s Desc = tri m( process _pass_data ( $aData[' Desc'] ) ) ;
850           if ( $this ->  getLangSt ring( $thi s -> field Desc ) !=  $sDesc )   850           if ( $this ->  getLangSt ring( $thi s -> field Desc ) !=  $sDesc )
851                $this ->  updateLan gString( $ this -> fi eldDesc, $ sDesc );   851                $this ->  updateLan gString( $ this -> fi eldDesc, $ sDesc );
852              852           
853           //  check typ e   853           //  check typ e
854           if ( $aItem[' Type'] !=  'system' a nd $aItem[ 'Type'] !=  'block' )  {   854           if ( $aItem[' Type'] !=  'system' a nd $aItem[ 'Type'] !=  'block' )  {
855                   855                
856                //we can  change th e type   856                //we can  change th e type
857                $sType =  trim( str ip_tags( p rocess_pas s_data( $a Data['Type '] ) ) );   857                $sType =  trim( str ip_tags( p rocess_pas s_data( $a Data['Type '] ) ) );
858                   858                
859                if( !iss et( $this  -> aTypes[ $sType] )  ) {   859                if( !iss et( $this  -> aTypes[ $sType] )  ) {
860                     $this   ->   genSaveIte mError(   ' Don\'t   fuck   with   my   brain!   I   don\'t   know   this   type.',   'Type'   );   860                     $this   ->   genSaveIte mError(   '
I   don\'t   know   this   type.',   'Type'   );
861                    $bHa veErrors =  true;   861                    $bHa veErrors =  true;
862                } elseif ( $sType = = $aItem[' Type'] ) {   862                } elseif ( $sType = = $aItem[' Type'] ) {
863                    // a ll ok. don 't change   863                    // a ll ok. don 't change
864                } else   864                } else
865                    $aUp date['Type '] = $sTyp e; //chang e   865                    $aUp date['Type '] = $sTyp e; //chang e
866              866           
867                // check  the addit ional prop erties   867                // check  the addit ional prop erties
868                if( !$bH aveErrors  ) { // do  not contin ue if have  errors   868                if( !$bH aveErrors  ) { // do  not contin ue if have  errors
869                       869                    
870                    // c heck selec tors contr ols   870                    // c heck selec tors contr ols
871                    if(  $sType ==  'select_on e' ) {   871                    if(  $sType ==  'select_on e' ) {
872                         if( $aData ['Control_ one'] == $ aItem['Con trol'] ) {   872                         if( $aData ['Control_ one'] == $ aItem['Con trol'] ) {
873                             //all  ok   873                             //all  ok
874                         } elseif(  $aData['Co ntrol_one' ] == 'sele ct' or $aD ata['Contr ol_one'] = = 'radio'  ) {   874                         } elseif(  $aData['Co ntrol_one' ] == 'sele ct' or $aD ata['Contr ol_one'] = = 'radio'  ) {
875                             $aUpda te['Contro l'] = $aDa ta['Contro l_one'];   875                             $aUpda te['Contro l'] = $aDa ta['Contro l_one'];
876                         } else {   876                         } else {
877                             $this  -> genSave ItemError(  'I don\'t  know this  control t ype.', 'Co ntrol_one'  );   877                             $this  -> genSave ItemError(  'I don\'t  know this  control t ype.', 'Co ntrol_one'  );
878                             $bHave Errors = t rue;   878                             $bHave Errors = t rue;
879                         }   879                         }
880                    } el seif( $sTy pe == 'sel ect_set' )  {   880                    } el seif( $sTy pe == 'sel ect_set' )  {
881                         if( $aData ['Control_ set'] == $ aItem['Con trol'] ) {   881                         if( $aData ['Control_ set'] == $ aItem['Con trol'] ) {
882                             //all  ok   882                             //all  ok
883                         } elseif(  $aData['Co ntrol_set' ] == 'sele ct' or $aD ata['Contr ol_set'] = = 'checkbo x' ) {   883                         } elseif(  $aData['Co ntrol_set' ] == 'sele ct' or $aD ata['Contr ol_set'] = = 'checkbo x' ) {
884                             $aUpda te['Contro l'] = $aDa ta['Contro l_set'];   884                             $aUpda te['Contro l'] = $aDa ta['Contro l_set'];
885                         } else {   885                         } else {
886                             $this  -> genSave ItemError(  'I don\'t  know this  control t ype.', 'Co ntrol_set'  );   886                             $this  -> genSave ItemError(  'I don\'t  know this  control t ype.', 'Co ntrol_set'  );
887                             $bHave Errors = t rue;   887                             $bHave Errors = t rue;
888                         }   888                         }
889                    } el se   889                    } el se
890                         $aUpdate[' Control']  = '';   890                         $aUpdate[' Control']  = '';
891                       891                    
892                    //ch eck Min   892                    //ch eck Min
893                    $iMi n = trim(  $aData['Mi n'] );   893                    $iMi n = trim(  $aData['Mi n'] );
894                       894                    
895                    if(  $iMin ===  '' or $sTy pe == 'boo l' or $sTy pe == 'sel ect_one' o r $sType = = 'select_ set' )   895                    if(  $iMin ===  '' or $sTy pe == 'boo l' or $sTy pe == 'sel ect_one' o r $sType = = 'select_ set' )
896                         $iMin = nu ll;   896                         $iMin = nu ll;
897                    else  {   897                    else  {
898                         $iMin = (i nt)$iMin;   898                         $iMin = (i nt)$iMin;
899                         if( $sType  == 'area'  and $iMin  > 65534 )   899                         if( $sType  == 'area'  and $iMin  > 65534 )
900                             $iMin  = 65535;   900                             $iMin  = 65535;
901                         elseif( $s Type != 'a rea' and $ iMin > 254  )   901                         elseif( $s Type != 'a rea' and $ iMin > 254  )
902                             $iMin  = 65535;   902                             $iMin  = 65535;
903                         elseif( $i Min < 0 )   903                         elseif( $i Min < 0 )
904                             $iMin  = 0;   904                             $iMin  = 0;
905                    }   905                    }
906                       906                    
907                    $aUp date['Min' ] = $iMin;   907                    $aUp date['Min' ] = $iMin;
908                       908                    
909                    //ch eck Max   909                    //ch eck Max
910                    $iMa x = trim(  $aData['Ma x'] );   910                    $iMa x = trim(  $aData['Ma x'] );
911                       911                    
912                    if(  $iMax ===  '' or $sTy pe == 'boo l' or $sTy pe == 'sel ect_one' o r $sType = = 'select_ set' )   912                    if(  $iMax ===  '' or $sTy pe == 'boo l' or $sTy pe == 'sel ect_one' o r $sType = = 'select_ set' )
913                         $iMax = nu ll;   913                         $iMax = nu ll;
914                    else  {   914                    else  {
915                         $iMax = (i nt)$iMax;   915                         $iMax = (i nt)$iMax;
916                         if( $sType  == 'area'  and $iMax  > 65534 )   916                         if( $sType  == 'area'  and $iMax  > 65534 )
917                             $iMax  = 65535;   917                             $iMax  = 65535;
918                         elseif( $s Type != 'a rea' and $ iMax > 254  )   918                         elseif( $s Type != 'a rea' and $ iMax > 254  )
919                             $iMax  = 65535;   919                             $iMax  = 65535;
920                         elseif( $i Max < 0 )   920                         elseif( $i Max < 0 )
921                             $iMax  = 0;   921                             $iMax  = 0;
922                    }   922                    }
923                       923                    
924                    $aUp date['Max' ] = $iMax;   924                    $aUp date['Max' ] = $iMax;
925                       925                    
926                    // s et min and  max searc h age   926                    // s et min and  max searc h age
927                    if(  $sNewName  == 'DateOf Birth' )   927                    if(  $sNewName  == 'DateOf Birth' )
928                         $this -> s etMinMaxAg e( ( $iMin  ? $iMin :  18 ), ( $ iMax ? $iM ax : 75 )  );   928                         $this -> s etMinMaxAg e( ( $iMin  ? $iMin :  18 ), ( $ iMax ? $iM ax : 75 )  );
929                       929                    
930                    //ch eck Check  :)   930                    //ch eck Check  :)
931                    if(  $sType ==  'select_on e' or $sTy pe == 'sel ect_set' o r $sType = = 'bool' )   931                    if(  $sType ==  'select_on e' or $sTy pe == 'sel ect_set' o r $sType = = 'bool' )
932                         $aUpdate[' Check'] =  '';   932                         $aUpdate[' Check'] =  '';
933                    else  {   933                    else  {
934                         $sCheck =  trim( proc ess_pass_d ata( $aDat a['Check']  ) );   934                         $sCheck =  trim( proc ess_pass_d ata( $aDat a['Check']  ) );
935                           935                        
936                         if( $aItem ['Check']  != $sCheck  )   936                         if( $aItem ['Check']  != $sCheck  )
937                             $aUpda te['Check' ] = $sChec k;   937                             $aUpda te['Check' ] = $sChec k;
938                    }   938                    }
939                       939                    
940                    //Un ique   940                    //Un ique
941                    $aUp date['Uniq ue'] = (   941                    $aUp date['Uniq ue'] = (
942                         isset( $aD ata['Uniqu e'] ) and   942                         isset( $aD ata['Uniqu e'] ) and
943                         $aData['Un ique'] ==  'yes' and   943                         $aData['Un ique'] ==  'yes' and
944                         ( $sType = = 'text' o r $sType = = 'area' o r $sType = = 'num' )   944                         ( $sType = = 'text' o r $sType = = 'area' o r $sType = = 'num' )
945                    ) ?  1 : 0;   945                    ) ?  1 : 0;
946                       946                    
947                    //Ma ndatory   947                    //Ma ndatory
948                    $aUp date['Mand atory'] =  ( isset( $ aData['Man datory'] )  and $aDat a['Mandato ry'] == 'y es' ) ? 1  : 0;   948                    $aUp date['Mand atory'] =  ( isset( $ aData['Man datory'] )  and $aDat a['Mandato ry'] == 'y es' ) ? 1  : 0;
949                       949                    
950                    //ch eck Values   950                    //ch eck Values
951                    if(  $sType ==  'select_on e' or $sTy pe == 'sel ect_set' )  {   951                    if(  $sType ==  'select_on e' or $sTy pe == 'sel ect_set' )  {
952                         $sValues =  trim( str ip_tags( p rocess_pas s_data( $a Data['Valu es'] ) ) ) ;   952                         $sValues =  trim( str ip_tags( p rocess_pas s_data( $a Data['Valu es'] ) ) ) ;
953                           953                        
954                         $sValues =  str_repla ce( "\r",  "\n", $sVa lues );    // for mac   954                         $sValues =  str_repla ce( "\r",  "\n", $sVa lues );    // for mac
955                         $sValues =  str_repla ce( "\n\n" , "\n", $s Values );  // for win   955                         $sValues =  str_repla ce( "\n\n" , "\n", $s Values );  // for win
956                                                                             ;  // for *ni x ;)   956                                                                             ;  // for *ni x ;)
957                           957                        
958                         if( $sValu es === ''  ) {   958                         if( $sValu es === ''  ) {
959                             $this  -> genSave ItemError(  'You must  enter val ues', 'Val ues' );   959                             $this  -> genSave ItemError(  'You must  enter val ues', 'Val ues' );
960                             $bHave Errors = t rue;   960                             $bHave Errors = t rue;
961                         } elseif(  $sValues ! = $aItem[' Values'] )  {   961                         } elseif(  $sValues ! = $aItem[' Values'] )  {
962                             if( su bstr( $sVa lues, 0, 2  ) == $thi s -> sLink Pref and ! $this -> c heckValues Link( subs tr( $sValu es, 2 ) )  ) {   962                             if( su bstr( $sVa lues, 0, 2  ) == $thi s -> sLink Pref and ! $this -> c heckValues Link( subs tr( $sValu es, 2 ) )  ) {
963                                 $t his -> gen SaveItemEr ror( 'You  entered in correct li nk', 'Valu es' );   963                                 $t his -> gen SaveItemEr ror( 'You  entered in correct li nk', 'Valu es' );
964                                 $b HaveErrors  = true;   964                                 $b HaveErrors  = true;
965                             } else   965                             } else
966                                 $a Update['Va lues'] = $ sValues;   966                                 $a Update['Va lues'] = $ sValues;
967                         }   967                         }
968                           968                        
969                         // get LKe y   969                         // get LKe y
970                         $sUseLKey  = trim( pr ocess_pass _data( $aD ata['UseLK ey'] ) );   970                         $sUseLKey  = trim( pr ocess_pass _data( $aD ata['UseLK ey'] ) );
971                         if( !$sUse LKey )   971                         if( !$sUse LKey )
972                             $sUseL Key = 'LKe y';   972                             $sUseL Key = 'LKe y';
973                           973                        
974                         $aUpdate[' UseLKey']  = $sUseLKe y;   974                         $aUpdate[' UseLKey']  = $sUseLKe y;
975     975                        
976                         //Add   Lang   Va r i a b l
e   // _FieldValu e s     {$this   ->   areaPageN am
e }
  976                         if( substr ( $sValues , 0, 2 ) ! = $this ->  sLinkPref  ) { // if  not a lin k
    977                              //Add   Lang   key   fo r   each   v a
l u e :   _FieldValu e _Ex am pl e
    978                             
977                         $aValues2L F = explod e("\n", $s Values);   979                             $aValu es2LF = ex plode("\n" , $sValues );
978                         foreach (  $aValues2L F as $sVal ues2LF ) {   980                             foreac h ( $aValu es2LF as $ sValues2LF  ) {
979                             $sLFKe y = '_Fiel dValues_'  . $sValues 2LF;   981                                 $s LFKey = '_ FieldValue s_' . $sVa lues2LF;
980                             $sLFVa lue = $sVa lues2LF;   982                                 $s LFValue =  $sValues2L F;
981                             //prin t "{$sLFKe y}<br />";   983                                 // print "{$s LFKey}<br  />";
982                             if( $t his -> get LangString ( $sLFKey  ) != $sLFV alue )   984                                 if ( $this ->  getLangSt ring( $sLF Key ) != $ sLFValue )
983                                 $t his -> upd ateLangStr ing( $sLFK ey, $sLFVa lue );   985                                      $this ->  updateLan gString( $ sLFKey, $s LFValue );
984                         }   986                             }
985                         //exit;   987                         }
986                           988                        
987                    } el seif( $aIt em['Values '] != '' )   989                    } el seif( $aIt em['Values '] != '' )
988                         $aUpdate[' Values'] =  '';   990                         $aUpdate[' Values'] =  '';
989                       991                    
990                    if(  !$bHaveErr ors ) {   992                    if(  !$bHaveErr ors ) {
991                         //Default   993                         //Default
992                         switch( $s Type ) {   994                         switch( $s Type ) {
993                             case ' text':   995                             case ' text':
994                                 $a Update['De fault'] =  trim( proc ess_pass_d ata( $aDat a['Default '] ) );   996                                 $a Update['De fault'] =  trim( proc ess_pass_d ata( $aDat a['Default '] ) );
995                             break;   997                             break;
996                             case ' pass':   998                             case ' pass':
997                             case ' area':   999                             case ' area':
998                             case ' select_set ':   1000                             case ' select_set ':
999                                 $a Update['De fault'] =  '';   1001                                 $a Update['De fault'] =  '';
1000                             break;   1002                             break;
1001                             case ' num':   1003                             case ' num':
1002                                 $a Update['De fault'] =  (int)$aDat a['Default '];   1004                                 $a Update['De fault'] =  (int)$aDat a['Default '];
1003                             break;   1005                             break;
1004                             case ' bool':   1006                             case ' bool':
1005                                 $a Update['De fault'] =  (int)(bool )$aData['D efault'];   1007                                 $a Update['De fault'] =  (int)(bool )$aData['D efault'];
1006                             break;   1008                             break;
1007                             case ' range':   1009                             case ' range':
1008                                 if ( trim( $a Data['Defa ult'] ) ==  '' )   1010                                 if ( trim( $a Data['Defa ult'] ) ==  '' )
1009                                      $aUpdate ['Default' ] = '';   1011                                      $aUpdate ['Default' ] = '';
1010                                 el se {   1012                                 el se {
1011                                      list( $s First, $sS econd ) =  explode( ' -', trim(  $aData['De fault'], 2  ) );    1013                                      list( $s First, $sS econd ) =  explode( ' -', trim(  $aData['De fault'], 2  ) ); 
1012                                      $sFirst   = (int)tr im( $sFirs t );   1014                                      $sFirst   = (int)tr im( $sFirs t );
1013                                      $sSecond  = (int)tr im( $sSeco nd );   1015                                      $sSecond  = (int)tr im( $sSeco nd );
1014                                      $aUpdate ['Default' ] = "$sFir st-$sSecon d";   1016                                      $aUpdate ['Default' ] = "$sFir st-$sSecon d";
1015                                 }   1017                                 }
1016                             break;   1018                             break;
1017                             case ' date':   1019                             case ' date':
1018                                 if ( $aData[' Default']  === '' )   1020                                 if ( $aData[' Default']  === '' )
1019                                      $aUpdate ['Default' ] = '';   1021                                      $aUpdate ['Default' ] = '';
1020                                 el se   1022                                 el se
1021                                      $aUpdate ['Default' ] = date(  'Y-m-d', s trtotime(  trim( proc ess_pass_d ata( $aDat a['Default '] ) ) ) ) ;   1023                                      $aUpdate ['Default' ] = date(  'Y-m-d', s trtotime(  trim( proc ess_pass_d ata( $aDat a['Default '] ) ) ) ) ;
1022                             break;   1024                             break;
1023                                1025                             
1024                             case ' select_one ':   1026                             case ' select_one ':
1025                                 $s Default =  trim( proc ess_pass_d ata( $aDat a['Default '] ) );   1027                                 $s Default =  trim( proc ess_pass_d ata( $aDat a['Default '] ) );
1026                                 if ( $sDefaul t === '' )   1028                                 if ( $sDefaul t === '' )
1027                                      $aUpdate ['Default' ] = '';   1029                                      $aUpdate ['Default' ] = '';
1028                                 el se {   1030                                 el se {
1029                                      if( $thi s -> check SelectDefa ult( $sVal ues, $sDef ault ) )   1031                                      if( $thi s -> check SelectDefa ult( $sVal ues, $sDef ault ) )
1030                                          $aUp date['Defa ult'] = $s Default;   1032                                          $aUp date['Defa ult'] = $s Default;
1031                                      else {   1033                                      else {
1032                                          $thi s -> genSa veItemErro r( 'You en tered an i ncorrect v alue', 'De fault' );   1034                                          $thi s -> genSa veItemErro r( 'You en tered an i ncorrect v alue', 'De fault' );
1033                                          $bHa veErrors =  true;   1035                                          $bHa veErrors =  true;
1034                                      }   1036                                      }
1035                                 }   1037                                 }
1036                             break;   1038                             break;
1037                         }   1039                         }
1038                           1040                        
1039                         //matching . not impl emented ye t   1041                         //matching . not impl emented ye t
1040                    }   1042                    }
1041                }   1043                }
1042           }   1044           }
1043              1045           
1044           if ( $aItem[' Type'] ==  'block' an d $this ->  iAreaID = = 1 ) { // Join   1046           if ( $aItem[' Type'] ==  'block' an d $this ->  iAreaID = = 1 ) { // Join
1045                //get Jo inPage   1047                //get Jo inPage
1046                $iJoinPa ge = (int) $aData['Jo inPage'];   1048                $iJoinPa ge = (int) $aData['Jo inPage'];
1047                if( $aIt em['JoinPa ge'] != $i JoinPage )   1049                if( $aIt em['JoinPa ge'] != $i JoinPage )
1048                    $aUp date['Join Page'] = $ iJoinPage;   1050                    $aUp date['Join Page'] = $ iJoinPage;
1049           }   1051           }
1050              1052           
1051           // system fie lds proper ties   1053           // system fie lds proper ties
1052           if ( $aItem[' Name'] ==  'Keyword'  ) {   1054           if ( $aItem[' Name'] ==  'Keyword'  ) {
1053                if( is_a rray( $aDa ta['Keywor dFields']  ) ) {   1055                if( is_a rray( $aDa ta['Keywor dFields']  ) ) {
1054                    $sKe ywordField s = implod e( "\n", $ aData['Key wordFields '] );   1056                    $sKe ywordField s = implod e( "\n", $ aData['Key wordFields '] );
1055                       1057                    
1056                    if(  process_pa ss_data( $ sKeywordFi elds ) !=  $aItem['Ex tra'] )   1058                    if(  process_pa ss_data( $ sKeywordFi elds ) !=  $aItem['Ex tra'] )
1057                         $aUpdate[' Extra'] =  $sKeywordF ields;   1059                         $aUpdate[' Extra'] =  $sKeywordF ields;
1058                }   1060                }
1059           }   1061           }
1060              1062           
1061           if ( $aItem[' Name'] ==  'Couple' )  {   1063           if ( $aItem[' Name'] ==  'Couple' )  {
1062                if( is_a rray( $aDa ta['Couple Fields'] )  ) {   1064                if( is_a rray( $aDa ta['Couple Fields'] )  ) {
1063                    $sKe ywordField s = implod e( "\n", $ aData['Cou pleFields' ] );   1065                    $sKe ywordField s = implod e( "\n", $ aData['Cou pleFields' ] );
1064                       1066                    
1065                    if(  process_pa ss_data( $ sKeywordFi elds ) !=  $aItem['Ex tra'] )   1067                    if(  process_pa ss_data( $ sKeywordFi elds ) !=  $aItem['Ex tra'] )
1066                         $aUpdate[' Extra'] =  $sKeywordF ields;   1068                         $aUpdate[' Extra'] =  $sKeywordF ields;
1067                }   1069                }
1068           }   1070           }
1069              1071           
1070           //  update er ror messag es   1072           //  update er ror messag es
1071           fo reach( arr ay( 'Manda tory', 'Mi n', 'Max',  'Unique',  'Check' )  as $sErrN ame ) {   1073           fo reach( arr ay( 'Manda tory', 'Mi n', 'Max',  'Unique',  'Check' )  as $sErrN ame ) {
1072                $sErrMsg  = trim( p rocess_pas s_data( $a Data[$sErr Name . '_m sg'] ) );   1074                $sErrMsg  = trim( p rocess_pas s_data( $a Data[$sErr Name . '_m sg'] ) );
1073                if( empt y($sErrMsg ) )   1075                if( empt y($sErrMsg ) )
1074                    cont inue;   1076                    cont inue;
1075                   1077                
1076                $sErrKey  = "_Field Error_{$sN ewName}_{$ sErrName}" ;   1078                $sErrKey  = "_Field Error_{$sN ewName}_{$ sErrName}" ;
1077                   1079                
1078                $this ->  updateLan gString( $ sErrKey, $ sErrMsg );   1080                $this ->  updateLan gString( $ sErrKey, $ sErrMsg );
1079           }   1081           }
1080              1082           
1081           //  add match ing   1083           //  add match ing
1082           if ( isset( $ aData['Mat chField']  ) and (int )$aData['M atchField' ] != $aIte m['MatchFi eld'] )   1084           if ( isset( $ aData['Mat chField']  ) and (int )$aData['M atchField' ] != $aIte m['MatchFi eld'] )
1083                $aUpdate ['MatchFie ld'] = (in t)$aData[' MatchField '];   1085                $aUpdate ['MatchFie ld'] = (in t)$aData[' MatchField '];
1084              1086           
1085           if ( isset( $ aData['Mat chPercent' ] ) and (i nt)$aData[ 'MatchPerc ent'] != $ aItem['Mat chPercent' ] )   1087           if ( isset( $ aData['Mat chPercent' ] ) and (i nt)$aData[ 'MatchPerc ent'] != $ aItem['Mat chPercent' ] )
1086                $aUpdate ['MatchPer cent'] = ( int)$aData ['MatchPer cent'];   1088                $aUpdate ['MatchPer cent'] = ( int)$aData ['MatchPer cent'];
1087              1089           
1088           if ( !empty(  $aUpdate )  and !$bHa veErrors )  {   1090           if ( !empty(  $aUpdate )  and !$bHa veErrors )  {
1089                $this ->  doUpdateI tem( $aIte m, $aUpdat e );   1091                $this ->  doUpdateI tem( $aIte m, $aUpdat e );
1090                if( isse t( $aUpdat e['Name']  ) )   1092                if( isse t( $aUpdat e['Name']  ) )
1091                    $thi s -> genSa veItemForm Update( 'u pdateItem' , $iItemID , $aUpdate ['Name'] ) ;   1093                    $thi s -> genSa veItemForm Update( 'u pdateItem' , $iItemID , $aUpdate ['Name'] ) ;
1092                   1094                
1093                if( $aIt em['Type']  == 'block ' and $aUp date['Name '] ) {   1095                if( $aIt em['Type']  == 'block ' and $aUp date['Name '] ) {
1094                    $sQu ery = "   1096                    $sQu ery = "
1095                         UPDATE `Pa geCompose`  SET   1097                         UPDATE `Pa geCompose`  SET
1096                             `Capti on` = '_Fi eldCaption _" . addsl ashes( $sN ewName ) .  "_View'   1098                             `Capti on` = '_Fi eldCaption _" . addsl ashes( $sN ewName ) .  "_View'
1097                         WHERE   1099                         WHERE
1098                             `Func`  = 'PFBloc k' AND   1100                             `Func`  = 'PFBloc k' AND
1099                             `Conte nt` = '$iI temID'   1101                             `Conte nt` = '$iI temID'
1100                         ";   1102                         ";
1101                       1103                    
1102                    db_r es( $sQuer y );   1104                    db_r es( $sQuer y );
1103                }   1105                }
1104           }   1106           }
1105              1107           
1106           if ( !$bHaveE rrors )   1108           if ( !$bHaveE rrors )
1107                $this ->  genSaveIt emFormClos e();   1109                $this ->  genSaveIt emFormClos e();
1108              1110           
1109           $t his -> gen SaveItemFo oter();   1111           $t his -> gen SaveItemFo oter();
1110       }   1112       }
1111          1113       
1112       functi on setMinM axAge( $iM in, $iMax  ) {   1114       functi on setMinM axAge( $iM in, $iMax  ) {
1113           se tParam( 's earch_star t_age', $i Min );   1115           se tParam( 's earch_star t_age', $i Min );
1114           se tParam( 's earch_end_ age',   $i Max );   1116           se tParam( 's earch_end_ age',   $i Max );
1115       }   1117       }
1116          1118       
1117       functi on checkVa luesLink(  $sKey ) {   1119       functi on checkVa luesLink(  $sKey ) {
1118           gl obal $aPre Values;   1120           gl obal $aPre Values;
1119              1121           
1120           re turn isset ( $aPreVal ues[$sKey]  );   1122           re turn isset ( $aPreVal ues[$sKey]  );
1121       }   1123       }
1122          1124       
1123       functi on checkSe lectDefaul t( $sValue s, $sDefau lt ) {   1125       functi on checkSe lectDefaul t( $sValue s, $sDefau lt ) {
1124           gl obal $aPre Values;   1126           gl obal $aPre Values;
1125              1127           
1126           if ( substr(  $sValues,  0, 2 ) ==  $this -> s LinkPref )  { //it is  link   1128           if ( substr(  $sValues,  0, 2 ) ==  $this -> s LinkPref )  { //it is  link
1127                $sKey =  substr( $s Values, 2  );   1129                $sKey =  substr( $s Values, 2  );
1128                return i sset( $aPr eValues[$s Key][$sDef ault] );   1130                return i sset( $aPr eValues[$s Key][$sDef ault] );
1129           }  else {   1131           }  else {
1130                $aValues  = explode ( "\n", $s Values );   1132                $aValues  = explode ( "\n", $s Values );
1131                return i n_array( $ sDefault,  $aValues ) ;   1133                return i n_array( $ sDefault,  $aValues ) ;
1132           }   1134           }
1133       }   1135       }
1134          1136       
1135       functi on doUpdat eItem( $aI tem, $aUpd ate ) {   1137       functi on doUpdat eItem( $aI tem, $aUpd ate ) {
1136           gl obal $aPre Values;   1138           gl obal $aPre Values;
1137              1139           
1138           $a UpdateStrs  = '';   1140           $a UpdateStrs  = '';
1139           fo reach( $aU pdate as $ sKey => $s Value ) {   1141           fo reach( $aU pdate as $ sKey => $s Value ) {
1140                if( is_n ull( $sVal ue ) )   1142                if( is_n ull( $sVal ue ) )
1141                    $aUp dateStrs[]  = "`$sKey ` = NULL";   1143                    $aUp dateStrs[]  = "`$sKey ` = NULL";
1142                else   1144                else
1143                    $aUp dateStrs[]  = "`$sKey ` = '" . a ddslashes(  $sValue )  . "'";   1145                    $aUp dateStrs[]  = "`$sKey ` = '" . a ddslashes(  $sValue )  . "'";
1144           }   1146           }
1145              1147           
1146           $s Query = "   1148           $s Query = "
1147                UPDATE ` ProfileFie lds` SET    1149                UPDATE ` ProfileFie lds` SET 
1148                    " .  implode( "   1150                    " .  implode( "
1149                    ", $ aUpdateStr s ) . "   1151                    ", $ aUpdateStr s ) . "
1150                WHERE `I D` = {$aIt em['ID']}" ;   1152                WHERE `I D` = {$aIt em['ID']}" ;
1151              1153           
1152           db _res( $sQu ery );   1154           db _res( $sQu ery );
1153              1155           
1154           if ( //we nee d alter Pr ofiles tab le   1156           if ( //we nee d alter Pr ofiles tab le
1155                $aItem[' Type'] !=  'block' an d (   1157                $aItem[' Type'] !=  'block' an d (
1156                    isse t( $aUpdat e['Type']  ) or   1158                    isse t( $aUpdat e['Type']  ) or
1157                    isse t( $aUpdat e['Name']  ) or   1159                    isse t( $aUpdat e['Name']  ) or
1158                    isse t( $aUpdat e['Values' ] ) or   1160                    isse t( $aUpdat e['Values' ] ) or
1159                    isse t( $aUpdat e['Default '] )   1161                    isse t( $aUpdat e['Default '] )
1160                )   1162                )
1161           )  {   1163           )  {
1162                $aAlter  = array(   1164                $aAlter  = array(
1163                    'Typ e'    => i sset( $aUp date['Type ']    ) ?  $aUpdate[' Type']     : $aItem[' Type'],   1165                    'Typ e'    => i sset( $aUp date['Type ']    ) ?  $aUpdate[' Type']     : $aItem[' Type'],
1164                    'Nam e'    => i sset( $aUp date['Name ']    ) ?  $aUpdate[' Name']     : $aItem[' Name'],   1166                    'Nam e'    => i sset( $aUp date['Name ']    ) ?  $aUpdate[' Name']     : $aItem[' Name'],
1165                    'Val ues'  => i sset( $aUp date['Valu es']  ) ?  $aUpdate[' Values']   : $aItem[' Values'],   1167                    'Val ues'  => i sset( $aUp date['Valu es']  ) ?  $aUpdate[' Values']   : $aItem[' Values'],
1166                    'Def ault' => i sset( $aUp date['Defa ult'] ) ?  $aUpdate[' Default']  : $aItem[' Default'],   1168                    'Def ault' => i sset( $aUp date['Defa ult'] ) ?  $aUpdate[' Default']  : $aItem[' Default'],
1167                );   1169                );
1168                   1170                
1169                if( subs tr( $aAlte r['Values' ], 0, 2 )  == $this - > sLinkPre f )   1171                if( subs tr( $aAlte r['Values' ], 0, 2 )  == $this - > sLinkPre f )
1170                    $aAl ter['Type' ] .= '_lin ked';   1172                    $aAl ter['Type' ] .= '_lin ked';
1171                   1173                
1172                $sQuery  = "ALTER T ABLE `Prof iles` CHAN GE `{$aIte m['Name']} ` `{$aAlte r['Name']} ` {$this - > aTypesAl ter[$aAlte r['Type']] }";   1174                $sQuery  = "ALTER T ABLE `Prof iles` CHAN GE `{$aIte m['Name']} ` `{$aAlte r['Name']} ` {$this - > aTypesAl ter[$aAlte r['Type']] }";
1173                $sReplac edVal = ($ aAlter['De fault'] !=  '') ? "de fault '" .  addslashe s( $aAlter ['Default' ] ) . "'"  : "";   1175                $sReplac edVal = ($ aAlter['De fault'] !=  '') ? "de fault '" .  addslashe s( $aAlter ['Default' ] ) . "'"  : "";
1174                $sQuery  = str_repl ace( '{def ault}', $s ReplacedVa l, $sQuery  );   1176                $sQuery  = str_repl ace( '{def ault}', $s ReplacedVa l, $sQuery  );
1175                   1177                
1176                if( $aAl ter['Type' ] == 'sele ct_one' or  $aAlter[' Type'] ==  'select_se t' ) { //i nsert valu es   1178                if( $aAl ter['Type' ] == 'sele ct_one' or  $aAlter[' Type'] ==  'select_se t' ) { //i nsert valu es
1177                    $aVa luesAlter  = explode(  "\n", $aA lter['Valu es'] ); // explode va lues to ar ray   1179                    $aVa luesAlter  = explode(  "\n", $aA lter['Valu es'] ); // explode va lues to ar ray
1178                       1180                    
1179                    fore ach( $aVal uesAlter a s $iKey =>  $sValue ) { //add sl ashes to e very value   1181                    fore ach( $aVal uesAlter a s $iKey =>  $sValue ) { //add sl ashes to e very value
1180                         $sValue =  str_replac e( '\\', ' \\\\', $sV alue );   1182                         $sValue =  str_replac e( '\\', ' \\\\', $sV alue );
1181                         $sValue =  str_replac e( '\'', ' \\\'', $sV alue );   1183                         $sValue =  str_replac e( '\'', ' \\\'', $sV alue );
1182                         $aValuesAl ter[$iKey]  = $sValue ;   1184                         $aValuesAl ter[$iKey]  = $sValue ;
1183                    }   1185                    }
1184                       1186                    
1185                    $sVa luesAlter  = " '" . i mplode( "' , '", $aVa luesAlter  ) . "' ";  // implode  values to  string li ke 'a','b' ,'c\'d'   1187                    $sVa luesAlter  = " '" . i mplode( "' , '", $aVa luesAlter  ) . "' ";  // implode  values to  string li ke 'a','b' ,'c\'d'
1186                    $sQu ery = str_ replace( ' {values}',  $sValuesA lter, $sQu ery ); //r eplace it  in place   1188                    $sQu ery = str_ replace( ' {values}',  $sValuesA lter, $sQu ery ); //r eplace it  in place
1187                } elseif ( $aAlter[ 'Type'] ==  'select_s et_linked'  ) {   1189                } elseif ( $aAlter[ 'Type'] ==  'select_s et_linked'  ) {
1188                    $sLi nk = subst r( $aAlter ['Values'] , 2 );   1190                    $sLi nk = subst r( $aAlter ['Values'] , 2 );
1189                    $aVa luesAlter  = array_ke ys( $aPreV alues[$sLi nk] );   1191                    $aVa luesAlter  = array_ke ys( $aPreV alues[$sLi nk] );
1190                       1192                    
1191                    $sVa luesAlter  = implode(  ', ', $aV aluesAlter  );   1193                    $sVa luesAlter  = implode(  ', ', $aV aluesAlter  );
1192                    $sVa luesAlter  = str_repl ace( '\\',  '\\\\', $ sValuesAlt er );   1194                    $sVa luesAlter  = str_repl ace( '\\',  '\\\\', $ sValuesAlt er );
1193                    $sVa luesAlter  = str_repl ace( '\'',  '\\\'', $ sValuesAlt er );   1195                    $sVa luesAlter  = str_repl ace( '\'',  '\\\'', $ sValuesAlt er );
1194                       1196                    
1195                    $sVa luesAlter  = "'" .str _replace(  ', ', "',  '", $sValu esAlter )  ."'";   1197                    $sVa luesAlter  = "'" .str _replace(  ', ', "',  '", $sValu esAlter )  ."'";
1196                       1198                    
1197                    $sQu ery = str_ replace( ' {values}',  $sValuesA lter, $sQu ery ); //r eplace it  in place   1199                    $sQu ery = str_ replace( ' {values}',  $sValuesA lter, $sQu ery ); //r eplace it  in place
1198                }   1200                }
1199                   1201                
1200                db_res(  $sQuery );   1202                db_res(  $sQuery );
1201           }   1203           }
1202       }   1204       }
1203          1205       
1204       functi on createN ewField()  {   1206       functi on createN ewField()  {
1205           $i NewID = 0;   1207           $i NewID = 0;
1206              1208           
1207           // try to ins ert new it em   1209           // try to ins ert new it em
1208           if ( db_res(  "INSERT IN TO `Profil eFields` ( `Name`, `T ype` ) VAL UES ('NEW_ ITEM', 'te xt')", 0 )  and $iNew ID = mysql _insert_id () ) {   1210           if ( db_res(  "INSERT IN TO `Profil eFields` ( `Name`, `T ype` ) VAL UES ('NEW_ ITEM', 'te xt')", 0 )  and $iNew ID = mysql _insert_id () ) {
1209                //if suc cess - try  to alter  table   1211                //if suc cess - try  to alter  table
1210                if( !db_ res( "ALTE R TABLE `P rofiles` A DD `NEW_IT EM` varcha r(255) NOT  NULL defa ult ''", 0  ) ) {   1212                if( !db_ res( "ALTE R TABLE `P rofiles` A DD `NEW_IT EM` varcha r(255) NOT  NULL defa ult ''", 0  ) ) {
1211                    //if  couldn't  alter - de lete inser ted field   1213                    //if  couldn't  alter - de lete inser ted field
1212                    db_r es( "DELET E FROM `Pr ofileField s` WHERE ` ID` = $iNe wID" );   1214                    db_r es( "DELET E FROM `Pr ofileField s` WHERE ` ID` = $iNe wID" );
1213                    $iNe wID = 0;   1215                    $iNe wID = 0;
1214                }   1216                }
1215           }   1217           }
1216              1218           
1217           re turn $iNew ID;   1219           re turn $iNew ID;
1218       }   1220       }
1219          1221       
1220       functi on createN ewBlock()  {   1222       functi on createN ewBlock()  {
1221           db _res( "INS ERT INTO ` ProfileFie lds` (`Nam e`, `Type`  ) VALUES  ('NEW BLOC K', 'block ')", 0 );   1223           db _res( "INS ERT INTO ` ProfileFie lds` (`Nam e`, `Type`  ) VALUES  ('NEW BLOC K', 'block ')", 0 );
1222           $i NewID = my sql_insert _id();   1224           $i NewID = my sql_insert _id();
1223              1225           
1224           db _res( "   1226           db _res( "
1225                INSERT I NTO `PageC ompose`   1227                INSERT I NTO `PageC ompose`
1226                    ( `D esc`, `Cap tion`, `Vi sible`, `F unc`, `Con tent`, `Pa ge` )   1228                    ( `D esc`, `Cap tion`, `Vi sible`, `F unc`, `Con tent`, `Pa ge` )
1227                VALUES   1229                VALUES
1228                    ( 'P rofile Fie lds Block' , '_FieldC aption_NEW  BLOCK_Vie w', 'non,m emb', 'PFB lock', '$i NewID', 'p rofile' )   1230                    ( 'P rofile Fie lds Block' , '_FieldC aption_NEW  BLOCK_Vie w', 'non,m emb', 'PFB lock', '$i NewID', 'p rofile' )
1229           "  );   1231           "  );
1230              1232           
1231           re turn $iNew ID;   1233           re turn $iNew ID;
1232       }   1234       }
1233          1235       
1234       functi on updateL angString(  $sKey, $s String ) {   1236       functi on updateL angString(  $sKey, $s String ) {
1235              1237           
1236           if ( $sKey ==  '' )   1238           if ( $sKey ==  '' )
1237                return f alse;   1239                return f alse;
1238              1240           
1239           $s Key_db     = addslash es( $sKey  );   1241           $s Key_db     = addslash es( $sKey  );
1240           $s String_db  = addslash es( $sStri ng );   1242           $s String_db  = addslash es( $sStri ng );
1241              1243           
1242           $s Query = "S ELECT `ID`  FROM `Loc alizationK eys` WHERE  `Key` = ' $sKey_db'" ;   1244           $s Query = "S ELECT `ID`  FROM `Loc alizationK eys` WHERE  `Key` = ' $sKey_db'" ;
1243           $i KeyID = (i nt)db_valu e( $sQuery  );   1245           $i KeyID = (i nt)db_valu e( $sQuery  );
1244              1246           
1245           if ( !$iKeyID  ) { //cre ate key   1247           if ( !$iKeyID  ) { //cre ate key
1246                $sQuery  = "INSERT  INTO `Loca lizationKe ys` (`IDCa tegory`,`K ey`) VALUE S (32,'$sK ey_db')";   1248                $sQuery  = "INSERT  INTO `Loca lizationKe ys` (`IDCa tegory`,`K ey`) VALUE S (32,'$sK ey_db')";
1247                db_res(  $sQuery );   1249                db_res(  $sQuery );
1248                $iKeyID  = mysql_in sert_id();   1250                $iKeyID  = mysql_in sert_id();
1249           }   1251           }
1250              1252           
1251           $s Query = "   1253           $s Query = "
1252                SELECT C OUNT( * )  FROM `Loca lizationSt rings`   1254                SELECT C OUNT( * )  FROM `Loca lizationSt rings`
1253                WHERE `I DKey` = $i KeyID AND  `IDLanguag e` = {$thi s -> sLang ID}";   1255                WHERE `I DKey` = $i KeyID AND  `IDLanguag e` = {$thi s -> sLang ID}";
1254              1256           
1255           $i Count = (i nt)db_valu e( $sQuery  );   1257           $i Count = (i nt)db_valu e( $sQuery  );
1256              1258           
1257           if ( $iCount  ) {   1259           if ( $iCount  ) {
1258                $sQuery  = "   1260                $sQuery  = "
1259                    UPDA TE `Locali zationStri ngs`   1261                    UPDA TE `Locali zationStri ngs`
1260                    SET  `String` =  '$sString _db'   1262                    SET  `String` =  '$sString _db'
1261                    WHER E `IDKey`  = $iKeyID  AND `IDLan guage` = { $this -> s LangID}";   1263                    WHER E `IDKey`  = $iKeyID  AND `IDLan guage` = { $this -> s LangID}";
1262                   1264                
1263                db_res(  $sQuery );   1265                db_res(  $sQuery );
1264           }  else {   1266           }  else {
1265                $sQuery  = "INSERT  INTO `Loca lizationSt rings` VAL UES ( $iKe yID, {$thi s -> sLang ID}, '$sSt ring_db' ) ";   1267                $sQuery  = "INSERT  INTO `Loca lizationSt rings` VAL UES ( $iKe yID, {$thi s -> sLang ID}, '$sSt ring_db' ) ";
1266                db_res(  $sQuery );   1268                db_res(  $sQuery );
1267           }   1269           }
1268              1270           
1269           co mpileLangu age( $this  -> sLangI D );   1271           co mpileLangu age( $this  -> sLangI D );
1270       }   1272       }
1271          1273       
1272       functi on genSave ItemHeader () {   1274       functi on genSave ItemHeader () {
1273           ?>   1275           ?>
1274   <html><scr ipt type=" text/javas cript">   1276   <html><scr ipt type=" text/javas cript">
1275           <?   1277           <?
1276       }   1278       }
1277          1279       
1278       functi on genSave ItemError(  $sText, $ sField = ' ' ) {   1280       functi on genSave ItemError(  $sText, $ sField = ' ' ) {
1279           $t his -> isH aveErrors  = true;   1281           $t his -> isH aveErrors  = true;
1280              1282           
1281           if ( !$sField  )   1283           if ( !$sField  )
1282                echo "al ert( '" .  addslashes ( $sText )  . "' );";   1284                echo "al ert( '" .  addslashes ( $sText )  . "' );";
1283           el se {   1285           el se {
1284                ?>   1286                ?>
1285                parent.g enEditForm Error( '<? = $sField  ?>', '<?=  addslashes ( $sText )  ?>' );   1287                parent.g enEditForm Error( '<? = $sField  ?>', '<?=  addslashes ( $sText )  ?>' );
1286                <?   1288                <?
1287           }   1289           }
1288       }   1290       }
1289          1291       
1290       functi on genSave ItemFooter () {   1292       functi on genSave ItemFooter () {
1291           ?>   1293           ?>
1292     1294  
1293   </script>< /html>   1295   </script>< /html>
1294           <?   1296           <?
1295       }   1297       }
1296          1298       
1297       functi on deleteI tem( $iIte mID ) {   1299       functi on deleteI tem( $iIte mID ) {
1298           $t his -> gen SaveItemHe ader();   1300           $t his -> gen SaveItemHe ader();
1299              1301           
1300           $a Item = db_ assoc_arr(  "SELECT *  FROM `Pro fileFields ` WHERE `I D` = $iIte mID" );   1302           $a Item = db_ assoc_arr(  "SELECT *  FROM `Pro fileFields ` WHERE `I D` = $iIte mID" );
1301              1303           
1302           if ( !$aItem  )   1304           if ( !$aItem  )
1303                $this ->  genSaveIt emError( ' Warning! I tem not fo und.' );   1305                $this ->  genSaveIt emError( ' Warning! I tem not fo und.' );
1304           el seif( $aIt em['Type']  == 'syste m' or !(in t)$aItem[' Deletable' ] )   1306           el seif( $aIt em['Type']  == 'syste m' or !(in t)$aItem[' Deletable' ] )
1305                $this ->  genSaveIt emError( ' The field  cannot be  deleted.'  );   1307                $this ->  genSaveIt emError( ' The field  cannot be  deleted.'  );
1306           el se{   1308           el se{
1307                $sQuery  = "DELETE  FROM `Prof ileFields`  WHERE `ID ` = $iItem ID";   1309                $sQuery  = "DELETE  FROM `Prof ileFields`  WHERE `ID ` = $iItem ID";
1308                db_res(  $sQuery );   1310                db_res(  $sQuery );
1309                   1311                
1310                if( $aIt em['Type']  == 'block ' )   1312                if( $aIt em['Type']  == 'block ' )
1311                    db_r es( "DELET E FROM `Pa geCompose`  WHERE `Fu nc` = 'PFB lock' AND  `Content`  = '$iItemI D'" );   1313                    db_r es( "DELET E FROM `Pa geCompose`  WHERE `Fu nc` = 'PFB lock' AND  `Content`  = '$iItemI D'" );
1312                else   1314                else
1313                    db_r es( "ALTER  TABLE `Pr ofiles` DR OP `{$aIte m['Name']} `" );   1315                    db_r es( "ALTER  TABLE `Pr ofiles` DR OP `{$aIte m['Name']} `" );
1314                   1316                
1315                $this ->  genSaveIt emFormUpda te( 'delet eItem', $i ItemID );   1317                $this ->  genSaveIt emFormUpda te( 'delet eItem', $i ItemID );
1316                //$this  -> genSave ItemFormCl ose();   1318                //$this  -> genSave ItemFormCl ose();
1317           }   1319           }
1318           $t his -> gen SaveItemFo oter();   1320           $t his -> gen SaveItemFo oter();
1319       }   1321       }
1320          1322       
1321       functi on genSave ItemFormUp date( $sTe xt, $iItem ID, $sNewN ame = '' )  {   1323       functi on genSave ItemFormUp date( $sTe xt, $iItem ID, $sNewN ame = '' )  {
1322           ?>   1324           ?>
1323           pa rent.updat eBuilder(  '<?= $sTex t ?>', <?=  $iItemID  ?>, '<?= a ddslashes(  $sNewName  ) ?>' );   1325           pa rent.updat eBuilder(  '<?= $sTex t ?>', <?=  $iItemID  ?>, '<?= a ddslashes(  $sNewName  ) ?>' );
1324           <?   1326           <?
1325       }   1327       }
1326          1328       
1327       functi on genSave ItemFormCl ose() {   1329       functi on genSave ItemFormCl ose() {
1328           ?>   1330           ?>
1329           pa rent.hideE ditForm();   1331           pa rent.hideE ditForm();
1330           <?   1332           <?
1331       }   1333       }
1332   }   1334   }
1333     1335  
1334     1336  
1335     1337  
1336   class BxDo lPFMAreaJS ONObj {   1338   class BxDo lPFMAreaJS ONObj {
1337          1339       
1338       functi on BxDolPF MAreaJSONO bj( $oArea  ) {   1340       functi on BxDolPF MAreaJSONO bj( $oArea  ) {
1339           $t his -> id  = $oArea - > iAreaID;   1341           $t his -> id  = $oArea - > iAreaID;
1340              1342           
1341           $t his -> act ive_blocks    = array ();   1343           $t his -> act ive_blocks    = array ();
1342           $t his -> ina ctive_bloc ks = array ();   1344           $t his -> ina ctive_bloc ks = array ();
1343           $t his -> act ive_items     = array ();   1345           $t his -> act ive_items     = array ();
1344           $t his -> ina ctive_item s  = array ();   1346           $t his -> ina ctive_item s  = array ();
1345              1347           
1346           fo reach( $oA rea -> aBl ocks as $i ID => $sNa me )   1348           fo reach( $oA rea -> aBl ocks as $i ID => $sNa me )
1347                $this ->  active_bl ocks[] = n ew BxDolPF MItem( $iI D, $sName  );   1349                $this ->  active_bl ocks[] = n ew BxDolPF MItem( $iI D, $sName  );
1348              1350           
1349           fo reach( $oA rea -> aIt ems as $iI D => $aIte m )   1351           fo reach( $oA rea -> aIt ems as $iI D => $aIte m )
1350                $this ->  active_it ems[] = ne w BxDolPFM Item( $iID , $aItem[0 ], $aItem[ 1] );   1352                $this ->  active_it ems[] = ne w BxDolPFM Item( $iID , $aItem[0 ], $aItem[ 1] );
1351              1353           
1352           fo reach( $oA rea -> aBl ocksInac a s $iID =>  $sName )   1354           fo reach( $oA rea -> aBl ocksInac a s $iID =>  $sName )
1353                $this ->  inactive_ blocks[] =  new BxDol PFMItem( $ iID, $sNam e );   1355                $this ->  inactive_ blocks[] =  new BxDol PFMItem( $ iID, $sNam e );
1354              1356           
1355           fo reach( $oA rea -> aIt emsInac as  $iID => $ sName )   1357           fo reach( $oA rea -> aIt emsInac as  $iID => $ sName )
1356                $this ->  inactive_ items[] =  new BxDolP FMItem( $i ID, $sName  );   1358                $this ->  inactive_ items[] =  new BxDolP FMItem( $i ID, $sName  );
1357       }   1359       }
1358   }   1360   }
1359     1361  
1360   /* Used fo r JSON gen eration */   1362   /* Used fo r JSON gen eration */
1361   class BxDo lPFMItem {   1363   class BxDo lPFMItem {
1362          1364       
1363       functi on BxDolPF MItem( $iI D, $sName,  $iBlock =  0 ) {   1365       functi on BxDolPF MItem( $iI D, $sName,  $iBlock =  0 ) {
1364           $t his -> id  = $iID;   1366           $t his -> id  = $iID;
1365           $t his -> nam e = $sName ;   1367           $t his -> nam e = $sName ;
1366              1368           
1367           $t his -> blo ck = $iBlo ck;   1369           $t his -> blo ck = $iBlo ck;
1368       }   1370       }
1369   }   1371   }
1370     1372  
1371     1373  
1372     1374  
1373   /*   1375   /*
1374       Cacher  created o nly for cr eating a c ache :)   1376       Cacher  created o nly for cr eating a c ache :)
1375   */   1377   */
1376     1378  
1377   class BxDo lPFMCacher  {   1379   class BxDo lPFMCacher  {
1378          1380       
1379       var $a AreasProps ;   1381       var $a AreasProps ;
1380       var $s CacheFile;   1382       var $s CacheFile;
1381          1383       
1382       functi on BxDolPF MCacher()  {   1384       functi on BxDolPF MCacher()  {
1383              1385           
1384           // additional  propertie s for cach ing blocks   1386           // additional  propertie s for cach ing blocks
1385           $a AddBlockPr ops = arra y(    1387           $a AddBlockPr ops = arra y( 
1386                'Join' = > array(   1388                'Join' = > array(
1387                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Join',   1389                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Join',
1388                    'Des c'      =>  '_FieldDe sc_{Name}_ Join'   1390                    'Des c'      =>  '_FieldDe sc_{Name}_ Join'
1389                ),   1391                ),
1390                'Edit' = > array(   1392                'Edit' = > array(
1391                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Edit',   1393                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Edit',
1392                    'Des c'      =>  '_FieldDe sc_{Name}_ Edit'   1394                    'Des c'      =>  '_FieldDe sc_{Name}_ Edit'
1393                ),   1395                ),
1394                'View' = > array(   1396                'View' = > array(
1395                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_View',   1397                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_View',
1396                    'Des c'      =>  '_FieldDe sc_{Name}_ View'   1398                    'Des c'      =>  '_FieldDe sc_{Name}_ View'
1397                ),   1399                ),
1398                'Search'  => array(   1400                'Search'  => array(
1399                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Search' ,   1401                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Search' ,
1400                    'Des c'      =>  '_FieldDe sc_{Name}_ Search'   1402                    'Des c'      =>  '_FieldDe sc_{Name}_ Search'
1401                )   1403                )
1402           );   1404           );
1403     1405  
1404           // additional  propertie s for cach ing items   1406           // additional  propertie s for cach ing items
1405           $a AddProps =  array(    1407           $a AddProps =  array( 
1406                'Join' = > array(   1408                'Join' = > array(
1407                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Join',   1409                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Join',
1408                    'Des c'      =>  '_FieldDe sc_{Name}_ Join',   1410                    'Des c'      =>  '_FieldDe sc_{Name}_ Join',
1409                    'Man datoryMsg'  => '_Fiel dError_{Na me}_Mandat ory',   1411                    'Man datoryMsg'  => '_Fiel dError_{Na me}_Mandat ory',
1410                    'Min Msg'    =>  '_FieldEr ror_{Name} _Min',   1412                    'Min Msg'    =>  '_FieldEr ror_{Name} _Min',
1411                    'Max Msg'    =>  '_FieldEr ror_{Name} _Max',   1413                    'Max Msg'    =>  '_FieldEr ror_{Name} _Max',
1412                    'Uni queMsg' =>  '_FieldEr ror_{Name} _Unique',   1414                    'Uni queMsg' =>  '_FieldEr ror_{Name} _Unique',
1413                    'Che ckMsg'  =>  '_FieldEr ror_{Name} _Check'   1415                    'Che ckMsg'  =>  '_FieldEr ror_{Name} _Check'
1414                ),   1416                ),
1415                'Edit' = > array(   1417                'Edit' = > array(
1416                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Edit',   1418                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Edit',
1417                    'Des c'      =>  '_FieldDe sc_{Name}_ Edit',   1419                    'Des c'      =>  '_FieldDe sc_{Name}_ Edit',
1418                    'Man datoryMsg'   => '_Fie ldError_{N ame}_Manda tory',   1420                    'Man datoryMsg'   => '_Fie ldError_{N ame}_Manda tory',
1419                    'Min Msg'    =>  '_FieldEr ror_{Name} _Min',   1421                    'Min Msg'    =>  '_FieldEr ror_{Name} _Min',
1420                    'Max Msg'    =>  '_FieldEr ror_{Name} _Max',   1422                    'Max Msg'    =>  '_FieldEr ror_{Name} _Max',
1421                    'Uni queMsg' =>  '_FieldEr ror_{Name} _Unique',   1423                    'Uni queMsg' =>  '_FieldEr ror_{Name} _Unique',
1422                    'Che ckMsg'  =>  '_FieldEr ror_{Name} _Check'   1424                    'Che ckMsg'  =>  '_FieldEr ror_{Name} _Check'
1423                ),   1425                ),
1424                'View' = > array(   1426                'View' = > array(
1425                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_View',   1427                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_View',
1426                    'Des c'      =>  '_FieldDe sc_{Name}_ View'   1428                    'Des c'      =>  '_FieldDe sc_{Name}_ View'
1427                ),   1429                ),
1428                'Search'  => array(   1430                'Search'  => array(
1429                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Search' ,   1431                    'Cap tion'   =>  '_FieldCa ption_{Nam e}_Search' ,
1430                    'Des c'      =>  '_FieldDe sc_{Name}_ Search'   1432                    'Des c'      =>  '_FieldDe sc_{Name}_ Search'
1431                )   1433                )
1432           );   1434           );
1433              1435           
1434           $t his -> aAr easProps =  array (   1436           $t his -> aAr easProps =  array (
1435                1  => ar ray( 'Titl e' => 'Joi n',   'Ord er' => 'Jo inOrder',  'Block' =>  'JoinBloc k', 'AddSe lect' => ' Control,Ex tra,Min,Ma x,Values,C heck,Uniqu e,Mandator y,UseLKey' ,                'Add BlockProps ' => $aAdd BlockProps ['Join'],    'AddProp s' => $aAd dProps['Jo in'] ),   1437                1  => ar ray( 'Titl e' => 'Joi n',   'Ord er' => 'Jo inOrder',  'Block' =>  'JoinBloc k', 'AddSe lect' => ' Control,Ex tra,Min,Ma x,Values,C heck,Uniqu e,Mandator y,UseLKey' ,                'Add BlockProps ' => $aAdd BlockProps ['Join'],    'AddProp s' => $aAd dProps['Jo in'] ),
1436                   1438                
1437                2  => ar ray( 'Titl e' => 'Edi t (Owner)' ,   'Order ' => 'Edit OwnOrder',  'Block' = > 'EditOwn Block', 'A ddSelect'  => 'Contro l,Extra,Mi n,Max,Valu es,Check,U nique,Mand atory,UseL Key', 'Add BlockProps ' => $aAdd BlockProps ['Edit'],    'AddProp s' => $aAd dProps['Ed it'] ),   1439                2  => ar ray( 'Titl e' => 'Edi t (Owner)' ,   'Order ' => 'Edit OwnOrder',  'Block' = > 'EditOwn Block', 'A ddSelect'  => 'Contro l,Extra,Mi n,Max,Valu es,Check,U nique,Mand atory,UseL Key', 'Add BlockProps ' => $aAdd BlockProps ['Edit'],    'AddProp s' => $aAd dProps['Ed it'] ),
1438                3  => ar ray( 'Titl e' => 'Edi t (Admin)' ,   'Order ' => 'Edit AdmOrder',  'Block' = > 'EditAdm Block', 'A ddSelect'  => 'Contro l,Extra,Mi n,Max,Valu es,Check,U nique,Mand atory,UseL Key', 'Add BlockProps ' => $aAdd BlockProps ['Edit'],    'AddProp s' => $aAd dProps['Ed it'] ),   1440                3  => ar ray( 'Titl e' => 'Edi t (Admin)' ,   'Order ' => 'Edit AdmOrder',  'Block' = > 'EditAdm Block', 'A ddSelect'  => 'Contro l,Extra,Mi n,Max,Valu es,Check,U nique,Mand atory,UseL Key', 'Add BlockProps ' => $aAdd BlockProps ['Edit'],    'AddProp s' => $aAd dProps['Ed it'] ),
1439                4  => ar ray( 'Titl e' => 'Edi t (Moder)' ,   'Order ' => 'Edit ModOrder',  'Block' = > 'EditMod Block', 'A ddSelect'  => 'Contro l,Extra,Mi n,Max,Valu es,Check,U nique,Mand atory,UseL Key', 'Add BlockProps ' => $aAdd BlockProps ['Edit'],    'AddProp s' => $aAd dProps['Ed it'] ),   1441                4  => ar ray( 'Titl e' => 'Edi t (Moder)' ,   'Order ' => 'Edit ModOrder',  'Block' = > 'EditMod Block', 'A ddSelect'  => 'Contro l,Extra,Mi n,Max,Valu es,Check,U nique,Mand atory,UseL Key', 'Add BlockProps ' => $aAdd BlockProps ['Edit'],    'AddProp s' => $aAd dProps['Ed it'] ),
1440                   1442                
1441                5  => ar ray( 'Titl e' => 'Vie w (Admin)' ,     'Ord er' => 'Vi ewAdmOrder ',  'Block ' => 'View AdmBlock',   'AddSele ct' => 'Va lues,UseLK ey',                           ' AddBlockPr ops' => $a AddBlockPr ops['View' ],   'AddP rops' => $ aAddProps[ 'View'] ),   1443                5  => ar ray( 'Titl e' => 'Vie w (Admin)' ,     'Ord er' => 'Vi ewAdmOrder ',  'Block ' => 'View AdmBlock',   'AddSele ct' => 'Va lues,UseLK ey',                           ' AddBlockPr ops' => $a AddBlockPr ops['View' ],   'AddP rops' => $ aAddProps[ 'View'] ),
1442                6  => ar ray( 'Titl e' => 'Vie w (Member) ',    'Ord er' => 'Vi ewMembOrde r', 'Block ' => 'View MembBlock' , 'AddSele ct' => 'Va lues,UseLK ey',                           ' AddBlockPr ops' => $a AddBlockPr ops['View' ],   'AddP rops' => $ aAddProps[ 'View'] ),   1444                6  => ar ray( 'Titl e' => 'Vie w (Member) ',    'Ord er' => 'Vi ewMembOrde r', 'Block ' => 'View MembBlock' , 'AddSele ct' => 'Va lues,UseLK ey',                           ' AddBlockPr ops' => $a AddBlockPr ops['View' ],   'AddP rops' => $ aAddProps[ 'View'] ),
1443                7  => ar ray( 'Titl e' => 'Vie w (Moder)' ,     'Ord er' => 'Vi ewModOrder ',  'Block ' => 'View ModBlock',   'AddSele ct' => 'Va lues,UseLK ey',                           ' AddBlockPr ops' => $a AddBlockPr ops['View' ],   'AddP rops' => $ aAddProps[ 'View'] ),   1445                7  => ar ray( 'Titl e' => 'Vie w (Moder)' ,     'Ord er' => 'Vi ewModOrder ',  'Block ' => 'View ModBlock',   'AddSele ct' => 'Va lues,UseLK ey',                           ' AddBlockPr ops' => $a AddBlockPr ops['View' ],   'AddP rops' => $ aAddProps[ 'View'] ),
1444                8  => ar ray( 'Titl e' => 'Vie w (Visitor )',   'Ord er' => 'Vi ewVisOrder ',  'Block ' => 'View VisBlock',   'AddSele ct' => 'Va lues,UseLK ey',                           ' AddBlockPr ops' => $a AddBlockPr ops['View' ],   'AddP rops' => $ aAddProps[ 'View'] ),   1446                8  => ar ray( 'Titl e' => 'Vie w (Visitor )',   'Ord er' => 'Vi ewVisOrder ',  'Block ' => 'View VisBlock',   'AddSele ct' => 'Va lues,UseLK ey',                           ' AddBlockPr ops' => $a AddBlockPr ops['View' ],   'AddP rops' => $ aAddProps[ 'View'] ),
1445                   1447                
1446                9  => ar ray( 'Titl e' => 'Sea rch (Simpl e)', 'Orde r' => 'Sea rchSimpleO rder', 'Bl ock' => 'S earchSimpl eBlock', ' AddSelect'  => 'Extra ,Control,U seLKey',               'AddBlock Props' =>  $aAddBlock Props['Sea rch'], 'Ad dProps' =>  $aAddProp s['Search' ] ),   1448                9  => ar ray( 'Titl e' => 'Sea rch (Simpl e)', 'Orde r' => 'Sea rchSimpleO rder', 'Bl ock' => 'S earchSimpl eBlock', ' AddSelect'  => 'Extra ,Control,U seLKey',               'AddBlock Props' =>  $aAddBlock Props['Sea rch'], 'Ad dProps' =>  $aAddProp s['Search' ] ),
1447                10 => ar ray( 'Titl e' => 'Sea rch (Quick )',  'Orde r' => 'Sea rchQuickOr der',  'Bl ock' => 'S earchQuick Block',  ' AddSelect'  => 'Extra ,Control,U seLKey',               'AddBlock Props' =>  $aAddBlock Props['Sea rch'], 'Ad dProps' =>  $aAddProp s['Search' ] ),   1449                10 => ar ray( 'Titl e' => 'Sea rch (Quick )',  'Orde r' => 'Sea rchQuickOr der',  'Bl ock' => 'S earchQuick Block',  ' AddSelect'  => 'Extra ,Control,U seLKey',               'AddBlock Props' =>  $aAddBlock Props['Sea rch'], 'Ad dProps' =>  $aAddProp s['Search' ] ),
1448                11 => ar ray( 'Titl e' => 'Sea rch (Adv)' ,    'Orde r' => 'Sea rchAdvOrde r',    'Bl ock' => 'S earchAdvBl ock',    ' AddSelect'  => 'Extra ,Control,U seLKey',               'AddBlock Props' =>  $aAddBlock Props['Sea rch'], 'Ad dProps' =>  $aAddProp s['Search' ] ),   1450                11 => ar ray( 'Titl e' => 'Sea rch (Adv)' ,    'Orde r' => 'Sea rchAdvOrde r',    'Bl ock' => 'S earchAdvBl ock',    ' AddSelect'  => 'Extra ,Control,U seLKey',               'AddBlock Props' =>  $aAddBlock Props['Sea rch'], 'Ad dProps' =>  $aAddProp s['Search' ] ),
1449                   1451                
1450                //specia l areas   1452                //specia l areas
1451                100 => a rray( 'Tit le' => 'Al l Fields.  PC cache',  'AddSelec t' => 'Def ault,Uniqu e,Extra' ) ,   1453                100 => a rray( 'Tit le' => 'Al l Fields.  PC cache',  'AddSelec t' => 'Def ault,Uniqu e,Extra' ) ,
1452                101 => a rray( 'Tit le' => 'Ma tching Fie lds',        'AddSele ct' => 'Ma tchField,M atchPercen t' ),   1454                101 => a rray( 'Tit le' => 'Ma tching Fie lds',        'AddSele ct' => 'Ma tchField,M atchPercen t' ),
1453           );   1455           );
1454              1456           
1455           $t his -> sCa cheFile =  BX_DIRECTO RY_PATH_IN C . 'db_ca ched/Profi leFields.i nc';   1457           $t his -> sCa cheFile =  BX_DIRECTO RY_PATH_IN C . 'db_ca ched/Profi leFields.i nc';
1456              1458           
1457       }   1459       }
1458          1460       
1459       functi on createC ache() {   1461       functi on createC ache() {
1460           $r CacheFile  = @fopen(  $this -> s CacheFile,  'w' );   1462           $r CacheFile  = @fopen(  $this -> s CacheFile,  'w' );
1461           if ( !$rCache File ) {   1463           if ( !$rCache File ) {
1462                echo '<b r /><b>War ning!</b>  Cannot ope n Profile  Fields cac he file ('  . $this - > sCacheFi le . ') fo r write.';   1464                echo '<b r /><b>War ning!</b>  Cannot ope n Profile  Fields cac he file ('  . $this - > sCacheFi le . ') fo r write.';
1463                return f alse;   1465                return f alse;
1464           }   1466           }
1465              1467           
1466           $s CacheStrin g = "// ca che of Pro file Field s\n\nretur n array(\n   //areas\ n";   1468           $s CacheStrin g = "// ca che of Pro file Field s\n\nretur n array(\n   //areas\ n";
1467              1469           
1468           //  get areas   1470           //  get areas
1469           fo reach ($th is -> aAre asProps as  $iAreaID  => $aArea)  {   1471           fo reach ($th is -> aAre asProps as  $iAreaID  => $aArea)  {
1470                $oArea =  new BxDol ProfileFie ldsArea( $ iAreaID, $ this );   1472                $oArea =  new BxDol ProfileFie ldsArea( $ iAreaID, $ this );
1471                   1473                
1472                $sCacheS tring .= $ oArea -> g etCacheStr ing();   1474                $sCacheS tring .= $ oArea -> g etCacheStr ing();
1473           }   1475           }
1474              1476           
1475           $s CacheStrin g .= ");\n ";   1477           $s CacheStrin g .= ");\n ";
1476              1478           
1477              1479           
1478           $i Res = fwri te( $rCach eFile, $sC acheString  );   1480           $i Res = fwri te( $rCach eFile, $sC acheString  );
1479              1481           
1480           fc lose( $rCa cheFile );   1482           fc lose( $rCa cheFile );
1481              1483           
1482           if ( $iRes == = false )  {   1484           if ( $iRes == = false )  {
1483                echo '<b r /><b>War ning!</b>  Cannot wri te to Prof ile Fields  cache fil e (' . $th is -> sCac heFile . ' ).';   1485                echo '<b r /><b>War ning!</b>  Cannot wri te to Prof ile Fields  cache fil e (' . $th is -> sCac heFile . ' ).';
1484                return f alse;   1486                return f alse;
1485           }   1487           }
1486              1488           
1487           re turn true;   1489           re turn true;
1488       }   1490       }
1489          1491       
1490   }   1492   }
1491     1493  
1492   /*   1494   /*
1493       Profil eFieldsAre a   1495       Profil eFieldsAre a
1494       Used p rimarily t o create c ache strin gs   1496       Used p rimarily t o create c ache strin gs
1495   */   1497   */
1496     1498  
1497   class BxDo lProfileFi eldsArea {   1499   class BxDo lProfileFi eldsArea {
1498          1500       
1499       var $i d;   1501       var $i d;
1500       var $o Parent;   1502       var $o Parent;
1501       var $s Title;   1503       var $s Title;
1502       var $s BlockCol;   1504       var $s BlockCol;
1503       var $s OrderCol;   1505       var $s OrderCol;
1504       var $a Blocks;   1506       var $a Blocks;
1505       var $a Pages;   1507       var $a Pages;
1506          1508       
1507       functi on BxDolPr ofileField sArea( $iA reaID, &$o Parent ) {   1509       functi on BxDolPr ofileField sArea( $iA reaID, &$o Parent ) {
1508           $t his -> id  = $iAreaID ;   1510           $t his -> id  = $iAreaID ;
1509           $t his -> oPa rent = &$o Parent;   1511           $t his -> oPa rent = &$o Parent;
1510              1512           
1511           $t his -> sTi tle          = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['Title'];   1513           $t his -> sTi tle          = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['Title'];
1512           $t his -> sBl ockCol       = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['Block'];   1514           $t his -> sBl ockCol       = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['Block'];
1513           $t his -> sOr derCol       = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['Order'];   1515           $t his -> sOr derCol       = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['Order'];
1514           $t his -> sAd dSelect      = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['AddSelec t'];   1516           $t his -> sAd dSelect      = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['AddSelec t'];
1515           $t his -> aAd dBlockProp s = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['AddBlock Props'];   1517           $t his -> aAd dBlockProp s = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['AddBlock Props'];
1516           $t his -> aAd dProps       = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['AddProps '];   1518           $t his -> aAd dProps       = $this  -> oParent  -> aAreas Props[ $th is -> id ] ['AddProps '];
1517       }   1519       }
1518          1520       
1519       functi on getCach eString()  {   1521       functi on getCach eString()  {
1520              1522           
1521           $s CacheStrin g = "\n  / /{$this ->  sTitle}\n   {$this - > id} => a rray(\n";  //!pasd   1523           $s CacheStrin g = "\n  / /{$this ->  sTitle}\n   {$this - > id} => a rray(\n";  //!pasd
1522              1524           
1523           if ( $this ->  id == 1 )  {   1525           if ( $this ->  id == 1 )  {
1524                $this ->  aPages =  $this -> g etJoinPage s();   1526                $this ->  aPages =  $this -> g etJoinPage s();
1525                   1527                
1526                $sCacheS tring .= "     //page s\n";   1528                $sCacheS tring .= "     //page s\n";
1527                foreach(  $this ->  aPages as  $iPage ){   1529                foreach(  $this ->  aPages as  $iPage ){
1528                    $thi s -> aBloc ks = $this  -> getBlo cks( "`Joi nPage` = $ iPage" );   1530                    $thi s -> aBloc ks = $this  -> getBlo cks( "`Joi nPage` = $ iPage" );
1529                       1531                    
1530                    $sCa cheString  .= "    $i Page => ar ray(\n"; / /!pasd   1532                    $sCa cheString  .= "    $i Page => ar ray(\n"; / /!pasd
1531                         $sCacheStr ing .= $th is -> getB locksCache String( '   ' );   1533                         $sCacheStr ing .= $th is -> getB locksCache String( '   ' );
1532                    $sCa cheString  .= "    ), \n";   1534                    $sCa cheString  .= "    ), \n";
1533                }   1535                }
1534           }  else {   1536           }  else {
1535                if( $thi s -> id ==  100 or $t his -> id  == 101 )   1537                if( $thi s -> id ==  100 or $t his -> id  == 101 )
1536                    $thi s -> aBloc ks = array ( 0 => ''  );   1538                    $thi s -> aBloc ks = array ( 0 => ''  );
1537                else   1539                else
1538                    $thi s -> aBloc ks = $this  -> getBlo cks();   1540                    $thi s -> aBloc ks = $this  -> getBlo cks();
1539                   1541                
1540                $sCacheS tring .= $ this -> ge tBlocksCac heString() ;   1542                $sCacheS tring .= $ this -> ge tBlocksCac heString() ;
1541           }   1543           }
1542              1544           
1543           $s CacheStrin g .= "  ), \n";   1545           $s CacheStrin g .= "  ), \n";
1544              1546           
1545           re turn $sCac heString;   1547           re turn $sCac heString;
1546       }   1548       }
1547          1549       
1548       functi on getBloc ksCacheStr ing( $sPre fix = '' )  {   1550       functi on getBloc ksCacheStr ing( $sPre fix = '' )  {
1549           $s CacheStrin g = "$sPre fix    //b locks\n";   1551           $s CacheStrin g = "$sPre fix    //b locks\n";
1550              1552           
1551           fo reach ($th is -> aBlo cks as $iB lockID =>  $sBlockNam e) {   1553           fo reach ($th is -> aBlo cks as $iB lockID =>  $sBlockNam e) {
1552                $sBlockN ame = $thi s -> addSl ashes( $sB lockName ) ;   1554                $sBlockN ame = $thi s -> addSl ashes( $sB lockName ) ;
1553                $sCacheS tring .= " $sPrefix     $iBlockI D => array (\n"; //!p asd   1555                $sCacheS tring .= " $sPrefix     $iBlockI D => array (\n"; //!p asd
1554                $sCacheS tring .= " $sPrefix       //bloc k properti es\n";   1556                $sCacheS tring .= " $sPrefix       //bloc k properti es\n";
1555                   1557                
1556                // add a dditional  properties   1558                // add a dditional  properties
1557                if( is_a rray($this  -> aAddBl ockProps)  )   1559                if( is_a rray($this  -> aAddBl ockProps)  )
1558                    fore ach ($this  -> aAddBl ockProps a s $sProp = > $sValue)  {   1560                    fore ach ($this  -> aAddBl ockProps a s $sProp = > $sValue)  {
1559                         $sPropValu e = str_re place( '{N ame}', $sB lockName,  $sValue );   1561                         $sPropValu e = str_re place( '{N ame}', $sB lockName,  $sValue );
1560                         $sCacheStr ing .= "$s Prefix       '$sProp'  => '$sPro pValue',\n ";   1562                         $sCacheStr ing .= "$s Prefix       '$sProp'  => '$sPro pValue',\n ";
1561                    }   1563                    }
1562                   1564                
1563                //proces s items   1565                //proces s items
1564                $aItems  = $this ->  getItemsO fBlock($iB lockID);   1566                $aItems  = $this ->  getItemsO fBlock($iB lockID);
1565                   1567                
1566                $sCacheS tring .= " $sPrefix       'Items ' => array (\n";   1568                $sCacheS tring .= " $sPrefix       'Items ' => array (\n";
1567                foreach  ($aItems a s $iBlockI D => $aIte m) {   1569                foreach  ($aItems a s $iBlockI D => $aIte m) {
1568                    $sCa cheString  .= "$sPref ix         $iBlockID  => array(\ n"; //!pas d   1570                    $sCa cheString  .= "$sPref ix         $iBlockID  => array(\ n"; //!pas d
1569                    $sCa cheString  .= "$sPref ix           //item p roperties\ n";   1571                    $sCa cheString  .= "$sPref ix           //item p roperties\ n";
1570                       1572                    
1571                    // a dd additio nal proper ties   1573                    // a dd additio nal proper ties
1572                    if(  is_array($ this -> aA ddProps) )   1574                    if(  is_array($ this -> aA ddProps) )
1573                         foreach ($ this -> aA ddProps as  $sProp =>  $sValue)  {   1575                         foreach ($ this -> aA ddProps as  $sProp =>  $sValue)  {
1574                             $aItem [ $sProp ]  = str_rep lace( '{Na me}', $aIt em['Name'] , $sValue  );   1576                             $aItem [ $sProp ]  = str_rep lace( '{Na me}', $aIt em['Name'] , $sValue  );
1575                         }   1577                         }
1576                       1578                    
1577                    fore ach ($aIte m as $sPro p => $sVal ue) {   1579                    fore ach ($aIte m as $sPro p => $sVal ue) {
1578                         if( $sProp  == 'ID' )   1580                         if( $sProp  == 'ID' )
1579                             contin ue; //do n ot process  ID it is  already in  key   1581                             contin ue; //do n ot process  ID it is  already in  key
1580                           1582                        
1581                         $sCacheStr ing   .=   "$sPrefix            '$sProp'   =>   "   .   $this   ->   process ThisFuckin g Value
(   $sProp,   $sValue,   "$sPrefix            "   )   .   ",\n";
  1583                         $sCacheStr ing   .=   "$sPrefix            '$sProp'   =>   "   .   $this   ->   process
Value 4CacheStri ng (   $sProp,   $sValue,   "$sPrefix            "   )   .   ",\n";
1582                    }   1584                    }
1583                       1585                    
1584                    $sCa cheString  .= "$sPref ix         ),\n";   1586                    $sCa cheString  .= "$sPref ix         ),\n";
1585                }   1587                }
1586                   1588                
1587                $sCacheS tring .= " $sPrefix       ),\n";  //close i tems   1589                $sCacheS tring .= " $sPrefix       ),\n";  //close i tems
1588                $sCacheS tring .= " $sPrefix     ),\n"; / /close blo ck   1590                $sCacheS tring .= " $sPrefix     ),\n"; / /close blo ck
1589           }   1591           }
1590              1592           
1591           re turn $sCac heString;   1593           re turn $sCac heString;
1592       }   1594       }
1593          1595       
1594        function   process ThisFuckin g Value
(   $sProp,   $sValue,   $sPrefix   =   ''   )   {
  1596        function   process
Value 4CacheStri ng (   $sProp,   $sValue,   $sPrefix   =   ''   )   {
1595           if ( is_null(  $sValue )  )   1597           if ( is_null(  $sValue )  )
1596                return ' null'; //j ust a null   1598                return ' null'; //j ust a null
1597              1599           
1598           sw itch( $sPr op ) {   1600           sw itch( $sPr op ) {
1599                case 'Na me':   1601                case 'Na me':
1600                case 'Ty pe':   1602                case 'Ty pe':
1601                case 'Ca ption':   1603                case 'Ca ption':
1602                case 'De sc':   1604                case 'De sc':
1603                case 'Ma ndatoryMsg ':   1605                case 'Ma ndatoryMsg ':
1604                case 'Mi nMsg':   1606                case 'Mi nMsg':
1605                case 'Ma xMsg':   1607                case 'Ma xMsg':
1606                case 'Un iqueMsg':   1608                case 'Un iqueMsg':
1607                case 'Ch eckMsg':   1609                case 'Ch eckMsg':
1608                    retu rn "'$sVal ue'"; // s tring in s ingle quot es, simple  text (wit hout quote s)   1610                    retu rn "'$sVal ue'"; // s tring in s ingle quot es, simple  text (wit hout quote s)
1609                case 'Mi n':   1611                case 'Mi n':
1610                case 'Ma x':   1612                case 'Ma x':
1611                case 'Ma tchPercent ':   1613                case 'Ma tchPercent ':
1612                case 'Ma tchField':   1614                case 'Ma tchField':
1613                    retu rn "$sValu e"; //inte ger   1615                    retu rn "$sValu e"; //inte ger
1614                case 'Ma ndatory':   1616                case 'Ma ndatory':
1615                case 'Un ique':   1617                case 'Un ique':
1616                    retu rn ( $sVal ue == '1'  ? 'true' :  'false' ) ; //boolea n   1618                    retu rn ( $sVal ue == '1'  ? 'true' :  'false' ) ; //boolea n
1617                case 'Va lues':   1619                case 'Va lues':
1618                    if(  $sValue ==  '' )   1620                    if(  $sValue ==  '' )
1619                         return "'' ";   1621                         return "'' ";
1620                    else if( substr ( $sValue,  0, 2) ==  '#!' )   1622                    else if( substr ( $sValue,  0, 2) ==  '#!' )
1621                         return '"'  . $this - > addSlash esDblQuot(  $sValue )  . '"'; // string in  double quo tes   1623                         return '"'  . $this - > addSlash esDblQuot(  $sValue )  . '"'; // string in  double quo tes
1622                    else  {   1624                    else  {
1623                         // WOOW! L ets make i t array! > :-E   1625                         // WOOW! L ets make i t array! > :-E
1624                         $aValues =  explode(  "\n", $sVa lue );   1626                         $aValues =  explode(  "\n", $sVa lue );
1625                           1627                        
1626                         $sRet = "a rray(\n";   1628                         $sRet = "a rray(\n";
1627                           1629                        
1628                         foreach( $ aValues as  $iKey =>  $sValue1 )  {   1630                         foreach( $ aValues as  $iKey =>  $sValue1 )  {
1629                             $sValu e1 = $this  -> addSla shes( $sVa lue1 );   1631                             $sValu e1 = $this  -> addSla shes( $sVa lue1 );
1630                             $sRet  .= "$sPref ix  v$iKey  => '$sVal ue1',\n";   1632                             $sRet  .= "$sPref ix  v$iKey  => '$sVal ue1',\n";
1631                         }   1633                         }
1632                           1634                        
1633                         $sRet .= " $sPrefix)" ;   1635                         $sRet .= " $sPrefix)" ;
1634                           1636                        
1635                         return $sR et;   1637                         return $sR et;
1636                    }   1638                    }
1637                default:   1639                default:
1638                    retu rn '"' . $ this -> ad dSlashesDb lQuot( $sV alue ) . ' "'; //stri ng in doub le quotes   1640                    retu rn '"' . $ this -> ad dSlashesDb lQuot( $sV alue ) . ' "'; //stri ng in doub le quotes
1639           }   1641           }
1640       }   1642       }
1641          1643       
1642       functi on addSlas hes( $sTex t ) {   1644       functi on addSlas hes( $sTex t ) {
1643           $s Text = str _replace(  "\\", "\\\ \", $sText  );   1645           $s Text = str _replace(  "\\", "\\\ \", $sText  );
1644           $s Text = str _replace(  "'", "\\'" , $sText ) ;   1646           $s Text = str _replace(  "'", "\\'" , $sText ) ;
1645              1647           
1646           re turn $sTex t;   1648           re turn $sTex t;
1647       }   1649       }
1648          1650       
1649       functi on addSlas hesDblQuot ( $sText ) {   1651       functi on addSlas hesDblQuot ( $sText ) {
1650           $s Text = str _replace(  '\\',  '\\ \\', $sTex t );   1652           $s Text = str _replace(  '\\',  '\\ \\', $sTex t );
1651           $s Text = str _replace(  '"',   '\" ',   $sTex t );   1653           $s Text = str _replace(  '"',   '\" ',   $sTex t );
1652           $s Text = str _replace(  '$',   '\$ ',   $sTex t );   1654           $s Text = str _replace(  '$',   '\$ ',   $sTex t );
1653           $s Text = str _replace(  "\r",  '\r ',   $sTex t );   1655           $s Text = str _replace(  "\r",  '\r ',   $sTex t );
1654           $s Text = str _replace(  "\n",  '\n ',   $sTex t );   1656           $s Text = str _replace(  "\n",  '\n ',   $sTex t );
1655           $s Text = str _replace(  "\t",  '\t ',   $sTex t );   1657           $s Text = str _replace(  "\t",  '\t ',   $sTex t );
1656           $s Text = str _replace(  "\x0", '\x 0',  $sTex t );   1658           $s Text = str _replace(  "\x0", '\x 0',  $sTex t );
1657              1659           
1658           re turn $sTex t;   1660           re turn $sTex t;
1659       }   1661       }
1660     1662  
1661          1663       
1662       functi on getJoin Pages() {   1664       functi on getJoin Pages() {
1663           $a Pages = ar ray();   1665           $a Pages = ar ray();
1664              1666           
1665           $s Query = "   1667           $s Query = "
1666                SELECT   1668                SELECT
1667                    DIST INCT `Join Page`   1669                    DIST INCT `Join Page`
1668                FROM `Pr ofileField s`   1670                FROM `Pr ofileField s`
1669                WHERE   1671                WHERE
1670                    `Typ e` = 'bloc k' AND   1672                    `Typ e` = 'bloc k' AND
1671                    `Joi nOrder` IS  NOT NULL   1673                    `Joi nOrder` IS  NOT NULL
1672           ";   1674           ";
1673              1675           
1674           $r Pages = db _res( $sQu ery );   1676           $r Pages = db _res( $sQu ery );
1675              1677           
1676           wh ile( $aPag e = mysql_ fetch_asso c( $rPages  ) ) {   1678           wh ile( $aPag e = mysql_ fetch_asso c( $rPages  ) ) {
1677                $aPages[ ] = (int)$ aPage['Joi nPage'];   1679                $aPages[ ] = (int)$ aPage['Joi nPage'];
1678           }   1680           }
1679              1681           
1680           re turn $aPag es;   1682           re turn $aPag es;
1681       }   1683       }
1682          1684       
1683       //`Joi nPage` = $ iPage   1685       //`Joi nPage` = $ iPage
1684       functi on getBloc ks( $sAddS ort = '1'  ) {   1686       functi on getBloc ks( $sAddS ort = '1'  ) {
1685           $a Blocks = a rray();   1687           $a Blocks = a rray();
1686              1688           
1687           $s Query = "   1689           $s Query = "
1688                SELECT   1690                SELECT
1689                    `ID` ,   1691                    `ID` ,
1690                    `Nam e`   1692                    `Nam e`
1691                FROM `Pr ofileField s`   1693                FROM `Pr ofileField s`
1692                WHERE   1694                WHERE
1693                    `Typ e` = 'bloc k' AND   1695                    `Typ e` = 'bloc k' AND
1694                    `{$t his -> sOr derCol}` I S NOT NULL  AND   1696                    `{$t his -> sOr derCol}` I S NOT NULL  AND
1695                    $sAd dSort   1697                    $sAd dSort
1696                ORDER BY   1698                ORDER BY
1697                    `{$t his -> sOr derCol}`   1699                    `{$t his -> sOr derCol}`
1698           ";   1700           ";
1699              1701           
1700           $r Blocks = d b_res( $sQ uery );   1702           $r Blocks = d b_res( $sQ uery );
1701              1703           
1702           wh ile( $aBlo ck = mysql _fetch_ass oc( $rBloc ks ) ) {   1704           wh ile( $aBlo ck = mysql _fetch_ass oc( $rBloc ks ) ) {
1703                $aBlocks [ $aBlock[ 'ID'] ] =  $aBlock['N ame'];   1705                $aBlocks [ $aBlock[ 'ID'] ] =  $aBlock['N ame'];
1704           }   1706           }
1705              1707           
1706           re turn $aBlo cks;   1708           re turn $aBlo cks;
1707       }   1709       }
1708          1710       
1709       functi on getItem sOfBlock(  $iBlockID  ) {   1711       functi on getItem sOfBlock(  $iBlockID  ) {
1710           $a Items = ar ray();   1712           $a Items = ar ray();
1711              1713           
1712           $s AddSelect  = '`' . st r_replace(  ',', '`,  `', $this  -> sAddSel ect ) . '` ';   1714           $s AddSelect  = '`' . st r_replace(  ',', '`,  `', $this  -> sAddSel ect ) . '` ';
1713              1715           
1714           if ( $this ->  id == 100  )   1716           if ( $this ->  id == 100  )
1715                $sWhere  = '1';   1717                $sWhere  = '1';
1716           el seif( $thi s -> id ==  101 )   1718           el seif( $thi s -> id ==  101 )
1717                $sWhere  = "`MatchF ield` != ' '";   1719                $sWhere  = "`MatchF ield` != ' '";
1718           el se   1720           el se
1719                $sWhere  = "`{$this  -> sBlock Col}` = $i BlockID AN D `{$this  -> sOrderC ol}` IS NO T NULL";   1721                $sWhere  = "`{$this  -> sBlock Col}` = $i BlockID AN D `{$this  -> sOrderC ol}` IS NO T NULL";
1720              1722           
1721           $s OrderCol =  isset( $t his -> sOr derCol ) ?  $this ->  sOrderCol  : 'ID';   1723           $s OrderCol =  isset( $t his -> sOr derCol ) ?  $this ->  sOrderCol  : 'ID';
1722              1724           
1723           $s Query = "   1725           $s Query = "
1724                SELECT   1726                SELECT
1725                    `ID` ,   1727                    `ID` ,
1726                    `Nam e`,   1728                    `Nam e`,
1727                    `Typ e`,   1729                    `Typ e`,
1728                    $sAd dSelect   1730                    $sAd dSelect
1729                FROM   1731                FROM
1730                    `Pro fileFields `   1732                    `Pro fileFields `
1731                WHERE   1733                WHERE
1732                    `Typ e` != 'blo ck' AND   1734                    `Typ e` != 'blo ck' AND
1733                    $sWh ere   1735                    $sWh ere
1734                ORDER BY   1736                ORDER BY
1735                    `$sO rderCol`   1737                    `$sO rderCol`
1736           ";   1738           ";
1737              1739           
1738           $r Items = db _res( $sQu ery );   1740           $r Items = db _res( $sQu ery );
1739              1741           
1740           wh ile( $aIte m = mysql_ fetch_asso c($rItems)  ) {   1742           wh ile( $aIte m = mysql_ fetch_asso c($rItems)  ) {
1741                $aItems[  $aItem['I D'] ] = $a Item;   1743                $aItems[  $aItem['I D'] ] = $a Item;
1742           }   1744           }
1743              1745           
1744           re turn $aIte ms;   1746           re turn $aIte ms;
1745       }   1747       }
1746   }   1748   }