Completed
Push — master ( 40b7eb...708e0f )
by Christian
07:55
created
default/boinc/modules/boincstats/includes/pchart/class/pSpring.class.php 5 patches
Doc Comments   +9 added lines patch added patch discarded remove patch
@@ -258,6 +258,11 @@  discard block
 block discarded – undo
258 258
      $this->Data[$SourceID]["Connections"][] = $TargetID;
259 259
     }
260 260
    /* Get the median linked nodes position */
261
+
262
+   /**
263
+    * @param double $X
264
+    * @param double $Y
265
+    */
261 266
    function getMedianOffset($Key,$X,$Y)
262 267
     {
263 268
      $Cpt = 1;
@@ -277,6 +282,10 @@  discard block
 block discarded – undo
277 282
     }
278 283
 
279 284
    /* Return the ID of the attached partner with the biggest weight */
285
+
286
+   /**
287
+    * @return double
288
+    */
280 289
    function getBiggestPartner($Key)
281 290
     {
282 291
      if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
Please login to merge, or discard this patch.
Indentation   +665 added lines, -665 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
      pSpring - class to draw spring graphs
4 4
 
5 5
      Version     : 2.1.3
@@ -13,856 +13,856 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- define("NODE_TYPE_FREE"	, 690001);
17
- define("NODE_TYPE_CENTRAL"	, 690002);
18
-
19
- define("NODE_SHAPE_CIRCLE"	, 690011);
20
- define("NODE_SHAPE_TRIANGLE"	, 690012);
21
- define("NODE_SHAPE_SQUARE"	, 690013);
22
-
23
- define("ALGORITHM_RANDOM"	, 690021);
24
- define("ALGORITHM_WEIGHTED"	, 690022);
25
- define("ALGORITHM_CIRCULAR"	, 690023);
26
- define("ALGORITHM_CENTRAL"	, 690024);
27
-
28
- define("LABEL_CLASSIC"		, 690031);
29
- define("LABEL_LIGHT"		, 690032);
30
-
31
- /* pSpring class definition */
32
- class pSpring
33
-  {
34
-   var $History;
35
-   var $pChartObject;
36
-   var $Data;
37
-   var $Links;
38
-   var $X1;
39
-   var $Y1;
40
-   var $X2;
41
-   var $Y2;
42
-   var $AutoComputeFreeZone;
43
-   var $Labels;
44
-
45
-   /* Class creator */
46
-   function pSpring()
16
+    define("NODE_TYPE_FREE"	, 690001);
17
+    define("NODE_TYPE_CENTRAL"	, 690002);
18
+
19
+    define("NODE_SHAPE_CIRCLE"	, 690011);
20
+    define("NODE_SHAPE_TRIANGLE"	, 690012);
21
+    define("NODE_SHAPE_SQUARE"	, 690013);
22
+
23
+    define("ALGORITHM_RANDOM"	, 690021);
24
+    define("ALGORITHM_WEIGHTED"	, 690022);
25
+    define("ALGORITHM_CIRCULAR"	, 690023);
26
+    define("ALGORITHM_CENTRAL"	, 690024);
27
+
28
+    define("LABEL_CLASSIC"		, 690031);
29
+    define("LABEL_LIGHT"		, 690032);
30
+
31
+    /* pSpring class definition */
32
+    class pSpring
47 33
     {
48
-     /* Initialise data arrays */
49
-     $this->Data = "";
50
-     $this->Links = "";
51
-
52
-     /* Set nodes defaults */
53
-     $this->Default["R"]		= 255;
54
-     $this->Default["G"]		= 255;
55
-     $this->Default["B"]		= 255;
56
-     $this->Default["Alpha"]		= 100;
57
-     $this->Default["BorderR"]		= 0;
58
-     $this->Default["BorderG"]		= 0;
59
-     $this->Default["BorderB"]		= 0;
60
-     $this->Default["BorderAlpha"]	= 100;
61
-     $this->Default["Surrounding"]	= NULL;
62
-     $this->Default["BackgroundR"]	= 255;
63
-     $this->Default["BackgroundG"]	= 255;
64
-     $this->Default["BackgroundB"]	= 255;
65
-     $this->Default["BackgroundAlpha"]	= 0;
66
-     $this->Default["Force"]		= 1;
67
-     $this->Default["NodeType"]		= NODE_TYPE_FREE;
68
-     $this->Default["Size"]		= 5;
69
-     $this->Default["Shape"]		= NODE_SHAPE_CIRCLE;
70
-     $this->Default["FreeZone"]		= 40;
71
-     $this->Default["LinkR"]		= 0;
72
-     $this->Default["LinkG"]		= 0;
73
-     $this->Default["LinkB"]		= 0;
74
-     $this->Default["LinkAlpha"]	= 0;
75
-
76
-     $this->Labels["Type"]		= LABEL_CLASSIC;
77
-     $this->Labels["R"]			= 0;
78
-     $this->Labels["G"]			= 0;
79
-     $this->Labels["B"]			= 0;
80
-     $this->Labels["Alpha"]		= 100;
81
-
82
-     $this->AutoComputeFreeZone         = FALSE;
34
+    var $History;
35
+    var $pChartObject;
36
+    var $Data;
37
+    var $Links;
38
+    var $X1;
39
+    var $Y1;
40
+    var $X2;
41
+    var $Y2;
42
+    var $AutoComputeFreeZone;
43
+    var $Labels;
44
+
45
+    /* Class creator */
46
+    function pSpring()
47
+    {
48
+        /* Initialise data arrays */
49
+        $this->Data = "";
50
+        $this->Links = "";
51
+
52
+        /* Set nodes defaults */
53
+        $this->Default["R"]		= 255;
54
+        $this->Default["G"]		= 255;
55
+        $this->Default["B"]		= 255;
56
+        $this->Default["Alpha"]		= 100;
57
+        $this->Default["BorderR"]		= 0;
58
+        $this->Default["BorderG"]		= 0;
59
+        $this->Default["BorderB"]		= 0;
60
+        $this->Default["BorderAlpha"]	= 100;
61
+        $this->Default["Surrounding"]	= NULL;
62
+        $this->Default["BackgroundR"]	= 255;
63
+        $this->Default["BackgroundG"]	= 255;
64
+        $this->Default["BackgroundB"]	= 255;
65
+        $this->Default["BackgroundAlpha"]	= 0;
66
+        $this->Default["Force"]		= 1;
67
+        $this->Default["NodeType"]		= NODE_TYPE_FREE;
68
+        $this->Default["Size"]		= 5;
69
+        $this->Default["Shape"]		= NODE_SHAPE_CIRCLE;
70
+        $this->Default["FreeZone"]		= 40;
71
+        $this->Default["LinkR"]		= 0;
72
+        $this->Default["LinkG"]		= 0;
73
+        $this->Default["LinkB"]		= 0;
74
+        $this->Default["LinkAlpha"]	= 0;
75
+
76
+        $this->Labels["Type"]		= LABEL_CLASSIC;
77
+        $this->Labels["R"]			= 0;
78
+        $this->Labels["G"]			= 0;
79
+        $this->Labels["B"]			= 0;
80
+        $this->Labels["Alpha"]		= 100;
81
+
82
+        $this->AutoComputeFreeZone         = FALSE;
83 83
     }
84 84
 
85
-   /* Set default links options */
86
-   function setLinkDefaults($Settings="")
85
+    /* Set default links options */
86
+    function setLinkDefaults($Settings="")
87 87
     {
88
-     if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89
-     if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90
-     if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
91
-     if ( isset($Settings["Alpha"]) ) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
88
+        if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89
+        if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90
+        if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
91
+        if ( isset($Settings["Alpha"]) ) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
92 92
     }
93 93
 
94
-   /* Set default links options */
95
-   function setLabelsSettings($Settings="")
94
+    /* Set default links options */
95
+    function setLabelsSettings($Settings="")
96 96
     {
97
-     if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98
-     if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99
-     if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
100
-     if ( isset($Settings["B"]) )     { $this->Labels["B"] = $Settings["B"]; }
101
-     if ( isset($Settings["Alpha"]) ) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
97
+        if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98
+        if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99
+        if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
100
+        if ( isset($Settings["B"]) )     { $this->Labels["B"] = $Settings["B"]; }
101
+        if ( isset($Settings["Alpha"]) ) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
102 102
     }
103 103
 
104
-   /* Auto compute the FreeZone size based on the number of connections */
105
-   function autoFreeZone()
104
+    /* Auto compute the FreeZone size based on the number of connections */
105
+    function autoFreeZone()
106 106
     {
107
-     /* Check connections reciprocity */
108
-     foreach($this->Data as $Key => $Settings)
109
-      {
110
-       if ( isset($Settings["Connections"]) )
107
+        /* Check connections reciprocity */
108
+        foreach($this->Data as $Key => $Settings)
109
+        {
110
+        if ( isset($Settings["Connections"]) )
111 111
         { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; }
112
-       else
112
+        else
113 113
         { $this->Data[$Key]["FreeZone"] = 20; }
114
-      }
114
+        }
115 115
 
116 116
     }
117 117
 
118
-   /* Set link properties */
119
-   function linkProperties($FromNode,$ToNode,$Settings)
118
+    /* Set link properties */
119
+    function linkProperties($FromNode,$ToNode,$Settings)
120 120
     {
121
-     if ( !isset($this->Data[$FromNode]) ) { return(0); }
122
-     if ( !isset($this->Data[$ToNode]) )   { return(0); }
123
-
124
-     $R			= isset($Settings["R"]) ? $Settings["R"] : 0;
125
-     $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126
-     $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127
-     $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129
-     $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
130
-
131
-     $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132
-     $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
133
-     $this->Links[$FromNode][$ToNode]["B"] = $B;         $this->Links[$ToNode][$FromNode]["B"] = $B;
134
-     $this->Links[$FromNode][$ToNode]["Alpha"] = $Alpha; $this->Links[$ToNode][$FromNode]["Alpha"] = $Alpha;
135
-     $this->Links[$FromNode][$ToNode]["Name"] = $Name;   $this->Links[$ToNode][$FromNode]["Name"] = $Name;
136
-     $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
121
+        if ( !isset($this->Data[$FromNode]) ) { return(0); }
122
+        if ( !isset($this->Data[$ToNode]) )   { return(0); }
123
+
124
+        $R			= isset($Settings["R"]) ? $Settings["R"] : 0;
125
+        $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126
+        $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127
+        $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
+        $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129
+        $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
130
+
131
+        $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132
+        $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
133
+        $this->Links[$FromNode][$ToNode]["B"] = $B;         $this->Links[$ToNode][$FromNode]["B"] = $B;
134
+        $this->Links[$FromNode][$ToNode]["Alpha"] = $Alpha; $this->Links[$ToNode][$FromNode]["Alpha"] = $Alpha;
135
+        $this->Links[$FromNode][$ToNode]["Name"] = $Name;   $this->Links[$ToNode][$FromNode]["Name"] = $Name;
136
+        $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
137 137
     }
138 138
 
139
-   function setNodeDefaults($Settings="")
139
+    function setNodeDefaults($Settings="")
140 140
     {
141
-     if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142
-     if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143
-     if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
144
-     if ( isset($Settings["Alpha"]) ) { $this->Default["Alpha"]				= $Settings["Alpha"]; }
145
-     if ( isset($Settings["BorderR"]) ) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
-     if ( isset($Settings["BorderG"]) ) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
-     if ( isset($Settings["BorderB"]) ) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
-     if ( isset($Settings["BorderAlpha"]) ) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
-     if ( isset($Settings["Surrounding"]) ) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
-     if ( isset($Settings["BackgroundR"]) ) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
-     if ( isset($Settings["BackgroundG"]) ) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
-     if ( isset($Settings["BackgroundB"]) ) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
-     if ( isset($Settings["BackgroundAlpha"]) ) { $this->Default["BackgroundAlpha"]	= $Settings["BackgroundAlpha"]; }
154
-     if ( isset($Settings["NodeType"]) ) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
-     if ( isset($Settings["Size"]) ) { $this->Default["Size"]				= $Settings["Size"]; }
156
-     if ( isset($Settings["Shape"]) ) { $this->Default["Shape"]				= $Settings["Shape"]; }
157
-     if ( isset($Settings["FreeZone"]) ) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
141
+        if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142
+        if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143
+        if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
144
+        if ( isset($Settings["Alpha"]) ) { $this->Default["Alpha"]				= $Settings["Alpha"]; }
145
+        if ( isset($Settings["BorderR"]) ) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
+        if ( isset($Settings["BorderG"]) ) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
+        if ( isset($Settings["BorderB"]) ) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
+        if ( isset($Settings["BorderAlpha"]) ) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
+        if ( isset($Settings["Surrounding"]) ) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
+        if ( isset($Settings["BackgroundR"]) ) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
+        if ( isset($Settings["BackgroundG"]) ) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
+        if ( isset($Settings["BackgroundB"]) ) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
+        if ( isset($Settings["BackgroundAlpha"]) ) { $this->Default["BackgroundAlpha"]	= $Settings["BackgroundAlpha"]; }
154
+        if ( isset($Settings["NodeType"]) ) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
+        if ( isset($Settings["Size"]) ) { $this->Default["Size"]				= $Settings["Size"]; }
156
+        if ( isset($Settings["Shape"]) ) { $this->Default["Shape"]				= $Settings["Shape"]; }
157
+        if ( isset($Settings["FreeZone"]) ) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
158 158
     }
159 159
 
160
-   /* Add a node */
161
-   function addNode($NodeID,$Settings="")
160
+    /* Add a node */
161
+    function addNode($NodeID,$Settings="")
162 162
     {
163
-     /* if the node already exists, ignore */
164
-     if (isset($this->Data[$NodeID])) { return(0); }
165
-
166
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
-     $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
168
-
169
-     $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170
-     $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
171
-     $B			= isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"];
172
-     $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
173
-     $BorderR		= isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"];
174
-     $BorderG		= isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"];
175
-     $BorderB		= isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"];
176
-     $BorderAlpha	= isset($Settings["BorderAlpha"]) ? $Settings["BorderAlpha"] : $this->Default["BorderAlpha"];
177
-     $Surrounding	= isset($Settings["Surrounding"]) ? $Settings["Surrounding"] : $this->Default["Surrounding"];
178
-     $BackgroundR	= isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"];
179
-     $BackgroundG	= isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"];
180
-     $BackgroundB	= isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"];
181
-     $BackgroundAlpha	= isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
-     $Force		= isset($Settings["Force"]) ? $Settings["Force"] :  $this->Default["Force"];
183
-     $NodeType		= isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"];
184
-     $Size		= isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
185
-     $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186
-     $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187
-
188
-     if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189
-
190
-     $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191
-     $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
192
-     $this->Data[$NodeID]["BackgroundR"]	= $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
193
-     $this->Data[$NodeID]["Name"]		= $Name;
194
-     $this->Data[$NodeID]["Force"]		= $Force;
195
-     $this->Data[$NodeID]["Type"]		= $NodeType;
196
-     $this->Data[$NodeID]["Size"]		= $Size;
197
-     $this->Data[$NodeID]["Shape"]		= $Shape;
198
-     $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
-     if ( $Connections != NULL )
200
-      {
201
-       if ( is_array($Connections ) )
202
-        {
203
-         foreach($Connections as $Key => $Value)
204
-          $this->Data[$NodeID]["Connections"][] = $Value;
205
-        }
206
-       else
163
+        /* if the node already exists, ignore */
164
+        if (isset($this->Data[$NodeID])) { return(0); }
165
+
166
+        $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
+        $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
168
+
169
+        $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170
+        $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
171
+        $B			= isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"];
172
+        $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
173
+        $BorderR		= isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"];
174
+        $BorderG		= isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"];
175
+        $BorderB		= isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"];
176
+        $BorderAlpha	= isset($Settings["BorderAlpha"]) ? $Settings["BorderAlpha"] : $this->Default["BorderAlpha"];
177
+        $Surrounding	= isset($Settings["Surrounding"]) ? $Settings["Surrounding"] : $this->Default["Surrounding"];
178
+        $BackgroundR	= isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"];
179
+        $BackgroundG	= isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"];
180
+        $BackgroundB	= isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"];
181
+        $BackgroundAlpha	= isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
+        $Force		= isset($Settings["Force"]) ? $Settings["Force"] :  $this->Default["Force"];
183
+        $NodeType		= isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"];
184
+        $Size		= isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
185
+        $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186
+        $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187
+
188
+        if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189
+
190
+        $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191
+        $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
192
+        $this->Data[$NodeID]["BackgroundR"]	= $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
193
+        $this->Data[$NodeID]["Name"]		= $Name;
194
+        $this->Data[$NodeID]["Force"]		= $Force;
195
+        $this->Data[$NodeID]["Type"]		= $NodeType;
196
+        $this->Data[$NodeID]["Size"]		= $Size;
197
+        $this->Data[$NodeID]["Shape"]		= $Shape;
198
+        $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
+        if ( $Connections != NULL )
200
+        {
201
+        if ( is_array($Connections ) )
202
+        {
203
+            foreach($Connections as $Key => $Value)
204
+            $this->Data[$NodeID]["Connections"][] = $Value;
205
+        }
206
+        else
207 207
         $this->Data[$NodeID]["Connections"][] = $Connections;
208
-      }
208
+        }
209 209
     }
210 210
 
211
-   /* Set color attribute for a list of nodes */
212
-   function setNodesColor($Nodes,$Settings="")
211
+    /* Set color attribute for a list of nodes */
212
+    function setNodesColor($Nodes,$Settings="")
213 213
     {
214
-     if ( is_array($Nodes) )
215
-      {
216
-       foreach ($Nodes as $Key => $NodeID)
217
-        {
218
-         if (isset($this->Data[$NodeID]) )
219
-          {
220
-           if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
-           if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
-           if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
-           if ( isset($Settings["Alpha"]) ) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
-           if ( isset($Settings["BorderR"]) ) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
-           if ( isset($Settings["BorderG"]) ) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
-           if ( isset($Settings["BorderB"]) ) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
-           if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
-           if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229
-          }
230
-        }
231
-      }
232
-     else
233
-      {
234
-       if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
-       if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
-       if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
-       if ( isset($Settings["Alpha"]) ) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
-       if ( isset($Settings["BorderR"]) ) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
-       if ( isset($Settings["BorderG"]) ) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
-       if ( isset($Settings["BorderB"]) ) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
-       if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
-       if ( isset($Settings["Surrounding"]) ) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
243
-      }
214
+        if ( is_array($Nodes) )
215
+        {
216
+        foreach ($Nodes as $Key => $NodeID)
217
+        {
218
+            if (isset($this->Data[$NodeID]) )
219
+            {
220
+            if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
+            if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
+            if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
+            if ( isset($Settings["Alpha"]) ) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
+            if ( isset($Settings["BorderR"]) ) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
+            if ( isset($Settings["BorderG"]) ) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
+            if ( isset($Settings["BorderB"]) ) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
+            if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
+            if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229
+            }
230
+        }
231
+        }
232
+        else
233
+        {
234
+        if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
+        if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
+        if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
+        if ( isset($Settings["Alpha"]) ) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
+        if ( isset($Settings["BorderR"]) ) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
+        if ( isset($Settings["BorderG"]) ) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
+        if ( isset($Settings["BorderB"]) ) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
+        if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
+        if ( isset($Settings["Surrounding"]) ) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
243
+        }
244 244
     }
245 245
 
246
-   /* Returns all the nodes details */
247
-   function dumpNodes()
246
+    /* Returns all the nodes details */
247
+    function dumpNodes()
248 248
     { return($this->Data); }
249 249
 
250
-   /* Check if a connection exists and create it if required */
251
-   function checkConnection($SourceID, $TargetID)
250
+    /* Check if a connection exists and create it if required */
251
+    function checkConnection($SourceID, $TargetID)
252 252
     {
253
-     if ( isset($this->Data[$SourceID]["Connections"]) )
254
-      {
255
-       foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
253
+        if ( isset($this->Data[$SourceID]["Connections"]) )
254
+        {
255
+        foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
256 256
         { if ( $TargetID == $ConnectionID ) { return(TRUE); } }
257
-      }
258
-     $this->Data[$SourceID]["Connections"][] = $TargetID;
257
+        }
258
+        $this->Data[$SourceID]["Connections"][] = $TargetID;
259 259
     }
260
-   /* Get the median linked nodes position */
261
-   function getMedianOffset($Key,$X,$Y)
260
+    /* Get the median linked nodes position */
261
+    function getMedianOffset($Key,$X,$Y)
262 262
     {
263
-     $Cpt = 1;
264
-     if ( isset($this->Data[$Key]["Connections"]) )
265
-      {
266
-       foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
267
-        {
268
-         if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
269
-          {
270
-           $X = $X + $this->Data[$NodeID]["X"];
271
-           $Y = $Y + $this->Data[$NodeID]["Y"];
272
-           $Cpt++;
273
-          }
274
-        }
275
-      }
276
-     return(array("X"=>$X/$Cpt,"Y"=>$Y/$Cpt));
263
+        $Cpt = 1;
264
+        if ( isset($this->Data[$Key]["Connections"]) )
265
+        {
266
+        foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
267
+        {
268
+            if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
269
+            {
270
+            $X = $X + $this->Data[$NodeID]["X"];
271
+            $Y = $Y + $this->Data[$NodeID]["Y"];
272
+            $Cpt++;
273
+            }
274
+        }
275
+        }
276
+        return(array("X"=>$X/$Cpt,"Y"=>$Y/$Cpt));
277 277
     }
278 278
 
279
-   /* Return the ID of the attached partner with the biggest weight */
280
-   function getBiggestPartner($Key)
279
+    /* Return the ID of the attached partner with the biggest weight */
280
+    function getBiggestPartner($Key)
281 281
     {
282
-     if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
282
+        if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
283 283
 
284
-     $MaxWeight = 0; $Result = "";
285
-     foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
286
-      {
287
-       if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
284
+        $MaxWeight = 0; $Result = "";
285
+        foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
286
+        {
287
+        if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
288 288
         { $MaxWeight = $this->Data[$PeerID]["Weight"]; $Result = $PeerID; }
289
-      }
290
-     return($Result);
289
+        }
290
+        return($Result);
291 291
     }
292 292
 
293
-   /* Do the initial node positions computing pass */
294
-   function firstPass($Algorithm)
293
+    /* Do the initial node positions computing pass */
294
+    function firstPass($Algorithm)
295 295
     {
296
-     $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297
-     $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
296
+        $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297
+        $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
298 298
 
299
-     /* Check connections reciprocity */
300
-     foreach($this->Data as $Key => $Settings)
301
-      {
302
-       if ( isset($Settings["Connections"]) )
299
+        /* Check connections reciprocity */
300
+        foreach($this->Data as $Key => $Settings)
301
+        {
302
+        if ( isset($Settings["Connections"]) )
303 303
         {
304
-         foreach($Settings["Connections"] as $ID => $ConnectionID)
305
-          $this->checkConnection($ConnectionID,$Key);
304
+            foreach($Settings["Connections"] as $ID => $ConnectionID)
305
+            $this->checkConnection($ConnectionID,$Key);
306
+        }
306 307
         }
307
-      }
308 308
 
309
-     if ( $this->AutoComputeFreeZone ) { $this->autoFreeZone(); }
309
+        if ( $this->AutoComputeFreeZone ) { $this->autoFreeZone(); }
310 310
 
311
-     /* Get the max number of connections */
312
-     $MaxConnections = 0;
313
-     foreach($this->Data as $Key => $Settings)
314
-      { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
311
+        /* Get the max number of connections */
312
+        $MaxConnections = 0;
313
+        foreach($this->Data as $Key => $Settings)
314
+        { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
315 315
 
316
-     if ( $Algorithm == ALGORITHM_WEIGHTED )
317
-      {
318
-       foreach($this->Data as $Key => $Settings)
316
+        if ( $Algorithm == ALGORITHM_WEIGHTED )
317
+        {
318
+        foreach($this->Data as $Key => $Settings)
319 319
         {
320
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
322
-          {
323
-           if ( isset($Settings["Connections"]) )
320
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
322
+            {
323
+            if ( isset($Settings["Connections"]) )
324 324
             { $Connections = count($Settings["Connections"]); }
325
-           else
325
+            else
326 326
             { $Connections = 0; }
327 327
 
328
-           $Ring  = $MaxConnections - $Connections;
329
-           $Angle = rand(0,360);
328
+            $Ring  = $MaxConnections - $Connections;
329
+            $Angle = rand(0,360);
330 330
            
331
-           $this->Data[$Key]["X"] = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
332
-           $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
333
-          }
331
+            $this->Data[$Key]["X"] = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
332
+            $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
333
+            }
334 334
         }
335
-      }
336
-     elseif ( $Algorithm == ALGORITHM_CENTRAL )
337
-      {
338
-       /* Put a weight on each nodes */
339
-       foreach($this->Data as $Key => $Settings)
335
+        }
336
+        elseif ( $Algorithm == ALGORITHM_CENTRAL )
337
+        {
338
+        /* Put a weight on each nodes */
339
+        foreach($this->Data as $Key => $Settings)
340 340
         {
341
-         if ( isset($Settings["Connections"]) )
342
-          $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343
-         else
344
-          $this->Data[$Key]["Weight"] = 0;
341
+            if ( isset($Settings["Connections"]) )
342
+            $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343
+            else
344
+            $this->Data[$Key]["Weight"] = 0;
345 345
         }
346 346
 
347
-       $MaxConnections = $MaxConnections + 1;
348
-       for($i=$MaxConnections;$i>=0;$i--)
347
+        $MaxConnections = $MaxConnections + 1;
348
+        for($i=$MaxConnections;$i>=0;$i--)
349 349
         {
350
-         foreach($this->Data as $Key => $Settings)
351
-          {
352
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
350
+            foreach($this->Data as $Key => $Settings)
354 351
             {
355
-             if ( isset($Settings["Connections"]) )
356
-              { $Connections = count($Settings["Connections"]); }
357
-             else
358
-              { $Connections = 0; }
359
-
360
-             if ( $Connections == $i )
361
-              {
362
-               $BiggestPartner = $this->getBiggestPartner($Key);
363
-               if ( $BiggestPartner != "" )
352
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
354
+            {
355
+                if ( isset($Settings["Connections"]) )
356
+                { $Connections = count($Settings["Connections"]); }
357
+                else
358
+                { $Connections = 0; }
359
+
360
+                if ( $Connections == $i )
364 361
                 {
365
-                 $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366
-                 $Weight        = $this->Data[$BiggestPartner]["Weight"];
367
-                 $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368
-                 $Done          = FALSE; $Tries = 0;
369
-                 while (!$Done && $Tries <= $Weight*2)
370
-                  {
371
-                   $Tries++;
372
-                   $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
-                   if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
362
+                $BiggestPartner = $this->getBiggestPartner($Key);
363
+                if ( $BiggestPartner != "" )
364
+                {
365
+                    $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366
+                    $Weight        = $this->Data[$BiggestPartner]["Weight"];
367
+                    $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368
+                    $Done          = FALSE; $Tries = 0;
369
+                    while (!$Done && $Tries <= $Weight*2)
370
+                    {
371
+                    $Tries++;
372
+                    $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
+                    if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
374 374
                     {
375
-                     $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376
-                     $Done = TRUE; 
375
+                        $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376
+                        $Done = TRUE; 
377 377
                     }
378
-                  }
379
-                 if ( !$Done )
380
-                  { $Angle = rand(0,360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
378
+                    }
379
+                    if ( !$Done )
380
+                    { $Angle = rand(0,360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
381 381
 
382
-                 $X = cos(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["X"];
383
-                 $Y = sin(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["Y"];
382
+                    $X = cos(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["X"];
383
+                    $Y = sin(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["Y"];
384 384
 
385
-                 $this->Data[$Key]["X"] = $X;
386
-                 $this->Data[$Key]["Y"] = $Y;
385
+                    $this->Data[$Key]["X"] = $X;
386
+                    $this->Data[$Key]["Y"] = $Y;
387
+                }
387 388
                 }
388
-              }
389 389
             }
390
-          }
391
-        }
392
-      }
393
-     elseif ( $Algorithm == ALGORITHM_CIRCULAR )
394
-      {
395
-       $MaxConnections = $MaxConnections + 1;
396
-       for($i=$MaxConnections;$i>=0;$i--)
397
-        {
398
-         foreach($this->Data as $Key => $Settings)
399
-          {
400
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
390
+            }
391
+        }
392
+        }
393
+        elseif ( $Algorithm == ALGORITHM_CIRCULAR )
394
+        {
395
+        $MaxConnections = $MaxConnections + 1;
396
+        for($i=$MaxConnections;$i>=0;$i--)
397
+        {
398
+            foreach($this->Data as $Key => $Settings)
399
+            {
400
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
402 402
             {
403
-             if ( isset($Settings["Connections"]) )
404
-              { $Connections = count($Settings["Connections"]); }
405
-             else
406
-              { $Connections = 0; }
403
+                if ( isset($Settings["Connections"]) )
404
+                { $Connections = count($Settings["Connections"]); }
405
+                else
406
+                { $Connections = 0; }
407 407
 
408
-             if ( $Connections == $i )
409
-              {
410
-               $Ring  = $MaxConnections - $Connections;
411
-               $Angle = rand(0,360);
408
+                if ( $Connections == $i )
409
+                {
410
+                $Ring  = $MaxConnections - $Connections;
411
+                $Angle = rand(0,360);
412 412
 
413
-               $X = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
414
-               $Y = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
413
+                $X = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
414
+                $Y = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
415 415
 
416
-               $MedianOffset = $this->getMedianOffset($Key,$X,$Y);
416
+                $MedianOffset = $this->getMedianOffset($Key,$X,$Y);
417 417
 
418
-               $this->Data[$Key]["X"] = $MedianOffset["X"];
419
-               $this->Data[$Key]["Y"] = $MedianOffset["Y"];
420
-              }
418
+                $this->Data[$Key]["X"] = $MedianOffset["X"];
419
+                $this->Data[$Key]["Y"] = $MedianOffset["Y"];
420
+                }
421 421
             }
422
-          }
422
+            }
423
+        }
423 424
         }
424
-      }
425
-     elseif ( $Algorithm == ALGORITHM_RANDOM )
426
-      {
427
-       foreach($this->Data as $Key => $Settings)
425
+        elseif ( $Algorithm == ALGORITHM_RANDOM )
428 426
         {
429
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
430
-          {
431
-           $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432
-           $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
433
-          }
434
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
427
+        foreach($this->Data as $Key => $Settings)
428
+        {
429
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
430
+            {
431
+            $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432
+            $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
433
+            }
434
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
435
+        }
435 436
         }
436
-      }
437 437
     }
438 438
 
439
-   /* Compute one pass */
440
-   function doPass()
439
+    /* Compute one pass */
440
+    function doPass()
441 441
     {
442
-     /* Compute vectors */
443
-     foreach($this->Data as $Key => $Settings)
444
-      {
445
-       if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
442
+        /* Compute vectors */
443
+        foreach($this->Data as $Key => $Settings)
446 444
         {
447
-         unset($this->Data[$Key]["Vectors"]);
445
+        if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
446
+        {
447
+            unset($this->Data[$Key]["Vectors"]);
448 448
 
449
-         $X1 = $Settings["X"];
450
-         $Y1 = $Settings["Y"];
449
+            $X1 = $Settings["X"];
450
+            $Y1 = $Settings["Y"];
451 451
 
452
-         /* Repulsion vectors */
453
-         foreach($this->Data as $Key2 => $Settings2)
454
-          {
455
-           if ( $Key != $Key2 )
452
+            /* Repulsion vectors */
453
+            foreach($this->Data as $Key2 => $Settings2)
454
+            {
455
+            if ( $Key != $Key2 )
456 456
             {
457
-             $X2 = $this->Data[$Key2]["X"];
458
-             $Y2 = $this->Data[$Key2]["Y"];
459
-             $FreeZone = $this->Data[$Key2]["FreeZone"];
460
-
461
-             $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
462
-             $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
463
-
464
-             /* Nodes too close, repulsion occurs */
465
-             if ( $Distance < $FreeZone )
466
-              {
467
-               $Force = log(pow(2,$FreeZone-$Distance));
468
-               if ( $Force > 1 )
457
+                $X2 = $this->Data[$Key2]["X"];
458
+                $Y2 = $this->Data[$Key2]["Y"];
459
+                $FreeZone = $this->Data[$Key2]["FreeZone"];
460
+
461
+                $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
462
+                $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
463
+
464
+                /* Nodes too close, repulsion occurs */
465
+                if ( $Distance < $FreeZone )
466
+                {
467
+                $Force = log(pow(2,$FreeZone-$Distance));
468
+                if ( $Force > 1 )
469 469
                 { $this->Data[$Key]["Vectors"][] = array("Type"=>"R","Angle"=>$Angle % 360,"Force"=>$Force); }
470
-              }
470
+                }
471
+            }
471 472
             }
472
-          }
473 473
 
474
-         /* Attraction vectors */
475
-         if ( isset($Settings["Connections"]) )
476
-          {
477
-           foreach($Settings["Connections"] as $ID => $NodeID)
474
+            /* Attraction vectors */
475
+            if ( isset($Settings["Connections"]) )
478 476
             {
479
-             if ( isset($this->Data[$NodeID]) )
480
-              {
481
-               $X2 = $this->Data[$NodeID]["X"];
482
-               $Y2 = $this->Data[$NodeID]["Y"];
483
-               $FreeZone = $this->Data[$Key2]["FreeZone"];
477
+            foreach($Settings["Connections"] as $ID => $NodeID)
478
+            {
479
+                if ( isset($this->Data[$NodeID]) )
480
+                {
481
+                $X2 = $this->Data[$NodeID]["X"];
482
+                $Y2 = $this->Data[$NodeID]["Y"];
483
+                $FreeZone = $this->Data[$Key2]["FreeZone"];
484 484
 
485
-               $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
486
-               $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2);
485
+                $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
486
+                $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2);
487 487
 
488
-               if ( $Distance > $FreeZone )
488
+                if ( $Distance > $FreeZone )
489 489
                 $Force = log(($Distance-$FreeZone)+1);
490
-               else
490
+                else
491 491
                 { $Force = log(($FreeZone-$Distance)+1); ($Angle = $Angle + 180); }
492 492
 
493
-               if ( $Force > 1 )
493
+                if ( $Force > 1 )
494 494
                 $this->Data[$Key]["Vectors"][] = array("Type"=>"A","Angle"=>$Angle % 360,"Force"=>$Force);
495
-              }
495
+                }
496
+            }
496 497
             }
497
-          }
498 498
         }
499
-      }
499
+        }
500 500
 
501
-     /* Move the nodes accoding to the vectors */
502
-     foreach($this->Data as $Key => $Settings)
503
-      {
504
-       $X = $Settings["X"];
505
-       $Y = $Settings["Y"];
501
+        /* Move the nodes accoding to the vectors */
502
+        foreach($this->Data as $Key => $Settings)
503
+        {
504
+        $X = $Settings["X"];
505
+        $Y = $Settings["Y"];
506 506
 
507
-       if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
507
+        if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
508 508
         {
509
-         foreach($Settings["Vectors"] as $ID => $Vector)
510
-          {
511
-           $Type  = $Vector["Type"];
512
-           $Force = $Vector["Force"];
513
-           $Angle = $Vector["Angle"];
514
-           $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
509
+            foreach($Settings["Vectors"] as $ID => $Vector)
510
+            {
511
+            $Type  = $Vector["Type"];
512
+            $Force = $Vector["Force"];
513
+            $Angle = $Vector["Angle"];
514
+            $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
515 515
 
516
-           $X = cos(deg2rad($Angle)) * $Force * $Factor + $X;
517
-           $Y = sin(deg2rad($Angle)) * $Force * $Factor + $Y;
518
-          }
516
+            $X = cos(deg2rad($Angle)) * $Force * $Factor + $X;
517
+            $Y = sin(deg2rad($Angle)) * $Force * $Factor + $Y;
518
+            }
519 519
         }
520 520
 
521
-       $this->Data[$Key]["X"] = $X;
522
-       $this->Data[$Key]["Y"] = $Y;
523
-      }
521
+        $this->Data[$Key]["X"] = $X;
522
+        $this->Data[$Key]["Y"] = $Y;
523
+        }
524 524
     }
525 525
 
526
-   function lastPass()
526
+    function lastPass()
527 527
     {
528
-     /* Put everything inside the graph area */
529
-     foreach($this->Data as $Key => $Settings)
530
-      {
531
-       $X = $Settings["X"];
532
-       $Y = $Settings["Y"];
533
-
534
-       if ( $X < $this->X1 ) { $X = $this->X1; }
535
-       if ( $X > $this->X2 ) { $X = $this->X2; }
536
-       if ( $Y < $this->Y1 ) { $Y = $this->Y1; }
537
-       if ( $Y > $this->Y2 ) { $Y = $this->Y2; }
538
-
539
-       $this->Data[$Key]["X"] = $X;
540
-       $this->Data[$Key]["Y"] = $Y;
541
-      }
542
-
543
-     /* Dump all links */
544
-     $Links = "";
545
-     foreach($this->Data as $Key => $Settings)
546
-      {
547
-       $X1 = $Settings["X"];
548
-       $Y1 = $Settings["Y"];
549
-
550
-       if ( isset($Settings["Connections"]) )
551
-        {
552
-         foreach ($Settings["Connections"] as $ID => $NodeID)
553
-          {
554
-           if ( isset($this->Data[$NodeID]) )
528
+        /* Put everything inside the graph area */
529
+        foreach($this->Data as $Key => $Settings)
530
+        {
531
+        $X = $Settings["X"];
532
+        $Y = $Settings["Y"];
533
+
534
+        if ( $X < $this->X1 ) { $X = $this->X1; }
535
+        if ( $X > $this->X2 ) { $X = $this->X2; }
536
+        if ( $Y < $this->Y1 ) { $Y = $this->Y1; }
537
+        if ( $Y > $this->Y2 ) { $Y = $this->Y2; }
538
+
539
+        $this->Data[$Key]["X"] = $X;
540
+        $this->Data[$Key]["Y"] = $Y;
541
+        }
542
+
543
+        /* Dump all links */
544
+        $Links = "";
545
+        foreach($this->Data as $Key => $Settings)
546
+        {
547
+        $X1 = $Settings["X"];
548
+        $Y1 = $Settings["Y"];
549
+
550
+        if ( isset($Settings["Connections"]) )
551
+        {
552
+            foreach ($Settings["Connections"] as $ID => $NodeID)
553
+            {
554
+            if ( isset($this->Data[$NodeID]) )
555 555
             {
556
-             $X2 = $this->Data[$NodeID]["X"];
557
-             $Y2 = $this->Data[$NodeID]["Y"];
556
+                $X2 = $this->Data[$NodeID]["X"];
557
+                $Y2 = $this->Data[$NodeID]["Y"];
558 558
 
559
-             $Links[] = array("X1"=>$X1,"Y1"=>$Y1,"X2"=>$X2,"Y2"=>$Y2,"Source"=>$Settings["Name"],"Destination"=>$this->Data[$NodeID]["Name"]);
559
+                $Links[] = array("X1"=>$X1,"Y1"=>$Y1,"X2"=>$X2,"Y2"=>$Y2,"Source"=>$Settings["Name"],"Destination"=>$this->Data[$NodeID]["Name"]);
560 560
             }
561
-          }
561
+            }
562
+        }
562 563
         }
563
-      }
564 564
 
565
-     /* Check collisions */
566
-     $Conflicts = 0;
567
-     foreach($this->Data as $Key => $Settings)
568
-      {
569
-       $X1 = $Settings["X"];
570
-       $Y1 = $Settings["Y"];
565
+        /* Check collisions */
566
+        $Conflicts = 0;
567
+        foreach($this->Data as $Key => $Settings)
568
+        {
569
+        $X1 = $Settings["X"];
570
+        $Y1 = $Settings["Y"];
571 571
 
572
-       if ( isset($Settings["Connections"]) )
572
+        if ( isset($Settings["Connections"]) )
573 573
         {
574
-         foreach ($Settings["Connections"] as $ID => $NodeID)
575
-          {
576
-           if ( isset($this->Data[$NodeID]) )
574
+            foreach ($Settings["Connections"] as $ID => $NodeID)
575
+            {
576
+            if ( isset($this->Data[$NodeID]) )
577 577
             {
578
-             $X2 = $this->Data[$NodeID]["X"];
579
-             $Y2 = $this->Data[$NodeID]["Y"];
578
+                $X2 = $this->Data[$NodeID]["X"];
579
+                $Y2 = $this->Data[$NodeID]["Y"];
580 580
 
581
-             foreach($Links as $IDLinks => $Link)
582
-              {
583
-               $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
581
+                foreach($Links as $IDLinks => $Link)
582
+                {
583
+                $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
584 584
 
585
-               if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
585
+                if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
586 586
                 {
587
-                 if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
588
-                  {
589
-                   if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
587
+                    if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
588
+                    {
589
+                    if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
590 590
                     { $Conflicts++; }
591
-                  }
591
+                    }
592
+                }
592 593
                 }
593
-              }
594 594
             }
595
-          }
595
+            }
596
+        }
596 597
         }
597
-      }
598
-     return($Conflicts/2);
598
+        return($Conflicts/2);
599 599
     }
600 600
 
601
-   /* Center the graph */
602
-   function center()
601
+    /* Center the graph */
602
+    function center()
603 603
     {
604
-     /* Determine the real center */
605
-     $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606
-     $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
607
-
608
-     /* Get current boundaries */
609
-     $XMin = $this->X2; $XMax = $this->X1;
610
-     $YMin = $this->Y2; $YMax = $this->Y1;
611
-     foreach($this->Data as $Key => $Settings)
612
-      {
613
-       $X = $Settings["X"];
614
-       $Y = $Settings["Y"];
615
-
616
-       if ( $X < $XMin) { $XMin = $X; }
617
-       if ( $X > $XMax) { $XMax = $X; }
618
-       if ( $Y < $YMin) { $YMin = $Y; }
619
-       if ( $Y > $YMax) { $YMax = $Y; }
620
-      }
621
-     $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
622
-     $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;
623
-
624
-     /* Compute the offset to apply */
625
-     $XOffset = $TargetCenterX - $CurrentCenterX;
626
-     $YOffset = $TargetCenterY - $CurrentCenterY;
627
-
628
-     /* Correct the points position */
629
-     foreach($this->Data as $Key => $Settings)
630
-      {
631
-       $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632
-       $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
633
-      }
634
-    }
604
+        /* Determine the real center */
605
+        $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606
+        $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
607
+
608
+        /* Get current boundaries */
609
+        $XMin = $this->X2; $XMax = $this->X1;
610
+        $YMin = $this->Y2; $YMax = $this->Y1;
611
+        foreach($this->Data as $Key => $Settings)
612
+        {
613
+        $X = $Settings["X"];
614
+        $Y = $Settings["Y"];
635 615
 
636
-   /* Create the encoded string */
637
-   function drawSpring($Object,$Settings="")
638
-    {
639
-     $this->pChartObject = $Object;
616
+        if ( $X < $XMin) { $XMin = $X; }
617
+        if ( $X > $XMax) { $XMax = $X; }
618
+        if ( $Y < $YMin) { $YMin = $Y; }
619
+        if ( $Y > $YMax) { $YMax = $Y; }
620
+        }
621
+        $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
622
+        $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;
640 623
 
641
-     $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
-     $Retries			= isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
643
-     $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644
-     $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645
-     $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646
-     $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
-     $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648
-     $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
649
-     $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650
-     $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
624
+        /* Compute the offset to apply */
625
+        $XOffset = $TargetCenterX - $CurrentCenterX;
626
+        $YOffset = $TargetCenterY - $CurrentCenterY;
651 627
 
652
-     $FontSize		= $Object->FontSize;
653
-     $this->X1		= $Object->GraphAreaX1;
654
-     $this->Y1		= $Object->GraphAreaY1;
655
-     $this->X2		= $Object->GraphAreaX2;
656
-     $this->Y2		= $Object->GraphAreaY2;
628
+        /* Correct the points position */
629
+        foreach($this->Data as $Key => $Settings)
630
+        {
631
+        $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632
+        $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
633
+        }
634
+    }
657 635
 
658
-     $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
-     while ($Conflicts != 0 && $Jobs < $Retries )
660
-      {
661
-       $Jobs++;
636
+    /* Create the encoded string */
637
+    function drawSpring($Object,$Settings="")
638
+    {
639
+        $this->pChartObject = $Object;
640
+
641
+        $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
+        $Retries			= isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
643
+        $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644
+        $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645
+        $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646
+        $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
+        $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648
+        $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
649
+        $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650
+        $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
651
+
652
+        $FontSize		= $Object->FontSize;
653
+        $this->X1		= $Object->GraphAreaX1;
654
+        $this->Y1		= $Object->GraphAreaY1;
655
+        $this->X2		= $Object->GraphAreaX2;
656
+        $this->Y2		= $Object->GraphAreaY2;
657
+
658
+        $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
+        while ($Conflicts != 0 && $Jobs < $Retries )
660
+        {
661
+        $Jobs++;
662 662
 
663
-       /* Compute the initial settings */
664
-       $this->firstPass($Algorithm);
663
+        /* Compute the initial settings */
664
+        $this->firstPass($Algorithm);
665 665
 
666
-       /* Apply the vectors */
667
-       if ( $Pass > 0 ) 
666
+        /* Apply the vectors */
667
+        if ( $Pass > 0 ) 
668 668
         {
669
-         for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
669
+            for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
670 670
         }
671 671
 
672
-       $Conflicts = $this->lastPass();
673
-       if ( $this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"] )
672
+        $Conflicts = $this->lastPass();
673
+        if ( $this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"] )
674 674
         { $this->History["MinimumConflicts"] = $Conflicts; $this->History["Result"] = $this->Data; }
675
-      }
675
+        }
676 676
 
677
-     $Conflicts  = $this->History["MinimumConflicts"];
678
-     $this->Data = $this->History["Result"];
677
+        $Conflicts  = $this->History["MinimumConflicts"];
678
+        $this->Data = $this->History["Result"];
679 679
 
680
-     if ( $CenterGraph ) { $this->center(); }
680
+        if ( $CenterGraph ) { $this->center(); }
681 681
 
682
-     /* Draw the connections */
683
-     $Drawn = "";
684
-     foreach($this->Data as $Key => $Settings)
685
-      {
686
-       $X	= $Settings["X"];
687
-       $Y	= $Settings["Y"];
682
+        /* Draw the connections */
683
+        $Drawn = "";
684
+        foreach($this->Data as $Key => $Settings)
685
+        {
686
+        $X	= $Settings["X"];
687
+        $Y	= $Settings["Y"];
688 688
 
689
-       if ( isset($Settings["Connections"]) )
689
+        if ( isset($Settings["Connections"]) )
690 690
         {
691
-         foreach ($Settings["Connections"] as $ID => $NodeID)
692
-          {
693
-           if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694
-           if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
691
+            foreach ($Settings["Connections"] as $ID => $NodeID)
692
+            {
693
+            if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694
+            if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
695 695
 
696
-           if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
696
+            if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
697 697
             {
698
-             $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
698
+                $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
699 699
 
700
-             if ( $this->Links != "" )
701
-              {
702
-               if ( isset($this->Links[$Key][$NodeID]["R"]) )
700
+                if ( $this->Links != "" )
701
+                {
702
+                if ( isset($this->Links[$Key][$NodeID]["R"]) )
703 703
                 { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"],"G"=>$this->Links[$Key][$NodeID]["G"],"B"=>$this->Links[$Key][$NodeID]["B"],"Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); }
704 704
 
705
-               if ( isset($this->Links[$Key][$NodeID]["Ticks"]) )
706
-                 { $Color["Ticks"] = $this->Links[$Key][$NodeID]["Ticks"]; }
707
-              }
705
+                if ( isset($this->Links[$Key][$NodeID]["Ticks"]) )
706
+                    { $Color["Ticks"] = $this->Links[$Key][$NodeID]["Ticks"]; }
707
+                }
708 708
 
709
-             $X2 = $this->Data[$NodeID]["X"];
710
-             $Y2 = $this->Data[$NodeID]["Y"];
711
-             $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712
-             $Drawn[$Key][$NodeID] = TRUE;
709
+                $X2 = $this->Data[$NodeID]["X"];
710
+                $Y2 = $this->Data[$NodeID]["Y"];
711
+                $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712
+                $Drawn[$Key][$NodeID] = TRUE;
713 713
 
714
-             if ( isset($this->Links) && $this->Links != "" )
715
-              {
716
-               if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
714
+                if ( isset($this->Links) && $this->Links != "" )
715
+                {
716
+                if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
717 717
                 {
718
-                 $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719
-                 $TxtX  = ($X2 - $X)/2 + $X;
720
-                 $TxtY  = ($Y2 - $Y)/2 + $Y;
721
-
722
-                 if ( $X <= $X2 )
723
-                  $Angle = (360-$this->getAngle($X,$Y,$X2,$Y2)) % 360;
724
-                 else
725
-                  $Angle = (360-$this->getAngle($X2,$Y2,$X,$Y)) % 360;
726
-
727
-                 $Settings          = $Color;
728
-                 $Settings["Angle"] = $Angle;
729
-                 $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
730
-                 $this->pChartObject->drawText($TxtX,$TxtY,$Name,$Settings);
718
+                    $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719
+                    $TxtX  = ($X2 - $X)/2 + $X;
720
+                    $TxtY  = ($Y2 - $Y)/2 + $Y;
721
+
722
+                    if ( $X <= $X2 )
723
+                    $Angle = (360-$this->getAngle($X,$Y,$X2,$Y2)) % 360;
724
+                    else
725
+                    $Angle = (360-$this->getAngle($X2,$Y2,$X,$Y)) % 360;
726
+
727
+                    $Settings          = $Color;
728
+                    $Settings["Angle"] = $Angle;
729
+                    $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
730
+                    $this->pChartObject->drawText($TxtX,$TxtY,$Name,$Settings);
731 731
                 }
732
-              }
732
+                }
733
+            }
733 734
             }
734
-          }
735 735
         }
736
-      }
736
+        }
737 737
 
738
-     /* Draw the quiet zones */
739
-     if ( $DrawQuietZone )
740
-      {
741
-       foreach($this->Data as $Key => $Settings)
738
+        /* Draw the quiet zones */
739
+        if ( $DrawQuietZone )
740
+        {
741
+        foreach($this->Data as $Key => $Settings)
742 742
         {
743
-         $X	 = $Settings["X"];
744
-         $Y	 = $Settings["Y"];
745
-         $FreeZone = $Settings["FreeZone"];
743
+            $X	 = $Settings["X"];
744
+            $Y	 = $Settings["Y"];
745
+            $FreeZone = $Settings["FreeZone"];
746 746
 
747
-         $this->pChartObject->drawFilledCircle($X,$Y,$FreeZone,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>2));
747
+            $this->pChartObject->drawFilledCircle($X,$Y,$FreeZone,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>2));
748
+        }
748 749
         }
749
-      }
750 750
 
751 751
 
752
-     /* Draw the nodes */
753
-     foreach($this->Data as $Key => $Settings)
754
-      {
755
-       $X	 = $Settings["X"];
756
-       $Y	 = $Settings["Y"];
757
-       $Name	 = $Settings["Name"];
758
-       $FreeZone = $Settings["FreeZone"];
759
-       $Shape    = $Settings["Shape"];
760
-       $Size     = $Settings["Size"];
752
+        /* Draw the nodes */
753
+        foreach($this->Data as $Key => $Settings)
754
+        {
755
+        $X	 = $Settings["X"];
756
+        $Y	 = $Settings["Y"];
757
+        $Name	 = $Settings["Name"];
758
+        $FreeZone = $Settings["FreeZone"];
759
+        $Shape    = $Settings["Shape"];
760
+        $Size     = $Settings["Size"];
761 761
 
762
-       $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
762
+        $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
763 763
 
764
-       if ( $Shape == NODE_SHAPE_CIRCLE )
764
+        if ( $Shape == NODE_SHAPE_CIRCLE )
765 765
         {
766
-         $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
766
+            $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
767 767
         }
768
-       elseif ( $Shape == NODE_SHAPE_TRIANGLE )
768
+        elseif ( $Shape == NODE_SHAPE_TRIANGLE )
769 769
         {
770
-         $Points = "";
771
-         $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772
-         $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773
-         $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774
-         $this->pChartObject->drawPolygon($Points,$Color);
770
+            $Points = "";
771
+            $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772
+            $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773
+            $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774
+            $this->pChartObject->drawPolygon($Points,$Color);
775 775
         }
776
-       elseif ( $Shape == NODE_SHAPE_SQUARE )
776
+        elseif ( $Shape == NODE_SHAPE_SQUARE )
777 777
         {
778
-         $Offset = $Size/2; $Size = $Size / 2;
779
-         $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
778
+            $Offset = $Size/2; $Size = $Size / 2;
779
+            $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
780 780
         }
781 781
 
782
-       if ( $Name != "" )
782
+        if ( $Name != "" )
783 783
         {
784
-         $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
784
+            $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
785 785
 
786
-         if ( $this->Labels["Type"] == LABEL_LIGHT )
787
-          {
788
-           $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789
-           $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
790
-          }
791
-         elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792
-          {
793
-           $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794
-           $LabelOptions["DrawBox"]       = TRUE;
795
-           $LabelOptions["BoxAlpha"]      = 50;
796
-           $LabelOptions["BorderOffset"]  = 4;
797
-           $LabelOptions["RoundedRadius"] = 3;
798
-           $LabelOptions["BoxRounded"]    = TRUE;
799
-           $LabelOptions["NoShadow"]      = TRUE;
800
-
801
-           $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
802
-          }
786
+            if ( $this->Labels["Type"] == LABEL_LIGHT )
787
+            {
788
+            $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789
+            $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
790
+            }
791
+            elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792
+            {
793
+            $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794
+            $LabelOptions["DrawBox"]       = TRUE;
795
+            $LabelOptions["BoxAlpha"]      = 50;
796
+            $LabelOptions["BorderOffset"]  = 4;
797
+            $LabelOptions["RoundedRadius"] = 3;
798
+            $LabelOptions["BoxRounded"]    = TRUE;
799
+            $LabelOptions["NoShadow"]      = TRUE;
800
+
801
+            $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
802
+            }
803
+        }
803 804
         }
804
-      }
805 805
 
806
-     /* Draw the vectors */
807
-     if ( $DrawVectors )
808
-      {
809
-       foreach($this->Data as $Key => $Settings)
806
+        /* Draw the vectors */
807
+        if ( $DrawVectors )
810 808
         {
811
-         $X1 = $Settings["X"];
812
-         $Y1 = $Settings["Y"];
809
+        foreach($this->Data as $Key => $Settings)
810
+        {
811
+            $X1 = $Settings["X"];
812
+            $Y1 = $Settings["Y"];
813 813
 
814
-         if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
815
-          {
816
-           foreach($Settings["Vectors"] as $ID => $Vector)
814
+            if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
815
+            {
816
+            foreach($Settings["Vectors"] as $ID => $Vector)
817 817
             {
818
-             $Type  = $Vector["Type"];
819
-             $Force = $Vector["Force"];
820
-             $Angle = $Vector["Angle"];
821
-             $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
822
-             $Color  = $Type == "A" ? array("FillR"=>255,"FillG"=>0,"FillB"=>0) : array("FillR"=>0,"FillG"=>255,"FillB"=>0);
818
+                $Type  = $Vector["Type"];
819
+                $Force = $Vector["Force"];
820
+                $Angle = $Vector["Angle"];
821
+                $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
822
+                $Color  = $Type == "A" ? array("FillR"=>255,"FillG"=>0,"FillB"=>0) : array("FillR"=>0,"FillG"=>255,"FillB"=>0);
823 823
 
824
-             $X2 = cos(deg2rad($Angle)) * $Force * $Factor + $X1;
825
-             $Y2 = sin(deg2rad($Angle)) * $Force * $Factor + $Y1;
824
+                $X2 = cos(deg2rad($Angle)) * $Force * $Factor + $X1;
825
+                $Y2 = sin(deg2rad($Angle)) * $Force * $Factor + $Y1;
826 826
 
827
-             $this->pChartObject->drawArrow($X1,$Y1,$X2,$Y2,$Color);
827
+                $this->pChartObject->drawArrow($X1,$Y1,$X2,$Y2,$Color);
828 828
             }
829
-          }
829
+            }
830
+        }
830 831
         }
831
-      }
832 832
 
833
-     return(array("Pass"=>$Jobs,"Conflicts"=>$Conflicts));
833
+        return(array("Pass"=>$Jobs,"Conflicts"=>$Conflicts));
834 834
     }
835 835
 
836
-   /* Return the distance between two points */
837
-   function getDistance($X1,$Y1,$X2,$Y2)
836
+    /* Return the distance between two points */
837
+    function getDistance($X1,$Y1,$X2,$Y2)
838 838
     { return (sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1))); }
839 839
 
840
-   /* Return the angle made by a line and the X axis */
841
-   function getAngle($X1,$Y1,$X2,$Y2)
840
+    /* Return the angle made by a line and the X axis */
841
+    function getAngle($X1,$Y1,$X2,$Y2)
842 842
     {
843
-     $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844
-     if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
843
+        $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844
+        if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
845 845
     }
846 846
 
847
-   function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
847
+    function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
848 848
     {
849
-     $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850
-     $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
849
+        $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850
+        $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
851 851
 
852
-     if ( $B == 0 ) { return(FALSE); }
853
-     $Xi = $A / $B;
852
+        if ( $B == 0 ) { return(FALSE); }
853
+        $Xi = $A / $B;
854 854
 
855
-     $C = ($X1 - $X2);
856
-     if ( $C == 0 ) { return(FALSE); }
857
-     $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
855
+        $C = ($X1 - $X2);
856
+        if ( $C == 0 ) { return(FALSE); }
857
+        $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
858 858
 
859
-     if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860
-      {
861
-       if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
859
+        if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860
+        {
861
+        if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
862 862
         { return(TRUE); }
863
-      }
863
+        }
864 864
 
865
-      return(FALSE);   
865
+        return(FALSE);   
866
+    }
866 867
     }
867
-  }
868 868
 ?>
869 869
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- define("NODE_TYPE_FREE"	, 690001);
17
- define("NODE_TYPE_CENTRAL"	, 690002);
16
+ define("NODE_TYPE_FREE", 690001);
17
+ define("NODE_TYPE_CENTRAL", 690002);
18 18
 
19
- define("NODE_SHAPE_CIRCLE"	, 690011);
20
- define("NODE_SHAPE_TRIANGLE"	, 690012);
21
- define("NODE_SHAPE_SQUARE"	, 690013);
19
+ define("NODE_SHAPE_CIRCLE", 690011);
20
+ define("NODE_SHAPE_TRIANGLE", 690012);
21
+ define("NODE_SHAPE_SQUARE", 690013);
22 22
 
23
- define("ALGORITHM_RANDOM"	, 690021);
24
- define("ALGORITHM_WEIGHTED"	, 690022);
25
- define("ALGORITHM_CIRCULAR"	, 690023);
26
- define("ALGORITHM_CENTRAL"	, 690024);
23
+ define("ALGORITHM_RANDOM", 690021);
24
+ define("ALGORITHM_WEIGHTED", 690022);
25
+ define("ALGORITHM_CIRCULAR", 690023);
26
+ define("ALGORITHM_CENTRAL", 690024);
27 27
 
28
- define("LABEL_CLASSIC"		, 690031);
29
- define("LABEL_LIGHT"		, 690032);
28
+ define("LABEL_CLASSIC", 690031);
29
+ define("LABEL_LIGHT", 690032);
30 30
 
31 31
  /* pSpring class definition */
32 32
  class pSpring
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      $this->Default["R"]		= 255;
54 54
      $this->Default["G"]		= 255;
55 55
      $this->Default["B"]		= 255;
56
-     $this->Default["Alpha"]		= 100;
56
+     $this->Default["Alpha"] = 100;
57 57
      $this->Default["BorderR"]		= 0;
58 58
      $this->Default["BorderG"]		= 0;
59 59
      $this->Default["BorderB"]		= 0;
@@ -62,52 +62,52 @@  discard block
 block discarded – undo
62 62
      $this->Default["BackgroundR"]	= 255;
63 63
      $this->Default["BackgroundG"]	= 255;
64 64
      $this->Default["BackgroundB"]	= 255;
65
-     $this->Default["BackgroundAlpha"]	= 0;
65
+     $this->Default["BackgroundAlpha"] = 0;
66 66
      $this->Default["Force"]		= 1;
67 67
      $this->Default["NodeType"]		= NODE_TYPE_FREE;
68
-     $this->Default["Size"]		= 5;
68
+     $this->Default["Size"] = 5;
69 69
      $this->Default["Shape"]		= NODE_SHAPE_CIRCLE;
70 70
      $this->Default["FreeZone"]		= 40;
71 71
      $this->Default["LinkR"]		= 0;
72 72
      $this->Default["LinkG"]		= 0;
73 73
      $this->Default["LinkB"]		= 0;
74
-     $this->Default["LinkAlpha"]	= 0;
74
+     $this->Default["LinkAlpha"] = 0;
75 75
 
76
-     $this->Labels["Type"]		= LABEL_CLASSIC;
76
+     $this->Labels["Type"] = LABEL_CLASSIC;
77 77
      $this->Labels["R"]			= 0;
78 78
      $this->Labels["G"]			= 0;
79 79
      $this->Labels["B"]			= 0;
80
-     $this->Labels["Alpha"]		= 100;
80
+     $this->Labels["Alpha"] = 100;
81 81
 
82
-     $this->AutoComputeFreeZone         = FALSE;
82
+     $this->AutoComputeFreeZone = FALSE;
83 83
     }
84 84
 
85 85
    /* Set default links options */
86
-   function setLinkDefaults($Settings="")
86
+   function setLinkDefaults($Settings = "")
87 87
     {
88
-     if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89
-     if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90
-     if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
91
-     if ( isset($Settings["Alpha"]) ) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
88
+     if (isset($Settings["R"])) { $this->Default["LinkR"] = $Settings["R"]; }
89
+     if (isset($Settings["G"])) { $this->Default["LinkG"] = $Settings["G"]; }
90
+     if (isset($Settings["B"])) { $this->Default["LinkB"] = $Settings["B"]; }
91
+     if (isset($Settings["Alpha"])) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
92 92
     }
93 93
 
94 94
    /* Set default links options */
95
-   function setLabelsSettings($Settings="")
95
+   function setLabelsSettings($Settings = "")
96 96
     {
97
-     if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98
-     if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99
-     if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
100
-     if ( isset($Settings["B"]) )     { $this->Labels["B"] = $Settings["B"]; }
101
-     if ( isset($Settings["Alpha"]) ) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
97
+     if (isset($Settings["Type"])) { $this->Labels["Type"] = $Settings["Type"]; }
98
+     if (isset($Settings["R"])) { $this->Labels["R"] = $Settings["R"]; }
99
+     if (isset($Settings["G"])) { $this->Labels["G"] = $Settings["G"]; }
100
+     if (isset($Settings["B"])) { $this->Labels["B"] = $Settings["B"]; }
101
+     if (isset($Settings["Alpha"])) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
102 102
     }
103 103
 
104 104
    /* Auto compute the FreeZone size based on the number of connections */
105 105
    function autoFreeZone()
106 106
     {
107 107
      /* Check connections reciprocity */
108
-     foreach($this->Data as $Key => $Settings)
108
+     foreach ($this->Data as $Key => $Settings)
109 109
       {
110
-       if ( isset($Settings["Connections"]) )
110
+       if (isset($Settings["Connections"]))
111 111
         { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; }
112 112
        else
113 113
         { $this->Data[$Key]["FreeZone"] = 20; }
@@ -116,60 +116,60 @@  discard block
 block discarded – undo
116 116
     }
117 117
 
118 118
    /* Set link properties */
119
-   function linkProperties($FromNode,$ToNode,$Settings)
119
+   function linkProperties($FromNode, $ToNode, $Settings)
120 120
     {
121
-     if ( !isset($this->Data[$FromNode]) ) { return(0); }
122
-     if ( !isset($this->Data[$ToNode]) )   { return(0); }
121
+     if (!isset($this->Data[$FromNode])) { return(0); }
122
+     if (!isset($this->Data[$ToNode])) { return(0); }
123 123
 
124 124
      $R			= isset($Settings["R"]) ? $Settings["R"] : 0;
125 125
      $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126 126
      $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127 127
      $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
128
+     $Name = isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129 129
      $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
130 130
 
131
-     $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132
-     $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
133
-     $this->Links[$FromNode][$ToNode]["B"] = $B;         $this->Links[$ToNode][$FromNode]["B"] = $B;
131
+     $this->Links[$FromNode][$ToNode]["R"] = $R; $this->Links[$ToNode][$FromNode]["R"] = $R;
132
+     $this->Links[$FromNode][$ToNode]["G"] = $G; $this->Links[$ToNode][$FromNode]["G"] = $G;
133
+     $this->Links[$FromNode][$ToNode]["B"] = $B; $this->Links[$ToNode][$FromNode]["B"] = $B;
134 134
      $this->Links[$FromNode][$ToNode]["Alpha"] = $Alpha; $this->Links[$ToNode][$FromNode]["Alpha"] = $Alpha;
135
-     $this->Links[$FromNode][$ToNode]["Name"] = $Name;   $this->Links[$ToNode][$FromNode]["Name"] = $Name;
135
+     $this->Links[$FromNode][$ToNode]["Name"] = $Name; $this->Links[$ToNode][$FromNode]["Name"] = $Name;
136 136
      $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
137 137
     }
138 138
 
139
-   function setNodeDefaults($Settings="")
139
+   function setNodeDefaults($Settings = "")
140 140
     {
141
-     if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142
-     if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143
-     if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
144
-     if ( isset($Settings["Alpha"]) ) { $this->Default["Alpha"]				= $Settings["Alpha"]; }
145
-     if ( isset($Settings["BorderR"]) ) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
-     if ( isset($Settings["BorderG"]) ) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
-     if ( isset($Settings["BorderB"]) ) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
-     if ( isset($Settings["BorderAlpha"]) ) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
-     if ( isset($Settings["Surrounding"]) ) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
-     if ( isset($Settings["BackgroundR"]) ) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
-     if ( isset($Settings["BackgroundG"]) ) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
-     if ( isset($Settings["BackgroundB"]) ) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
-     if ( isset($Settings["BackgroundAlpha"]) ) { $this->Default["BackgroundAlpha"]	= $Settings["BackgroundAlpha"]; }
154
-     if ( isset($Settings["NodeType"]) ) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
-     if ( isset($Settings["Size"]) ) { $this->Default["Size"]				= $Settings["Size"]; }
156
-     if ( isset($Settings["Shape"]) ) { $this->Default["Shape"]				= $Settings["Shape"]; }
157
-     if ( isset($Settings["FreeZone"]) ) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
141
+     if (isset($Settings["R"])) { $this->Default["R"]					= $Settings["R"]; }
142
+     if (isset($Settings["G"])) { $this->Default["G"]					= $Settings["G"]; }
143
+     if (isset($Settings["B"])) { $this->Default["B"]					= $Settings["B"]; }
144
+     if (isset($Settings["Alpha"])) { $this->Default["Alpha"] = $Settings["Alpha"]; }
145
+     if (isset($Settings["BorderR"])) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
+     if (isset($Settings["BorderG"])) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
+     if (isset($Settings["BorderB"])) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
+     if (isset($Settings["BorderAlpha"])) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
+     if (isset($Settings["Surrounding"])) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
+     if (isset($Settings["BackgroundR"])) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
+     if (isset($Settings["BackgroundG"])) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
+     if (isset($Settings["BackgroundB"])) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
+     if (isset($Settings["BackgroundAlpha"])) { $this->Default["BackgroundAlpha"] = $Settings["BackgroundAlpha"]; }
154
+     if (isset($Settings["NodeType"])) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
+     if (isset($Settings["Size"])) { $this->Default["Size"] = $Settings["Size"]; }
156
+     if (isset($Settings["Shape"])) { $this->Default["Shape"] = $Settings["Shape"]; }
157
+     if (isset($Settings["FreeZone"])) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
158 158
     }
159 159
 
160 160
    /* Add a node */
161
-   function addNode($NodeID,$Settings="")
161
+   function addNode($NodeID, $Settings = "")
162 162
     {
163 163
      /* if the node already exists, ignore */
164 164
      if (isset($this->Data[$NodeID])) { return(0); }
165 165
 
166
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
-     $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
166
+     $Name = isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
+     $Connections = isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
168 168
 
169 169
      $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170 170
      $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
171 171
      $B			= isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"];
172
-     $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
172
+     $Alpha = isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
173 173
      $BorderR		= isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"];
174 174
      $BorderG		= isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"];
175 175
      $BorderB		= isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"];
@@ -178,29 +178,29 @@  discard block
 block discarded – undo
178 178
      $BackgroundR	= isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"];
179 179
      $BackgroundG	= isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"];
180 180
      $BackgroundB	= isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"];
181
-     $BackgroundAlpha	= isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
-     $Force		= isset($Settings["Force"]) ? $Settings["Force"] :  $this->Default["Force"];
181
+     $BackgroundAlpha = isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
+     $Force		= isset($Settings["Force"]) ? $Settings["Force"] : $this->Default["Force"];
183 183
      $NodeType		= isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"];
184
-     $Size		= isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
184
+     $Size = isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
185 185
      $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186 186
      $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187 187
 
188
-     if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
188
+     if ($Surrounding != NULL) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189 189
 
190 190
      $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191 191
      $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
192
-     $this->Data[$NodeID]["BackgroundR"]	= $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
192
+     $this->Data[$NodeID]["BackgroundR"] = $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
193 193
      $this->Data[$NodeID]["Name"]		= $Name;
194 194
      $this->Data[$NodeID]["Force"]		= $Force;
195 195
      $this->Data[$NodeID]["Type"]		= $NodeType;
196 196
      $this->Data[$NodeID]["Size"]		= $Size;
197 197
      $this->Data[$NodeID]["Shape"]		= $Shape;
198
-     $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
-     if ( $Connections != NULL )
198
+     $this->Data[$NodeID]["FreeZone"] = $FreeZone;
199
+     if ($Connections != NULL)
200 200
       {
201
-       if ( is_array($Connections ) )
201
+       if (is_array($Connections))
202 202
         {
203
-         foreach($Connections as $Key => $Value)
203
+         foreach ($Connections as $Key => $Value)
204 204
           $this->Data[$NodeID]["Connections"][] = $Value;
205 205
         }
206 206
        else
@@ -209,37 +209,37 @@  discard block
 block discarded – undo
209 209
     }
210 210
 
211 211
    /* Set color attribute for a list of nodes */
212
-   function setNodesColor($Nodes,$Settings="")
212
+   function setNodesColor($Nodes, $Settings = "")
213 213
     {
214
-     if ( is_array($Nodes) )
214
+     if (is_array($Nodes))
215 215
       {
216 216
        foreach ($Nodes as $Key => $NodeID)
217 217
         {
218
-         if (isset($this->Data[$NodeID]) )
218
+         if (isset($this->Data[$NodeID]))
219 219
           {
220
-           if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
-           if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
-           if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
-           if ( isset($Settings["Alpha"]) ) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
-           if ( isset($Settings["BorderR"]) ) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
-           if ( isset($Settings["BorderG"]) ) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
-           if ( isset($Settings["BorderB"]) ) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
-           if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
-           if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
220
+           if (isset($Settings["R"])) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
+           if (isset($Settings["G"])) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
+           if (isset($Settings["B"])) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
+           if (isset($Settings["Alpha"])) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
+           if (isset($Settings["BorderR"])) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
+           if (isset($Settings["BorderG"])) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
+           if (isset($Settings["BorderB"])) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
+           if (isset($Settings["BorderAlpha"])) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
+           if (isset($Settings["Surrounding"])) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229 229
           }
230 230
         }
231 231
       }
232 232
      else
233 233
       {
234
-       if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
-       if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
-       if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
-       if ( isset($Settings["Alpha"]) ) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
-       if ( isset($Settings["BorderR"]) ) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
-       if ( isset($Settings["BorderG"]) ) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
-       if ( isset($Settings["BorderB"]) ) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
-       if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
-       if ( isset($Settings["Surrounding"]) ) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
234
+       if (isset($Settings["R"])) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
+       if (isset($Settings["G"])) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
+       if (isset($Settings["B"])) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
+       if (isset($Settings["Alpha"])) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
+       if (isset($Settings["BorderR"])) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
+       if (isset($Settings["BorderG"])) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
+       if (isset($Settings["BorderB"])) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
+       if (isset($Settings["BorderAlpha"])) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
+       if (isset($Settings["Surrounding"])) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
243 243
       }
244 244
     }
245 245
 
@@ -250,22 +250,22 @@  discard block
 block discarded – undo
250 250
    /* Check if a connection exists and create it if required */
251 251
    function checkConnection($SourceID, $TargetID)
252 252
     {
253
-     if ( isset($this->Data[$SourceID]["Connections"]) )
253
+     if (isset($this->Data[$SourceID]["Connections"]))
254 254
       {
255 255
        foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
256
-        { if ( $TargetID == $ConnectionID ) { return(TRUE); } }
256
+        { if ($TargetID == $ConnectionID) { return(TRUE); } }
257 257
       }
258 258
      $this->Data[$SourceID]["Connections"][] = $TargetID;
259 259
     }
260 260
    /* Get the median linked nodes position */
261
-   function getMedianOffset($Key,$X,$Y)
261
+   function getMedianOffset($Key, $X, $Y)
262 262
     {
263 263
      $Cpt = 1;
264
-     if ( isset($this->Data[$Key]["Connections"]) )
264
+     if (isset($this->Data[$Key]["Connections"]))
265 265
       {
266
-       foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
266
+       foreach ($this->Data[$Key]["Connections"] as $ID => $NodeID)
267 267
         {
268
-         if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
268
+         if (isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]))
269 269
           {
270 270
            $X = $X + $this->Data[$NodeID]["X"];
271 271
            $Y = $Y + $this->Data[$NodeID]["Y"];
@@ -273,18 +273,18 @@  discard block
 block discarded – undo
273 273
           }
274 274
         }
275 275
       }
276
-     return(array("X"=>$X/$Cpt,"Y"=>$Y/$Cpt));
276
+     return(array("X"=>$X/$Cpt, "Y"=>$Y/$Cpt));
277 277
     }
278 278
 
279 279
    /* Return the ID of the attached partner with the biggest weight */
280 280
    function getBiggestPartner($Key)
281 281
     {
282
-     if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
282
+     if (!isset($this->Data[$Key]["Connections"])) { return(""); }
283 283
 
284 284
      $MaxWeight = 0; $Result = "";
285
-     foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
285
+     foreach ($this->Data[$Key]["Connections"] as $Key => $PeerID)
286 286
       {
287
-       if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
287
+       if ($this->Data[$PeerID]["Weight"] > $MaxWeight)
288 288
         { $MaxWeight = $this->Data[$PeerID]["Weight"]; $Result = $PeerID; }
289 289
       }
290 290
      return($Result);
@@ -293,94 +293,94 @@  discard block
 block discarded – undo
293 293
    /* Do the initial node positions computing pass */
294 294
    function firstPass($Algorithm)
295 295
     {
296
-     $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297
-     $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
296
+     $CenterX = ($this->X2 - $this->X1)/2 + $this->X1;
297
+     $CenterY = ($this->Y2 - $this->Y1)/2 + $this->Y1;
298 298
 
299 299
      /* Check connections reciprocity */
300
-     foreach($this->Data as $Key => $Settings)
300
+     foreach ($this->Data as $Key => $Settings)
301 301
       {
302
-       if ( isset($Settings["Connections"]) )
302
+       if (isset($Settings["Connections"]))
303 303
         {
304
-         foreach($Settings["Connections"] as $ID => $ConnectionID)
305
-          $this->checkConnection($ConnectionID,$Key);
304
+         foreach ($Settings["Connections"] as $ID => $ConnectionID)
305
+          $this->checkConnection($ConnectionID, $Key);
306 306
         }
307 307
       }
308 308
 
309
-     if ( $this->AutoComputeFreeZone ) { $this->autoFreeZone(); }
309
+     if ($this->AutoComputeFreeZone) { $this->autoFreeZone(); }
310 310
 
311 311
      /* Get the max number of connections */
312 312
      $MaxConnections = 0;
313
-     foreach($this->Data as $Key => $Settings)
314
-      { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
313
+     foreach ($this->Data as $Key => $Settings)
314
+      { if (isset($Settings["Connections"])) { if ($MaxConnections < count($Settings["Connections"])) { $MaxConnections = count($Settings["Connections"]); } } }
315 315
 
316
-     if ( $Algorithm == ALGORITHM_WEIGHTED )
316
+     if ($Algorithm == ALGORITHM_WEIGHTED)
317 317
       {
318
-       foreach($this->Data as $Key => $Settings)
318
+       foreach ($this->Data as $Key => $Settings)
319 319
         {
320
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
320
+         if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
+         if ($Settings["Type"] == NODE_TYPE_FREE)
322 322
           {
323
-           if ( isset($Settings["Connections"]) )
323
+           if (isset($Settings["Connections"]))
324 324
             { $Connections = count($Settings["Connections"]); }
325 325
            else
326 326
             { $Connections = 0; }
327 327
 
328 328
            $Ring  = $MaxConnections - $Connections;
329
-           $Angle = rand(0,360);
329
+           $Angle = rand(0, 360);
330 330
            
331
-           $this->Data[$Key]["X"] = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
332
-           $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
331
+           $this->Data[$Key]["X"] = cos(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterX;
332
+           $this->Data[$Key]["Y"] = sin(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterY;
333 333
           }
334 334
         }
335 335
       }
336
-     elseif ( $Algorithm == ALGORITHM_CENTRAL )
336
+     elseif ($Algorithm == ALGORITHM_CENTRAL)
337 337
       {
338 338
        /* Put a weight on each nodes */
339
-       foreach($this->Data as $Key => $Settings)
339
+       foreach ($this->Data as $Key => $Settings)
340 340
         {
341
-         if ( isset($Settings["Connections"]) )
341
+         if (isset($Settings["Connections"]))
342 342
           $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343 343
          else
344 344
           $this->Data[$Key]["Weight"] = 0;
345 345
         }
346 346
 
347 347
        $MaxConnections = $MaxConnections + 1;
348
-       for($i=$MaxConnections;$i>=0;$i--)
348
+       for ($i = $MaxConnections; $i >= 0; $i--)
349 349
         {
350
-         foreach($this->Data as $Key => $Settings)
350
+         foreach ($this->Data as $Key => $Settings)
351 351
           {
352
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
352
+           if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
+           if ($Settings["Type"] == NODE_TYPE_FREE)
354 354
             {
355
-             if ( isset($Settings["Connections"]) )
355
+             if (isset($Settings["Connections"]))
356 356
               { $Connections = count($Settings["Connections"]); }
357 357
              else
358 358
               { $Connections = 0; }
359 359
 
360
-             if ( $Connections == $i )
360
+             if ($Connections == $i)
361 361
               {
362 362
                $BiggestPartner = $this->getBiggestPartner($Key);
363
-               if ( $BiggestPartner != "" )
363
+               if ($BiggestPartner != "")
364 364
                 {
365 365
                  $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366 366
                  $Weight        = $this->Data[$BiggestPartner]["Weight"];
367
-                 $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
367
+                 $AngleDivision = 360/$this->Data[$BiggestPartner]["Weight"];
368 368
                  $Done          = FALSE; $Tries = 0;
369 369
                  while (!$Done && $Tries <= $Weight*2)
370 370
                   {
371 371
                    $Tries++;
372
-                   $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
-                   if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
372
+                   $Angle = floor(rand(0, $Weight)*$AngleDivision);
373
+                   if (!isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]))
374 374
                     {
375 375
                      $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376 376
                      $Done = TRUE; 
377 377
                     }
378 378
                   }
379
-                 if ( !$Done )
380
-                  { $Angle = rand(0,360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
379
+                 if (!$Done)
380
+                  { $Angle = rand(0, 360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
381 381
 
382
-                 $X = cos(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["X"];
383
-                 $Y = sin(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["Y"];
382
+                 $X = cos(deg2rad($Angle))*($Ring) + $this->Data[$BiggestPartner]["X"];
383
+                 $Y = sin(deg2rad($Angle))*($Ring) + $this->Data[$BiggestPartner]["Y"];
384 384
 
385 385
                  $this->Data[$Key]["X"] = $X;
386 386
                  $this->Data[$Key]["Y"] = $Y;
@@ -390,30 +390,30 @@  discard block
 block discarded – undo
390 390
           }
391 391
         }
392 392
       }
393
-     elseif ( $Algorithm == ALGORITHM_CIRCULAR )
393
+     elseif ($Algorithm == ALGORITHM_CIRCULAR)
394 394
       {
395 395
        $MaxConnections = $MaxConnections + 1;
396
-       for($i=$MaxConnections;$i>=0;$i--)
396
+       for ($i = $MaxConnections; $i >= 0; $i--)
397 397
         {
398
-         foreach($this->Data as $Key => $Settings)
398
+         foreach ($this->Data as $Key => $Settings)
399 399
           {
400
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
400
+           if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
+           if ($Settings["Type"] == NODE_TYPE_FREE)
402 402
             {
403
-             if ( isset($Settings["Connections"]) )
403
+             if (isset($Settings["Connections"]))
404 404
               { $Connections = count($Settings["Connections"]); }
405 405
              else
406 406
               { $Connections = 0; }
407 407
 
408
-             if ( $Connections == $i )
408
+             if ($Connections == $i)
409 409
               {
410 410
                $Ring  = $MaxConnections - $Connections;
411
-               $Angle = rand(0,360);
411
+               $Angle = rand(0, 360);
412 412
 
413
-               $X = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
414
-               $Y = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
413
+               $X = cos(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterX;
414
+               $Y = sin(deg2rad($Angle))*($Ring*$this->RingSize) + $CenterY;
415 415
 
416
-               $MedianOffset = $this->getMedianOffset($Key,$X,$Y);
416
+               $MedianOffset = $this->getMedianOffset($Key, $X, $Y);
417 417
 
418 418
                $this->Data[$Key]["X"] = $MedianOffset["X"];
419 419
                $this->Data[$Key]["Y"] = $MedianOffset["Y"];
@@ -422,16 +422,16 @@  discard block
 block discarded – undo
422 422
           }
423 423
         }
424 424
       }
425
-     elseif ( $Algorithm == ALGORITHM_RANDOM )
425
+     elseif ($Algorithm == ALGORITHM_RANDOM)
426 426
       {
427
-       foreach($this->Data as $Key => $Settings)
427
+       foreach ($this->Data as $Key => $Settings)
428 428
         {
429
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
429
+         if ($Settings["Type"] == NODE_TYPE_FREE)
430 430
           {
431
-           $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432
-           $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
431
+           $this->Data[$Key]["X"] = $CenterX + rand(-20, 20);
432
+           $this->Data[$Key]["Y"] = $CenterY + rand(-20, 20);
433 433
           }
434
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
434
+         if ($Settings["Type"] == NODE_TYPE_CENTRAL) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
435 435
         }
436 436
       }
437 437
     }
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
    function doPass()
441 441
     {
442 442
      /* Compute vectors */
443
-     foreach($this->Data as $Key => $Settings)
443
+     foreach ($this->Data as $Key => $Settings)
444 444
       {
445
-       if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
445
+       if ($Settings["Type"] != NODE_TYPE_CENTRAL)
446 446
         {
447 447
          unset($this->Data[$Key]["Vectors"]);
448 448
 
@@ -450,48 +450,48 @@  discard block
 block discarded – undo
450 450
          $Y1 = $Settings["Y"];
451 451
 
452 452
          /* Repulsion vectors */
453
-         foreach($this->Data as $Key2 => $Settings2)
453
+         foreach ($this->Data as $Key2 => $Settings2)
454 454
           {
455
-           if ( $Key != $Key2 )
455
+           if ($Key != $Key2)
456 456
             {
457 457
              $X2 = $this->Data[$Key2]["X"];
458 458
              $Y2 = $this->Data[$Key2]["Y"];
459 459
              $FreeZone = $this->Data[$Key2]["FreeZone"];
460 460
 
461
-             $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
462
-             $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
461
+             $Distance = $this->getDistance($X1, $Y1, $X2, $Y2);
462
+             $Angle    = $this->getAngle($X1, $Y1, $X2, $Y2) + 180;
463 463
 
464 464
              /* Nodes too close, repulsion occurs */
465
-             if ( $Distance < $FreeZone )
465
+             if ($Distance < $FreeZone)
466 466
               {
467
-               $Force = log(pow(2,$FreeZone-$Distance));
468
-               if ( $Force > 1 )
469
-                { $this->Data[$Key]["Vectors"][] = array("Type"=>"R","Angle"=>$Angle % 360,"Force"=>$Force); }
467
+               $Force = log(pow(2, $FreeZone - $Distance));
468
+               if ($Force > 1)
469
+                { $this->Data[$Key]["Vectors"][] = array("Type"=>"R", "Angle"=>$Angle%360, "Force"=>$Force); }
470 470
               }
471 471
             }
472 472
           }
473 473
 
474 474
          /* Attraction vectors */
475
-         if ( isset($Settings["Connections"]) )
475
+         if (isset($Settings["Connections"]))
476 476
           {
477
-           foreach($Settings["Connections"] as $ID => $NodeID)
477
+           foreach ($Settings["Connections"] as $ID => $NodeID)
478 478
             {
479
-             if ( isset($this->Data[$NodeID]) )
479
+             if (isset($this->Data[$NodeID]))
480 480
               {
481 481
                $X2 = $this->Data[$NodeID]["X"];
482 482
                $Y2 = $this->Data[$NodeID]["Y"];
483 483
                $FreeZone = $this->Data[$Key2]["FreeZone"];
484 484
 
485
-               $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
486
-               $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2);
485
+               $Distance = $this->getDistance($X1, $Y1, $X2, $Y2);
486
+               $Angle    = $this->getAngle($X1, $Y1, $X2, $Y2);
487 487
 
488
-               if ( $Distance > $FreeZone )
489
-                $Force = log(($Distance-$FreeZone)+1);
488
+               if ($Distance > $FreeZone)
489
+                $Force = log(($Distance - $FreeZone) + 1);
490 490
                else
491
-                { $Force = log(($FreeZone-$Distance)+1); ($Angle = $Angle + 180); }
491
+                { $Force = log(($FreeZone - $Distance) + 1); ($Angle = $Angle + 180); }
492 492
 
493
-               if ( $Force > 1 )
494
-                $this->Data[$Key]["Vectors"][] = array("Type"=>"A","Angle"=>$Angle % 360,"Force"=>$Force);
493
+               if ($Force > 1)
494
+                $this->Data[$Key]["Vectors"][] = array("Type"=>"A", "Angle"=>$Angle%360, "Force"=>$Force);
495 495
               }
496 496
             }
497 497
           }
@@ -499,22 +499,22 @@  discard block
 block discarded – undo
499 499
       }
500 500
 
501 501
      /* Move the nodes accoding to the vectors */
502
-     foreach($this->Data as $Key => $Settings)
502
+     foreach ($this->Data as $Key => $Settings)
503 503
       {
504 504
        $X = $Settings["X"];
505 505
        $Y = $Settings["Y"];
506 506
 
507
-       if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
507
+       if (isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL)
508 508
         {
509
-         foreach($Settings["Vectors"] as $ID => $Vector)
509
+         foreach ($Settings["Vectors"] as $ID => $Vector)
510 510
           {
511 511
            $Type  = $Vector["Type"];
512 512
            $Force = $Vector["Force"];
513 513
            $Angle = $Vector["Angle"];
514 514
            $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
515 515
 
516
-           $X = cos(deg2rad($Angle)) * $Force * $Factor + $X;
517
-           $Y = sin(deg2rad($Angle)) * $Force * $Factor + $Y;
516
+           $X = cos(deg2rad($Angle))*$Force*$Factor + $X;
517
+           $Y = sin(deg2rad($Angle))*$Force*$Factor + $Y;
518 518
           }
519 519
         }
520 520
 
@@ -526,15 +526,15 @@  discard block
 block discarded – undo
526 526
    function lastPass()
527 527
     {
528 528
      /* Put everything inside the graph area */
529
-     foreach($this->Data as $Key => $Settings)
529
+     foreach ($this->Data as $Key => $Settings)
530 530
       {
531 531
        $X = $Settings["X"];
532 532
        $Y = $Settings["Y"];
533 533
 
534
-       if ( $X < $this->X1 ) { $X = $this->X1; }
535
-       if ( $X > $this->X2 ) { $X = $this->X2; }
536
-       if ( $Y < $this->Y1 ) { $Y = $this->Y1; }
537
-       if ( $Y > $this->Y2 ) { $Y = $this->Y2; }
534
+       if ($X < $this->X1) { $X = $this->X1; }
535
+       if ($X > $this->X2) { $X = $this->X2; }
536
+       if ($Y < $this->Y1) { $Y = $this->Y1; }
537
+       if ($Y > $this->Y2) { $Y = $this->Y2; }
538 538
 
539 539
        $this->Data[$Key]["X"] = $X;
540 540
        $this->Data[$Key]["Y"] = $Y;
@@ -542,21 +542,21 @@  discard block
 block discarded – undo
542 542
 
543 543
      /* Dump all links */
544 544
      $Links = "";
545
-     foreach($this->Data as $Key => $Settings)
545
+     foreach ($this->Data as $Key => $Settings)
546 546
       {
547 547
        $X1 = $Settings["X"];
548 548
        $Y1 = $Settings["Y"];
549 549
 
550
-       if ( isset($Settings["Connections"]) )
550
+       if (isset($Settings["Connections"]))
551 551
         {
552 552
          foreach ($Settings["Connections"] as $ID => $NodeID)
553 553
           {
554
-           if ( isset($this->Data[$NodeID]) )
554
+           if (isset($this->Data[$NodeID]))
555 555
             {
556 556
              $X2 = $this->Data[$NodeID]["X"];
557 557
              $Y2 = $this->Data[$NodeID]["Y"];
558 558
 
559
-             $Links[] = array("X1"=>$X1,"Y1"=>$Y1,"X2"=>$X2,"Y2"=>$Y2,"Source"=>$Settings["Name"],"Destination"=>$this->Data[$NodeID]["Name"]);
559
+             $Links[] = array("X1"=>$X1, "Y1"=>$Y1, "X2"=>$X2, "Y2"=>$Y2, "Source"=>$Settings["Name"], "Destination"=>$this->Data[$NodeID]["Name"]);
560 560
             }
561 561
           }
562 562
         }
@@ -564,29 +564,29 @@  discard block
 block discarded – undo
564 564
 
565 565
      /* Check collisions */
566 566
      $Conflicts = 0;
567
-     foreach($this->Data as $Key => $Settings)
567
+     foreach ($this->Data as $Key => $Settings)
568 568
       {
569 569
        $X1 = $Settings["X"];
570 570
        $Y1 = $Settings["Y"];
571 571
 
572
-       if ( isset($Settings["Connections"]) )
572
+       if (isset($Settings["Connections"]))
573 573
         {
574 574
          foreach ($Settings["Connections"] as $ID => $NodeID)
575 575
           {
576
-           if ( isset($this->Data[$NodeID]) )
576
+           if (isset($this->Data[$NodeID]))
577 577
             {
578 578
              $X2 = $this->Data[$NodeID]["X"];
579 579
              $Y2 = $this->Data[$NodeID]["Y"];
580 580
 
581
-             foreach($Links as $IDLinks => $Link)
581
+             foreach ($Links as $IDLinks => $Link)
582 582
               {
583 583
                $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
584 584
 
585
-               if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
585
+               if (!($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4))
586 586
                 {
587
-                 if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
587
+                 if ($this->intersect($X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4))
588 588
                   {
589
-                   if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
589
+                   if ($Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"])
590 590
                     { $Conflicts++; }
591 591
                   }
592 592
                 }
@@ -602,31 +602,31 @@  discard block
 block discarded – undo
602 602
    function center()
603 603
     {
604 604
      /* Determine the real center */
605
-     $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606
-     $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
605
+     $TargetCenterX = ($this->X2 - $this->X1)/2 + $this->X1;
606
+     $TargetCenterY = ($this->Y2 - $this->Y1)/2 + $this->Y1;
607 607
 
608 608
      /* Get current boundaries */
609 609
      $XMin = $this->X2; $XMax = $this->X1;
610 610
      $YMin = $this->Y2; $YMax = $this->Y1;
611
-     foreach($this->Data as $Key => $Settings)
611
+     foreach ($this->Data as $Key => $Settings)
612 612
       {
613 613
        $X = $Settings["X"];
614 614
        $Y = $Settings["Y"];
615 615
 
616
-       if ( $X < $XMin) { $XMin = $X; }
617
-       if ( $X > $XMax) { $XMax = $X; }
618
-       if ( $Y < $YMin) { $YMin = $Y; }
619
-       if ( $Y > $YMax) { $YMax = $Y; }
616
+       if ($X < $XMin) { $XMin = $X; }
617
+       if ($X > $XMax) { $XMax = $X; }
618
+       if ($Y < $YMin) { $YMin = $Y; }
619
+       if ($Y > $YMax) { $YMax = $Y; }
620 620
       }
621
-     $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
622
-     $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;
621
+     $CurrentCenterX = ($XMax - $XMin)/2 + $XMin;
622
+     $CurrentCenterY = ($YMax - $YMin)/2 + $YMin;
623 623
 
624 624
      /* Compute the offset to apply */
625 625
      $XOffset = $TargetCenterX - $CurrentCenterX;
626 626
      $YOffset = $TargetCenterY - $CurrentCenterY;
627 627
 
628 628
      /* Correct the points position */
629
-     foreach($this->Data as $Key => $Settings)
629
+     foreach ($this->Data as $Key => $Settings)
630 630
       {
631 631
        $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632 632
        $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
@@ -634,20 +634,20 @@  discard block
 block discarded – undo
634 634
     }
635 635
 
636 636
    /* Create the encoded string */
637
-   function drawSpring($Object,$Settings="")
637
+   function drawSpring($Object, $Settings = "")
638 638
     {
639 639
      $this->pChartObject = $Object;
640 640
 
641
-     $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
-     $Retries			= isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
641
+     $Pass = isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
+     $Retries = isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
643 643
      $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644 644
      $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645
-     $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
645
+     $this->RingSize = isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646 646
      $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
-     $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
647
+     $DrawQuietZone = isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648 648
      $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
649 649
      $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650
-     $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
650
+     $Algorithm = isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
651 651
 
652 652
      $FontSize		= $Object->FontSize;
653 653
      $this->X1		= $Object->GraphAreaX1;
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
      $this->Y2		= $Object->GraphAreaY2;
657 657
 
658 658
      $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
-     while ($Conflicts != 0 && $Jobs < $Retries )
659
+     while ($Conflicts != 0 && $Jobs < $Retries)
660 660
       {
661 661
        $Jobs++;
662 662
 
@@ -664,70 +664,70 @@  discard block
 block discarded – undo
664 664
        $this->firstPass($Algorithm);
665 665
 
666 666
        /* Apply the vectors */
667
-       if ( $Pass > 0 ) 
667
+       if ($Pass > 0) 
668 668
         {
669
-         for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
669
+         for ($i = 0; $i <= $Pass; $i++) { $this->doPass(); }
670 670
         }
671 671
 
672 672
        $Conflicts = $this->lastPass();
673
-       if ( $this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"] )
673
+       if ($this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"])
674 674
         { $this->History["MinimumConflicts"] = $Conflicts; $this->History["Result"] = $this->Data; }
675 675
       }
676 676
 
677 677
      $Conflicts  = $this->History["MinimumConflicts"];
678 678
      $this->Data = $this->History["Result"];
679 679
 
680
-     if ( $CenterGraph ) { $this->center(); }
680
+     if ($CenterGraph) { $this->center(); }
681 681
 
682 682
      /* Draw the connections */
683 683
      $Drawn = "";
684
-     foreach($this->Data as $Key => $Settings)
684
+     foreach ($this->Data as $Key => $Settings)
685 685
       {
686 686
        $X	= $Settings["X"];
687 687
        $Y	= $Settings["Y"];
688 688
 
689
-       if ( isset($Settings["Connections"]) )
689
+       if (isset($Settings["Connections"]))
690 690
         {
691 691
          foreach ($Settings["Connections"] as $ID => $NodeID)
692 692
           {
693
-           if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694
-           if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
693
+           if (!isset($Drawn[$Key])) { $Drawn[$Key] = ""; }
694
+           if (!isset($Drawn[$NodeID])) { $Drawn[$NodeID] = ""; }
695 695
 
696
-           if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
696
+           if (isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]))
697 697
             {
698
-             $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
698
+             $Color = array("R"=>$this->Default["LinkR"], "G"=>$this->Default["LinkG"], "B"=>$this->Default["LinkB"], "Alpha"=>$this->Default["Alpha"]);
699 699
 
700
-             if ( $this->Links != "" )
700
+             if ($this->Links != "")
701 701
               {
702
-               if ( isset($this->Links[$Key][$NodeID]["R"]) )
703
-                { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"],"G"=>$this->Links[$Key][$NodeID]["G"],"B"=>$this->Links[$Key][$NodeID]["B"],"Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); }
702
+               if (isset($this->Links[$Key][$NodeID]["R"]))
703
+                { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"], "G"=>$this->Links[$Key][$NodeID]["G"], "B"=>$this->Links[$Key][$NodeID]["B"], "Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); }
704 704
 
705
-               if ( isset($this->Links[$Key][$NodeID]["Ticks"]) )
705
+               if (isset($this->Links[$Key][$NodeID]["Ticks"]))
706 706
                  { $Color["Ticks"] = $this->Links[$Key][$NodeID]["Ticks"]; }
707 707
               }
708 708
 
709 709
              $X2 = $this->Data[$NodeID]["X"];
710 710
              $Y2 = $this->Data[$NodeID]["Y"];
711
-             $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
711
+             $this->pChartObject->drawLine($X, $Y, $X2, $Y2, $Color);
712 712
              $Drawn[$Key][$NodeID] = TRUE;
713 713
 
714
-             if ( isset($this->Links) && $this->Links != "" )
714
+             if (isset($this->Links) && $this->Links != "")
715 715
               {
716
-               if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
716
+               if (isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]))
717 717
                 {
718 718
                  $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719 719
                  $TxtX  = ($X2 - $X)/2 + $X;
720 720
                  $TxtY  = ($Y2 - $Y)/2 + $Y;
721 721
 
722
-                 if ( $X <= $X2 )
723
-                  $Angle = (360-$this->getAngle($X,$Y,$X2,$Y2)) % 360;
722
+                 if ($X <= $X2)
723
+                  $Angle = (360 - $this->getAngle($X, $Y, $X2, $Y2))%360;
724 724
                  else
725
-                  $Angle = (360-$this->getAngle($X2,$Y2,$X,$Y)) % 360;
725
+                  $Angle = (360 - $this->getAngle($X2, $Y2, $X, $Y))%360;
726 726
 
727 727
                  $Settings          = $Color;
728 728
                  $Settings["Angle"] = $Angle;
729 729
                  $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
730
-                 $this->pChartObject->drawText($TxtX,$TxtY,$Name,$Settings);
730
+                 $this->pChartObject->drawText($TxtX, $TxtY, $Name, $Settings);
731 731
                 }
732 732
               }
733 733
             }
@@ -736,59 +736,59 @@  discard block
 block discarded – undo
736 736
       }
737 737
 
738 738
      /* Draw the quiet zones */
739
-     if ( $DrawQuietZone )
739
+     if ($DrawQuietZone)
740 740
       {
741
-       foreach($this->Data as $Key => $Settings)
741
+       foreach ($this->Data as $Key => $Settings)
742 742
         {
743 743
          $X	 = $Settings["X"];
744 744
          $Y	 = $Settings["Y"];
745 745
          $FreeZone = $Settings["FreeZone"];
746 746
 
747
-         $this->pChartObject->drawFilledCircle($X,$Y,$FreeZone,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>2));
747
+         $this->pChartObject->drawFilledCircle($X, $Y, $FreeZone, array("R"=>0, "G"=>0, "B"=>0, "Alpha"=>2));
748 748
         }
749 749
       }
750 750
 
751 751
 
752 752
      /* Draw the nodes */
753
-     foreach($this->Data as $Key => $Settings)
753
+     foreach ($this->Data as $Key => $Settings)
754 754
       {
755 755
        $X	 = $Settings["X"];
756 756
        $Y	 = $Settings["Y"];
757
-       $Name	 = $Settings["Name"];
757
+       $Name = $Settings["Name"];
758 758
        $FreeZone = $Settings["FreeZone"];
759 759
        $Shape    = $Settings["Shape"];
760 760
        $Size     = $Settings["Size"];
761 761
 
762
-       $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
762
+       $Color = array("R"=>$Settings["R"], "G"=>$Settings["G"], "B"=>$Settings["B"], "Alpha"=>$Settings["Alpha"], "BorderR"=>$Settings["BorderR"], "BorderG"=>$Settings["BorderG"], "BorderB"=>$Settings["BorderB"], "BorderApha"=>$Settings["BorderAlpha"]);
763 763
 
764
-       if ( $Shape == NODE_SHAPE_CIRCLE )
764
+       if ($Shape == NODE_SHAPE_CIRCLE)
765 765
         {
766
-         $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
766
+         $this->pChartObject->drawFilledCircle($X, $Y, $Size, $Color);
767 767
         }
768
-       elseif ( $Shape == NODE_SHAPE_TRIANGLE )
768
+       elseif ($Shape == NODE_SHAPE_TRIANGLE)
769 769
         {
770 770
          $Points = "";
771
-         $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772
-         $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773
-         $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774
-         $this->pChartObject->drawPolygon($Points,$Color);
771
+         $Points[] = cos(deg2rad(270))*$Size + $X; $Points[] = sin(deg2rad(270))*$Size + $Y;
772
+         $Points[] = cos(deg2rad(45))*$Size + $X; $Points[] = sin(deg2rad(45))*$Size + $Y;
773
+         $Points[] = cos(deg2rad(135))*$Size + $X; $Points[] = sin(deg2rad(135))*$Size + $Y;
774
+         $this->pChartObject->drawPolygon($Points, $Color);
775 775
         }
776
-       elseif ( $Shape == NODE_SHAPE_SQUARE )
776
+       elseif ($Shape == NODE_SHAPE_SQUARE)
777 777
         {
778
-         $Offset = $Size/2; $Size = $Size / 2;
779
-         $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
778
+         $Offset = $Size/2; $Size = $Size/2;
779
+         $this->pChartObject->drawFilledRectangle($X - $Offset, $Y - $Offset, $X + $Offset, $Y + $Offset, $Color);
780 780
         }
781 781
 
782
-       if ( $Name != "" )
782
+       if ($Name != "")
783 783
         {
784
-         $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
784
+         $LabelOptions = array("R"=>$this->Labels["R"], "G"=>$this->Labels["G"], "B"=>$this->Labels["B"], "Alpha"=>$this->Labels["Alpha"]);
785 785
 
786
-         if ( $this->Labels["Type"] == LABEL_LIGHT )
786
+         if ($this->Labels["Type"] == LABEL_LIGHT)
787 787
           {
788 788
            $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789
-           $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
789
+           $this->pChartObject->drawText($X, $Y, $Name, $LabelOptions);
790 790
           }
791
-         elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
791
+         elseif ($this->Labels["Type"] == LABEL_CLASSIC)
792 792
           {
793 793
            $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794 794
            $LabelOptions["DrawBox"]       = TRUE;
@@ -798,67 +798,67 @@  discard block
 block discarded – undo
798 798
            $LabelOptions["BoxRounded"]    = TRUE;
799 799
            $LabelOptions["NoShadow"]      = TRUE;
800 800
 
801
-           $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
801
+           $this->pChartObject->drawText($X, $Y + $Size + $TextPadding, $Name, $LabelOptions);
802 802
           }
803 803
         }
804 804
       }
805 805
 
806 806
      /* Draw the vectors */
807
-     if ( $DrawVectors )
807
+     if ($DrawVectors)
808 808
       {
809
-       foreach($this->Data as $Key => $Settings)
809
+       foreach ($this->Data as $Key => $Settings)
810 810
         {
811 811
          $X1 = $Settings["X"];
812 812
          $Y1 = $Settings["Y"];
813 813
 
814
-         if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
814
+         if (isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL)
815 815
           {
816
-           foreach($Settings["Vectors"] as $ID => $Vector)
816
+           foreach ($Settings["Vectors"] as $ID => $Vector)
817 817
             {
818 818
              $Type  = $Vector["Type"];
819 819
              $Force = $Vector["Force"];
820 820
              $Angle = $Vector["Angle"];
821 821
              $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
822
-             $Color  = $Type == "A" ? array("FillR"=>255,"FillG"=>0,"FillB"=>0) : array("FillR"=>0,"FillG"=>255,"FillB"=>0);
822
+             $Color  = $Type == "A" ? array("FillR"=>255, "FillG"=>0, "FillB"=>0) : array("FillR"=>0, "FillG"=>255, "FillB"=>0);
823 823
 
824
-             $X2 = cos(deg2rad($Angle)) * $Force * $Factor + $X1;
825
-             $Y2 = sin(deg2rad($Angle)) * $Force * $Factor + $Y1;
824
+             $X2 = cos(deg2rad($Angle))*$Force*$Factor + $X1;
825
+             $Y2 = sin(deg2rad($Angle))*$Force*$Factor + $Y1;
826 826
 
827
-             $this->pChartObject->drawArrow($X1,$Y1,$X2,$Y2,$Color);
827
+             $this->pChartObject->drawArrow($X1, $Y1, $X2, $Y2, $Color);
828 828
             }
829 829
           }
830 830
         }
831 831
       }
832 832
 
833
-     return(array("Pass"=>$Jobs,"Conflicts"=>$Conflicts));
833
+     return(array("Pass"=>$Jobs, "Conflicts"=>$Conflicts));
834 834
     }
835 835
 
836 836
    /* Return the distance between two points */
837
-   function getDistance($X1,$Y1,$X2,$Y2)
838
-    { return (sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1))); }
837
+   function getDistance($X1, $Y1, $X2, $Y2)
838
+    { return (sqrt(($X2 - $X1)*($X2 - $X1) + ($Y2 - $Y1)*($Y2 - $Y1))); }
839 839
 
840 840
    /* Return the angle made by a line and the X axis */
841
-   function getAngle($X1,$Y1,$X2,$Y2)
841
+   function getAngle($X1, $Y1, $X2, $Y2)
842 842
     {
843
-     $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844
-     if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
843
+     $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1; $Angle = rad2deg(atan2($Opposite, $Adjacent));
844
+     if ($Angle > 0) { return($Angle); } else { return(360 - abs($Angle)); }
845 845
     }
846 846
 
847
-   function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
847
+   function intersect($X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4)
848 848
     {
849
-     $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850
-     $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
849
+     $A = (($X3*$Y4 - $X4*$Y3)*($X1 - $X2) - ($X1*$Y2 - $X2*$Y1)*($X3 - $X4));
850
+     $B = (($Y1 - $Y2)*($X3 - $X4) - ($Y3 - $Y4)*($X1 - $X2));
851 851
 
852
-     if ( $B == 0 ) { return(FALSE); }
853
-     $Xi = $A / $B;
852
+     if ($B == 0) { return(FALSE); }
853
+     $Xi = $A/$B;
854 854
 
855 855
      $C = ($X1 - $X2);
856
-     if ( $C == 0 ) { return(FALSE); }
857
-     $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
856
+     if ($C == 0) { return(FALSE); }
857
+     $Yi = $Xi*(($Y1 - $Y2)/$C) + (($X1*$Y2 - $X2*$Y1)/$C);
858 858
 
859
-     if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
859
+     if ($Xi >= min($X1, $X2) && $Xi >= min($X3, $X4) && $Xi <= max($X1, $X2) && $Xi <= max($X3, $X4))
860 860
       {
861
-       if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
861
+       if ($Yi >= min($Y1, $Y2) && $Yi >= min($Y3, $Y4) && $Yi <= max($Y1, $Y2) && $Yi <= max($Y3, $Y4))
862 862
         { return(TRUE); }
863 863
       }
864 864
 
Please login to merge, or discard this patch.
Braces   +112 added lines, -223 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
  define("LABEL_LIGHT"		, 690032);
30 30
 
31 31
  /* pSpring class definition */
32
- class pSpring
33
-  {
32
+ class pSpring {
34 33
    var $History;
35 34
    var $pChartObject;
36 35
    var $Data;
@@ -43,8 +42,7 @@  discard block
 block discarded – undo
43 42
    var $Labels;
44 43
 
45 44
    /* Class creator */
46
-   function pSpring()
47
-    {
45
+   function pSpring() {
48 46
      /* Initialise data arrays */
49 47
      $this->Data = "";
50 48
      $this->Links = "";
@@ -83,8 +81,7 @@  discard block
 block discarded – undo
83 81
     }
84 82
 
85 83
    /* Set default links options */
86
-   function setLinkDefaults($Settings="")
87
-    {
84
+   function setLinkDefaults($Settings="") {
88 85
      if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89 86
      if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90 87
      if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
@@ -92,8 +89,7 @@  discard block
 block discarded – undo
92 89
     }
93 90
 
94 91
    /* Set default links options */
95
-   function setLabelsSettings($Settings="")
96
-    {
92
+   function setLabelsSettings($Settings="") {
97 93
      if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98 94
      if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99 95
      if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
@@ -102,22 +98,18 @@  discard block
 block discarded – undo
102 98
     }
103 99
 
104 100
    /* Auto compute the FreeZone size based on the number of connections */
105
-   function autoFreeZone()
106
-    {
101
+   function autoFreeZone() {
107 102
      /* Check connections reciprocity */
108
-     foreach($this->Data as $Key => $Settings)
109
-      {
103
+     foreach($this->Data as $Key => $Settings) {
110 104
        if ( isset($Settings["Connections"]) )
111
-        { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; }
112
-       else
105
+        { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; } else
113 106
         { $this->Data[$Key]["FreeZone"] = 20; }
114 107
       }
115 108
 
116 109
     }
117 110
 
118 111
    /* Set link properties */
119
-   function linkProperties($FromNode,$ToNode,$Settings)
120
-    {
112
+   function linkProperties($FromNode,$ToNode,$Settings) {
121 113
      if ( !isset($this->Data[$FromNode]) ) { return(0); }
122 114
      if ( !isset($this->Data[$ToNode]) )   { return(0); }
123 115
 
@@ -136,8 +128,7 @@  discard block
 block discarded – undo
136 128
      $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
137 129
     }
138 130
 
139
-   function setNodeDefaults($Settings="")
140
-    {
131
+   function setNodeDefaults($Settings="") {
141 132
      if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142 133
      if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143 134
      if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
@@ -158,8 +149,7 @@  discard block
 block discarded – undo
158 149
     }
159 150
 
160 151
    /* Add a node */
161
-   function addNode($NodeID,$Settings="")
162
-    {
152
+   function addNode($NodeID,$Settings="") {
163 153
      /* if the node already exists, ignore */
164 154
      if (isset($this->Data[$NodeID])) { return(0); }
165 155
 
@@ -196,27 +186,21 @@  discard block
 block discarded – undo
196 186
      $this->Data[$NodeID]["Size"]		= $Size;
197 187
      $this->Data[$NodeID]["Shape"]		= $Shape;
198 188
      $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
-     if ( $Connections != NULL )
200
-      {
201
-       if ( is_array($Connections ) )
202
-        {
203
-         foreach($Connections as $Key => $Value)
204
-          $this->Data[$NodeID]["Connections"][] = $Value;
205
-        }
206
-       else
189
+     if ( $Connections != NULL ) {
190
+       if ( is_array($Connections ) ) {
191
+         foreach($Connections as $Key => $Value) {
192
+                   $this->Data[$NodeID]["Connections"][] = $Value;
193
+         }
194
+        } else
207 195
         $this->Data[$NodeID]["Connections"][] = $Connections;
208 196
       }
209 197
     }
210 198
 
211 199
    /* Set color attribute for a list of nodes */
212
-   function setNodesColor($Nodes,$Settings="")
213
-    {
214
-     if ( is_array($Nodes) )
215
-      {
216
-       foreach ($Nodes as $Key => $NodeID)
217
-        {
218
-         if (isset($this->Data[$NodeID]) )
219
-          {
200
+   function setNodesColor($Nodes,$Settings="") {
201
+     if ( is_array($Nodes) ) {
202
+       foreach ($Nodes as $Key => $NodeID) {
203
+         if (isset($this->Data[$NodeID]) ) {
220 204
            if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221 205
            if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222 206
            if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
@@ -228,9 +212,7 @@  discard block
 block discarded – undo
228 212
            if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229 213
           }
230 214
         }
231
-      }
232
-     else
233
-      {
215
+      } else {
234 216
        if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235 217
        if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236 218
        if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
@@ -248,25 +230,19 @@  discard block
 block discarded – undo
248 230
     { return($this->Data); }
249 231
 
250 232
    /* Check if a connection exists and create it if required */
251
-   function checkConnection($SourceID, $TargetID)
252
-    {
253
-     if ( isset($this->Data[$SourceID]["Connections"]) )
254
-      {
233
+   function checkConnection($SourceID, $TargetID) {
234
+     if ( isset($this->Data[$SourceID]["Connections"]) ) {
255 235
        foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
256 236
         { if ( $TargetID == $ConnectionID ) { return(TRUE); } }
257 237
       }
258 238
      $this->Data[$SourceID]["Connections"][] = $TargetID;
259 239
     }
260 240
    /* Get the median linked nodes position */
261
-   function getMedianOffset($Key,$X,$Y)
262
-    {
241
+   function getMedianOffset($Key,$X,$Y) {
263 242
      $Cpt = 1;
264
-     if ( isset($this->Data[$Key]["Connections"]) )
265
-      {
266
-       foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
267
-        {
268
-         if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
269
-          {
243
+     if ( isset($this->Data[$Key]["Connections"]) ) {
244
+       foreach($this->Data[$Key]["Connections"] as $ID => $NodeID) {
245
+         if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) ) {
270 246
            $X = $X + $this->Data[$NodeID]["X"];
271 247
            $Y = $Y + $this->Data[$NodeID]["Y"];
272 248
            $Cpt++;
@@ -277,13 +253,11 @@  discard block
 block discarded – undo
277 253
     }
278 254
 
279 255
    /* Return the ID of the attached partner with the biggest weight */
280
-   function getBiggestPartner($Key)
281
-    {
256
+   function getBiggestPartner($Key) {
282 257
      if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
283 258
 
284 259
      $MaxWeight = 0; $Result = "";
285
-     foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
286
-      {
260
+     foreach($this->Data[$Key]["Connections"] as $Key => $PeerID) {
287 261
        if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
288 262
         { $MaxWeight = $this->Data[$PeerID]["Weight"]; $Result = $PeerID; }
289 263
       }
@@ -291,18 +265,16 @@  discard block
 block discarded – undo
291 265
     }
292 266
 
293 267
    /* Do the initial node positions computing pass */
294
-   function firstPass($Algorithm)
295
-    {
268
+   function firstPass($Algorithm) {
296 269
      $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297 270
      $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
298 271
 
299 272
      /* Check connections reciprocity */
300
-     foreach($this->Data as $Key => $Settings)
301
-      {
302
-       if ( isset($Settings["Connections"]) )
303
-        {
304
-         foreach($Settings["Connections"] as $ID => $ConnectionID)
305
-          $this->checkConnection($ConnectionID,$Key);
273
+     foreach($this->Data as $Key => $Settings) {
274
+       if ( isset($Settings["Connections"]) ) {
275
+         foreach($Settings["Connections"] as $ID => $ConnectionID) {
276
+                   $this->checkConnection($ConnectionID,$Key);
277
+         }
306 278
         }
307 279
       }
308 280
 
@@ -313,16 +285,12 @@  discard block
 block discarded – undo
313 285
      foreach($this->Data as $Key => $Settings)
314 286
       { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
315 287
 
316
-     if ( $Algorithm == ALGORITHM_WEIGHTED )
317
-      {
318
-       foreach($this->Data as $Key => $Settings)
319
-        {
288
+     if ( $Algorithm == ALGORITHM_WEIGHTED ) {
289
+       foreach($this->Data as $Key => $Settings) {
320 290
          if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
322
-          {
291
+         if ( $Settings["Type"] == NODE_TYPE_FREE ) {
323 292
            if ( isset($Settings["Connections"]) )
324
-            { $Connections = count($Settings["Connections"]); }
325
-           else
293
+            { $Connections = count($Settings["Connections"]); } else
326 294
             { $Connections = 0; }
327 295
 
328 296
            $Ring  = $MaxConnections - $Connections;
@@ -332,12 +300,9 @@  discard block
 block discarded – undo
332 300
            $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
333 301
           }
334 302
         }
335
-      }
336
-     elseif ( $Algorithm == ALGORITHM_CENTRAL )
337
-      {
303
+      } elseif ( $Algorithm == ALGORITHM_CENTRAL ) {
338 304
        /* Put a weight on each nodes */
339
-       foreach($this->Data as $Key => $Settings)
340
-        {
305
+       foreach($this->Data as $Key => $Settings) {
341 306
          if ( isset($Settings["Connections"]) )
342 307
           $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343 308
          else
@@ -345,33 +310,25 @@  discard block
 block discarded – undo
345 310
         }
346 311
 
347 312
        $MaxConnections = $MaxConnections + 1;
348
-       for($i=$MaxConnections;$i>=0;$i--)
349
-        {
350
-         foreach($this->Data as $Key => $Settings)
351
-          {
313
+       for($i=$MaxConnections;$i>=0;$i--) {
314
+         foreach($this->Data as $Key => $Settings) {
352 315
            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
354
-            {
316
+           if ( $Settings["Type"] == NODE_TYPE_FREE ) {
355 317
              if ( isset($Settings["Connections"]) )
356
-              { $Connections = count($Settings["Connections"]); }
357
-             else
318
+              { $Connections = count($Settings["Connections"]); } else
358 319
               { $Connections = 0; }
359 320
 
360
-             if ( $Connections == $i )
361
-              {
321
+             if ( $Connections == $i ) {
362 322
                $BiggestPartner = $this->getBiggestPartner($Key);
363
-               if ( $BiggestPartner != "" )
364
-                {
323
+               if ( $BiggestPartner != "" ) {
365 324
                  $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366 325
                  $Weight        = $this->Data[$BiggestPartner]["Weight"];
367 326
                  $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368 327
                  $Done          = FALSE; $Tries = 0;
369
-                 while (!$Done && $Tries <= $Weight*2)
370
-                  {
328
+                 while (!$Done && $Tries <= $Weight*2) {
371 329
                    $Tries++;
372 330
                    $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
-                   if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
374
-                    {
331
+                   if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) ) {
375 332
                      $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376 333
                      $Done = TRUE; 
377 334
                     }
@@ -389,24 +346,17 @@  discard block
 block discarded – undo
389 346
             }
390 347
           }
391 348
         }
392
-      }
393
-     elseif ( $Algorithm == ALGORITHM_CIRCULAR )
394
-      {
349
+      } elseif ( $Algorithm == ALGORITHM_CIRCULAR ) {
395 350
        $MaxConnections = $MaxConnections + 1;
396
-       for($i=$MaxConnections;$i>=0;$i--)
397
-        {
398
-         foreach($this->Data as $Key => $Settings)
399
-          {
351
+       for($i=$MaxConnections;$i>=0;$i--) {
352
+         foreach($this->Data as $Key => $Settings) {
400 353
            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
402
-            {
354
+           if ( $Settings["Type"] == NODE_TYPE_FREE ) {
403 355
              if ( isset($Settings["Connections"]) )
404
-              { $Connections = count($Settings["Connections"]); }
405
-             else
356
+              { $Connections = count($Settings["Connections"]); } else
406 357
               { $Connections = 0; }
407 358
 
408
-             if ( $Connections == $i )
409
-              {
359
+             if ( $Connections == $i ) {
410 360
                $Ring  = $MaxConnections - $Connections;
411 361
                $Angle = rand(0,360);
412 362
 
@@ -421,13 +371,9 @@  discard block
 block discarded – undo
421 371
             }
422 372
           }
423 373
         }
424
-      }
425
-     elseif ( $Algorithm == ALGORITHM_RANDOM )
426
-      {
427
-       foreach($this->Data as $Key => $Settings)
428
-        {
429
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
430
-          {
374
+      } elseif ( $Algorithm == ALGORITHM_RANDOM ) {
375
+       foreach($this->Data as $Key => $Settings) {
376
+         if ( $Settings["Type"] == NODE_TYPE_FREE ) {
431 377
            $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432 378
            $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
433 379
           }
@@ -437,23 +383,18 @@  discard block
 block discarded – undo
437 383
     }
438 384
 
439 385
    /* Compute one pass */
440
-   function doPass()
441
-    {
386
+   function doPass() {
442 387
      /* Compute vectors */
443
-     foreach($this->Data as $Key => $Settings)
444
-      {
445
-       if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
446
-        {
388
+     foreach($this->Data as $Key => $Settings) {
389
+       if ( $Settings["Type"] != NODE_TYPE_CENTRAL ) {
447 390
          unset($this->Data[$Key]["Vectors"]);
448 391
 
449 392
          $X1 = $Settings["X"];
450 393
          $Y1 = $Settings["Y"];
451 394
 
452 395
          /* Repulsion vectors */
453
-         foreach($this->Data as $Key2 => $Settings2)
454
-          {
455
-           if ( $Key != $Key2 )
456
-            {
396
+         foreach($this->Data as $Key2 => $Settings2) {
397
+           if ( $Key != $Key2 ) {
457 398
              $X2 = $this->Data[$Key2]["X"];
458 399
              $Y2 = $this->Data[$Key2]["Y"];
459 400
              $FreeZone = $this->Data[$Key2]["FreeZone"];
@@ -462,8 +403,7 @@  discard block
 block discarded – undo
462 403
              $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
463 404
 
464 405
              /* Nodes too close, repulsion occurs */
465
-             if ( $Distance < $FreeZone )
466
-              {
406
+             if ( $Distance < $FreeZone ) {
467 407
                $Force = log(pow(2,$FreeZone-$Distance));
468 408
                if ( $Force > 1 )
469 409
                 { $this->Data[$Key]["Vectors"][] = array("Type"=>"R","Angle"=>$Angle % 360,"Force"=>$Force); }
@@ -472,12 +412,9 @@  discard block
 block discarded – undo
472 412
           }
473 413
 
474 414
          /* Attraction vectors */
475
-         if ( isset($Settings["Connections"]) )
476
-          {
477
-           foreach($Settings["Connections"] as $ID => $NodeID)
478
-            {
479
-             if ( isset($this->Data[$NodeID]) )
480
-              {
415
+         if ( isset($Settings["Connections"]) ) {
416
+           foreach($Settings["Connections"] as $ID => $NodeID) {
417
+             if ( isset($this->Data[$NodeID]) ) {
481 418
                $X2 = $this->Data[$NodeID]["X"];
482 419
                $Y2 = $this->Data[$NodeID]["Y"];
483 420
                $FreeZone = $this->Data[$Key2]["FreeZone"];
@@ -499,15 +436,12 @@  discard block
 block discarded – undo
499 436
       }
500 437
 
501 438
      /* Move the nodes accoding to the vectors */
502
-     foreach($this->Data as $Key => $Settings)
503
-      {
439
+     foreach($this->Data as $Key => $Settings) {
504 440
        $X = $Settings["X"];
505 441
        $Y = $Settings["Y"];
506 442
 
507
-       if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
508
-        {
509
-         foreach($Settings["Vectors"] as $ID => $Vector)
510
-          {
443
+       if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) {
444
+         foreach($Settings["Vectors"] as $ID => $Vector) {
511 445
            $Type  = $Vector["Type"];
512 446
            $Force = $Vector["Force"];
513 447
            $Angle = $Vector["Angle"];
@@ -523,11 +457,9 @@  discard block
 block discarded – undo
523 457
       }
524 458
     }
525 459
 
526
-   function lastPass()
527
-    {
460
+   function lastPass() {
528 461
      /* Put everything inside the graph area */
529
-     foreach($this->Data as $Key => $Settings)
530
-      {
462
+     foreach($this->Data as $Key => $Settings) {
531 463
        $X = $Settings["X"];
532 464
        $Y = $Settings["Y"];
533 465
 
@@ -542,17 +474,13 @@  discard block
 block discarded – undo
542 474
 
543 475
      /* Dump all links */
544 476
      $Links = "";
545
-     foreach($this->Data as $Key => $Settings)
546
-      {
477
+     foreach($this->Data as $Key => $Settings) {
547 478
        $X1 = $Settings["X"];
548 479
        $Y1 = $Settings["Y"];
549 480
 
550
-       if ( isset($Settings["Connections"]) )
551
-        {
552
-         foreach ($Settings["Connections"] as $ID => $NodeID)
553
-          {
554
-           if ( isset($this->Data[$NodeID]) )
555
-            {
481
+       if ( isset($Settings["Connections"]) ) {
482
+         foreach ($Settings["Connections"] as $ID => $NodeID) {
483
+           if ( isset($this->Data[$NodeID]) ) {
556 484
              $X2 = $this->Data[$NodeID]["X"];
557 485
              $Y2 = $this->Data[$NodeID]["Y"];
558 486
 
@@ -564,28 +492,21 @@  discard block
 block discarded – undo
564 492
 
565 493
      /* Check collisions */
566 494
      $Conflicts = 0;
567
-     foreach($this->Data as $Key => $Settings)
568
-      {
495
+     foreach($this->Data as $Key => $Settings) {
569 496
        $X1 = $Settings["X"];
570 497
        $Y1 = $Settings["Y"];
571 498
 
572
-       if ( isset($Settings["Connections"]) )
573
-        {
574
-         foreach ($Settings["Connections"] as $ID => $NodeID)
575
-          {
576
-           if ( isset($this->Data[$NodeID]) )
577
-            {
499
+       if ( isset($Settings["Connections"]) ) {
500
+         foreach ($Settings["Connections"] as $ID => $NodeID) {
501
+           if ( isset($this->Data[$NodeID]) ) {
578 502
              $X2 = $this->Data[$NodeID]["X"];
579 503
              $Y2 = $this->Data[$NodeID]["Y"];
580 504
 
581
-             foreach($Links as $IDLinks => $Link)
582
-              {
505
+             foreach($Links as $IDLinks => $Link) {
583 506
                $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
584 507
 
585
-               if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
586
-                {
587
-                 if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
588
-                  {
508
+               if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) ) {
509
+                 if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) ) {
589 510
                    if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
590 511
                     { $Conflicts++; }
591 512
                   }
@@ -599,8 +520,7 @@  discard block
 block discarded – undo
599 520
     }
600 521
 
601 522
    /* Center the graph */
602
-   function center()
603
-    {
523
+   function center() {
604 524
      /* Determine the real center */
605 525
      $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606 526
      $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
@@ -608,8 +528,7 @@  discard block
 block discarded – undo
608 528
      /* Get current boundaries */
609 529
      $XMin = $this->X2; $XMax = $this->X1;
610 530
      $YMin = $this->Y2; $YMax = $this->Y1;
611
-     foreach($this->Data as $Key => $Settings)
612
-      {
531
+     foreach($this->Data as $Key => $Settings) {
613 532
        $X = $Settings["X"];
614 533
        $Y = $Settings["Y"];
615 534
 
@@ -626,16 +545,14 @@  discard block
 block discarded – undo
626 545
      $YOffset = $TargetCenterY - $CurrentCenterY;
627 546
 
628 547
      /* Correct the points position */
629
-     foreach($this->Data as $Key => $Settings)
630
-      {
548
+     foreach($this->Data as $Key => $Settings) {
631 549
        $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632 550
        $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
633 551
       }
634 552
     }
635 553
 
636 554
    /* Create the encoded string */
637
-   function drawSpring($Object,$Settings="")
638
-    {
555
+   function drawSpring($Object,$Settings="") {
639 556
      $this->pChartObject = $Object;
640 557
 
641 558
      $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
@@ -656,16 +573,14 @@  discard block
 block discarded – undo
656 573
      $this->Y2		= $Object->GraphAreaY2;
657 574
 
658 575
      $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
-     while ($Conflicts != 0 && $Jobs < $Retries )
660
-      {
576
+     while ($Conflicts != 0 && $Jobs < $Retries ) {
661 577
        $Jobs++;
662 578
 
663 579
        /* Compute the initial settings */
664 580
        $this->firstPass($Algorithm);
665 581
 
666 582
        /* Apply the vectors */
667
-       if ( $Pass > 0 ) 
668
-        {
583
+       if ( $Pass > 0 ) {
669 584
          for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
670 585
         }
671 586
 
@@ -681,24 +596,19 @@  discard block
 block discarded – undo
681 596
 
682 597
      /* Draw the connections */
683 598
      $Drawn = "";
684
-     foreach($this->Data as $Key => $Settings)
685
-      {
599
+     foreach($this->Data as $Key => $Settings) {
686 600
        $X	= $Settings["X"];
687 601
        $Y	= $Settings["Y"];
688 602
 
689
-       if ( isset($Settings["Connections"]) )
690
-        {
691
-         foreach ($Settings["Connections"] as $ID => $NodeID)
692
-          {
603
+       if ( isset($Settings["Connections"]) ) {
604
+         foreach ($Settings["Connections"] as $ID => $NodeID) {
693 605
            if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694 606
            if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
695 607
 
696
-           if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
697
-            {
608
+           if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) ) {
698 609
              $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
699 610
 
700
-             if ( $this->Links != "" )
701
-              {
611
+             if ( $this->Links != "" ) {
702 612
                if ( isset($this->Links[$Key][$NodeID]["R"]) )
703 613
                 { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"],"G"=>$this->Links[$Key][$NodeID]["G"],"B"=>$this->Links[$Key][$NodeID]["B"],"Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); }
704 614
 
@@ -711,10 +621,8 @@  discard block
 block discarded – undo
711 621
              $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712 622
              $Drawn[$Key][$NodeID] = TRUE;
713 623
 
714
-             if ( isset($this->Links) && $this->Links != "" )
715
-              {
716
-               if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
717
-                {
624
+             if ( isset($this->Links) && $this->Links != "" ) {
625
+               if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) ) {
718 626
                  $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719 627
                  $TxtX  = ($X2 - $X)/2 + $X;
720 628
                  $TxtY  = ($Y2 - $Y)/2 + $Y;
@@ -736,10 +644,8 @@  discard block
 block discarded – undo
736 644
       }
737 645
 
738 646
      /* Draw the quiet zones */
739
-     if ( $DrawQuietZone )
740
-      {
741
-       foreach($this->Data as $Key => $Settings)
742
-        {
647
+     if ( $DrawQuietZone ) {
648
+       foreach($this->Data as $Key => $Settings) {
743 649
          $X	 = $Settings["X"];
744 650
          $Y	 = $Settings["Y"];
745 651
          $FreeZone = $Settings["FreeZone"];
@@ -750,8 +656,7 @@  discard block
 block discarded – undo
750 656
 
751 657
 
752 658
      /* Draw the nodes */
753
-     foreach($this->Data as $Key => $Settings)
754
-      {
659
+     foreach($this->Data as $Key => $Settings) {
755 660
        $X	 = $Settings["X"];
756 661
        $Y	 = $Settings["Y"];
757 662
        $Name	 = $Settings["Name"];
@@ -761,35 +666,26 @@  discard block
 block discarded – undo
761 666
 
762 667
        $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
763 668
 
764
-       if ( $Shape == NODE_SHAPE_CIRCLE )
765
-        {
669
+       if ( $Shape == NODE_SHAPE_CIRCLE ) {
766 670
          $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
767
-        }
768
-       elseif ( $Shape == NODE_SHAPE_TRIANGLE )
769
-        {
671
+        } elseif ( $Shape == NODE_SHAPE_TRIANGLE ) {
770 672
          $Points = "";
771 673
          $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772 674
          $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773 675
          $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774 676
          $this->pChartObject->drawPolygon($Points,$Color);
775
-        }
776
-       elseif ( $Shape == NODE_SHAPE_SQUARE )
777
-        {
677
+        } elseif ( $Shape == NODE_SHAPE_SQUARE ) {
778 678
          $Offset = $Size/2; $Size = $Size / 2;
779 679
          $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
780 680
         }
781 681
 
782
-       if ( $Name != "" )
783
-        {
682
+       if ( $Name != "" ) {
784 683
          $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
785 684
 
786
-         if ( $this->Labels["Type"] == LABEL_LIGHT )
787
-          {
685
+         if ( $this->Labels["Type"] == LABEL_LIGHT ) {
788 686
            $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789 687
            $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
790
-          }
791
-         elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792
-          {
688
+          } elseif ( $this->Labels["Type"] == LABEL_CLASSIC ) {
793 689
            $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794 690
            $LabelOptions["DrawBox"]       = TRUE;
795 691
            $LabelOptions["BoxAlpha"]      = 50;
@@ -804,17 +700,13 @@  discard block
 block discarded – undo
804 700
       }
805 701
 
806 702
      /* Draw the vectors */
807
-     if ( $DrawVectors )
808
-      {
809
-       foreach($this->Data as $Key => $Settings)
810
-        {
703
+     if ( $DrawVectors ) {
704
+       foreach($this->Data as $Key => $Settings) {
811 705
          $X1 = $Settings["X"];
812 706
          $Y1 = $Settings["Y"];
813 707
 
814
-         if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
815
-          {
816
-           foreach($Settings["Vectors"] as $ID => $Vector)
817
-            {
708
+         if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL ) {
709
+           foreach($Settings["Vectors"] as $ID => $Vector) {
818 710
              $Type  = $Vector["Type"];
819 711
              $Force = $Vector["Force"];
820 712
              $Angle = $Vector["Angle"];
@@ -838,14 +730,12 @@  discard block
 block discarded – undo
838 730
     { return (sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1))); }
839 731
 
840 732
    /* Return the angle made by a line and the X axis */
841
-   function getAngle($X1,$Y1,$X2,$Y2)
842
-    {
733
+   function getAngle($X1,$Y1,$X2,$Y2) {
843 734
      $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844 735
      if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
845 736
     }
846 737
 
847
-   function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
848
-    {
738
+   function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) {
849 739
      $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850 740
      $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
851 741
 
@@ -856,8 +746,7 @@  discard block
 block discarded – undo
856 746
      if ( $C == 0 ) { return(FALSE); }
857 747
      $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
858 748
 
859
-     if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860
-      {
749
+     if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4)) {
861 750
        if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
862 751
         { return(TRUE); }
863 752
       }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      $this->Default["BorderG"]		= 0;
59 59
      $this->Default["BorderB"]		= 0;
60 60
      $this->Default["BorderAlpha"]	= 100;
61
-     $this->Default["Surrounding"]	= NULL;
61
+     $this->Default["Surrounding"]	= null;
62 62
      $this->Default["BackgroundR"]	= 255;
63 63
      $this->Default["BackgroundG"]	= 255;
64 64
      $this->Default["BackgroundB"]	= 255;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      $this->Labels["B"]			= 0;
80 80
      $this->Labels["Alpha"]		= 100;
81 81
 
82
-     $this->AutoComputeFreeZone         = FALSE;
82
+     $this->AutoComputeFreeZone         = false;
83 83
     }
84 84
 
85 85
    /* Set default links options */
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
      $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126 126
      $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127 127
      $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129
-     $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
128
+     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : null;
129
+     $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : null;
130 130
 
131 131
      $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132 132
      $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      if (isset($this->Data[$NodeID])) { return(0); }
165 165
 
166 166
      $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
-     $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
167
+     $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : null;
168 168
 
169 169
      $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170 170
      $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186 186
      $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187 187
 
188
-     if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
188
+     if ( $Surrounding != null ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189 189
 
190 190
      $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191 191
      $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
      $this->Data[$NodeID]["Size"]		= $Size;
197 197
      $this->Data[$NodeID]["Shape"]		= $Shape;
198 198
      $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
-     if ( $Connections != NULL )
199
+     if ( $Connections != null )
200 200
       {
201 201
        if ( is_array($Connections ) )
202 202
         {
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      if ( isset($this->Data[$SourceID]["Connections"]) )
254 254
       {
255 255
        foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
256
-        { if ( $TargetID == $ConnectionID ) { return(TRUE); } }
256
+        { if ( $TargetID == $ConnectionID ) { return(true); } }
257 257
       }
258 258
      $this->Data[$SourceID]["Connections"][] = $TargetID;
259 259
     }
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                  $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366 366
                  $Weight        = $this->Data[$BiggestPartner]["Weight"];
367 367
                  $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368
-                 $Done          = FALSE; $Tries = 0;
368
+                 $Done          = false; $Tries = 0;
369 369
                  while (!$Done && $Tries <= $Weight*2)
370 370
                   {
371 371
                    $Tries++;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
                    if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
374 374
                     {
375 375
                      $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376
-                     $Done = TRUE; 
376
+                     $Done = true; 
377 377
                     }
378 378
                   }
379 379
                  if ( !$Done )
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
      $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644 644
      $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645 645
      $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646
-     $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
-     $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648
-     $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
646
+     $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : false;
647
+     $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : false;
648
+     $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : true;
649 649
      $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650 650
      $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
651 651
 
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
              $X2 = $this->Data[$NodeID]["X"];
710 710
              $Y2 = $this->Data[$NodeID]["Y"];
711 711
              $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712
-             $Drawn[$Key][$NodeID] = TRUE;
712
+             $Drawn[$Key][$NodeID] = true;
713 713
 
714 714
              if ( isset($this->Links) && $this->Links != "" )
715 715
               {
@@ -791,12 +791,12 @@  discard block
 block discarded – undo
791 791
          elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792 792
           {
793 793
            $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794
-           $LabelOptions["DrawBox"]       = TRUE;
794
+           $LabelOptions["DrawBox"]       = true;
795 795
            $LabelOptions["BoxAlpha"]      = 50;
796 796
            $LabelOptions["BorderOffset"]  = 4;
797 797
            $LabelOptions["RoundedRadius"] = 3;
798
-           $LabelOptions["BoxRounded"]    = TRUE;
799
-           $LabelOptions["NoShadow"]      = TRUE;
798
+           $LabelOptions["BoxRounded"]    = true;
799
+           $LabelOptions["NoShadow"]      = true;
800 800
 
801 801
            $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
802 802
           }
@@ -849,20 +849,20 @@  discard block
 block discarded – undo
849 849
      $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850 850
      $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
851 851
 
852
-     if ( $B == 0 ) { return(FALSE); }
852
+     if ( $B == 0 ) { return(false); }
853 853
      $Xi = $A / $B;
854 854
 
855 855
      $C = ($X1 - $X2);
856
-     if ( $C == 0 ) { return(FALSE); }
856
+     if ( $C == 0 ) { return(false); }
857 857
      $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
858 858
 
859 859
      if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860 860
       {
861 861
        if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
862
-        { return(TRUE); }
862
+        { return(true); }
863 863
       }
864 864
 
865
-      return(FALSE);   
865
+      return(false);   
866 866
     }
867 867
   }
868 868
 ?>
869 869
\ No newline at end of file
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincuser/includes/boincuser.helpers.inc 5 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -26,6 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 /**
28 28
  * Get an image object from a given file and cck field
29
+ * @param string $field_name
30
+ * @param string $content_type
29 31
  */ 
30 32
 function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = FALSE) {
31 33
   $field = content_fields($field_name, $content_type); 
@@ -237,6 +239,7 @@  discard block
 block discarded – undo
237 239
 /**
238 240
  * Include BOINC code
239 241
  * The path from the BOINC html root must be included (e.g. user/file.php)
242
+ * @param string $file
240 243
  */
241 244
 function include_boinc($file) {
242 245
   if ($include_dir = boinc_get_path()) {
@@ -252,6 +255,7 @@  discard block
 block discarded – undo
252 255
 
253 256
 /**
254 257
  * Get the BOINC include path
258
+ * @return string
255 259
  */
256 260
 function boinc_get_path($type = 'root') {
257 261
   $dir = "boinc_{$type}_dir";
Please login to merge, or discard this patch.
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
12 12
 
13 13
 if (!function_exists('user_load_by_mail')) {
14
-  /**
15
-   * user_load_by_mail will be broken out of user_load
16
-   */
17
-  function user_load_by_mail($mail) {
14
+    /**
15
+     * user_load_by_mail will be broken out of user_load
16
+     */
17
+    function user_load_by_mail($mail) {
18 18
     return user_load(array('mail' => $mail));
19
-  }
19
+    }
20 20
 }
21 21
  
22 22
 
@@ -28,14 +28,14 @@  discard block
 block discarded – undo
28 28
  * Get an image object from a given file and cck field
29 29
  */ 
30 30
 function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = FALSE) {
31
-  $field = content_fields($field_name, $content_type); 
32
-  $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
33
-  if ($ignore_resolution) {
31
+    $field = content_fields($field_name, $content_type); 
32
+    $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
33
+    if ($ignore_resolution) {
34 34
     unset($validators['filefield_validate_image_resolution']);
35
-  }
36
-  $target_path = filefield_widget_file_path($field);
37
-  // Create the image object
38
-  return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE);
35
+    }
36
+    $target_path = filefield_widget_file_path($field);
37
+    // Create the image object
38
+    return field_file_save_file($image_path, $validators, $target_path, FILE_EXISTS_REPLACE);
39 39
 }
40 40
 
41 41
 
@@ -47,62 +47,62 @@  discard block
 block discarded – undo
47 47
  * 
48 48
  */
49 49
 function boincuser_check_credit_requirements() {
50
-  global $user;
51
-  if (!$user->uid) {
50
+    global $user;
51
+    if (!$user->uid) {
52 52
     return FALSE;
53
-  }
54
-  $account = user_load($user->uid);
55
-  $min_credit_to_post = variable_get('boinc_comment_min_credit', 0);
56
-  $community_role = array_search('community member', user_roles(true));
57
-  $unrestricted_role = array_search('verified contributor', user_roles(true));
53
+    }
54
+    $account = user_load($user->uid);
55
+    $min_credit_to_post = variable_get('boinc_comment_min_credit', 0);
56
+    $community_role = array_search('community member', user_roles(true));
57
+    $unrestricted_role = array_search('verified contributor', user_roles(true));
58 58
   
59
-  // Set user roles based on current penalty status and total credit
60
-  if ($account->boincuser_penalty_expiration > time()) {
59
+    // Set user roles based on current penalty status and total credit
60
+    if ($account->boincuser_penalty_expiration > time()) {
61 61
     drupal_set_message(bts(
62
-      'You are banned from community participation until @date',
63
-      array('@date' => format_date($account->boincuser_penalty_expiration))
62
+        'You are banned from community participation until @date',
63
+        array('@date' => format_date($account->boincuser_penalty_expiration))
64 64
     ), 'warning', FALSE);
65 65
     if (isset($account->roles[$community_role])) {
66
-      // Remove from the community role, if not already
67
-      unset($account->roles[$community_role]);
66
+        // Remove from the community role, if not already
67
+        unset($account->roles[$community_role]);
68 68
     }
69 69
     if (isset($account->roles[$unrestricted_role])) {
70
-      // Likewise, revoke extra privileges
71
-      unset($account->roles[$unrestricted_role]);
70
+        // Likewise, revoke extra privileges
71
+        unset($account->roles[$unrestricted_role]);
72 72
     }
73 73
     user_save($account, array('roles' => $account->roles));
74
-  }
75
-  elseif ($account->boincuser_total_credit >= $min_credit_to_post) {
74
+    }
75
+    elseif ($account->boincuser_total_credit >= $min_credit_to_post) {
76 76
     if (!isset($account->roles[$unrestricted_role])) {
77
-      // This user is now above the credit threshold and is allowed full
78
-      // privileges
79
-      $account->roles[$unrestricted_role] = 'verified contributor';
80
-      user_save($account, array('roles' => $account->roles));
77
+        // This user is now above the credit threshold and is allowed full
78
+        // privileges
79
+        $account->roles[$unrestricted_role] = 'verified contributor';
80
+        user_save($account, array('roles' => $account->roles));
81 81
     }
82
-  }
83
-  else {
82
+    }
83
+    else {
84 84
     drupal_set_message(bts(
85
-      'You must earn @count more credits to be able to post comments on this site.',
86
-      array('@count' => $min_credit_to_post - $account->boincuser_total_credit)
85
+        'You must earn @count more credits to be able to post comments on this site.',
86
+        array('@count' => $min_credit_to_post - $account->boincuser_total_credit)
87 87
     ), 'warning', FALSE);
88 88
     if (isset($account->roles[$unrestricted_role])) {
89
-      // Either the threshold has been raised or credits have been revoked;
90
-      // this user no longer qualifies for full privileges
91
-      unset($account->roles[$unrestricted_role]);
92
-      user_save($account, array('roles' => $account->roles));
89
+        // Either the threshold has been raised or credits have been revoked;
90
+        // this user no longer qualifies for full privileges
91
+        unset($account->roles[$unrestricted_role]);
92
+        user_save($account, array('roles' => $account->roles));
93
+    }
93 94
     }
94
-  }
95 95
 }
96 96
 
97 97
 /**
98 98
  * Get the cid of the first comment the user has not seen on a given node
99 99
  */
100 100
 function boincuser_get_first_unread_comment_id($nid, $uid = NULL) {
101
-  if (!$uid) {
101
+    if (!$uid) {
102 102
     global $user;
103 103
     $uid = $user->uid;
104
-  }
105
-  return db_result(db_query("
104
+    }
105
+    return db_result(db_query("
106 106
     SELECT c.cid
107 107
     FROM {node} n
108 108
     INNER JOIN {comments} c ON c.nid = n.nid
@@ -113,40 +113,40 @@  discard block
 block discarded – undo
113 113
     ORDER BY c.timestamp ASC
114 114
     LIMIT 1",
115 115
     $uid, $nid
116
-  ));
116
+    ));
117 117
 }
118 118
 
119 119
 /**
120 120
  * Choose and set the user of the day
121 121
  */
122 122
 function boincuser_select_user_of_the_day() {
123
-  // First get a list of users with recent credit
124
-  db_set_active('boinc');
125
-  $users_with_credit = db_query("
123
+    // First get a list of users with recent credit
124
+    db_set_active('boinc');
125
+    $users_with_credit = db_query("
126 126
     SELECT
127 127
       id
128 128
     FROM {user} u
129 129
     JOIN {profile} p ON p.userid = u.id
130 130
     WHERE expavg_credit > 1
131 131
     ORDER BY uotd_time ASC, RAND()"
132
-  );
133
-  db_set_active('default');
134
-  $active_users = array();
135
-  while ($user_with_credit = db_fetch_object($users_with_credit)) {
132
+    );
133
+    db_set_active('default');
134
+    $active_users = array();
135
+    while ($user_with_credit = db_fetch_object($users_with_credit)) {
136 136
     $active_users[] = $user_with_credit->id;
137
-  }
138
-  $active_users = implode(',', $active_users);
139
-  // Limit to users who have never been user of the day, if there are any
140
-  $never_been_picked = db_result(db_query("
137
+    }
138
+    $active_users = implode(',', $active_users);
139
+    // Limit to users who have never been user of the day, if there are any
140
+    $never_been_picked = db_result(db_query("
141 141
     SELECT COUNT(*)
142 142
     FROM {boincuser} bu
143 143
     WHERE bu.uotd_time = 0
144 144
     " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '')
145
-  ));
146
-  $new_uotd_uid = 0;
147
-  while (!$new_uotd_uid) {
145
+    ));
146
+    $new_uotd_uid = 0;
147
+    while (!$new_uotd_uid) {
148 148
     // Select a user of the day randomly from the pool
149
-      $new_uotd_uid = db_result(db_query("
149
+        $new_uotd_uid = db_result(db_query("
150 150
       SELECT
151 151
         n.uid
152 152
       FROM {node} n
@@ -160,56 +160,56 @@  discard block
 block discarded – undo
160 160
       LIMIT 1"
161 161
     ));
162 162
     if (!$new_uotd_uid) {
163
-      // Can't find a user with a profile; remove constraints on the pool
164
-      if ($never_been_picked) {
163
+        // Can't find a user with a profile; remove constraints on the pool
164
+        if ($never_been_picked) {
165 165
         // Allow users who have been previously selected
166 166
         $never_been_picked = FALSE;
167
-      }
168
-      elseif ($active_users) {
167
+        }
168
+        elseif ($active_users) {
169 169
         // Allow users who are not even active (getting desperate)
170 170
         $active_users = FALSE;
171
-      }
172
-      else {
171
+        }
172
+        else {
173 173
         // Process failed...
174 174
         return FALSE;
175
-      }
175
+        }
176 176
     }
177
-  }
178
-  $uotd = user_load($new_uotd_uid);
179
-  if ($uotd->uid) {
177
+    }
178
+    $uotd = user_load($new_uotd_uid);
179
+    if ($uotd->uid) {
180 180
     db_query("
181 181
       UPDATE {boincuser}
182 182
       SET uotd_time = '%d'
183 183
       WHERE uid = '%d'",
184
-      time(), $uotd->uid
184
+        time(), $uotd->uid
185 185
     );
186
-  }
187
-  return $uotd;
186
+    }
187
+    return $uotd;
188 188
 }
189 189
 
190 190
 /**
191 191
  * Determine the first unique name from a given base
192 192
  */
193 193
 function find_unique_name($requested_name) {
194
-  if (!$requested_name) {
194
+    if (!$requested_name) {
195 195
     // If the name is empty, set it
196 196
     $requested_name = 'anonymous';
197
-  }
198
-  $same_name_tally = 1;
199
-  $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $requested_name);
200
-  $name_length = strlen($cleaned_name);
201
-  if ($name_length > 56) {
197
+    }
198
+    $same_name_tally = 1;
199
+    $cleaned_name = preg_replace('/[^a-zA-Z0-9_ \.-]/s', '_', $requested_name);
200
+    $name_length = strlen($cleaned_name);
201
+    if ($name_length > 56) {
202 202
     // Name is limited to 60 characters, but we want to leave space to add a
203 203
     // tally if needed (for users with duplicate names); Limit to 56 chars and
204 204
     // replace the middle of the string with "..." if too long
205 205
     $cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3);
206
-  }
207
-  $unique_name = $cleaned_name;
208
-  while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) {
206
+    }
207
+    $unique_name = $cleaned_name;
208
+    while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) {
209 209
     $same_name_tally++;
210 210
     $unique_name = "{$cleaned_name}_{$same_name_tally}";
211
-  }
212
-  return $unique_name;
211
+    }
212
+    return $unique_name;
213 213
 }
214 214
 
215 215
 
@@ -221,17 +221,17 @@  discard block
 block discarded – undo
221 221
  * Require BOINC library
222 222
  */
223 223
 function require_boinc($libraries) {
224
-  if ($include_dir = boinc_get_path('html_inc')) {
224
+    if ($include_dir = boinc_get_path('html_inc')) {
225 225
     $working_dir = getcwd();
226 226
     chdir($include_dir);
227 227
     if (!is_array($libraries)) {
228
-      $libraries = array($libraries);
228
+        $libraries = array($libraries);
229 229
     }
230 230
     foreach ($libraries as $library) {
231
-      require_once("{$library}.inc");
231
+        require_once("{$library}.inc");
232 232
     }
233 233
     chdir($working_dir);
234
-  }
234
+    }
235 235
 }
236 236
 
237 237
 /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
  * The path from the BOINC html root must be included (e.g. user/file.php)
240 240
  */
241 241
 function include_boinc($file) {
242
-  if ($include_dir = boinc_get_path()) {
242
+    if ($include_dir = boinc_get_path()) {
243 243
     $include_dir .= '/html';
244 244
     $workingDir = getcwd();
245 245
     $path = dirname($file);
@@ -247,84 +247,84 @@  discard block
 block discarded – undo
247 247
     chdir("{$include_dir}/{$path}");
248 248
     include($file);
249 249
     chdir($workingDir);
250
-  }
250
+    }
251 251
 }
252 252
 
253 253
 /**
254 254
  * Get the BOINC include path
255 255
  */
256 256
 function boinc_get_path($type = 'root') {
257
-  $dir = "boinc_{$type}_dir";
258
-  if ($include_dir = variable_get("boinc_{$type}_dir", '')) {
257
+    $dir = "boinc_{$type}_dir";
258
+    if ($include_dir = variable_get("boinc_{$type}_dir", '')) {
259 259
     return $include_dir;
260
-  }
261
-  else {
260
+    }
261
+    else {
262 262
     // Don't show errors on blacklisted pages
263 263
     $page_blacklist = array(
264
-      'admin/boinc/environment'
264
+        'admin/boinc/environment'
265 265
     );
266 266
     if (!in_array($_GET['q'], $page_blacklist)) {
267
-      watchdog('boincuser', 'The BOINC environment is not configured. Please
267
+        watchdog('boincuser', 'The BOINC environment is not configured. Please
268 268
           !configure_it', array('!configure_it' => l(t('configure it now'),
269 269
             'admin/boinc/environment')), WATCHDOG_WARNING);
270
-      if (user_access('administer site configuration')) {
270
+        if (user_access('administer site configuration')) {
271 271
         drupal_set_message(t('The BOINC environment is not configured. Please
272 272
           !configure_it', array('!configure_it' => l(t('configure it now'),
273 273
             'admin/boinc/environment'))), 'warning', FALSE);
274
-      }
275
-      else {
274
+        }
275
+        else {
276 276
         drupal_set_message(t('There is a problem with the site. Please contact
277 277
           the system administrator.'), 'error', FALSE);
278
-      }
279
-      // Redirect home to display the error message and avoid fatal errors
280
-      // (unless on a blacklisted page)
281
-      $redirect_blacklist = array(
278
+        }
279
+        // Redirect home to display the error message and avoid fatal errors
280
+        // (unless on a blacklisted page)
281
+        $redirect_blacklist = array(
282 282
         'admin/settings/performance',
283 283
         'admin/boinc/environment',
284 284
         'home',
285 285
         ''
286
-      );
287
-      if (!in_array($_GET['q'], $redirect_blacklist)) {
286
+        );
287
+        if (!in_array($_GET['q'], $redirect_blacklist)) {
288 288
         drupal_goto('');
289
-      }
289
+        }
290 290
     }
291 291
     else {
292
-      // Clear the messages on the environment config page
293
-      drupal_get_messages();
292
+        // Clear the messages on the environment config page
293
+        drupal_get_messages();
294 294
     }
295
-  }
296
-  return FALSE;
295
+    }
296
+    return FALSE;
297 297
 }
298 298
 
299 299
 /**
300 300
  * Get the configured scheduler tags
301 301
  */
302 302
 function boinc_get_scheduler_tags() {
303
-  // Don't generate messages for blacklisted pages
304
-  $page_blacklist = array(
303
+    // Don't generate messages for blacklisted pages
304
+    $page_blacklist = array(
305 305
     'admin/boinc/environment',
306 306
     'admin/boinc/scheduler'
307
-  );
308
-  if ($url_config = variable_get('boinc_scheduler_urls', '')) {
307
+    );
308
+    if ($url_config = variable_get('boinc_scheduler_urls', '')) {
309 309
     return explode("\r\n", $url_config);
310
-  }
311
-  elseif (!in_array($_GET['q'], $page_blacklist)) {
310
+    }
311
+    elseif (!in_array($_GET['q'], $page_blacklist)) {
312 312
     watchdog('boincuser', 'The BOINC scheduling server settings are not yet
313 313
         configured. Please !verify for the settings to become effective.',
314
-          array('!verify' => l(t('verify the default values') . ' <strong>' . 
314
+            array('!verify' => l(t('verify the default values') . ' <strong>' . 
315 315
             t('and') . '</strong> ' . t('save the configuration'),
316 316
             'admin/boinc/scheduler', array('html' => TRUE))
317
-          ), WATCHDOG_WARNING);
317
+            ), WATCHDOG_WARNING);
318 318
     if (user_access('administer site configuration')) {
319
-      drupal_set_message(t('The BOINC scheduling server settings are not yet
319
+        drupal_set_message(t('The BOINC scheduling server settings are not yet
320 320
           configured. Please !verify for the settings to become effective',
321 321
             array('!verify' => l(t('verify the default values') . ' <strong>' . 
322
-              t('and') . '</strong> ' . t('save the configuration'),
323
-              'admin/boinc/scheduler', array('html' => TRUE))
322
+                t('and') . '</strong> ' . t('save the configuration'),
323
+                'admin/boinc/scheduler', array('html' => TRUE))
324 324
             )), 'warning', FALSE);
325 325
     }
326
-  }
327
-  return array();
326
+    }
327
+    return array();
328 328
 }
329 329
 
330 330
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -336,41 +336,41 @@  discard block
 block discarded – undo
336 336
  * Determine if a BOINC ID matches the logged in user
337 337
  */
338 338
 function is_current_boinc_user($boinc_id) {
339
-  global $user;
340
-  if (!$user->uid) {
339
+    global $user;
340
+    if (!$user->uid) {
341 341
     return FALSE;
342
-  }
343
-  // boincuser_id is not stored in the global user, so load a new instance
344
-  $drupuser = user_load($user->uid);
345
-  return ($boinc_id == $drupuser->boincuser_id);
342
+    }
343
+    // boincuser_id is not stored in the global user, so load a new instance
344
+    $drupuser = user_load($user->uid);
345
+    return ($boinc_id == $drupuser->boincuser_id);
346 346
 }
347 347
 
348 348
 /**
349 349
  * Convert a BOINC ID to a Drupal ID
350 350
  */
351 351
 function boincuser_lookup_uid($boinc_id) {
352
-  $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id));
353
-  return $drupal_id;
352
+    $drupal_id = db_result(db_query("SELECT uid FROM {boincuser} WHERE boinc_id='%d'", $boinc_id));
353
+    return $drupal_id;
354 354
 }
355 355
 function get_drupal_id($boinc_id) {
356
-  return boincuser_lookup_uid($boinc_id);
356
+    return boincuser_lookup_uid($boinc_id);
357 357
 }
358 358
 
359 359
 /**
360 360
  * Get a BOINC user object
361 361
  */
362 362
 function boincuser_load($user_id = NULL, $is_drupal_id = FALSE) {
363
-  if (!$user_id) {
363
+    if (!$user_id) {
364 364
     global $user;
365 365
     $user_id = $user->uid;
366 366
     $is_drupal_id = TRUE;
367
-  }
368
-  if ($is_drupal_id) {
367
+    }
368
+    if ($is_drupal_id) {
369 369
     $account = user_load($user_id);
370 370
     $user_id = $account->boincuser_id;
371
-  }
372
-  require_boinc('boinc_db');
373
-  return BoincUser::lookup_id($user_id);
371
+    }
372
+    require_boinc('boinc_db');
373
+    return BoincUser::lookup_id($user_id);
374 374
 }
375 375
 
376 376
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
  * Wrapper for boinc_version() function
383 383
  */
384 384
 function get_boinc_version($x) {
385
-  require_boinc('host');
386
-  return function_exists('boinc_version') ? boinc_version($x) : 'err!';
385
+    require_boinc('host');
386
+    return function_exists('boinc_version') ? boinc_version($x) : 'err!';
387 387
 }
388 388
   
389 389
 
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
393 393
 
394 394
 /**
395
-  * Generate the friend block header
396
-  */
395
+ * Generate the friend block header
396
+ */
397 397
 function boincuser_views_friends_block_header($context = null) {
398
-  // Get the friend count for the user being viewed
399
-  $view = views_get_current_view();
400
-  $account_id = $view->args[0];
401
-  $friend_count = flag_friend_get_friend_count($account_id);
402
-  return '<h2 class="pane-title">' . bts('Friends (@count)', 
398
+    // Get the friend count for the user being viewed
399
+    $view = views_get_current_view();
400
+    $account_id = $view->args[0];
401
+    $friend_count = flag_friend_get_friend_count($account_id);
402
+    return '<h2 class="pane-title">' . bts('Friends (@count)', 
403 403
     array('@count' => $friend_count)) . '</h2>';
404 404
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
       WHERE n.type = 'profile'
155 155
       AND n.status = 1
156 156
       AND n.moderate = 0
157
-      " . ($never_been_picked ? " AND bu.uotd_time = 0 " : '') . "
158
-      " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') . "
157
+      " . ($never_been_picked ? " AND bu.uotd_time = 0 " : '')."
158
+      " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '')."
159 159
       ORDER BY RAND()
160 160
       LIMIT 1"
161 161
     ));
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     // Name is limited to 60 characters, but we want to leave space to add a
203 203
     // tally if needed (for users with duplicate names); Limit to 56 chars and
204 204
     // replace the middle of the string with "..." if too long
205
-    $cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length-56)+3);
205
+    $cleaned_name = substr_replace($cleaned_name, '...', 28, ($name_length - 56) + 3);
206 206
   }
207 207
   $unique_name = $cleaned_name;
208 208
   while (db_result(db_query("SELECT uid FROM {users} WHERE name = '{$unique_name}' LIMIT 1"))) {
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
   elseif (!in_array($_GET['q'], $page_blacklist)) {
312 312
     watchdog('boincuser', 'The BOINC scheduling server settings are not yet
313 313
         configured. Please !verify for the settings to become effective.',
314
-          array('!verify' => l(t('verify the default values') . ' <strong>' . 
315
-            t('and') . '</strong> ' . t('save the configuration'),
314
+          array('!verify' => l(t('verify the default values').' <strong>'. 
315
+            t('and').'</strong> '.t('save the configuration'),
316 316
             'admin/boinc/scheduler', array('html' => TRUE))
317 317
           ), WATCHDOG_WARNING);
318 318
     if (user_access('administer site configuration')) {
319 319
       drupal_set_message(t('The BOINC scheduling server settings are not yet
320 320
           configured. Please !verify for the settings to become effective',
321
-            array('!verify' => l(t('verify the default values') . ' <strong>' . 
322
-              t('and') . '</strong> ' . t('save the configuration'),
321
+            array('!verify' => l(t('verify the default values').' <strong>'. 
322
+              t('and').'</strong> '.t('save the configuration'),
323 323
               'admin/boinc/scheduler', array('html' => TRUE))
324 324
             )), 'warning', FALSE);
325 325
     }
@@ -399,6 +399,6 @@  discard block
 block discarded – undo
399 399
   $view = views_get_current_view();
400 400
   $account_id = $view->args[0];
401 401
   $friend_count = flag_friend_get_friend_count($account_id);
402
-  return '<h2 class="pane-title">' . bts('Friends (@count)', 
403
-    array('@count' => $friend_count)) . '</h2>';
402
+  return '<h2 class="pane-title">'.bts('Friends (@count)', 
403
+    array('@count' => $friend_count)).'</h2>';
404 404
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -71,16 +71,14 @@  discard block
 block discarded – undo
71 71
       unset($account->roles[$unrestricted_role]);
72 72
     }
73 73
     user_save($account, array('roles' => $account->roles));
74
-  }
75
-  elseif ($account->boincuser_total_credit >= $min_credit_to_post) {
74
+  } elseif ($account->boincuser_total_credit >= $min_credit_to_post) {
76 75
     if (!isset($account->roles[$unrestricted_role])) {
77 76
       // This user is now above the credit threshold and is allowed full
78 77
       // privileges
79 78
       $account->roles[$unrestricted_role] = 'verified contributor';
80 79
       user_save($account, array('roles' => $account->roles));
81 80
     }
82
-  }
83
-  else {
81
+  } else {
84 82
     drupal_set_message(bts(
85 83
       'You must earn @count more credits to be able to post comments on this site.',
86 84
       array('@count' => $min_credit_to_post - $account->boincuser_total_credit)
@@ -164,12 +162,10 @@  discard block
 block discarded – undo
164 162
       if ($never_been_picked) {
165 163
         // Allow users who have been previously selected
166 164
         $never_been_picked = FALSE;
167
-      }
168
-      elseif ($active_users) {
165
+      } elseif ($active_users) {
169 166
         // Allow users who are not even active (getting desperate)
170 167
         $active_users = FALSE;
171
-      }
172
-      else {
168
+      } else {
173 169
         // Process failed...
174 170
         return FALSE;
175 171
       }
@@ -257,8 +253,7 @@  discard block
 block discarded – undo
257 253
   $dir = "boinc_{$type}_dir";
258 254
   if ($include_dir = variable_get("boinc_{$type}_dir", '')) {
259 255
     return $include_dir;
260
-  }
261
-  else {
256
+  } else {
262 257
     // Don't show errors on blacklisted pages
263 258
     $page_blacklist = array(
264 259
       'admin/boinc/environment'
@@ -271,8 +266,7 @@  discard block
 block discarded – undo
271 266
         drupal_set_message(t('The BOINC environment is not configured. Please
272 267
           !configure_it', array('!configure_it' => l(t('configure it now'),
273 268
             'admin/boinc/environment'))), 'warning', FALSE);
274
-      }
275
-      else {
269
+      } else {
276 270
         drupal_set_message(t('There is a problem with the site. Please contact
277 271
           the system administrator.'), 'error', FALSE);
278 272
       }
@@ -287,8 +281,7 @@  discard block
 block discarded – undo
287 281
       if (!in_array($_GET['q'], $redirect_blacklist)) {
288 282
         drupal_goto('');
289 283
       }
290
-    }
291
-    else {
284
+    } else {
292 285
       // Clear the messages on the environment config page
293 286
       drupal_get_messages();
294 287
     }
@@ -307,8 +300,7 @@  discard block
 block discarded – undo
307 300
   );
308 301
   if ($url_config = variable_get('boinc_scheduler_urls', '')) {
309 302
     return explode("\r\n", $url_config);
310
-  }
311
-  elseif (!in_array($_GET['q'], $page_blacklist)) {
303
+  } elseif (!in_array($_GET['q'], $page_blacklist)) {
312 304
     watchdog('boincuser', 'The BOINC scheduling server settings are not yet
313 305
         configured. Please !verify for the settings to become effective.',
314 306
           array('!verify' => l(t('verify the default values') . ' <strong>' . 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 /**
28 28
  * Get an image object from a given file and cck field
29 29
  */ 
30
-function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = FALSE) {
30
+function get_cck_image_object($image_path, $field_name, $content_type, $ignore_resolution = false) {
31 31
   $field = content_fields($field_name, $content_type); 
32 32
   $validators = array_merge(filefield_widget_upload_validators($field), imagefield_widget_upload_validators($field));
33 33
   if ($ignore_resolution) {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 function boincuser_check_credit_requirements() {
50 50
   global $user;
51 51
   if (!$user->uid) {
52
-    return FALSE;
52
+    return false;
53 53
   }
54 54
   $account = user_load($user->uid);
55 55
   $min_credit_to_post = variable_get('boinc_comment_min_credit', 0);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     drupal_set_message(bts(
62 62
       'You are banned from community participation until @date',
63 63
       array('@date' => format_date($account->boincuser_penalty_expiration))
64
-    ), 'warning', FALSE);
64
+    ), 'warning', false);
65 65
     if (isset($account->roles[$community_role])) {
66 66
       // Remove from the community role, if not already
67 67
       unset($account->roles[$community_role]);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     drupal_set_message(bts(
85 85
       'You must earn @count more credits to be able to post comments on this site.',
86 86
       array('@count' => $min_credit_to_post - $account->boincuser_total_credit)
87
-    ), 'warning', FALSE);
87
+    ), 'warning', false);
88 88
     if (isset($account->roles[$unrestricted_role])) {
89 89
       // Either the threshold has been raised or credits have been revoked;
90 90
       // this user no longer qualifies for full privileges
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 /**
98 98
  * Get the cid of the first comment the user has not seen on a given node
99 99
  */
100
-function boincuser_get_first_unread_comment_id($nid, $uid = NULL) {
100
+function boincuser_get_first_unread_comment_id($nid, $uid = null) {
101 101
   if (!$uid) {
102 102
     global $user;
103 103
     $uid = $user->uid;
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
       // Can't find a user with a profile; remove constraints on the pool
164 164
       if ($never_been_picked) {
165 165
         // Allow users who have been previously selected
166
-        $never_been_picked = FALSE;
166
+        $never_been_picked = false;
167 167
       }
168 168
       elseif ($active_users) {
169 169
         // Allow users who are not even active (getting desperate)
170
-        $active_users = FALSE;
170
+        $active_users = false;
171 171
       }
172 172
       else {
173 173
         // Process failed...
174
-        return FALSE;
174
+        return false;
175 175
       }
176 176
     }
177 177
   }
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
       if (user_access('administer site configuration')) {
271 271
         drupal_set_message(t('The BOINC environment is not configured. Please
272 272
           !configure_it', array('!configure_it' => l(t('configure it now'),
273
-            'admin/boinc/environment'))), 'warning', FALSE);
273
+            'admin/boinc/environment'))), 'warning', false);
274 274
       }
275 275
       else {
276 276
         drupal_set_message(t('There is a problem with the site. Please contact
277
-          the system administrator.'), 'error', FALSE);
277
+          the system administrator.'), 'error', false);
278 278
       }
279 279
       // Redirect home to display the error message and avoid fatal errors
280 280
       // (unless on a blacklisted page)
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
       drupal_get_messages();
294 294
     }
295 295
   }
296
-  return FALSE;
296
+  return false;
297 297
 }
298 298
 
299 299
 /**
@@ -313,15 +313,15 @@  discard block
 block discarded – undo
313 313
         configured. Please !verify for the settings to become effective.',
314 314
           array('!verify' => l(t('verify the default values') . ' <strong>' . 
315 315
             t('and') . '</strong> ' . t('save the configuration'),
316
-            'admin/boinc/scheduler', array('html' => TRUE))
316
+            'admin/boinc/scheduler', array('html' => true))
317 317
           ), WATCHDOG_WARNING);
318 318
     if (user_access('administer site configuration')) {
319 319
       drupal_set_message(t('The BOINC scheduling server settings are not yet
320 320
           configured. Please !verify for the settings to become effective',
321 321
             array('!verify' => l(t('verify the default values') . ' <strong>' . 
322 322
               t('and') . '</strong> ' . t('save the configuration'),
323
-              'admin/boinc/scheduler', array('html' => TRUE))
324
-            )), 'warning', FALSE);
323
+              'admin/boinc/scheduler', array('html' => true))
324
+            )), 'warning', false);
325 325
     }
326 326
   }
327 327
   return array();
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 function is_current_boinc_user($boinc_id) {
339 339
   global $user;
340 340
   if (!$user->uid) {
341
-    return FALSE;
341
+    return false;
342 342
   }
343 343
   // boincuser_id is not stored in the global user, so load a new instance
344 344
   $drupuser = user_load($user->uid);
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 /**
360 360
  * Get a BOINC user object
361 361
  */
362
-function boincuser_load($user_id = NULL, $is_drupal_id = FALSE) {
362
+function boincuser_load($user_id = null, $is_drupal_id = false) {
363 363
   if (!$user_id) {
364 364
     global $user;
365 365
     $user_id = $user->uid;
366
-    $is_drupal_id = TRUE;
366
+    $is_drupal_id = true;
367 367
   }
368 368
   if ($is_drupal_id) {
369 369
     $account = user_load($user_id);
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.forms.inc 5 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -13,6 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 /**
15 15
  * The structure of the general preferences form
16
+ * @param string $prefs_preset
16 17
  */
17 18
 function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) {
18 19
   $form = array();
@@ -754,6 +755,7 @@  discard block
 block discarded – undo
754 755
 
755 756
 /**
756 757
  * Perform the database updates to merge the old host into the new host
758
+ * @param string $message
757 759
  */
758 760
 function boincwork_host_merge($old_host, $new_host, &$message = NULL) {
759 761
   // Decay the average credit of the two hosts
Please login to merge, or discard this patch.
Indentation   +843 added lines, -843 removed lines patch added patch discarded remove patch
@@ -15,16 +15,16 @@  discard block
 block discarded – undo
15 15
  * The structure of the general preferences form
16 16
  */
17 17
 function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) {
18
-  $form = array();
19
-  $prefs = null;
20
-  $established = TRUE;
18
+    $form = array();
19
+    $prefs = null;
20
+    $established = TRUE;
21 21
   
22
-  // Enable AHAH form support for dynamically updating content based on preset
23
-  ahah_helper_register($form, $form_state);
22
+    // Enable AHAH form support for dynamically updating content based on preset
23
+    ahah_helper_register($form, $form_state);
24 24
   
25
-  if (!$prefs_preset) {
25
+    if (!$prefs_preset) {
26 26
     if (isset($form_state['storage']['prefs']['preset'])) {
27
-      $prefs_preset = $form_state['storage']['prefs']['preset'];
27
+        $prefs_preset = $form_state['storage']['prefs']['preset'];
28 28
     }
29 29
     
30 30
     // Load preferences from BOINC account
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     
33 33
     // Take note if this is not an established preference set on the account
34 34
     if (isset($prefs['@attributes']['cleared'])) {
35
-      $established = FALSE;
35
+        $established = FALSE;
36 36
     }
37 37
     
38 38
     // Determine if a preset is selected or if these are custom settings
@@ -47,45 +47,45 @@  discard block
 block discarded – undo
47 47
             $prefs_preset = $prefs['preset']['@value'];
48 48
         }
49 49
     }// if !$prefs_preset
50
-  }
51
-  // Extract mod_time tag if present, because it will be erased with
52
-  // boincwork_get_preset_prefs() below.
53
-  $mod_time = null;
54
-  if (isset($prefs['mod_time']['@value'])) {
55
-      $mod_time = $prefs['mod_time']['@value'];
56
-  }
50
+    }
51
+    // Extract mod_time tag if present, because it will be erased with
52
+    // boincwork_get_preset_prefs() below.
53
+    $mod_time = null;
54
+    if (isset($prefs['mod_time']['@value'])) {
55
+        $mod_time = $prefs['mod_time']['@value'];
56
+    }
57 57
 
58
-  if (isset($form_state['storage']['wip'])) {
59
-      switch ($prefs_preset) {
60
-      case 'standard':
58
+    if (isset($form_state['storage']['wip'])) {
59
+        switch ($prefs_preset) {
60
+        case 'standard':
61 61
       case 'maximum':
62 62
       case 'green':
63 63
       case 'minimum':
64 64
           $prefs = boincwork_get_preset_prefs($prefs_preset);
65
-          break;
66
-      case 'custom':
65
+            break;
66
+        case 'custom':
67 67
       default:
68 68
           // Just keeps prefs as they are
69 69
           unset($prefs['preset']);
70
-          break;
71
-      }// switch
72
-  } else {
73
-      $form_state['storage']['wip'] = TRUE;
74
-      if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75
-          if ($established) {
76
-              $prefs_preset = 'custom';
77
-          } else {
78
-              $prefs_preset = 'standard';
79
-              $prefs = boincwork_get_preset_prefs($prefs_preset);
80
-          }// if $established
81
-      }// if $prefs_preset
82
-  }// if WIP
83
-  
84
-  // This set of preferences is used in the form if no preferences
85
-  // have been set above, in variable $prefs.
86
-  require_boinc(array('db', 'prefs'));
87
-  $disk_space_config = get_disk_space_config();
88
-  $default = array(
70
+            break;
71
+        }// switch
72
+    } else {
73
+        $form_state['storage']['wip'] = TRUE;
74
+        if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75
+            if ($established) {
76
+                $prefs_preset = 'custom';
77
+            } else {
78
+                $prefs_preset = 'standard';
79
+                $prefs = boincwork_get_preset_prefs($prefs_preset);
80
+            }// if $established
81
+        }// if $prefs_preset
82
+    }// if WIP
83
+  
84
+    // This set of preferences is used in the form if no preferences
85
+    // have been set above, in variable $prefs.
86
+    require_boinc(array('db', 'prefs'));
87
+    $disk_space_config = get_disk_space_config();
88
+    $default = array(
89 89
     'preset' => $prefs_preset,
90 90
     // Processing...
91 91
     'run_on_batteries' => 0,
@@ -120,385 +120,385 @@  discard block
 block discarded – undo
120 120
     'daily_xfer_limit_mb' => 0,
121 121
     'daily_xfer_period_days' => 0,
122 122
     'dont_verify_images' => 0
123
-  );
124
-  foreach ($default as $name => $value) {
123
+    );
124
+    foreach ($default as $name => $value) {
125 125
     if (isset($prefs[$name])) {
126
-      if (is_array($prefs[$name])) {
126
+        if (is_array($prefs[$name])) {
127 127
         if (isset($prefs[$name]['@value'])) {
128
-          $default[$name] = $prefs[$name]['@value'];
128
+            $default[$name] = $prefs[$name]['@value'];
129 129
         }
130
-      }
131
-      else {
130
+        }
131
+        else {
132 132
         $default[$name] = $prefs[$name];
133
-      }
133
+        }
134
+    }
134 135
     }
135
-  }
136 136
 
137
-  // Standard option sets
138
-  $form['boolean_options'] = array(
137
+    // Standard option sets
138
+    $form['boolean_options'] = array(
139 139
     '#type' => 'value',
140 140
     '#value' => array(1 => bts('yes'), 0 => bts('no'))
141
-  );
142
-  $form['hour_options'] = array(
141
+    );
142
+    $form['hour_options'] = array(
143 143
     '#type' => 'value',
144 144
     '#value' => array('0:00','1:00','2:00','3:00','4:00', 
145
-     '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
-     '12:00','13:00','14:00','15:00','16:00','17:00',
147
-     '18:00','19:00','20:00','21:00','22:00','23:00')
148
-  );
149
-  
150
-  // Identify preference sets that are established to distinguish what has been
151
-  // saved to the database from what is just showing default values
152
-  $form['#established'] = $established;
145
+        '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
+        '12:00','13:00','14:00','15:00','16:00','17:00',
147
+        '18:00','19:00','20:00','21:00','22:00','23:00')
148
+    );
149
+  
150
+    // Identify preference sets that are established to distinguish what has been
151
+    // saved to the database from what is just showing default values
152
+    $form['#established'] = $established;
153 153
    
154
-  // Set up the preference container for AHAH
155
-  $form['prefs'] = array(
154
+    // Set up the preference container for AHAH
155
+    $form['prefs'] = array(
156 156
     '#title' => '',
157 157
     '#type' => 'fieldset',
158 158
     '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div.
159 159
     '#attributes' => array('class' => 'ahah-container'),
160 160
     '#suffix' => '</div>',
161 161
     '#tree'   => TRUE
162
-  );
163
-  //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
162
+    );
163
+    //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
164 164
   
165
-  // Hidden elements
166
-  $form['prefs']['modified'] = array(
165
+    // Hidden elements
166
+    $form['prefs']['modified'] = array(
167 167
     '#type' => 'hidden',
168 168
     '#value' => $mod_time
169
-  );
170
-  $form['prefs']['venue'] = array(
169
+    );
170
+    $form['prefs']['venue'] = array(
171 171
     '#type' => 'hidden',
172 172
     '#value' => $venue
173
-  );
173
+    );
174 174
   
175
-  $form['prefs']['separator_top'] = array(
175
+    $form['prefs']['separator_top'] = array(
176 176
     '#value' => '<div class="separator"></div>'
177
-  );
177
+    );
178 178
   
179
-  // Simplified selectors
180
-  $form['prefs']['preset'] = array(
179
+    // Simplified selectors
180
+    $form['prefs']['preset'] = array(
181 181
     '#title' => bts('Presets'),
182 182
     '#type' => 'radios',
183 183
     '#description' => ' ',
184 184
     '#options' => array(
185
-      'standard' => bts('Standard'),
186
-      'maximum' => bts('Maximum'),
187
-      'green' => bts('Green'),
188
-      'minimum' => bts('Minimum'),
189
-      'custom' => bts('Custom')
185
+        'standard' => bts('Standard'),
186
+        'maximum' => bts('Maximum'),
187
+        'green' => bts('Green'),
188
+        'minimum' => bts('Minimum'),
189
+        'custom' => bts('Custom')
190 190
     ),
191 191
     '#prefix' => '<div class="simple-form-controls">',
192 192
     '#suffix' => '</div>',
193 193
     '#default_value' => $default['preset'],
194 194
     '#ahah' => array(
195
-      'event' => 'change',
196
-      'path' => ahah_helper_path(array('prefs')),
197
-      'wrapper' => 'prefs-wrapper'
195
+        'event' => 'change',
196
+        'path' => ahah_helper_path(array('prefs')),
197
+        'wrapper' => 'prefs-wrapper'
198 198
     )
199
-  );
200
-  $form['prefs']['select preset'] = array(
199
+    );
200
+    $form['prefs']['select preset'] = array(
201 201
     '#type'  => 'submit',
202 202
     '#value' => bts('Update preset'),
203 203
     '#submit' => array('ahah_helper_generic_submit'),
204 204
     // The 'no-js' class only displays this button if javascript is disabled
205 205
     '#attributes' => array('class' => 'no-js'),
206
-  );
206
+    );
207 207
   
208
-  // Advanced preferences
209
-  $form['prefs']['advanced'] = array(
208
+    // Advanced preferences
209
+    $form['prefs']['advanced'] = array(
210 210
     '#title' => bts('Advanced settings'),
211 211
     '#type' => 'fieldset',
212 212
     '#description' => '',
213 213
     '#collapsible' => TRUE,
214 214
     '#collapsed' => !$advanced,
215 215
     '#attributes' => array('class' => 'advanced-settings'),
216
-  );
216
+    );
217 217
   
218
-  // Processing preferences
218
+    // Processing preferences
219 219
   
220
-  $form['prefs']['advanced']['anchor'] = array(
220
+    $form['prefs']['advanced']['anchor'] = array(
221 221
     '#value' => '<a name="advanced"></a>'
222
-  );
222
+    );
223 223
   
224
-  $form['prefs']['advanced']['separator_top'] = array(
224
+    $form['prefs']['advanced']['separator_top'] = array(
225 225
     '#value' => '<div class="separator"></div>'
226
-  );
226
+    );
227 227
   
228
-  $form['prefs']['advanced']['processor'] = array(
228
+    $form['prefs']['advanced']['processor'] = array(
229 229
     '#title' => bts('Processor usage'),
230 230
     '#type' => 'fieldset',
231 231
     '#description' => '',
232 232
     '#collapsible' => FALSE,
233 233
     '#collapsed' => FALSE
234
-  );
235
-  $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
234
+    );
235
+    $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
236 236
     '#title' => bts('Suspend when computer is on battery?'),
237 237
     '#type' => 'radios',
238 238
     '#description' => bts('Suspends computing on portables when running on battery power.'),
239 239
     '#options' => $form['boolean_options']['#value'],
240 240
     '#attributes' => array('class' => 'fancy'),
241 241
     '#default_value' => ($default['run_on_batteries']) ? 0 : 1 // intentional inversion of setting
242
-  );
243
-  $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
242
+    );
243
+    $form['prefs']['advanced']['processor']['run_if_user_active'] = array(
244 244
     '#title' => bts('Suspend when computer is in use?'),
245 245
     '#type' => 'radios',
246 246
     '#description' => bts("Suspends computing and file transfers when you're using the computer."),
247 247
     '#options' => $form['boolean_options']['#value'],
248 248
     '#attributes' => array('class' => 'fancy'),
249 249
     '#default_value' => ($default['run_if_user_active']) ? 0 : 1 // intentional inversion of setting
250
-  );
251
-  $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
250
+    );
251
+    $form['prefs']['advanced']['processor']['run_gpu_if_user_active'] = array(
252 252
     '#title' => bts('Suspend GPU computing when computer is in use?'),
253 253
     '#type' => 'radios',
254 254
     '#description' => bts("Suspends GPU computing when you're using the computer."),
255 255
     '#options' => $form['boolean_options']['#value'],
256 256
     '#attributes' => array('class' => 'fancy'),
257 257
     '#default_value' => ($default['run_gpu_if_user_active']) ? 0 : 1 // intentional inversion of setting
258
-  );
259
-  $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
258
+    );
259
+    $form['prefs']['advanced']['processor']['idle_time_to_run'] = array(
260 260
     '#title' => bts('"In use" means mouse/keyboard input in last'),
261 261
     '#type' => 'textfield',
262 262
     '#field_suffix' => bts('minutes'),
263 263
     '#default_value' => $default['idle_time_to_run'],
264 264
     '#size' => 1,
265 265
     '#description' => bts('This determines when the computer is considered "in use".')
266
-  );
267
-  $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
266
+    );
267
+    $form['prefs']['advanced']['processor']['suspend_if_no_recent_input'] = array(
268 268
     '#title' => bts('Suspend when no mouse/keyboard input in last'),
269 269
     '#type' => 'textfield',
270 270
     '#field_suffix' => bts('minutes'),
271 271
     '#default_value' => $default['suspend_if_no_recent_input'],
272 272
     '#size' => 1,
273 273
     '#description' => bts('This allows some computers to enter low-power mode when not in use.')
274
-  );
275
-  $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
274
+    );
275
+    $form['prefs']['advanced']['processor']['suspend_cpu_usage'] = array(
276 276
     '#title' => bts('Suspend when non-BOINC CPU usage is above'),
277 277
     '#type' => 'textfield',
278 278
     '#field_suffix' => '%',
279 279
     '#default_value' => $default['suspend_cpu_usage'],
280 280
     '#size' => 1,
281 281
     '#description' => bts('Suspend computing when your computer is busy running other programs.'),
282
-  );
283
-  $form['prefs']['advanced']['processor']['hour_label'] = array(
282
+    );
283
+    $form['prefs']['advanced']['processor']['hour_label'] = array(
284 284
     '#value' => '<div class="form-item"><label>' . bts('Compute only between:') . '</label></div>'
285
-  );
286
-  $form['prefs']['advanced']['processor']['start_hour'] = array(
285
+    );
286
+    $form['prefs']['advanced']['processor']['start_hour'] = array(
287 287
     '#type' => 'select',
288 288
     '#options' => $form['hour_options']['#value'],
289 289
     '#default_value' => $default['start_hour']
290
-  );
291
-  $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
290
+    );
291
+    $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
292 292
     '#value' => '<span>' . bts('and') . '</span>'
293
-  );
294
-  $form['prefs']['advanced']['processor']['end_hour'] = array(
293
+    );
294
+    $form['prefs']['advanced']['processor']['end_hour'] = array(
295 295
     '#type' => 'select',
296 296
     '#options' => $form['hour_options']['#value'],
297 297
     '#default_value' => $default['end_hour']
298
-  );
299
-  $form['prefs']['advanced']['processor']['hour_description'] = array(
298
+    );
299
+    $form['prefs']['advanced']['processor']['hour_description'] = array(
300 300
     '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.') . '</div></div>'
301
-  );
302
-  $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
301
+    );
302
+    $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
303 303
     '#title' => bts('Leave non-GPU tasks in memory while suspended?'),
304 304
     '#type' => 'radios',
305 305
     '#options' => $form['boolean_options']['#value'],
306 306
     '#attributes' => array('class' => 'fancy'),
307 307
     '#default_value' => $default['leave_apps_in_memory'],
308 308
     '#description' => bts('If "Yes", suspended tasks stay in memory, and resume with no work lost. If "No", suspended tasks are removed from memory, and resume from their last checkpoint.')
309
-  );
310
-  $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
309
+    );
310
+    $form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes'] = array(
311 311
     '#title' => bts('Switch between tasks every'),
312 312
     '#type' => 'textfield',
313 313
     '#field_suffix' => bts('minutes'),
314 314
     '#default_value' => $default['cpu_scheduling_period_minutes'],
315 315
     '#size' => 1,
316 316
     '#description' => bts('If you run several projects, BOINC may switch between them this often.')
317
-  );
318
-  $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
317
+    );
318
+    $form['prefs']['advanced']['processor']['max_ncpus_pct'] = array(
319 319
     '#title' => bts('Use at most'),
320 320
     '#type' => 'textfield',
321 321
     '#field_suffix' => bts('% of the processors'),
322 322
     '#default_value' => $default['max_ncpus_pct'],
323 323
     '#size' => 1,
324 324
     '#description' => bts('Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.'),
325
-  );
326
-  $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
325
+    );
326
+    $form['prefs']['advanced']['processor']['cpu_usage_limit'] = array(
327 327
     '#title' => bts('Use at most'),
328 328
     '#type' => 'textfield',
329 329
     '#field_suffix' => bts('% of the CPU time'),
330 330
     '#default_value' => $default['cpu_usage_limit'],
331 331
     '#size' => 1,
332 332
     '#description' => bts('Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.')
333
-  );
333
+    );
334 334
   
335
-  // Disk and memory preferences
336
-  $form['prefs']['advanced']['storage'] = array(
335
+    // Disk and memory preferences
336
+    $form['prefs']['advanced']['storage'] = array(
337 337
     '#title' => bts('Disk and memory usage'),
338 338
     '#type' => 'fieldset',
339 339
     '#description' => '',
340 340
     '#collapsible' => FALSE,
341 341
     '#collapsed' => FALSE
342
-  );
343
-  $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
342
+    );
343
+    $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
344 344
     '#title' => bts('Disk: use no more than'),
345 345
     '#type' => 'textfield',
346 346
     '#field_suffix' => 'GB',
347 347
     '#default_value' => $default['disk_max_used_gb'],
348 348
     '#size' => 1,
349 349
     '#description' => bts('Limit the total amount of disk space used by BOINC.'),
350
-  ); 
351
-  $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
350
+    ); 
351
+    $form['prefs']['advanced']['storage']['disk_min_free_gb'] = array(
352 352
     '#title' => bts('Disk: leave at least'),
353 353
     '#type' => 'textfield',
354 354
     '#field_suffix' => 'GB free',
355 355
     '#default_value' => $default['disk_min_free_gb'],
356 356
     '#size' => 1,
357 357
     '#description' => bts('Limit disk usage to leave this much free space on the volume where BOINC stores data.'),
358
-  );
359
-  $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
358
+    );
359
+    $form['prefs']['advanced']['storage']['disk_max_used_pct'] = array(
360 360
     '#title' => bts('Disk: use no more than'),
361 361
     '#type' => 'textfield',
362 362
     '#field_suffix' => bts('% of total'),
363 363
     '#default_value' => $default['disk_max_used_pct'],
364 364
     '#size' => 1,
365 365
     '#description' => bts('Limit the percentage of disk space used by BOINC on the volume where it stores data.')
366
-  ); 
367
-  $form['prefs']['advanced']['storage']['disk_interval'] = array(
366
+    ); 
367
+    $form['prefs']['advanced']['storage']['disk_interval'] = array(
368 368
     '#title' => bts('Request tasks to checkpoint at most every'),
369 369
     '#type' => 'textfield',
370 370
     '#field_suffix' => bts('seconds'),
371 371
     '#default_value' => $default['disk_interval'],
372 372
     '#size' => 1,
373 373
     '#description' => bts('This controls how often tasks save their state to disk, so that later they can be continued from that point.')
374
-  );
375
-  $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
374
+    );
375
+    $form['prefs']['advanced']['storage']['vm_max_used_pct'] = array(
376 376
     '#title' => bts('Page/swap file: use at most'),
377 377
     '#type' => 'textfield',
378 378
     '#field_suffix' => bts('% of total'),
379 379
     '#default_value' => $default['vm_max_used_pct'],
380 380
     '#size' => 1,
381 381
     '#description' => bts('Limit the swap space (page file) used by BOINC.')
382
-  );
383
-  $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
382
+    );
383
+    $form['prefs']['advanced']['storage']['ram_max_used_busy_pct'] = array(
384 384
     '#title' => bts('Memory: when computer is in use, use at most'),
385 385
     '#type' => 'textfield',
386 386
     '#field_suffix' => bts('% of total'),
387 387
     '#default_value' => $default['ram_max_used_busy_pct'],
388 388
     '#size' => 1,
389 389
     '#description' => bts("Limit the memory used by BOINC when you're using the computer.")
390
-  );
391
-  $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
390
+    );
391
+    $form['prefs']['advanced']['storage']['ram_max_used_idle_pct'] = array(
392 392
     '#title' => bts('Memory: when computer is not in use, use at most'),
393 393
     '#type' => 'textfield',
394 394
     '#field_suffix' => bts('% of total'),
395 395
     '#default_value' => $default['ram_max_used_idle_pct'],
396 396
     '#size' => 1,
397 397
     '#description' => bts("Limit the memory used by BOINC when you're not using the computer.")
398
-  );
398
+    );
399 399
   
400
-  // Network preferences
401
-  $form['prefs']['advanced']['network'] = array(
400
+    // Network preferences
401
+    $form['prefs']['advanced']['network'] = array(
402 402
     '#title' => bts('Network usage'),
403 403
     '#type' => 'fieldset',
404 404
     '#description' => '',
405 405
     '#collapsible' => FALSE,
406 406
     '#collapsed' => FALSE
407
-  );
408
-  $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
407
+    );
408
+    $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
409 409
     '#title' => bts('Store at least'),
410 410
     '#type' => 'textfield',
411 411
     '#field_suffix' => bts('days of work'),
412 412
     '#default_value' => $default['work_buf_min_days'],
413 413
     '#size' => 1,
414 414
     '#description' => bts('Store at least enough tasks to keep the computer busy for this long.')
415
-  ); 
416
-  $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
415
+    ); 
416
+    $form['prefs']['advanced']['network']['work_buf_additional_days'] = array(
417 417
     '#title' => bts('Store up to an additional'),
418 418
     '#type' => 'textfield',
419 419
     '#field_suffix' => bts('days'),
420 420
     '#default_value' => $default['work_buf_additional_days'],
421 421
     '#size' => 1,
422 422
     '#description' => bts('Store additional tasks above the minimum level.  Determines how much work is requested when contacting a project.')
423
-  ); 
424
-  $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
423
+    ); 
424
+    $form['prefs']['advanced']['network']['confirm_before_connecting'] = array(
425 425
     '#title' => bts('Confirm before connecting to Internet?'),
426 426
     '#type' => 'radios',
427 427
     '#options' => $form['boolean_options']['#value'],
428 428
     '#attributes' => array('class' => 'fancy'),
429 429
     '#default_value' => $default['confirm_before_connecting'],
430 430
     '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.')
431
-  ); 
432
-  $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
431
+    ); 
432
+    $form['prefs']['advanced']['network']['hangup_if_dialed'] = array(
433 433
     '#title' => bts('Disconnect when done?'),
434 434
     '#type' => 'radios',
435 435
     '#options' => $form['boolean_options']['#value'],
436 436
     '#attributes' => array('class' => 'fancy'),
437 437
     '#default_value' => $default['hangup_if_dialed'],
438 438
     '#description' => bts('Useful only if you have a modem, ISDN or VPN connection.')
439
-  );
440
-  $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
439
+    );
440
+    $form['prefs']['advanced']['network']['max_bytes_sec_down'] = array(
441 441
     '#title' => bts('Limit download rate to'),
442 442
     '#type' => 'textfield',
443 443
     '#field_suffix' => 'Kbytes/sec',
444 444
     '#default_value' => $default['max_bytes_sec_down']/1000,
445 445
     '#size' => 1,
446 446
     '#description' => bts('Limit the download rate of file transfers.')
447
-  ); 
448
-  $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
447
+    ); 
448
+    $form['prefs']['advanced']['network']['max_bytes_sec_up'] = array(
449 449
     '#title' => bts('Limit upload rate to'),
450 450
     '#type' => 'textfield',
451 451
     '#field_suffix' => 'Kbytes/sec',
452 452
     '#default_value' => $default['max_bytes_sec_up']/1000,
453 453
     '#size' => 1,
454 454
     '#description' => bts('Limit the upload rate of file transfers.')
455
-  );
456
-  $form['prefs']['advanced']['network']['hour_label'] = array(
455
+    );
456
+    $form['prefs']['advanced']['network']['hour_label'] = array(
457 457
     '#value' => '<div class="form-item"><label>' . bts('Transfer files only between') . '</label></div>'
458
-  );
459
-  $form['prefs']['advanced']['network']['net_start_hour'] = array(
458
+    );
459
+    $form['prefs']['advanced']['network']['net_start_hour'] = array(
460 460
     '#type' => 'select',
461 461
     '#options' => $form['hour_options']['#value'],
462 462
     '#default_value' => $default['net_start_hour']
463
-  );
464
-  $form['prefs']['advanced']['network']['hour_delimiter'] = array(
463
+    );
464
+    $form['prefs']['advanced']['network']['hour_delimiter'] = array(
465 465
     '#value' => '<span>' . bts('and') . '</span>'
466
-  );
467
-  $form['prefs']['advanced']['network']['net_end_hour'] = array(
466
+    );
467
+    $form['prefs']['advanced']['network']['net_end_hour'] = array(
468 468
     '#type' => 'select',
469 469
     '#options' => $form['hour_options']['#value'],
470 470
     '#default_value' => $default['net_end_hour']
471
-  );
472
-  $form['prefs']['advanced']['network']['hour_description'] = array(
471
+    );
472
+    $form['prefs']['advanced']['network']['hour_description'] = array(
473 473
     '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.') . '</div></div>'
474
-  ); 
475
-  $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
474
+    ); 
475
+    $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
476 476
     '#title' => bts('Limit usage to'),
477 477
     '#type' => 'textfield',
478 478
     '#field_suffix' => 'Mbytes',
479 479
     '#default_value' => $default['daily_xfer_limit_mb'],
480 480
     '#size' => 1
481
-  ); 
482
-  $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
481
+    ); 
482
+    $form['prefs']['advanced']['network']['daily_xfer_period_days'] = array(
483 483
     '#field_prefix' => 'every',
484 484
     '#type' => 'textfield',
485 485
     '#field_suffix' => bts('days'),
486 486
     '#default_value' => $default['daily_xfer_period_days'],
487 487
     '#size' => 1,
488 488
     '#description' => bts('Example: BOINC should transfer at most 2000 MB of data every 30 days.'),
489
-  ); 
490
-  $form['prefs']['advanced']['network']['dont_verify_images'] = array(
489
+    ); 
490
+    $form['prefs']['advanced']['network']['dont_verify_images'] = array(
491 491
     '#title' => bts('Skip data verification for image files?'),
492 492
     '#type' => 'radios',
493 493
     '#options' => $form['boolean_options']['#value'],
494 494
     '#attributes' => array('class' => 'fancy'),
495 495
     '#default_value' => $default['dont_verify_images'],
496 496
     '#description' => bts('Only select "Yes" if your Internet provider modifies image files. Skipping verification reduces the security of BOINC.')
497
-  );
497
+    );
498 498
   
499
-  // The "fancy radios" are made via javascript on document load. In order for
500
-  // these to work with AHAH, we need this crazy setTimeout() call.
501
-  $form['prefs']['fancy-radios'] = array(
499
+    // The "fancy radios" are made via javascript on document load. In order for
500
+    // these to work with AHAH, we need this crazy setTimeout() call.
501
+    $form['prefs']['fancy-radios'] = array(
502 502
     '#value' => '
503 503
       <script>
504 504
         setTimeout(
@@ -509,177 +509,177 @@  discard block
 block discarded – undo
509 509
           300
510 510
         )
511 511
       </script>'
512
-  );
513
-  $form['prefs']['view advanced'] = array(
512
+    );
513
+    $form['prefs']['view advanced'] = array(
514 514
     '#type' => 'hidden',
515 515
     '#value' => 1
516
-  );
516
+    );
517 517
   
518
-  $form['prefs']['separator_bottom'] = array(
518
+    $form['prefs']['separator_bottom'] = array(
519 519
     '#value' => '<div class="separator buttons"></div>'
520
-  );
520
+    );
521 521
   
522
-  // Form control
523
-  $form['prefs']['form control tabs prefix'] = array(
522
+    // Form control
523
+    $form['prefs']['form control tabs prefix'] = array(
524 524
     '#value' => '<ul class="form-control tab-list">'
525
-  );
526
-  $form['prefs']['submit'] = array(
525
+    );
526
+    $form['prefs']['submit'] = array(
527 527
     '#prefix' => '<li class="first tab">',
528 528
     '#type' => 'submit',
529 529
     '#value' => bts('Save changes'),
530 530
     '#suffix' => '</li>'
531
-  );
532
-  $form['prefs']['form control tabs'] = array(
531
+    );
532
+    $form['prefs']['form control tabs'] = array(
533 533
     '#value' => '<li class="tab">' . l(bts('Cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
534
-  );
535
-  if ($venue AND $venue != 'generic') {
534
+    );
535
+    if ($venue AND $venue != 'generic') {
536 536
     global $base_path;
537 537
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
538
-      l(bts('Clear'), "account/prefs/computing/clear/{$venue}",
538
+        l(bts('Clear'), "account/prefs/computing/clear/{$venue}",
539 539
         array(
540
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541
-          'attributes' => array(
540
+            'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541
+            'attributes' => array(
542 542
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
-              array('@name' => $venue)) . '\')'
544
-          )
543
+                array('@name' => $venue)) . '\')'
544
+            )
545 545
         )
546
-      ) . '</li>';
547
-  }
548
-  $form['prefs']['view control'] = array(
546
+        ) . '</li>';
547
+    }
548
+    $form['prefs']['view control'] = array(
549 549
     '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view') . ')', 'account/prefs/computing/combined') . '</li>'
550
-  );
551
-  $form['prefs']['form control tabs suffix'] = array(
550
+    );
551
+    $form['prefs']['form control tabs suffix'] = array(
552 552
     '#value' => '</ul>'
553
-  );
554
-  $form['#submit'][] = 'boincwork_generalprefs_form_submit';
553
+    );
554
+    $form['#submit'][] = 'boincwork_generalprefs_form_submit';
555 555
   
556
-  return $form;
556
+    return $form;
557 557
 }
558 558
 
559 559
 /**
560
-  * Validate the general preferences form.
561
-  */
560
+ * Validate the general preferences form.
561
+ */
562 562
 function boincwork_generalprefs_form_validate($form, &$form_state) {
563
-  require_boinc('util');
564
-  $values = $form_state['values']['prefs']['advanced'];
565
-  
566
-  //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>');
567
-  // Verify all non-boolean user input values and notify form API of failures
568
-  
569
-  // Processing preferences
570
-  if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}")));
571
-  if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}")));
572
-  if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}")));
573
-  if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}")));
574
-  if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}")));
575
-  if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}")));
576
-  if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}")));
577
-  if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}")));
563
+    require_boinc('util');
564
+    $values = $form_state['values']['prefs']['advanced'];
565
+  
566
+    //drupal_set_message('<pre>' . print_r($form_state['values'], true) . '</pre>');
567
+    // Verify all non-boolean user input values and notify form API of failures
568
+  
569
+    // Processing preferences
570
+    if (!verify_numeric($values['processor']['idle_time_to_run'], 1, 9999)) form_set_error('idle_time_to_run', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['idle_time_to_run']['#title']} [x] {$form['prefs']['advanced']['processor']['idle_time_to_run']['#field_suffix']}")));
571
+    if (!verify_numeric($values['processor']['suspend_if_no_recent_input'], 0, 9999)) form_set_error('suspend_if_no_recent_input', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_if_no_recent_input']['#field_suffix']}")));
572
+    if (!verify_numeric($values['processor']['suspend_cpu_usage'], 0, 100)) form_set_error('suspend_cpu_usage', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#title']} [x] {$form['prefs']['advanced']['processor']['suspend_cpu_usage']['#field_suffix']}")));
573
+    if (!verify_numeric($values['processor']['start_hour'], 0, 23)) form_set_error('start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['start_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['start_hour']['#field_suffix']}")));
574
+    if (!verify_numeric($values['processor']['end_hour'], 0, 23)) form_set_error('end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['end_hour']['#title']} [x] {$form['prefs']['advanced']['processor']['end_hour']['#field_suffix']}")));
575
+    if (!verify_numeric($values['processor']['cpu_scheduling_period_minutes'], 1, 9999)) form_set_error('cpu_scheduling_period_minutes', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_scheduling_period_minutes']['#field_suffix']}")));
576
+    if (!verify_numeric($values['processor']['max_ncpus_pct'], 0, 100)) form_set_error('max_ncpus_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['max_ncpus_pct']['#title']} [x] {$form['prefs']['advanced']['processor']['max_ncpus_pct']['#field_suffix']}")));
577
+    if (!verify_numeric($values['processor']['cpu_usage_limit'], 0, 100)) form_set_error('cpu_usage_limit', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['processor']['cpu_usage_limit']['#title']} [x] {$form['prefs']['advanced']['processor']['cpu_usage_limit']['#field_suffix']}")));
578 578
 
579
-  // Storage preferences
580
-  if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}")));
581
-  if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}")));
582
-  if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}")));
583
-  if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}")));
584
-  if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}")));
585
-  if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}")));
586
-  if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}")));
579
+    // Storage preferences
580
+    if (!verify_numeric($values['storage']['disk_max_used_gb'], 0, 9999999)) form_set_error('disk_max_used_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_gb']['#field_suffix']}")));
581
+    if (!verify_numeric($values['storage']['disk_min_free_gb'], 0.001, 9999999)) form_set_error('disk_min_free_gb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_min_free_gb']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_min_free_gb']['#field_suffix']}")));
582
+    if (!verify_numeric($values['storage']['disk_max_used_pct'], 0, 100)) form_set_error('disk_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_max_used_pct']['#field_suffix']}")));
583
+    if (!verify_numeric($values['storage']['disk_interval'], 0, 9999999)) form_set_error('disk_interval', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['disk_interval']['#title']} [x] {$form['prefs']['advanced']['storage']['disk_interval']['#field_suffix']}")));
584
+    if (!verify_numeric($values['storage']['vm_max_used_pct'], 0, 100)) form_set_error('vm_max_used_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['vm_max_used_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['vm_max_used_pct']['#field_suffix']}")));
585
+    if (!verify_numeric($values['storage']['ram_max_used_busy_pct'], 0, 100)) form_set_error('ram_max_used_busy_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_busy_pct']['#field_suffix']}")));
586
+    if (!verify_numeric($values['storage']['ram_max_used_idle_pct'], 0, 100)) form_set_error('ram_max_used_idle_pct', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#title']} [x] {$form['prefs']['advanced']['storage']['ram_max_used_idle_pct']['#field_suffix']}")));
587 587
 
588
-  // Network preferences
589
-  if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}")));
590
-  if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}")));
591
-  if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}")));
592
-  if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}")));
593
-  if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}")));
594
-  if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}")));
595
-  if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}")));
596
-  if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}")));
588
+    // Network preferences
589
+    if (!verify_numeric($values['network']['work_buf_min_days'], 0, 10)) form_set_error('work_buf_min_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_min_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_min_days']['#field_suffix']}")));
590
+    if (!verify_numeric($values['network']['work_buf_additional_days'], 0, 10)) form_set_error('work_buf_additional_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['work_buf_additional_days']['#title']} [x] {$form['prefs']['advanced']['network']['work_buf_additional_days']['#field_suffix']}")));
591
+    if (!verify_numeric($values['network']['max_bytes_sec_down'], 0, 9999.999)) form_set_error('max_bytes_sec_down', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_down']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_down']['#field_suffix']}")));
592
+    if (!verify_numeric($values['network']['max_bytes_sec_up'], 0, 9999.999)) form_set_error('max_bytes_sec_up', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['max_bytes_sec_up']['#title']} [x] {$form['prefs']['advanced']['network']['max_bytes_sec_up']['#field_suffix']}")));
593
+    if (!verify_numeric($values['network']['net_start_hour'], 0, 23)) form_set_error('net_start_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_start_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_start_hour']['#field_suffix']}")));
594
+    if (!verify_numeric($values['network']['net_end_hour'], 0, 23)) form_set_error('net_end_hour', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['net_end_hour']['#title']} [x] {$form['prefs']['advanced']['network']['net_end_hour']['#field_suffix']}")));
595
+    if (!verify_numeric($values['network']['daily_xfer_limit_mb'], 0, 9999999)) form_set_error('daily_xfer_limit_mb', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}")));
596
+    if (!verify_numeric($values['network']['daily_xfer_period_days'], 0, 9999999)) form_set_error('daily_xfer_period_days', bts('Invalid setting for "%preference"', array('%preference' => "{$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#title']} [x] {$form['prefs']['advanced']['network']['daily_xfer_limit_mb']['#field_suffix']}")));
597 597
 }
598 598
 
599 599
 /**
600
-  * Handle post-validation submission of general preferences form.
601
-  */
600
+ * Handle post-validation submission of general preferences form.
601
+ */
602 602
 function boincwork_generalprefs_form_submit($form, &$form_state) {
603
-  global $user;
604
-  $account = user_load($user->uid);
605
-  
606
-  $values = $form_state['values']['prefs']['advanced'];
607
-  $venue = $form_state['values']['prefs']['venue'];
608
-  $preset = $form_state['values']['prefs']['preset'];
609
-  
610
-  // Load preferences from BOINC account
611
-  $prefs = boincwork_load_prefs('general', $venue);
612
-  
613
-  // Processing preferences
614
-  $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
615
-  $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
616
-  $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1;
617
-  $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
618
-  $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
619
-  $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
620
-  $prefs['start_hour'] = $values['processor']['start_hour'];
621
-  $prefs['end_hour'] = $values['processor']['end_hour'];
622
-  $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
623
-  $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
624
-  $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
625
-  $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
626
-  
627
-  // Storage preferences
628
-  $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
629
-  $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
630
-  $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
631
-  $prefs['disk_interval'] = $values['storage']['disk_interval'];
632
-  $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
633
-  $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
634
-  $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
635
-  
636
-  // Network preferences
637
-  $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
638
-  $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
639
-  $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
640
-  $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
641
-  $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
642
-  $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
643
-  $prefs['net_start_hour'] = $values['network']['net_start_hour'];
644
-  $prefs['net_end_hour'] = $values['network']['net_end_hour'];
645
-  $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
646
-  $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
647
-  $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
603
+    global $user;
604
+    $account = user_load($user->uid);
605
+  
606
+    $values = $form_state['values']['prefs']['advanced'];
607
+    $venue = $form_state['values']['prefs']['venue'];
608
+    $preset = $form_state['values']['prefs']['preset'];
609
+  
610
+    // Load preferences from BOINC account
611
+    $prefs = boincwork_load_prefs('general', $venue);
612
+  
613
+    // Processing preferences
614
+    $prefs['run_on_batteries'] = ($values['processor']['run_on_batteries']) ? 0 : 1;
615
+    $prefs['run_if_user_active'] = ($values['processor']['run_if_user_active']) ? 0 : 1;
616
+    $prefs['run_gpu_if_user_active'] = ($values['processor']['run_gpu_if_user_active']) ? 0 : 1;
617
+    $prefs['idle_time_to_run'] = $values['processor']['idle_time_to_run'];
618
+    $prefs['suspend_if_no_recent_input'] = $values['processor']['suspend_if_no_recent_input'];
619
+    $prefs['suspend_cpu_usage'] = $values['processor']['suspend_cpu_usage'];
620
+    $prefs['start_hour'] = $values['processor']['start_hour'];
621
+    $prefs['end_hour'] = $values['processor']['end_hour'];
622
+    $prefs['leave_apps_in_memory'] = ($values['processor']['leave_apps_in_memory']) ? 1 : 0;
623
+    $prefs['cpu_scheduling_period_minutes'] = $values['processor']['cpu_scheduling_period_minutes'];
624
+    $prefs['max_ncpus_pct'] = $values['processor']['max_ncpus_pct'];
625
+    $prefs['cpu_usage_limit'] = $values['processor']['cpu_usage_limit'];
626
+  
627
+    // Storage preferences
628
+    $prefs['disk_max_used_gb'] = $values['storage']['disk_max_used_gb'];
629
+    $prefs['disk_min_free_gb'] = $values['storage']['disk_min_free_gb'];
630
+    $prefs['disk_max_used_pct'] = $values['storage']['disk_max_used_pct'];
631
+    $prefs['disk_interval'] = $values['storage']['disk_interval'];
632
+    $prefs['vm_max_used_pct'] = $values['storage']['vm_max_used_pct'];
633
+    $prefs['ram_max_used_busy_pct'] = $values['storage']['ram_max_used_busy_pct'];
634
+    $prefs['ram_max_used_idle_pct'] = $values['storage']['ram_max_used_idle_pct'];
635
+  
636
+    // Network preferences
637
+    $prefs['work_buf_min_days'] = $values['network']['work_buf_min_days'];
638
+    $prefs['work_buf_additional_days'] = $values['network']['work_buf_additional_days'];
639
+    $prefs['confirm_before_connecting'] = ($values['network']['confirm_before_connecting']) ? 1 : 0;
640
+    $prefs['hangup_if_dialed'] = ($values['network']['hangup_if_dialed']) ? 1 : 0;
641
+    $prefs['max_bytes_sec_down'] = $values['network']['max_bytes_sec_down']*1000;
642
+    $prefs['max_bytes_sec_up'] = $values['network']['max_bytes_sec_up']*1000;
643
+    $prefs['net_start_hour'] = $values['network']['net_start_hour'];
644
+    $prefs['net_end_hour'] = $values['network']['net_end_hour'];
645
+    $prefs['daily_xfer_limit_mb'] = $values['network']['daily_xfer_limit_mb'];
646
+    $prefs['daily_xfer_period_days'] = $values['network']['daily_xfer_period_days'];
647
+    $prefs['dont_verify_images'] = ($values['network']['dont_verify_images']) ? 1 : 0;
648 648
 
649
-  // transform old way to store the preset into new way
650
-  // ideally this should already have happened in boincwork_generalprefs_form()
651
-  if (isset($prefs['@attributes']['preset'])) {
649
+    // transform old way to store the preset into new way
650
+    // ideally this should already have happened in boincwork_generalprefs_form()
651
+    if (isset($prefs['@attributes']['preset'])) {
652 652
     $prefs['preset'] = $prefs['@attributes']['preset'];
653 653
     unset($prefs['@attributes']['preset']);
654
-  }
655
-  // Save the preset selection (or lack thereof)
656
-  if (!$preset OR $preset == 'custom') {
654
+    }
655
+    // Save the preset selection (or lack thereof)
656
+    if (!$preset OR $preset == 'custom') {
657 657
     $prefs['preset'] = 'custom';
658
-  }
659
-  else {
658
+    }
659
+    else {
660 660
     $prefs['preset'] = $preset;
661
-  }
661
+    }
662 662
   
663
-  // If this is a new preference set, be sure to unset the "cleared" attribute
664
-  if (isset($prefs['@attributes']['cleared'])) {
663
+    // If this is a new preference set, be sure to unset the "cleared" attribute
664
+    if (isset($prefs['@attributes']['cleared'])) {
665 665
     unset($prefs['@attributes']['cleared']);
666
-  }
666
+    }
667 667
   
668
-  // Update database
669
-  $result = boincwork_save_prefs($prefs, 'general', $venue);
668
+    // Update database
669
+    $result = boincwork_save_prefs($prefs, 'general', $venue);
670 670
   
671
-  if (!$result) {
671
+    if (!$result) {
672 672
     watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysql_error()), WATCHDOG_ERROR);
673 673
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
674
-  }
675
-  elseif (!drupal_get_messages('status', FALSE)) {
674
+    }
675
+    elseif (!drupal_get_messages('status', FALSE)) {
676 676
     // Show this message if the set wasn't created automatically (in which case
677 677
     // there is a message tailored to that) {
678 678
     drupal_set_message(t('Your preferences have been updated.
679 679
       Client-related preferences will take effect when your computer 
680 680
       communicates with @project or you issue the "Update"
681 681
       command from the BOINC client.', array('@project' => PROJECT)));
682
-  }
682
+    }
683 683
 }
684 684
 
685 685
 
@@ -691,88 +691,88 @@  discard block
 block discarded – undo
691 691
  * Find compatible hosts for merging
692 692
  */
693 693
 function boincwork_host_get_compatible_hosts($host_id) {
694
-  require_boinc('host');
695
-  global $user;
696
-  $account = user_load($user->uid);
697
-  $compatible_hosts = array();
698
-  $host_count = 0;
699
-  db_set_active('boinc');
700
-  $current_host = db_fetch_object(db_query("
694
+    require_boinc('host');
695
+    global $user;
696
+    $account = user_load($user->uid);
697
+    $compatible_hosts = array();
698
+    $host_count = 0;
699
+    db_set_active('boinc');
700
+    $current_host = db_fetch_object(db_query("
701 701
     SELECT id, domain_name, create_time, total_credit, rpc_time, os_name,
702 702
       p_vendor, p_model
703 703
     FROM {host}
704 704
     WHERE userid = '%d' AND id = '%d'",
705 705
     $account->boincuser_id, $host_id
706
-  ));
707
-  db_set_active('default');
708
-  $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
-  $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
710
-  // Get the list of all other hosts owned by this user for comparison
711
-  db_set_active('boinc');
712
-  $all_other_hosts = db_query("
706
+    ));
707
+    db_set_active('default');
708
+    $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
+    $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
710
+    // Get the list of all other hosts owned by this user for comparison
711
+    db_set_active('boinc');
712
+    $all_other_hosts = db_query("
713 713
     SELECT id, domain_name, create_time, total_credit, rpc_time, os_name,
714 714
       p_vendor, p_model
715 715
     FROM {host}
716 716
     WHERE userid = '%d' AND id <> '%d'",
717 717
     $account->boincuser_id, $host_id
718
-  );
719
-  db_set_active('default');
720
-  // Compare all hosts to see if any are plausible duplicates
721
-  while ($other_host = db_fetch_object($all_other_hosts)) {
718
+    );
719
+    db_set_active('default');
720
+    // Compare all hosts to see if any are plausible duplicates
721
+    while ($other_host = db_fetch_object($all_other_hosts)) {
722 722
     // First, disqualify if hosts were active at the same time
723 723
     if (!$current_host->is_new) {
724
-      $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
-      $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
726
-      if (!$other_host->is_new) {
724
+        $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
+        $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
726
+        if (!$other_host->is_new) {
727 727
         // If both hosts being compared are not new, see if times overlap
728 728
         if (!times_disjoint($current_host, $other_host)) {
729
-          // Hosts were active at the same time; can't be a duplicate
730
-          continue;
729
+            // Hosts were active at the same time; can't be a duplicate
730
+            continue;
731
+        }
731 732
         }
732
-      }
733 733
     }
734 734
     // Next, disqualify if hosts have different OS platforms
735 735
     if (!os_compatible($current_host, $other_host)) {
736
-      // Hosts have different OS platforms; not really a duplicate
737
-      continue;
736
+        // Hosts have different OS platforms; not really a duplicate
737
+        continue;
738 738
     }
739 739
     // Finally, disqualify if hosts have different CPUs
740 740
     if (!cpus_compatible($current_host, $other_host)) {
741
-      // CPUs don't match; not a duplicate
742
-      continue;
741
+        // CPUs don't match; not a duplicate
742
+        continue;
743 743
     }
744 744
     // If not disqualified, this host is available for merging
745 745
     $hosts[] = $other_host;
746 746
     $host_count++;
747 747
     if ($host_count == 500) {
748
-      // This is enough!
749
-      break;
748
+        // This is enough!
749
+        break;
750 750
     }
751
-  }
752
-  return $hosts;
751
+    }
752
+    return $hosts;
753 753
 }
754 754
 
755 755
 /**
756 756
  * Perform the database updates to merge the old host into the new host
757 757
  */
758 758
 function boincwork_host_merge($old_host, $new_host, &$message = NULL) {
759
-  // Decay the average credit of the two hosts
760
-  require_boinc('credit');
761
-  $now = time();
762
-  update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
763
-  update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
764
-  
765
-  // Update the database:
766
-  // - add credit from old host to new host
767
-  // - change results to refer to the new host
768
-  // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id])
769
-  
770
-  $total_credit = $old_host->total_credit + $new_host->total_credit;
771
-  $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
772
-  
773
-  // Move credit from the old host to the new host
774
-  db_set_active('boinc');
775
-  $credit_updated = db_query("
759
+    // Decay the average credit of the two hosts
760
+    require_boinc('credit');
761
+    $now = time();
762
+    update_average($now, 0, 0, $old_host->expavg_credit, $old_host->expavg_time);
763
+    update_average($now, 0, 0, $new_host->expavg_credit, $new_host->expavg_time);
764
+  
765
+    // Update the database:
766
+    // - add credit from old host to new host
767
+    // - change results to refer to the new host
768
+    // - put old host in "zombie" state (userid=0, rpc_seqno=[new_host_id])
769
+  
770
+    $total_credit = $old_host->total_credit + $new_host->total_credit;
771
+    $recent_credit = $old_host->expavg_credit + $new_host->expavg_credit;
772
+  
773
+    // Move credit from the old host to the new host
774
+    db_set_active('boinc');
775
+    $credit_updated = db_query("
776 776
     UPDATE {host}
777 777
     SET
778 778
       total_credit = '%d',
@@ -780,34 +780,34 @@  discard block
 block discarded – undo
780 780
       expavg_time = '%d'
781 781
     WHERE id = '%d'",
782 782
     $total_credit, $recent_credit, $now, $new_host->id
783
-  );
784
-  db_set_active('default');
785
-  if (!$credit_updated) {
783
+    );
784
+    db_set_active('default');
785
+    if (!$credit_updated) {
786 786
     if ($message !== NULL) {
787
-      $message = bts('Could not update credit');
787
+        $message = bts('Could not update credit');
788 788
     }
789 789
     return FALSE;
790
-  }
790
+    }
791 791
   
792
-  // Move results from the old host to the new host
793
-  db_set_active('boinc');
794
-  $results_updated = db_query("
792
+    // Move results from the old host to the new host
793
+    db_set_active('boinc');
794
+    $results_updated = db_query("
795 795
     UPDATE {result}
796 796
     SET hostid = '%d'
797 797
     WHERE hostid = '%d'",
798 798
     $new_host->id, $old_host->id
799
-  );
800
-  db_set_active('default');
801
-  if (!$results_updated) {
799
+    );
800
+    db_set_active('default');
801
+    if (!$results_updated) {
802 802
     if ($message !== NULL) {
803
-      $message = bts('Could not update results');
803
+        $message = bts('Could not update results');
804 804
     }
805 805
     return FALSE;
806
-  }
806
+    }
807 807
   
808
-  // Retire the old host
809
-  db_set_active('boinc');
810
-  $old_host_retired = db_query("
808
+    // Retire the old host
809
+    db_set_active('boinc');
810
+    $old_host_retired = db_query("
811 811
     UPDATE {host}
812 812
     SET
813 813
       total_credit = '0',
@@ -816,16 +816,16 @@  discard block
 block discarded – undo
816 816
       rpc_seqno = '%d'
817 817
     WHERE id = '%d'",
818 818
     $new_host->id, $old_host->id
819
-  );
820
-  db_set_active('default');
821
-  if (!$old_host_retired) {
819
+    );
820
+    db_set_active('default');
821
+    if (!$old_host_retired) {
822 822
     if ($message !== NULL) {
823
-      $message = bts('Could not retire old computer');
823
+        $message = bts('Could not retire old computer');
824 824
     }
825 825
     return FALSE;
826
-  }
826
+    }
827 827
   
828
-  return TRUE;
828
+    return TRUE;
829 829
 }
830 830
 
831 831
 /**
@@ -833,75 +833,75 @@  discard block
 block discarded – undo
833 833
  */
834 834
 function boincwork_host_merge_form(&$form_state, $host_id) {
835 835
 
836
-  if (!boincwork_host_user_is_owner($host_id)) {
836
+    if (!boincwork_host_user_is_owner($host_id)) {
837 837
     drupal_goto("host/{$host_id}");
838
-  }
838
+    }
839 839
   
840
-  $form = array();
841
-  $form_state['storage']['current_host_id'] = $host_id;
842
-  $current_host = boincwork_host_get_info($host_id);
840
+    $form = array();
841
+    $form_state['storage']['current_host_id'] = $host_id;
842
+    $current_host = boincwork_host_get_info($host_id);
843 843
   
844
-  // Get hosts that could be merged with this one
845
-  $hosts = boincwork_host_get_compatible_hosts($host_id);
844
+    // Get hosts that could be merged with this one
845
+    $hosts = boincwork_host_get_compatible_hosts($host_id);
846 846
   
847
-  if (!$hosts) {
847
+    if (!$hosts) {
848 848
     drupal_set_message(t('There are no computers eligible for merging with this
849 849
       one'), 'warning'
850 850
     );
851 851
     drupal_goto("host/{$host_id}");
852
-  }
852
+    }
853 853
   
854
-  $form['overview'] = array(
854
+    $form['overview'] = array(
855 855
     '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to'
856
-      . ' the same computer by mistake. You can correct this by merging old'
857
-      . ' identities with the newest one.') . '</p>'
858
-      . '<p>'
859
-      . bts('Check the computers that are the same as @name'
860
-      . ' (created on @date at @time with computer ID @id)',
856
+        . ' the same computer by mistake. You can correct this by merging old'
857
+        . ' identities with the newest one.') . '</p>'
858
+        . '<p>'
859
+        . bts('Check the computers that are the same as @name'
860
+        . ' (created on @date at @time with computer ID @id)',
861 861
         array(
862
-          '@name' => $current_host->domain_name,
863
-          '@date' => date('j M Y', $current_host->create_time),
864
-          '@time' => date('H:i:s T', $current_host->create_time),
865
-          '@id' => $current_host->id,
862
+            '@name' => $current_host->domain_name,
863
+            '@date' => date('j M Y', $current_host->create_time),
864
+            '@time' => date('H:i:s T', $current_host->create_time),
865
+            '@id' => $current_host->id,
866 866
         )
867
-      ) . '</p>',
868
-  );
867
+        ) . '</p>',
868
+    );
869 869
   
870
-  $options = array();
871
-  foreach ($hosts as $host) {
870
+    $options = array();
871
+    foreach ($hosts as $host) {
872 872
     $options[$host->id] = array(
873
-      $host->domain_name,
874
-      date('j M Y H:i:s T', $host->create_time),
875
-      $host->id,
873
+        $host->domain_name,
874
+        date('j M Y H:i:s T', $host->create_time),
875
+        $host->id,
876 876
     );
877
-  }
877
+    }
878 878
   
879
-  $form['merge'] = array(
879
+    $form['merge'] = array(
880 880
     '#title' => '',
881 881
     '#type' => 'tableselect',
882 882
     '#header' => array(bts('Name'), bts('Created'), bts('Computer ID')),
883 883
     '#options' => $options,
884
-  );
884
+    );
885 885
   
886
-  $form['prefs']['separator_bottom'] = array(
887
-  //  '#value' => '<div class="separator buttons"></div>'
888
-  );
886
+    $form['prefs']['separator_bottom'] = array(
887
+    //  '#value' => '<div class="separator buttons"></div>'
888
+    );
889 889
   
890
-  // Form control
891
-  $form['prefs']['form control tabs prefix'] = array(
890
+    // Form control
891
+    $form['prefs']['form control tabs prefix'] = array(
892 892
     '#value' => '<ul class="form-control tab-list">'
893
-  );
894
-  $form['prefs']['submit'] = array(
893
+    );
894
+    $form['prefs']['submit'] = array(
895 895
     '#prefix' => '<li class="first tab">',
896 896
     '#type' => 'submit',
897 897
     '#value' => bts('Merge'),
898 898
     '#suffix' => '</li>'
899
-  );
900
-  $form['prefs']['form control tabs'] = array(
899
+    );
900
+    $form['prefs']['form control tabs'] = array(
901 901
     '#value' => '<li class="tab">' . l(bts('Cancel'), "host/{$host_id}") . '</li>'
902
-  );
902
+    );
903 903
   
904
-  return $form;
904
+    return $form;
905 905
 }
906 906
 
907 907
 /**
@@ -914,76 +914,76 @@  discard block
 block discarded – undo
914 914
  * Handle submission of the merge host form
915 915
  */
916 916
 function boincwork_host_merge_form_submit($form, &$form_state) {
917
-  $merged = array();
918
-  $errors = array();
919
-  $current_host_id = $form_state['storage']['current_host_id'];
920
-  $current_host = boincwork_host_get_info($current_host_id);
921
-  $selected_hosts = array_filter($form_state['values']['merge']);
917
+    $merged = array();
918
+    $errors = array();
919
+    $current_host_id = $form_state['storage']['current_host_id'];
920
+    $current_host = boincwork_host_get_info($current_host_id);
921
+    $selected_hosts = array_filter($form_state['values']['merge']);
922 922
   
923
-  foreach ($selected_hosts as $host_id) {
923
+    foreach ($selected_hosts as $host_id) {
924 924
     // Attempt to merge each host, noting the results
925 925
     $message = '';
926 926
     $old_host = boincwork_host_get_info($host_id);
927 927
     if (boincwork_host_merge($old_host, $current_host, $message)) {
928
-      $merged[$old_host->id] = $old_host->id;
929
-      $current_host = boincwork_host_get_info($current_host_id);
928
+        $merged[$old_host->id] = $old_host->id;
929
+        $current_host = boincwork_host_get_info($current_host_id);
930 930
     }
931 931
     else {
932
-      $errors[$old_host->id] = $message;
932
+        $errors[$old_host->id] = $message;
933
+    }
933 934
     }
934
-  }
935 935
   
936
-  if ($merged) {
936
+    if ($merged) {
937 937
     // Generate a natural language list of IDs that were merged
938 938
     $oxford_comma = ',';
939 939
     $conjunction = bts('and');
940 940
     $list = array_keys($merged);
941 941
     $last = array_pop($list);
942 942
     if ($list) {
943
-      if (count($merged) == 2) {
943
+        if (count($merged) == 2) {
944 944
         $oxford_comma = '';
945
-      }
946
-      $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
945
+        }
946
+        $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
947 947
     }
948 948
     else {
949
-      $list = $last;
949
+        $list = $last;
950 950
     }
951 951
     if (count($merged) == 1) {
952
-      drupal_set_message(bts(
952
+        drupal_set_message(bts(
953 953
         'Computer @old_id has been merged successfully into @id.',
954 954
         array(
955
-          '@old_id' => $list,
956
-          '@id' => $current_host_id
955
+            '@old_id' => $list,
956
+            '@id' => $current_host_id
957 957
         )
958
-      ));
958
+        ));
959 959
     }
960 960
     else {
961
-      drupal_set_message(bts(
961
+        drupal_set_message(bts(
962 962
         'Computers @old_ids have been merged successfully into @id.',
963 963
         array(
964
-          '@old_ids' => $list,
965
-          '@id' => $current_host_id
964
+            '@old_ids' => $list,
965
+            '@id' => $current_host_id
966 966
         )
967
-      ));
967
+        ));
968
+    }
968 969
     }
969
-  }
970 970
   
971
-  if ($errors) {
971
+    if ($errors) {
972 972
     // Report any hosts that failed to merge
973 973
     foreach ($errors as $id => $error) {
974
-      drupal_set_message(
974
+        drupal_set_message(
975 975
         bts('Computer @old_id failed to merge: @message',
976
-          array(
976
+            array(
977 977
             '@old_id' => $id,
978 978
             '@message' => $error,
979
-          )
979
+            )
980 980
         ),
981 981
         'warning'
982
-      );
982
+        );
983
+    }
983 984
     }
984
-  }
985 985
   
986
-  drupal_goto("host/{$current_host_id}");
986
+    drupal_goto("host/{$current_host_id}");
987 987
 }
988 988
 
989 989
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -995,38 +995,38 @@  discard block
 block discarded – undo
995 995
  */
996 996
 function boincwork_projectprefs_form(&$form_state, $venue) {
997 997
   
998
-  global $user;
999
-  $account = user_load($user->uid);
998
+    global $user;
999
+    $account = user_load($user->uid);
1000 1000
   
1001
-  $established = TRUE;
1001
+    $established = TRUE;
1002 1002
   
1003
-  // Get availability of special BOINC preferences
1004
-  require_boinc(array('util'));
1005
-  $app_types = get_app_types();
1003
+    // Get availability of special BOINC preferences
1004
+    require_boinc(array('util'));
1005
+    $app_types = get_app_types();
1006 1006
   
1007
-  // Load any existing preferences from BOINC account
1008
-  $prefs = boincwork_load_prefs('project', $venue);
1007
+    // Load any existing preferences from BOINC account
1008
+    $prefs = boincwork_load_prefs('project', $venue);
1009 1009
   
1010
-  // Take note if this is not an established preference set on the account
1011
-  if (isset($prefs['@attributes']['cleared'])) {
1010
+    // Take note if this is not an established preference set on the account
1011
+    if (isset($prefs['@attributes']['cleared'])) {
1012 1012
     $established = FALSE;
1013
-  }
1013
+    }
1014 1014
   
1015
-  $venue_is_default = FALSE;
1016
-  if ($account->boincuser_default_pref_set) {
1015
+    $venue_is_default = FALSE;
1016
+    if ($account->boincuser_default_pref_set) {
1017 1017
     if ($account->boincuser_default_pref_set == $venue) {
1018
-      $venue_is_default = TRUE;
1018
+        $venue_is_default = TRUE;
1019
+    }
1019 1020
     }
1020
-  }
1021
-  elseif (!$venue OR $venue == 'generic') {
1021
+    elseif (!$venue OR $venue == 'generic') {
1022 1022
     $venue_is_default = TRUE;
1023
-  }
1024
-  else {
1023
+    }
1024
+    else {
1025 1025
     $venue_is_default = FALSE;
1026
-  }
1026
+    }
1027 1027
   
1028
-  // Define form defaults
1029
-  $default = array(
1028
+    // Define form defaults
1029
+    $default = array(
1030 1030
     'resource_share' => 100,
1031 1031
     'no_cpu' => 0,
1032 1032
     'no_cuda' => 0,
@@ -1034,329 +1034,329 @@  discard block
 block discarded – undo
1034 1034
     'no_intel_gpu' => 0,
1035 1035
     'default_venue' => $venue_is_default,
1036 1036
     'allow_beta_work' => $prefs['allow_beta_work'],
1037
-  );
1038
-  foreach ($default as $name => $value) {
1037
+    );
1038
+    foreach ($default as $name => $value) {
1039 1039
     if (isset($prefs[$name])) {
1040
-      if (is_array($prefs[$name])) {
1040
+        if (is_array($prefs[$name])) {
1041 1041
         if (isset($prefs[$name]['@value'])) {
1042
-          $default[$name] = $prefs[$name]['@value'];
1042
+            $default[$name] = $prefs[$name]['@value'];
1043 1043
         }
1044
-      }
1045
-      else {
1044
+        }
1045
+        else {
1046 1046
         $default[$name] = $prefs[$name];
1047
-      }
1047
+        }
1048
+    }
1048 1049
     }
1049
-  }
1050 1050
   
1051
-  // Standard option sets
1052
-  $form['boolean_options'] = array(
1051
+    // Standard option sets
1052
+    $form['boolean_options'] = array(
1053 1053
     '#type' => 'value',
1054 1054
     '#value' => array(1 => bts('yes'), 0 => bts('no'))
1055
-  );
1055
+    );
1056 1056
   
1057
-  // Identify preference sets that are established to distinguish what has been
1058
-  // saved to the database from what is just showing default values
1059
-  $form['#established'] = $established;
1057
+    // Identify preference sets that are established to distinguish what has been
1058
+    // saved to the database from what is just showing default values
1059
+    $form['#established'] = $established;
1060 1060
   
1061
-  // Top level form options
1062
-  $form['#tree'] = TRUE;
1061
+    // Top level form options
1062
+    $form['#tree'] = TRUE;
1063 1063
   
1064
-  // Hidden elements
1065
-  $form['venue'] = array(
1064
+    // Hidden elements
1065
+    $form['venue'] = array(
1066 1066
     '#type' => 'hidden',
1067 1067
     '#value' => $venue
1068
-  );
1068
+    );
1069 1069
   
1070
-  $form['separator_top'] = array(
1070
+    $form['separator_top'] = array(
1071 1071
     '#value' => '<div class="separator"></div>'
1072
-  );
1072
+    );
1073 1073
   
1074
-  // Common project preferences  
1075
-  $form['resource'] = array(
1074
+    // Common project preferences  
1075
+    $form['resource'] = array(
1076 1076
     '#title' => bts('Resource settings'),
1077 1077
     '#type' => 'fieldset',
1078 1078
     '#description' => null,
1079 1079
     '#collapsible' => TRUE,
1080 1080
     '#collapsed' => FALSE
1081
-  );
1082
-  $form['resource']['resource_share'] = array(
1081
+    );
1082
+    $form['resource']['resource_share'] = array(
1083 1083
     '#title' => bts('Resource share'),
1084 1084
     '#type' => 'textfield',
1085 1085
     '#default_value' => $default['resource_share'],
1086 1086
     '#size' => 5,
1087 1087
     '#description' => bts("Determines the proportion of your computer's resources allocated to this project. Example: if you participate in two BOINC projects with resource shares of 100 and 200, the first will get 1/3 of your resources and the second will get 2/3.")
1088
-  );
1089
-  if ($app_types->count > 1) {
1088
+    );
1089
+    if ($app_types->count > 1) {
1090 1090
     if ($app_types->cpu) {
1091
-      $form['resource']['no_cpu'] = array(
1091
+        $form['resource']['no_cpu'] = array(
1092 1092
         '#title' => bts('Use CPU'),
1093 1093
         '#type' => 'radios',
1094 1094
         '#options' => $form['boolean_options']['#value'],
1095 1095
         '#attributes' => array('class' => 'fancy'),
1096 1096
         '#default_value' => $default['no_cpu'] ? 0 : 1,
1097 1097
         '#description' => bts('Request CPU-only tasks from this project.')
1098
-      );
1098
+        );
1099 1099
     }
1100 1100
     if ($app_types->cuda) {
1101
-      $form['resource']['no_cuda'] = array(
1101
+        $form['resource']['no_cuda'] = array(
1102 1102
         '#title' => bts('Use NVIDIA GPU'),
1103 1103
         '#type' => 'radios',
1104 1104
         '#options' => $form['boolean_options']['#value'],
1105 1105
         '#attributes' => array('class' => 'fancy'),
1106 1106
         '#default_value' => $default['no_cuda'] ? 0 : 1,
1107 1107
         '#description' => bts('Request NVIDIA GPU tasks from this project.')
1108
-      );
1108
+        );
1109 1109
     }
1110 1110
     if ($app_types->ati) {
1111
-      $form['resource']['no_ati'] = array(
1111
+        $form['resource']['no_ati'] = array(
1112 1112
         '#title' => bts('Use ATI GPU'),
1113 1113
         '#type' => 'radios',
1114 1114
         '#options' => $form['boolean_options']['#value'],
1115 1115
         '#attributes' => array('class' => 'fancy'),
1116 1116
         '#default_value' => $default['no_ati'] ? 0 : 1,
1117 1117
         '#description' => bts('Request ATI GPU tasks from this project.')
1118
-      );
1118
+        );
1119 1119
     }
1120 1120
     if ($app_types->intel_gpu) {
1121
-      $form['resource']['no_intel_gpu'] = array(
1121
+        $form['resource']['no_intel_gpu'] = array(
1122 1122
         '#title' => bts('Use INTEL GPU'),
1123 1123
         '#type' => 'radios',
1124 1124
         '#options' => $form['boolean_options']['#value'],
1125 1125
         '#attributes' => array('class' => 'fancy'),
1126 1126
         '#default_value' => $default['no_intel_gpu'] ? 0 : 1,
1127 1127
         '#description' => bts('Request Intel GPU tasks from this project.')
1128
-      );
1128
+        );
1129
+    }
1129 1130
     }
1130
-  }
1131 1131
   
1132
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1132
+    if (variable_get('boinc_prefs_options_beta', FALSE)) {
1133 1133
     $form['beta'] = array(
1134
-      '#title' => bts('Beta settings'),
1135
-      '#type' => 'fieldset',
1136
-      '#description' => null,
1137
-      '#collapsible' => TRUE,
1138
-      '#collapsed' => FALSE
1134
+        '#title' => bts('Beta settings'),
1135
+        '#type' => 'fieldset',
1136
+        '#description' => null,
1137
+        '#collapsible' => TRUE,
1138
+        '#collapsed' => FALSE
1139 1139
     );
1140 1140
     $form['beta']['allow_beta_work'] = array(
1141
-      '#title' => bts('Run test applications?'),
1142
-      '#type' => 'radios',
1143
-      '#options' => $form['boolean_options']['#value'],
1144
-      '#attributes' => array('class' => 'fancy'),
1145
-      '#default_value' => ($default['allow_beta_work']) ? 1 : 0,
1146
-      '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer')
1141
+        '#title' => bts('Run test applications?'),
1142
+        '#type' => 'radios',
1143
+        '#options' => $form['boolean_options']['#value'],
1144
+        '#attributes' => array('class' => 'fancy'),
1145
+        '#default_value' => ($default['allow_beta_work']) ? 1 : 0,
1146
+        '#description' => bts('This helps us develop applications, but may cause jobs to fail on your computer')
1147 1147
     );
1148
-  }
1148
+    }
1149 1149
   
1150
-  // Add project specific prefs to the form
1151
-  boincwork_add_project_specific_prefs($form, $prefs);
1150
+    // Add project specific prefs to the form
1151
+    boincwork_add_project_specific_prefs($form, $prefs);
1152 1152
   
1153
-  // Set whether to use this preference set by default for new computers
1154
-  $form['default_set'] = array(
1153
+    // Set whether to use this preference set by default for new computers
1154
+    $form['default_set'] = array(
1155 1155
     '#title' => bts('Default set'),
1156 1156
     '#type' => 'fieldset',
1157 1157
     '#description' => null,
1158 1158
     '#collapsible' => TRUE,
1159 1159
     '#collapsed' => FALSE
1160
-  );
1161
-  $form['default_set']['default_venue'] = array(
1160
+    );
1161
+    $form['default_set']['default_venue'] = array(
1162 1162
     '#title' => bts('Set used for new computers'),
1163 1163
     '#type' => 'radios',
1164 1164
     '#options' => $form['boolean_options']['#value'],
1165 1165
     '#attributes' => array('class' => 'fancy'),
1166 1166
     '#default_value' => $default['default_venue'] ? 1 : 0,
1167 1167
     '#description' => ''
1168
-  );
1168
+    );
1169 1169
   
1170
-  $form['prefs']['separator_bottom'] = array(
1170
+    $form['prefs']['separator_bottom'] = array(
1171 1171
     '#value' => '<div class="separator buttons"></div>'
1172
-  );
1172
+    );
1173 1173
   
1174
-  // Form control
1175
-  $form['prefs']['form control tabs prefix'] = array(
1174
+    // Form control
1175
+    $form['prefs']['form control tabs prefix'] = array(
1176 1176
     '#value' => '<ul class="form-control tab-list">'
1177
-  );
1178
-  $form['prefs']['submit'] = array(
1177
+    );
1178
+    $form['prefs']['submit'] = array(
1179 1179
     '#prefix' => '<li class="first tab">',
1180 1180
     '#type' => 'submit',
1181 1181
     '#value' => bts('Save changes'),
1182 1182
     '#suffix' => '</li>'
1183
-  );
1184
-  $form['prefs']['form control tabs'] = array(
1183
+    );
1184
+    $form['prefs']['form control tabs'] = array(
1185 1185
     '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>'
1186
-  );
1187
-  if ($venue AND $venue != 'generic') {
1186
+    );
1187
+    if ($venue AND $venue != 'generic') {
1188 1188
     global $base_path;
1189 1189
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
1190
-      l(bts('Clear'), "account/prefs/project/clear/{$venue}",
1190
+        l(bts('Clear'), "account/prefs/project/clear/{$venue}",
1191 1191
         array(
1192
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1193
-          'attributes' => array(
1192
+            'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1193
+            'attributes' => array(
1194 1194
             'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
1195
-              array('@name' => $venue)) . '\')'
1196
-          )
1195
+                array('@name' => $venue)) . '\')'
1196
+            )
1197 1197
         )
1198
-      ) . '</li>';
1199
-  }
1200
-  $form['prefs']['view control'] = array(
1198
+        ) . '</li>';
1199
+    }
1200
+    $form['prefs']['view control'] = array(
1201 1201
     '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view') . ')', 'account/prefs/project/combined') . '</li>'
1202
-  );
1203
-  $form['prefs']['form control tabs suffix'] = array(
1202
+    );
1203
+    $form['prefs']['form control tabs suffix'] = array(
1204 1204
     '#value' => '</ul>'
1205
-  );
1205
+    );
1206 1206
   
1207
-  return $form;
1207
+    return $form;
1208 1208
 }
1209 1209
 
1210 1210
 /**
1211 1211
  * Add project specific preferences to the project preferences form
1212 1212
  */
1213 1213
 function boincwork_add_project_specific_prefs(&$form, $prefs) {
1214
-  // Load project specific preferences from XML config
1215
-  $xml = boincwork_get_project_specific_config();
1214
+    // Load project specific preferences from XML config
1215
+    $xml = boincwork_get_project_specific_config();
1216 1216
   
1217
-  // Respect the order of the top level elements
1218
-  $ordered_array = array();
1219
-  $unordered_array = array();
1220
-  foreach ($xml['project_specific_preferences'] as $type => $element) {
1217
+    // Respect the order of the top level elements
1218
+    $ordered_array = array();
1219
+    $unordered_array = array();
1220
+    foreach ($xml['project_specific_preferences'] as $type => $element) {
1221 1221
     if (is_array($element) AND is_numeric(key($element))) {
1222
-      foreach ($element as $ordered_element) {
1222
+        foreach ($element as $ordered_element) {
1223 1223
         if (isset($ordered_element['@position'])) {
1224
-          $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1224
+            $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1225 1225
         }
1226 1226
         else {
1227
-          $unordered_array[] = array($type => $ordered_element);
1227
+            $unordered_array[] = array($type => $ordered_element);
1228
+        }
1228 1229
         }
1229
-      }
1230 1230
     }
1231 1231
     elseif (isset($element['@position'])) {
1232
-      $ordered_array[$element['@position']] = array($type => $element);
1232
+        $ordered_array[$element['@position']] = array($type => $element);
1233 1233
     }
1234 1234
     else {
1235
-      $unordered_array[] = array($type => $element);
1235
+        $unordered_array[] = array($type => $element);
1236
+    }
1236 1237
     }
1237
-  }
1238
-  ksort($ordered_array);
1239
-  $primed_array = array_merge($ordered_array, $unordered_array);
1240
-  $xml = array('project_specific_preferences' => $primed_array);
1238
+    ksort($ordered_array);
1239
+    $primed_array = array_merge($ordered_array, $unordered_array);
1240
+    $xml = array('project_specific_preferences' => $primed_array);
1241 1241
     
1242
-  foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1242
+    foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1243 1243
     $type = key($wrapped_element);
1244 1244
     $element= reset($wrapped_element);
1245 1245
     boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']);
1246
-  }
1246
+    }
1247 1247
 }
1248 1248
 
1249 1249
 /**
1250
-  * Validate the project preferences form.
1251
-  */
1250
+ * Validate the project preferences form.
1251
+ */
1252 1252
 function boincwork_projectprefs_form_validate($form, &$form_state) {
1253 1253
   
1254
-  // Verify all text user input values and notify form API of failures
1255
-  $validation_rules = array(
1254
+    // Verify all text user input values and notify form API of failures
1255
+    $validation_rules = array(
1256 1256
     'resource' => array(
1257
-      'resource_share' => array(
1257
+        'resource_share' => array(
1258 1258
         'datatype' => 'integer',
1259 1259
         'min' => 0
1260
-      ),
1260
+        ),
1261 1261
     ),
1262
-  );
1262
+    );
1263 1263
   
1264
-  // Add validation rules for project specific settings
1265
-  $validation_rules += boincwork_get_project_specific_config_validation_rules();
1264
+    // Add validation rules for project specific settings
1265
+    $validation_rules += boincwork_get_project_specific_config_validation_rules();
1266 1266
   
1267
-  // Perform validation
1268
-  boincwork_validate_form($validation_rules, $form_state['values']);
1267
+    // Perform validation
1268
+    boincwork_validate_form($validation_rules, $form_state['values']);
1269 1269
   
1270
-  // Check for app validation
1271
-  if (isset($validation_rules['apps'])) {
1270
+    // Check for app validation
1271
+    if (isset($validation_rules['apps'])) {
1272 1272
     if (isset($validation_rules['apps']['minimum selected'])
1273 1273
         AND $validation_rules['apps']['minimum selected'] > 0) {
1274
-      $apps_selected = 0;
1275
-      foreach ($validation_rules['apps']['list'] as $app) {
1274
+        $apps_selected = 0;
1275
+        foreach ($validation_rules['apps']['list'] as $app) {
1276 1276
         if ($form_state['values']['applications'][$app]) $apps_selected++;
1277
-      }
1278
-      if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1277
+        }
1278
+        if ($apps_selected < $validation_rules['apps']['minimum selected']) {
1279 1279
         form_set_error(
1280
-          'applications',
1281
-          bts('At least one application must be selected')
1280
+            'applications',
1281
+            bts('At least one application must be selected')
1282 1282
         );
1283
-      }
1284
-      if ($apps_selected == count($validation_rules['apps']['list'])) {
1283
+        }
1284
+        if ($apps_selected == count($validation_rules['apps']['list'])) {
1285 1285
         foreach ($validation_rules['apps']['list'] as $app) {
1286
-          unset($form_state['values']['applications'][$app]);
1286
+            unset($form_state['values']['applications'][$app]);
1287 1287
         }
1288 1288
         $form_state['storage']['all apps selected'] = TRUE;
1289
-      }
1289
+        }
1290
+    }
1290 1291
     }
1291
-  }
1292 1292
 }
1293 1293
 
1294 1294
 /**
1295
-  * Handle post-validation submission of project preferences form.
1296
-  */
1295
+ * Handle post-validation submission of project preferences form.
1296
+ */
1297 1297
 function boincwork_projectprefs_form_submit($form, &$form_state) {
1298
-  global $user;
1299
-  global $site_name;
1298
+    global $user;
1299
+    global $site_name;
1300 1300
   
1301
-  require_boinc(array('util'));
1302
-  $app_types = get_app_types();
1301
+    require_boinc(array('util'));
1302
+    $app_types = get_app_types();
1303 1303
   
1304
-  $account = user_load($user->uid);
1305
-  $edit = $form_state['values'];
1306
-  $venue = $edit['venue'];
1304
+    $account = user_load($user->uid);
1305
+    $edit = $form_state['values'];
1306
+    $venue = $edit['venue'];
1307 1307
   
1308
-  // Load preferences from BOINC account
1309
-  $prefs = boincwork_load_prefs('project', $venue);
1308
+    // Load preferences from BOINC account
1309
+    $prefs = boincwork_load_prefs('project', $venue);
1310 1310
   
1311
-  // Resource preferences
1312
-  $prefs['resource_share'] = $edit['resource']['resource_share'];
1313
-  if ($app_types->count > 1) {
1311
+    // Resource preferences
1312
+    $prefs['resource_share'] = $edit['resource']['resource_share'];
1313
+    if ($app_types->count > 1) {
1314 1314
     if ($app_types->cpu) $prefs['no_cpu'] = ($edit['resource']['no_cpu']) ? 0 : 1;
1315 1315
     if ($app_types->cuda) $prefs['no_cuda'] = ($edit['resource']['no_cuda']) ? 0 : 1;
1316 1316
     if ($app_types->ati) $prefs['no_ati'] = ($edit['resource']['no_ati']) ? 0 : 1;
1317 1317
     if ($app_types->intel_gpu) $prefs['no_intel_gpu'] = ($edit['resource']['no_intel_gpu']) ? 0 : 1;
1318
-  }
1318
+    }
1319 1319
   
1320
-  // Beta preferences
1321
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1320
+    // Beta preferences
1321
+    if (variable_get('boinc_prefs_options_beta', FALSE)) {
1322 1322
     $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0;
1323
-  }
1323
+    }
1324 1324
   
1325
-  // Load project specific preferences from XML config
1326
-  $xml = boincwork_get_project_specific_config();
1327
-  $updated_prefs = array(
1325
+    // Load project specific preferences from XML config
1326
+    $xml = boincwork_get_project_specific_config();
1327
+    $updated_prefs = array(
1328 1328
     'project_specific' => boincwork_format_project_specific_prefs_data($edit)
1329
-  );
1330
-  $prefs = $updated_prefs + $prefs;
1329
+    );
1330
+    $prefs = $updated_prefs + $prefs;
1331 1331
   
1332
-  // Don't specify apps if all are selected
1333
-  if (isset($form_state['storage']['all apps selected'])) {
1332
+    // Don't specify apps if all are selected
1333
+    if (isset($form_state['storage']['all apps selected'])) {
1334 1334
     unset($prefs['project_specific']['app_id']);
1335 1335
     unset($form_state['storage']['all apps selected']);
1336
-  }
1336
+    }
1337 1337
   
1338
-  // If this is a new preference set, be sure to unset the "cleared" attribute
1339
-  if (isset($prefs['@attributes']['cleared'])) {
1338
+    // If this is a new preference set, be sure to unset the "cleared" attribute
1339
+    if (isset($prefs['@attributes']['cleared'])) {
1340 1340
     unset($prefs['@attributes']['cleared']);
1341
-  }
1341
+    }
1342 1342
   
1343
-  // Save preferences back to the BOINC account
1344
-  $result = boincwork_save_prefs($prefs, 'project', $venue);
1343
+    // Save preferences back to the BOINC account
1344
+    $result = boincwork_save_prefs($prefs, 'project', $venue);
1345 1345
   
1346
-  // Update the user's default preference set
1347
-  if ($edit['default_set']['default_venue']) {
1346
+    // Update the user's default preference set
1347
+    if ($edit['default_set']['default_venue']) {
1348 1348
     boincwork_set_default_venue($venue);
1349
-  }
1350
-  elseif ($venue == $account->boincuser_default_pref_set) {
1349
+    }
1350
+    elseif ($venue == $account->boincuser_default_pref_set) {
1351 1351
     // User has cleared out the default venue setting
1352 1352
     boincwork_set_default_venue();
1353
-  }
1353
+    }
1354 1354
   
1355
-  if (!$result) {
1355
+    if (!$result) {
1356 1356
     watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysql_error()), WATCHDOG_ERROR);
1357 1357
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
1358
-  }
1359
-  elseif (!drupal_get_messages('status', FALSE)) {
1358
+    }
1359
+    elseif (!drupal_get_messages('status', FALSE)) {
1360 1360
     // Show this message if the set wasn't created automatically (in which case
1361 1361
     // there is a message tailored to that)
1362 1362
     drupal_set_message(t('Your preferences have been updated.
@@ -1364,53 +1364,53 @@  discard block
 block discarded – undo
1364 1364
         communicates with @project or you issue the "Update"
1365 1365
         command from the BOINC client.', 
1366 1366
         array('@project' => $site_name)));
1367
-  }
1367
+    }
1368 1368
 }
1369 1369
 
1370 1370
 /**
1371 1371
  * The structure of the community preferences form
1372 1372
  */
1373 1373
 function communityprefs_form(&$form_state) {
1374
-  global $user;
1375
-  $account = user_load($user->uid);
1376
-  $form = array();
1377
-  
1378
-  // Pull in some elements from the profile form
1379
-  $profile_form_state = array();
1380
-  $profile = new stdClass();
1381
-  $profile->type = 'profile';
1382
-  $profile->language = '';
1383
-  if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1374
+    global $user;
1375
+    $account = user_load($user->uid);
1376
+    $form = array();
1377
+  
1378
+    // Pull in some elements from the profile form
1379
+    $profile_form_state = array();
1380
+    $profile = new stdClass();
1381
+    $profile->type = 'profile';
1382
+    $profile->language = '';
1383
+    if ($profile_nid = content_profile_profile_exists($profile, $account->uid)) {
1384 1384
     $profile_node = node_load($profile_nid);
1385 1385
     $form_state['storage']['profile_node'] = $profile_node;
1386 1386
     module_load_include('inc', 'node', 'node.pages');    
1387 1387
     $profile_form = drupal_retrieve_form('profile_node_form', $profile_form_state, $profile_node);
1388 1388
     drupal_prepare_form('profile_node_form', $profile_form, $profile_form_state);
1389
-  }
1389
+    }
1390 1390
   
1391
-  // Standard option sets
1392
-  $form['boolean_options'] = array(
1391
+    // Standard option sets
1392
+    $form['boolean_options'] = array(
1393 1393
     '#type' => 'value',
1394 1394
     '#value' => array(1 => bts('yes'), 0 => bts('no'))
1395
-  );
1395
+    );
1396 1396
   
1397
-  $default = array(
1397
+    $default = array(
1398 1398
     'pm_send_notification' => '', // This is set already in pm_email_notify_user
1399 1399
     'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0,
1400 1400
     'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50),
1401 1401
     'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST),
1402
-  );
1402
+    );
1403 1403
   
1404
-  // General options
1405
-  $form['general'] = array(
1404
+    // General options
1405
+    $form['general'] = array(
1406 1406
     '#type' => 'fieldset',
1407 1407
     '#title' => bts('General settings'),
1408 1408
     '#weight' => 0,
1409 1409
     '#collapsible' => TRUE,
1410 1410
     '#collapsed' => FALSE
1411
-  );
1412
-  // Add the BOINC user name (non-unique, user editable)
1413
-  $form['general']['boincuser_name'] = array(
1411
+    );
1412
+    // Add the BOINC user name (non-unique, user editable)
1413
+    $form['general']['boincuser_name'] = array(
1414 1414
     '#type' => 'textfield',
1415 1415
     '#title' => bts('Name'),
1416 1416
     '#default_value' => $account->boincuser_name,
@@ -1418,239 +1418,239 @@  discard block
 block discarded – undo
1418 1418
     '#required' => TRUE,
1419 1419
     '#description' => '',
1420 1420
     '#size' => 40
1421
-  );
1422
-  // Time zone
1423
-  if (variable_get('configurable_timezones', 1)) {
1421
+    );
1422
+    // Time zone
1423
+    if (variable_get('configurable_timezones', 1)) {
1424 1424
     $zones = _system_zonelist();
1425 1425
     $form['general']['timezone'] = array(
1426
-      '#type' => 'select',
1427
-      '#title' => bts('Time zone'),
1428
-      '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1429
-      '#options' => $zones,
1430
-      '#description' => '',
1426
+        '#type' => 'select',
1427
+        '#title' => bts('Time zone'),
1428
+        '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1429
+        '#options' => $zones,
1430
+        '#description' => '',
1431 1431
     );
1432
-  }
1432
+    }
1433 1433
   
1434
-  // Notification options
1435
-  $form['notifications'] = array(
1434
+    // Notification options
1435
+    $form['notifications'] = array(
1436 1436
     '#type' => 'fieldset',
1437 1437
     '#title' => bts('Notification settings'),
1438 1438
     '#weight' => 5,
1439 1439
     '#collapsible' => TRUE,
1440 1440
     '#collapsed' => FALSE
1441
-  );
1442
-  // Pull in private message notification handling and tweak the form
1443
-  $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
1444
-  $form['notifications']['pm_send_notifications'] = array_replace(
1441
+    );
1442
+    // Pull in private message notification handling and tweak the form
1443
+    $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
1444
+    $form['notifications']['pm_send_notifications'] = array_replace(
1445 1445
     $pm_notify['enable_pm_mail']['pm_send_notifications'],
1446 1446
     array(
1447
-      '#type' => 'radios',
1448
-      '#title' => bts('Receive email notification for private messages?'),
1449
-      '#description' => ' ',
1450
-      '#options' => $form['boolean_options']['#value'],
1451
-      '#attributes' => array('class' => 'fancy')
1447
+        '#type' => 'radios',
1448
+        '#title' => bts('Receive email notification for private messages?'),
1449
+        '#description' => ' ',
1450
+        '#options' => $form['boolean_options']['#value'],
1451
+        '#attributes' => array('class' => 'fancy')
1452 1452
     )
1453
-  );
1454
-  $form['notifications']['friend_notification'] = array(
1453
+    );
1454
+    $form['notifications']['friend_notification'] = array(
1455 1455
     '#type' => 'radios',
1456 1456
     '#title' => bts('Receive email notification for friend requests?'),
1457 1457
     '#description' => ' ',
1458 1458
     '#options' => array(0 => bts('yes'), -1 => bts('no')),
1459 1459
     '#attributes' => array('class' => 'fancy'),
1460 1460
     '#default_value' => $default['friend_notification']
1461
-  );
1461
+    );
1462 1462
   
1463
-  // Internationalization options
1464
-  if (module_exists('internationalization')) {
1463
+    // Internationalization options
1464
+    if (module_exists('internationalization')) {
1465 1465
     $languages = language_list('enabled');
1466 1466
     $languages = $languages[1];
1467 1467
     $names = array();
1468 1468
     foreach ($languages as $langcode => $item) {
1469
-      $name = t($item->name);
1470
-      $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1469
+        $name = t($item->name);
1470
+        $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1471 1471
     }
1472 1472
     $form['locale'] = array(
1473
-      '#type' => 'fieldset',
1474
-      '#title' => bts('Language settings'),
1475
-      '#weight' => 10,
1476
-      '#collapsible' => TRUE,
1477
-      '#collapsed' => FALSE,
1473
+        '#type' => 'fieldset',
1474
+        '#title' => bts('Language settings'),
1475
+        '#weight' => 10,
1476
+        '#collapsible' => TRUE,
1477
+        '#collapsed' => FALSE,
1478 1478
     );
1479 1479
 
1480 1480
     // Get language negotiation settings.
1481 1481
     $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE);
1482 1482
     $user_preferred_language = user_preferred_language($account);
1483 1483
     $form['locale']['language'] = array(
1484
-      '#type' => 'select',
1485
-      '#title' => bts('Language'),
1486
-      '#default_value' => check_plain($user_preferred_language->language),
1487
-      '#options' => $names,
1488
-      '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.") : bts("This account's default language for e-mails."),
1484
+        '#type' => 'select',
1485
+        '#title' => bts('Language'),
1486
+        '#default_value' => check_plain($user_preferred_language->language),
1487
+        '#options' => $names,
1488
+        '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? bts("This account's default language for e-mails and preferred language for site presentation.") : bts("This account's default language for e-mails."),
1489 1489
     );
1490
-  }
1490
+    }
1491 1491
   
1492
-  // Avatar options
1493
-  $form['gravatar'] = array(
1492
+    // Avatar options
1493
+    $form['gravatar'] = array(
1494 1494
     '#type' => 'item',
1495 1495
     '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail)),
1496 1496
     '#description' => bts('Your Gravatar will not be shown if you upload a user picture.'),
1497
-  );
1498
-  if (user_access('disable own gravatar', $account)) {
1497
+    );
1498
+    if (user_access('disable own gravatar', $account)) {
1499 1499
     $form['gravatar'] = array(
1500
-      '#type' => 'checkbox',
1501
-      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail)),
1502
-      '#description' => bts('Gravatar will not be shown if an avatar is uploaded.'),
1503
-      '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1504
-      '#disabled' => !empty($account->picture),
1505
-    );
1506
-  }
1507
-  $form['gravatar']['#weight'] = 15;
1508
-  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings') . '</a></legend>';
1509
-  // Upload an avatar (pulled from profile_node_form):
1510
-  if (!empty($profile_form['field_image'])) {
1500
+        '#type' => 'checkbox',
1501
+        '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail)),
1502
+        '#description' => bts('Gravatar will not be shown if an avatar is uploaded.'),
1503
+        '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1504
+        '#disabled' => !empty($account->picture),
1505
+    );
1506
+    }
1507
+    $form['gravatar']['#weight'] = 15;
1508
+    $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings') . '</a></legend>';
1509
+    // Upload an avatar (pulled from profile_node_form):
1510
+    if (!empty($profile_form['field_image'])) {
1511 1511
     $form['field_image'] = $profile_form['field_image'];
1512
-  }
1513
-  else {
1512
+    }
1513
+    else {
1514 1514
     $form['field_image'] = array(
1515
-      '#value' => '<div class="form-item">'
1515
+        '#value' => '<div class="form-item">'
1516 1516
         . '<label class="placeholder">'
1517 1517
         . bts('This is not available until your profile is set up.')
1518 1518
         . '</label>'
1519 1519
         . l(bts('Create a profile'), 'account/profile/edit', array('attributes' => array('class' => 'form-link')))
1520 1520
         . '</div>',
1521 1521
     );
1522
-  }
1523
-  $form['field_image'][0]['#title'] = bts('Upload an avatar');
1524
-  $form['field_image']['#weight'] = 20;
1525
-  $form['field_image']['#suffix'] = '</fieldset>';
1522
+    }
1523
+    $form['field_image'][0]['#title'] = bts('Upload an avatar');
1524
+    $form['field_image']['#weight'] = 20;
1525
+    $form['field_image']['#suffix'] = '</fieldset>';
1526 1526
   
1527
-  // Forum options
1528
-  $form['forums'] = array(
1527
+    // Forum options
1528
+    $form['forums'] = array(
1529 1529
     '#type' => 'fieldset',
1530 1530
     '#title' => bts('Forum settings'),
1531 1531
     '#weight' => 25,
1532 1532
     '#collapsible' => TRUE,
1533 1533
     '#collapsed' => FALSE
1534
-  );
1535
-  $form['forums']['comments_per_page'] = array(
1534
+    );
1535
+    $form['forums']['comments_per_page'] = array(
1536 1536
     '#type' => 'select',
1537 1537
     '#title' => bts('In discussion topics, show at most @comments_per_page', array('@comments_per_page' => '')),
1538 1538
     '#options' => array(10 => 10, 20 => 20, 30 => 30, 50 => 50, 100 => 100),
1539 1539
     '#default_value' => $default['comments_per_page']
1540
-  );
1541
-  // Can't have a typical Drupal form suffix on a select box?
1542
-  $form['forums']['comments_per_page_suffix'] = array(
1540
+    );
1541
+    // Can't have a typical Drupal form suffix on a select box?
1542
+    $form['forums']['comments_per_page_suffix'] = array(
1543 1543
     '#value' => '<span>' . bts('comments per page') . '</span>'
1544
-  );
1545
-  $form['forums']['comments_order'] = array(
1544
+    );
1545
+    $form['forums']['comments_order'] = array(
1546 1546
     '#type' => 'select',
1547 1547
     '#title' => bts('Sort comments in discussions'),
1548 1548
     '#options' => array(1 => bts('Newest post first'), 2 => bts('Oldest post first')),
1549 1549
     '#default_value' => $default['comments_order']
1550
-  );
1551
-  // Signature (pulled from user_edit_form):
1552
-  if (variable_get('user_signatures', 0) && module_exists('comment')) {
1550
+    );
1551
+    // Signature (pulled from user_edit_form):
1552
+    if (variable_get('user_signatures', 0) && module_exists('comment')) {
1553 1553
     $form['forums']['signature'] = array(
1554
-      '#type' => 'textarea',
1555
-      '#title' => bts('Signature'),
1556
-      '#description' => bts('Your signature will be publicly displayed at the end of your comments.'),
1557
-      '#default_value' => $account->signature
1558
-      );
1554
+        '#type' => 'textarea',
1555
+        '#title' => bts('Signature'),
1556
+        '#description' => bts('Your signature will be publicly displayed at the end of your comments.'),
1557
+        '#default_value' => $account->signature
1558
+        );
1559 1559
     // Prevent a "validation error" message when the user attempts to save with a default value they
1560 1560
     // do not have access to.
1561 1561
     if (!filter_access($account->signature_format) && empty($_POST)) {
1562
-      drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1563
-      $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1562
+        drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1563
+        $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1564 1564
     }
1565 1565
     $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format'));
1566 1566
     // Optionally hide signatures from comments
1567 1567
     $form['forums']['hide_signatures'] = array(
1568
-      '#type' => 'radios',
1569
-      '#title' => bts('Hide signatures in forums'),
1570
-      '#description' => ' ',
1571
-      '#options' => $form['boolean_options']['#value'],
1572
-      '#attributes' => array('class' => 'fancy'),
1573
-      '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0,
1574
-    );
1575
-  }
1568
+        '#type' => 'radios',
1569
+        '#title' => bts('Hide signatures in forums'),
1570
+        '#description' => ' ',
1571
+        '#options' => $form['boolean_options']['#value'],
1572
+        '#attributes' => array('class' => 'fancy'),
1573
+        '#default_value' => isset($account->hide_signatures) ? $account->hide_signatures : 0,
1574
+    );
1575
+    }
1576 1576
 
1577
-  //Ignored users list
1578
-  if (module_exists('ignore_user')) {
1577
+    //Ignored users list
1578
+    if (module_exists('ignore_user')) {
1579 1579
     $form['forums']['ignored_users'] = array(
1580
-      '#value' => '<div class="form-item">'
1580
+        '#value' => '<div class="form-item">'
1581 1581
         . '<label>'
1582
-	. bts('Ignore Users in forums:')
1583
-	. '</label>'
1582
+    . bts('Ignore Users in forums:')
1583
+    . '</label>'
1584 1584
         . bts('<a href="@ignore-user-list">View/Edit</a> your ignored users list.',
1585
-	  array(
1586
-	    '@ignore-user-list' => url('ignore_user/list'),
1587
-	    array('attributes' => array('class' => 'form-link'))
1588
-	  )
1589
-	)
1590
-	. '</div>',
1591
-    );
1592
-  }//endif module_exists('ignore_user')
1585
+        array(
1586
+        '@ignore-user-list' => url('ignore_user/list'),
1587
+        array('attributes' => array('class' => 'form-link'))
1588
+        )
1589
+    )
1590
+    . '</div>',
1591
+    );
1592
+    }//endif module_exists('ignore_user')
1593 1593
 
1594
-  //Bottom separator
1595
-  $form['separator_bottom'] = array(
1594
+    //Bottom separator
1595
+    $form['separator_bottom'] = array(
1596 1596
     '#value' => '<div class="separator buttons"></div>',
1597 1597
     '#weight' => 999,
1598
-  );
1598
+    );
1599 1599
   
1600
-  // Form control
1601
-  $form['form control tabs prefix'] = array(
1600
+    // Form control
1601
+    $form['form control tabs prefix'] = array(
1602 1602
     '#value' => '<ul class="form-control tab-list">',
1603 1603
     '#weight' => 1001,
1604
-  );
1605
-  $form['submit'] = array(
1604
+    );
1605
+    $form['submit'] = array(
1606 1606
     '#prefix' => '<li class="first tab">',
1607 1607
     '#type' => 'submit',
1608 1608
     '#value' => bts('Save changes'),
1609 1609
     '#suffix' => '</li>',
1610 1610
     '#weight' => 1002,
1611
-  );
1612
-  $form['form control tabs'] = array(
1611
+    );
1612
+    $form['form control tabs'] = array(
1613 1613
     '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>',
1614 1614
     '#weight' => 1003,
1615
-  );
1616
-  $form['form control tabs suffix'] = array(
1615
+    );
1616
+    $form['form control tabs suffix'] = array(
1617 1617
     '#value' => '</ul>',
1618 1618
     '#weight' => 1004,
1619
-  );
1620
-  return $form;
1619
+    );
1620
+    return $form;
1621 1621
 }
1622 1622
 
1623 1623
 /**
1624
-  * Handle post-validation submission of community preferences form.
1625
-  */
1624
+ * Handle post-validation submission of community preferences form.
1625
+ */
1626 1626
 function communityprefs_form_submit($form, &$form_state) {
1627
-  require_boinc('boinc_db');
1628
-  global $user;
1629
-  $account = user_load($user->uid);
1630
-  $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1631
-  $edit = $form_state['values'];
1632
-  $profile_node = $form_state['storage']['profile_node'];
1633
-  
1634
-  // Display name
1635
-  if ($edit['boincuser_name'] != $boinc_user->name) {
1627
+    require_boinc('boinc_db');
1628
+    global $user;
1629
+    $account = user_load($user->uid);
1630
+    $boinc_user = BoincUser::lookup_id($account->boincuser_id);
1631
+    $edit = $form_state['values'];
1632
+    $profile_node = $form_state['storage']['profile_node'];
1633
+  
1634
+    // Display name
1635
+    if ($edit['boincuser_name'] != $boinc_user->name) {
1636 1636
     $boincuser_name = $edit['boincuser_name'];
1637 1637
     $result = $boinc_user->update(
1638 1638
         "name='{$boincuser_name}'"
1639 1639
     );
1640
-  }
1640
+    }
1641 1641
   
1642
-  // Private message settings
1643
-  pm_email_notify_user('submit', $edit, $user);
1642
+    // Private message settings
1643
+    pm_email_notify_user('submit', $edit, $user);
1644 1644
   
1645
-  // Avatar settings
1646
-  if (!$edit['field_image']) $edit['field_image'] = array();
1647
-  $profile_node->field_image = $edit['field_image'];
1648
-  node_save($profile_node);
1649
-  // Flush this from the node cache or changes won't show up immediately!
1650
-  $profile_node = node_load($profile_node->nid, NULL, TRUE);
1645
+    // Avatar settings
1646
+    if (!$edit['field_image']) $edit['field_image'] = array();
1647
+    $profile_node->field_image = $edit['field_image'];
1648
+    node_save($profile_node);
1649
+    // Flush this from the node cache or changes won't show up immediately!
1650
+    $profile_node = node_load($profile_node->nid, NULL, TRUE);
1651 1651
   
1652
-  // All other settings
1653
-  $settings = array(
1652
+    // All other settings
1653
+    $settings = array(
1654 1654
     'signature' => $edit['signature'],
1655 1655
     'signature_format' => $edit['signature_format'],
1656 1656
     'timezone' => $edit['timezone'],
@@ -1659,134 +1659,134 @@  discard block
 block discarded – undo
1659 1659
     'hide_signatures' => $edit['hide_signatures'],
1660 1660
     'sort' => $edit['comments_order'],
1661 1661
     'gravatar' => $edit['gravatar'],
1662
-  );
1663
-  if (module_exists('internationalization')) {
1662
+    );
1663
+    if (module_exists('internationalization')) {
1664 1664
     $settings['language'] = $edit['language'];
1665 1665
     global $language;
1666 1666
     if ($user->language != $edit['language']) {
1667
-      global $base_url;
1668
-      if ($edit['language'] != language_default('language')) {
1667
+        global $base_url;
1668
+        if ($edit['language'] != language_default('language')) {
1669 1669
         $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1670
-      }
1671
-      else {
1670
+        }
1671
+        else {
1672 1672
         $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1673
-      }
1673
+        }
1674
+    }
1674 1675
     }
1675
-  }
1676
-  user_save($user, $settings);
1676
+    user_save($user, $settings);
1677 1677
   
1678
-  drupal_set_message(bts('Your community preferences have been updated.'));
1678
+    drupal_set_message(bts('Your community preferences have been updated.'));
1679 1679
   
1680
-  // Form will not redirect if storage is set; not good if language changes
1681
-  unset($form_state['storage']);
1680
+    // Form will not redirect if storage is set; not good if language changes
1681
+    unset($form_state['storage']);
1682 1682
 }
1683 1683
 
1684 1684
 /**
1685 1685
  * The structure of the privacy preferences form
1686 1686
  */
1687 1687
 function boincwork_privacyprefs_form(&$form_state) {
1688
-  require_boinc(array('user', 'prefs', 'util'));
1688
+    require_boinc(array('user', 'prefs', 'util'));
1689 1689
   
1690
-  global $user;
1691
-  $account = user_load($user->uid);
1692
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1690
+    global $user;
1691
+    $account = user_load($user->uid);
1692
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1693 1693
   
1694
-  // Load preferences from BOINC account
1695
-  $prefs = boincwork_load_prefs('project');
1694
+    // Load preferences from BOINC account
1695
+    $prefs = boincwork_load_prefs('project');
1696 1696
   
1697
-  //if (!$prefs AND !$initialize_if_empty) return null;
1697
+    //if (!$prefs AND !$initialize_if_empty) return null;
1698 1698
   
1699
-  // Define form defaults
1700
-  $default = array(
1699
+    // Define form defaults
1700
+    $default = array(
1701 1701
     'privacy' => array(
1702
-      'send_email' => ($boincuser->send_email) ? 1 : 0,
1703
-      'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1702
+        'send_email' => ($boincuser->send_email) ? 1 : 0,
1703
+        'show_hosts' => ($boincuser->show_hosts) ? 1 : 0
1704 1704
     )
1705
-  );
1705
+    );
1706 1706
   
1707
-  // Standard option sets
1708
-  $form['boolean_options'] = array(
1707
+    // Standard option sets
1708
+    $form['boolean_options'] = array(
1709 1709
     '#type' => 'value',
1710 1710
     '#value' => array(1 => bts('yes'), 0 => bts('no'))
1711
-  );
1711
+    );
1712 1712
   
1713
-  $form['privacy'] = array(
1713
+    $form['privacy'] = array(
1714 1714
     '#title' => bts('Privacy settings'),
1715 1715
     '#type' => 'fieldset',
1716 1716
     '#description' => null,
1717 1717
     '#collapsible' => TRUE,
1718 1718
     '#collapsed' => FALSE
1719
-  );
1720
-  $form['privacy']['send_email'] = array(
1719
+    );
1720
+    $form['privacy']['send_email'] = array(
1721 1721
     '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'BOINC'))),
1722 1722
     '#type' => 'radios',
1723 1723
     '#options' => $form['boolean_options']['#value'],
1724 1724
     '#attributes' => array('class' => 'fancy'),
1725 1725
     '#default_value' => $default['privacy']['send_email']
1726
-  );
1727
-  $form['privacy']['show_hosts'] = array(
1726
+    );
1727
+    $form['privacy']['show_hosts'] = array(
1728 1728
     '#title' => bts('Should @project show your computers on its web site?', array('@project' => variable_get('site_name', 'BOINC'))),
1729 1729
     '#type' => 'radios',
1730 1730
     '#options' => $form['boolean_options']['#value'],
1731 1731
     '#attributes' => array('class' => 'fancy'),
1732 1732
     '#default_value' => $default['privacy']['show_hosts']
1733
-  );
1733
+    );
1734 1734
   
1735
-  $form['prefs']['separator_bottom'] = array(
1735
+    $form['prefs']['separator_bottom'] = array(
1736 1736
     '#value' => '<div class="separator buttons"></div>'
1737
-  );
1737
+    );
1738 1738
   
1739
-  // Form control
1740
-  $form['prefs']['form control tabs prefix'] = array(
1739
+    // Form control
1740
+    $form['prefs']['form control tabs prefix'] = array(
1741 1741
     '#value' => '<ul class="form-control tab-list">'
1742
-  );
1743
-  $form['prefs']['submit'] = array(
1742
+    );
1743
+    $form['prefs']['submit'] = array(
1744 1744
     '#prefix' => '<li class="first tab">',
1745 1745
     '#type' => 'submit',
1746 1746
     '#value' => bts('Save changes'),
1747 1747
     '#suffix' => '</li>'
1748
-  );
1749
-  $form['prefs']['form control tabs'] = array(
1748
+    );
1749
+    $form['prefs']['form control tabs'] = array(
1750 1750
     '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>'
1751
-  );
1752
-  $form['prefs']['form control tabs suffix'] = array(
1751
+    );
1752
+    $form['prefs']['form control tabs suffix'] = array(
1753 1753
     '#value' => '</ul>'
1754
-  );
1754
+    );
1755 1755
   
1756
-  return $form;
1756
+    return $form;
1757 1757
 }
1758 1758
 
1759 1759
 /**
1760
-  * Validate the privacy preferences form.
1761
-  */
1760
+ * Validate the privacy preferences form.
1761
+ */
1762 1762
 function boincwork_privacyprefs_form_validate($form, &$form_state) {
1763
-  require_boinc('util');
1763
+    require_boinc('util');
1764 1764
   
1765
-  // Verify all non-boolean user input values and notify form API of failures
1766
-  // ... currently there are no non-boolean values!
1765
+    // Verify all non-boolean user input values and notify form API of failures
1766
+    // ... currently there are no non-boolean values!
1767 1767
 }
1768 1768
 
1769 1769
 /**
1770
-  * Handle post-validation submission of privacy preferences form.
1771
-  */
1770
+ * Handle post-validation submission of privacy preferences form.
1771
+ */
1772 1772
 function boincwork_privacyprefs_form_submit($form, &$form_state) {
1773
-  require_boinc(array('user', 'prefs'));
1773
+    require_boinc(array('user', 'prefs'));
1774 1774
   
1775
-  global $user;
1776
-  $account = user_load($user->uid);
1775
+    global $user;
1776
+    $account = user_load($user->uid);
1777 1777
   
1778
-  // Load BOINC account
1779
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1778
+    // Load BOINC account
1779
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1780 1780
   
1781
-  // Privacy preferences
1782
-  $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1783
-  $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1781
+    // Privacy preferences
1782
+    $boincuser->send_email = ($form_state['values']['send_email']) ? true : false;
1783
+    $boincuser->show_hosts = ($form_state['values']['show_hosts']) ? true : false;
1784 1784
   
1785
-  //project_prefs_update($boincuser, $main_prefs);
1785
+    //project_prefs_update($boincuser, $main_prefs);
1786 1786
   
1787
-  db_set_active('boinc');
1788
-  db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1789
-  db_set_active('default');
1787
+    db_set_active('boinc');
1788
+    db_query("UPDATE user SET send_email = '{$boincuser->send_email}', show_hosts = '{$boincuser->show_hosts}' WHERE id = '{$boincuser->id}'");
1789
+    db_set_active('default');
1790 1790
   
1791
-  drupal_set_message(t('Your privacy preferences have been updated.'));
1791
+    drupal_set_message(t('Your privacy preferences have been updated.'));
1792 1792
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
       }// switch
72 72
   } else {
73 73
       $form_state['storage']['wip'] = TRUE;
74
-      if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
74
+      if (!in_array($prefs_preset, array('standard', 'maximum', 'green', 'minimum', 'custom'))) {
75 75
           if ($established) {
76 76
               $prefs_preset = 'custom';
77 77
           } else {
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
   );
142 142
   $form['hour_options'] = array(
143 143
     '#type' => 'value',
144
-    '#value' => array('0:00','1:00','2:00','3:00','4:00', 
145
-     '5:00','6:00','7:00','8:00','9:00','10:00','11:00', 
146
-     '12:00','13:00','14:00','15:00','16:00','17:00',
147
-     '18:00','19:00','20:00','21:00','22:00','23:00')
144
+    '#value' => array('0:00', '1:00', '2:00', '3:00', '4:00', 
145
+     '5:00', '6:00', '7:00', '8:00', '9:00', '10:00', '11:00', 
146
+     '12:00', '13:00', '14:00', '15:00', '16:00', '17:00',
147
+     '18:00', '19:00', '20:00', '21:00', '22:00', '23:00')
148 148
   );
149 149
   
150 150
   // Identify preference sets that are established to distinguish what has been
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
     '#description' => bts('Suspend computing when your computer is busy running other programs.'),
282 282
   );
283 283
   $form['prefs']['advanced']['processor']['hour_label'] = array(
284
-    '#value' => '<div class="form-item"><label>' . bts('Compute only between:') . '</label></div>'
284
+    '#value' => '<div class="form-item"><label>'.bts('Compute only between:').'</label></div>'
285 285
   );
286 286
   $form['prefs']['advanced']['processor']['start_hour'] = array(
287 287
     '#type' => 'select',
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     '#default_value' => $default['start_hour']
290 290
   );
291 291
   $form['prefs']['advanced']['processor']['hour_delimiter'] = array(
292
-    '#value' => '<span>' . bts('and') . '</span>'
292
+    '#value' => '<span>'.bts('and').'</span>'
293 293
   );
294 294
   $form['prefs']['advanced']['processor']['end_hour'] = array(
295 295
     '#type' => 'select',
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     '#default_value' => $default['end_hour']
298 298
   );
299 299
   $form['prefs']['advanced']['processor']['hour_description'] = array(
300
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Compute only during a particular period each day.') . '</div></div>'
300
+    '#value' => '<div class="form-item slim"><div class="description">'.bts('Compute only during a particular period each day.').'</div></div>'
301 301
   );
302 302
   $form['prefs']['advanced']['processor']['leave_apps_in_memory'] = array(
303 303
     '#title' => bts('Leave non-GPU tasks in memory while suspended?'),
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     '#description' => bts('Limit the upload rate of file transfers.')
455 455
   );
456 456
   $form['prefs']['advanced']['network']['hour_label'] = array(
457
-    '#value' => '<div class="form-item"><label>' . bts('Transfer files only between') . '</label></div>'
457
+    '#value' => '<div class="form-item"><label>'.bts('Transfer files only between').'</label></div>'
458 458
   );
459 459
   $form['prefs']['advanced']['network']['net_start_hour'] = array(
460 460
     '#type' => 'select',
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
     '#default_value' => $default['net_start_hour']
463 463
   );
464 464
   $form['prefs']['advanced']['network']['hour_delimiter'] = array(
465
-    '#value' => '<span>' . bts('and') . '</span>'
465
+    '#value' => '<span>'.bts('and').'</span>'
466 466
   );
467 467
   $form['prefs']['advanced']['network']['net_end_hour'] = array(
468 468
     '#type' => 'select',
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     '#default_value' => $default['net_end_hour']
471 471
   );
472 472
   $form['prefs']['advanced']['network']['hour_description'] = array(
473
-    '#value' => '<div class="form-item slim"><div class="description">' . bts('Transfer files only during a particular period each day.') . '</div></div>'
473
+    '#value' => '<div class="form-item slim"><div class="description">'.bts('Transfer files only during a particular period each day.').'</div></div>'
474 474
   ); 
475 475
   $form['prefs']['advanced']['network']['daily_xfer_limit_mb'] = array(
476 476
     '#title' => bts('Limit usage to'),
@@ -530,23 +530,23 @@  discard block
 block discarded – undo
530 530
     '#suffix' => '</li>'
531 531
   );
532 532
   $form['prefs']['form control tabs'] = array(
533
-    '#value' => '<li class="tab">' . l(bts('Cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
533
+    '#value' => '<li class="tab">'.l(bts('Cancel'), drupal_get_path_alias("account/prefs/computing/edit")).'</li>'
534 534
   );
535 535
   if ($venue AND $venue != 'generic') {
536 536
     global $base_path;
537
-    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
537
+    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">'. 
538 538
       l(bts('Clear'), "account/prefs/computing/clear/{$venue}",
539 539
         array(
540
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
540
+          'query' => 'destination='.urlencode(drupal_get_path_alias('account/prefs/computing/combined')),
541 541
           'attributes' => array(
542
-            'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
-              array('@name' => $venue)) . '\')'
542
+            'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the @name preference set. Are you sure?',
543
+              array('@name' => $venue)).'\')'
544 544
           )
545 545
         )
546
-      ) . '</li>';
546
+      ).'</li>';
547 547
   }
548 548
   $form['prefs']['view control'] = array(
549
-    '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view') . ')', 'account/prefs/computing/combined') . '</li>'
549
+    '#value' => '<li class="first alt tab">'.l('('.bts('Show comparison view').')', 'account/prefs/computing/combined').'</li>'
550 550
   );
551 551
   $form['prefs']['form control tabs suffix'] = array(
552 552
     '#value' => '</ul>'
@@ -852,9 +852,9 @@  discard block
 block discarded – undo
852 852
   }
853 853
   
854 854
   $form['overview'] = array(
855
-    '#value' => '<p>' . bts('Sometimes BOINC assigns separate identities to'
855
+    '#value' => '<p>'.bts('Sometimes BOINC assigns separate identities to'
856 856
       . ' the same computer by mistake. You can correct this by merging old'
857
-      . ' identities with the newest one.') . '</p>'
857
+      . ' identities with the newest one.').'</p>'
858 858
       . '<p>'
859 859
       . bts('Check the computers that are the same as @name'
860 860
       . ' (created on @date at @time with computer ID @id)',
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
           '@time' => date('H:i:s T', $current_host->create_time),
865 865
           '@id' => $current_host->id,
866 866
         )
867
-      ) . '</p>',
867
+      ).'</p>',
868 868
   );
869 869
   
870 870
   $options = array();
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
     '#suffix' => '</li>'
899 899
   );
900 900
   $form['prefs']['form control tabs'] = array(
901
-    '#value' => '<li class="tab">' . l(bts('Cancel'), "host/{$host_id}") . '</li>'
901
+    '#value' => '<li class="tab">'.l(bts('Cancel'), "host/{$host_id}").'</li>'
902 902
   );
903 903
   
904 904
   return $form;
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
       if (count($merged) == 2) {
944 944
         $oxford_comma = '';
945 945
       }
946
-      $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
946
+      $list = implode(', ', $list).$oxford_comma.' '.$conjunction.' '.$last;
947 947
     }
948 948
     else {
949 949
       $list = $last;
@@ -1182,23 +1182,23 @@  discard block
 block discarded – undo
1182 1182
     '#suffix' => '</li>'
1183 1183
   );
1184 1184
   $form['prefs']['form control tabs'] = array(
1185
-    '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>'
1185
+    '#value' => '<li class="tab">'.l(bts('Cancel'), $_GET['q']).'</li>'
1186 1186
   );
1187 1187
   if ($venue AND $venue != 'generic') {
1188 1188
     global $base_path;
1189
-    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
1189
+    $form['prefs']['form control tabs']['#value'] .= '<li class="tab">'. 
1190 1190
       l(bts('Clear'), "account/prefs/project/clear/{$venue}",
1191 1191
         array(
1192
-          'query' => 'destination=' . urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1192
+          'query' => 'destination='.urlencode(drupal_get_path_alias('account/prefs/project/combined')),
1193 1193
           'attributes' => array(
1194
-            'onclick' => 'return confirm(\'' . bts('This will remove all of your settings from the @name preference set. Are you sure?',
1195
-              array('@name' => $venue)) . '\')'
1194
+            'onclick' => 'return confirm(\''.bts('This will remove all of your settings from the @name preference set. Are you sure?',
1195
+              array('@name' => $venue)).'\')'
1196 1196
           )
1197 1197
         )
1198
-      ) . '</li>';
1198
+      ).'</li>';
1199 1199
   }
1200 1200
   $form['prefs']['view control'] = array(
1201
-    '#value' => '<li class="first alt tab">' . l('(' . bts('Show comparison view') . ')', 'account/prefs/project/combined') . '</li>'
1201
+    '#value' => '<li class="first alt tab">'.l('('.bts('Show comparison view').')', 'account/prefs/project/combined').'</li>'
1202 1202
   );
1203 1203
   $form['prefs']['form control tabs suffix'] = array(
1204 1204
     '#value' => '</ul>'
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
     
1242 1242
   foreach ($xml['project_specific_preferences'] as $wrapped_element) {
1243 1243
     $type = key($wrapped_element);
1244
-    $element= reset($wrapped_element);
1244
+    $element = reset($wrapped_element);
1245 1245
     boincwork_generate_prefs_element($form, $type, $element, $prefs['project_specific']);
1246 1246
   }
1247 1247
 }
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
     $names = array();
1468 1468
     foreach ($languages as $langcode => $item) {
1469 1469
       $name = t($item->name);
1470
-      $names[check_plain($langcode)] = check_plain($name . ($item->native != $name ? ' ('. $item->native .')' : ''));
1470
+      $names[check_plain($langcode)] = check_plain($name.($item->native != $name ? ' ('.$item->native.')' : ''));
1471 1471
     }
1472 1472
     $form['locale'] = array(
1473 1473
       '#type' => 'fieldset',
@@ -1492,20 +1492,20 @@  discard block
 block discarded – undo
1492 1492
   // Avatar options
1493 1493
   $form['gravatar'] = array(
1494 1494
     '#type' => 'item',
1495
-    '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail)),
1495
+    '#value' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, it will be used for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/'.$account->mail)),
1496 1496
     '#description' => bts('Your Gravatar will not be shown if you upload a user picture.'),
1497 1497
   );
1498 1498
   if (user_access('disable own gravatar', $account)) {
1499 1499
     $form['gravatar'] = array(
1500 1500
       '#type' => 'checkbox',
1501
-      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/' . $account->mail)),
1501
+      '#title' => bts('If you have a <a href="@gravatar-check">valid Gravatar</a> associated with your e-mail address, use it for your user picture.', array('@gravatar-check' => 'http://en.gravatar.com/site/check/'.$account->mail)),
1502 1502
       '#description' => bts('Gravatar will not be shown if an avatar is uploaded.'),
1503 1503
       '#default_value' => isset($account->gravatar) ? $account->gravatar : 0,
1504 1504
       '#disabled' => !empty($account->picture),
1505 1505
     );
1506 1506
   }
1507 1507
   $form['gravatar']['#weight'] = 15;
1508
-  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">' . bts('Avatar settings') . '</a></legend>';
1508
+  $form['gravatar']['#prefix'] = '<fieldset class="collapsible"><legend><a href="#">'.bts('Avatar settings').'</a></legend>';
1509 1509
   // Upload an avatar (pulled from profile_node_form):
1510 1510
   if (!empty($profile_form['field_image'])) {
1511 1511
     $form['field_image'] = $profile_form['field_image'];
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
   );
1541 1541
   // Can't have a typical Drupal form suffix on a select box?
1542 1542
   $form['forums']['comments_per_page_suffix'] = array(
1543
-    '#value' => '<span>' . bts('comments per page') . '</span>'
1543
+    '#value' => '<span>'.bts('comments per page').'</span>'
1544 1544
   );
1545 1545
   $form['forums']['comments_order'] = array(
1546 1546
     '#type' => 'select',
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
     '#weight' => 1002,
1611 1611
   );
1612 1612
   $form['form control tabs'] = array(
1613
-    '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>',
1613
+    '#value' => '<li class="tab">'.l(bts('Cancel'), $_GET['q']).'</li>',
1614 1614
     '#weight' => 1003,
1615 1615
   );
1616 1616
   $form['form control tabs suffix'] = array(
@@ -1666,10 +1666,10 @@  discard block
 block discarded – undo
1666 1666
     if ($user->language != $edit['language']) {
1667 1667
       global $base_url;
1668 1668
       if ($edit['language'] != language_default('language')) {
1669
-        $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1669
+        $form_state['redirect'] = $base_url.'/'.$edit['language'].'/'.$_GET['q'];
1670 1670
       }
1671 1671
       else {
1672
-        $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1672
+        $form_state['redirect'] = $base_url.'/'.$_GET['q'];
1673 1673
       }
1674 1674
     }
1675 1675
   }
@@ -1747,7 +1747,7 @@  discard block
 block discarded – undo
1747 1747
     '#suffix' => '</li>'
1748 1748
   );
1749 1749
   $form['prefs']['form control tabs'] = array(
1750
-    '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>'
1750
+    '#value' => '<li class="tab">'.l(bts('Cancel'), $_GET['q']).'</li>'
1751 1751
   );
1752 1752
   $form['prefs']['form control tabs suffix'] = array(
1753 1753
     '#value' => '</ul>'
Please login to merge, or discard this patch.
Braces   +16 added lines, -32 removed lines patch added patch discarded remove patch
@@ -127,8 +127,7 @@  discard block
 block discarded – undo
127 127
         if (isset($prefs[$name]['@value'])) {
128 128
           $default[$name] = $prefs[$name]['@value'];
129 129
         }
130
-      }
131
-      else {
130
+      } else {
132 131
         $default[$name] = $prefs[$name];
133 132
       }
134 133
     }
@@ -655,8 +654,7 @@  discard block
 block discarded – undo
655 654
   // Save the preset selection (or lack thereof)
656 655
   if (!$preset OR $preset == 'custom') {
657 656
     $prefs['preset'] = 'custom';
658
-  }
659
-  else {
657
+  } else {
660 658
     $prefs['preset'] = $preset;
661 659
   }
662 660
   
@@ -671,8 +669,7 @@  discard block
 block discarded – undo
671 669
   if (!$result) {
672 670
     watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysql_error()), WATCHDOG_ERROR);
673 671
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
674
-  }
675
-  elseif (!drupal_get_messages('status', FALSE)) {
672
+  } elseif (!drupal_get_messages('status', FALSE)) {
676 673
     // Show this message if the set wasn't created automatically (in which case
677 674
     // there is a message tailored to that) {
678 675
     drupal_set_message(t('Your preferences have been updated.
@@ -927,8 +924,7 @@  discard block
 block discarded – undo
927 924
     if (boincwork_host_merge($old_host, $current_host, $message)) {
928 925
       $merged[$old_host->id] = $old_host->id;
929 926
       $current_host = boincwork_host_get_info($current_host_id);
930
-    }
931
-    else {
927
+    } else {
932 928
       $errors[$old_host->id] = $message;
933 929
     }
934 930
   }
@@ -944,8 +940,7 @@  discard block
 block discarded – undo
944 940
         $oxford_comma = '';
945 941
       }
946 942
       $list = implode(', ', $list) . $oxford_comma . ' ' . $conjunction . ' ' . $last;
947
-    }
948
-    else {
943
+    } else {
949 944
       $list = $last;
950 945
     }
951 946
     if (count($merged) == 1) {
@@ -956,8 +951,7 @@  discard block
 block discarded – undo
956 951
           '@id' => $current_host_id
957 952
         )
958 953
       ));
959
-    }
960
-    else {
954
+    } else {
961 955
       drupal_set_message(bts(
962 956
         'Computers @old_ids have been merged successfully into @id.',
963 957
         array(
@@ -1017,11 +1011,9 @@  discard block
 block discarded – undo
1017 1011
     if ($account->boincuser_default_pref_set == $venue) {
1018 1012
       $venue_is_default = TRUE;
1019 1013
     }
1020
-  }
1021
-  elseif (!$venue OR $venue == 'generic') {
1014
+  } elseif (!$venue OR $venue == 'generic') {
1022 1015
     $venue_is_default = TRUE;
1023
-  }
1024
-  else {
1016
+  } else {
1025 1017
     $venue_is_default = FALSE;
1026 1018
   }
1027 1019
   
@@ -1041,8 +1033,7 @@  discard block
 block discarded – undo
1041 1033
         if (isset($prefs[$name]['@value'])) {
1042 1034
           $default[$name] = $prefs[$name]['@value'];
1043 1035
         }
1044
-      }
1045
-      else {
1036
+      } else {
1046 1037
         $default[$name] = $prefs[$name];
1047 1038
       }
1048 1039
     }
@@ -1222,16 +1213,13 @@  discard block
 block discarded – undo
1222 1213
       foreach ($element as $ordered_element) {
1223 1214
         if (isset($ordered_element['@position'])) {
1224 1215
           $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
1225
-        }
1226
-        else {
1216
+        } else {
1227 1217
           $unordered_array[] = array($type => $ordered_element);
1228 1218
         }
1229 1219
       }
1230
-    }
1231
-    elseif (isset($element['@position'])) {
1220
+    } elseif (isset($element['@position'])) {
1232 1221
       $ordered_array[$element['@position']] = array($type => $element);
1233
-    }
1234
-    else {
1222
+    } else {
1235 1223
       $unordered_array[] = array($type => $element);
1236 1224
     }
1237 1225
   }
@@ -1346,8 +1334,7 @@  discard block
 block discarded – undo
1346 1334
   // Update the user's default preference set
1347 1335
   if ($edit['default_set']['default_venue']) {
1348 1336
     boincwork_set_default_venue($venue);
1349
-  }
1350
-  elseif ($venue == $account->boincuser_default_pref_set) {
1337
+  } elseif ($venue == $account->boincuser_default_pref_set) {
1351 1338
     // User has cleared out the default venue setting
1352 1339
     boincwork_set_default_venue();
1353 1340
   }
@@ -1355,8 +1342,7 @@  discard block
 block discarded – undo
1355 1342
   if (!$result) {
1356 1343
     watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysql_error()), WATCHDOG_ERROR);
1357 1344
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
1358
-  }
1359
-  elseif (!drupal_get_messages('status', FALSE)) {
1345
+  } elseif (!drupal_get_messages('status', FALSE)) {
1360 1346
     // Show this message if the set wasn't created automatically (in which case
1361 1347
     // there is a message tailored to that)
1362 1348
     drupal_set_message(t('Your preferences have been updated.
@@ -1509,8 +1495,7 @@  discard block
 block discarded – undo
1509 1495
   // Upload an avatar (pulled from profile_node_form):
1510 1496
   if (!empty($profile_form['field_image'])) {
1511 1497
     $form['field_image'] = $profile_form['field_image'];
1512
-  }
1513
-  else {
1498
+  } else {
1514 1499
     $form['field_image'] = array(
1515 1500
       '#value' => '<div class="form-item">'
1516 1501
         . '<label class="placeholder">'
@@ -1667,8 +1652,7 @@  discard block
 block discarded – undo
1667 1652
       global $base_url;
1668 1653
       if ($edit['language'] != language_default('language')) {
1669 1654
         $form_state['redirect'] = $base_url . '/' . $edit['language'] . '/' . $_GET['q'];
1670
-      }
1671
-      else {
1655
+      } else {
1672 1656
         $form_state['redirect'] = $base_url . '/' . $_GET['q'];
1673 1657
       }
1674 1658
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -14,10 +14,10 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * The structure of the general preferences form
16 16
  */
17
-function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = FALSE) {
17
+function boincwork_generalprefs_form(&$form_state, $venue, $prefs_preset = null, $advanced = false) {
18 18
   $form = array();
19 19
   $prefs = null;
20
-  $established = TRUE;
20
+  $established = true;
21 21
   
22 22
   // Enable AHAH form support for dynamically updating content based on preset
23 23
   ahah_helper_register($form, $form_state);
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     
33 33
     // Take note if this is not an established preference set on the account
34 34
     if (isset($prefs['@attributes']['cleared'])) {
35
-      $established = FALSE;
35
+      $established = false;
36 36
     }
37 37
     
38 38
     // Determine if a preset is selected or if these are custom settings
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
           break;
71 71
       }// switch
72 72
   } else {
73
-      $form_state['storage']['wip'] = TRUE;
73
+      $form_state['storage']['wip'] = true;
74 74
       if ( !in_array($prefs_preset, array('standard','maximum','green','minimum','custom')) ) {
75 75
           if ($established) {
76 76
               $prefs_preset = 'custom';
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
     '#prefix' => '<div id="prefs-wrapper">', // This is our wrapper div.
159 159
     '#attributes' => array('class' => 'ahah-container'),
160 160
     '#suffix' => '</div>',
161
-    '#tree'   => TRUE
161
+    '#tree'   => true
162 162
   );
163 163
   //$form['prefs']['debug'] = array('#value' => '<pre>' . print_r($form_state, true) . '</pre>');
164 164
   
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
     '#title' => bts('Advanced settings'),
211 211
     '#type' => 'fieldset',
212 212
     '#description' => '',
213
-    '#collapsible' => TRUE,
213
+    '#collapsible' => true,
214 214
     '#collapsed' => !$advanced,
215 215
     '#attributes' => array('class' => 'advanced-settings'),
216 216
   );
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
     '#title' => bts('Processor usage'),
230 230
     '#type' => 'fieldset',
231 231
     '#description' => '',
232
-    '#collapsible' => FALSE,
233
-    '#collapsed' => FALSE
232
+    '#collapsible' => false,
233
+    '#collapsed' => false
234 234
   );
235 235
   $form['prefs']['advanced']['processor']['run_on_batteries'] = array(
236 236
     '#title' => bts('Suspend when computer is on battery?'),
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
     '#title' => bts('Disk and memory usage'),
338 338
     '#type' => 'fieldset',
339 339
     '#description' => '',
340
-    '#collapsible' => FALSE,
341
-    '#collapsed' => FALSE
340
+    '#collapsible' => false,
341
+    '#collapsed' => false
342 342
   );
343 343
   $form['prefs']['advanced']['storage']['disk_max_used_gb'] = array(
344 344
     '#title' => bts('Disk: use no more than'),
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
     '#title' => bts('Network usage'),
403 403
     '#type' => 'fieldset',
404 404
     '#description' => '',
405
-    '#collapsible' => FALSE,
406
-    '#collapsed' => FALSE
405
+    '#collapsible' => false,
406
+    '#collapsed' => false
407 407
   );
408 408
   $form['prefs']['advanced']['network']['work_buf_min_days'] = array(
409 409
     '#title' => bts('Store at least'),
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
   $form['prefs']['form control tabs'] = array(
533 533
     '#value' => '<li class="tab">' . l(bts('Cancel'), drupal_get_path_alias("account/prefs/computing/edit")) . '</li>'
534 534
   );
535
-  if ($venue AND $venue != 'generic') {
535
+  if ($venue and $venue != 'generic') {
536 536
     global $base_path;
537 537
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
538 538
       l(bts('Clear'), "account/prefs/computing/clear/{$venue}",
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
     unset($prefs['@attributes']['preset']);
654 654
   }
655 655
   // Save the preset selection (or lack thereof)
656
-  if (!$preset OR $preset == 'custom') {
656
+  if (!$preset or $preset == 'custom') {
657 657
     $prefs['preset'] = 'custom';
658 658
   }
659 659
   else {
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
     watchdog('boincwork', 'Error updating global prefs for user @id: @message', array('@id' => $account->id, '@message' => mysql_error()), WATCHDOG_ERROR);
673 673
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
674 674
   }
675
-  elseif (!drupal_get_messages('status', FALSE)) {
675
+  elseif (!drupal_get_messages('status', false)) {
676 676
     // Show this message if the set wasn't created automatically (in which case
677 677
     // there is a message tailored to that) {
678 678
     drupal_set_message(t('Your preferences have been updated.
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
   ));
707 707
   db_set_active('default');
708 708
   $current_host->task_count = boincwork_host_get_task_count($current_host->id);
709
-  $current_host->is_new = !$current_host->total_credit AND !$current_host->task_count;
709
+  $current_host->is_new = !$current_host->total_credit and !$current_host->task_count;
710 710
   // Get the list of all other hosts owned by this user for comparison
711 711
   db_set_active('boinc');
712 712
   $all_other_hosts = db_query("
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
     // First, disqualify if hosts were active at the same time
723 723
     if (!$current_host->is_new) {
724 724
       $other_host->task_count = boincwork_host_get_task_count($other_host->id);
725
-      $other_host->is_new = !$other_host->total_credit AND !$other_host->task_count;
725
+      $other_host->is_new = !$other_host->total_credit and !$other_host->task_count;
726 726
       if (!$other_host->is_new) {
727 727
         // If both hosts being compared are not new, see if times overlap
728 728
         if (!times_disjoint($current_host, $other_host)) {
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 /**
756 756
  * Perform the database updates to merge the old host into the new host
757 757
  */
758
-function boincwork_host_merge($old_host, $new_host, &$message = NULL) {
758
+function boincwork_host_merge($old_host, $new_host, &$message = null) {
759 759
   // Decay the average credit of the two hosts
760 760
   require_boinc('credit');
761 761
   $now = time();
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
   );
784 784
   db_set_active('default');
785 785
   if (!$credit_updated) {
786
-    if ($message !== NULL) {
786
+    if ($message !== null) {
787 787
       $message = bts('Could not update credit');
788 788
     }
789
-    return FALSE;
789
+    return false;
790 790
   }
791 791
   
792 792
   // Move results from the old host to the new host
@@ -799,10 +799,10 @@  discard block
 block discarded – undo
799 799
   );
800 800
   db_set_active('default');
801 801
   if (!$results_updated) {
802
-    if ($message !== NULL) {
802
+    if ($message !== null) {
803 803
       $message = bts('Could not update results');
804 804
     }
805
-    return FALSE;
805
+    return false;
806 806
   }
807 807
   
808 808
   // Retire the old host
@@ -819,13 +819,13 @@  discard block
 block discarded – undo
819 819
   );
820 820
   db_set_active('default');
821 821
   if (!$old_host_retired) {
822
-    if ($message !== NULL) {
822
+    if ($message !== null) {
823 823
       $message = bts('Could not retire old computer');
824 824
     }
825
-    return FALSE;
825
+    return false;
826 826
   }
827 827
   
828
-  return TRUE;
828
+  return true;
829 829
 }
830 830
 
831 831
 /**
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
   global $user;
999 999
   $account = user_load($user->uid);
1000 1000
   
1001
-  $established = TRUE;
1001
+  $established = true;
1002 1002
   
1003 1003
   // Get availability of special BOINC preferences
1004 1004
   require_boinc(array('util'));
@@ -1009,20 +1009,20 @@  discard block
 block discarded – undo
1009 1009
   
1010 1010
   // Take note if this is not an established preference set on the account
1011 1011
   if (isset($prefs['@attributes']['cleared'])) {
1012
-    $established = FALSE;
1012
+    $established = false;
1013 1013
   }
1014 1014
   
1015
-  $venue_is_default = FALSE;
1015
+  $venue_is_default = false;
1016 1016
   if ($account->boincuser_default_pref_set) {
1017 1017
     if ($account->boincuser_default_pref_set == $venue) {
1018
-      $venue_is_default = TRUE;
1018
+      $venue_is_default = true;
1019 1019
     }
1020 1020
   }
1021
-  elseif (!$venue OR $venue == 'generic') {
1022
-    $venue_is_default = TRUE;
1021
+  elseif (!$venue or $venue == 'generic') {
1022
+    $venue_is_default = true;
1023 1023
   }
1024 1024
   else {
1025
-    $venue_is_default = FALSE;
1025
+    $venue_is_default = false;
1026 1026
   }
1027 1027
   
1028 1028
   // Define form defaults
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
   $form['#established'] = $established;
1060 1060
   
1061 1061
   // Top level form options
1062
-  $form['#tree'] = TRUE;
1062
+  $form['#tree'] = true;
1063 1063
   
1064 1064
   // Hidden elements
1065 1065
   $form['venue'] = array(
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
     '#title' => bts('Resource settings'),
1077 1077
     '#type' => 'fieldset',
1078 1078
     '#description' => null,
1079
-    '#collapsible' => TRUE,
1080
-    '#collapsed' => FALSE
1079
+    '#collapsible' => true,
1080
+    '#collapsed' => false
1081 1081
   );
1082 1082
   $form['resource']['resource_share'] = array(
1083 1083
     '#title' => bts('Resource share'),
@@ -1129,13 +1129,13 @@  discard block
 block discarded – undo
1129 1129
     }
1130 1130
   }
1131 1131
   
1132
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1132
+  if (variable_get('boinc_prefs_options_beta', false)) {
1133 1133
     $form['beta'] = array(
1134 1134
       '#title' => bts('Beta settings'),
1135 1135
       '#type' => 'fieldset',
1136 1136
       '#description' => null,
1137
-      '#collapsible' => TRUE,
1138
-      '#collapsed' => FALSE
1137
+      '#collapsible' => true,
1138
+      '#collapsed' => false
1139 1139
     );
1140 1140
     $form['beta']['allow_beta_work'] = array(
1141 1141
       '#title' => bts('Run test applications?'),
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
     '#title' => bts('Default set'),
1156 1156
     '#type' => 'fieldset',
1157 1157
     '#description' => null,
1158
-    '#collapsible' => TRUE,
1159
-    '#collapsed' => FALSE
1158
+    '#collapsible' => true,
1159
+    '#collapsed' => false
1160 1160
   );
1161 1161
   $form['default_set']['default_venue'] = array(
1162 1162
     '#title' => bts('Set used for new computers'),
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
   $form['prefs']['form control tabs'] = array(
1185 1185
     '#value' => '<li class="tab">' . l(bts('Cancel'), $_GET['q']) . '</li>'
1186 1186
   );
1187
-  if ($venue AND $venue != 'generic') {
1187
+  if ($venue and $venue != 'generic') {
1188 1188
     global $base_path;
1189 1189
     $form['prefs']['form control tabs']['#value'] .= '<li class="tab">' . 
1190 1190
       l(bts('Clear'), "account/prefs/project/clear/{$venue}",
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
   $ordered_array = array();
1219 1219
   $unordered_array = array();
1220 1220
   foreach ($xml['project_specific_preferences'] as $type => $element) {
1221
-    if (is_array($element) AND is_numeric(key($element))) {
1221
+    if (is_array($element) and is_numeric(key($element))) {
1222 1222
       foreach ($element as $ordered_element) {
1223 1223
         if (isset($ordered_element['@position'])) {
1224 1224
           $ordered_array[$ordered_element['@position']] = array($type => $ordered_element);
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
   // Check for app validation
1271 1271
   if (isset($validation_rules['apps'])) {
1272 1272
     if (isset($validation_rules['apps']['minimum selected'])
1273
-        AND $validation_rules['apps']['minimum selected'] > 0) {
1273
+        and $validation_rules['apps']['minimum selected'] > 0) {
1274 1274
       $apps_selected = 0;
1275 1275
       foreach ($validation_rules['apps']['list'] as $app) {
1276 1276
         if ($form_state['values']['applications'][$app]) $apps_selected++;
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
         foreach ($validation_rules['apps']['list'] as $app) {
1286 1286
           unset($form_state['values']['applications'][$app]);
1287 1287
         }
1288
-        $form_state['storage']['all apps selected'] = TRUE;
1288
+        $form_state['storage']['all apps selected'] = true;
1289 1289
       }
1290 1290
     }
1291 1291
   }
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
   }
1319 1319
   
1320 1320
   // Beta preferences
1321
-  if (variable_get('boinc_prefs_options_beta', FALSE)) {
1321
+  if (variable_get('boinc_prefs_options_beta', false)) {
1322 1322
     $prefs['allow_beta_work'] = ($edit['beta']['allow_beta_work']) ? 1 : 0;
1323 1323
   }
1324 1324
   
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
1356 1356
     watchdog('boincwork', 'Error updating project prefs for user @id: @message', array('@id' => $user->id, '@message' => mysql_error()), WATCHDOG_ERROR);
1357 1357
     drupal_set_message(t('Your changes could not be saved. Please contact support!'), 'error');
1358 1358
   }
1359
-  elseif (!drupal_get_messages('status', FALSE)) {
1359
+  elseif (!drupal_get_messages('status', false)) {
1360 1360
     // Show this message if the set wasn't created automatically (in which case
1361 1361
     // there is a message tailored to that)
1362 1362
     drupal_set_message(t('Your preferences have been updated.
@@ -1397,8 +1397,8 @@  discard block
 block discarded – undo
1397 1397
   $default = array(
1398 1398
     'pm_send_notification' => '', // This is set already in pm_email_notify_user
1399 1399
     'friend_notification' => isset($account->friend_notification) ? $account->friend_notification : 0,
1400
-    'comments_per_page' => (isset($account->comments_per_page) AND $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50),
1401
-    'comments_order' => (isset($account->sort) AND $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST),
1400
+    'comments_per_page' => (isset($account->comments_per_page) and $account->comments_per_page) ? $account->comments_per_page : variable_get('comment_default_per_page_forum', 50),
1401
+    'comments_order' => (isset($account->sort) and $account->sort) ? $account->sort : variable_get('comment_default_order_forum', COMMENT_ORDER_OLDEST_FIRST),
1402 1402
   );
1403 1403
   
1404 1404
   // General options
@@ -1406,8 +1406,8 @@  discard block
 block discarded – undo
1406 1406
     '#type' => 'fieldset',
1407 1407
     '#title' => bts('General settings'),
1408 1408
     '#weight' => 0,
1409
-    '#collapsible' => TRUE,
1410
-    '#collapsed' => FALSE
1409
+    '#collapsible' => true,
1410
+    '#collapsed' => false
1411 1411
   );
1412 1412
   // Add the BOINC user name (non-unique, user editable)
1413 1413
   $form['general']['boincuser_name'] = array(
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
     '#title' => bts('Name'),
1416 1416
     '#default_value' => $account->boincuser_name,
1417 1417
     '#maxlength' => USERNAME_MAX_LENGTH,
1418
-    '#required' => TRUE,
1418
+    '#required' => true,
1419 1419
     '#description' => '',
1420 1420
     '#size' => 40
1421 1421
   );
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
     $form['general']['timezone'] = array(
1426 1426
       '#type' => 'select',
1427 1427
       '#title' => bts('Time zone'),
1428
-      '#default_value' => ($account->timezone !== NULL) ? $account->timezone : variable_get('date_default_timezone', 0),
1428
+      '#default_value' => ($account->timezone !== null) ? $account->timezone : variable_get('date_default_timezone', 0),
1429 1429
       '#options' => $zones,
1430 1430
       '#description' => '',
1431 1431
     );
@@ -1436,8 +1436,8 @@  discard block
 block discarded – undo
1436 1436
     '#type' => 'fieldset',
1437 1437
     '#title' => bts('Notification settings'),
1438 1438
     '#weight' => 5,
1439
-    '#collapsible' => TRUE,
1440
-    '#collapsed' => FALSE
1439
+    '#collapsible' => true,
1440
+    '#collapsed' => false
1441 1441
   );
1442 1442
   // Pull in private message notification handling and tweak the form
1443 1443
   $pm_notify = pm_email_notify_user('form', $edit, $account, 'account');
@@ -1473,8 +1473,8 @@  discard block
 block discarded – undo
1473 1473
       '#type' => 'fieldset',
1474 1474
       '#title' => bts('Language settings'),
1475 1475
       '#weight' => 10,
1476
-      '#collapsible' => TRUE,
1477
-      '#collapsed' => FALSE,
1476
+      '#collapsible' => true,
1477
+      '#collapsed' => false,
1478 1478
     );
1479 1479
 
1480 1480
     // Get language negotiation settings.
@@ -1529,8 +1529,8 @@  discard block
 block discarded – undo
1529 1529
     '#type' => 'fieldset',
1530 1530
     '#title' => bts('Forum settings'),
1531 1531
     '#weight' => 25,
1532
-    '#collapsible' => TRUE,
1533
-    '#collapsed' => FALSE
1532
+    '#collapsible' => true,
1533
+    '#collapsed' => false
1534 1534
   );
1535 1535
   $form['forums']['comments_per_page'] = array(
1536 1536
     '#type' => 'select',
@@ -1562,7 +1562,7 @@  discard block
 block discarded – undo
1562 1562
       drupal_set_message(t("The signature input format has been set to a format you don't have access to. It will be changed to a format you have access to when you save this page."));
1563 1563
       $edit['signature_format'] = FILTER_FORMAT_DEFAULT;
1564 1564
     }
1565
-    $form['forums']['signature_format'] = filter_form($account->signature_format, NULL, array('signature_format'));
1565
+    $form['forums']['signature_format'] = filter_form($account->signature_format, null, array('signature_format'));
1566 1566
     // Optionally hide signatures from comments
1567 1567
     $form['forums']['hide_signatures'] = array(
1568 1568
       '#type' => 'radios',
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
   $profile_node->field_image = $edit['field_image'];
1648 1648
   node_save($profile_node);
1649 1649
   // Flush this from the node cache or changes won't show up immediately!
1650
-  $profile_node = node_load($profile_node->nid, NULL, TRUE);
1650
+  $profile_node = node_load($profile_node->nid, null, true);
1651 1651
   
1652 1652
   // All other settings
1653 1653
   $settings = array(
@@ -1714,8 +1714,8 @@  discard block
 block discarded – undo
1714 1714
     '#title' => bts('Privacy settings'),
1715 1715
     '#type' => 'fieldset',
1716 1716
     '#description' => null,
1717
-    '#collapsible' => TRUE,
1718
-    '#collapsed' => FALSE
1717
+    '#collapsible' => true,
1718
+    '#collapsed' => false
1719 1719
   );
1720 1720
   $form['privacy']['send_email'] = array(
1721 1721
     '#title' => bts('Is it OK for @project and your team (if any) to email you?', array('@project' => variable_get('site_name', 'BOINC'))),
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/boincwork/includes/boincwork.helpers.inc 6 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -977,6 +977,7 @@  discard block
 block discarded – undo
977 977
 
978 978
 /**
979 979
  * Format a number to be displayed using a maximum number of digits
980
+ * @param double $number
980 981
  */ 
981 982
 function boincwork_format_stats($number, $max_digits = 4) {
982 983
   $suffix = array(
@@ -1187,6 +1188,9 @@  discard block
 block discarded – undo
1187 1188
   //  xml_to_array(): Convert an XML DOM object to array format
1188 1189
   //------------------------------------------------------------------------------------------------
1189 1190
   
1191
+  /**
1192
+   * @param DOMDocument $xml
1193
+   */
1190 1194
   function xml_to_array($xml) {
1191 1195
       $node = $xml->firstChild; //$xml->first_child();
1192 1196
       $result = '';
@@ -1269,6 +1273,7 @@  discard block
 block discarded – undo
1269 1273
 
1270 1274
 /**
1271 1275
   * Determine output for host list views when no hosts are found.
1276
+  * @param string $context
1272 1277
   */
1273 1278
 function boincwork_views_host_list_empty_text($context = NULL) {
1274 1279
   
Please login to merge, or discard this patch.
Indentation   +603 added lines, -603 removed lines patch added patch discarded remove patch
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
  * that was selected
12 12
  */
13 13
 function boincwork_ahah_helper_venue_submit($form, &$form_state) {
14
-  $form_state['storage']['prefs']['preset'] = null;
15
-  ahah_helper_generic_submit($form, $form_state);
14
+    $form_state['storage']['prefs']['preset'] = null;
15
+    ahah_helper_generic_submit($form, $form_state);
16 16
 }
17 17
 
18 18
 /**
19 19
  * Get a predetermined set of preferences
20 20
  */
21 21
 function boincwork_get_preset_prefs($preset = null) {
22
-  $saved_state = variable_get('boincwork_preset_prefs', null);
22
+    $saved_state = variable_get('boincwork_preset_prefs', null);
23 23
   
24
-  // If not configured yet, use these values as for inital
25
-  // computing/general preferences.
26
-  if (!$saved_state) {
24
+    // If not configured yet, use these values as for inital
25
+    // computing/general preferences.
26
+    if (!$saved_state) {
27 27
     // Get BOINC project disk space configurations from config.xml to
28 28
     // fill in initial preference values.
29 29
     require_boinc(array('db', 'prefs'));
@@ -160,88 +160,88 @@  discard block
 block discarded – undo
160 160
           <dont_verify_images>0</dont_verify_images>
161 161
         </preset>
162 162
       </general_preferences>';
163
-  }
163
+    }
164 164
   
165
-  // Convert XML data to array format
166
-  $preset_prefs = load_configuration($saved_state);
165
+    // Convert XML data to array format
166
+    $preset_prefs = load_configuration($saved_state);
167 167
   
168
-  if ($preset) {
168
+    if ($preset) {
169 169
     // Load preset from configuration
170 170
     $preset_prefs = (array) $preset_prefs['general_preferences'];
171 171
     if (isset($preset_prefs['preset'])) {
172
-      if (!is_numeric(key($preset_prefs['preset']))) {
172
+        if (!is_numeric(key($preset_prefs['preset']))) {
173 173
         $preset_prefs['preset'] = array($preset_prefs['preset']);
174
-      }
175
-      foreach ($preset_prefs['preset'] as $key => $prefs) {
174
+        }
175
+        foreach ($preset_prefs['preset'] as $key => $prefs) {
176 176
         if (isset($prefs['@attributes']['name']) AND $prefs['@attributes']['name'] == $preset) {
177
-          return $preset_prefs['preset'][$key];
177
+            return $preset_prefs['preset'][$key];
178
+        }
178 179
         }
179
-      }
180 180
     }
181
-  }
182
-  return $preset_prefs;
181
+    }
182
+    return $preset_prefs;
183 183
 }
184 184
 
185 185
 /**
186 186
  * Load (and validate) the project specific configuration XML
187 187
  */
188 188
 function boincwork_get_project_specific_config() {
189
-  $raw_config_data = variable_get('boinc_project_specific_prefs_config', '');
189
+    $raw_config_data = variable_get('boinc_project_specific_prefs_config', '');
190 190
   
191
-  $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
192
-  libxml_use_internal_errors(true);
191
+    $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
192
+    libxml_use_internal_errors(true);
193 193
   
194
-  $xml = new DomDocument();
195
-  $xml->loadXML($raw_config_data, LIBXML_NOBLANKS);
196
-  if (!$xml->schemaValidate($xsd)) {
194
+    $xml = new DomDocument();
195
+    $xml->loadXML($raw_config_data, LIBXML_NOBLANKS);
196
+    if (!$xml->schemaValidate($xsd)) {
197 197
     $errors = libxml_get_errors();
198 198
     $lines = explode("\r", $raw_config_data);
199 199
     drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
200
-      ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
200
+        ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
201 201
     return NULL;
202
-  }
202
+    }
203 203
   
204
-  // Convert XML to array for validation
205
-  $xml = load_configuration($raw_config_data);
206
-  return $xml;
204
+    // Convert XML to array for validation
205
+    $xml = load_configuration($raw_config_data);
206
+    return $xml;
207 207
 }
208 208
 
209 209
 /**
210 210
  * Get rules by which to validate project specific data
211 211
  */
212 212
 function boincwork_get_project_specific_config_validation_rules($xml = array()) {
213
-  $rules = array();
214
-  if (!$xml) {
213
+    $rules = array();
214
+    if (!$xml) {
215 215
     // Read the config XML
216 216
     $xml = boincwork_get_project_specific_config();
217 217
     $xml = $xml['project_specific_preferences'];
218
-  }
219
-  foreach ($xml as $type => $elements) {
218
+    }
219
+    foreach ($xml as $type => $elements) {
220 220
     if (is_array($elements) AND !is_numeric(key($elements))) {
221
-      $elements = array($elements);
221
+        $elements = array($elements);
222 222
     }
223 223
     switch ($type) {
224 224
     case 'compound':
225 225
       foreach ($elements as $element) {
226 226
         $name = $element['@attributes']['name'];
227 227
         $rules[$name] = boincwork_get_project_specific_config_validation_rules($element['attributes']);
228
-      }
229
-      break;
228
+        }
229
+        break;
230 230
       
231 231
     case 'text':
232 232
       foreach ($elements as $element) {
233 233
         $name = $element['@attributes']['name'];
234 234
         $rules[$name] = array(
235
-          'datatype' => $element['@attributes']['datatype']
235
+            'datatype' => $element['@attributes']['datatype']
236 236
         );
237 237
         if (isset($element['@attributes']['min'])) {
238
-          $rules[$name]['min'] = $element['@attributes']['min'];
238
+            $rules[$name]['min'] = $element['@attributes']['min'];
239 239
         }
240 240
         if (isset($element['@attributes']['max'])) {
241
-          $rules[$name]['max'] = $element['@attributes']['max'];
241
+            $rules[$name]['max'] = $element['@attributes']['max'];
242 242
         }
243
-      }
244
-      break;
243
+        }
244
+        break;
245 245
     /*
246 246
     case 'radio':
247 247
     case 'dropdown':
@@ -265,24 +265,24 @@  discard block
 block discarded – undo
265 265
       $rules['apps'] = array(
266 266
         'minimum selected' => 1,
267 267
         'list' => array()
268
-      );
269
-      foreach ($elements as $element) {
268
+        );
269
+        foreach ($elements as $element) {
270 270
         foreach ($element['app'] as $app) {
271
-          $name = "app_{$app['@attributes']['id']}";
272
-          $rules['apps']['list'][] = $name;
273
-          //$rules[$name] = array(
274
-          //  'options' => $options
275
-          //);
271
+            $name = "app_{$app['@attributes']['id']}";
272
+            $rules['apps']['list'][] = $name;
273
+            //$rules[$name] = array(
274
+            //  'options' => $options
275
+            //);
276 276
         }
277
-      }
278
-      break;
277
+        }
278
+        break;
279 279
       
280 280
     case 'group':
281 281
       foreach ($elements as $element) {
282 282
         $name = $element['@attributes']['name'];
283 283
         $rules += boincwork_get_project_specific_config_validation_rules($element);
284
-      }
285
-      break;
284
+        }
285
+        break;
286 286
     /*
287 287
     case 'boolean':
288 288
       // Shouldn't need to validate boolean...
@@ -290,39 +290,39 @@  discard block
 block discarded – undo
290 290
       */
291 291
     default:
292 292
     }
293
-  }
294
-  return $rules;
293
+    }
294
+    return $rules;
295 295
 }
296 296
 
297 297
 /**
298 298
  * Define how project specific settings should be saved
299 299
  */
300 300
 function boincwork_format_project_specific_prefs_data($values, $xml = array()) {
301
-  $defaults = array();
302
-  if (!$xml) {
301
+    $defaults = array();
302
+    if (!$xml) {
303 303
     // Read the config XML
304 304
     $xml = boincwork_get_project_specific_config();
305 305
     $xml = $xml['project_specific_preferences'];
306
-  }
307
-  foreach ($xml as $type => $elements) {
306
+    }
307
+    foreach ($xml as $type => $elements) {
308 308
     $structure_data = array();
309 309
     if (is_array($elements) AND !is_numeric(key($elements))) {
310
-      $elements = array($elements);
310
+        $elements = array($elements);
311 311
     }
312 312
     switch ($type) {
313 313
     case 'compound':
314 314
       foreach ($elements as $element) {
315 315
         $name = $element['@attributes']['name'];
316 316
         $default[$name]['@attributes'] = boincwork_format_project_specific_prefs_data($values[$name], $element['attributes']);
317
-      }
318
-      $defaults += $default;
319
-      break;
317
+        }
318
+        $defaults += $default;
319
+        break;
320 320
       
321 321
     case 'group':
322 322
       foreach ($elements as $element) {
323 323
         $defaults += boincwork_format_project_specific_prefs_data($values, $element);
324
-      }
325
-      break;
324
+        }
325
+        break;
326 326
       
327 327
     case 'text':
328 328
     case 'radio':
@@ -331,315 +331,315 @@  discard block
 block discarded – undo
331 331
       foreach ($elements as $element) {
332 332
         $name = $element['@attributes']['name'];
333 333
         if (isset($element['@attributes']['entitytype']) AND $element['@attributes']['entitytype'] == 'attribute') {
334
-          $defaults['@attributes'][$name] = $values[$name];
334
+            $defaults['@attributes'][$name] = $values[$name];
335 335
         }
336 336
         else {
337
-          $defaults[$name] = $values[$name];
337
+            $defaults[$name] = $values[$name];
338 338
         }
339
-      }
340
-      break;
339
+        }
340
+        break;
341 341
     
342 342
     case 'apps':
343 343
       foreach ($elements as $element) {
344 344
         $defaults['app_id'] = array();
345 345
         foreach ($element['app'] as $app) {
346
-          $app_id = $app['@attributes']['id'];
347
-          if ($values['applications']["app_{$app_id}"]) {
346
+            $app_id = $app['@attributes']['id'];
347
+            if ($values['applications']["app_{$app_id}"]) {
348 348
             $defaults['app_id'][] = $app_id;
349
-          }
349
+            }
350 350
         }
351
-      }
352
-      break;
351
+        }
352
+        break;
353 353
       
354 354
     default:
355 355
     }
356
-  }
357
-  return $defaults;
356
+    }
357
+    return $defaults;
358 358
 }
359 359
 
360 360
 /**
361 361
  * Add an element to the form based on its definition
362 362
  */
363 363
 function boincwork_generate_prefs_element(&$form, $type, $elements, $user_prefs = null) {
364
-  switch ($type) {
365
-  case 'text':
364
+    switch ($type) {
365
+    case 'text':
366 366
     if (!is_numeric(key($elements))) {
367
-      $elements = array($elements);
367
+        $elements = array($elements);
368 368
     }
369 369
     foreach ($elements as $element) {
370
-      $name = $element['@attributes']['name'];
371
-      $default = $element['@attributes']['default'];
372
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
373
-      $description = '';
374
-      if (isset($element['description'])) {
370
+        $name = $element['@attributes']['name'];
371
+        $default = $element['@attributes']['default'];
372
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
373
+        $description = '';
374
+        if (isset($element['description'])) {
375 375
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
376
-      }
376
+        }
377 377
       
378
-      $value = $default;
379
-      $user_pref = $user_prefs;
380
-      $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
381
-      if ($entitytype == 'attribute') {
378
+        $value = $default;
379
+        $user_pref = $user_prefs;
380
+        $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
381
+        if ($entitytype == 'attribute') {
382 382
         $user_pref = $user_prefs['@attributes'];
383
-      }
384
-      if (isset($user_pref[$name])) {
383
+        }
384
+        if (isset($user_pref[$name])) {
385 385
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
386
-          $value = $user_pref[$name]['@value'];
386
+            $value = $user_pref[$name]['@value'];
387 387
         }
388 388
         else {
389
-          $value = $user_pref[$name];
389
+            $value = $user_pref[$name];
390
+        }
390 391
         }
391
-      }
392 392
       
393
-      // Use appropriate datatype
394
-      if (isset($element['@attributes']['datatype'])) {
393
+        // Use appropriate datatype
394
+        if (isset($element['@attributes']['datatype'])) {
395 395
         switch($element['@attributes']['datatype']) {
396 396
         case 'integer':
397 397
           $value = (int) $value;
398
-          break;
398
+            break;
399 399
           
400 400
         case 'float':
401 401
           $value = number_format((float) $value, 2);
402
-          break;
402
+            break;
403 403
         
404 404
         default:
405 405
         }
406
-      }
406
+        }
407 407
       
408
-      // Translate elements as appropriate
409
-      if ($title) {
408
+        // Translate elements as appropriate
409
+        if ($title) {
410 410
         i18nstrings_update('project:prefs_xml', $title);
411 411
         $title = i18nstrings('project:prefs_xml', $title);
412
-      }
413
-      if ($description) {
412
+        }
413
+        if ($description) {
414 414
         i18nstrings_update('project:prefs_xml', $description);
415 415
         $description = i18nstrings('project:prefs_xml', $description);
416
-      }
416
+        }
417 417
       
418
-      $form[$name] = array(
418
+        $form[$name] = array(
419 419
         '#title' => $title,
420 420
         '#type' => 'textfield',
421 421
         '#default_value' => $value,
422 422
         '#size' => 5,
423 423
         '#description' => $description . bts(' Default value: @default', array('@default' => $default))
424
-      );
424
+        );
425 425
     }
426 426
     break;
427 427
     
428
-  case 'boolean':
428
+    case 'boolean':
429 429
     if (!is_numeric(key($elements))) {
430
-      $elements = array($elements);
430
+        $elements = array($elements);
431 431
     }
432 432
     foreach ($elements as $element) {
433
-      $name = $element['@attributes']['name'];
434
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
435
-      $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0;
436
-      $description = '';
437
-      if (isset($element['description'])) {
433
+        $name = $element['@attributes']['name'];
434
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
435
+        $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0;
436
+        $description = '';
437
+        if (isset($element['description'])) {
438 438
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
439
-      }
439
+        }
440 440
       
441
-      $value = $default;
442
-      $user_pref = $user_prefs;
443
-      $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
444
-      if ($entitytype == 'attribute') {
441
+        $value = $default;
442
+        $user_pref = $user_prefs;
443
+        $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
444
+        if ($entitytype == 'attribute') {
445 445
         $user_pref = $user_prefs['@attributes'];
446
-      }
447
-      if (isset($user_pref[$name])) {
446
+        }
447
+        if (isset($user_pref[$name])) {
448 448
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
449
-          $value = $user_pref[$name]['@value'];
449
+            $value = $user_pref[$name]['@value'];
450 450
         }
451 451
         else {
452
-          $value = $user_pref[$name];
452
+            $value = $user_pref[$name];
453
+        }
453 454
         }
454
-      }
455 455
       
456
-      // Translate elements as appropriate
457
-      if ($title) {
456
+        // Translate elements as appropriate
457
+        if ($title) {
458 458
         i18nstrings_update('project:prefs_xml', $title);
459 459
         $title = i18nstrings('project:prefs_xml', $title);
460
-      }
461
-      if ($description) {
460
+        }
461
+        if ($description) {
462 462
         i18nstrings_update('project:prefs_xml', $description);
463 463
         $description = i18nstrings('project:prefs_xml', $description);
464
-      }
464
+        }
465 465
       
466
-      $form[$name] = array(
466
+        $form[$name] = array(
467 467
         '#title' => $title,
468 468
         '#type' => 'radios',
469 469
         '#options' => array(1 => bts('yes'), 0 => bts('no')),
470 470
         '#attributes' => array('class' => 'fancy'),
471 471
         '#default_value' => $value,
472 472
         '#description' => $description
473
-      );
473
+        );
474 474
     }
475 475
     break;
476 476
     
477
-  case 'radio':
477
+    case 'radio':
478 478
   case 'dropdown':
479 479
     
480 480
     if (!is_numeric(key($elements))) {
481
-      $elements = array($elements);
481
+        $elements = array($elements);
482 482
     }
483 483
     foreach ($elements as $element) {
484
-      $name = $element['@attributes']['name'];
485
-      $default = null;
486
-      $options = array();
487
-      foreach($element['items']['item'] as $item) {
484
+        $name = $element['@attributes']['name'];
485
+        $default = null;
486
+        $options = array();
487
+        foreach($element['items']['item'] as $item) {
488 488
         if (is_array($item)) {
489
-          $value = $item['@value'];
490
-          if ($default === NULL AND
489
+            $value = $item['@value'];
490
+            if ($default === NULL AND
491 491
               isset($item['@attributes']) AND
492 492
               isset($item['@attributes']['selected'])) {
493 493
             $default = ($item['@attributes']['selected'] == 'true') ? $item['@value'] : null;
494
-          }
494
+            }
495 495
         }
496 496
         else {
497
-          $value = $item;
497
+            $value = $item;
498 498
         }
499 499
         $options[$value] = $value;
500
-      }
501
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
502
-      $description = '';
503
-      if (isset($element['description'])) {
500
+        }
501
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
502
+        $description = '';
503
+        if (isset($element['description'])) {
504 504
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
505
-      }
506
-      $user_pref = $user_prefs;
507
-      $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
508
-      if ($entitytype == 'attribute') {
505
+        }
506
+        $user_pref = $user_prefs;
507
+        $entitytype = isset($element['@attributes']['entitytype']) ? $element['@attributes']['entitytype'] : 'element';
508
+        if ($entitytype == 'attribute') {
509 509
         $user_pref = $user_prefs['@attributes'];
510
-      }
511
-      $value = isset($user_pref[$name]) ? $user_pref[$name] : $default;
510
+        }
511
+        $value = isset($user_pref[$name]) ? $user_pref[$name] : $default;
512 512
       
513
-      // Translate elements as appropriate
514
-      if ($title) {
513
+        // Translate elements as appropriate
514
+        if ($title) {
515 515
         i18nstrings_update('project:prefs_xml', $title);
516 516
         $title = i18nstrings('project:prefs_xml', $title);
517
-      }
518
-      if ($description) {
517
+        }
518
+        if ($description) {
519 519
         i18nstrings_update('project:prefs_xml', $description);
520 520
         $description = i18nstrings('project:prefs_xml', $description);
521
-      }
521
+        }
522 522
       
523
-      $form[$name] = array(
523
+        $form[$name] = array(
524 524
         '#title' => $title,
525 525
         '#type' => ($type == 'radio') ? 'radios' : 'select',
526 526
         '#options' => $options,
527 527
         '#attributes' => array('class' => 'fancy'),
528 528
         '#default_value' => $value,
529 529
         '#description' => $description . bts(' Default value: @default', array('@default' =>$default))
530
-      );
530
+        );
531 531
     }
532 532
     break;
533 533
     
534
-  case 'apps':
534
+    case 'apps':
535 535
     $title = is_array($elements['title']) ? $elements['title']['@value'] : $elements['title'];
536 536
     
537
-      // Translate elements as appropriate
538
-      if ($title) {
537
+        // Translate elements as appropriate
538
+        if ($title) {
539 539
         i18nstrings_update('project:prefs_xml', $title);
540 540
         $title = i18nstrings('project:prefs_xml', $title);
541
-      }
541
+        }
542 542
     
543 543
     $form['applications'] = array(
544
-      '#title' => bts('Applications'),
545
-      '#type' => 'fieldset',
546
-      '#description' => $title,
547
-      '#collapsible' => TRUE,
548
-      '#collapsed' => FALSE
544
+        '#title' => bts('Applications'),
545
+        '#type' => 'fieldset',
546
+        '#description' => $title,
547
+        '#collapsible' => TRUE,
548
+        '#collapsed' => FALSE
549 549
     );
550 550
     $applications = array();
551 551
     if (!is_array($user_prefs['app_id'])) {
552
-      $user_prefs['app_id'] = array($user_prefs['app_id']);
552
+        $user_prefs['app_id'] = array($user_prefs['app_id']);
553 553
     }
554 554
     foreach ($user_prefs['app_id'] as $app) {
555
-      if (!$app) continue;
556
-      if (is_array($app) AND isset($app['@value'])) {
555
+        if (!$app) continue;
556
+        if (is_array($app) AND isset($app['@value'])) {
557 557
         $app = $app['@value'];
558
-      }
559
-      $applications[] = $app;
558
+        }
559
+        $applications[] = $app;
560 560
     }
561 561
     foreach ($elements['app'] as $app) {
562
-      $app_id = $app['@attributes']['id'];
563
-      $app_name = $app['@value'];
564
-      $app_enabled = TRUE;
565
-      if (isset($app['@attributes']['enabled']) AND
562
+        $app_id = $app['@attributes']['id'];
563
+        $app_name = $app['@value'];
564
+        $app_enabled = TRUE;
565
+        if (isset($app['@attributes']['enabled']) AND
566 566
           $app['@attributes']['enabled'] == 'false') {
567 567
         $app_enabled = FALSE;
568
-      }
569
-      if ($applications) {
568
+        }
569
+        if ($applications) {
570 570
         $checked = in_array($app_id, $applications);
571
-      } else {
571
+        } else {
572 572
         $checked = TRUE;
573 573
         if (isset($app['@attributes']['selected']) AND
574 574
             $app['@attributes']['selected'] == 'false') {
575
-          $checked = FALSE;
575
+            $checked = FALSE;
576 576
         }
577
-      }
578
-      $form['applications']["app_{$app_id}"] = array(
577
+        }
578
+        $form['applications']["app_{$app_id}"] = array(
579 579
         '#title' => $app_name,
580 580
         '#type' => 'checkbox',
581 581
         '#default_value' => ($checked) ? 'x' : false,
582 582
         '#disabled' => !$app_enabled
583
-      );
583
+        );
584 584
     }
585 585
     
586 586
     break;
587 587
     
588
-  case 'group':
588
+    case 'group':
589 589
     if (!is_numeric(key($elements))) {
590
-      $elements = array($elements);
590
+        $elements = array($elements);
591 591
     }
592 592
     foreach ($elements as $key => $element) {
593
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
594
-      $name = str_replace(' ','_',strtolower($title));
595
-      $name = "group_{$name}";
593
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
594
+        $name = str_replace(' ','_',strtolower($title));
595
+        $name = "group_{$name}";
596 596
       
597
-      // Translate elements as appropriate
598
-      if ($title) {
597
+        // Translate elements as appropriate
598
+        if ($title) {
599 599
         i18nstrings_update('project:prefs_xml', $title);
600 600
         $title = i18nstrings('project:prefs_xml', $title);
601
-      }
601
+        }
602 602
       
603
-      $form[$name] = array(
604
-          '#title' => $title,
605
-          '#type' => 'fieldset',
606
-          '#tree' => FALSE,
607
-          //'#description' => t('Notes about this group of fields'),
608
-          '#collapsible' => TRUE,
609
-          '#collapsed' => FALSE
610
-      );
611
-      // Recursively populate the compound element
612
-      foreach ($element as $child_type => $child) {
603
+        $form[$name] = array(
604
+            '#title' => $title,
605
+            '#type' => 'fieldset',
606
+            '#tree' => FALSE,
607
+            //'#description' => t('Notes about this group of fields'),
608
+            '#collapsible' => TRUE,
609
+            '#collapsed' => FALSE
610
+        );
611
+        // Recursively populate the compound element
612
+        foreach ($element as $child_type => $child) {
613 613
         boincwork_generate_prefs_element($form[$name], $child_type, $child, $user_prefs);
614
-      }
614
+        }
615 615
     }
616 616
     break;
617 617
     
618
-  case 'compound':
618
+    case 'compound':
619 619
     if (!is_numeric(key($elements))) {
620
-      $elements = array($elements);
620
+        $elements = array($elements);
621 621
     }
622 622
     foreach ($elements as $element) {
623
-      $name = $element['@attributes']['name'];
624
-      $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
623
+        $name = $element['@attributes']['name'];
624
+        $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
625 625
       
626
-      // Translate elements as appropriate
627
-      if ($title) {
626
+        // Translate elements as appropriate
627
+        if ($title) {
628 628
         i18nstrings_update('project:prefs_xml', $title);
629 629
         $title = i18nstrings('project:prefs_xml', $title);
630
-      }
630
+        }
631 631
       
632
-      $form[$name] = array(
633
-          '#title' => $title,
634
-          '#type' => 'fieldset',
635
-          //'#description' => t('Notes about this group of fields'),
636
-          '#collapsible' => TRUE,
637
-          '#collapsed' => FALSE
638
-      );
639
-      // Recursively populate the compound element
640
-      foreach ($element['attributes'] as $child_type => $child) {
632
+        $form[$name] = array(
633
+            '#title' => $title,
634
+            '#type' => 'fieldset',
635
+            //'#description' => t('Notes about this group of fields'),
636
+            '#collapsible' => TRUE,
637
+            '#collapsed' => FALSE
638
+        );
639
+        // Recursively populate the compound element
640
+        foreach ($element['attributes'] as $child_type => $child) {
641 641
         boincwork_generate_prefs_element($form[$name], $child_type, $child, $user_prefs[$name]['@attributes']);
642
-      }
642
+        }
643 643
     }
644 644
     break;
645 645
     
@@ -655,24 +655,24 @@  discard block
 block discarded – undo
655 655
  */
656 656
 function boincwork_make_prefs_table($prefs, $top_level = TRUE) {
657 657
 
658
-  $prefs_table = array();
659
-  $uncategorized = array();
658
+    $prefs_table = array();
659
+    $uncategorized = array();
660 660
   
661
-  // Parse the project preferences form
662
-  foreach ($prefs as $key => $element) {
661
+    // Parse the project preferences form
662
+    foreach ($prefs as $key => $element) {
663 663
     
664 664
     // Determine which type of element this is and act accordingly
665 665
     $element_type = NULL;
666 666
     if (is_array($element) AND isset($element['#type'])) {
667
-      $element_type = $element['#type'];
667
+        $element_type = $element['#type'];
668 668
     }
669 669
     switch ($element_type) {
670 670
     case 'fieldset':
671 671
       $prefs_table[$key] = array(
672 672
         'name' => $element['#title'],
673 673
         'elements' => boincwork_make_prefs_table($element, FALSE),
674
-      );
675
-      break;
674
+        );
675
+        break;
676 676
     case 'textfield':
677 677
     case 'radios':
678 678
     case 'checkbox':
@@ -682,45 +682,45 @@  discard block
 block discarded – undo
682 682
         switch ($key) {
683 683
         case 'start_hour':
684 684
           $element['#title'] = bts('Compute only between:');
685
-          break;
685
+            break;
686 686
         case 'net_start_hour':
687 687
           $element['#title'] = bts('Transfer files only between:');
688
-          break;
688
+            break;
689 689
         default:
690 690
         }
691
-      }
692
-      $prefs_element = array(
691
+        }
692
+        $prefs_element = array(
693 693
         'name' => (isset($element['#title'])) ? $element['#title'] : '',
694 694
         'description' => (isset($element['#description'])) ? $element['#description'] : '',
695 695
         'default_value' => (isset($element['#default_value'])) ? $element['#default_value'] : NULL,
696
-      );
697
-      if ($top_level) {
696
+        );
697
+        if ($top_level) {
698 698
         $uncategorized[$key] = $prefs_element;
699
-      }
700
-      else {
699
+        }
700
+        else {
701 701
         $prefs_table[$key] = $prefs_element;
702
-      }
703
-      break;
702
+        }
703
+        break;
704 704
     default:
705 705
     }
706
-  }
706
+    }
707 707
   
708
-  if ($prefs_table AND $uncategorized) {
708
+    if ($prefs_table AND $uncategorized) {
709 709
     // Throw any settings that don't fit elsewhere into "other"
710 710
     $prefs_table['other'] = array(
711
-      'name' => bts('Other settings'),
712
-      'elements' => $uncategorized,
711
+        'name' => bts('Other settings'),
712
+        'elements' => $uncategorized,
713 713
     );
714
-  }
715
-  elseif ($uncategorized) {
714
+    }
715
+    elseif ($uncategorized) {
716 716
     // If nothing is categorized, output all prefs under a general "settings"
717 717
     $prefs_table['settings'] = array(
718
-      'name' => bts('Settings'),
719
-      'elements' => $uncategorized,
718
+        'name' => bts('Settings'),
719
+        'elements' => $uncategorized,
720 720
     );
721
-  }
721
+    }
722 722
   
723
-  return $prefs_table;
723
+    return $prefs_table;
724 724
 }
725 725
  
726 726
 /**
@@ -728,33 +728,33 @@  discard block
 block discarded – undo
728 728
  */
729 729
 function boincwork_load_prefs($type = 'general', $venue = null, $account = null) {
730 730
   
731
-  require_boinc(array('user'));
731
+    require_boinc(array('user'));
732 732
   
733
-  // Load the BOINC user object
734
-  if (!$account) {
733
+    // Load the BOINC user object
734
+    if (!$account) {
735 735
     global $user;
736 736
     $account = $user;
737
-  }
738
-  $account = user_load($account->uid);
739
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
737
+    }
738
+    $account = user_load($account->uid);
739
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
740 740
   
741
-  // Load the desired preferences for the user
742
-  $main_prefs = array();
743
-  if ($type == 'project') {
741
+    // Load the desired preferences for the user
742
+    $main_prefs = array();
743
+    if ($type == 'project') {
744 744
     if ($boincuser->project_prefs) {
745
-      $main_prefs = load_configuration($boincuser->project_prefs);
746
-      $main_prefs = (array) $main_prefs['project_preferences'];
745
+        $main_prefs = load_configuration($boincuser->project_prefs);
746
+        $main_prefs = (array) $main_prefs['project_preferences'];
747 747
     }
748
-  }
749
-  else {
748
+    }
749
+    else {
750 750
     if ($boincuser->global_prefs) {
751
-      $main_prefs = load_configuration($boincuser->global_prefs);
752
-      $main_prefs = (array) $main_prefs['global_preferences'];
751
+        $main_prefs = load_configuration($boincuser->global_prefs);
752
+        $main_prefs = (array) $main_prefs['global_preferences'];
753
+    }
753 754
     }
754
-  }
755 755
   
756
-  // Return general preferences or a subset based on venue
757
-  if (!$venue OR $venue == 'generic') {
756
+    // Return general preferences or a subset based on venue
757
+    if (!$venue OR $venue == 'generic') {
758 758
     unset($main_prefs['venue']);
759 759
     // Use the length of the $main_prefs array as a condition as to
760 760
     // whether the preferences have already been set. This is
@@ -762,23 +762,23 @@  discard block
 block discarded – undo
762 762
     if (count($main_prefs) < 3)
763 763
         $main_prefs['@attributes'] = array('cleared' => 1);
764 764
     return $main_prefs;
765
-  }
766
-  else {
765
+    }
766
+    else {
767 767
     if (isset($main_prefs['venue'])) {
768
-      if (!is_numeric(key($main_prefs['venue']))) {
768
+        if (!is_numeric(key($main_prefs['venue']))) {
769 769
         $main_prefs['venue'] = array($main_prefs['venue']);
770
-      }
771
-      foreach ($main_prefs['venue'] as $key => $prefs_venue) {
770
+        }
771
+        foreach ($main_prefs['venue'] as $key => $prefs_venue) {
772 772
         if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
773
-          return $main_prefs['venue'][$key];
773
+            return $main_prefs['venue'][$key];
774
+        }
774 775
         }
775
-      }
776 776
     }
777
-  }
777
+    }
778 778
 
779
-  return array(
779
+    return array(
780 780
     '@attributes' => array('name' => $venue, 'cleared' => 1)
781
-  );
781
+    );
782 782
 }
783 783
 
784 784
 /**
@@ -786,99 +786,99 @@  discard block
 block discarded – undo
786 786
  */
787 787
 function boincwork_save_prefs($prefs, $type = 'general', $venue = null, $account = null) {
788 788
   
789
-  require_boinc(array('user'));
789
+    require_boinc(array('user'));
790 790
   
791
-  // Load existing project prefs from the BOINC user object
792
-  if (!$account) {
791
+    // Load existing project prefs from the BOINC user object
792
+    if (!$account) {
793 793
     global $user;
794 794
     $account = $user;
795
-  }
796
-  $account = user_load($account->uid);
797
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
795
+    }
796
+    $account = user_load($account->uid);
797
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
798 798
   
799
-  // Load the specified preferences for the user
800
-  $main_prefs = array();
801
-  if ($type == 'project') {
799
+    // Load the specified preferences for the user
800
+    $main_prefs = array();
801
+    if ($type == 'project') {
802 802
     if ($boincuser->project_prefs) {
803
-      $main_prefs = load_configuration($boincuser->project_prefs);
804
-      $main_prefs = (array) $main_prefs['project_preferences'];
803
+        $main_prefs = load_configuration($boincuser->project_prefs);
804
+        $main_prefs = (array) $main_prefs['project_preferences'];
805 805
     }
806
-  }
807
-  else {
806
+    }
807
+    else {
808 808
     if ($boincuser->global_prefs) {
809
-      $main_prefs = load_configuration($boincuser->global_prefs);
810
-      $main_prefs = (array) $main_prefs['global_preferences'];
809
+        $main_prefs = load_configuration($boincuser->global_prefs);
810
+        $main_prefs = (array) $main_prefs['global_preferences'];
811
+    }
811 812
     }
812
-  }
813 813
   
814
-  // Save all preferences or a subset based on venue
815
-  //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>');
816
-  $new_venue = true;
817
-  if (!$venue OR $venue == 'generic') {
814
+    // Save all preferences or a subset based on venue
815
+    //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>');
816
+    $new_venue = true;
817
+    if (!$venue OR $venue == 'generic') {
818 818
     //$main_prefs = $prefs;
819 819
     $main_prefs = $prefs + $main_prefs;
820
-  }
821
-  else {
820
+    }
821
+    else {
822 822
     if (isset($main_prefs['venue'])) {
823
-      if (!is_numeric(key($main_prefs['venue']))) {
823
+        if (!is_numeric(key($main_prefs['venue']))) {
824 824
         $main_prefs['venue'] = array($main_prefs['venue']);
825
-      }
826
-      foreach ($main_prefs['venue'] as $key => $prefs_venue) {
825
+        }
826
+        foreach ($main_prefs['venue'] as $key => $prefs_venue) {
827 827
         if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
828
-          if ($prefs) {
828
+            if ($prefs) {
829 829
             $main_prefs['venue'][$key] = $prefs;
830
-          }
831
-          else {
830
+            }
831
+            else {
832 832
             // If prefs is null, clear out this preference set
833 833
             unset($main_prefs['venue'][$key]);
834 834
             if (count($main_prefs['venue']) == 0) {
835
-              // If that was the only preference set configured, unset the
836
-              // venue tag altogether
837
-              unset($main_prefs['venue']);
835
+                // If that was the only preference set configured, unset the
836
+                // venue tag altogether
837
+                unset($main_prefs['venue']);
838 838
             }
839
-          }
840
-          $new_venue = false;
841
-          break;
839
+            }
840
+            $new_venue = false;
841
+            break;
842
+        }
842 843
         }
843
-      }
844 844
     }
845 845
     if ($new_venue) {
846
-      $main_prefs['venue'][] = $prefs;
846
+        $main_prefs['venue'][] = $prefs;
847
+    }
847 848
     }
848
-  }
849 849
   
850
-  // Set modified time
851
-  if ($type == 'general') {
850
+    // Set modified time
851
+    if ($type == 'general') {
852 852
     if (!isset($main_prefs['mod_time'])) {
853
-      $main_prefs = array_merge(array('mod_time' => 0), $main_prefs);
853
+        $main_prefs = array_merge(array('mod_time' => 0), $main_prefs);
854 854
     }
855 855
     $main_prefs['mod_time'] = time();
856 856
     // unset source information, the Client will fill this in again
857 857
     if (isset($main_prefs['source_project'])) {
858
-      unset($main_prefs['source_project']);
858
+        unset($main_prefs['source_project']);
859 859
     }
860 860
     if (isset($main_prefs['source_scheduler'])) {
861
-      unset($main_prefs['source_scheduler']);
861
+        unset($main_prefs['source_scheduler']);
862
+    }
862 863
     }
863
-  }
864 864
   
865
-  // Convert prefs back to XML and save to database
866
-  $result = null;
867
-  if ($type == 'project') {
865
+    // Convert prefs back to XML and save to database
866
+    $result = null;
867
+    if ($type == 'project') {
868 868
     $main_prefs = array('project_preferences' => $main_prefs);
869 869
     $boincuser->project_prefs = save_configuration($main_prefs);
870 870
     db_set_active('boinc');
871 871
     $result = db_query("UPDATE user SET project_prefs = '{$boincuser->project_prefs}' WHERE id = '{$boincuser->id}'");
872 872
     db_set_active('default');
873
-  }
874
-  else {
873
+    }
874
+    else {
875 875
     $main_prefs = array('global_preferences' => $main_prefs);
876 876
     $boincuser->global_prefs = save_configuration($main_prefs);
877 877
     db_set_active('boinc');
878 878
     $result = db_query("UPDATE user SET global_prefs = '{$boincuser->global_prefs}' WHERE id = '{$boincuser->id}'");
879 879
     db_set_active('default');
880
-  }
881
-  return $result;
880
+    }
881
+    return $result;
882 882
 }
883 883
 
884 884
 
@@ -892,94 +892,94 @@  discard block
 block discarded – undo
892 892
  */ 
893 893
 function boincwork_set_default_venue($venue = '') {
894 894
   
895
-  global $user;
896
-  $account = user_load($user->uid);
895
+    global $user;
896
+    $account = user_load($user->uid);
897 897
   
898
-  if ($venue == 'generic') {
898
+    if ($venue == 'generic') {
899 899
     $venue = '';
900
-  }
900
+    }
901 901
   
902
-  db_set_active('boinc');
903
-  db_query("
902
+    db_set_active('boinc');
903
+    db_query("
904 904
     UPDATE user
905 905
     SET venue = '%s'
906 906
     WHERE id = %d",
907 907
     $venue, $account->boincuser_id
908
-  );
909
-  db_set_active('default');
908
+    );
909
+    db_set_active('default');
910 910
 }
911 911
 
912 912
 /**
913 913
  * Recursively validate submitted form values against a set of rules
914 914
  */ 
915 915
 function boincwork_validate_form($validation_rules, $values, $path = array()) {
916
-  foreach ($validation_rules as $field => $rules) {
916
+    foreach ($validation_rules as $field => $rules) {
917 917
     $parents = $path;
918 918
     if (is_array($values[$field])) {
919
-      // Process nested form elements
920
-      $parents[] = $field;
921
-      boincwork_validate_form($rules, $values[$field], $parents);
919
+        // Process nested form elements
920
+        $parents[] = $field;
921
+        boincwork_validate_form($rules, $values[$field], $parents);
922 922
     }
923 923
     else {
924
-      if ($parents) {
924
+        if ($parents) {
925 925
         // form_set_error() identifies nested form elements with '][' as a
926 926
         // delimiter between each parent and child element
927 927
         $parents[] = $field;
928 928
         $form_field = implode('][', $parents);
929
-      }
930
-      else {
929
+        }
930
+        else {
931 931
         $form_field = $field;
932
-      }
933
-      if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
932
+        }
933
+        if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
934 934
         form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field)));
935
-      }
936
-      if (isset($rules['min']) AND $values[$field] < $rules['min']) {
935
+        }
936
+        if (isset($rules['min']) AND $values[$field] < $rules['min']) {
937 937
         form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field)));
938
-      }
939
-      if (isset($rules['max']) AND $values[$field] > $rules['max']) {
938
+        }
939
+        if (isset($rules['max']) AND $values[$field] > $rules['max']) {
940 940
         form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field)));
941
-      }
941
+        }
942
+    }
942 943
     }
943
-  }
944 944
 }
945 945
 
946 946
 /**
947 947
  * Check that numeric data conforms to specifications
948 948
  */
949 949
 function boincwork_validate_datatype($data, $datatype = NULL) {
950
-  switch ($datatype) {
951
-  case 'float':
950
+    switch ($datatype) {
951
+    case 'float':
952 952
     if (!is_numeric($data)) {
953
-      return FALSE;
953
+        return FALSE;
954 954
     }
955 955
     $data += 0;
956 956
     if (!is_float($data)) {
957
-      return FALSE;
957
+        return FALSE;
958 958
     }
959 959
     break;
960 960
     
961
-  case 'integer':
961
+    case 'integer':
962 962
     if (!is_numeric($data)) {
963
-      return FALSE;
963
+        return FALSE;
964 964
     }
965 965
     $data += 0;
966 966
     if (!is_int($data)) {
967
-      return FALSE;
967
+        return FALSE;
968 968
     }
969 969
     break;
970 970
   
971
-  case 'text':
971
+    case 'text':
972 972
   default:
973 973
     
974 974
   }
975
-  return TRUE;
975
+    return TRUE;
976 976
 }
977 977
 
978 978
 /**
979 979
  * Format a number to be displayed using a maximum number of digits
980 980
  */ 
981 981
 function boincwork_format_stats($number, $max_digits = 4) {
982
-  $suffix = array(
982
+    $suffix = array(
983 983
     0 => '',
984 984
     1 => 'k',
985 985
     2 => 'M',
@@ -989,95 +989,95 @@  discard block
 block discarded – undo
989 989
     6 => 'E',
990 990
     7 => 'Z',
991 991
     8 => 'Y'
992
-  );
993
-  if (!is_numeric($number)) $number = 0;
992
+    );
993
+    if (!is_numeric($number)) $number = 0;
994 994
   
995
-  $digits = floor(log($number, 10)) + 1;
996
-  $magnitude = 0;
997
-  $precision = 0;
998
-  if ($digits > $max_digits) {
995
+    $digits = floor(log($number, 10)) + 1;
996
+    $magnitude = 0;
997
+    $precision = 0;
998
+    if ($digits > $max_digits) {
999 999
     $magnitude = floor(($digits - ($max_digits - 3)) / 3);
1000 1000
     $precision = $max_digits - ($digits - ($magnitude * 3) + 1);
1001 1001
     $number = round($number / pow(1000, $magnitude), $precision);
1002
-  }
1003
-  $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1002
+    }
1003
+    $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1004 1004
   
1005
-  return $number;
1005
+    return $number;
1006 1006
 }
1007 1007
 
1008 1008
 
1009
-  //------------------------------------------------------------------------------------------------
1010
-  //  load_configuration(): Convert structured text/xml to array
1011
-  //------------------------------------------------------------------------------------------------
1009
+    //------------------------------------------------------------------------------------------------
1010
+    //  load_configuration(): Convert structured text/xml to array
1011
+    //------------------------------------------------------------------------------------------------
1012 1012
   
1013
-  function load_configuration($text)
1014
-  {
1015
-      if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1016
-      if ($xml = text_to_xml($text)) return xml_to_array($xml);
1017
-      return false;
1018
-  }
1013
+    function load_configuration($text)
1014
+    {
1015
+        if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1016
+        if ($xml = text_to_xml($text)) return xml_to_array($xml);
1017
+        return false;
1018
+    }
1019 1019
   
1020
-  //------------------------------------------------------------------------------------------------
1021
-  //  save_configuration(): Convert array to structured text/xml
1022
-  //------------------------------------------------------------------------------------------------
1020
+    //------------------------------------------------------------------------------------------------
1021
+    //  save_configuration(): Convert array to structured text/xml
1022
+    //------------------------------------------------------------------------------------------------
1023 1023
   
1024
-  function save_configuration($array)
1025
-  {
1026
-      if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1027
-      return false;
1028
-  }
1024
+    function save_configuration($array)
1025
+    {
1026
+        if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1027
+        return false;
1028
+    }
1029 1029
   
1030
-  //------------------------------------------------------------------------------------------------
1031
-  //  array_to_xml(): Take a multidimensional array and convert it to a structured
1032
-  //  DOM XML object
1033
-  //------------------------------------------------------------------------------------------------
1030
+    //------------------------------------------------------------------------------------------------
1031
+    //  array_to_xml(): Take a multidimensional array and convert it to a structured
1032
+    //  DOM XML object
1033
+    //------------------------------------------------------------------------------------------------
1034 1034
   
1035
-  function array_to_xml($array, $dom = false, $parent_node = false) {
1035
+    function array_to_xml($array, $dom = false, $parent_node = false) {
1036 1036
     $is_root = false;
1037 1037
     if (!$dom) $dom = new DomDocument('1.0');
1038 1038
     if (!$parent_node) {
1039
-      $parent_node = $dom;
1040
-      $is_root = true;
1039
+        $parent_node = $dom;
1040
+        $is_root = true;
1041 1041
     }
1042 1042
     // Created an intermediate array to attempt to sort by @position
1043 1043
     $ordered_array = array();
1044 1044
     $unordered_array = array();
1045 1045
     foreach ($array as $name => $value) {
1046
-      if ($is_root) {
1046
+        if ($is_root) {
1047 1047
         $unordered_array[] = $array;
1048 1048
         break;
1049
-      }
1050
-      if (is_array($value)) {
1049
+        }
1050
+        if (is_array($value)) {
1051 1051
         if (is_numeric(key($value))) {
1052
-          foreach ($value as $item) {
1052
+            foreach ($value as $item) {
1053 1053
             if (is_array($item) AND isset($item['@position'])) {
1054
-              $ordered_array[$item['@position']] = array(
1054
+                $ordered_array[$item['@position']] = array(
1055 1055
                 $name => $item
1056
-              );
1056
+                );
1057 1057
             }
1058 1058
             else {
1059
-              $unordered_array[] = array(
1059
+                $unordered_array[] = array(
1060 1060
                 $name => $item
1061
-              );
1061
+                );
1062
+            }
1062 1063
             }
1063
-          }
1064 1064
         }
1065 1065
         elseif (isset($value['@position'])) {
1066
-          $ordered_array[$value['@position']] = array(
1066
+            $ordered_array[$value['@position']] = array(
1067 1067
             $name => $value
1068
-          );
1068
+            );
1069 1069
         }
1070 1070
         else {
1071
-          $unordered_array[] = array(
1071
+            $unordered_array[] = array(
1072 1072
             $name => $value
1073
-          );
1073
+            );
1074 1074
         }
1075
-      }
1076
-      else {
1075
+        }
1076
+        else {
1077 1077
         $unordered_array[] = array(
1078
-          $name => $value
1078
+            $name => $value
1079 1079
         );
1080
-      }
1080
+        }
1081 1081
     }
1082 1082
     
1083 1083
     // Now append items without explicit positions at the end
@@ -1085,39 +1085,39 @@  discard block
 block discarded – undo
1085 1085
     
1086 1086
     // Convert to XML...
1087 1087
     foreach ($primed_array as $item) {
1088
-      list($name, $value) = each($item);
1089
-      if (strcmp($name, '@attributes') == 0) {
1088
+        list($name, $value) = each($item);
1089
+        if (strcmp($name, '@attributes') == 0) {
1090 1090
         if (!is_array($value)) continue;
1091 1091
         foreach ($value as $attributeName => $attributeValue) {
1092
-          $parent_node->setAttribute($attributeName, $attributeValue);
1092
+            $parent_node->setAttribute($attributeName, $attributeValue);
1093 1093
         }
1094
-      } elseif (strcmp($name, '@value') == 0) {
1094
+        } elseif (strcmp($name, '@value') == 0) {
1095 1095
         if (isset($value)) $parent_node->nodeValue = $value;
1096
-      } elseif (strcmp($name, '@position') == 0) {
1096
+        } elseif (strcmp($name, '@position') == 0) {
1097 1097
         continue;
1098
-      } else {
1098
+        } else {
1099 1099
         if (is_numeric($name)) {
1100
-          $name = $parent_node->tagName;
1100
+            $name = $parent_node->tagName;
1101 1101
         }
1102 1102
         $current_item = $dom->createElement($name);
1103 1103
         if (is_array($value)) {
1104
-          if (is_numeric(key($value))) {
1104
+            if (is_numeric(key($value))) {
1105 1105
             $current_node = $parent_node->appendChild($current_item);
1106 1106
             $current_node = array_to_xml($value, $dom, $current_node);
1107 1107
             $child_count = $current_node->childNodes->length;
1108 1108
             for ($i = 0; $i < $child_count; $i++) {
1109
-              $parent_node->appendChild($current_node->childNodes->item(0));
1109
+                $parent_node->appendChild($current_node->childNodes->item(0));
1110 1110
             }
1111 1111
             $parent_node->removeChild($current_node);
1112
-          } else {
1112
+            } else {
1113 1113
             $current_node = $dom->appendChild($current_item);
1114 1114
             $parent_node->appendChild(array_to_xml($value, $dom, $current_node));
1115
-          }
1115
+            }
1116 1116
         } else {
1117
-          if (isset($value)) $current_item->nodeValue = $value;
1118
-          $parent_node->appendChild($current_item);
1117
+            if (isset($value)) $current_item->nodeValue = $value;
1118
+            $parent_node->appendChild($current_item);
1119
+        }
1119 1120
         }
1120
-      }
1121 1121
     }
1122 1122
     /*
1123 1123
     foreach ($array as $name => $value) {
@@ -1153,114 +1153,114 @@  discard block
 block discarded – undo
1153 1153
       }
1154 1154
     }*/
1155 1155
     return $parent_node;
1156
-  }
1156
+    }
1157 1157
   
1158
-  //------------------------------------------------------------------------------------------------
1159
-  //  xml_to_text(): Convert an XML DOM object to string format
1160
-  //------------------------------------------------------------------------------------------------
1158
+    //------------------------------------------------------------------------------------------------
1159
+    //  xml_to_text(): Convert an XML DOM object to string format
1160
+    //------------------------------------------------------------------------------------------------
1161 1161
   
1162
-  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1163
-  {
1164
-      $xml->formatOutput = true;
1165
-      $text = $xml->saveXML();
1166
-      if (!$include_xml_declaration) {
1162
+    function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1163
+    {
1164
+        $xml->formatOutput = true;
1165
+        $text = $xml->saveXML();
1166
+        if (!$include_xml_declaration) {
1167 1167
         $text = preg_replace('/<\?xml version=.*\?>\s*/i', '', $text, 1);
1168
-      }
1169
-      if ($add_carriage_returns) {;
1168
+        }
1169
+        if ($add_carriage_returns) {;
1170 1170
         $text = preg_replace('/\n/i', "\r\n", $text);
1171
-      }
1172
-      return trim($text);
1173
-  }
1171
+        }
1172
+        return trim($text);
1173
+    }
1174 1174
   
1175
-  //------------------------------------------------------------------------------------------------
1176
-  //  text_to_xml(): Convert an XML DOM object to string format
1177
-  //------------------------------------------------------------------------------------------------
1175
+    //------------------------------------------------------------------------------------------------
1176
+    //  text_to_xml(): Convert an XML DOM object to string format
1177
+    //------------------------------------------------------------------------------------------------
1178 1178
   
1179
-  function text_to_xml($text) {
1179
+    function text_to_xml($text) {
1180 1180
     $xml = new DomDocument();
1181 1181
     if ( !($xml->loadXML($text)) ) return false;
1182 1182
     return $xml;
1183
-  }
1183
+    }
1184 1184
   
1185 1185
   
1186
-  //------------------------------------------------------------------------------------------------
1187
-  //  xml_to_array(): Convert an XML DOM object to array format
1188
-  //------------------------------------------------------------------------------------------------
1186
+    //------------------------------------------------------------------------------------------------
1187
+    //  xml_to_array(): Convert an XML DOM object to array format
1188
+    //------------------------------------------------------------------------------------------------
1189 1189
   
1190
-  function xml_to_array($xml) {
1191
-      $node = $xml->firstChild; //$xml->first_child();
1192
-      $result = '';
1193
-      $index = 1;
1194
-      $position = 0;
1195
-      while (!is_null($node)) {
1196
-          switch ($node->nodeType) {
1197
-          case XML_TEXT_NODE:
1190
+    function xml_to_array($xml) {
1191
+        $node = $xml->firstChild; //$xml->first_child();
1192
+        $result = '';
1193
+        $index = 1;
1194
+        $position = 0;
1195
+        while (!is_null($node)) {
1196
+            switch ($node->nodeType) {
1197
+            case XML_TEXT_NODE:
1198 1198
               if (trim($node->nodeValue)  != '') $result = $node->nodeValue;
1199
-              break;
1200
-          case XML_ELEMENT_NODE:
1199
+                break;
1200
+            case XML_ELEMENT_NODE:
1201 1201
               $node_name = $node->nodeName;
1202
-              $parent = $node->parentNode;
1203
-              $sibling = $node->nextSibling;
1202
+                $parent = $node->parentNode;
1203
+                $sibling = $node->nextSibling;
1204 1204
               
1205
-              // Determine if this node forms a set with siblings (share a node name)
1206
-              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1207
-              if (!$sibling) {
1208
-                  $sibling = $node->previousSibling;
1209
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1210
-              }
1205
+                // Determine if this node forms a set with siblings (share a node name)
1206
+                while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1207
+                if (!$sibling) {
1208
+                    $sibling = $node->previousSibling;
1209
+                    while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1210
+                }
1211 1211
               
1212
-              if ($sibling) {
1213
-                  $result[$node_name][$index] = '';
1214
-                  if ($node->childNodes) {
1215
-                      $result[$node_name][$index] = xml_to_array($node) ;
1216
-                  }
1217
-                  if ($node->hasAttributes()) {
1218
-                      $attributes = $node->attributes;
1219
-                      if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1220
-                          $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1221
-                      }
1222
-                      foreach ($attributes as $key => $attribute) {
1223
-                          $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value;
1224
-                      }
1225
-                  }
1226
-                  // Retain the position of the element
1227
-                  if (!is_array($result[$node_name][$index])) {
1212
+                if ($sibling) {
1213
+                    $result[$node_name][$index] = '';
1214
+                    if ($node->childNodes) {
1215
+                        $result[$node_name][$index] = xml_to_array($node) ;
1216
+                    }
1217
+                    if ($node->hasAttributes()) {
1218
+                        $attributes = $node->attributes;
1219
+                        if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1220
+                            $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1221
+                        }
1222
+                        foreach ($attributes as $key => $attribute) {
1223
+                            $result[$node_name][$index]['@attributes'][$attribute->name] = $attribute->value;
1224
+                        }
1225
+                    }
1226
+                    // Retain the position of the element
1227
+                    if (!is_array($result[$node_name][$index])) {
1228 1228
                     $result[$node_name][$index] = array(
1229
-                      '@value' => $result[$node_name][$index]
1229
+                        '@value' => $result[$node_name][$index]
1230 1230
                     );
1231
-                  }
1232
-                  $result[$node_name][$index]['@position'] = $position;
1233
-                  $position++;
1234
-                  $index++;
1235
-              } else {
1236
-                  $result[$node_name] = '';
1237
-                  if ($node->childNodes) {
1238
-                      $result[$node_name] = xml_to_array($node) ;
1239
-                  }
1240
-                  if ($node->hasAttributes()) {
1241
-                      $attributes = $node->attributes;
1242
-                      if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1243
-                          $result[$node_name] = array('@value' => $result[$node_name]);
1244
-                      }
1245
-                      foreach($attributes as $key => $attribute) {
1246
-                          $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1247
-                      }
1248
-                  }
1249
-                  // Retain the position of the element
1250
-                  if (!is_array($result[$node_name])) {
1231
+                    }
1232
+                    $result[$node_name][$index]['@position'] = $position;
1233
+                    $position++;
1234
+                    $index++;
1235
+                } else {
1236
+                    $result[$node_name] = '';
1237
+                    if ($node->childNodes) {
1238
+                        $result[$node_name] = xml_to_array($node) ;
1239
+                    }
1240
+                    if ($node->hasAttributes()) {
1241
+                        $attributes = $node->attributes;
1242
+                        if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1243
+                            $result[$node_name] = array('@value' => $result[$node_name]);
1244
+                        }
1245
+                        foreach($attributes as $key => $attribute) {
1246
+                            $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1247
+                        }
1248
+                    }
1249
+                    // Retain the position of the element
1250
+                    if (!is_array($result[$node_name])) {
1251 1251
                     $result[$node_name] = array(
1252
-                      '@value' => $result[$node_name]
1252
+                        '@value' => $result[$node_name]
1253 1253
                     );
1254
-                  }
1255
-                  $result[$node_name]['@position'] = $position;
1256
-                  $position++;
1257
-              }
1258
-              break;
1259
-          }
1260
-          $node = $node->nextSibling;
1261
-      }
1262
-      return $result;
1263
-  }
1254
+                    }
1255
+                    $result[$node_name]['@position'] = $position;
1256
+                    $position++;
1257
+                }
1258
+                break;
1259
+            }
1260
+            $node = $node->nextSibling;
1261
+        }
1262
+        return $result;
1263
+    }
1264 1264
   
1265 1265
 
1266 1266
 /*  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *
@@ -1268,172 +1268,172 @@  discard block
 block discarded – undo
1268 1268
  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  *  */
1269 1269
 
1270 1270
 /**
1271
-  * Determine output for host list views when no hosts are found.
1272
-  */
1271
+ * Determine output for host list views when no hosts are found.
1272
+ */
1273 1273
 function boincwork_views_host_list_empty_text($context = NULL) {
1274 1274
   
1275
-  // Pull the BOINC user ID from the view arguments to get show_hosts 
1276
-  // preference for that user
1277
-  require_boinc('boinc_db');
1278
-  $view = views_get_current_view();
1279
-  $account = user_load($view->args[0]);
1280
-  $boincuser = BoincUser::lookup_id($account->boincuser_id);
1275
+    // Pull the BOINC user ID from the view arguments to get show_hosts 
1276
+    // preference for that user
1277
+    require_boinc('boinc_db');
1278
+    $view = views_get_current_view();
1279
+    $account = user_load($view->args[0]);
1280
+    $boincuser = BoincUser::lookup_id($account->boincuser_id);
1281 1281
   
1282
-  // Determine if hosts are associated at all or just hidden
1283
-  $output = '';
1284
-  if ($boincuser->show_hosts) {
1282
+    // Determine if hosts are associated at all or just hidden
1283
+    $output = '';
1284
+    if ($boincuser->show_hosts) {
1285 1285
     switch($context) {
1286 1286
     case 'active':
1287 1287
       $output .=  '<h2>' . bts('No active computers') . '</h2>';
1288
-      $output .=  '<p>' . bts('This user has no computers that have been'
1289
-      . ' active in the last 30 days.') . '</p>';
1290
-      break;
1288
+        $output .=  '<p>' . bts('This user has no computers that have been'
1289
+        . ' active in the last 30 days.') . '</p>';
1290
+        break;
1291 1291
       
1292 1292
     case 'preferences':
1293 1293
       $output .=  '<h2>' . bts('No computers') . '</h2>';
1294
-      $output .=  '<p>' . bts('There are no computers assigned to this'
1295
-      . ' preference set.') . '</p>';
1296
-      break;
1294
+        $output .=  '<p>' . bts('There are no computers assigned to this'
1295
+        . ' preference set.') . '</p>';
1296
+        break;
1297 1297
     
1298 1298
     default:
1299 1299
       $output .=  '<h2>' . bts('Computers pending') . '</h2>';
1300
-      $output .=  '<p>' . bts('This user does not yet have any associated'
1301
-      . ' computers. Computers will be displayed when they have earned their'
1302
-      . ' first credits.') . '</p>';
1300
+        $output .=  '<p>' . bts('This user does not yet have any associated'
1301
+        . ' computers. Computers will be displayed when they have earned their'
1302
+        . ' first credits.') . '</p>';
1303 1303
     }
1304
-  }
1305
-  else {
1304
+    }
1305
+    else {
1306 1306
     $output .=  '<h2>' . bts('Computers hidden') . '</h2>';
1307 1307
     $output .=  '<p>' . bts('This user has chosen not to show information'
1308 1308
     . ' about their computers.') . '</p>';
1309
-  }
1310
-  return $output;
1309
+    }
1310
+    return $output;
1311 1311
 }
1312 1312
 
1313 1313
 /**
1314
-  * Determine output for task list views when no tasks are found.
1315
-  */
1314
+ * Determine output for task list views when no tasks are found.
1315
+ */
1316 1316
 function boincwork_views_task_list_empty_text($context = NULL) {
1317 1317
   
1318
-  // 
1319
-  $output = '';
1320
-  switch($context) {
1321
-  default:
1318
+    // 
1319
+    $output = '';
1320
+    switch($context) {
1321
+    default:
1322 1322
     $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context))
1323 1323
     . '</h2>';
1324 1324
     $output .=  '<p>' . bts('There are no tasks of this type on record')
1325 1325
     . '</p>';
1326
-  }
1327
-  return $output;
1326
+    }
1327
+    return $output;
1328 1328
 }
1329 1329
 
1330 1330
 /**
1331
-  * Output links to perform host actions
1332
-  */
1331
+ * Output links to perform host actions
1332
+ */
1333 1333
 function boincwork_host_action_links($host_id) {
1334
-  $output = '';
1335
-  if (boincwork_host_user_is_owner($host_id)) {
1334
+    $output = '';
1335
+    if (boincwork_host_user_is_owner($host_id)) {
1336 1336
     // Show merge hosts option
1337 1337
     $output = '<ul class="tab-list"><li class="first tab">';
1338 1338
     $output .= l(bts('Merge'), "host/{$host_id}/merge");
1339 1339
     $output .= '</li>';
1340 1340
     // If host has no tasks, allow the host to be deleted
1341 1341
     if (!boincwork_host_get_task_count($host_id)) {
1342
-      $output .= '<li class="tab">';
1343
-      $output .= l(bts('Delete'), "host/{$host_id}/delete",
1342
+        $output .= '<li class="tab">';
1343
+        $output .= l(bts('Delete'), "host/{$host_id}/delete",
1344 1344
         array(
1345
-          'attributes' => array(
1345
+            'attributes' => array(
1346 1346
             'onclick' => 'return confirm(\'' . bts('This will delete host @id'
1347
-              . ' from your account forever. Are you sure this is OK?',
1348
-              array('@id' => $host_id)
1347
+                . ' from your account forever. Are you sure this is OK?',
1348
+                array('@id' => $host_id)
1349 1349
             ) . '\')'
1350
-          )
1350
+            )
1351 1351
         )
1352
-      );
1353
-      $output .= '</li>';
1352
+        );
1353
+        $output .= '</li>';
1354 1354
     }
1355 1355
     $output .= '</ul>';
1356
-  }
1357
-  return $output;
1356
+    }
1357
+    return $output;
1358 1358
 }
1359 1359
 
1360 1360
 /**
1361 1361
  * Get details for a given host
1362 1362
  */
1363 1363
 function boincwork_host_get_info($host_id) {
1364
-  db_set_active('boinc');
1365
-  $host = db_fetch_object(db_query(
1364
+    db_set_active('boinc');
1365
+    $host = db_fetch_object(db_query(
1366 1366
     "SELECT * FROM {host} WHERE id = '%d'",
1367 1367
     $host_id
1368
-  ));
1369
-  db_set_active('default');
1370
-  return $host;
1368
+    ));
1369
+    db_set_active('default');
1370
+    return $host;
1371 1371
 }
1372 1372
 
1373 1373
 /**
1374 1374
  * Get the number of tasks associated with a given host
1375 1375
  */
1376 1376
 function boincwork_host_get_task_count($host_id) {
1377
-  db_set_active('boinc');
1378
-  $count = db_result(db_query(
1377
+    db_set_active('boinc');
1378
+    $count = db_result(db_query(
1379 1379
     "SELECT COUNT(*) FROM {result} WHERE hostid = '%d'",
1380 1380
     $host_id
1381
-  ));
1382
-  db_set_active('default');
1383
-  return $count;
1381
+    ));
1382
+    db_set_active('default');
1383
+    return $count;
1384 1384
 }
1385 1385
 
1386 1386
 /**
1387 1387
  * Check whether a user is the owner of a host
1388 1388
  */
1389 1389
 function boincwork_host_user_is_owner($host_id, $uid = NULL) {
1390
-  if (!$uid) {
1390
+    if (!$uid) {
1391 1391
     global $user;
1392 1392
     $uid = $user->uid;
1393
-  }
1394
-  $account = user_load($uid);
1395
-  // Get host owner
1396
-  db_set_active('boinc');
1397
-  $owner = db_result(db_query(
1393
+    }
1394
+    $account = user_load($uid);
1395
+    // Get host owner
1396
+    db_set_active('boinc');
1397
+    $owner = db_result(db_query(
1398 1398
     "SELECT userid FROM {host} WHERE id = '%d'",
1399 1399
     $host_id
1400
-  ));
1401
-  db_set_active('default');
1402
-  return ($account->boincuser_id === $owner);
1400
+    ));
1401
+    db_set_active('default');
1402
+    return ($account->boincuser_id === $owner);
1403 1403
 }
1404 1404
 
1405 1405
 /**
1406
-  * Determine output for host last contact time
1407
-  */
1406
+ * Determine output for host last contact time
1407
+ */
1408 1408
 function boincwork_host_last_contact($timestamp, $host_id = NULL, $context = NULL) {
1409
-  $output = '---';
1410
-  $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1411
-  $log = '';
1412
-  if ($timestamp) {
1409
+    $output = '---';
1410
+    $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1411
+    $log = '';
1412
+    if ($timestamp) {
1413 1413
     $output = gmdate('j M Y | G:i:s', $timestamp) . ' UTC';
1414
-  }
1415
-  if ($root_log_dir AND $host_id) {
1414
+    }
1415
+    if ($root_log_dir AND $host_id) {
1416 1416
     $subdir = substr($host_id, 0, -3) OR $subdir = 0;
1417 1417
     $log = implode('/', array($root_log_dir, $subdir, $host_id));
1418
-  }
1419
-  if ($log AND file_exists($log)) {
1418
+    }
1419
+    if ($log AND file_exists($log)) {
1420 1420
     $output = l($output, "host/{$host_id}/log");
1421
-  }
1422
-  return $output;
1421
+    }
1422
+    return $output;
1423 1423
 }
1424 1424
 
1425 1425
 /**
1426 1426
  * 
1427 1427
  */
1428 1428
 function boincwork_host_venue_selector($host_id) {
1429
-  $output = '';
1430
-  if (function_exists('jump_quickly')) {
1429
+    $output = '';
1430
+    if (function_exists('jump_quickly')) {
1431 1431
     $path = "host/{$host_id}/set-venue";
1432 1432
     $venues = array(
1433
-      "{$path}/generic" => bts('Generic'),
1434
-      "{$path}/home" => bts('Home'),
1435
-      "{$path}/work" => bts('Work'),
1436
-      "{$path}/school" => bts('School')
1433
+        "{$path}/generic" => bts('Generic'),
1434
+        "{$path}/home" => bts('Home'),
1435
+        "{$path}/work" => bts('Work'),
1436
+        "{$path}/school" => bts('School')
1437 1437
     );
1438 1438
     variable_set('jump_use_js_venues-Array', 1);
1439 1439
     drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
@@ -1441,32 +1441,32 @@  discard block
 block discarded – undo
1441 1441
     // Get current venue
1442 1442
     db_set_active('boinc');
1443 1443
     $venue = db_result(db_query(
1444
-      "SELECT venue FROM {host} WHERE id = '%d'",
1445
-      $host_id
1444
+        "SELECT venue FROM {host} WHERE id = '%d'",
1445
+        $host_id
1446 1446
     ));
1447 1447
     db_set_active('default');
1448 1448
     $output .= jump_quickly($venues, 'venues', 1, "{$path}/{$venue}");
1449
-  }
1450
-  return $output;
1449
+    }
1450
+    return $output;
1451 1451
 }
1452 1452
 
1453 1453
 /**
1454
-  * Determine output for task reported time / deadline
1455
-  */
1454
+ * Determine output for task reported time / deadline
1455
+ */
1456 1456
 function boincwork_task_time_reported($received_time = NULL, $deadline = NULL, $context = NULL) {
1457
-  $output = '---';
1458
-  if ($received_time OR $deadline) {
1457
+    $output = '---';
1458
+    if ($received_time OR $deadline) {
1459 1459
     $timestamp = ($received_time) ? $received_time : $deadline;
1460 1460
     $output = gmdate('j M Y, G:i:s', $timestamp) . ' UTC';
1461 1461
     // Add a wrapper to deadline text
1462 1462
     if (!$received_time) {
1463
-      if (time() < $deadline) {
1463
+        if (time() < $deadline) {
1464 1464
         $output = '<span class="on-time">' . $output . '</span>';
1465
-      }
1466
-      else {
1465
+        }
1466
+        else {
1467 1467
         $output = '<span class="past-due">' . $output . '</span>';
1468
-      }
1468
+        }
1469 1469
     }
1470
-  }
1471
-  return $output;
1470
+    }
1471
+    return $output;
1472 1472
 }
Please login to merge, or discard this patch.
Switch Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -643,9 +643,9 @@
 block discarded – undo
643 643
     }
644 644
     break;
645 645
     
646
-    default:
647
-      // Don't generate form elements for things that aren't explicitly form
648
-      // elements (i.e. 'title', '@attributes' keys, and the like)
646
+  default:
647
+    // Don't generate form elements for things that aren't explicitly form
648
+    // elements (i.e. 'title', '@attributes' keys, and the like)
649 649
   }
650 650
 }
651 651
 
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
   
168 168
   if ($preset) {
169 169
     // Load preset from configuration
170
-    $preset_prefs = (array) $preset_prefs['general_preferences'];
170
+    $preset_prefs = (array)$preset_prefs['general_preferences'];
171 171
     if (isset($preset_prefs['preset'])) {
172 172
       if (!is_numeric(key($preset_prefs['preset']))) {
173 173
         $preset_prefs['preset'] = array($preset_prefs['preset']);
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 function boincwork_get_project_specific_config() {
189 189
   $raw_config_data = variable_get('boinc_project_specific_prefs_config', '');
190 190
   
191
-  $xsd = './' . drupal_get_path('module', 'boincwork') . '/includes/projectprefs.xsd';
191
+  $xsd = './'.drupal_get_path('module', 'boincwork').'/includes/projectprefs.xsd';
192 192
   libxml_use_internal_errors(true);
193 193
   
194 194
   $xml = new DomDocument();
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
   if (!$xml->schemaValidate($xsd)) {
197 197
     $errors = libxml_get_errors();
198 198
     $lines = explode("\r", $raw_config_data);
199
-    drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
200
-      ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
199
+    drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}".
200
+      ': <br/>'.htmlentities($lines[$errors[0]->line - 1]), 'error');
201 201
     return NULL;
202 202
   }
203 203
   
@@ -392,13 +392,13 @@  discard block
 block discarded – undo
392 392
       
393 393
       // Use appropriate datatype
394 394
       if (isset($element['@attributes']['datatype'])) {
395
-        switch($element['@attributes']['datatype']) {
395
+        switch ($element['@attributes']['datatype']) {
396 396
         case 'integer':
397
-          $value = (int) $value;
397
+          $value = (int)$value;
398 398
           break;
399 399
           
400 400
         case 'float':
401
-          $value = number_format((float) $value, 2);
401
+          $value = number_format((float)$value, 2);
402 402
           break;
403 403
         
404 404
         default:
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         '#type' => 'textfield',
421 421
         '#default_value' => $value,
422 422
         '#size' => 5,
423
-        '#description' => $description . bts(' Default value: @default', array('@default' => $default))
423
+        '#description' => $description.bts(' Default value: @default', array('@default' => $default))
424 424
       );
425 425
     }
426 426
     break;
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
       $name = $element['@attributes']['name'];
485 485
       $default = null;
486 486
       $options = array();
487
-      foreach($element['items']['item'] as $item) {
487
+      foreach ($element['items']['item'] as $item) {
488 488
         if (is_array($item)) {
489 489
           $value = $item['@value'];
490 490
           if ($default === NULL AND
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
         '#options' => $options,
527 527
         '#attributes' => array('class' => 'fancy'),
528 528
         '#default_value' => $value,
529
-        '#description' => $description . bts(' Default value: @default', array('@default' =>$default))
529
+        '#description' => $description.bts(' Default value: @default', array('@default' =>$default))
530 530
       );
531 531
     }
532 532
     break;
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
     }
592 592
     foreach ($elements as $key => $element) {
593 593
       $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
594
-      $name = str_replace(' ','_',strtolower($title));
594
+      $name = str_replace(' ', '_', strtolower($title));
595 595
       $name = "group_{$name}";
596 596
       
597 597
       // Translate elements as appropriate
@@ -743,13 +743,13 @@  discard block
 block discarded – undo
743 743
   if ($type == 'project') {
744 744
     if ($boincuser->project_prefs) {
745 745
       $main_prefs = load_configuration($boincuser->project_prefs);
746
-      $main_prefs = (array) $main_prefs['project_preferences'];
746
+      $main_prefs = (array)$main_prefs['project_preferences'];
747 747
     }
748 748
   }
749 749
   else {
750 750
     if ($boincuser->global_prefs) {
751 751
       $main_prefs = load_configuration($boincuser->global_prefs);
752
-      $main_prefs = (array) $main_prefs['global_preferences'];
752
+      $main_prefs = (array)$main_prefs['global_preferences'];
753 753
     }
754 754
   }
755 755
   
@@ -801,13 +801,13 @@  discard block
 block discarded – undo
801 801
   if ($type == 'project') {
802 802
     if ($boincuser->project_prefs) {
803 803
       $main_prefs = load_configuration($boincuser->project_prefs);
804
-      $main_prefs = (array) $main_prefs['project_preferences'];
804
+      $main_prefs = (array)$main_prefs['project_preferences'];
805 805
     }
806 806
   }
807 807
   else {
808 808
     if ($boincuser->global_prefs) {
809 809
       $main_prefs = load_configuration($boincuser->global_prefs);
810
-      $main_prefs = (array) $main_prefs['global_preferences'];
810
+      $main_prefs = (array)$main_prefs['global_preferences'];
811 811
     }
812 812
   }
813 813
   
@@ -996,11 +996,11 @@  discard block
 block discarded – undo
996 996
   $magnitude = 0;
997 997
   $precision = 0;
998 998
   if ($digits > $max_digits) {
999
-    $magnitude = floor(($digits - ($max_digits - 3)) / 3);
1000
-    $precision = $max_digits - ($digits - ($magnitude * 3) + 1);
1001
-    $number = round($number / pow(1000, $magnitude), $precision);
999
+    $magnitude = floor(($digits - ($max_digits - 3))/3);
1000
+    $precision = $max_digits - ($digits - ($magnitude*3) + 1);
1001
+    $number = round($number/pow(1000, $magnitude), $precision);
1002 1002
   }
1003
-  $number = number_format($number, $precision) . (($magnitude) ? "{$suffix[$magnitude]}" : '');
1003
+  $number = number_format($number, $precision).(($magnitude) ? "{$suffix[$magnitude]}" : '');
1004 1004
   
1005 1005
   return $number;
1006 1006
 }
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
   
1179 1179
   function text_to_xml($text) {
1180 1180
     $xml = new DomDocument();
1181
-    if ( !($xml->loadXML($text)) ) return false;
1181
+    if (!($xml->loadXML($text))) return false;
1182 1182
     return $xml;
1183 1183
   }
1184 1184
   
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
       while (!is_null($node)) {
1196 1196
           switch ($node->nodeType) {
1197 1197
           case XML_TEXT_NODE:
1198
-              if (trim($node->nodeValue)  != '') $result = $node->nodeValue;
1198
+              if (trim($node->nodeValue) != '') $result = $node->nodeValue;
1199 1199
               break;
1200 1200
           case XML_ELEMENT_NODE:
1201 1201
               $node_name = $node->nodeName;
@@ -1212,7 +1212,7 @@  discard block
 block discarded – undo
1212 1212
               if ($sibling) {
1213 1213
                   $result[$node_name][$index] = '';
1214 1214
                   if ($node->childNodes) {
1215
-                      $result[$node_name][$index] = xml_to_array($node) ;
1215
+                      $result[$node_name][$index] = xml_to_array($node);
1216 1216
                   }
1217 1217
                   if ($node->hasAttributes()) {
1218 1218
                       $attributes = $node->attributes;
@@ -1235,14 +1235,14 @@  discard block
 block discarded – undo
1235 1235
               } else {
1236 1236
                   $result[$node_name] = '';
1237 1237
                   if ($node->childNodes) {
1238
-                      $result[$node_name] = xml_to_array($node) ;
1238
+                      $result[$node_name] = xml_to_array($node);
1239 1239
                   }
1240 1240
                   if ($node->hasAttributes()) {
1241 1241
                       $attributes = $node->attributes;
1242 1242
                       if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1243 1243
                           $result[$node_name] = array('@value' => $result[$node_name]);
1244 1244
                       }
1245
-                      foreach($attributes as $key => $attribute) {
1245
+                      foreach ($attributes as $key => $attribute) {
1246 1246
                           $result[$node_name]['@attributes'][$attribute->name] = $attribute->value;
1247 1247
                       }
1248 1248
                   }
@@ -1282,30 +1282,30 @@  discard block
 block discarded – undo
1282 1282
   // Determine if hosts are associated at all or just hidden
1283 1283
   $output = '';
1284 1284
   if ($boincuser->show_hosts) {
1285
-    switch($context) {
1285
+    switch ($context) {
1286 1286
     case 'active':
1287
-      $output .=  '<h2>' . bts('No active computers') . '</h2>';
1288
-      $output .=  '<p>' . bts('This user has no computers that have been'
1289
-      . ' active in the last 30 days.') . '</p>';
1287
+      $output .= '<h2>'.bts('No active computers').'</h2>';
1288
+      $output .= '<p>'.bts('This user has no computers that have been'
1289
+      . ' active in the last 30 days.').'</p>';
1290 1290
       break;
1291 1291
       
1292 1292
     case 'preferences':
1293
-      $output .=  '<h2>' . bts('No computers') . '</h2>';
1294
-      $output .=  '<p>' . bts('There are no computers assigned to this'
1295
-      . ' preference set.') . '</p>';
1293
+      $output .= '<h2>'.bts('No computers').'</h2>';
1294
+      $output .= '<p>'.bts('There are no computers assigned to this'
1295
+      . ' preference set.').'</p>';
1296 1296
       break;
1297 1297
     
1298 1298
     default:
1299
-      $output .=  '<h2>' . bts('Computers pending') . '</h2>';
1300
-      $output .=  '<p>' . bts('This user does not yet have any associated'
1299
+      $output .= '<h2>'.bts('Computers pending').'</h2>';
1300
+      $output .= '<p>'.bts('This user does not yet have any associated'
1301 1301
       . ' computers. Computers will be displayed when they have earned their'
1302
-      . ' first credits.') . '</p>';
1302
+      . ' first credits.').'</p>';
1303 1303
     }
1304 1304
   }
1305 1305
   else {
1306
-    $output .=  '<h2>' . bts('Computers hidden') . '</h2>';
1307
-    $output .=  '<p>' . bts('This user has chosen not to show information'
1308
-    . ' about their computers.') . '</p>';
1306
+    $output .= '<h2>'.bts('Computers hidden').'</h2>';
1307
+    $output .= '<p>'.bts('This user has chosen not to show information'
1308
+    . ' about their computers.').'</p>';
1309 1309
   }
1310 1310
   return $output;
1311 1311
 }
@@ -1317,11 +1317,11 @@  discard block
 block discarded – undo
1317 1317
   
1318 1318
   // 
1319 1319
   $output = '';
1320
-  switch($context) {
1320
+  switch ($context) {
1321 1321
   default:
1322
-    $output .=  '<h2>' . bts('No @type tasks', array('@type' => $context))
1322
+    $output .= '<h2>'.bts('No @type tasks', array('@type' => $context))
1323 1323
     . '</h2>';
1324
-    $output .=  '<p>' . bts('There are no tasks of this type on record')
1324
+    $output .= '<p>'.bts('There are no tasks of this type on record')
1325 1325
     . '</p>';
1326 1326
   }
1327 1327
   return $output;
@@ -1343,10 +1343,10 @@  discard block
 block discarded – undo
1343 1343
       $output .= l(bts('Delete'), "host/{$host_id}/delete",
1344 1344
         array(
1345 1345
           'attributes' => array(
1346
-            'onclick' => 'return confirm(\'' . bts('This will delete host @id'
1346
+            'onclick' => 'return confirm(\''.bts('This will delete host @id'
1347 1347
               . ' from your account forever. Are you sure this is OK?',
1348 1348
               array('@id' => $host_id)
1349
-            ) . '\')'
1349
+            ).'\')'
1350 1350
           )
1351 1351
         )
1352 1352
       );
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
   $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1411 1411
   $log = '';
1412 1412
   if ($timestamp) {
1413
-    $output = gmdate('j M Y | G:i:s', $timestamp) . ' UTC';
1413
+    $output = gmdate('j M Y | G:i:s', $timestamp).' UTC';
1414 1414
   }
1415 1415
   if ($root_log_dir AND $host_id) {
1416 1416
     $subdir = substr($host_id, 0, -3) OR $subdir = 0;
@@ -1436,8 +1436,8 @@  discard block
 block discarded – undo
1436 1436
       "{$path}/school" => bts('School')
1437 1437
     );
1438 1438
     variable_set('jump_use_js_venues-Array', 1);
1439
-    drupal_add_js(drupal_get_path('module', 'jump') . '/jump.js');
1440
-    drupal_add_js(drupal_get_path('theme', 'boinc') . '/js/prefs.js', 'theme');
1439
+    drupal_add_js(drupal_get_path('module', 'jump').'/jump.js');
1440
+    drupal_add_js(drupal_get_path('theme', 'boinc').'/js/prefs.js', 'theme');
1441 1441
     // Get current venue
1442 1442
     db_set_active('boinc');
1443 1443
     $venue = db_result(db_query(
@@ -1457,14 +1457,14 @@  discard block
 block discarded – undo
1457 1457
   $output = '---';
1458 1458
   if ($received_time OR $deadline) {
1459 1459
     $timestamp = ($received_time) ? $received_time : $deadline;
1460
-    $output = gmdate('j M Y, G:i:s', $timestamp) . ' UTC';
1460
+    $output = gmdate('j M Y, G:i:s', $timestamp).' UTC';
1461 1461
     // Add a wrapper to deadline text
1462 1462
     if (!$received_time) {
1463 1463
       if (time() < $deadline) {
1464
-        $output = '<span class="on-time">' . $output . '</span>';
1464
+        $output = '<span class="on-time">'.$output.'</span>';
1465 1465
       }
1466 1466
       else {
1467
-        $output = '<span class="past-due">' . $output . '</span>';
1467
+        $output = '<span class="past-due">'.$output.'</span>';
1468 1468
       }
1469 1469
     }
1470 1470
   }
Please login to merge, or discard this patch.
Braces   +29 added lines, -48 removed lines patch added patch discarded remove patch
@@ -332,8 +332,7 @@  discard block
 block discarded – undo
332 332
         $name = $element['@attributes']['name'];
333 333
         if (isset($element['@attributes']['entitytype']) AND $element['@attributes']['entitytype'] == 'attribute') {
334 334
           $defaults['@attributes'][$name] = $values[$name];
335
-        }
336
-        else {
335
+        } else {
337 336
           $defaults[$name] = $values[$name];
338 337
         }
339 338
       }
@@ -384,8 +383,7 @@  discard block
 block discarded – undo
384 383
       if (isset($user_pref[$name])) {
385 384
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
386 385
           $value = $user_pref[$name]['@value'];
387
-        }
388
-        else {
386
+        } else {
389 387
           $value = $user_pref[$name];
390 388
         }
391 389
       }
@@ -447,8 +445,7 @@  discard block
 block discarded – undo
447 445
       if (isset($user_pref[$name])) {
448 446
         if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
449 447
           $value = $user_pref[$name]['@value'];
450
-        }
451
-        else {
448
+        } else {
452 449
           $value = $user_pref[$name];
453 450
         }
454 451
       }
@@ -492,8 +489,7 @@  discard block
 block discarded – undo
492 489
               isset($item['@attributes']['selected'])) {
493 490
             $default = ($item['@attributes']['selected'] == 'true') ? $item['@value'] : null;
494 491
           }
495
-        }
496
-        else {
492
+        } else {
497 493
           $value = $item;
498 494
         }
499 495
         $options[$value] = $value;
@@ -696,8 +692,7 @@  discard block
 block discarded – undo
696 692
       );
697 693
       if ($top_level) {
698 694
         $uncategorized[$key] = $prefs_element;
699
-      }
700
-      else {
695
+      } else {
701 696
         $prefs_table[$key] = $prefs_element;
702 697
       }
703 698
       break;
@@ -711,8 +706,7 @@  discard block
 block discarded – undo
711 706
       'name' => bts('Other settings'),
712 707
       'elements' => $uncategorized,
713 708
     );
714
-  }
715
-  elseif ($uncategorized) {
709
+  } elseif ($uncategorized) {
716 710
     // If nothing is categorized, output all prefs under a general "settings"
717 711
     $prefs_table['settings'] = array(
718 712
       'name' => bts('Settings'),
@@ -745,8 +739,7 @@  discard block
 block discarded – undo
745 739
       $main_prefs = load_configuration($boincuser->project_prefs);
746 740
       $main_prefs = (array) $main_prefs['project_preferences'];
747 741
     }
748
-  }
749
-  else {
742
+  } else {
750 743
     if ($boincuser->global_prefs) {
751 744
       $main_prefs = load_configuration($boincuser->global_prefs);
752 745
       $main_prefs = (array) $main_prefs['global_preferences'];
@@ -762,8 +755,7 @@  discard block
 block discarded – undo
762 755
     if (count($main_prefs) < 3)
763 756
         $main_prefs['@attributes'] = array('cleared' => 1);
764 757
     return $main_prefs;
765
-  }
766
-  else {
758
+  } else {
767 759
     if (isset($main_prefs['venue'])) {
768 760
       if (!is_numeric(key($main_prefs['venue']))) {
769 761
         $main_prefs['venue'] = array($main_prefs['venue']);
@@ -803,8 +795,7 @@  discard block
 block discarded – undo
803 795
       $main_prefs = load_configuration($boincuser->project_prefs);
804 796
       $main_prefs = (array) $main_prefs['project_preferences'];
805 797
     }
806
-  }
807
-  else {
798
+  } else {
808 799
     if ($boincuser->global_prefs) {
809 800
       $main_prefs = load_configuration($boincuser->global_prefs);
810 801
       $main_prefs = (array) $main_prefs['global_preferences'];
@@ -817,8 +808,7 @@  discard block
 block discarded – undo
817 808
   if (!$venue OR $venue == 'generic') {
818 809
     //$main_prefs = $prefs;
819 810
     $main_prefs = $prefs + $main_prefs;
820
-  }
821
-  else {
811
+  } else {
822 812
     if (isset($main_prefs['venue'])) {
823 813
       if (!is_numeric(key($main_prefs['venue']))) {
824 814
         $main_prefs['venue'] = array($main_prefs['venue']);
@@ -827,8 +817,7 @@  discard block
 block discarded – undo
827 817
         if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
828 818
           if ($prefs) {
829 819
             $main_prefs['venue'][$key] = $prefs;
830
-          }
831
-          else {
820
+          } else {
832 821
             // If prefs is null, clear out this preference set
833 822
             unset($main_prefs['venue'][$key]);
834 823
             if (count($main_prefs['venue']) == 0) {
@@ -870,8 +859,7 @@  discard block
 block discarded – undo
870 859
     db_set_active('boinc');
871 860
     $result = db_query("UPDATE user SET project_prefs = '{$boincuser->project_prefs}' WHERE id = '{$boincuser->id}'");
872 861
     db_set_active('default');
873
-  }
874
-  else {
862
+  } else {
875 863
     $main_prefs = array('global_preferences' => $main_prefs);
876 864
     $boincuser->global_prefs = save_configuration($main_prefs);
877 865
     db_set_active('boinc');
@@ -919,15 +907,13 @@  discard block
 block discarded – undo
919 907
       // Process nested form elements
920 908
       $parents[] = $field;
921 909
       boincwork_validate_form($rules, $values[$field], $parents);
922
-    }
923
-    else {
910
+    } else {
924 911
       if ($parents) {
925 912
         // form_set_error() identifies nested form elements with '][' as a
926 913
         // delimiter between each parent and child element
927 914
         $parents[] = $field;
928 915
         $form_field = implode('][', $parents);
929
-      }
930
-      else {
916
+      } else {
931 917
         $form_field = $field;
932 918
       }
933 919
       if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
@@ -1010,8 +996,7 @@  discard block
 block discarded – undo
1010 996
   //  load_configuration(): Convert structured text/xml to array
1011 997
   //------------------------------------------------------------------------------------------------
1012 998
   
1013
-  function load_configuration($text)
1014
-  {
999
+  function load_configuration($text) {
1015 1000
       if (preg_match('/^\<\?xml .*\?\>$/i', $text)) return null;
1016 1001
       if ($xml = text_to_xml($text)) return xml_to_array($xml);
1017 1002
       return false;
@@ -1021,8 +1006,7 @@  discard block
 block discarded – undo
1021 1006
   //  save_configuration(): Convert array to structured text/xml
1022 1007
   //------------------------------------------------------------------------------------------------
1023 1008
   
1024
-  function save_configuration($array)
1025
-  {
1009
+  function save_configuration($array) {
1026 1010
       if ($xml = array_to_xml($array)) return xml_to_text($xml, false, true);
1027 1011
       return false;
1028 1012
   }
@@ -1054,26 +1038,22 @@  discard block
 block discarded – undo
1054 1038
               $ordered_array[$item['@position']] = array(
1055 1039
                 $name => $item
1056 1040
               );
1057
-            }
1058
-            else {
1041
+            } else {
1059 1042
               $unordered_array[] = array(
1060 1043
                 $name => $item
1061 1044
               );
1062 1045
             }
1063 1046
           }
1064
-        }
1065
-        elseif (isset($value['@position'])) {
1047
+        } elseif (isset($value['@position'])) {
1066 1048
           $ordered_array[$value['@position']] = array(
1067 1049
             $name => $value
1068 1050
           );
1069
-        }
1070
-        else {
1051
+        } else {
1071 1052
           $unordered_array[] = array(
1072 1053
             $name => $value
1073 1054
           );
1074 1055
         }
1075
-      }
1076
-      else {
1056
+      } else {
1077 1057
         $unordered_array[] = array(
1078 1058
           $name => $value
1079 1059
         );
@@ -1159,8 +1139,7 @@  discard block
 block discarded – undo
1159 1139
   //  xml_to_text(): Convert an XML DOM object to string format
1160 1140
   //------------------------------------------------------------------------------------------------
1161 1141
   
1162
-  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false)
1163
-  {
1142
+  function xml_to_text($xml, $include_xml_declaration = true, $add_carriage_returns = false) {
1164 1143
       $xml->formatOutput = true;
1165 1144
       $text = $xml->saveXML();
1166 1145
       if (!$include_xml_declaration) {
@@ -1203,10 +1182,14 @@  discard block
 block discarded – undo
1203 1182
               $sibling = $node->nextSibling;
1204 1183
               
1205 1184
               // Determine if this node forms a set with siblings (share a node name)
1206
-              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1185
+              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) {
1186
+                  $sibling = $sibling->nextSibling;
1187
+              }
1207 1188
               if (!$sibling) {
1208 1189
                   $sibling = $node->previousSibling;
1209
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1190
+                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) {
1191
+                      $sibling = $sibling->previousSibling;
1192
+                  }
1210 1193
               }
1211 1194
               
1212 1195
               if ($sibling) {
@@ -1301,8 +1284,7 @@  discard block
 block discarded – undo
1301 1284
       . ' computers. Computers will be displayed when they have earned their'
1302 1285
       . ' first credits.') . '</p>';
1303 1286
     }
1304
-  }
1305
-  else {
1287
+  } else {
1306 1288
     $output .=  '<h2>' . bts('Computers hidden') . '</h2>';
1307 1289
     $output .=  '<p>' . bts('This user has chosen not to show information'
1308 1290
     . ' about their computers.') . '</p>';
@@ -1462,8 +1444,7 @@  discard block
 block discarded – undo
1462 1444
     if (!$received_time) {
1463 1445
       if (time() < $deadline) {
1464 1446
         $output = '<span class="on-time">' . $output . '</span>';
1465
-      }
1466
-      else {
1447
+      } else {
1467 1448
         $output = '<span class="past-due">' . $output . '</span>';
1468 1449
       }
1469 1450
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         $preset_prefs['preset'] = array($preset_prefs['preset']);
174 174
       }
175 175
       foreach ($preset_prefs['preset'] as $key => $prefs) {
176
-        if (isset($prefs['@attributes']['name']) AND $prefs['@attributes']['name'] == $preset) {
176
+        if (isset($prefs['@attributes']['name']) and $prefs['@attributes']['name'] == $preset) {
177 177
           return $preset_prefs['preset'][$key];
178 178
         }
179 179
       }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
     $lines = explode("\r", $raw_config_data);
199 199
     drupal_set_message("{$errors[0]->message} at line {$errors[0]->line}" .
200 200
       ': <br/>' . htmlentities($lines[$errors[0]->line - 1]), 'error');
201
-    return NULL;
201
+    return null;
202 202
   }
203 203
   
204 204
   // Convert XML to array for validation
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     $xml = $xml['project_specific_preferences'];
218 218
   }
219 219
   foreach ($xml as $type => $elements) {
220
-    if (is_array($elements) AND !is_numeric(key($elements))) {
220
+    if (is_array($elements) and !is_numeric(key($elements))) {
221 221
       $elements = array($elements);
222 222
     }
223 223
     switch ($type) {
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
   }
307 307
   foreach ($xml as $type => $elements) {
308 308
     $structure_data = array();
309
-    if (is_array($elements) AND !is_numeric(key($elements))) {
309
+    if (is_array($elements) and !is_numeric(key($elements))) {
310 310
       $elements = array($elements);
311 311
     }
312 312
     switch ($type) {
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     case 'boolean':
331 331
       foreach ($elements as $element) {
332 332
         $name = $element['@attributes']['name'];
333
-        if (isset($element['@attributes']['entitytype']) AND $element['@attributes']['entitytype'] == 'attribute') {
333
+        if (isset($element['@attributes']['entitytype']) and $element['@attributes']['entitytype'] == 'attribute') {
334 334
           $defaults['@attributes'][$name] = $values[$name];
335 335
         }
336 336
         else {
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         $user_pref = $user_prefs['@attributes'];
383 383
       }
384 384
       if (isset($user_pref[$name])) {
385
-        if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
385
+        if (is_array($user_pref[$name]) and isset($user_pref[$name]['@value'])) {
386 386
           $value = $user_pref[$name]['@value'];
387 387
         }
388 388
         else {
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
     foreach ($elements as $element) {
433 433
       $name = $element['@attributes']['name'];
434 434
       $title = is_array($element['title']) ? $element['title']['@value'] : $element['title'];
435
-      $default = (isset($element['@attributes']['selected']) AND $element['@attributes']['selected'] == 'true') ? 1 : 0;
435
+      $default = (isset($element['@attributes']['selected']) and $element['@attributes']['selected'] == 'true') ? 1 : 0;
436 436
       $description = '';
437 437
       if (isset($element['description'])) {
438 438
         $description = is_array($element['description']) ? $element['description']['@value'] : $element['description'];
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         $user_pref = $user_prefs['@attributes'];
446 446
       }
447 447
       if (isset($user_pref[$name])) {
448
-        if (is_array($user_pref[$name]) AND isset($user_pref[$name]['@value'])) {
448
+        if (is_array($user_pref[$name]) and isset($user_pref[$name]['@value'])) {
449 449
           $value = $user_pref[$name]['@value'];
450 450
         }
451 451
         else {
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
       foreach($element['items']['item'] as $item) {
488 488
         if (is_array($item)) {
489 489
           $value = $item['@value'];
490
-          if ($default === NULL AND
491
-              isset($item['@attributes']) AND
490
+          if ($default === null and
491
+              isset($item['@attributes']) and
492 492
               isset($item['@attributes']['selected'])) {
493 493
             $default = ($item['@attributes']['selected'] == 'true') ? $item['@value'] : null;
494 494
           }
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
       '#title' => bts('Applications'),
545 545
       '#type' => 'fieldset',
546 546
       '#description' => $title,
547
-      '#collapsible' => TRUE,
548
-      '#collapsed' => FALSE
547
+      '#collapsible' => true,
548
+      '#collapsed' => false
549 549
     );
550 550
     $applications = array();
551 551
     if (!is_array($user_prefs['app_id'])) {
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
     }
554 554
     foreach ($user_prefs['app_id'] as $app) {
555 555
       if (!$app) continue;
556
-      if (is_array($app) AND isset($app['@value'])) {
556
+      if (is_array($app) and isset($app['@value'])) {
557 557
         $app = $app['@value'];
558 558
       }
559 559
       $applications[] = $app;
@@ -561,18 +561,18 @@  discard block
 block discarded – undo
561 561
     foreach ($elements['app'] as $app) {
562 562
       $app_id = $app['@attributes']['id'];
563 563
       $app_name = $app['@value'];
564
-      $app_enabled = TRUE;
565
-      if (isset($app['@attributes']['enabled']) AND
564
+      $app_enabled = true;
565
+      if (isset($app['@attributes']['enabled']) and
566 566
           $app['@attributes']['enabled'] == 'false') {
567
-        $app_enabled = FALSE;
567
+        $app_enabled = false;
568 568
       }
569 569
       if ($applications) {
570 570
         $checked = in_array($app_id, $applications);
571 571
       } else {
572
-        $checked = TRUE;
573
-        if (isset($app['@attributes']['selected']) AND
572
+        $checked = true;
573
+        if (isset($app['@attributes']['selected']) and
574 574
             $app['@attributes']['selected'] == 'false') {
575
-          $checked = FALSE;
575
+          $checked = false;
576 576
         }
577 577
       }
578 578
       $form['applications']["app_{$app_id}"] = array(
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
       $form[$name] = array(
604 604
           '#title' => $title,
605 605
           '#type' => 'fieldset',
606
-          '#tree' => FALSE,
606
+          '#tree' => false,
607 607
           //'#description' => t('Notes about this group of fields'),
608
-          '#collapsible' => TRUE,
609
-          '#collapsed' => FALSE
608
+          '#collapsible' => true,
609
+          '#collapsed' => false
610 610
       );
611 611
       // Recursively populate the compound element
612 612
       foreach ($element as $child_type => $child) {
@@ -633,8 +633,8 @@  discard block
 block discarded – undo
633 633
           '#title' => $title,
634 634
           '#type' => 'fieldset',
635 635
           //'#description' => t('Notes about this group of fields'),
636
-          '#collapsible' => TRUE,
637
-          '#collapsed' => FALSE
636
+          '#collapsible' => true,
637
+          '#collapsed' => false
638 638
       );
639 639
       // Recursively populate the compound element
640 640
       foreach ($element['attributes'] as $child_type => $child) {
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
  * Generate a tabular structure out of preferences for use in comparison
654 654
  * views of preference sets
655 655
  */
656
-function boincwork_make_prefs_table($prefs, $top_level = TRUE) {
656
+function boincwork_make_prefs_table($prefs, $top_level = true) {
657 657
 
658 658
   $prefs_table = array();
659 659
   $uncategorized = array();
@@ -662,15 +662,15 @@  discard block
 block discarded – undo
662 662
   foreach ($prefs as $key => $element) {
663 663
     
664 664
     // Determine which type of element this is and act accordingly
665
-    $element_type = NULL;
666
-    if (is_array($element) AND isset($element['#type'])) {
665
+    $element_type = null;
666
+    if (is_array($element) and isset($element['#type'])) {
667 667
       $element_type = $element['#type'];
668 668
     }
669 669
     switch ($element_type) {
670 670
     case 'fieldset':
671 671
       $prefs_table[$key] = array(
672 672
         'name' => $element['#title'],
673
-        'elements' => boincwork_make_prefs_table($element, FALSE),
673
+        'elements' => boincwork_make_prefs_table($element, false),
674 674
       );
675 675
       break;
676 676
     case 'textfield':
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
       $prefs_element = array(
693 693
         'name' => (isset($element['#title'])) ? $element['#title'] : '',
694 694
         'description' => (isset($element['#description'])) ? $element['#description'] : '',
695
-        'default_value' => (isset($element['#default_value'])) ? $element['#default_value'] : NULL,
695
+        'default_value' => (isset($element['#default_value'])) ? $element['#default_value'] : null,
696 696
       );
697 697
       if ($top_level) {
698 698
         $uncategorized[$key] = $prefs_element;
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
     }
706 706
   }
707 707
   
708
-  if ($prefs_table AND $uncategorized) {
708
+  if ($prefs_table and $uncategorized) {
709 709
     // Throw any settings that don't fit elsewhere into "other"
710 710
     $prefs_table['other'] = array(
711 711
       'name' => bts('Other settings'),
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
   }
755 755
   
756 756
   // Return general preferences or a subset based on venue
757
-  if (!$venue OR $venue == 'generic') {
757
+  if (!$venue or $venue == 'generic') {
758 758
     unset($main_prefs['venue']);
759 759
     // Use the length of the $main_prefs array as a condition as to
760 760
     // whether the preferences have already been set. This is
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
         $main_prefs['venue'] = array($main_prefs['venue']);
770 770
       }
771 771
       foreach ($main_prefs['venue'] as $key => $prefs_venue) {
772
-        if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
772
+        if (isset($prefs_venue['@attributes']['name']) and $prefs_venue['@attributes']['name'] == $venue) {
773 773
           return $main_prefs['venue'][$key];
774 774
         }
775 775
       }
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
   // Save all preferences or a subset based on venue
815 815
   //drupal_set_message('<pre>' . print_r($main_prefs, true) . '</pre>');
816 816
   $new_venue = true;
817
-  if (!$venue OR $venue == 'generic') {
817
+  if (!$venue or $venue == 'generic') {
818 818
     //$main_prefs = $prefs;
819 819
     $main_prefs = $prefs + $main_prefs;
820 820
   }
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
         $main_prefs['venue'] = array($main_prefs['venue']);
825 825
       }
826 826
       foreach ($main_prefs['venue'] as $key => $prefs_venue) {
827
-        if (isset($prefs_venue['@attributes']['name']) AND $prefs_venue['@attributes']['name'] == $venue) {
827
+        if (isset($prefs_venue['@attributes']['name']) and $prefs_venue['@attributes']['name'] == $venue) {
828 828
           if ($prefs) {
829 829
             $main_prefs['venue'][$key] = $prefs;
830 830
           }
@@ -930,13 +930,13 @@  discard block
 block discarded – undo
930 930
       else {
931 931
         $form_field = $field;
932 932
       }
933
-      if (isset($rules['datatype']) AND !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
933
+      if (isset($rules['datatype']) and !boincwork_validate_datatype($values[$field], $rules['datatype'])) {
934 934
         form_set_error($form_field, bts('Invalid data type for @field', array('@field' => $field)));
935 935
       }
936
-      if (isset($rules['min']) AND $values[$field] < $rules['min']) {
936
+      if (isset($rules['min']) and $values[$field] < $rules['min']) {
937 937
         form_set_error($form_field, bts('Minimum value not met for @field', array('@field' => $field)));
938 938
       }
939
-      if (isset($rules['max']) AND $values[$field] > $rules['max']) {
939
+      if (isset($rules['max']) and $values[$field] > $rules['max']) {
940 940
         form_set_error($form_field, bts('Maximum value exceeded for @field', array('@field' => $field)));
941 941
       }
942 942
     }
@@ -946,25 +946,25 @@  discard block
 block discarded – undo
946 946
 /**
947 947
  * Check that numeric data conforms to specifications
948 948
  */
949
-function boincwork_validate_datatype($data, $datatype = NULL) {
949
+function boincwork_validate_datatype($data, $datatype = null) {
950 950
   switch ($datatype) {
951 951
   case 'float':
952 952
     if (!is_numeric($data)) {
953
-      return FALSE;
953
+      return false;
954 954
     }
955 955
     $data += 0;
956 956
     if (!is_float($data)) {
957
-      return FALSE;
957
+      return false;
958 958
     }
959 959
     break;
960 960
     
961 961
   case 'integer':
962 962
     if (!is_numeric($data)) {
963
-      return FALSE;
963
+      return false;
964 964
     }
965 965
     $data += 0;
966 966
     if (!is_int($data)) {
967
-      return FALSE;
967
+      return false;
968 968
     }
969 969
     break;
970 970
   
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
   default:
973 973
     
974 974
   }
975
-  return TRUE;
975
+  return true;
976 976
 }
977 977
 
978 978
 /**
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
       if (is_array($value)) {
1051 1051
         if (is_numeric(key($value))) {
1052 1052
           foreach ($value as $item) {
1053
-            if (is_array($item) AND isset($item['@position'])) {
1053
+            if (is_array($item) and isset($item['@position'])) {
1054 1054
               $ordered_array[$item['@position']] = array(
1055 1055
                 $name => $item
1056 1056
               );
@@ -1203,10 +1203,10 @@  discard block
 block discarded – undo
1203 1203
               $sibling = $node->nextSibling;
1204 1204
               
1205 1205
               // Determine if this node forms a set with siblings (share a node name)
1206
-              while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1206
+              while (($sibling) and (($sibling->nodeType != XML_ELEMENT_NODE) or ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->nextSibling;
1207 1207
               if (!$sibling) {
1208 1208
                   $sibling = $node->previousSibling;
1209
-                  while (($sibling) AND (($sibling->nodeType != XML_ELEMENT_NODE) OR ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1209
+                  while (($sibling) and (($sibling->nodeType != XML_ELEMENT_NODE) or ($sibling->nodeName != $node->nodeName))) $sibling = $sibling->previousSibling;
1210 1210
               }
1211 1211
               
1212 1212
               if ($sibling) {
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
                   }
1217 1217
                   if ($node->hasAttributes()) {
1218 1218
                       $attributes = $node->attributes;
1219
-                      if ($result[$node_name][$index] !== '' AND !is_array($result[$node_name][$index])) {
1219
+                      if ($result[$node_name][$index] !== '' and !is_array($result[$node_name][$index])) {
1220 1220
                           $result[$node_name][$index] = array('@value' => $result[$node_name][$index]);
1221 1221
                       }
1222 1222
                       foreach ($attributes as $key => $attribute) {
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
                   }
1240 1240
                   if ($node->hasAttributes()) {
1241 1241
                       $attributes = $node->attributes;
1242
-                      if ($result[$node_name] !== '' AND !is_array($result[$node_name])) {
1242
+                      if ($result[$node_name] !== '' and !is_array($result[$node_name])) {
1243 1243
                           $result[$node_name] = array('@value' => $result[$node_name]);
1244 1244
                       }
1245 1245
                       foreach($attributes as $key => $attribute) {
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 /**
1271 1271
   * Determine output for host list views when no hosts are found.
1272 1272
   */
1273
-function boincwork_views_host_list_empty_text($context = NULL) {
1273
+function boincwork_views_host_list_empty_text($context = null) {
1274 1274
   
1275 1275
   // Pull the BOINC user ID from the view arguments to get show_hosts 
1276 1276
   // preference for that user
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 /**
1314 1314
   * Determine output for task list views when no tasks are found.
1315 1315
   */
1316
-function boincwork_views_task_list_empty_text($context = NULL) {
1316
+function boincwork_views_task_list_empty_text($context = null) {
1317 1317
   
1318 1318
   // 
1319 1319
   $output = '';
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
 /**
1387 1387
  * Check whether a user is the owner of a host
1388 1388
  */
1389
-function boincwork_host_user_is_owner($host_id, $uid = NULL) {
1389
+function boincwork_host_user_is_owner($host_id, $uid = null) {
1390 1390
   if (!$uid) {
1391 1391
     global $user;
1392 1392
     $uid = $user->uid;
@@ -1405,18 +1405,18 @@  discard block
 block discarded – undo
1405 1405
 /**
1406 1406
   * Determine output for host last contact time
1407 1407
   */
1408
-function boincwork_host_last_contact($timestamp, $host_id = NULL, $context = NULL) {
1408
+function boincwork_host_last_contact($timestamp, $host_id = null, $context = null) {
1409 1409
   $output = '---';
1410 1410
   $root_log_dir = variable_get('boinc_host_sched_logs_dir', '');
1411 1411
   $log = '';
1412 1412
   if ($timestamp) {
1413 1413
     $output = gmdate('j M Y | G:i:s', $timestamp) . ' UTC';
1414 1414
   }
1415
-  if ($root_log_dir AND $host_id) {
1416
-    $subdir = substr($host_id, 0, -3) OR $subdir = 0;
1415
+  if ($root_log_dir and $host_id) {
1416
+    $subdir = substr($host_id, 0, -3) or $subdir = 0;
1417 1417
     $log = implode('/', array($root_log_dir, $subdir, $host_id));
1418 1418
   }
1419
-  if ($log AND file_exists($log)) {
1419
+  if ($log and file_exists($log)) {
1420 1420
     $output = l($output, "host/{$host_id}/log");
1421 1421
   }
1422 1422
   return $output;
@@ -1453,9 +1453,9 @@  discard block
 block discarded – undo
1453 1453
 /**
1454 1454
   * Determine output for task reported time / deadline
1455 1455
   */
1456
-function boincwork_task_time_reported($received_time = NULL, $deadline = NULL, $context = NULL) {
1456
+function boincwork_task_time_reported($received_time = null, $deadline = null, $context = null) {
1457 1457
   $output = '---';
1458
-  if ($received_time OR $deadline) {
1458
+  if ($received_time or $deadline) {
1459 1459
     $timestamp = ($received_time) ? $received_time : $deadline;
1460 1460
     $output = gmdate('j M Y, G:i:s', $timestamp) . ' UTC';
1461 1461
     // Add a wrapper to deadline text
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/bbcode/bbcode-filter.inc 5 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -1,6 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 // $Id: bbcode-filter.inc,v 1.66 2008/11/30 08:50:08 naudefj Exp $
3 3
 
4
+/**
5
+ * @param string $body
6
+ */
4 7
 function _bbcode_filter_process(&$body, $format = -1) {
5 8
 
6 9
   $quote_text = t('Quote:');
Please login to merge, or discard this patch.
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -3,128 +3,128 @@  discard block
 block discarded – undo
3 3
 
4 4
 function _bbcode_filter_process(&$body, $format = -1) {
5 5
 
6
-  $quote_text = t('Quote:');
7
-  $quote_user = t('\\1 wrote:');
6
+    $quote_text = t('Quote:');
7
+    $quote_user = t('\\1 wrote:');
8 8
 
9
-  // Encode all script tags to prevent XSS html injection attacks
10
-  $body = preg_replace(array('#<script([^>]*)>#i', '#</script([^>]*)>#i'), array('&lt;script\\1&gt;', '&lt;/script\\1&gt;'), $body);
9
+    // Encode all script tags to prevent XSS html injection attacks
10
+    $body = preg_replace(array('#<script([^>]*)>#i', '#</script([^>]*)>#i'), array('&lt;script\\1&gt;', '&lt;/script\\1&gt;'), $body);
11 11
 
12
-  // Find all [code] tags and check if they contain a newline. If we find a newline, 
13
-  // that [code] should be rendered as a block, otherwise it will still be inline
14
-  $mode = variable_get("bbcode_paragraph_breaks_$format", 2);
15
-  $pre = array(); $i = 0;
16
-  if (preg_match_all('#\[code(?::\w+)?\](.*?)\[/code(?::\w+)?\]#si', $body, $code_tags, PREG_SET_ORDER)) {
12
+    // Find all [code] tags and check if they contain a newline. If we find a newline, 
13
+    // that [code] should be rendered as a block, otherwise it will still be inline
14
+    $mode = variable_get("bbcode_paragraph_breaks_$format", 2);
15
+    $pre = array(); $i = 0;
16
+    if (preg_match_all('#\[code(?::\w+)?\](.*?)\[/code(?::\w+)?\]#si', $body, $code_tags, PREG_SET_ORDER)) {
17 17
     foreach ($code_tags as $code_tag) {
18
-      $code_tag[1] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $code_tag[1]);
19
-      if (strpos($code_tag[1], "\n") === FALSE)
18
+        $code_tag[1] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $code_tag[1]);
19
+        if (strpos($code_tag[1], "\n") === FALSE)
20 20
         $body = str_replace($code_tag[0], '<code class="bb-code">'. $code_tag[1] .'</code>', $body);
21
-      elseif ($mode) {
21
+        elseif ($mode) {
22 22
         // Strip preformatted code blocks from text during line break processing, replaced below
23 23
         $body = str_replace($code_tag[0], "***pRe_sTrInG$i***", $body);
24 24
         $pre[$i++] = '<pre class="bb-code-block">'. $code_tag[1] .'</pre>';
25
-      }
26
-      else
25
+        }
26
+        else
27 27
         $body = str_replace($code_tag[0], '<pre class="bb-code-block">'. $code_tag[1] .'</pre>', $body);
28 28
     }
29
-  }
29
+    }
30 30
 
31
-  // Apply line and paragraph breaks (skipping preformatted code)
32
-  if ($mode) {
31
+    // Apply line and paragraph breaks (skipping preformatted code)
32
+    if ($mode) {
33 33
 
34 34
     if ($mode == 1) 	// Line breaks only (starting with PHP 4.0.5, nl2br() is XHTML compliant)
35
-      $body = nl2br($body);
35
+        $body = nl2br($body);
36 36
 
37 37
     if ($mode == 2) {	// Line and paragraph breaks (may not always be XHTML compliant)
38
-      $body  = preg_replace("/(\r\n|\n|\r)/", "\n", $body);
39
-      $body  = preg_replace("/\n\n+/", "\n\n", $body);
40
-      $parts = explode("\n\n", $body);
41
-      for ($i=0; $i<sizeof($parts); $i++) {
42
-         // No linebreaks if paragraph starts with an HTML tag
43
-         if ( !preg_match('/^<.*>/', $parts[$i]) ) 
44
-           $parts[$i] = nl2br($parts[$i]);
45
-
46
-         // Some tags should not be in paragraph blocks
47
-         if ( !preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i]) ) 
48
-           $parts[$i] = '<p>'. $parts[$i] .'</p>';
49
-      }
50
-      $body = implode("\n\n", $parts);
38
+        $body  = preg_replace("/(\r\n|\n|\r)/", "\n", $body);
39
+        $body  = preg_replace("/\n\n+/", "\n\n", $body);
40
+        $parts = explode("\n\n", $body);
41
+        for ($i=0; $i<sizeof($parts); $i++) {
42
+            // No linebreaks if paragraph starts with an HTML tag
43
+            if ( !preg_match('/^<.*>/', $parts[$i]) ) 
44
+            $parts[$i] = nl2br($parts[$i]);
45
+
46
+            // Some tags should not be in paragraph blocks
47
+            if ( !preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i]) ) 
48
+            $parts[$i] = '<p>'. $parts[$i] .'</p>';
49
+        }
50
+        $body = implode("\n\n", $parts);
51 51
     }
52 52
 
53 53
     // Reinsert preformatted code blocks
54 54
     foreach ($pre as $i => $code_tag) 
55
-       $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body);
56
-  }
55
+        $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body);
56
+    }
57 57
   
58
-  // Replace any improper quote tags with proper quote tags
59
-  $body = str_replace('[quote/]', '[/quote]', $body);
58
+    // Replace any improper quote tags with proper quote tags
59
+    $body = str_replace('[quote/]', '[/quote]', $body);
60 60
   
61
-  // Add closing tags to prevent users from disruping your site's HTML
62
-  // (required for nestable tags only: [list] and [quote])
63
-  preg_match_all('/\[quote/i', $body, $matches);
64
-  $opentags = count($matches['0']);
65
-  preg_match_all('/\[\/quote\]/i', $body, $matches);
66
-  $unclosed = $opentags - count($matches['0']);
67
-  for ($i = 0; $i < $unclosed; $i++) {
61
+    // Add closing tags to prevent users from disruping your site's HTML
62
+    // (required for nestable tags only: [list] and [quote])
63
+    preg_match_all('/\[quote/i', $body, $matches);
64
+    $opentags = count($matches['0']);
65
+    preg_match_all('/\[\/quote\]/i', $body, $matches);
66
+    $unclosed = $opentags - count($matches['0']);
67
+    for ($i = 0; $i < $unclosed; $i++) {
68 68
     $body .= '[/quote]';
69
-  }
70
-  // Also add opening tags, if needed
71
-  for ($i = $unclosed; $i < 0; $i++) {
69
+    }
70
+    // Also add opening tags, if needed
71
+    for ($i = $unclosed; $i < 0; $i++) {
72 72
     $body = '[quote]' . $body;
73
-  }
74
-  preg_match_all('/\[list/i', $body, $matches);
75
-  $opentags = count($matches['0']);
76
-  preg_match_all('/\[\/list\]/i', $body, $matches);
77
-  $unclosed = $opentags - count($matches['0']);
78
-  for ($i = 0; $i < $unclosed; $i++) {
73
+    }
74
+    preg_match_all('/\[list/i', $body, $matches);
75
+    $opentags = count($matches['0']);
76
+    preg_match_all('/\[\/list\]/i', $body, $matches);
77
+    $unclosed = $opentags - count($matches['0']);
78
+    for ($i = 0; $i < $unclosed; $i++) {
79 79
     $body .= '[/list]';
80
-  }
81
-  for ($i = $unclosed; $i < 0; $i++) {
80
+    }
81
+    for ($i = $unclosed; $i < 0; $i++) {
82 82
     $body = '[list]' . $body;
83
-  }
83
+    }
84 84
 
85
-  // begin processing for [size] 
86
-  if (stristr($body, '[size=') !== FALSE) { // prevent useless processing
85
+    // begin processing for [size] 
86
+    if (stristr($body, '[size=') !== FALSE) { // prevent useless processing
87 87
     $arr = array(
88
-      'tag'         => 'size',
89
-      'pattern'     => '#\[\x07=([\d]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi',
90
-      'replacement' => '"<span style=\"font-size:". _bbcode_round_size_val(\'$1\') ."px\">". str_replace(\'\"\', \'"\', \'$2\') ."</span>"',
91
-      'text'        => $body);
88
+        'tag'         => 'size',
89
+        'pattern'     => '#\[\x07=([\d]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi',
90
+        'replacement' => '"<span style=\"font-size:". _bbcode_round_size_val(\'$1\') ."px\">". str_replace(\'\"\', \'"\', \'$2\') ."</span>"',
91
+        'text'        => $body);
92 92
     $body = _bbcode_replace_nest_tag($arr);
93
-  } // end processing for [size]
93
+    } // end processing for [size]
94 94
 
95
-  // begin processing for [color]
96
-  if (stristr($body, '[color=') !== FALSE) { // prevent useless processing
95
+    // begin processing for [color]
96
+    if (stristr($body, '[color=') !== FALSE) { // prevent useless processing
97 97
     $arr = array(
98
-      'tag'         => 'color',
99
-      'pattern'     => '#\[\x07=([\#\w]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
100
-      'replacement' => '<span style="color:$1">$2</span>',
101
-      'text'        => $body);
98
+        'tag'         => 'color',
99
+        'pattern'     => '#\[\x07=([\#\w]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
100
+        'replacement' => '<span style="color:$1">$2</span>',
101
+        'text'        => $body);
102 102
     $body = _bbcode_replace_nest_tag($arr);
103
-  } // end processing for [color]
103
+    } // end processing for [color]
104 104
 
105
-  // begin processing for [font]
106
-  if (stristr($body, '[font=') !== FALSE) { // prevent useless processing
105
+    // begin processing for [font]
106
+    if (stristr($body, '[font=') !== FALSE) { // prevent useless processing
107 107
     $arr = array(
108
-      'tag'         => 'font',
109
-      'pattern'     => '#\[\x07=([\w\s]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
110
-      'replacement' => '<span style="font-family:$1">$2</span>',
111
-      'text'        => $body);
108
+        'tag'         => 'font',
109
+        'pattern'     => '#\[\x07=([\w\s]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
110
+        'replacement' => '<span style="font-family:$1">$2</span>',
111
+        'text'        => $body);
112 112
     $body = _bbcode_replace_nest_tag($arr);
113
-  } // end processing for [font]
113
+    } // end processing for [font]
114 114
 
115
-  // begin processing for [list] and [*]
116
-  if (stristr($body, '[list') !== FALSE) { // prevent useless processing
115
+    // begin processing for [list] and [*]
116
+    if (stristr($body, '[list') !== FALSE) { // prevent useless processing
117 117
     $l_type = array(
118
-      NULL   => array('style' => 'circle', 'tag' => 'ul'),
119
-      'c'    => array('style' => 'circle', 'tag' => 'ul'),
120
-      'd'    => array('style' => 'disc', 'tag' => 'ul'),
121
-      's'    => array('style' => 'square', 'tag' => 'ul'),
122
-      '1'    => array('style' => 'decimal', 'tag' => 'ol'),
123
-      'a'    => array('style' => 'lower-alpha', 'tag' => 'ol'),
124
-      'A'    => array('style' => 'upper-alpha', 'tag' => 'ol'),
125
-      'i'    => array('style' => 'lower-roman', 'tag' => 'ol'),
126
-      'I'    => array('style' => 'upper-roman', 'tag' => 'ol')
127
-      );
118
+        NULL   => array('style' => 'circle', 'tag' => 'ul'),
119
+        'c'    => array('style' => 'circle', 'tag' => 'ul'),
120
+        'd'    => array('style' => 'disc', 'tag' => 'ul'),
121
+        's'    => array('style' => 'square', 'tag' => 'ul'),
122
+        '1'    => array('style' => 'decimal', 'tag' => 'ol'),
123
+        'a'    => array('style' => 'lower-alpha', 'tag' => 'ol'),
124
+        'A'    => array('style' => 'upper-alpha', 'tag' => 'ol'),
125
+        'i'    => array('style' => 'lower-roman', 'tag' => 'ol'),
126
+        'I'    => array('style' => 'upper-roman', 'tag' => 'ol')
127
+        );
128 128
     $body = preg_replace('#(\[[/]*)list(.*?\])#si', "$1\x07$2", $body);
129 129
 
130 130
     // replace to <li> tags - [*]..[*]|[*]..[/list]
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
     // replace to <ol>/<ul> and </ol>/</ul> tags
140 140
     // It will be better to use &count and do-while, if php 5 or higher.
141 141
     while (preg_match("#\[\x07[=]*((?-i)[cds1aAiI])*(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si", $body)) {
142
-      $body = preg_replace("#\[\x07[=]*((?-i)[cds1aAiI])*(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi", '"<". $l_type[\'$1\']["tag"] ." class=\"bb-list\" style=\"list-style-type:". $l_type[\'$1\']["style"] .";\">". str_replace(\'\"\', \'"\', \'$2\') ."</". $l_type[\'$1\']["tag"] .">"', $body);
142
+        $body = preg_replace("#\[\x07[=]*((?-i)[cds1aAiI])*(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi", '"<". $l_type[\'$1\']["tag"] ." class=\"bb-list\" style=\"list-style-type:". $l_type[\'$1\']["style"] .";\">". str_replace(\'\"\', \'"\', \'$2\') ."</". $l_type[\'$1\']["tag"] .">"', $body);
143 143
     }
144 144
 
145 145
     // remove <br /> tags
146 146
     $body = preg_replace('#(<[/]*([uo]l|li).*>.*)<br />#i', '$1', $body);
147
-  } // end processing for [list] and [*]
147
+    } // end processing for [list] and [*]
148 148
 
149
-  // Define BBCode tags
150
-  $preg = array(
149
+    // Define BBCode tags
150
+    $preg = array(
151 151
     // Implement [notag]
152 152
     '#\[notag(?::\w+)?\](.*?)\[/notag(?::\w+)?\]#sie'        => '_bbcode_notag_tag(\'\\1\')',
153 153
 
@@ -215,36 +215,36 @@  discard block
 block discarded – undo
215 215
     // Cleanup table output (td, th and tr tags)
216 216
     '#<([\/]?)t([dhr])><br />#si'                           => '<\\1t\\2>',
217 217
     '#<table(.+?)><br />#si'                                => '<table\\1>',
218
-  );
219
-  $body = preg_replace(array_keys($preg), array_values($preg), $body);
218
+    );
219
+    $body = preg_replace(array_keys($preg), array_values($preg), $body);
220 220
 
221
-  // Simple replacements (str_replace is faster than preg_replace)
222
-  $str = array(
221
+    // Simple replacements (str_replace is faster than preg_replace)
222
+    $str = array(
223 223
     // Horizontal delimiter
224 224
     '[hr]'   => '<hr class="bb-hr" />',
225 225
     // Force line break
226 226
     '[br]'   => '<br class="bb-br" />',
227 227
     // Force space
228 228
     '[sp]'   => '&nbsp;',
229
-  );
230
-  $body = str_replace(array_keys($str), array_values($str), $body);
229
+    );
230
+    $body = str_replace(array_keys($str), array_values($str), $body);
231 231
 
232
-  // We cannot evaluate the variable in callback function because 
233
-  // there is no way to pass the $format variable
234
-  if (variable_get("bbcode_encode_mailto_$format", 1)) {
232
+    // We cannot evaluate the variable in callback function because 
233
+    // there is no way to pass the $format variable
234
+    if (variable_get("bbcode_encode_mailto_$format", 1)) {
235 235
     // Replacing email addresses with encoded html
236 236
     $body = preg_replace_callback('#\[email(?::\w+)?\]([\w\.\-\+~@]+)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body);
237 237
     $body = preg_replace_callback('#\[email=(.*?)(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body);
238
-  }
239
-  else {
238
+    }
239
+    else {
240 240
     $body = preg_replace(
241
-      array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si','#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'),
242
-      array('<a href="mailto:\\1" class="bb-email">\\1</a>', '<a href="mailto:\\1" class="bb-email">\\2</a>'),
243
-      $body);
244
-  }
241
+        array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si','#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'),
242
+        array('<a href="mailto:\\1" class="bb-email">\\1</a>', '<a href="mailto:\\1" class="bb-email">\\2</a>'),
243
+        $body);
244
+    }
245 245
 
246
-  // Turns web and e-mail addresses into clickable links
247
-  if (variable_get("bbcode_make_links_$format", 1)) {
246
+    // Turns web and e-mail addresses into clickable links
247
+    if (variable_get("bbcode_make_links_$format", 1)) {
248 248
 
249 249
     // pad with a space so we can match things at the start of the 1st line
250 250
     $ret = ' ' . $body;
@@ -260,109 +260,109 @@  discard block
 block discarded – undo
260 260
     // Must contain at least 2 dots. xxxx contains either alphanum, or "-"
261 261
     // zzzz is optional.. will contain everything up to the first space, newline,
262 262
     // comma, double quote or <.
263
-     $ret = preg_replace('#([\t\r\n >\(\[\|])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\'\(\n\r\t<\)\[\]\|]*)?)#i', '\1<a href="http://\2.\3">\2.\3</a>', $ret);
263
+        $ret = preg_replace('#([\t\r\n >\(\[\|])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\'\(\n\r\t<\)\[\]\|]*)?)#i', '\1<a href="http://\2.\3">\2.\3</a>', $ret);
264 264
 
265 265
     // matches an email@domain type address at the start of a line, or after a space.
266 266
     // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
267 267
     if (variable_get("bbcode_encode_mailto_$format", 1))
268
-      $ret = preg_replace_callback("#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", '_bbcode_encode_mailto', $ret);
268
+        $ret = preg_replace_callback("#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", '_bbcode_encode_mailto', $ret);
269 269
     else 
270
-      $ret = preg_replace('#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i', '\\1<a href="mailto:\\2@\\3">\\2@\\3</a>', $ret);
270
+        $ret = preg_replace('#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i', '\\1<a href="mailto:\\2@\\3">\\2@\\3</a>', $ret);
271 271
 
272 272
     // Remove our padding
273 273
     $ret = str_replace("\x07", '', $ret);
274 274
     $body = substr($ret, 1);
275
-  }
275
+    }
276 276
 
277
-  if (variable_get("bbcode_filter_nofollow_$format", 0)) {
277
+    if (variable_get("bbcode_filter_nofollow_$format", 0)) {
278 278
     $body = preg_replace('#<a([^>]+)>#i', '<a\\1 rel="nofollow">', $body);
279
-  }
279
+    }
280 280
 
281
-  return $body;
281
+    return $body;
282 282
 }
283 283
 
284 284
 function _bbcode_generate_heading($level, $text) {
285
-  $anchor = preg_replace('/([\s]+)/', '_', $text);
286
-  $anchor = preg_replace('/([\W]+)/', '',  $anchor);
287
-  return '<h'. $level .'><a name="'. $anchor .'">'. $text .'</a></h'. $level .'>';
285
+    $anchor = preg_replace('/([\s]+)/', '_', $text);
286
+    $anchor = preg_replace('/([\W]+)/', '',  $anchor);
287
+    return '<h'. $level .'><a name="'. $anchor .'">'. $text .'</a></h'. $level .'>';
288 288
 }
289 289
 
290 290
 function _bbcode_generate_index($body, $tag = 'ol') {
291
-  $level = 0;
292
-  $index = '<'. $tag .">\n";
293
-  $close_tags = 0;
291
+    $level = 0;
292
+    $index = '<'. $tag .">\n";
293
+    $close_tags = 0;
294 294
 
295
-  if (preg_match_all('#\[h([1-6]).*?\](.*?)\[/h([1-6]).*?\]#si', $body, $head_tags, PREG_SET_ORDER)) {
295
+    if (preg_match_all('#\[h([1-6]).*?\](.*?)\[/h([1-6]).*?\]#si', $body, $head_tags, PREG_SET_ORDER)) {
296 296
     foreach ($head_tags as $head_tag) {
297
-      if ($level == 0) $level = $head_tag[1];
298
-      $anchor = preg_replace('/([\s]+)/', '_', $head_tag[2]);
299
-      $anchor = preg_replace('/([\W]+)/', '',  $anchor);
297
+        if ($level == 0) $level = $head_tag[1];
298
+        $anchor = preg_replace('/([\s]+)/', '_', $head_tag[2]);
299
+        $anchor = preg_replace('/([\W]+)/', '',  $anchor);
300 300
 
301
-      if ($head_tag[1] > $level) {
301
+        if ($head_tag[1] > $level) {
302 302
         $index .= '<'. $tag .">\n";
303 303
         $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
304 304
         $close_tags++;
305 305
         $level = $head_tag[1];
306
-      } else if ($head_tag[1] < $level) {
306
+        } else if ($head_tag[1] < $level) {
307 307
         while ($close_tags > 0) {
308
-           $index .= '</'. $tag .">\n";
309
-           $close_tags--;
308
+            $index .= '</'. $tag .">\n";
309
+            $close_tags--;
310 310
         }
311 311
         $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
312 312
         $level = $head_tag[1];
313
-      } else {
313
+        } else {
314 314
         $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
315 315
         $level = $head_tag[1];
316
-      }
316
+        }
317
+    }
317 318
     }
318
-  }
319
-  while ($close_tags >= 0) {
319
+    while ($close_tags >= 0) {
320 320
     $index .= '</'. $tag .">\n";
321 321
     $close_tags--;
322
-  }
323
-  return $index;
322
+    }
323
+    return $index;
324 324
 }
325 325
 
326 326
 function _bbcode_encode_mailto($matches) {
327
-  if (isset($matches[3])) 
327
+    if (isset($matches[3])) 
328 328
     $link = 'document.write(\'<a href="mailto:' . $matches[2].'@'.$matches[3] . '">' . $matches[2].'@'.$matches[3] . '</a>\');';
329
-  else 
329
+    else 
330 330
     $link = 'document.write(\'<a href="mailto:' . $matches[1] . '" class="bb-email">' . (isset($matches[2]) ? $matches[2] : $matches[1]) . '</a>\');';
331 331
 
332
-  $js_encode = '';
333
-  for ($x = 0; $x < strlen($link); $x++) 
332
+    $js_encode = '';
333
+    for ($x = 0; $x < strlen($link); $x++) 
334 334
     $js_encode .= '%' . bin2hex($link{$x});
335 335
 
336
-  $link = '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
337
-  if (isset($matches[3]))
336
+    $link = '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
337
+    if (isset($matches[3]))
338 338
     $link = $matches[1] . $link;
339 339
 
340
-  return $link;
340
+    return $link;
341 341
 }
342 342
 
343 343
 function _bbcode_notag_tag($text = NULL) {
344
-  return str_replace( array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
344
+    return str_replace( array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
345 345
 }
346 346
 
347 347
 function _bbcode_php_tag($text = NULL) {
348
-  return '<pre>'. highlight_string( str_replace('<br />', '', stripslashes($text)), true) .'</pre>';
348
+    return '<pre>'. highlight_string( str_replace('<br />', '', stripslashes($text)), true) .'</pre>';
349 349
 }
350 350
 
351 351
 function _bbcode_round_size_val($size) {
352
-  if ($size < 6)
353
-      return 6;
354
-  elseif ($size > 48)
355
-      return 48;
356
-  else
357
-     return $size;
352
+    if ($size < 6)
353
+        return 6;
354
+    elseif ($size > 48)
355
+        return 48;
356
+    else
357
+        return $size;
358 358
 }
359 359
 
360 360
 function _bbcode_replace_nest_tag($arr = NULL) {
361
-  $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']);
362
-  // It will be better to use &count and do-while, if php 5 or higher.
363
-  while (preg_match($arr['pattern'], $text)) {
361
+    $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']);
362
+    // It will be better to use &count and do-while, if php 5 or higher.
363
+    while (preg_match($arr['pattern'], $text)) {
364 364
     $text = preg_replace($arr['pattern'], $arr['replacement'], $text);
365
-  }
366
-  return $text;
365
+    }
366
+    return $text;
367 367
 }
368 368
 
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
     foreach ($code_tags as $code_tag) {
18 18
       $code_tag[1] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $code_tag[1]);
19 19
       if (strpos($code_tag[1], "\n") === FALSE)
20
-        $body = str_replace($code_tag[0], '<code class="bb-code">'. $code_tag[1] .'</code>', $body);
20
+        $body = str_replace($code_tag[0], '<code class="bb-code">'.$code_tag[1].'</code>', $body);
21 21
       elseif ($mode) {
22 22
         // Strip preformatted code blocks from text during line break processing, replaced below
23 23
         $body = str_replace($code_tag[0], "***pRe_sTrInG$i***", $body);
24
-        $pre[$i++] = '<pre class="bb-code-block">'. $code_tag[1] .'</pre>';
24
+        $pre[$i++] = '<pre class="bb-code-block">'.$code_tag[1].'</pre>';
25 25
       }
26 26
       else
27
-        $body = str_replace($code_tag[0], '<pre class="bb-code-block">'. $code_tag[1] .'</pre>', $body);
27
+        $body = str_replace($code_tag[0], '<pre class="bb-code-block">'.$code_tag[1].'</pre>', $body);
28 28
     }
29 29
   }
30 30
 
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
       $body  = preg_replace("/(\r\n|\n|\r)/", "\n", $body);
39 39
       $body  = preg_replace("/\n\n+/", "\n\n", $body);
40 40
       $parts = explode("\n\n", $body);
41
-      for ($i=0; $i<sizeof($parts); $i++) {
41
+      for ($i = 0; $i < sizeof($parts); $i++) {
42 42
          // No linebreaks if paragraph starts with an HTML tag
43
-         if ( !preg_match('/^<.*>/', $parts[$i]) ) 
43
+         if (!preg_match('/^<.*>/', $parts[$i])) 
44 44
            $parts[$i] = nl2br($parts[$i]);
45 45
 
46 46
          // Some tags should not be in paragraph blocks
47
-         if ( !preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i]) ) 
48
-           $parts[$i] = '<p>'. $parts[$i] .'</p>';
47
+         if (!preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i])) 
48
+           $parts[$i] = '<p>'.$parts[$i].'</p>';
49 49
       }
50 50
       $body = implode("\n\n", $parts);
51 51
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
   }
70 70
   // Also add opening tags, if needed
71 71
   for ($i = $unclosed; $i < 0; $i++) {
72
-    $body = '[quote]' . $body;
72
+    $body = '[quote]'.$body;
73 73
   }
74 74
   preg_match_all('/\[list/i', $body, $matches);
75 75
   $opentags = count($matches['0']);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     $body .= '[/list]';
80 80
   }
81 81
   for ($i = $unclosed; $i < 0; $i++) {
82
-    $body = '[list]' . $body;
82
+    $body = '[list]'.$body;
83 83
   }
84 84
 
85 85
   // begin processing for [size] 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
   }
239 239
   else {
240 240
     $body = preg_replace(
241
-      array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si','#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'),
241
+      array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si', '#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'),
242 242
       array('<a href="mailto:\\1" class="bb-email">\\1</a>', '<a href="mailto:\\1" class="bb-email">\\2</a>'),
243 243
       $body);
244 244
   }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
   if (variable_get("bbcode_make_links_$format", 1)) {
248 248
 
249 249
     // pad with a space so we can match things at the start of the 1st line
250
-    $ret = ' ' . $body;
250
+    $ret = ' '.$body;
251 251
     // padding to already filtered links
252 252
     $ret = preg_replace('#(<a.+>)(.+</a>)#i', "$1\x07$2", $ret);
253 253
 
@@ -283,41 +283,41 @@  discard block
 block discarded – undo
283 283
 
284 284
 function _bbcode_generate_heading($level, $text) {
285 285
   $anchor = preg_replace('/([\s]+)/', '_', $text);
286
-  $anchor = preg_replace('/([\W]+)/', '',  $anchor);
287
-  return '<h'. $level .'><a name="'. $anchor .'">'. $text .'</a></h'. $level .'>';
286
+  $anchor = preg_replace('/([\W]+)/', '', $anchor);
287
+  return '<h'.$level.'><a name="'.$anchor.'">'.$text.'</a></h'.$level.'>';
288 288
 }
289 289
 
290 290
 function _bbcode_generate_index($body, $tag = 'ol') {
291 291
   $level = 0;
292
-  $index = '<'. $tag .">\n";
292
+  $index = '<'.$tag.">\n";
293 293
   $close_tags = 0;
294 294
 
295 295
   if (preg_match_all('#\[h([1-6]).*?\](.*?)\[/h([1-6]).*?\]#si', $body, $head_tags, PREG_SET_ORDER)) {
296 296
     foreach ($head_tags as $head_tag) {
297 297
       if ($level == 0) $level = $head_tag[1];
298 298
       $anchor = preg_replace('/([\s]+)/', '_', $head_tag[2]);
299
-      $anchor = preg_replace('/([\W]+)/', '',  $anchor);
299
+      $anchor = preg_replace('/([\W]+)/', '', $anchor);
300 300
 
301 301
       if ($head_tag[1] > $level) {
302
-        $index .= '<'. $tag .">\n";
303
-        $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
302
+        $index .= '<'.$tag.">\n";
303
+        $index .= '<li><a href="#'.$anchor.'">'.$head_tag[2]."</a>\n";
304 304
         $close_tags++;
305 305
         $level = $head_tag[1];
306 306
       } else if ($head_tag[1] < $level) {
307 307
         while ($close_tags > 0) {
308
-           $index .= '</'. $tag .">\n";
308
+           $index .= '</'.$tag.">\n";
309 309
            $close_tags--;
310 310
         }
311
-        $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
311
+        $index .= '<li><a href="#'.$anchor.'">'.$head_tag[2]."</a>\n";
312 312
         $level = $head_tag[1];
313 313
       } else {
314
-        $index .= '<li><a href="#'. $anchor .'">'. $head_tag[2] ."</a>\n";
314
+        $index .= '<li><a href="#'.$anchor.'">'.$head_tag[2]."</a>\n";
315 315
         $level = $head_tag[1];
316 316
       }
317 317
     }
318 318
   }
319 319
   while ($close_tags >= 0) {
320
-    $index .= '</'. $tag .">\n";
320
+    $index .= '</'.$tag.">\n";
321 321
     $close_tags--;
322 322
   }
323 323
   return $index;
@@ -325,27 +325,27 @@  discard block
 block discarded – undo
325 325
 
326 326
 function _bbcode_encode_mailto($matches) {
327 327
   if (isset($matches[3])) 
328
-    $link = 'document.write(\'<a href="mailto:' . $matches[2].'@'.$matches[3] . '">' . $matches[2].'@'.$matches[3] . '</a>\');';
328
+    $link = 'document.write(\'<a href="mailto:'.$matches[2].'@'.$matches[3].'">'.$matches[2].'@'.$matches[3].'</a>\');';
329 329
   else 
330
-    $link = 'document.write(\'<a href="mailto:' . $matches[1] . '" class="bb-email">' . (isset($matches[2]) ? $matches[2] : $matches[1]) . '</a>\');';
330
+    $link = 'document.write(\'<a href="mailto:'.$matches[1].'" class="bb-email">'.(isset($matches[2]) ? $matches[2] : $matches[1]).'</a>\');';
331 331
 
332 332
   $js_encode = '';
333 333
   for ($x = 0; $x < strlen($link); $x++) 
334
-    $js_encode .= '%' . bin2hex($link{$x});
334
+    $js_encode .= '%'.bin2hex($link{$x});
335 335
 
336 336
   $link = '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
337 337
   if (isset($matches[3]))
338
-    $link = $matches[1] . $link;
338
+    $link = $matches[1].$link;
339 339
 
340 340
   return $link;
341 341
 }
342 342
 
343 343
 function _bbcode_notag_tag($text = NULL) {
344
-  return str_replace( array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
344
+  return str_replace(array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
345 345
 }
346 346
 
347 347
 function _bbcode_php_tag($text = NULL) {
348
-  return '<pre>'. highlight_string( str_replace('<br />', '', stripslashes($text)), true) .'</pre>';
348
+  return '<pre>'.highlight_string(str_replace('<br />', '', stripslashes($text)), true).'</pre>';
349 349
 }
350 350
 
351 351
 function _bbcode_round_size_val($size) {
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 }
359 359
 
360 360
 function _bbcode_replace_nest_tag($arr = NULL) {
361
-  $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']);
361
+  $text = preg_replace('#(\[[/]*)'.$arr['tag'].'(.*?\])#si', "$1\x07$2", $arr['text']);
362 362
   // It will be better to use &count and do-while, if php 5 or higher.
363 363
   while (preg_match($arr['pattern'], $text)) {
364 364
     $text = preg_replace($arr['pattern'], $arr['replacement'], $text);
Please login to merge, or discard this patch.
Braces   +18 added lines, -13 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
         // Strip preformatted code blocks from text during line break processing, replaced below
23 23
         $body = str_replace($code_tag[0], "***pRe_sTrInG$i***", $body);
24 24
         $pre[$i++] = '<pre class="bb-code-block">'. $code_tag[1] .'</pre>';
25
-      }
26
-      else
25
+      } else
27 26
         $body = str_replace($code_tag[0], '<pre class="bb-code-block">'. $code_tag[1] .'</pre>', $body);
28 27
     }
29 28
   }
@@ -34,7 +33,8 @@  discard block
 block discarded – undo
34 33
     if ($mode == 1) 	// Line breaks only (starting with PHP 4.0.5, nl2br() is XHTML compliant)
35 34
       $body = nl2br($body);
36 35
 
37
-    if ($mode == 2) {	// Line and paragraph breaks (may not always be XHTML compliant)
36
+    if ($mode == 2) {
37
+// Line and paragraph breaks (may not always be XHTML compliant)
38 38
       $body  = preg_replace("/(\r\n|\n|\r)/", "\n", $body);
39 39
       $body  = preg_replace("/\n\n+/", "\n\n", $body);
40 40
       $parts = explode("\n\n", $body);
@@ -51,8 +51,9 @@  discard block
 block discarded – undo
51 51
     }
52 52
 
53 53
     // Reinsert preformatted code blocks
54
-    foreach ($pre as $i => $code_tag) 
55
-       $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body);
54
+    foreach ($pre as $i => $code_tag) {
55
+           $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body);
56
+    }
56 57
   }
57 58
   
58 59
   // Replace any improper quote tags with proper quote tags
@@ -83,7 +84,8 @@  discard block
 block discarded – undo
83 84
   }
84 85
 
85 86
   // begin processing for [size] 
86
-  if (stristr($body, '[size=') !== FALSE) { // prevent useless processing
87
+  if (stristr($body, '[size=') !== FALSE) {
88
+// prevent useless processing
87 89
     $arr = array(
88 90
       'tag'         => 'size',
89 91
       'pattern'     => '#\[\x07=([\d]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi',
@@ -93,7 +95,8 @@  discard block
 block discarded – undo
93 95
   } // end processing for [size]
94 96
 
95 97
   // begin processing for [color]
96
-  if (stristr($body, '[color=') !== FALSE) { // prevent useless processing
98
+  if (stristr($body, '[color=') !== FALSE) {
99
+// prevent useless processing
97 100
     $arr = array(
98 101
       'tag'         => 'color',
99 102
       'pattern'     => '#\[\x07=([\#\w]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
@@ -103,7 +106,8 @@  discard block
 block discarded – undo
103 106
   } // end processing for [color]
104 107
 
105 108
   // begin processing for [font]
106
-  if (stristr($body, '[font=') !== FALSE) { // prevent useless processing
109
+  if (stristr($body, '[font=') !== FALSE) {
110
+// prevent useless processing
107 111
     $arr = array(
108 112
       'tag'         => 'font',
109 113
       'pattern'     => '#\[\x07=([\w\s]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
@@ -113,7 +117,8 @@  discard block
 block discarded – undo
113 117
   } // end processing for [font]
114 118
 
115 119
   // begin processing for [list] and [*]
116
-  if (stristr($body, '[list') !== FALSE) { // prevent useless processing
120
+  if (stristr($body, '[list') !== FALSE) {
121
+// prevent useless processing
117 122
     $l_type = array(
118 123
       NULL   => array('style' => 'circle', 'tag' => 'ul'),
119 124
       'c'    => array('style' => 'circle', 'tag' => 'ul'),
@@ -235,8 +240,7 @@  discard block
 block discarded – undo
235 240
     // Replacing email addresses with encoded html
236 241
     $body = preg_replace_callback('#\[email(?::\w+)?\]([\w\.\-\+~@]+)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body);
237 242
     $body = preg_replace_callback('#\[email=(.*?)(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body);
238
-  }
239
-  else {
243
+  } else {
240 244
     $body = preg_replace(
241 245
       array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si','#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'),
242 246
       array('<a href="mailto:\\1" class="bb-email">\\1</a>', '<a href="mailto:\\1" class="bb-email">\\2</a>'),
@@ -330,8 +334,9 @@  discard block
 block discarded – undo
330 334
     $link = 'document.write(\'<a href="mailto:' . $matches[1] . '" class="bb-email">' . (isset($matches[2]) ? $matches[2] : $matches[1]) . '</a>\');';
331 335
 
332 336
   $js_encode = '';
333
-  for ($x = 0; $x < strlen($link); $x++) 
334
-    $js_encode .= '%' . bin2hex($link{$x});
337
+  for ($x = 0; $x < strlen($link); $x++) {
338
+      $js_encode .= '%' . bin2hex($link{$x});
339
+  }
335 340
 
336 341
   $link = '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
337 342
   if (isset($matches[3]))
Please login to merge, or discard this patch.
Upper-Lower-Casing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
   if (preg_match_all('#\[code(?::\w+)?\](.*?)\[/code(?::\w+)?\]#si', $body, $code_tags, PREG_SET_ORDER)) {
17 17
     foreach ($code_tags as $code_tag) {
18 18
       $code_tag[1] = str_replace(array('<', '>'), array('&lt;', '&gt;'), $code_tag[1]);
19
-      if (strpos($code_tag[1], "\n") === FALSE)
19
+      if (strpos($code_tag[1], "\n") === false)
20 20
         $body = str_replace($code_tag[0], '<code class="bb-code">'. $code_tag[1] .'</code>', $body);
21 21
       elseif ($mode) {
22 22
         // Strip preformatted code blocks from text during line break processing, replaced below
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
   }
84 84
 
85 85
   // begin processing for [size] 
86
-  if (stristr($body, '[size=') !== FALSE) { // prevent useless processing
86
+  if (stristr($body, '[size=') !== false) { // prevent useless processing
87 87
     $arr = array(
88 88
       'tag'         => 'size',
89 89
       'pattern'     => '#\[\x07=([\d]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#esi',
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
   } // end processing for [size]
94 94
 
95 95
   // begin processing for [color]
96
-  if (stristr($body, '[color=') !== FALSE) { // prevent useless processing
96
+  if (stristr($body, '[color=') !== false) { // prevent useless processing
97 97
     $arr = array(
98 98
       'tag'         => 'color',
99 99
       'pattern'     => '#\[\x07=([\#\w]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
   } // end processing for [color]
104 104
 
105 105
   // begin processing for [font]
106
-  if (stristr($body, '[font=') !== FALSE) { // prevent useless processing
106
+  if (stristr($body, '[font=') !== false) { // prevent useless processing
107 107
     $arr = array(
108 108
       'tag'         => 'font',
109 109
       'pattern'     => '#\[\x07=([\w\s]+)(?::\w+)?\]([^\x07]*)\[/\x07(?::\w+)?\]#si',
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
   } // end processing for [font]
114 114
 
115 115
   // begin processing for [list] and [*]
116
-  if (stristr($body, '[list') !== FALSE) { // prevent useless processing
116
+  if (stristr($body, '[list') !== false) { // prevent useless processing
117 117
     $l_type = array(
118
-      NULL   => array('style' => 'circle', 'tag' => 'ul'),
118
+      null   => array('style' => 'circle', 'tag' => 'ul'),
119 119
       'c'    => array('style' => 'circle', 'tag' => 'ul'),
120 120
       'd'    => array('style' => 'disc', 'tag' => 'ul'),
121 121
       's'    => array('style' => 'square', 'tag' => 'ul'),
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
   return $link;
341 341
 }
342 342
 
343
-function _bbcode_notag_tag($text = NULL) {
343
+function _bbcode_notag_tag($text = null) {
344 344
   return str_replace( array('[', ']', '@'), array('&#91;', '&#93;', '&#64;'), stripslashes($text));
345 345
 }
346 346
 
347
-function _bbcode_php_tag($text = NULL) {
347
+function _bbcode_php_tag($text = null) {
348 348
   return '<pre>'. highlight_string( str_replace('<br />', '', stripslashes($text)), true) .'</pre>';
349 349
 }
350 350
 
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
      return $size;
358 358
 }
359 359
 
360
-function _bbcode_replace_nest_tag($arr = NULL) {
360
+function _bbcode_replace_nest_tag($arr = null) {
361 361
   $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']);
362 362
   // It will be better to use &count and do-while, if php 5 or higher.
363 363
   while (preg_match($arr['pattern'], $text)) {
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/cck/content.module 6 patches
Doc Comments   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1234,6 +1234,8 @@  discard block
 block discarded – undo
1234 1234
  *
1235 1235
  * For each operation, both this function and _content_field_invoke_default() are
1236 1236
  * called so that the default database handling can occur.
1237
+ * @param string $op
1238
+ * @param boolean $page
1237 1239
  */
1238 1240
 function _content_field_invoke($op, &$node, $teaser = NULL, $page = NULL) {
1239 1241
   $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
@@ -1268,6 +1270,8 @@  discard block
 block discarded – undo
1268 1270
 
1269 1271
 /**
1270 1272
  * Invoke content.module's version of a field hook.
1273
+ * @param string $op
1274
+ * @param boolean $page
1271 1275
  */
1272 1276
 function _content_field_invoke_default($op, &$node, $teaser = NULL, $page = NULL) {
1273 1277
   $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
@@ -1746,6 +1750,7 @@  discard block
 block discarded – undo
1746 1750
  * Used for items entered by administrators, like field descriptions,
1747 1751
  * allowed values, where some (mainly inline) mark-up may be desired
1748 1752
  * (so check_plain() is not acceptable).
1753
+ * @return string
1749 1754
  */
1750 1755
 function content_filter_xss($string) {
1751 1756
   return filter_xss($string, _content_filter_xss_allowed_tags());
@@ -1975,7 +1980,7 @@  discard block
 block discarded – undo
1975 1980
  *
1976 1981
  * @param $name
1977 1982
  *   The name of the content type or content field
1978
- * @param $storage
1983
+ * @param integer $storage
1979 1984
  *   CONTENT_DB_STORAGE_PER_FIELD or CONTENT_DB_STORAGE_PER_CONTENT_TYPE
1980 1985
  * @return
1981 1986
  *   A string containing the generated name for the database table
@@ -2109,7 +2114,7 @@  discard block
 block discarded – undo
2109 2114
  * @param $name
2110 2115
  *   Name of the index.
2111 2116
  * @return
2112
- *   TRUE if the table exists. Otherwise FALSE.
2117
+ boolean   TRUE if the table exists. Otherwise FALSE.
2113 2118
  */
2114 2119
 function content_db_index_exists($table, $name) {
2115 2120
   global $db_type;
@@ -2139,9 +2144,9 @@  discard block
 block discarded – undo
2139 2144
  *  with respect to a given operation. (currently used for field 'view',
2140 2145
  *  and widget 'default values' and 'multiple values')
2141 2146
  *
2142
- *  @param $entity
2147
+ *  @param string $entity
2143 2148
  *    'field' or 'widget'
2144
- *  @param $op
2149
+ *  @param string $op
2145 2150
  *    the name of the operation ('view', 'default value'...)
2146 2151
  *  @param $field
2147 2152
  *    The field array, including widget info.
@@ -2169,9 +2174,9 @@  discard block
 block discarded – undo
2169 2174
  *
2170 2175
  *  Currently used for widgets and formatters 'multiple values'.
2171 2176
  *
2172
- *  @param $entity
2177
+ *  @param string $entity
2173 2178
  *    'field', 'widget' or 'formatter'
2174
- *  @param $op
2179
+ *  @param string $op
2175 2180
  *    the name of the operation ('default values'...)
2176 2181
  *  @param $object
2177 2182
  *    - if $entity is 'field' or 'widget': the field array,
@@ -2232,7 +2237,7 @@  discard block
 block discarded – undo
2232 2237
 /**
2233 2238
  * Determine whether the user has access to a given field.
2234 2239
  *
2235
- * @param $op
2240
+ * @param string $op
2236 2241
  *   The operation to be performed. Possible values:
2237 2242
  *   - "edit"
2238 2243
  *   - "view"
@@ -2243,7 +2248,7 @@  discard block
 block discarded – undo
2243 2248
  * @param $node
2244 2249
  *   (optional) The node on which the operation is to be performed.
2245 2250
  * @return
2246
- *   TRUE if the operation is allowed;
2251
+ boolean   TRUE if the operation is allowed;
2247 2252
  *   FALSE if the operation is denied.
2248 2253
  */
2249 2254
 function content_access($op, $field, $account = NULL, $node = NULL) {
@@ -2324,7 +2329,7 @@  discard block
 block discarded – undo
2324 2329
  *      hook_content_build_modes().
2325 2330
  *
2326 2331
  * @return
2327
- *   Whether or not content is to be added to $content in this context.
2332
+ boolean   Whether or not content is to be added to $content in this context.
2328 2333
  *   Uses the value of the 'Exclude' checkbox for this field
2329 2334
  *   as set on the Manage fields screen.
2330 2335
  */
Please login to merge, or discard this patch.
Indentation   +931 added lines, -931 removed lines patch added patch discarded remove patch
@@ -16,88 +16,88 @@  discard block
 block discarded – undo
16 16
 define('CONTENT_HANDLE_MODULE', 0x0002);
17 17
 
18 18
 function content_help($path, $arg) {
19
-  switch ($path) {
19
+    switch ($path) {
20 20
     case 'admin/help#content':
21 21
       $output = '<p>'. t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))) .'</p>';
22
-      $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
-      $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
24
-      $output .= '<ul>';
25
-      $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
-      $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
-      $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
-      $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
-      $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
30
-      $output .= '</ul>';
31
-      $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
32
-      return $output;
33
-  }
22
+        $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
+        $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
24
+        $output .= '<ul>';
25
+        $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
+        $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
+        $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
+        $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
+        $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
30
+        $output .= '</ul>';
31
+        $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
32
+        return $output;
33
+    }
34 34
 }
35 35
 
36 36
 /**
37 37
  * Implementation of hook_flush_caches.
38 38
  */
39 39
 function content_flush_caches() {
40
-  return array(content_cache_tablename());
40
+    return array(content_cache_tablename());
41 41
 }
42 42
 
43 43
 /**
44 44
  * Implementation of hook_init().
45 45
  */
46 46
 function content_init() {
47
-  drupal_add_css(drupal_get_path('module', 'content') .'/theme/content-module.css');
48
-  if (module_exists('token') && !function_exists('content_token_values')) {
47
+    drupal_add_css(drupal_get_path('module', 'content') .'/theme/content-module.css');
48
+    if (module_exists('token') && !function_exists('content_token_values')) {
49 49
     module_load_include('inc', 'content', 'includes/content.token');
50
-  }
51
-  if (module_exists('diff') && !function_exists('content_diff')) {
50
+    }
51
+    if (module_exists('diff') && !function_exists('content_diff')) {
52 52
     module_load_include('inc', 'content', 'includes/content.diff');
53
-  }
53
+    }
54 54
 }
55 55
 
56 56
 /**
57 57
  * Implementation of hook_perm().
58 58
  */
59 59
 function content_perm() {
60
-  return array('Use PHP input for field settings (dangerous - grant with care)');
60
+    return array('Use PHP input for field settings (dangerous - grant with care)');
61 61
 }
62 62
 
63 63
 /**
64 64
  * Implementation of hook_menu_alter().
65 65
  */
66 66
 function content_menu_alter(&$items) {
67
-  // Customize the content types page with our own callback
68
-  $items['admin/content/types']['page callback'] = 'content_types_overview';
69
-  $items['admin/content/types']['file'] = 'content.admin.inc';
70
-  $items['admin/content/types']['file path'] = drupal_get_path('module', 'content') .'/includes';
67
+    // Customize the content types page with our own callback
68
+    $items['admin/content/types']['page callback'] = 'content_types_overview';
69
+    $items['admin/content/types']['file'] = 'content.admin.inc';
70
+    $items['admin/content/types']['file path'] = drupal_get_path('module', 'content') .'/includes';
71 71
 }
72 72
 
73 73
 /**
74 74
  * Implementation of hook_menu().
75 75
  */
76 76
 function content_menu() {
77
-  $items = array();
78
-  $items['admin/content/types/fields'] = array(
77
+    $items = array();
78
+    $items['admin/content/types/fields'] = array(
79 79
     'title' => 'Fields',
80 80
     'page callback' => 'content_fields_list',
81 81
     'access arguments' => array('administer content types'),
82 82
     'file' => 'includes/content.admin.inc',
83 83
     'type' => MENU_LOCAL_TASK,
84
-  );
85
-  // Callback for AHAH add more buttons.
86
-  $items['content/js_add_more'] = array(
84
+    );
85
+    // Callback for AHAH add more buttons.
86
+    $items['content/js_add_more'] = array(
87 87
     'page callback' => 'content_add_more_js',
88 88
     'access arguments' => array('access content'),
89 89
     'file' => 'includes/content.node_form.inc',
90 90
     'type' => MENU_CALLBACK,
91
-  );
91
+    );
92 92
 
93
-  // Make sure this doesn't fire until content_types is working,
94
-  // and tables are updated, needed to avoid errors on initial installation.
95
-  if (!defined('MAINTENANCE_MODE') && variable_get('content_schema_version', -1) >= 6007) {
93
+    // Make sure this doesn't fire until content_types is working,
94
+    // and tables are updated, needed to avoid errors on initial installation.
95
+    if (!defined('MAINTENANCE_MODE') && variable_get('content_schema_version', -1) >= 6007) {
96 96
     foreach (node_get_types() as $type) {
97
-      $type_name = $type->type;
98
-      $content_type = content_types($type_name);
99
-      $type_url_str = $content_type['url_str'];
100
-      $items['admin/content/node-type/'. $type_url_str .'/fields'] = array(
97
+        $type_name = $type->type;
98
+        $content_type = content_types($type_name);
99
+        $type_url_str = $content_type['url_str'];
100
+        $items['admin/content/node-type/'. $type_url_str .'/fields'] = array(
101 101
         'title' => 'Manage fields',
102 102
         'page callback' => 'drupal_get_form',
103 103
         'page arguments' => array('content_field_overview_form', $type_name),
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
         'file' => 'includes/content.admin.inc',
106 106
         'type' => MENU_LOCAL_TASK,
107 107
         'weight' => 1,
108
-      );
109
-      $items['admin/content/node-type/'. $type_url_str .'/display'] = array(
108
+        );
109
+        $items['admin/content/node-type/'. $type_url_str .'/display'] = array(
110 110
         'title' => 'Display fields',
111 111
         'page callback' => 'drupal_get_form',
112 112
         'page arguments' => array('content_display_overview_form', $type_name),
@@ -114,41 +114,41 @@  discard block
 block discarded – undo
114 114
         'file' => 'includes/content.admin.inc',
115 115
         'type' => MENU_LOCAL_TASK,
116 116
         'weight' => 2,
117
-      );
118
-      $contexts = content_build_modes('_tabs');
119
-      foreach ($contexts as $key => $tab) {
117
+        );
118
+        $contexts = content_build_modes('_tabs');
119
+        foreach ($contexts as $key => $tab) {
120 120
         $items['admin/content/node-type/'. $type_url_str .'/display/'. $key] = array(
121
-          'title' => $tab['title'],
122
-          'page arguments' => array('content_display_overview_form', $type_name, $key),
123
-          'access arguments' => array('administer content types'),
124
-          'type' => $key == 'basic' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
125
-          'weight' => $key == 'basic' ? 0 : 1,
121
+            'title' => $tab['title'],
122
+            'page arguments' => array('content_display_overview_form', $type_name, $key),
123
+            'access arguments' => array('administer content types'),
124
+            'type' => $key == 'basic' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
125
+            'weight' => $key == 'basic' ? 0 : 1,
126 126
         );
127
-      }
128
-      // Cast as an array in case this is called before any fields have
129
-      // been added, like when a new content type is created.
130
-      foreach ((array) $content_type['fields'] as $field) {
127
+        }
128
+        // Cast as an array in case this is called before any fields have
129
+        // been added, like when a new content type is created.
130
+        foreach ((array) $content_type['fields'] as $field) {
131 131
         $field_name = $field['field_name'];
132 132
         $items['admin/content/node-type/'. $type_url_str .'/fields/'. $field_name] = array(
133
-          'title' => $field['widget']['label'],
134
-          'page callback' => 'drupal_get_form',
135
-          'page arguments' => array('content_field_edit_form', $type_name, $field_name),
136
-          'access arguments' => array('administer content types'),
137
-          'file' => 'includes/content.admin.inc',
138
-          'type' => MENU_LOCAL_TASK,
133
+            'title' => $field['widget']['label'],
134
+            'page callback' => 'drupal_get_form',
135
+            'page arguments' => array('content_field_edit_form', $type_name, $field_name),
136
+            'access arguments' => array('administer content types'),
137
+            'file' => 'includes/content.admin.inc',
138
+            'type' => MENU_LOCAL_TASK,
139 139
         );
140 140
         $items['admin/content/node-type/'. $type_url_str .'/fields/'. $field_name .'/remove'] = array(
141
-          'title' => 'Remove field',
142
-          'page callback' => 'drupal_get_form',
143
-          'page arguments' => array('content_field_remove_form', $type_name, $field_name),
144
-          'access arguments' => array('administer content types'),
145
-          'file' => 'includes/content.admin.inc',
146
-          'type' => MENU_CALLBACK,
141
+            'title' => 'Remove field',
142
+            'page callback' => 'drupal_get_form',
143
+            'page arguments' => array('content_field_remove_form', $type_name, $field_name),
144
+            'access arguments' => array('administer content types'),
145
+            'file' => 'includes/content.admin.inc',
146
+            'type' => MENU_CALLBACK,
147 147
         );
148
-      }
148
+        }
149
+    }
149 150
     }
150
-  }
151
-  return $items;
151
+    return $items;
152 152
 }
153 153
 
154 154
 /**
@@ -163,69 +163,69 @@  discard block
 block discarded – undo
163 163
  * the same name as the hook_elements key.
164 164
  */
165 165
 function content_elements() {
166
-  return array(
166
+    return array(
167 167
     'content_multiple_values' => array(),
168 168
     'content_field' => array(),
169
-  );
169
+    );
170 170
 }
171 171
 
172 172
 /**
173 173
  * Implementation of hook_theme().
174 174
  */
175 175
 function content_theme() {
176
-  $path = drupal_get_path('module', 'content') .'/theme';
177
-  require_once "./$path/theme.inc";
176
+    $path = drupal_get_path('module', 'content') .'/theme';
177
+    require_once "./$path/theme.inc";
178 178
 
179
-  return array(
179
+    return array(
180 180
     'content_field' => array(
181
-      'template' => 'content-field',
182
-      'arguments' => array('element' => NULL),
183
-      'path' => $path,
181
+        'template' => 'content-field',
182
+        'arguments' => array('element' => NULL),
183
+        'path' => $path,
184 184
     ),
185 185
     'content_overview_links' => array(
186
-      'arguments' => array(),
186
+        'arguments' => array(),
187 187
     ),
188 188
     'content_field_overview_form' => array(
189
-      'template' => 'content-admin-field-overview-form',
190
-      'file' => 'theme.inc',
191
-      'path' => $path,
192
-      'arguments' => array('form' => NULL),
189
+        'template' => 'content-admin-field-overview-form',
190
+        'file' => 'theme.inc',
191
+        'path' => $path,
192
+        'arguments' => array('form' => NULL),
193 193
     ),
194 194
     'content_display_overview_form' => array(
195
-      'template' => 'content-admin-display-overview-form',
196
-      'file' => 'theme.inc',
197
-      'path' => $path,
198
-      'arguments' => array('form' => NULL),
195
+        'template' => 'content-admin-display-overview-form',
196
+        'file' => 'theme.inc',
197
+        'path' => $path,
198
+        'arguments' => array('form' => NULL),
199 199
     ),
200 200
     'content_exclude' => array(
201
-      'arguments' => array('content' => NULL, 'object' => array(), 'context' => NULL),
201
+        'arguments' => array('content' => NULL, 'object' => array(), 'context' => NULL),
202 202
     ),
203 203
     'content_view_multiple_field' => array(
204
-      'arguments' => array('items' => NULL, 'field' => NULL, 'data' => NULL),
204
+        'arguments' => array('items' => NULL, 'field' => NULL, 'data' => NULL),
205 205
     ),
206 206
     'content_multiple_values' => array(
207
-      'arguments' => array('element' => NULL),
207
+        'arguments' => array('element' => NULL),
208 208
     ),
209
-  );
209
+    );
210 210
 }
211 211
 
212 212
 /**
213 213
  * Implementation of hook_views_api().
214 214
  */
215 215
 function content_views_api() {
216
-  return array(
216
+    return array(
217 217
     'api' => 2,
218 218
     'path' => drupal_get_path('module', 'content') . '/includes/views',
219
-  );
219
+    );
220 220
 }
221 221
 
222 222
 /**
223 223
  * Implementation of hook_ctools_plugin_directory().
224 224
  */
225 225
 function content_ctools_plugin_directory($module, $plugin) {
226
-  if ($module == 'ctools' && $plugin == 'content_types') {
226
+    if ($module == 'ctools' && $plugin == 'content_types') {
227 227
     return 'includes/panels/' . $plugin;
228
-  }
228
+    }
229 229
 }
230 230
 
231 231
 /**
@@ -237,28 +237,28 @@  discard block
 block discarded – undo
237 237
  * cache the loaded object structure and invalidate it during the update process.
238 238
  */
239 239
 function content_load(&$node) {
240
-  $cid = 'content:'. $node->nid .':'. $node->vid;
241
-  if ($cached = cache_get($cid, content_cache_tablename())) {
240
+    $cid = 'content:'. $node->nid .':'. $node->vid;
241
+    if ($cached = cache_get($cid, content_cache_tablename())) {
242 242
     foreach ($cached->data as $key => $value) {
243
-      $node->$key = $value;
243
+        $node->$key = $value;
244 244
     }
245
-  }
246
-  else {
245
+    }
246
+    else {
247 247
     $default_additions = _content_field_invoke_default('load', $node);
248 248
     if ($default_additions) {
249
-      foreach ($default_additions as $key => $value) {
249
+        foreach ($default_additions as $key => $value) {
250 250
         $node->$key = $value;
251
-      }
251
+        }
252 252
     }
253 253
     $additions = _content_field_invoke('load', $node);
254 254
     if ($additions) {
255
-      foreach ($additions as $key => $value) {
255
+        foreach ($additions as $key => $value) {
256 256
         $node->$key = $value;
257 257
         $default_additions[$key] = $value;
258
-      }
258
+        }
259 259
     }
260 260
     cache_set($cid, $default_additions, content_cache_tablename());
261
-  }
261
+    }
262 262
 }
263 263
 
264 264
 /**
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
  *
267 267
  */
268 268
 function content_validate(&$node, $form = NULL) {
269
-  _content_field_invoke('validate', $node, $form);
270
-  _content_field_invoke_default('validate', $node, $form);
269
+    _content_field_invoke('validate', $node, $form);
270
+    _content_field_invoke_default('validate', $node, $form);
271 271
 }
272 272
 
273 273
 /**
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
  *
276 276
  */
277 277
 function content_presave(&$node) {
278
-  _content_field_invoke('presave', $node);
279
-  _content_field_invoke_default('presave', $node);
278
+    _content_field_invoke('presave', $node);
279
+    _content_field_invoke_default('presave', $node);
280 280
 }
281 281
 
282 282
 /**
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
  * Insert node type fields.
286 286
  */
287 287
 function content_insert(&$node) {
288
-  _content_field_invoke('insert', $node);
289
-  _content_field_invoke_default('insert', $node);
288
+    _content_field_invoke('insert', $node);
289
+    _content_field_invoke_default('insert', $node);
290 290
 }
291 291
 
292 292
 /**
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
  * Update node type fields.
296 296
  */
297 297
 function content_update(&$node) {
298
-  _content_field_invoke('update', $node);
299
-  _content_field_invoke_default('update', $node);
300
-  cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
298
+    _content_field_invoke('update', $node);
299
+    _content_field_invoke_default('update', $node);
300
+    cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
301 301
 }
302 302
 
303 303
 /**
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
  * Delete node type fields.
307 307
  */
308 308
 function content_delete(&$node) {
309
-  _content_field_invoke('delete', $node);
310
-  _content_field_invoke_default('delete', $node);
311
-  cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), TRUE);
309
+    _content_field_invoke('delete', $node);
310
+    _content_field_invoke_default('delete', $node);
311
+    cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), TRUE);
312 312
 }
313 313
 
314 314
 /**
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
  * Delete node type fields for a revision.
318 318
  */
319 319
 function content_delete_revision(&$node) {
320
-  _content_field_invoke('delete revision', $node);
321
-  _content_field_invoke_default('delete revision', $node);
322
-  cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
320
+    _content_field_invoke('delete revision', $node);
321
+    _content_field_invoke_default('delete revision', $node);
322
+    cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
323 323
 }
324 324
 
325 325
 /**
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
  * Generate field render arrays.
329 329
  */
330 330
 function content_view(&$node, $teaser = FALSE, $page = FALSE) {
331
-  // Let field modules sanitize their data for output.
332
-  _content_field_invoke('sanitize', $node, $teaser, $page);
331
+    // Let field modules sanitize their data for output.
332
+    _content_field_invoke('sanitize', $node, $teaser, $page);
333 333
 
334
-  // Merge fields.
335
-  $additions = _content_field_invoke_default('view', $node, $teaser, $page);
336
-  $node->content = array_merge((array) $node->content, $additions);
334
+    // Merge fields.
335
+    $additions = _content_field_invoke_default('view', $node, $teaser, $page);
336
+    $node->content = array_merge((array) $node->content, $additions);
337 337
 }
338 338
 
339 339
 /**
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
  *   The themed output for the field.
362 362
  */
363 363
 function content_view_field($field, $node, $teaser = FALSE, $page = FALSE) {
364
-  $output = '';
365
-  if (isset($node->$field['field_name'])) {
364
+    $output = '';
365
+    if (isset($node->$field['field_name'])) {
366 366
     $items = $node->$field['field_name'];
367 367
 
368 368
     // Use 'full'/'teaser' if not specified otherwise.
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
     $module = $field_types[$field['type']]['module'];
374 374
     $function = $module .'_field';
375 375
     if (function_exists($function)) {
376
-      $function('sanitize', $node, $field, $items, $teaser, $page);
377
-      $node->$field['field_name'] = $items;
376
+        $function('sanitize', $node, $field, $items, $teaser, $page);
377
+        $node->$field['field_name'] = $items;
378 378
     }
379 379
 
380 380
     $view = content_field('view', $node, $field, $items, $teaser, $page);
381 381
     // content_field('view') adds a wrapper to handle variables and 'excluded'
382 382
     // fields for node templates. We bypass it and render the actual field.
383 383
     $output = drupal_render($view[$field['field_name']]['field']);
384
-  }
385
-  return $output;
384
+    }
385
+    return $output;
386 386
 }
387 387
 
388 388
 /**
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
  * so that node templates can use it.
393 393
  */
394 394
 function content_alter(&$node, $teaser = FALSE, $page = FALSE) {
395
-  _content_field_invoke_default('alter', $node, $teaser, $page);
395
+    _content_field_invoke_default('alter', $node, $teaser, $page);
396 396
 }
397 397
 
398 398
 /**
@@ -401,70 +401,70 @@  discard block
 block discarded – undo
401 401
  * Generate field render arrays.
402 402
  */
403 403
 function content_prepare_translation(&$node) {
404
-  $default_additions = _content_field_invoke_default('prepare translation', $node);
405
-  $additions = _content_field_invoke('prepare translation', $node);
406
-  // Merge module additions after the default ones to enable overriding
407
-  // of field values.
408
-  $node = (object) array_merge((array) $node, $default_additions, $additions);
404
+    $default_additions = _content_field_invoke_default('prepare translation', $node);
405
+    $additions = _content_field_invoke('prepare translation', $node);
406
+    // Merge module additions after the default ones to enable overriding
407
+    // of field values.
408
+    $node = (object) array_merge((array) $node, $default_additions, $additions);
409 409
 }
410 410
 
411 411
 /**
412 412
  * Implementation of hook_nodeapi().
413 413
  */
414 414
 function content_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
415
-  // Prevent against invalid 'nodes' built by broken 3rd party code.
416
-  if (isset($node->type)) {
415
+    // Prevent against invalid 'nodes' built by broken 3rd party code.
416
+    if (isset($node->type)) {
417 417
     $type = content_types($node->type);
418 418
     // Save cycles if the type has no CCK fields.
419 419
     if (!empty($type['fields'])) {
420
-      $callback = 'content_'. str_replace(' ', '_', $op);
421
-      if (function_exists($callback)) {
420
+        $callback = 'content_'. str_replace(' ', '_', $op);
421
+        if (function_exists($callback)) {
422 422
         $callback($node, $a3, $a4);
423
-      }
423
+        }
424 424
     }
425 425
 
426 426
     // Special case for 'view' op, we want to adjust weights of non-cck fields
427 427
     // even if there are no actual fields for this type.
428 428
     if ($op == 'view') {
429
-      $node->content['#pre_render'][] = 'content_alter_extra_weights';
430
-      $node->content['#content_extra_fields'] = $type['extra'];
429
+        $node->content['#pre_render'][] = 'content_alter_extra_weights';
430
+        $node->content['#content_extra_fields'] = $type['extra'];
431
+    }
431 432
     }
432
-  }
433 433
 }
434 434
 
435 435
 /**
436 436
  *  Implementation of hook_form_alter().
437 437
  */
438 438
 function content_form_alter(&$form, $form_state, $form_id) {
439
-  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
439
+    if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
440 440
     $type = content_types($form['#node']->type);
441 441
     if (!empty($type['fields'])) {
442
-      module_load_include('inc', 'content', 'includes/content.node_form');
443
-      // Merge field widgets.
444
-      $form = array_merge($form, content_form($form, $form_state));
442
+        module_load_include('inc', 'content', 'includes/content.node_form');
443
+        // Merge field widgets.
444
+        $form = array_merge($form, content_form($form, $form_state));
445 445
     }
446 446
     $form['#pre_render'][] = 'content_alter_extra_weights';
447 447
     $form['#content_extra_fields'] = $type['extra'];
448
-  }
448
+    }
449 449
 }
450 450
 
451 451
 /**
452 452
  * Pre-render callback to adjust weights of non-CCK fields.
453 453
  */
454 454
 function content_alter_extra_weights($elements) {
455
-  if (isset($elements['#content_extra_fields'])) {
455
+    if (isset($elements['#content_extra_fields'])) {
456 456
     foreach ($elements['#content_extra_fields'] as $key => $value) {
457
-      // Some core 'fields' use a different key in node forms and in 'view'
458
-      // render arrays. Check we're not on a form first.
459
-      if (!isset($elements['#build_id']) && isset($value['view']) && isset($elements[$value['view']])) {
457
+        // Some core 'fields' use a different key in node forms and in 'view'
458
+        // render arrays. Check we're not on a form first.
459
+        if (!isset($elements['#build_id']) && isset($value['view']) && isset($elements[$value['view']])) {
460 460
         $elements[$value['view']]['#weight'] = $value['weight'];
461
-      }
462
-      elseif (isset($elements[$key])) {
461
+        }
462
+        elseif (isset($elements[$key])) {
463 463
         $elements[$key]['#weight'] = $value['weight'];
464
-      }
464
+        }
465
+    }
465 466
     }
466
-  }
467
-  return $elements;
467
+    return $elements;
468 468
 }
469 469
 
470 470
 /**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
  * included yet when the form is processed and invokes the callback.
473 473
  */
474 474
 function content_add_more_submit_proxy($form, &$form_state) {
475
-  module_load_include('inc', 'content', 'includes/content.node_form');
476
-  content_add_more_submit($form, $form_state);
475
+    module_load_include('inc', 'content', 'includes/content.node_form');
476
+    content_add_more_submit($form, $form_state);
477 477
 }
478 478
 
479 479
 /**
@@ -482,21 +482,21 @@  discard block
 block discarded – undo
482 482
  * Combine multiple values into a table with drag-n-drop reordering.
483 483
  */
484 484
 function theme_content_multiple_values($element) {
485
-  $field_name = $element['#field_name'];
486
-  $field = content_fields($field_name);
487
-  $output = '';
485
+    $field_name = $element['#field_name'];
486
+    $field = content_fields($field_name);
487
+    $output = '';
488 488
 
489
-  if ($field['multiple'] >= 1) {
489
+    if ($field['multiple'] >= 1) {
490 490
     $table_id = $element['#field_name'] .'_values';
491 491
     $order_class = $element['#field_name'] .'-delta-order';
492 492
     $required = !empty($element['#required']) ? '<span class="form-required" title="'. t('This field is required.') .'">*</span>' : '';
493 493
 
494 494
     $header = array(
495
-      array(
495
+        array(
496 496
         'data' => t('!title: !required', array('!title' => $element['#title'], '!required' => $required)),
497 497
         'colspan' => 2
498
-      ),
499
-      t('Order'),
498
+        ),
499
+        t('Order'),
500 500
     );
501 501
     $rows = array();
502 502
 
@@ -504,25 +504,25 @@  discard block
 block discarded – undo
504 504
     // preview or failed validation)
505 505
     $items = array();
506 506
     foreach (element_children($element) as $key) {
507
-      if ($key !== $element['#field_name'] .'_add_more') {
507
+        if ($key !== $element['#field_name'] .'_add_more') {
508 508
         $items[] = &$element[$key];
509
-      }
509
+        }
510 510
     }
511 511
     usort($items, '_content_sort_items_value_helper');
512 512
 
513 513
     // Add the items as table rows.
514 514
     foreach ($items as $key => $item) {
515
-      $item['_weight']['#attributes']['class'] = $order_class;
516
-      $delta_element = drupal_render($item['_weight']);
517
-      $cells = array(
515
+        $item['_weight']['#attributes']['class'] = $order_class;
516
+        $delta_element = drupal_render($item['_weight']);
517
+        $cells = array(
518 518
         array('data' => '', 'class' => 'content-multiple-drag'),
519 519
         drupal_render($item),
520 520
         array('data' => $delta_element, 'class' => 'delta-order'),
521
-      );
522
-      $rows[] = array(
521
+        );
522
+        $rows[] = array(
523 523
         'data' => $cells,
524 524
         'class' => 'draggable',
525
-      );
525
+        );
526 526
     }
527 527
 
528 528
     $output .= theme('table', $header, $rows, array('id' => $table_id, 'class' => 'content-multiple-table'));
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
     $output .= drupal_render($element[$element['#field_name'] .'_add_more']);
531 531
 
532 532
     drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
533
-  }
534
-  else {
533
+    }
534
+    else {
535 535
     foreach (element_children($element) as $key) {
536
-      $output .= drupal_render($element[$key]);
536
+        $output .= drupal_render($element[$key]);
537
+    }
537 538
     }
538
-  }
539 539
 
540
-  return $output;
540
+    return $output;
541 541
 }
542 542
 
543 543
 /**
@@ -552,29 +552,29 @@  discard block
 block discarded – undo
552 552
  *   field modules are installed, uninstalled, enabled or disabled.
553 553
  */
554 554
 function content_notify($op, $module) {
555
-  switch ($op) {
555
+    switch ($op) {
556 556
     case 'install':
557 557
       content_clear_type_cache();
558
-      break;
558
+        break;
559 559
     case 'uninstall':
560 560
       module_load_include('inc', 'content', 'includes/content.crud');
561
-      content_module_delete($module);
562
-      break;
561
+        content_module_delete($module);
562
+        break;
563 563
     case 'enable':
564 564
       content_associate_fields($module);
565
-      content_clear_type_cache();
566
-      break;
565
+        content_clear_type_cache();
566
+        break;
567 567
     case 'disable':
568 568
       // When CCK modules are disabled before content module's update is run
569 569
       // to add the active column, we can't do this.
570 570
       if (variable_get('content_schema_version', -1) < 6007) {
571 571
         return FALSE;
572
-      }
573
-      db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
-      content_clear_type_cache(TRUE);
576
-      break;
577
-  }
572
+        }
573
+        db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
+        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
+        content_clear_type_cache(TRUE);
576
+        break;
577
+    }
578 578
 }
579 579
 
580 580
 /**
@@ -584,39 +584,39 @@  discard block
 block discarded – undo
584 584
  *   The name of the module to update on.
585 585
  */
586 586
 function content_associate_fields($module) {
587
-  // When CCK modules are enabled before content module's update is run,
588
-  // to add module and active columns, we can't do this.
589
-  if (variable_get('content_schema_version', -1) < 6007) {
587
+    // When CCK modules are enabled before content module's update is run,
588
+    // to add module and active columns, we can't do this.
589
+    if (variable_get('content_schema_version', -1) < 6007) {
590 590
     return FALSE;
591
-  }
592
-  $module_fields = module_invoke($module, 'field_info');
593
-  if ($module_fields) {
591
+    }
592
+    $module_fields = module_invoke($module, 'field_info');
593
+    if ($module_fields) {
594 594
     foreach ($module_fields as $name => $field_info) {
595
-      watchdog('content', 'Updating field type %type with module %module.', array('%type' => $name, '%module' => $module));
596
-      db_query("UPDATE {". content_field_tablename() ."} SET module = '%s', active = %d WHERE type = '%s'", $module, 1, $name);
595
+        watchdog('content', 'Updating field type %type with module %module.', array('%type' => $name, '%module' => $module));
596
+        db_query("UPDATE {". content_field_tablename() ."} SET module = '%s', active = %d WHERE type = '%s'", $module, 1, $name);
597 597
     }
598
-  }
599
-  $module_widgets = module_invoke($module, 'widget_info');
600
-  if ($module_widgets) {
598
+    }
599
+    $module_widgets = module_invoke($module, 'widget_info');
600
+    if ($module_widgets) {
601 601
     foreach ($module_widgets as $name => $widget_info) {
602
-      watchdog('content', 'Updating widget type %type with module %module.', array('%type' => $name, '%module' => $module));
603
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_module = '%s', widget_active = %d WHERE widget_type = '%s'", $module, 1, $name);
604
-    }
605
-  }
606
-  // This is called from updates and installs, so get the install-safe
607
-  // version of a fields array.
608
-  $fields_set = array();
609
-  module_load_include('install', 'content');
610
-  $types = content_types_install();
611
-  foreach ($types as $type_name => $fields) {
602
+        watchdog('content', 'Updating widget type %type with module %module.', array('%type' => $name, '%module' => $module));
603
+        db_query("UPDATE {". content_instance_tablename() ."} SET widget_module = '%s', widget_active = %d WHERE widget_type = '%s'", $module, 1, $name);
604
+    }
605
+    }
606
+    // This is called from updates and installs, so get the install-safe
607
+    // version of a fields array.
608
+    $fields_set = array();
609
+    module_load_include('install', 'content');
610
+    $types = content_types_install();
611
+    foreach ($types as $type_name => $fields) {
612 612
     foreach ($fields as $field) {
613
-      if ($field['module'] == $module && !in_array($field['field_name'], $fields_set)) {
613
+        if ($field['module'] == $module && !in_array($field['field_name'], $fields_set)) {
614 614
         $columns = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field);
615 615
         db_query("UPDATE {". content_field_tablename() ."} SET db_columns = '%s' WHERE field_name = '%s'", serialize($columns), $field['field_name']);
616 616
         $fields_set[] = $field['field_name'];
617
-      }
617
+        }
618
+    }
618 619
     }
619
-  }
620 620
 }
621 621
 
622 622
 /**
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
  *   );
685 685
  */
686 686
 function content_field($op, &$node, $field, &$items, $teaser, $page) {
687
-  switch ($op) {
687
+    switch ($op) {
688 688
     case 'validate':
689 689
       // TODO: here we could validate that the number of multiple data is correct ?
690 690
       // We're controlling the number of fields to fill out and saving empty
@@ -699,107 +699,107 @@  discard block
 block discarded – undo
699 699
         include_once('./'. drupal_get_path('module', 'content') .'/includes/content.devel.inc');
700 700
         content_generate_fields($node, $field);
701 701
         $items = $node->{$field['field_name']};
702
-      }
703
-
704
-      // Manual node_save calls might not have all fields filled in.
705
-      // On node insert, we need to make sure all tables get at least an empty
706
-      // record, or subsequent edits, using drupal_write_record() in update mode,
707
-      // won't insert any data.
708
-      // Missing fields on node update are handled in content_storage().
709
-      if (empty($items) && !isset($node->nid)) {
702
+        }
703
+
704
+        // Manual node_save calls might not have all fields filled in.
705
+        // On node insert, we need to make sure all tables get at least an empty
706
+        // record, or subsequent edits, using drupal_write_record() in update mode,
707
+        // won't insert any data.
708
+        // Missing fields on node update are handled in content_storage().
709
+        if (empty($items) && !isset($node->nid)) {
710 710
         foreach (array_keys($field['columns']) as $column) {
711
-          $items[0][$column] = NULL;
711
+            $items[0][$column] = NULL;
712 712
         }
713 713
         $node->$field['field_name'] = $items;
714
-      }
714
+        }
715 715
 
716
-      // If there was an AHAH add more button in this field, don't save it.
717
-      // TODO: is it still needed ?
718
-      unset($items[$field['field_name'] .'_add_more']);
716
+        // If there was an AHAH add more button in this field, don't save it.
717
+        // TODO: is it still needed ?
718
+        unset($items[$field['field_name'] .'_add_more']);
719 719
 
720
-      if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
720
+        if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
721 721
         // Reorder items to account for drag-n-drop reordering.
722 722
         $items = _content_sort_items($field, $items);
723
-      }
723
+        }
724 724
 
725
-      // Filter out empty values.
726
-      $items = content_set_empty($field, $items);
725
+        // Filter out empty values.
726
+        $items = content_set_empty($field, $items);
727 727
 
728
-      break;
728
+        break;
729 729
 
730 730
     case 'view':
731 731
       $addition = array();
732 732
 
733
-      // Previewed nodes bypass the 'presave' op, so we need to some massaging.
734
-      if ($node->build_mode == NODE_BUILD_PREVIEW && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
733
+        // Previewed nodes bypass the 'presave' op, so we need to some massaging.
734
+        if ($node->build_mode == NODE_BUILD_PREVIEW && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
735 735
         if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
736
-          // Reorder items to account for drag-n-drop reordering.
737
-          $items = _content_sort_items($field, $items);
736
+            // Reorder items to account for drag-n-drop reordering.
737
+            $items = _content_sort_items($field, $items);
738 738
         }
739 739
 
740 740
         // Filter out empty values.
741 741
         $items = content_set_empty($field, $items);
742
-      }
742
+        }
743 743
 
744
-      // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745
-      if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
744
+        // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745
+        if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
746 746
         $context = $teaser ? 'teaser' : 'full';
747
-      }
748
-      else {
747
+        }
748
+        else {
749 749
         $context = $node->build_mode;
750
-      }
751
-      // The field may be missing info for $contexts added by modules
752
-      // enabled after the field was last edited.
753
-      $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754
-      if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
750
+        }
751
+        // The field may be missing info for $contexts added by modules
752
+        // enabled after the field was last edited.
753
+        $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754
+        if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
755 755
         $theme = $formatter['module'] .'_formatter_'. $formatter_name;
756 756
         $single = (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE);
757 757
 
758 758
         $label_display = isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above';
759 759
         // Do not include field labels when indexing content.
760 760
         if ($context == NODE_BUILD_SEARCH_INDEX) {
761
-          $label_display = 'hidden';
761
+            $label_display = 'hidden';
762 762
         }
763 763
 
764 764
         $element = array(
765
-          '#type' => 'content_field',
766
-          '#title' => check_plain(t($field['widget']['label'])),
767
-          '#field_name' => $field['field_name'],
768
-          '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
769
-          '#label_display' => $label_display,
770
-          '#node' => $node,
771
-          '#teaser' => $teaser,
772
-          '#page' => $page,
773
-          '#context' => $context,
774
-          '#single' => $single,
775
-          'items' => array(),
765
+            '#type' => 'content_field',
766
+            '#title' => check_plain(t($field['widget']['label'])),
767
+            '#field_name' => $field['field_name'],
768
+            '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
769
+            '#label_display' => $label_display,
770
+            '#node' => $node,
771
+            '#teaser' => $teaser,
772
+            '#page' => $page,
773
+            '#context' => $context,
774
+            '#single' => $single,
775
+            'items' => array(),
776 776
         );
777 777
 
778 778
         // Fill-in items.
779 779
         foreach ($items as $delta => $item) {
780
-          $element['items'][$delta] = array(
780
+            $element['items'][$delta] = array(
781 781
             '#item' => $item,
782 782
             '#weight' => $delta,
783
-          );
783
+            );
784 784
         }
785 785
 
786 786
         // Append formatter information either on each item ('single-value' formatter)
787 787
         // or at the upper 'items' level ('multiple-value' formatter)
788 788
         $format_info = array(
789
-          '#theme' => $theme,
790
-          '#field_name' => $field['field_name'],
791
-          '#type_name' => $node->type,
792
-          '#formatter' => $formatter_name,
793
-          '#node' => $node,
789
+            '#theme' => $theme,
790
+            '#field_name' => $field['field_name'],
791
+            '#type_name' => $node->type,
792
+            '#formatter' => $formatter_name,
793
+            '#node' => $node,
794 794
         );
795 795
         if ($single) {
796
-          foreach ($items as $delta => $item) {
796
+            foreach ($items as $delta => $item) {
797 797
             $element['items'][$delta] += $format_info;
798 798
             $element['items'][$delta]['#item']['#delta'] = $delta;
799
-          }
799
+            }
800 800
         }
801 801
         else {
802
-          $element['items'] += $format_info;
802
+            $element['items'] += $format_info;
803 803
         }
804 804
 
805 805
         // The wrapper lets us get the themed output for the whole field
@@ -807,17 +807,17 @@  discard block
 block discarded – undo
807 807
         // and hide it from the $content variable if needed.
808 808
         // See 'preprocess_node' op and theme_content_field_wrapper()?
809 809
         $wrapper = array(
810
-          'field' => $element,
811
-          '#weight' => $field['widget']['weight'],
812
-          '#post_render' => array('content_field_wrapper_post_render'),
813
-          '#field_name' => $field['field_name'],
814
-          '#type_name' => $node->type,
815
-          '#context' => $context,
810
+            'field' => $element,
811
+            '#weight' => $field['widget']['weight'],
812
+            '#post_render' => array('content_field_wrapper_post_render'),
813
+            '#field_name' => $field['field_name'],
814
+            '#type_name' => $node->type,
815
+            '#context' => $context,
816 816
         );
817 817
 
818 818
         $addition = array($field['field_name'] => $wrapper);
819
-      }
820
-      return $addition;
819
+        }
820
+        return $addition;
821 821
 
822 822
     case 'alter':
823 823
       // Add back the formatted values in the 'view' element,
@@ -827,64 +827,64 @@  discard block
 block discarded – undo
827 827
       // The location of the field's rendered output depends on whether the
828 828
       // field is in a fieldgroup or not.
829 829
       $wrapper = NULL;
830
-      if (isset($node->content[$field['field_name']])) {
830
+        if (isset($node->content[$field['field_name']])) {
831 831
         $wrapper = $node->content[$field['field_name']];
832
-      }
833
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
832
+        }
833
+        elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
834 834
         $wrapper = $node->content[$group_name]['group'][$field['field_name']];
835
-      }
835
+        }
836 836
 
837
-      if ($wrapper) {
837
+        if ($wrapper) {
838 838
         $element = $wrapper['field'];
839 839
         // '#single' is not set if the field is hidden or inaccessible.
840 840
         if (isset($element['#single'])) {
841
-          if (!empty($element['#single'])) {
841
+            if (!empty($element['#single'])) {
842 842
             // Single value formatter.
843 843
             foreach (element_children($element['items']) as $delta) {
844
-              // '#chilren' is not set if the field is empty.
845
-              $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
844
+                // '#chilren' is not set if the field is empty.
845
+                $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
846
+            }
846 847
             }
847
-          }
848
-          elseif (isset($element['items']['#children']))  {
848
+            elseif (isset($element['items']['#children']))  {
849 849
             // Multiple values formatter.
850 850
             $items[0]['view'] = $element['items']['#children'];
851
-          }
851
+            }
852 852
         }
853 853
         else {
854
-          // Hidden or inaccessible field.
855
-          $items[0]['view'] = '';
854
+            // Hidden or inaccessible field.
855
+            $items[0]['view'] = '';
856 856
         }
857
-      }
858
-      break;
857
+        }
858
+        break;
859 859
 
860 860
     case 'preprocess_node':
861 861
       // Add $FIELD_NAME_rendered variables.
862 862
       $addition = array();
863 863
 
864
-      // The location of the field's rendered output depends on whether the
865
-      // field is in a fieldgroup or not.
866
-      $wrapper = NULL;
867
-      if (isset($node->content[$field['field_name']])) {
864
+        // The location of the field's rendered output depends on whether the
865
+        // field is in a fieldgroup or not.
866
+        $wrapper = NULL;
867
+        if (isset($node->content[$field['field_name']])) {
868 868
         $wrapper = $node->content[$field['field_name']];
869
-      }
870
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
869
+        }
870
+        elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
871 871
         $wrapper = $node->content[$group_name]['group'][$field['field_name']];
872
-      }
872
+        }
873 873
 
874
-      if ($wrapper) {
874
+        if ($wrapper) {
875 875
         // '#chilren' is not set if the field is empty.
876 876
         $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
877
-      }
877
+        }
878 878
 
879
-      return $addition;
879
+        return $addition;
880 880
 
881 881
     case 'prepare translation':
882 882
       $addition = array();
883
-      if (isset($node->translation_source->$field['field_name'])) {
883
+        if (isset($node->translation_source->$field['field_name'])) {
884 884
         $addition[$field['field_name']] = $node->translation_source->$field['field_name'];
885
-      }
886
-      return $addition;
887
-  }
885
+        }
886
+        return $addition;
887
+    }
888 888
 }
889 889
 
890 890
 /**
@@ -899,24 +899,24 @@  discard block
 block discarded – undo
899 899
  *   returns filtered and adjusted item array
900 900
  */
901 901
 function content_set_empty($field, $items) {
902
-  // Filter out empty values.
903
-  $filtered = array();
904
-  $function = $field['module'] .'_content_is_empty';
905
-  foreach ((array) $items as $delta => $item) {
902
+    // Filter out empty values.
903
+    $filtered = array();
904
+    $function = $field['module'] .'_content_is_empty';
905
+    foreach ((array) $items as $delta => $item) {
906 906
     if (!$function($item, $field)) {
907
-      $filtered[] = $item;
907
+        $filtered[] = $item;
908
+    }
908 909
     }
909
-  }
910 910
 
911
-  // Make sure we store the right number of 'empty' values.
912
-  $empty = array();
913
-  foreach (array_keys($field['columns']) as $column) {
911
+    // Make sure we store the right number of 'empty' values.
912
+    $empty = array();
913
+    foreach (array_keys($field['columns']) as $column) {
914 914
     $empty[$column] = NULL;
915
-  }
916
-  $pad = $field['multiple'] > 1 ? $field['multiple'] : 1;
917
-  $filtered = array_pad($filtered, $pad, $empty);
915
+    }
916
+    $pad = $field['multiple'] > 1 ? $field['multiple'] : 1;
917
+    $filtered = array_pad($filtered, $pad, $empty);
918 918
 
919
-  return $filtered;
919
+    return $filtered;
920 920
 }
921 921
 
922 922
 /**
@@ -924,15 +924,15 @@  discard block
 block discarded – undo
924 924
  * user drag-n-drop reordering.
925 925
  */
926 926
 function _content_sort_items($field, $items) {
927
-  if ($field['multiple'] >= 1 && isset($items[0]['_weight'])) {
927
+    if ($field['multiple'] >= 1 && isset($items[0]['_weight'])) {
928 928
     usort($items, '_content_sort_items_helper');
929 929
     foreach ($items as $delta => $item) {
930
-      if (is_array($items[$delta])) {
930
+        if (is_array($items[$delta])) {
931 931
         unset($items[$delta]['_weight']);
932
-      }
932
+        }
933
+    }
933 934
     }
934
-  }
935
-  return $items;
935
+    return $items;
936 936
 }
937 937
 
938 938
 /**
@@ -940,50 +940,50 @@  discard block
 block discarded – undo
940 940
  * (copied form element_sort(), which acts on #weight keys)
941 941
  */
942 942
 function _content_sort_items_helper($a, $b) {
943
-  $a_weight = (is_array($a) && isset($a['_weight'])) ? $a['_weight'] : 0;
944
-  $b_weight = (is_array($b) && isset($b['_weight'])) ? $b['_weight'] : 0;
945
-  if ($a_weight == $b_weight) {
943
+    $a_weight = (is_array($a) && isset($a['_weight'])) ? $a['_weight'] : 0;
944
+    $b_weight = (is_array($b) && isset($b['_weight'])) ? $b['_weight'] : 0;
945
+    if ($a_weight == $b_weight) {
946 946
     return 0;
947
-  }
948
-  return ($a_weight < $b_weight) ? -1 : 1;
947
+    }
948
+    return ($a_weight < $b_weight) ? -1 : 1;
949 949
 }
950 950
 
951 951
 /**
952 952
  * Same as above, using ['_weight']['#value']
953 953
  */
954 954
 function _content_sort_items_value_helper($a, $b) {
955
-  $a_weight = (is_array($a) && isset($a['_weight']['#value'])) ? $a['_weight']['#value'] : 0;
956
-  $b_weight = (is_array($b) && isset($b['_weight']['#value'])) ? $b['_weight']['#value'] : 0;
957
-  if ($a_weight == $b_weight) {
955
+    $a_weight = (is_array($a) && isset($a['_weight']['#value'])) ? $a['_weight']['#value'] : 0;
956
+    $b_weight = (is_array($b) && isset($b['_weight']['#value'])) ? $b['_weight']['#value'] : 0;
957
+    if ($a_weight == $b_weight) {
958 958
     return 0;
959
-  }
960
-  return ($a_weight < $b_weight) ? -1 : 1;
959
+    }
960
+    return ($a_weight < $b_weight) ? -1 : 1;
961 961
 }
962 962
 
963 963
 /**
964 964
  * Handle storage ops for _content_field_invoke_default().
965 965
  */
966 966
 function content_storage($op, $node) {
967
-  // Don't try this before content module's update is run to add
968
-  // the active and module columns.
969
-  if (variable_get('content_schema_version', -1) < 6007) {
967
+    // Don't try this before content module's update is run to add
968
+    // the active and module columns.
969
+    if (variable_get('content_schema_version', -1) < 6007) {
970 970
     return FALSE;
971
-  }
971
+    }
972 972
 
973
-  $type_name = $node->type;
974
-  $type = content_types($type_name);
973
+    $type_name = $node->type;
974
+    $type = content_types($type_name);
975 975
 
976
-  switch ($op) {
976
+    switch ($op) {
977 977
     case 'load':
978 978
       // OPTIMIZE: load all non multiple fields in a single JOIN query ?
979 979
       // warning: 61-join limit in MySQL ?
980 980
       $additions = array();
981
-      // For each table used by this content type,
982
-      foreach ($type['tables'] as $table) {
981
+        // For each table used by this content type,
982
+        foreach ($type['tables'] as $table) {
983 983
         $schema = drupal_get_schema($table);
984 984
         // The per-type table might not have any fields actually stored in it.
985 985
         if (!$schema['content fields']) {
986
-          continue;
986
+            continue;
987 987
         }
988 988
         $query = 'SELECT * FROM {'. $table .'} WHERE vid = %d';
989 989
 
@@ -994,25 +994,25 @@  discard block
 block discarded – undo
994 994
 
995 995
         // For each table row, populate the fields.
996 996
         while ($row = db_fetch_array($result)) {
997
-          // For each field stored in the table, add the field item.
998
-          foreach ($schema['content fields'] as $field_name) {
997
+            // For each field stored in the table, add the field item.
998
+            foreach ($schema['content fields'] as $field_name) {
999 999
             $item = array();
1000 1000
             $field = content_fields($field_name, $type_name);
1001 1001
             $db_info = content_database_info($field);
1002 1002
             // For each column declared by the field, populate the item.
1003 1003
             foreach ($db_info['columns'] as $column => $attributes) {
1004
-              $item[$column] = $row[$attributes['column']];
1004
+                $item[$column] = $row[$attributes['column']];
1005 1005
             }
1006 1006
 
1007 1007
             // Add the item to the field values for the node.
1008 1008
             if (!isset($additions[$field_name])) {
1009
-              $additions[$field_name] = array();
1009
+                $additions[$field_name] = array();
1010 1010
             }
1011 1011
             $additions[$field_name][] = $item;
1012
-          }
1012
+            }
1013 1013
         }
1014
-      }
1015
-      return $additions;
1014
+        }
1015
+        return $additions;
1016 1016
 
1017 1017
     case 'insert':
1018 1018
     case 'update':
@@ -1020,17 +1020,17 @@  discard block
 block discarded – undo
1020 1020
         $schema = drupal_get_schema($table);
1021 1021
         $record = array();
1022 1022
         foreach ($schema['content fields'] as $field_name) {
1023
-          if (isset($node->$field_name)) {
1023
+            if (isset($node->$field_name)) {
1024 1024
             $field = content_fields($field_name, $type_name);
1025 1025
             // Multiple fields need specific handling, we'll deal with them later on.
1026 1026
             if ($field['multiple']) {
1027
-              continue;
1027
+                continue;
1028 1028
             }
1029 1029
             $db_info = content_database_info($field);
1030 1030
             foreach ($db_info['columns'] as $column => $attributes) {
1031
-              $record[$attributes['column']] = $node->{$field_name}[0][$column];
1031
+                $record[$attributes['column']] = $node->{$field_name}[0][$column];
1032
+            }
1032 1033
             }
1033
-          }
1034 1034
         }
1035 1035
         // $record might be empty because
1036 1036
         // - the table stores a multiple field :
@@ -1038,59 +1038,59 @@  discard block
 block discarded – undo
1038 1038
         // - this is the per-type table and no field is actually stored in it :
1039 1039
         //   we still store the nid and vid
1040 1040
         if (count($record) || empty($schema['content fields'])) {
1041
-          $record['nid'] = $node->nid;
1042
-          $record['vid'] = $node->vid;
1043
-          // Can't rely on the insert/update op of the node to decide if this
1044
-          // is an insert or an update, a node or revision may have existed
1045
-          // before any fields were created, so there may not be an entry here.
1046
-
1047
-          // TODO - should we auto create an entry for all existing nodes when
1048
-          // fields are added to content types -- either a NULL value
1049
-          // or the default value? May need to offer the user an option of
1050
-          // how to handle that.
1051
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1041
+            $record['nid'] = $node->nid;
1042
+            $record['vid'] = $node->vid;
1043
+            // Can't rely on the insert/update op of the node to decide if this
1044
+            // is an insert or an update, a node or revision may have existed
1045
+            // before any fields were created, so there may not be an entry here.
1046
+
1047
+            // TODO - should we auto create an entry for all existing nodes when
1048
+            // fields are added to content types -- either a NULL value
1049
+            // or the default value? May need to offer the user an option of
1050
+            // how to handle that.
1051
+            if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1052 1052
             content_write_record($table, $record, array('vid'));
1053
-          }
1054
-          else {
1053
+            }
1054
+            else {
1055 1055
             content_write_record($table, $record);
1056
-          }
1056
+            }
1057
+        }
1057 1058
         }
1058
-      }
1059 1059
 
1060
-      // Handle multiple fields.
1061
-      foreach ($type['fields'] as $field) {
1060
+        // Handle multiple fields.
1061
+        foreach ($type['fields'] as $field) {
1062 1062
         if ($field['multiple'] && isset($node->$field['field_name'])) {
1063
-          $db_info = content_database_info($field);
1064
-          // Delete and insert, rather than update, in case a value was added.
1065
-          if ($op == 'update') {
1063
+            $db_info = content_database_info($field);
1064
+            // Delete and insert, rather than update, in case a value was added.
1065
+            if ($op == 'update') {
1066 1066
             db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
1067
-          }
1068
-          foreach ($node->$field['field_name'] as $delta => $item) {
1067
+            }
1068
+            foreach ($node->$field['field_name'] as $delta => $item) {
1069 1069
             $record = array();
1070 1070
             foreach ($db_info['columns'] as $column => $attributes) {
1071
-              $record[$attributes['column']] = $item[$column];
1071
+                $record[$attributes['column']] = $item[$column];
1072 1072
             }
1073 1073
             $record['nid'] = $node->nid;
1074 1074
             $record['vid'] = $node->vid;
1075 1075
             $record['delta'] = $delta;
1076 1076
             content_write_record($db_info['table'], $record);
1077
-          }
1077
+            }
1078 1078
         }
1079
-      }
1080
-      break;
1079
+        }
1080
+        break;
1081 1081
 
1082 1082
     case 'delete':
1083 1083
       foreach ($type['tables'] as $table) {
1084 1084
         db_query('DELETE FROM {'. $table .'} WHERE nid = %d', $node->nid);
1085
-      }
1086
-      break;
1085
+        }
1086
+        break;
1087 1087
 
1088 1088
     case 'delete revision':
1089 1089
       foreach ($type['tables'] as $table) {
1090 1090
         db_query('DELETE FROM {'. $table .'} WHERE vid = %d', $node->vid);
1091
-      }
1092
-      break;
1093
-  }
1091
+        }
1092
+        break;
1093
+    }
1094 1094
 }
1095 1095
 
1096 1096
 /**
@@ -1125,108 +1125,108 @@  discard block
 block discarded – undo
1125 1125
  *   a new node.
1126 1126
  */
1127 1127
 function content_write_record($table, &$object, $update = array()) {
1128
-  // Standardize $update to an array.
1129
-  if (is_string($update)) {
1128
+    // Standardize $update to an array.
1129
+    if (is_string($update)) {
1130 1130
     $update = array($update);
1131
-  }
1131
+    }
1132 1132
 
1133
-  // Convert to an object if needed.
1134
-  if (is_array($object)) {
1133
+    // Convert to an object if needed.
1134
+    if (is_array($object)) {
1135 1135
     $object = (object) $object;
1136 1136
     $array = TRUE;
1137
-  }
1138
-  else {
1137
+    }
1138
+    else {
1139 1139
     $array = FALSE;
1140
-  }
1140
+    }
1141 1141
 
1142
-  $schema = drupal_get_schema($table);
1143
-  if (empty($schema)) {
1142
+    $schema = drupal_get_schema($table);
1143
+    if (empty($schema)) {
1144 1144
     return FALSE;
1145
-  }
1145
+    }
1146 1146
 
1147
-  $fields = $defs = $values = $serials = $placeholders = array();
1147
+    $fields = $defs = $values = $serials = $placeholders = array();
1148 1148
 
1149
-  // Go through our schema, build SQL, and when inserting, fill in defaults for
1150
-  // fields that are not set.
1151
-  foreach ($schema['fields'] as $field => $info) {
1149
+    // Go through our schema, build SQL, and when inserting, fill in defaults for
1150
+    // fields that are not set.
1151
+    foreach ($schema['fields'] as $field => $info) {
1152 1152
     // Special case -- skip serial types if we are updating.
1153 1153
     if ($info['type'] == 'serial' && count($update)) {
1154
-      continue;
1154
+        continue;
1155 1155
     }
1156 1156
 
1157 1157
     // For inserts, populate defaults from Schema if not already provided
1158 1158
     if (!isset($object->$field) && !count($update) && isset($info['default'])) {
1159
-      $object->$field = $info['default'];
1159
+        $object->$field = $info['default'];
1160 1160
     }
1161 1161
 
1162 1162
     // Track serial fields so we can helpfully populate them after the query.
1163 1163
     if ($info['type'] == 'serial') {
1164
-      $serials[] = $field;
1165
-      // Ignore values for serials when inserting data. Unsupported.
1166
-      unset($object->$field);
1164
+        $serials[] = $field;
1165
+        // Ignore values for serials when inserting data. Unsupported.
1166
+        unset($object->$field);
1167 1167
     }
1168 1168
 
1169 1169
     // Build arrays for the fields, placeholders, and values in our query.
1170 1170
     if (isset($object->$field) || array_key_exists($field, $object)) {
1171
-      $fields[] = $field;
1172
-      if (isset($object->$field)) {
1171
+        $fields[] = $field;
1172
+        if (isset($object->$field)) {
1173 1173
         $placeholders[] = db_type_placeholder($info['type']);
1174 1174
 
1175 1175
         if (empty($info['serialize'])) {
1176
-          $values[] = $object->$field;
1176
+            $values[] = $object->$field;
1177 1177
         }
1178 1178
         else {
1179
-          $values[] = serialize($object->$field);
1179
+            $values[] = serialize($object->$field);
1180
+        }
1180 1181
         }
1181
-      }
1182
-      else {
1182
+        else {
1183 1183
         $placeholders[] = 'NULL';
1184
-      }
1184
+        }
1185
+    }
1185 1186
     }
1186
-  }
1187 1187
 
1188
-  // Build the SQL.
1189
-  $query = '';
1190
-  if (!count($update)) {
1188
+    // Build the SQL.
1189
+    $query = '';
1190
+    if (!count($update)) {
1191 1191
     $query = "INSERT INTO {". $table ."} (". implode(', ', $fields) .') VALUES ('. implode(', ', $placeholders) .')';
1192 1192
     $return = SAVED_NEW;
1193
-  }
1194
-  else {
1193
+    }
1194
+    else {
1195 1195
     $query = '';
1196 1196
     foreach ($fields as $id => $field) {
1197
-      if ($query) {
1197
+        if ($query) {
1198 1198
         $query .= ', ';
1199
-      }
1200
-      $query .= $field .' = '. $placeholders[$id];
1199
+        }
1200
+        $query .= $field .' = '. $placeholders[$id];
1201 1201
     }
1202 1202
 
1203 1203
     foreach ($update as $key) {
1204
-      $conditions[] = "$key = ". db_type_placeholder($schema['fields'][$key]['type']);
1205
-      $values[] = $object->$key;
1204
+        $conditions[] = "$key = ". db_type_placeholder($schema['fields'][$key]['type']);
1205
+        $values[] = $object->$key;
1206 1206
     }
1207 1207
 
1208 1208
     $query = "UPDATE {". $table ."} SET $query WHERE ". implode(' AND ', $conditions);
1209 1209
     $return = SAVED_UPDATED;
1210
-  }
1210
+    }
1211 1211
 
1212
-  // Execute the SQL.
1213
-  if (db_query($query, $values)) {
1212
+    // Execute the SQL.
1213
+    if (db_query($query, $values)) {
1214 1214
     if ($serials) {
1215
-      // Get last insert ids and fill them in.
1216
-      foreach ($serials as $field) {
1215
+        // Get last insert ids and fill them in.
1216
+        foreach ($serials as $field) {
1217 1217
         $object->$field = db_last_insert_id($table, $field);
1218
-      }
1218
+        }
1219 1219
     }
1220 1220
 
1221 1221
     // If we began with an array, convert back so we don't surprise the caller.
1222 1222
     if ($array) {
1223
-      $object = (array) $object;
1223
+        $object = (array) $object;
1224 1224
     }
1225 1225
 
1226 1226
     return $return;
1227
-  }
1227
+    }
1228 1228
 
1229
-  return FALSE;
1229
+    return FALSE;
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1236,12 +1236,12 @@  discard block
 block discarded – undo
1236 1236
  * called so that the default database handling can occur.
1237 1237
  */
1238 1238
 function _content_field_invoke($op, &$node, $teaser = NULL, $page = NULL) {
1239
-  $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1240
-  $type = content_types($type_name);
1241
-  $field_types = _content_field_types();
1239
+    $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1240
+    $type = content_types($type_name);
1241
+    $field_types = _content_field_types();
1242 1242
 
1243
-  $return = array();
1244
-  foreach ($type['fields'] as $field) {
1243
+    $return = array();
1244
+    foreach ($type['fields'] as $field) {
1245 1245
     $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1246 1246
 
1247 1247
     // Make sure AHAH 'add more' button isn't sent to the fields for processing.
@@ -1250,52 +1250,52 @@  discard block
 block discarded – undo
1250 1250
     $module = $field_types[$field['type']]['module'];
1251 1251
     $function = $module .'_field';
1252 1252
     if (function_exists($function)) {
1253
-      $result = $function($op, $node, $field, $items, $teaser, $page);
1254
-      if (is_array($result)) {
1253
+        $result = $function($op, $node, $field, $items, $teaser, $page);
1254
+        if (is_array($result)) {
1255 1255
         $return = array_merge($return, $result);
1256
-      }
1257
-      else if (isset($result)) {
1256
+        }
1257
+        else if (isset($result)) {
1258 1258
         $return[] = $result;
1259
-      }
1259
+        }
1260 1260
     }
1261 1261
     // test for values in $items in case modules added items on insert
1262 1262
     if (isset($node->$field['field_name']) || count($items)) {
1263
-      $node->$field['field_name'] = $items;
1263
+        $node->$field['field_name'] = $items;
1264
+    }
1264 1265
     }
1265
-  }
1266
-  return $return;
1266
+    return $return;
1267 1267
 }
1268 1268
 
1269 1269
 /**
1270 1270
  * Invoke content.module's version of a field hook.
1271 1271
  */
1272 1272
 function _content_field_invoke_default($op, &$node, $teaser = NULL, $page = NULL) {
1273
-  $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1274
-  $type = content_types($type_name);
1275
-  $field_types = _content_field_types();
1276
-
1277
-  $return = array();
1278
-  // The operations involving database queries are better off handled by table
1279
-  // rather than by field.
1280
-  if (in_array($op, array('load', 'insert', 'update', 'delete', 'delete revision'))) {
1273
+    $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1274
+    $type = content_types($type_name);
1275
+    $field_types = _content_field_types();
1276
+
1277
+    $return = array();
1278
+    // The operations involving database queries are better off handled by table
1279
+    // rather than by field.
1280
+    if (in_array($op, array('load', 'insert', 'update', 'delete', 'delete revision'))) {
1281 1281
     return content_storage($op, $node);
1282
-  }
1283
-  else {
1282
+    }
1283
+    else {
1284 1284
     foreach ($type['fields'] as $field) {
1285
-      $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1286
-      $result = content_field($op, $node, $field, $items, $teaser, $page);
1287
-      if (is_array($result)) {
1285
+        $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1286
+        $result = content_field($op, $node, $field, $items, $teaser, $page);
1287
+        if (is_array($result)) {
1288 1288
         $return = array_merge($return, $result);
1289
-      }
1290
-      else if (isset($result)) {
1289
+        }
1290
+        else if (isset($result)) {
1291 1291
         $return[] = $result;
1292
-      }
1293
-      if (isset($node->$field['field_name'])) {
1292
+        }
1293
+        if (isset($node->$field['field_name'])) {
1294 1294
         $node->$field['field_name'] = $items;
1295
-      }
1295
+        }
1296
+    }
1296 1297
     }
1297
-  }
1298
-  return $return;
1298
+    return $return;
1299 1299
 }
1300 1300
 
1301 1301
 /**
@@ -1308,19 +1308,19 @@  discard block
 block discarded – undo
1308 1308
  * info to avoid foreach errors elsewhere in the code.
1309 1309
  */
1310 1310
 function content_types($type_name = NULL) {
1311
-  // handle type name with either an underscore or a dash
1312
-  $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : NULL;
1311
+    // handle type name with either an underscore or a dash
1312
+    $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : NULL;
1313 1313
 
1314
-  $info = _content_type_info();
1315
-  if (isset($info['content types'])) {
1314
+    $info = _content_type_info();
1315
+    if (isset($info['content types'])) {
1316 1316
     if (!isset($type_name)) {
1317
-      return $info['content types'];
1317
+        return $info['content types'];
1318 1318
     }
1319 1319
     if (isset($info['content types'][$type_name])) {
1320
-      return $info['content types'][$type_name];
1320
+        return $info['content types'][$type_name];
1321
+    }
1321 1322
     }
1322
-  }
1323
-  return array('tables' => array(), 'fields' => array(), 'extra' => array());
1323
+    return array('tables' => array(), 'fields' => array(), 'extra' => array());
1324 1324
 }
1325 1325
 
1326 1326
 /**
@@ -1337,36 +1337,36 @@  discard block
 block discarded – undo
1337 1337
  * but empty, as sometimes happens in the formatter.
1338 1338
  */
1339 1339
 function content_fields($field_name = NULL, $content_type_name = NULL) {
1340
-  $info = _content_type_info();
1341
-  if (isset($info['fields'])) {
1340
+    $info = _content_type_info();
1341
+    if (isset($info['fields'])) {
1342 1342
     if (empty($field_name)) {
1343
-      return $info['fields'];
1343
+        return $info['fields'];
1344 1344
     }
1345 1345
     if (isset($info['fields'][$field_name])) {
1346
-      if (empty($content_type_name)) {
1346
+        if (empty($content_type_name)) {
1347 1347
         return $info['fields'][$field_name];
1348
-      }
1349
-      if (isset($info['content types'][$content_type_name]['fields'][$field_name])) {
1348
+        }
1349
+        if (isset($info['content types'][$content_type_name]['fields'][$field_name])) {
1350 1350
         return $info['content types'][$content_type_name]['fields'][$field_name];
1351
-      }
1351
+        }
1352
+    }
1352 1353
     }
1353
-  }
1354 1354
 }
1355 1355
 
1356 1356
 /**
1357 1357
  * Return a list of field types.
1358 1358
  */
1359 1359
 function _content_field_types() {
1360
-  $info = _content_type_info();
1361
-  return isset($info['field types']) ? $info['field types'] : array();
1360
+    $info = _content_type_info();
1361
+    return isset($info['field types']) ? $info['field types'] : array();
1362 1362
 }
1363 1363
 
1364 1364
 /**
1365 1365
  * Return a list of widget types.
1366 1366
  */
1367 1367
 function _content_widget_types() {
1368
-  $info = _content_type_info();
1369
-  return isset($info['widget types']) ? $info['widget types'] : array();
1368
+    $info = _content_type_info();
1369
+    return isset($info['widget types']) ? $info['widget types'] : array();
1370 1370
 }
1371 1371
 
1372 1372
 /**
@@ -1374,16 +1374,16 @@  discard block
 block discarded – undo
1374 1374
  * defaulting to 'default' if none is found.
1375 1375
  */
1376 1376
 function _content_get_formatter($formatter_name, $field_type) {
1377
-  $field_types = _content_field_types();
1378
-  $formatters = $field_types[$field_type]['formatters'];
1377
+    $field_types = _content_field_types();
1378
+    $formatters = $field_types[$field_type]['formatters'];
1379 1379
 
1380
-  if (!isset($formatters[$formatter_name]) && $formatter_name != 'hidden') {
1380
+    if (!isset($formatters[$formatter_name]) && $formatter_name != 'hidden') {
1381 1381
     // This might happen when the selected formatter has been renamed in the
1382 1382
     // module, or if the module has been disabled since then.
1383 1383
     $formatter_name = 'default';
1384
-  }
1384
+    }
1385 1385
 
1386
-  return isset($formatters[$formatter_name]) ? $formatters[$formatter_name] : FALSE;
1386
+    return isset($formatters[$formatter_name]) ? $formatters[$formatter_name] : FALSE;
1387 1387
 }
1388 1388
 
1389 1389
 /**
@@ -1393,10 +1393,10 @@  discard block
 block discarded – undo
1393 1393
  *   If TRUE, clear the cache and fetch the information from the database again.
1394 1394
  */
1395 1395
 function _content_type_info($reset = FALSE) {
1396
-  global $language;
1397
-  static $info;
1396
+    global $language;
1397
+    static $info;
1398 1398
 
1399
-  if ($reset || !isset($info)) {
1399
+    if ($reset || !isset($info)) {
1400 1400
     // Make sure this function doesn't run until the tables have been created,
1401 1401
     // For instance: when first enabled and called from content_menu(),
1402 1402
     // or when uninstalled and some subsequent field module uninstall
@@ -1405,38 +1405,38 @@  discard block
 block discarded – undo
1405 1405
     // Don't try this before content module's update is run
1406 1406
     // to add module and active columns to the table.
1407 1407
     if (variable_get('content_schema_version', -1) < 6007) {
1408
-      return array();
1408
+        return array();
1409 1409
     }
1410 1410
 
1411 1411
     if (!$reset && $cached = cache_get('content_type_info:'. $language->language, content_cache_tablename())) {
1412
-      $info = $cached->data;
1412
+        $info = $cached->data;
1413 1413
     }
1414 1414
     else {
1415
-      $info = array(
1415
+        $info = array(
1416 1416
         'field types' => array(),
1417 1417
         'widget types' => array(),
1418 1418
         'fields' => array(),
1419 1419
         'content types' => array(),
1420
-      );
1420
+        );
1421 1421
 
1422
-      // Populate field types.
1423
-      foreach (module_list() as $module) {
1422
+        // Populate field types.
1423
+        foreach (module_list() as $module) {
1424 1424
         $module_field_types = module_invoke($module, 'field_info');
1425 1425
         if ($module_field_types) {
1426
-          foreach ($module_field_types as $name => $field_info) {
1426
+            foreach ($module_field_types as $name => $field_info) {
1427 1427
             // Truncate names to match the value that is stored in the database.
1428 1428
             $db_name = substr($name, 0, 32);
1429 1429
             $info['field types'][$db_name] = $field_info;
1430 1430
             $info['field types'][$db_name]['module'] = $module;
1431 1431
             $info['field types'][$db_name]['formatters'] = array();
1432
-          }
1432
+            }
1433
+        }
1433 1434
         }
1434
-      }
1435 1435
 
1436
-      // Populate widget types and formatters for known field types.
1437
-      foreach (module_list() as $module) {
1436
+        // Populate widget types and formatters for known field types.
1437
+        foreach (module_list() as $module) {
1438 1438
         if ($module_widgets = module_invoke($module, 'widget_info')) {
1439
-          foreach ($module_widgets as $name => $widget_info) {
1439
+            foreach ($module_widgets as $name => $widget_info) {
1440 1440
             // Truncate names to match the value that is stored in the database.
1441 1441
             $db_name = substr($name, 0, 32);
1442 1442
             $info['widget types'][$db_name] = $widget_info;
@@ -1444,44 +1444,44 @@  discard block
 block discarded – undo
1444 1444
             // Replace field types with db_compatible version of known field types.
1445 1445
             $info['widget types'][$db_name]['field types'] = array();
1446 1446
             foreach ($widget_info['field types'] as $field_type) {
1447
-              $field_type_db_name = substr($field_type, 0, 32);
1448
-              if (isset($info['field types'][$field_type_db_name])) {
1447
+                $field_type_db_name = substr($field_type, 0, 32);
1448
+                if (isset($info['field types'][$field_type_db_name])) {
1449 1449
                 $info['widget types'][$db_name]['field types'][] = $field_type_db_name;
1450
-              }
1450
+                }
1451
+            }
1451 1452
             }
1452
-          }
1453 1453
         }
1454 1454
 
1455 1455
         if ($module_formatters = module_invoke($module, 'field_formatter_info')) {
1456
-          foreach ($module_formatters as $name => $formatter_info) {
1456
+            foreach ($module_formatters as $name => $formatter_info) {
1457 1457
             foreach ($formatter_info['field types'] as $field_type) {
1458
-              // Truncate names to match the value that is stored in the database.
1459
-              $db_name = substr($field_type, 0, 32);
1460
-              if (isset($info['field types'][$db_name])) {
1458
+                // Truncate names to match the value that is stored in the database.
1459
+                $db_name = substr($field_type, 0, 32);
1460
+                if (isset($info['field types'][$db_name])) {
1461 1461
                 $info['field types'][$db_name]['formatters'][$name] = $formatter_info;
1462 1462
                 $info['field types'][$db_name]['formatters'][$name]['module'] = $module;
1463
-              }
1463
+                }
1464 1464
             }
1465
-          }
1465
+            }
1466
+        }
1466 1467
         }
1467
-      }
1468 1468
 
1469
-      // Populate actual field instances.
1470
-      module_load_include('inc', 'content', 'includes/content.crud');
1471
-      foreach (node_get_types('types', NULL, TRUE) as $type_name => $data) {
1469
+        // Populate actual field instances.
1470
+        module_load_include('inc', 'content', 'includes/content.crud');
1471
+        foreach (node_get_types('types', NULL, TRUE) as $type_name => $data) {
1472 1472
         $type = (array) $data;
1473 1473
         $type['url_str'] = str_replace('_', '-', $type['type']);
1474 1474
         $type['fields'] = array();
1475 1475
         $type['tables'] = array();
1476 1476
         if ($fields = content_field_instance_read(array('type_name' => $type_name))) {
1477
-          foreach ($fields as $field) {
1477
+            foreach ($fields as $field) {
1478 1478
             $db_info = content_database_info($field);
1479 1479
             $type['tables'][$db_info['table']] = $db_info['table'];
1480 1480
 
1481 1481
             // Allow external modules to translate field strings.
1482 1482
             $field_strings = array(
1483
-              'widget_label' => $field['widget']['label'],
1484
-              'widget_description' => $field['widget']['description'],
1483
+                'widget_label' => $field['widget']['label'],
1484
+                'widget_description' => $field['widget']['description'],
1485 1485
             );
1486 1486
             drupal_alter('content_field_strings', $field_strings, $field['type_name'], $field['field_name']);
1487 1487
             $field['widget']['label'] = $field_strings['widget_label'];
@@ -1491,11 +1491,11 @@  discard block
 block discarded – undo
1491 1491
             // This means that content_fields($field_name) (no type name)
1492 1492
             // returns the last instance loaded.
1493 1493
             $info['fields'][$field['field_name']] = $field;
1494
-          }
1495
-          // Make sure the per-type table is added, even if no field is actually
1496
-          // stored in it.
1497
-          $table = _content_tablename($type['type'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1498
-          $type['tables'][$table] = $table;
1494
+            }
1495
+            // Make sure the per-type table is added, even if no field is actually
1496
+            // stored in it.
1497
+            $table = _content_tablename($type['type'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1498
+            $type['tables'][$table] = $table;
1499 1499
         }
1500 1500
 
1501 1501
         // Gather information about non-CCK 'fields'.
@@ -1503,21 +1503,21 @@  discard block
 block discarded – undo
1503 1503
         drupal_alter('content_extra_fields', $extra, $type_name);
1504 1504
         // Add saved weights.
1505 1505
         foreach (variable_get('content_extra_weights_'. $type_name, array()) as $key => $value) {
1506
-          // Some stored entries might not exist anymore, for instance if uploads
1507
-          // have been disabled, or vocabularies removed...
1508
-          if (isset($extra[$key])) {
1506
+            // Some stored entries might not exist anymore, for instance if uploads
1507
+            // have been disabled, or vocabularies removed...
1508
+            if (isset($extra[$key])) {
1509 1509
             $extra[$key]['weight'] = $value;
1510
-          }
1510
+            }
1511 1511
         }
1512 1512
         $type['extra'] = $extra;
1513 1513
 
1514 1514
         $info['content types'][$type_name] = $type;
1515
-      }
1515
+        }
1516 1516
 
1517
-      cache_set('content_type_info:'. $language->language, $info, content_cache_tablename());
1517
+        cache_set('content_type_info:'. $language->language, $info, content_cache_tablename());
1518
+    }
1518 1519
     }
1519
-  }
1520
-  return $info;
1520
+    return $info;
1521 1521
 }
1522 1522
 
1523 1523
 /**
@@ -1525,20 +1525,20 @@  discard block
 block discarded – undo
1525 1525
  *  React to change in node types
1526 1526
  */
1527 1527
 function content_node_type($op, $info) {
1528
-  switch ($op) {
1528
+    switch ($op) {
1529 1529
     case 'insert':
1530 1530
       module_load_include('inc', 'content', 'includes/content.crud');
1531
-      content_type_create($info);
1532
-      break;
1531
+        content_type_create($info);
1532
+        break;
1533 1533
     case 'update':
1534 1534
       module_load_include('inc', 'content', 'includes/content.crud');
1535
-      content_type_update($info);
1536
-      break;
1535
+        content_type_update($info);
1536
+        break;
1537 1537
     case 'delete':
1538 1538
       module_load_include('inc', 'content', 'includes/content.crud');
1539
-      content_type_delete($info);
1540
-      break;
1541
-  }
1539
+        content_type_delete($info);
1540
+        break;
1541
+    }
1542 1542
 }
1543 1543
 
1544 1544
 /**
@@ -1546,19 +1546,19 @@  discard block
 block discarded – undo
1546 1546
  * information is changed.
1547 1547
  */
1548 1548
 function content_clear_type_cache($rebuild_schema = FALSE) {
1549
-  cache_clear_all('*', content_cache_tablename(), TRUE);
1550
-  _content_type_info(TRUE);
1549
+    cache_clear_all('*', content_cache_tablename(), TRUE);
1550
+    _content_type_info(TRUE);
1551 1551
 
1552
-  // Refresh the schema to pick up new information.
1553
-  if ($rebuild_schema) {
1552
+    // Refresh the schema to pick up new information.
1553
+    if ($rebuild_schema) {
1554 1554
     $schema = drupal_get_schema(NULL, TRUE);
1555
-  }
1555
+    }
1556 1556
 
1557
-  if (module_exists('views')) {
1557
+    if (module_exists('views')) {
1558 1558
     // Needed because this can be called from .install files
1559 1559
     module_load_include('module', 'views');
1560 1560
     views_invalidate_cache();
1561
-  }
1561
+    }
1562 1562
 }
1563 1563
 
1564 1564
 /**
@@ -1577,38 +1577,38 @@  discard block
 block discarded – undo
1577 1577
  *       database column that stores the data.
1578 1578
  */
1579 1579
 function content_database_info($field) {
1580
-  $db_info = array();
1581
-  if ($field['db_storage'] == CONTENT_DB_STORAGE_PER_FIELD) {
1580
+    $db_info = array();
1581
+    if ($field['db_storage'] == CONTENT_DB_STORAGE_PER_FIELD) {
1582 1582
     $db_info['table'] = _content_tablename($field['field_name'], CONTENT_DB_STORAGE_PER_FIELD);
1583
-  }
1584
-  else {
1583
+    }
1584
+    else {
1585 1585
     $db_info['table'] = _content_tablename($field['type_name'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1586
-  }
1586
+    }
1587 1587
 
1588
-  $db_info['columns'] = (array) $field['columns'];
1589
-  // Generate column names for this field from generic column names.
1590
-  foreach ($db_info['columns'] as $column_name => $attributes) {
1588
+    $db_info['columns'] = (array) $field['columns'];
1589
+    // Generate column names for this field from generic column names.
1590
+    foreach ($db_info['columns'] as $column_name => $attributes) {
1591 1591
     $db_info['columns'][$column_name]['column'] = $field['field_name'] .'_'. $column_name;
1592
-  }
1592
+    }
1593 1593
 
1594
-  return $db_info;
1594
+    return $db_info;
1595 1595
 }
1596 1596
 
1597 1597
 /**
1598 1598
  * Helper function for identifying the storage type for a field.
1599 1599
  */
1600 1600
 function content_storage_type($field) {
1601
-  if ($field['multiple'] > 0) {
1601
+    if ($field['multiple'] > 0) {
1602 1602
     return CONTENT_DB_STORAGE_PER_FIELD;
1603
-  }
1604
-  else {
1603
+    }
1604
+    else {
1605 1605
     module_load_include('inc', 'content', 'includes/content.crud');
1606 1606
     $instances = content_field_instance_read(array('field_name' => $field['field_name']));
1607 1607
     if (count($instances) > 1) {
1608
-      return CONTENT_DB_STORAGE_PER_FIELD;
1608
+        return CONTENT_DB_STORAGE_PER_FIELD;
1609
+    }
1609 1610
     }
1610
-  }
1611
-  return CONTENT_DB_STORAGE_PER_CONTENT_TYPE;
1611
+    return CONTENT_DB_STORAGE_PER_CONTENT_TYPE;
1612 1612
 }
1613 1613
 
1614 1614
 /**
@@ -1625,20 +1625,20 @@  discard block
 block discarded – undo
1625 1625
  *   The transposed array.
1626 1626
  */
1627 1627
 function content_transpose_array_rows_cols($array) {
1628
-  $result = array();
1629
-  if (is_array($array)) {
1628
+    $result = array();
1629
+    if (is_array($array)) {
1630 1630
     foreach ($array as $key1 => $value1) {
1631
-      if (is_array($value1)) {
1631
+        if (is_array($value1)) {
1632 1632
         foreach ($value1 as $key2 => $value2) {
1633
-          if (!isset($result[$key2])) {
1633
+            if (!isset($result[$key2])) {
1634 1634
             $result[$key2] = array();
1635
-          }
1636
-          $result[$key2][$key1] = $value2;
1635
+            }
1636
+            $result[$key2][$key1] = $value2;
1637 1637
         }
1638
-      }
1638
+        }
1639
+    }
1639 1640
     }
1640
-  }
1641
-  return $result;
1641
+    return $result;
1642 1642
 }
1643 1643
 
1644 1644
 /**
@@ -1650,18 +1650,18 @@  discard block
 block discarded – undo
1650 1650
  *   A flattened array.
1651 1651
  */
1652 1652
 function content_array_flatten($array) {
1653
-  $result = array();
1654
-  if (is_array($array)) {
1653
+    $result = array();
1654
+    if (is_array($array)) {
1655 1655
     foreach ($array as $key => $value) {
1656
-      if (is_array($value)) {
1656
+        if (is_array($value)) {
1657 1657
         $result += content_array_flatten($value);
1658
-      }
1659
-      else {
1658
+        }
1659
+        else {
1660 1660
         $result[$key] = $value;
1661
-      }
1661
+        }
1662
+    }
1662 1663
     }
1663
-  }
1664
-  return $result;
1664
+    return $result;
1665 1665
 }
1666 1666
 
1667 1667
 /**
@@ -1680,46 +1680,46 @@  discard block
 block discarded – undo
1680 1680
  *   when allowed values list is generated using PHP code.
1681 1681
  */
1682 1682
 function content_allowed_values($field, $flatten = TRUE) {
1683
-  static $allowed_values;
1683
+    static $allowed_values;
1684 1684
 
1685
-  $cid = $field['field_name'] .':'. ($flatten ? '1' : '0');
1686
-  if (isset($allowed_values[$cid])) {
1685
+    $cid = $field['field_name'] .':'. ($flatten ? '1' : '0');
1686
+    if (isset($allowed_values[$cid])) {
1687 1687
     return $allowed_values[$cid];
1688
-  }
1688
+    }
1689 1689
 
1690
-  $allowed_values[$cid] = array();
1690
+    $allowed_values[$cid] = array();
1691 1691
 
1692
-  if (isset($field['allowed_values_php'])) {
1692
+    if (isset($field['allowed_values_php'])) {
1693 1693
     ob_start();
1694 1694
     $result = eval($field['allowed_values_php']);
1695 1695
     if (is_array($result)) {
1696
-      if ($flatten) {
1696
+        if ($flatten) {
1697 1697
         $result = content_array_flatten($result);
1698
-      }
1699
-      $allowed_values[$cid] = $result;
1698
+        }
1699
+        $allowed_values[$cid] = $result;
1700 1700
     }
1701 1701
     ob_end_clean();
1702
-  }
1702
+    }
1703 1703
 
1704
-  if (empty($allowed_values[$cid]) && isset($field['allowed_values'])) {
1704
+    if (empty($allowed_values[$cid]) && isset($field['allowed_values'])) {
1705 1705
     $list = explode("\n", $field['allowed_values']);
1706 1706
     $list = array_map('trim', $list);
1707 1707
     $list = array_filter($list, 'strlen');
1708 1708
     foreach ($list as $opt) {
1709
-      // Sanitize the user input with a permissive filter.
1710
-      $opt = content_filter_xss($opt);
1711
-      if (strpos($opt, '|') !== FALSE) {
1709
+        // Sanitize the user input with a permissive filter.
1710
+        $opt = content_filter_xss($opt);
1711
+        if (strpos($opt, '|') !== FALSE) {
1712 1712
         list($key, $value) = explode('|', $opt);
1713 1713
         $allowed_values[$cid][$key] = (isset($value) && $value !=='') ? $value : $key;
1714
-      }
1715
-      else {
1714
+        }
1715
+        else {
1716 1716
         $allowed_values[$cid][$opt] = $opt;
1717
-      }
1717
+        }
1718 1718
     }
1719 1719
     // Allow external modules to translate allowed values list.
1720 1720
     drupal_alter('content_allowed_values', $allowed_values[$cid], $field);
1721
-  }
1722
-  return $allowed_values[$cid];
1721
+    }
1722
+    return $allowed_values[$cid];
1723 1723
 }
1724 1724
 
1725 1725
 /**
@@ -1730,14 +1730,14 @@  discard block
 block discarded – undo
1730 1730
  * @see content_handler_filter_many_to_one::allowed_values()
1731 1731
  */
1732 1732
 function content_allowed_values_filter_html(&$options) {
1733
-  foreach ($options as $key => $opt) {
1733
+    foreach ($options as $key => $opt) {
1734 1734
     if (is_array($opt)) {
1735
-      content_allowed_values_filter_html($options[$key]);
1735
+        content_allowed_values_filter_html($options[$key]);
1736 1736
     }
1737 1737
     else {
1738
-      $options[$key] = html_entity_decode(strip_tags($opt), ENT_QUOTES);
1738
+        $options[$key] = html_entity_decode(strip_tags($opt), ENT_QUOTES);
1739
+    }
1739 1740
     }
1740
-  }
1741 1741
 }
1742 1742
 
1743 1743
 /**
@@ -1748,21 +1748,21 @@  discard block
 block discarded – undo
1748 1748
  * (so check_plain() is not acceptable).
1749 1749
  */
1750 1750
 function content_filter_xss($string) {
1751
-  return filter_xss($string, _content_filter_xss_allowed_tags());
1751
+    return filter_xss($string, _content_filter_xss_allowed_tags());
1752 1752
 }
1753 1753
 
1754 1754
 /**
1755 1755
  * List of tags allowed by content_filter_xss().
1756 1756
  */
1757 1757
 function _content_filter_xss_allowed_tags() {
1758
-  return array('a', 'b', 'big',  'code', 'del', 'em', 'i', 'ins',  'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img');
1758
+    return array('a', 'b', 'big',  'code', 'del', 'em', 'i', 'ins',  'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img');
1759 1759
 }
1760 1760
 
1761 1761
 /**
1762 1762
  * Human-readable list of allowed tags, for display in help texts.
1763 1763
  */
1764 1764
 function _content_filter_xss_display_allowed_tags() {
1765
-  return '<'. implode('> <', _content_filter_xss_allowed_tags()) .'>';
1765
+    return '<'. implode('> <', _content_filter_xss_allowed_tags()) .'>';
1766 1766
 }
1767 1767
 
1768 1768
 /**
@@ -1790,52 +1790,52 @@  discard block
 block discarded – undo
1790 1790
  *   functions as necessary.
1791 1791
  */
1792 1792
 function content_format($field, $item, $formatter_name = 'default', $node = NULL) {
1793
-  if (!is_array($field)) {
1793
+    if (!is_array($field)) {
1794 1794
     $field = content_fields($field);
1795
-  }
1795
+    }
1796 1796
 
1797
-  if (content_access('view', $field, NULL, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1797
+    if (content_access('view', $field, NULL, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1798 1798
     $theme = $formatter['module'] .'_formatter_'. $formatter_name;
1799 1799
 
1800 1800
     $element = array(
1801
-      '#theme' => $theme,
1802
-      '#field_name' => $field['field_name'],
1803
-      '#type_name' => isset($node->type) ? $node->type :'',
1804
-      '#formatter' => $formatter_name,
1805
-      '#node' => $node,
1806
-      '#delta' => isset($item['#delta']) ? $item['#delta'] : NULL,
1801
+        '#theme' => $theme,
1802
+        '#field_name' => $field['field_name'],
1803
+        '#type_name' => isset($node->type) ? $node->type :'',
1804
+        '#formatter' => $formatter_name,
1805
+        '#node' => $node,
1806
+        '#delta' => isset($item['#delta']) ? $item['#delta'] : NULL,
1807 1807
     );
1808 1808
 
1809 1809
     if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) {
1810
-      // Single value formatter.
1810
+        // Single value formatter.
1811 1811
 
1812
-      // hook_field('sanitize') expects an array of items, so we build one.
1813
-      $items = array($item);
1814
-      $function = $field['module'] .'_field';
1815
-      if (function_exists($function)) {
1812
+        // hook_field('sanitize') expects an array of items, so we build one.
1813
+        $items = array($item);
1814
+        $function = $field['module'] .'_field';
1815
+        if (function_exists($function)) {
1816 1816
         $function('sanitize', $node, $field, $items, FALSE, FALSE);
1817
-      }
1817
+        }
1818 1818
 
1819
-      $element['#item'] = $items[0];
1819
+        $element['#item'] = $items[0];
1820 1820
     }
1821 1821
     else {
1822
-      // Multiple values formatter.
1823
-      $items = $item;
1824
-      $function = $field['module'] .'_field';
1825
-      if (function_exists($function)) {
1822
+        // Multiple values formatter.
1823
+        $items = $item;
1824
+        $function = $field['module'] .'_field';
1825
+        if (function_exists($function)) {
1826 1826
         $function('sanitize', $node, $field, $items, FALSE, FALSE);
1827
-      }
1827
+        }
1828 1828
 
1829
-      foreach ($items as $delta => $item) {
1829
+        foreach ($items as $delta => $item) {
1830 1830
         $element[$delta] = array(
1831
-          '#item' => $item,
1832
-          '#weight' => $delta,
1831
+            '#item' => $item,
1832
+            '#weight' => $delta,
1833 1833
         );
1834
-      }
1834
+        }
1835 1835
     }
1836 1836
 
1837 1837
     return theme($theme, $element);
1838
-  }
1838
+    }
1839 1839
 }
1840 1840
 
1841 1841
 /**
@@ -1851,31 +1851,31 @@  discard block
 block discarded – undo
1851 1851
  *   - a string tab id: the build modes in this tab.
1852 1852
  */
1853 1853
 function content_build_modes($selector = NULL) {
1854
-  static $info;
1854
+    static $info;
1855 1855
 
1856
-  if (!isset($info)) {
1856
+    if (!isset($info)) {
1857 1857
     $data = array();
1858 1858
     foreach (module_implements('content_build_modes') as $module) {
1859
-      $function = $module .'_content_build_modes';
1860
-      $data = array_merge($data, (array) $function());
1859
+        $function = $module .'_content_build_modes';
1860
+        $data = array_merge($data, (array) $function());
1861 1861
     }
1862 1862
     $flat = array();
1863 1863
     foreach ($data as $tab) {
1864
-      // Use the + operator to preserve numeric indexes (core build modes).
1865
-      $flat += (array) $tab['build modes'];
1864
+        // Use the + operator to preserve numeric indexes (core build modes).
1865
+        $flat += (array) $tab['build modes'];
1866 1866
     }
1867 1867
     $info = array('tabs' => $data, 'build modes' => $flat);
1868
-  }
1868
+    }
1869 1869
 
1870
-  if ($selector === '_tabs') {
1870
+    if ($selector === '_tabs') {
1871 1871
     return $info['tabs'];
1872
-  }
1873
-  elseif (isset($selector) && isset($info['tabs'][$selector])) {
1872
+    }
1873
+    elseif (isset($selector) && isset($info['tabs'][$selector])) {
1874 1874
     return isset($info['tabs'][$selector]) ? $info['tabs'][$selector]['build modes'] : array();
1875
-  }
1876
-  else {
1875
+    }
1876
+    else {
1877 1877
     return $info['build modes'];
1878
-  }
1878
+    }
1879 1879
 }
1880 1880
 
1881 1881
 /**
@@ -1914,60 +1914,60 @@  discard block
 block discarded – undo
1914 1914
  * );
1915 1915
  */
1916 1916
 function node_content_build_modes() {
1917
-  return array(
1917
+    return array(
1918 1918
     'basic' => array(
1919
-      'title' => t('Basic'),
1920
-      'build modes' => array(
1919
+        'title' => t('Basic'),
1920
+        'build modes' => array(
1921 1921
         'teaser' => array(
1922
-          'title' => t('Teaser'),
1923
-          'views style' => TRUE,
1922
+            'title' => t('Teaser'),
1923
+            'views style' => TRUE,
1924 1924
         ),
1925 1925
         'full' => array(
1926
-          'title' => t('Full node'),
1927
-          'views style' => TRUE,
1926
+            'title' => t('Full node'),
1927
+            'views style' => TRUE,
1928
+        ),
1928 1929
         ),
1929
-      ),
1930 1930
     ),
1931 1931
     'rss' => array(
1932
-      'title' => t('RSS'),
1933
-      'build modes' => array(
1932
+        'title' => t('RSS'),
1933
+        'build modes' => array(
1934 1934
         NODE_BUILD_RSS => array(
1935
-          'title' => t('RSS'),
1936
-          'views style' => FALSE,
1935
+            'title' => t('RSS'),
1936
+            'views style' => FALSE,
1937
+        ),
1937 1938
         ),
1938
-      ),
1939 1939
     ),
1940
-  );
1940
+    );
1941 1941
 }
1942 1942
 function search_content_build_modes() {
1943
-  return array(
1943
+    return array(
1944 1944
     'search' => array(
1945
-      'title' => t('Search'),
1946
-      'build modes' => array(
1945
+        'title' => t('Search'),
1946
+        'build modes' => array(
1947 1947
         NODE_BUILD_SEARCH_INDEX => array(
1948
-          'title' => t('Search Index'),
1949
-          'views style' => FALSE,
1948
+            'title' => t('Search Index'),
1949
+            'views style' => FALSE,
1950 1950
         ),
1951 1951
         NODE_BUILD_SEARCH_RESULT => array(
1952
-          'title' => t('Search Result'),
1953
-          'views style' => FALSE,
1952
+            'title' => t('Search Result'),
1953
+            'views style' => FALSE,
1954
+        ),
1954 1955
         ),
1955
-      ),
1956 1956
     ),
1957
-  );
1957
+    );
1958 1958
 }
1959 1959
 function book_content_build_modes() {
1960
-  return array(
1960
+    return array(
1961 1961
     'print' => array(
1962
-      'title' => t('Print'),
1963
-      'build modes' => array(
1962
+        'title' => t('Print'),
1963
+        'build modes' => array(
1964 1964
         NODE_BUILD_PRINT => array(
1965
-          'title' => t('Print'),
1966
-          'views style' => TRUE,
1965
+            'title' => t('Print'),
1966
+            'views style' => TRUE,
1967
+        ),
1967 1968
         ),
1968
-      ),
1969 1969
     ),
1970
-  );
1970
+    );
1971 1971
 }
1972 1972
 
1973 1973
 /**
@@ -1981,19 +1981,19 @@  discard block
 block discarded – undo
1981 1981
  *   A string containing the generated name for the database table
1982 1982
  */
1983 1983
 function _content_tablename($name, $storage, $version = NULL) {
1984
-  if (is_null($version)) {
1984
+    if (is_null($version)) {
1985 1985
     $version = variable_get('content_schema_version', 0);
1986
-  }
1986
+    }
1987 1987
 
1988
-  if ($version < 1003) {
1988
+    if ($version < 1003) {
1989 1989
     $version = 0;
1990
-  }
1991
-  else {
1990
+    }
1991
+    else {
1992 1992
     $version = 1003;
1993
-  }
1993
+    }
1994 1994
 
1995
-  $name = str_replace('-', '_', $name);
1996
-  switch ("$version-$storage") {
1995
+    $name = str_replace('-', '_', $name);
1996
+    switch ("$version-$storage") {
1997 1997
     case '0-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1998 1998
       return "node_$name";
1999 1999
     case '0-'. CONTENT_DB_STORAGE_PER_FIELD :
@@ -2002,7 +2002,7 @@  discard block
 block discarded – undo
2002 2002
       return "content_type_$name";
2003 2003
     case '1003-'. CONTENT_DB_STORAGE_PER_FIELD :
2004 2004
       return "content_$name";
2005
-  }
2005
+    }
2006 2006
 }
2007 2007
 
2008 2008
 /**
@@ -2014,10 +2014,10 @@  discard block
 block discarded – undo
2014 2014
  * with 'content_field'.
2015 2015
  */
2016 2016
 function content_field_tablename($version = NULL) {
2017
-  if (is_null($version)) {
2017
+    if (is_null($version)) {
2018 2018
     $version = variable_get('content_schema_version', 0);
2019
-  }
2020
-  return $version < 6001 ? 'node_field' : 'content_node_field';
2019
+    }
2020
+    return $version < 6001 ? 'node_field' : 'content_node_field';
2021 2021
 }
2022 2022
 
2023 2023
 /**
@@ -2026,10 +2026,10 @@  discard block
 block discarded – undo
2026 2026
  * Needed because the table name changes depending on version.
2027 2027
  */
2028 2028
 function content_instance_tablename($version = NULL) {
2029
-  if (is_null($version)) {
2029
+    if (is_null($version)) {
2030 2030
     $version = variable_get('content_schema_version', 0);
2031
-  }
2032
-  return $version < 6001 ? 'node_field_instance' : 'content_node_field_instance';
2031
+    }
2032
+    return $version < 6001 ? 'node_field_instance' : 'content_node_field_instance';
2033 2033
 }
2034 2034
 
2035 2035
 /**
@@ -2040,12 +2040,12 @@  discard block
 block discarded – undo
2040 2040
  * update 6000 runs, so the cache table will be used instead.
2041 2041
  */
2042 2042
 function content_cache_tablename() {
2043
-  if (variable_get('content_schema_version', -1) < 6000) {
2043
+    if (variable_get('content_schema_version', -1) < 6000) {
2044 2044
     return 'cache';
2045
-  }
2046
-  else {
2045
+    }
2046
+    else {
2047 2047
     return 'cache_content';
2048
-  }
2048
+    }
2049 2049
 }
2050 2050
 
2051 2051
 /**
@@ -2056,45 +2056,45 @@  discard block
 block discarded – undo
2056 2056
  * otherwise the function will return the whole thing.
2057 2057
  */
2058 2058
 function content_table_schema($field = NULL) {
2059
-  $schema = array(
2059
+    $schema = array(
2060 2060
     'fields' => array(
2061
-      'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
2062
-      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
2061
+        'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
2062
+        'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
2063 2063
     ),
2064 2064
     'primary key' => array('vid'),
2065 2065
     'indexes' => array(
2066
-      'nid'    => array('nid'),
2066
+        'nid'    => array('nid'),
2067 2067
     ),
2068
-  );
2068
+    );
2069 2069
 
2070
-  // Add delta column if needed.
2071
-  if (!empty($field['multiple'])) {
2070
+    // Add delta column if needed.
2071
+    if (!empty($field['multiple'])) {
2072 2072
     $schema['fields']['delta'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0);
2073 2073
     $schema['primary key'][] = 'delta';
2074
-  }
2075
-  $schema['content fields'] = array();
2074
+    }
2075
+    $schema['content fields'] = array();
2076 2076
 
2077
-  // Add field columns column if needed.
2078
-  // This function is called from install files where it is not safe
2079
-  // to use content_fields() or content_database_info(), so we
2080
-  // just used the column values stored in the $field.
2081
-  // We also need the schema to include fields from disabled modules
2082
-  // or there will be no way to delete those fields.
2077
+    // Add field columns column if needed.
2078
+    // This function is called from install files where it is not safe
2079
+    // to use content_fields() or content_database_info(), so we
2080
+    // just used the column values stored in the $field.
2081
+    // We also need the schema to include fields from disabled modules
2082
+    // or there will be no way to delete those fields.
2083 2083
 
2084
-  if (!empty($field['columns'])) {
2084
+    if (!empty($field['columns'])) {
2085 2085
     foreach ($field['columns'] as $column => $attributes) {
2086
-      $column_name =  $field['field_name'] .'_'. $column;
2087
-      if (isset($attributes['index']) && $attributes['index']) {
2086
+        $column_name =  $field['field_name'] .'_'. $column;
2087
+        if (isset($attributes['index']) && $attributes['index']) {
2088 2088
         $schema['indexes'][$column_name] = array($column_name);
2089 2089
         unset($attributes['index']);
2090
-      }
2091
-      unset($attributes['column']);
2092
-      unset($attributes['sortable']);
2093
-      $schema['fields'][$column_name] = $attributes;
2090
+        }
2091
+        unset($attributes['column']);
2092
+        unset($attributes['sortable']);
2093
+        $schema['fields'][$column_name] = $attributes;
2094 2094
     }
2095 2095
     $schema['content fields'][] = $field['field_name'];
2096
-  }
2097
-  return $schema;
2096
+    }
2097
+    return $schema;
2098 2098
 }
2099 2099
 
2100 2100
 /**
@@ -2112,26 +2112,26 @@  discard block
 block discarded – undo
2112 2112
  *   TRUE if the table exists. Otherwise FALSE.
2113 2113
  */
2114 2114
 function content_db_index_exists($table, $name) {
2115
-  global $db_type;
2116
-  if ($db_type == 'mysql' || $db_type == 'mysqli') {
2115
+    global $db_type;
2116
+    if ($db_type == 'mysql' || $db_type == 'mysqli') {
2117 2117
     if (version_compare(db_version(), '5.0.3') < 0) {
2118
-      // Earlier versions of MySQL don't support a WHERE clause for SHOW.
2119
-      $result = db_query('SHOW INDEX FROM {'. $table .'}');
2120
-      while ($row = db_fetch_array($result)) {
2118
+        // Earlier versions of MySQL don't support a WHERE clause for SHOW.
2119
+        $result = db_query('SHOW INDEX FROM {'. $table .'}');
2120
+        while ($row = db_fetch_array($result)) {
2121 2121
         if ($row['Key_name'] == $name) {
2122
-          return TRUE;
2122
+            return TRUE;
2123
+        }
2123 2124
         }
2124
-      }
2125
-      return FALSE;
2125
+        return FALSE;
2126 2126
     }
2127 2127
     return (bool)db_result(db_query("SHOW INDEX FROM {". $table ."} WHERE key_name = '$name'"));
2128
-  }
2129
-  elseif ($db_type == 'pgsql') {
2128
+    }
2129
+    elseif ($db_type == 'pgsql') {
2130 2130
     // Note that the index names in Schema API for PostgreSQL are prefixed by
2131 2131
     // the table name and suffixed by '_idx'.
2132 2132
     return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{". $table ."}_{$name}_idx'"));
2133
-  }
2134
-  return FALSE;
2133
+    }
2134
+    return FALSE;
2135 2135
 }
2136 2136
 
2137 2137
 /**
@@ -2152,15 +2152,15 @@  discard block
 block discarded – undo
2152 2152
  *
2153 2153
  */
2154 2154
 function content_callback($entity, $op, $field) {
2155
-  switch ($entity) {
2155
+    switch ($entity) {
2156 2156
     case 'field':
2157 2157
       $info = module_invoke($field['module'], "field_info");
2158
-      return isset($info[$field['type']]['callbacks'][$op]) ? $info[$field['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2158
+        return isset($info[$field['type']]['callbacks'][$op]) ? $info[$field['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2159 2159
 
2160 2160
     case 'widget':
2161 2161
       $info = module_invoke($field['widget']['module'], "widget_info");
2162
-      return isset($info[$field['widget']['type']]['callbacks'][$op]) ? $info[$field['widget']['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2163
-  }
2162
+        return isset($info[$field['widget']['type']]['callbacks'][$op]) ? $info[$field['widget']['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2163
+    }
2164 2164
 }
2165 2165
 
2166 2166
 /**
@@ -2182,20 +2182,20 @@  discard block
 block discarded – undo
2182 2182
  *    CONTENT_HANDLE_MODULE  - the implementing module handles this operation.
2183 2183
  */
2184 2184
 function content_handle($entity, $op, $object) {
2185
-  switch ($entity) {
2185
+    switch ($entity) {
2186 2186
     case 'field':
2187 2187
       $info = module_invoke($object['module'], "field_info");
2188
-      return isset($info[$object['type']][$op]) ? $info[$object['type']][$op] : CONTENT_HANDLE_CORE;
2188
+        return isset($info[$object['type']][$op]) ? $info[$object['type']][$op] : CONTENT_HANDLE_CORE;
2189 2189
 
2190 2190
     case 'widget':
2191 2191
       $info = module_invoke($object['widget']['module'], "widget_info");
2192
-      return isset($info[$object['widget']['type']][$op]) ? $info[$object['widget']['type']][$op] : CONTENT_HANDLE_CORE;
2192
+        return isset($info[$object['widget']['type']][$op]) ? $info[$object['widget']['type']][$op] : CONTENT_HANDLE_CORE;
2193 2193
 
2194 2194
     case 'formatter':
2195 2195
       // Much simpler, formatters arrays *are* the 'formatter_info' itself.
2196 2196
       // We let content_handle deal with them only for code consistency.
2197 2197
       return isset($object[$op]) ? $object[$op] : CONTENT_HANDLE_CORE;
2198
-  }
2198
+    }
2199 2199
 }
2200 2200
 
2201 2201
 /**
@@ -2211,22 +2211,22 @@  discard block
 block discarded – undo
2211 2211
  *    The default value for that field.
2212 2212
  */
2213 2213
 function content_default_value(&$form, &$form_state, $field, $delta) {
2214
-  $widget_types = _content_widget_types();
2215
-  $module = $widget_types[$field['widget']['type']]['module'];
2214
+    $widget_types = _content_widget_types();
2215
+    $module = $widget_types[$field['widget']['type']]['module'];
2216 2216
 
2217
-  $default_value = array();
2218
-  if (!empty($field['widget']['default_value_php'])) {
2217
+    $default_value = array();
2218
+    if (!empty($field['widget']['default_value_php'])) {
2219 2219
     ob_start();
2220 2220
     $result = eval($field['widget']['default_value_php']);
2221 2221
     ob_end_clean();
2222 2222
     if (is_array($result)) {
2223
-      $default_value = $result;
2223
+        $default_value = $result;
2224
+    }
2224 2225
     }
2225
-  }
2226
-  elseif (!empty($field['widget']['default_value'])) {
2226
+    elseif (!empty($field['widget']['default_value'])) {
2227 2227
     $default_value = $field['widget']['default_value'];
2228
-  }
2229
-  return (array) $default_value;
2228
+    }
2229
+    return (array) $default_value;
2230 2230
 }
2231 2231
 
2232 2232
 /**
@@ -2247,33 +2247,33 @@  discard block
 block discarded – undo
2247 2247
  *   FALSE if the operation is denied.
2248 2248
  */
2249 2249
 function content_access($op, $field, $account = NULL, $node = NULL) {
2250
-  global $user;
2250
+    global $user;
2251 2251
 
2252
-  if (is_null($account)) {
2252
+    if (is_null($account)) {
2253 2253
     $account = $user;
2254
-  }
2255
-  // Check for valid field data.
2256
-  if (!isset($field['field_name'])) {
2254
+    }
2255
+    // Check for valid field data.
2256
+    if (!isset($field['field_name'])) {
2257 2257
     return FALSE;
2258
-  }
2259
-  $access = module_invoke_all('field_access', $op, $field, $account, $node);
2260
-  foreach ($access as $value) {
2258
+    }
2259
+    $access = module_invoke_all('field_access', $op, $field, $account, $node);
2260
+    foreach ($access as $value) {
2261 2261
     if ($value === FALSE) {
2262
-      return FALSE;
2262
+        return FALSE;
2263
+    }
2263 2264
     }
2264
-  }
2265
-  return TRUE;
2265
+    return TRUE;
2266 2266
 }
2267 2267
 
2268
- /**
2269
- * Hide specified fields from the $content variable in node templates.
2270
- */
2268
+    /**
2269
+     * Hide specified fields from the $content variable in node templates.
2270
+     */
2271 2271
 function content_field_wrapper_post_render($content, $element) {
2272
-  $field = content_fields($element['#field_name'], $element['#type_name']);
2273
-  if (theme('content_exclude', $content, $field, $element['#context'])) {
2272
+    $field = content_fields($element['#field_name'], $element['#type_name']);
2273
+    if (theme('content_exclude', $content, $field, $element['#context'])) {
2274 2274
     return '';
2275
-  }
2276
-  return $content;
2275
+    }
2276
+    return $content;
2277 2277
 }
2278 2278
 
2279 2279
 
@@ -2329,17 +2329,17 @@  discard block
 block discarded – undo
2329 2329
  *   as set on the Manage fields screen.
2330 2330
  */
2331 2331
 function theme_content_exclude($content, $object, $context) {
2332
-  // The field may be missing info for $contexts added by modules
2333
-  // enabled after the field was last edited.
2334
-  if (empty($object['display_settings'])
2332
+    // The field may be missing info for $contexts added by modules
2333
+    // enabled after the field was last edited.
2334
+    if (empty($object['display_settings'])
2335 2335
     || empty($object['display_settings'][$context])
2336 2336
     || !is_array($object['display_settings'][$context])
2337 2337
     || empty($object['display_settings'][$context]['exclude'])) {
2338 2338
     return FALSE;
2339
-  }
2340
-  else {
2339
+    }
2340
+    else {
2341 2341
     return TRUE;
2342
-  }
2342
+    }
2343 2343
 }
2344 2344
 
2345 2345
 /**
@@ -2358,48 +2358,48 @@  discard block
 block discarded – undo
2358 2358
  * doesn't get called when the theme overrides the template. Bug in theme layer ?
2359 2359
  */
2360 2360
 function template_preprocess_content_field(&$variables) {
2361
-  $element = $variables['element'];
2362
-  $field = content_fields($element['#field_name'], $element['#node']->type);
2361
+    $element = $variables['element'];
2362
+    $field = content_fields($element['#field_name'], $element['#node']->type);
2363 2363
 
2364
-  $variables['node'] = $element['#node'];
2365
-  $variables['field'] = $field;
2366
-  $variables['items'] = array();
2364
+    $variables['node'] = $element['#node'];
2365
+    $variables['field'] = $field;
2366
+    $variables['items'] = array();
2367 2367
 
2368
-  if ($element['#single']) {
2368
+    if ($element['#single']) {
2369 2369
     // Single value formatter.
2370 2370
     foreach (element_children($element['items']) as $delta) {
2371
-      $variables['items'][$delta] = $element['items'][$delta]['#item'];
2372
-      // Use isset() to avoid undefined index message on #children when field values are empty.
2373
-      $variables['items'][$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
2371
+        $variables['items'][$delta] = $element['items'][$delta]['#item'];
2372
+        // Use isset() to avoid undefined index message on #children when field values are empty.
2373
+        $variables['items'][$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
2374 2374
     }
2375
-  }
2376
-  else  {
2375
+    }
2376
+    else  {
2377 2377
     // Multiple values formatter.
2378 2378
     // We display the 'all items' output as $items[0], as if it was the
2379 2379
     // output of a single valued field.
2380 2380
     // Raw values are still exposed for all items.
2381 2381
     foreach (element_children($element['items']) as $delta) {
2382
-      $variables['items'][$delta] = $element['items'][$delta]['#item'];
2382
+        $variables['items'][$delta] = $element['items'][$delta]['#item'];
2383 2383
     }
2384 2384
     $variables['items'][0]['view'] = $element['items']['#children'];
2385
-  }
2385
+    }
2386 2386
 
2387
-  $variables['teaser'] = $element['#teaser'];
2388
-  $variables['page'] = $element['#page'];
2387
+    $variables['teaser'] = $element['#teaser'];
2388
+    $variables['page'] = $element['#page'];
2389 2389
 
2390
-  $field_empty = TRUE;
2390
+    $field_empty = TRUE;
2391 2391
 
2392
-  foreach ($variables['items'] as $delta => $item) {
2392
+    foreach ($variables['items'] as $delta => $item) {
2393 2393
     if (!isset($item['view']) || (empty($item['view']) && (string)$item['view'] !== '0')) {
2394
-      $variables['items'][$delta]['empty'] = TRUE;
2394
+        $variables['items'][$delta]['empty'] = TRUE;
2395 2395
     }
2396 2396
     else {
2397
-      $field_empty = FALSE;
2398
-      $variables['items'][$delta]['empty'] = FALSE;
2397
+        $field_empty = FALSE;
2398
+        $variables['items'][$delta]['empty'] = FALSE;
2399
+    }
2399 2400
     }
2400
-  }
2401 2401
 
2402
-  $additions = array(
2402
+    $additions = array(
2403 2403
     'field_type' => $field['type'],
2404 2404
     'field_name' => $field['field_name'],
2405 2405
     'field_type_css' => strtr($field['type'], '_', '-'),
@@ -2408,13 +2408,13 @@  discard block
 block discarded – undo
2408 2408
     'label_display' => $element['#label_display'],
2409 2409
     'field_empty' => $field_empty,
2410 2410
     'template_files' => array(
2411
-      'content-field',
2412
-      'content-field-'. $element['#field_name'],
2413
-      'content-field-'. $element['#node']->type,
2414
-      'content-field-'. $element['#field_name'] .'-'. $element['#node']->type,
2411
+        'content-field',
2412
+        'content-field-'. $element['#field_name'],
2413
+        'content-field-'. $element['#node']->type,
2414
+        'content-field-'. $element['#field_name'] .'-'. $element['#node']->type,
2415 2415
     ),
2416
-  );
2417
-  $variables = array_merge($variables, $additions);
2416
+    );
2417
+    $variables = array_merge($variables, $additions);
2418 2418
 }
2419 2419
 
2420 2420
 /**
@@ -2425,8 +2425,8 @@  discard block
 block discarded – undo
2425 2425
  * - Adds the formatted values in the 'view' key of the items.
2426 2426
  */
2427 2427
 function content_preprocess_node(&$vars) {
2428
-  $additions = _content_field_invoke_default('preprocess_node', $vars['node']);
2429
-  $vars = array_merge($vars, $additions);
2428
+    $additions = _content_field_invoke_default('preprocess_node', $vars['node']);
2429
+    $vars = array_merge($vars, $additions);
2430 2430
 }
2431 2431
 
2432 2432
 /**
@@ -2438,10 +2438,10 @@  discard block
 block discarded – undo
2438 2438
  * @param $field
2439 2439
  */
2440 2440
 function content_content_fieldapi($op, $field) {
2441
-  if (module_exists('devel')) {
2441
+    if (module_exists('devel')) {
2442 2442
     //dsm($op);
2443 2443
     //dsm($field);
2444
-  }
2444
+    }
2445 2445
 }
2446 2446
 
2447 2447
 /**
@@ -2450,115 +2450,115 @@  discard block
 block discarded – undo
2450 2450
  * Informations for non-CCK 'node fields' defined in core.
2451 2451
  */
2452 2452
 function content_content_extra_fields($type_name) {
2453
-  $type = node_get_types('type', $type_name);
2454
-  $extra = array();
2453
+    $type = node_get_types('type', $type_name);
2454
+    $extra = array();
2455 2455
 
2456
-  if ($type->has_title) {
2456
+    if ($type->has_title) {
2457 2457
     $extra['title'] = array(
2458
-      'label' => $type->title_label,
2459
-      'description' => t('Node module form.'),
2460
-      'weight' => -5
2458
+        'label' => $type->title_label,
2459
+        'description' => t('Node module form.'),
2460
+        'weight' => -5
2461 2461
     );
2462
-  }
2463
-  if ($type->has_body) {
2462
+    }
2463
+    if ($type->has_body) {
2464 2464
     $extra['body_field'] = array(
2465
-      'label' => $type->body_label,
2466
-      'description' => t('Node module form.'),
2467
-      'weight' => 0,
2468
-      'view' => 'body'
2465
+        'label' => $type->body_label,
2466
+        'description' => t('Node module form.'),
2467
+        'weight' => 0,
2468
+        'view' => 'body'
2469 2469
     );
2470
-  }
2471
-  $extra['revision_information'] = array(
2470
+    }
2471
+    $extra['revision_information'] = array(
2472 2472
     'label' => t('Revision information'),
2473 2473
     'description' => t('Node module form.'),
2474 2474
     'weight' => 20
2475
-  );
2476
-  $extra['author'] = array(
2475
+    );
2476
+    $extra['author'] = array(
2477 2477
     'label' => t('Authoring information'),
2478 2478
     'description' => t('Node module form.'),
2479 2479
     'weight' => 20,
2480
-  );
2481
-  $extra['options'] = array(
2480
+    );
2481
+    $extra['options'] = array(
2482 2482
     'label' => t('Publishing options'),
2483 2483
     'description' => t('Node module form.'),
2484 2484
     'weight' => 25,
2485
-   );
2486
-  if (module_exists('comment')) {
2485
+    );
2486
+    if (module_exists('comment')) {
2487 2487
     $extra['comment_settings'] = array(
2488
-      'label' => t('Comment settings'),
2489
-      'description' => t('Comment module form.'),
2490
-      'weight' => 30
2488
+        'label' => t('Comment settings'),
2489
+        'description' => t('Comment module form.'),
2490
+        'weight' => 30
2491 2491
     );
2492
-  }
2493
-  if (module_exists('locale') && variable_get("language_content_type_$type_name", 0)) {
2492
+    }
2493
+    if (module_exists('locale') && variable_get("language_content_type_$type_name", 0)) {
2494 2494
     $extra['language'] = array(
2495
-      'label' => t('Language'),
2496
-      'description' => t('Locale module form.'),
2497
-      'weight' => 0
2495
+        'label' => t('Language'),
2496
+        'description' => t('Locale module form.'),
2497
+        'weight' => 0
2498 2498
     );
2499
-  }
2500
-  if (module_exists('translation') && translation_supported_type($type_name)) {
2499
+    }
2500
+    if (module_exists('translation') && translation_supported_type($type_name)) {
2501 2501
     $extra['translation'] = array(
2502
-      'label' => t('Translation settings'),
2503
-      'description' => t('Translation module form.'),
2504
-      'weight' => 30
2502
+        'label' => t('Translation settings'),
2503
+        'description' => t('Translation module form.'),
2504
+        'weight' => 30
2505 2505
     );
2506
-  }
2507
-  if (module_exists('menu')) {
2506
+    }
2507
+    if (module_exists('menu')) {
2508 2508
     $extra['menu'] = array(
2509
-      'label' => t('Menu settings'),
2510
-      'description' => t('Menu module form.'),
2511
-      'weight' => -2
2509
+        'label' => t('Menu settings'),
2510
+        'description' => t('Menu module form.'),
2511
+        'weight' => -2
2512 2512
     );
2513
-  }
2514
-  if (module_exists('taxonomy') && taxonomy_get_vocabularies($type_name)) {
2513
+    }
2514
+    if (module_exists('taxonomy') && taxonomy_get_vocabularies($type_name)) {
2515 2515
     $extra['taxonomy'] = array(
2516
-      'label' => t('Taxonomy'),
2517
-      'description' => t('Taxonomy module form.'),
2518
-      'weight' => -3
2516
+        'label' => t('Taxonomy'),
2517
+        'description' => t('Taxonomy module form.'),
2518
+        'weight' => -3
2519 2519
     );
2520
-  }
2521
-  if (module_exists('book')) {
2520
+    }
2521
+    if (module_exists('book')) {
2522 2522
     $extra['book'] = array(
2523
-      'label' => t('Book'),
2524
-      'description' => t('Book module form.'),
2525
-      'weight' => 10
2523
+        'label' => t('Book'),
2524
+        'description' => t('Book module form.'),
2525
+        'weight' => 10
2526 2526
     );
2527
-  }
2528
-  if (module_exists('path')) {
2527
+    }
2528
+    if (module_exists('path')) {
2529 2529
     $extra['path'] = array(
2530
-      'label' => t('Path settings'),
2531
-      'description' => t('Path module form.'),
2532
-      'weight' => 30
2530
+        'label' => t('Path settings'),
2531
+        'description' => t('Path module form.'),
2532
+        'weight' => 30
2533 2533
     );
2534
-  }
2535
-  if ($type_name == 'poll' && module_exists('poll')) {
2534
+    }
2535
+    if ($type_name == 'poll' && module_exists('poll')) {
2536 2536
     $extra['title'] = array(
2537
-      'label' => t('Poll title'),
2538
-      'description' => t('Poll module title.'),
2539
-      'weight' => -5
2537
+        'label' => t('Poll title'),
2538
+        'description' => t('Poll module title.'),
2539
+        'weight' => -5
2540 2540
     );
2541 2541
     $extra['choice_wrapper'] = array(
2542
-      'label' => t('Poll choices'),
2543
-      'description' => t('Poll module choices.'),
2544
-      'weight' => -4
2542
+        'label' => t('Poll choices'),
2543
+        'description' => t('Poll module choices.'),
2544
+        'weight' => -4
2545 2545
     );
2546 2546
     $extra['settings'] = array(
2547
-      'label' => t('Poll settings'),
2548
-      'description' => t('Poll module settings.'),
2549
-      'weight' => -3
2547
+        'label' => t('Poll settings'),
2548
+        'description' => t('Poll module settings.'),
2549
+        'weight' => -3
2550 2550
     );
2551
-  }
2552
-  if (module_exists('upload') && variable_get("upload_$type_name", TRUE)) {
2551
+    }
2552
+    if (module_exists('upload') && variable_get("upload_$type_name", TRUE)) {
2553 2553
     $extra['attachments'] = array(
2554
-      'label' => t('File attachments'),
2555
-      'description' => t('Upload module form.'),
2556
-      'weight' => 30,
2557
-      'view' => 'files'
2554
+        'label' => t('File attachments'),
2555
+        'description' => t('Upload module form.'),
2556
+        'weight' => 30,
2557
+        'view' => 'files'
2558 2558
     );
2559
-  }
2559
+    }
2560 2560
 
2561
-  return $extra;
2561
+    return $extra;
2562 2562
 }
2563 2563
 
2564 2564
 /**
@@ -2579,18 +2579,18 @@  discard block
 block discarded – undo
2579 2579
  *   by content.module.
2580 2580
  */
2581 2581
 function content_extra_field_weight($type_name, $pseudo_field_name) {
2582
-  $type = content_types($type_name);
2582
+    $type = content_types($type_name);
2583 2583
 
2584
-  // If we don't have the requested item, this may be because the cached
2585
-  // information for 'extra' fields hasn't been refreshed yet.
2586
-  if (!isset($type['extra'][$pseudo_field_name])) {
2584
+    // If we don't have the requested item, this may be because the cached
2585
+    // information for 'extra' fields hasn't been refreshed yet.
2586
+    if (!isset($type['extra'][$pseudo_field_name])) {
2587 2587
     content_clear_type_cache();
2588 2588
     $type = content_types($type_name);
2589
-  }
2589
+    }
2590 2590
 
2591
-  if (isset($type['extra'][$pseudo_field_name])) {
2591
+    if (isset($type['extra'][$pseudo_field_name])) {
2592 2592
     return $type['extra'][$pseudo_field_name]['weight'];
2593
-  }
2593
+    }
2594 2594
 }
2595 2595
 
2596 2596
 /**
@@ -2617,68 +2617,68 @@  discard block
 block discarded – undo
2617 2617
  * Do we want to eliminate them from the results?
2618 2618
  */
2619 2619
 function content_max_delta($field_name, $type_name = NULL) {
2620
-  $fields = content_fields();
2621
-  $field = $fields[$field_name];
2620
+    $fields = content_fields();
2621
+    $field = $fields[$field_name];
2622 2622
 
2623
-  // Non-multiple value fields don't use the delta column,
2624
-  // but could exist in multiple databases. If any value
2625
-  // exists in any examined table, the max delta will be zero.
2626
-  if (empty($field['multiple'])) {
2623
+    // Non-multiple value fields don't use the delta column,
2624
+    // but could exist in multiple databases. If any value
2625
+    // exists in any examined table, the max delta will be zero.
2626
+    if (empty($field['multiple'])) {
2627 2627
     $content_types = content_types();
2628 2628
     foreach ($content_types as $content_type) {
2629
-      if (empty($type_name) || $content_type['type'] == $type_name) {
2629
+        if (empty($type_name) || $content_type['type'] == $type_name) {
2630 2630
         foreach ($content_type['fields'] as $field) {
2631
-          $db_info = content_database_info($field);
2632
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $db_info['table'] ."}")) >= 1) {
2631
+            $db_info = content_database_info($field);
2632
+            if (db_result(db_query("SELECT COUNT(*) FROM {". $db_info['table'] ."}")) >= 1) {
2633 2633
             return 0;
2634
-          }
2634
+            }
2635
+        }
2635 2636
         }
2636
-      }
2637 2637
     }
2638
-  }
2639
-  // Multiple value fields always share the same table and use the delta.
2640
-  // If we want to find delta values for a particular type, we join
2641
-  // in the node table to limit the type.
2642
-  else {
2638
+    }
2639
+    // Multiple value fields always share the same table and use the delta.
2640
+    // If we want to find delta values for a particular type, we join
2641
+    // in the node table to limit the type.
2642
+    else {
2643 2643
     $db_info = content_database_info($field);
2644 2644
     if (!empty($type_name)) {
2645
-      $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2645
+        $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2646 2646
     }
2647 2647
     else {
2648
-      $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."}"));
2648
+        $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."}"));
2649 2649
     }
2650 2650
     if ($delta >= 0) {
2651
-      return $delta;
2651
+        return $delta;
2652 2652
     }
2653
-  }
2654
-  // If we got this far, there is no data for this field.
2655
-  return NULL;
2653
+    }
2654
+    // If we got this far, there is no data for this field.
2655
+    return NULL;
2656 2656
 }
2657 2657
 
2658 2658
 /**
2659 2659
  * Helper function to identify inactive fields.
2660 2660
  */
2661 2661
 function content_inactive_fields($type_name = NULL) {
2662
-  module_load_include('inc', 'content', 'includes/content.crud');
2663
-  if (!empty($type_name)) {
2662
+    module_load_include('inc', 'content', 'includes/content.crud');
2663
+    if (!empty($type_name)) {
2664 2664
     $param = array('type_name' => $type_name);
2665 2665
     $inactive = array($type_name => array());
2666
-  }
2667
-  else {
2666
+    }
2667
+    else {
2668 2668
     $param = array();
2669 2669
     $inactive = array();
2670
-  }
2671
-  $all = content_field_instance_read($param, TRUE);
2672
-  $active = array_keys(content_fields());
2673
-  foreach ($all as $field) {
2670
+    }
2671
+    $all = content_field_instance_read($param, TRUE);
2672
+    $active = array_keys(content_fields());
2673
+    foreach ($all as $field) {
2674 2674
     if (!in_array($field['field_name'], $active)) {
2675
-      $inactive[$field['type_name']][$field['field_name']] = content_field_instance_expand($field);
2675
+        $inactive[$field['type_name']][$field['field_name']] = content_field_instance_expand($field);
2676
+    }
2676 2677
     }
2677
-  }
2678
-  if (!empty($type_name)) {
2678
+    if (!empty($type_name)) {
2679 2679
     return $inactive[$type_name];
2680
-  }
2681
-  return $inactive;
2680
+    }
2681
+    return $inactive;
2682 2682
 }
2683 2683
 
2684 2684
  
@@ -2689,21 +2689,21 @@  discard block
 block discarded – undo
2689 2689
  * if the fields have other (shared) instances that are still active.
2690 2690
  */
2691 2691
 function content_inactive_instances($type_name = NULL) {
2692
-  module_load_include('inc', 'content', 'includes/content.crud');
2693
-  if (!empty($type_name)) {
2692
+    module_load_include('inc', 'content', 'includes/content.crud');
2693
+    if (!empty($type_name)) {
2694 2694
     $param = array('type_name' => $type_name);
2695 2695
     $inactive = array($type_name => array());
2696
-  }
2697
-  else {
2696
+    }
2697
+    else {
2698 2698
     $param = array();
2699 2699
     $inactive = array();
2700
-  }
2701
-  $all = content_field_instance_read($param, TRUE);
2702
-  foreach ($all as $field) {
2700
+    }
2701
+    $all = content_field_instance_read($param, TRUE);
2702
+    foreach ($all as $field) {
2703 2703
     $inactive[$field['type_name']][$field['field_name']] = content_field_instance_expand($field);
2704
-  }
2705
-  if (!empty($type_name)) {
2704
+    }
2705
+    if (!empty($type_name)) {
2706 2706
     return $inactive[$type_name];
2707
-  }
2708
-  return $inactive;
2707
+    }
2708
+    return $inactive;
2709 2709
 }
Please login to merge, or discard this patch.
Switch Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
 
18 18
 function content_help($path, $arg) {
19 19
   switch ($path) {
20
-    case 'admin/help#content':
21
-      $output = '<p>'. t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))) .'</p>';
22
-      $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
-      $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
24
-      $output .= '<ul>';
25
-      $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
-      $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
-      $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
-      $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
-      $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
30
-      $output .= '</ul>';
31
-      $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
32
-      return $output;
20
+  case 'admin/help#content':
21
+    $output = '<p>'. t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))) .'</p>';
22
+    $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
+    $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
24
+    $output .= '<ul>';
25
+    $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
+    $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
+    $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
+    $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
+    $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
30
+    $output .= '</ul>';
31
+    $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
32
+    return $output;
33 33
   }
34 34
 }
35 35
 
@@ -553,27 +553,27 @@  discard block
 block discarded – undo
553 553
  */
554 554
 function content_notify($op, $module) {
555 555
   switch ($op) {
556
-    case 'install':
557
-      content_clear_type_cache();
558
-      break;
559
-    case 'uninstall':
560
-      module_load_include('inc', 'content', 'includes/content.crud');
561
-      content_module_delete($module);
562
-      break;
563
-    case 'enable':
564
-      content_associate_fields($module);
565
-      content_clear_type_cache();
566
-      break;
567
-    case 'disable':
568
-      // When CCK modules are disabled before content module's update is run
569
-      // to add the active column, we can't do this.
570
-      if (variable_get('content_schema_version', -1) < 6007) {
571
-        return FALSE;
572
-      }
573
-      db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
-      content_clear_type_cache(TRUE);
576
-      break;
556
+  case 'install':
557
+    content_clear_type_cache();
558
+    break;
559
+  case 'uninstall':
560
+    module_load_include('inc', 'content', 'includes/content.crud');
561
+    content_module_delete($module);
562
+    break;
563
+  case 'enable':
564
+    content_associate_fields($module);
565
+    content_clear_type_cache();
566
+    break;
567
+  case 'disable':
568
+    // When CCK modules are disabled before content module's update is run
569
+    // to add the active column, we can't do this.
570
+    if (variable_get('content_schema_version', -1) < 6007) {
571
+      return FALSE;
572
+    }
573
+    db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
+    db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
+    content_clear_type_cache(TRUE);
576
+    break;
577 577
   }
578 578
 }
579 579
 
@@ -685,38 +685,53 @@  discard block
 block discarded – undo
685 685
  */
686 686
 function content_field($op, &$node, $field, &$items, $teaser, $page) {
687 687
   switch ($op) {
688
-    case 'validate':
689
-      // TODO: here we could validate that the number of multiple data is correct ?
690
-      // We're controlling the number of fields to fill out and saving empty
691
-      // ones if a specified number is requested, so no reason to do any validation
692
-      // here right now, but if later create a method to indicate whether
693
-      // 'required' means all values must be filled out, we can come back
694
-      // here and check that they're not empty.
695
-      break;
696
-
697
-    case 'presave':
698
-      if (!empty($node->devel_generate)) {
699
-        include_once('./'. drupal_get_path('module', 'content') .'/includes/content.devel.inc');
700
-        content_generate_fields($node, $field);
701
-        $items = $node->{$field['field_name']};
702
-      }
688
+  case 'validate':
689
+    // TODO: here we could validate that the number of multiple data is correct ?
690
+    // We're controlling the number of fields to fill out and saving empty
691
+    // ones if a specified number is requested, so no reason to do any validation
692
+    // here right now, but if later create a method to indicate whether
693
+    // 'required' means all values must be filled out, we can come back
694
+    // here and check that they're not empty.
695
+    break;
696
+
697
+  case 'presave':
698
+    if (!empty($node->devel_generate)) {
699
+      include_once('./'. drupal_get_path('module', 'content') .'/includes/content.devel.inc');
700
+      content_generate_fields($node, $field);
701
+      $items = $node->{$field['field_name']};
702
+    }
703 703
 
704
-      // Manual node_save calls might not have all fields filled in.
705
-      // On node insert, we need to make sure all tables get at least an empty
706
-      // record, or subsequent edits, using drupal_write_record() in update mode,
707
-      // won't insert any data.
708
-      // Missing fields on node update are handled in content_storage().
709
-      if (empty($items) && !isset($node->nid)) {
710
-        foreach (array_keys($field['columns']) as $column) {
711
-          $items[0][$column] = NULL;
712
-        }
713
-        $node->$field['field_name'] = $items;
704
+    // Manual node_save calls might not have all fields filled in.
705
+    // On node insert, we need to make sure all tables get at least an empty
706
+    // record, or subsequent edits, using drupal_write_record() in update mode,
707
+    // won't insert any data.
708
+    // Missing fields on node update are handled in content_storage().
709
+    if (empty($items) && !isset($node->nid)) {
710
+      foreach (array_keys($field['columns']) as $column) {
711
+        $items[0][$column] = NULL;
714 712
       }
713
+      $node->$field['field_name'] = $items;
714
+    }
715 715
 
716
-      // If there was an AHAH add more button in this field, don't save it.
717
-      // TODO: is it still needed ?
718
-      unset($items[$field['field_name'] .'_add_more']);
716
+    // If there was an AHAH add more button in this field, don't save it.
717
+    // TODO: is it still needed ?
718
+    unset($items[$field['field_name'] .'_add_more']);
719
+
720
+    if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
721
+      // Reorder items to account for drag-n-drop reordering.
722
+      $items = _content_sort_items($field, $items);
723
+    }
724
+
725
+    // Filter out empty values.
726
+    $items = content_set_empty($field, $items);
719 727
 
728
+    break;
729
+
730
+  case 'view':
731
+    $addition = array();
732
+
733
+    // Previewed nodes bypass the 'presave' op, so we need to some massaging.
734
+    if ($node->build_mode == NODE_BUILD_PREVIEW && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
720 735
       if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
721 736
         // Reorder items to account for drag-n-drop reordering.
722 737
         $items = _content_sort_items($field, $items);
@@ -724,166 +739,151 @@  discard block
 block discarded – undo
724 739
 
725 740
       // Filter out empty values.
726 741
       $items = content_set_empty($field, $items);
742
+    }
727 743
 
728
-      break;
729
-
730
-    case 'view':
731
-      $addition = array();
744
+    // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745
+    if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
746
+      $context = $teaser ? 'teaser' : 'full';
747
+    }
748
+    else {
749
+      $context = $node->build_mode;
750
+    }
751
+    // The field may be missing info for $contexts added by modules
752
+    // enabled after the field was last edited.
753
+    $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754
+    if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
755
+      $theme = $formatter['module'] .'_formatter_'. $formatter_name;
756
+      $single = (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE);
757
+
758
+      $label_display = isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above';
759
+      // Do not include field labels when indexing content.
760
+      if ($context == NODE_BUILD_SEARCH_INDEX) {
761
+        $label_display = 'hidden';
762
+      }
732 763
 
733
-      // Previewed nodes bypass the 'presave' op, so we need to some massaging.
734
-      if ($node->build_mode == NODE_BUILD_PREVIEW && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
735
-        if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
736
-          // Reorder items to account for drag-n-drop reordering.
737
-          $items = _content_sort_items($field, $items);
738
-        }
764
+      $element = array(
765
+        '#type' => 'content_field',
766
+        '#title' => check_plain(t($field['widget']['label'])),
767
+        '#field_name' => $field['field_name'],
768
+        '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
769
+        '#label_display' => $label_display,
770
+        '#node' => $node,
771
+        '#teaser' => $teaser,
772
+        '#page' => $page,
773
+        '#context' => $context,
774
+        '#single' => $single,
775
+        'items' => array(),
776
+      );
739 777
 
740
-        // Filter out empty values.
741
-        $items = content_set_empty($field, $items);
778
+      // Fill-in items.
779
+      foreach ($items as $delta => $item) {
780
+        $element['items'][$delta] = array(
781
+          '#item' => $item,
782
+          '#weight' => $delta,
783
+        );
742 784
       }
743 785
 
744
-      // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745
-      if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
746
-        $context = $teaser ? 'teaser' : 'full';
786
+      // Append formatter information either on each item ('single-value' formatter)
787
+      // or at the upper 'items' level ('multiple-value' formatter)
788
+      $format_info = array(
789
+        '#theme' => $theme,
790
+        '#field_name' => $field['field_name'],
791
+        '#type_name' => $node->type,
792
+        '#formatter' => $formatter_name,
793
+        '#node' => $node,
794
+      );
795
+      if ($single) {
796
+        foreach ($items as $delta => $item) {
797
+          $element['items'][$delta] += $format_info;
798
+          $element['items'][$delta]['#item']['#delta'] = $delta;
799
+        }
747 800
       }
748 801
       else {
749
-        $context = $node->build_mode;
802
+        $element['items'] += $format_info;
750 803
       }
751
-      // The field may be missing info for $contexts added by modules
752
-      // enabled after the field was last edited.
753
-      $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754
-      if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
755
-        $theme = $formatter['module'] .'_formatter_'. $formatter_name;
756
-        $single = (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE);
757
-
758
-        $label_display = isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above';
759
-        // Do not include field labels when indexing content.
760
-        if ($context == NODE_BUILD_SEARCH_INDEX) {
761
-          $label_display = 'hidden';
762
-        }
763 804
 
764
-        $element = array(
765
-          '#type' => 'content_field',
766
-          '#title' => check_plain(t($field['widget']['label'])),
767
-          '#field_name' => $field['field_name'],
768
-          '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
769
-          '#label_display' => $label_display,
770
-          '#node' => $node,
771
-          '#teaser' => $teaser,
772
-          '#page' => $page,
773
-          '#context' => $context,
774
-          '#single' => $single,
775
-          'items' => array(),
776
-        );
805
+      // The wrapper lets us get the themed output for the whole field
806
+      // to populate the $FIELD_NAME_rendered variable for node templates,
807
+      // and hide it from the $content variable if needed.
808
+      // See 'preprocess_node' op and theme_content_field_wrapper()?
809
+      $wrapper = array(
810
+        'field' => $element,
811
+        '#weight' => $field['widget']['weight'],
812
+        '#post_render' => array('content_field_wrapper_post_render'),
813
+        '#field_name' => $field['field_name'],
814
+        '#type_name' => $node->type,
815
+        '#context' => $context,
816
+      );
777 817
 
778
-        // Fill-in items.
779
-        foreach ($items as $delta => $item) {
780
-          $element['items'][$delta] = array(
781
-            '#item' => $item,
782
-            '#weight' => $delta,
783
-          );
784
-        }
818
+      $addition = array($field['field_name'] => $wrapper);
819
+    }
820
+    return $addition;
821
+
822
+  case 'alter':
823
+    // Add back the formatted values in the 'view' element,
824
+    // so that tokens and node templates can use it.
825
+    // Note: Doing this in 'preprocess_node' breaks token integration.
826
+
827
+    // The location of the field's rendered output depends on whether the
828
+    // field is in a fieldgroup or not.
829
+    $wrapper = NULL;
830
+    if (isset($node->content[$field['field_name']])) {
831
+      $wrapper = $node->content[$field['field_name']];
832
+    }
833
+    elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
834
+      $wrapper = $node->content[$group_name]['group'][$field['field_name']];
835
+    }
785 836
 
786
-        // Append formatter information either on each item ('single-value' formatter)
787
-        // or at the upper 'items' level ('multiple-value' formatter)
788
-        $format_info = array(
789
-          '#theme' => $theme,
790
-          '#field_name' => $field['field_name'],
791
-          '#type_name' => $node->type,
792
-          '#formatter' => $formatter_name,
793
-          '#node' => $node,
794
-        );
795
-        if ($single) {
796
-          foreach ($items as $delta => $item) {
797
-            $element['items'][$delta] += $format_info;
798
-            $element['items'][$delta]['#item']['#delta'] = $delta;
837
+    if ($wrapper) {
838
+      $element = $wrapper['field'];
839
+      // '#single' is not set if the field is hidden or inaccessible.
840
+      if (isset($element['#single'])) {
841
+        if (!empty($element['#single'])) {
842
+          // Single value formatter.
843
+          foreach (element_children($element['items']) as $delta) {
844
+            // '#chilren' is not set if the field is empty.
845
+            $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
799 846
           }
800 847
         }
801
-        else {
802
-          $element['items'] += $format_info;
848
+        elseif (isset($element['items']['#children']))  {
849
+          // Multiple values formatter.
850
+          $items[0]['view'] = $element['items']['#children'];
803 851
         }
804
-
805
-        // The wrapper lets us get the themed output for the whole field
806
-        // to populate the $FIELD_NAME_rendered variable for node templates,
807
-        // and hide it from the $content variable if needed.
808
-        // See 'preprocess_node' op and theme_content_field_wrapper()?
809
-        $wrapper = array(
810
-          'field' => $element,
811
-          '#weight' => $field['widget']['weight'],
812
-          '#post_render' => array('content_field_wrapper_post_render'),
813
-          '#field_name' => $field['field_name'],
814
-          '#type_name' => $node->type,
815
-          '#context' => $context,
816
-        );
817
-
818
-        $addition = array($field['field_name'] => $wrapper);
819
-      }
820
-      return $addition;
821
-
822
-    case 'alter':
823
-      // Add back the formatted values in the 'view' element,
824
-      // so that tokens and node templates can use it.
825
-      // Note: Doing this in 'preprocess_node' breaks token integration.
826
-
827
-      // The location of the field's rendered output depends on whether the
828
-      // field is in a fieldgroup or not.
829
-      $wrapper = NULL;
830
-      if (isset($node->content[$field['field_name']])) {
831
-        $wrapper = $node->content[$field['field_name']];
832 852
       }
833
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
834
-        $wrapper = $node->content[$group_name]['group'][$field['field_name']];
835
-      }
836
-
837
-      if ($wrapper) {
838
-        $element = $wrapper['field'];
839
-        // '#single' is not set if the field is hidden or inaccessible.
840
-        if (isset($element['#single'])) {
841
-          if (!empty($element['#single'])) {
842
-            // Single value formatter.
843
-            foreach (element_children($element['items']) as $delta) {
844
-              // '#chilren' is not set if the field is empty.
845
-              $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
846
-            }
847
-          }
848
-          elseif (isset($element['items']['#children']))  {
849
-            // Multiple values formatter.
850
-            $items[0]['view'] = $element['items']['#children'];
851
-          }
852
-        }
853
-        else {
854
-          // Hidden or inaccessible field.
855
-          $items[0]['view'] = '';
856
-        }
853
+      else {
854
+        // Hidden or inaccessible field.
855
+        $items[0]['view'] = '';
857 856
       }
858
-      break;
857
+    }
858
+    break;
859 859
 
860
-    case 'preprocess_node':
861
-      // Add $FIELD_NAME_rendered variables.
862
-      $addition = array();
860
+  case 'preprocess_node':
861
+    // Add $FIELD_NAME_rendered variables.
862
+    $addition = array();
863 863
 
864
-      // The location of the field's rendered output depends on whether the
865
-      // field is in a fieldgroup or not.
866
-      $wrapper = NULL;
867
-      if (isset($node->content[$field['field_name']])) {
868
-        $wrapper = $node->content[$field['field_name']];
869
-      }
870
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
871
-        $wrapper = $node->content[$group_name]['group'][$field['field_name']];
872
-      }
864
+    // The location of the field's rendered output depends on whether the
865
+    // field is in a fieldgroup or not.
866
+    $wrapper = NULL;
867
+    if (isset($node->content[$field['field_name']])) {
868
+      $wrapper = $node->content[$field['field_name']];
869
+    }
870
+    elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
871
+      $wrapper = $node->content[$group_name]['group'][$field['field_name']];
872
+    }
873 873
 
874
-      if ($wrapper) {
875
-        // '#chilren' is not set if the field is empty.
876
-        $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
877
-      }
874
+    if ($wrapper) {
875
+      // '#chilren' is not set if the field is empty.
876
+      $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
877
+    }
878 878
 
879
-      return $addition;
879
+    return $addition;
880 880
 
881
-    case 'prepare translation':
882
-      $addition = array();
883
-      if (isset($node->translation_source->$field['field_name'])) {
884
-        $addition[$field['field_name']] = $node->translation_source->$field['field_name'];
885
-      }
886
-      return $addition;
881
+  case 'prepare translation':
882
+    $addition = array();
883
+    if (isset($node->translation_source->$field['field_name'])) {
884
+      $addition[$field['field_name']] = $node->translation_source->$field['field_name'];
885
+    }
886
+    return $addition;
887 887
   }
888 888
 }
889 889
 
@@ -974,122 +974,122 @@  discard block
 block discarded – undo
974 974
   $type = content_types($type_name);
975 975
 
976 976
   switch ($op) {
977
-    case 'load':
978
-      // OPTIMIZE: load all non multiple fields in a single JOIN query ?
979
-      // warning: 61-join limit in MySQL ?
980
-      $additions = array();
981
-      // For each table used by this content type,
982
-      foreach ($type['tables'] as $table) {
983
-        $schema = drupal_get_schema($table);
984
-        // The per-type table might not have any fields actually stored in it.
985
-        if (!$schema['content fields']) {
986
-          continue;
987
-        }
988
-        $query = 'SELECT * FROM {'. $table .'} WHERE vid = %d';
989
-
990
-        // If we're loading a table for a multiple field,
991
-        // we fetch all rows (values) ordered by delta,
992
-        // else we only fetch one row.
993
-        $result = isset($schema['fields']['delta']) ? db_query($query .' ORDER BY delta', $node->vid) : db_query_range($query, $node->vid, 0, 1);
994
-
995
-        // For each table row, populate the fields.
996
-        while ($row = db_fetch_array($result)) {
997
-          // For each field stored in the table, add the field item.
998
-          foreach ($schema['content fields'] as $field_name) {
999
-            $item = array();
1000
-            $field = content_fields($field_name, $type_name);
1001
-            $db_info = content_database_info($field);
1002
-            // For each column declared by the field, populate the item.
1003
-            foreach ($db_info['columns'] as $column => $attributes) {
1004
-              $item[$column] = $row[$attributes['column']];
1005
-            }
1006
-
1007
-            // Add the item to the field values for the node.
1008
-            if (!isset($additions[$field_name])) {
1009
-              $additions[$field_name] = array();
1010
-            }
1011
-            $additions[$field_name][] = $item;
1012
-          }
1013
-        }
977
+  case 'load':
978
+    // OPTIMIZE: load all non multiple fields in a single JOIN query ?
979
+    // warning: 61-join limit in MySQL ?
980
+    $additions = array();
981
+    // For each table used by this content type,
982
+    foreach ($type['tables'] as $table) {
983
+      $schema = drupal_get_schema($table);
984
+      // The per-type table might not have any fields actually stored in it.
985
+      if (!$schema['content fields']) {
986
+        continue;
1014 987
       }
1015
-      return $additions;
988
+      $query = 'SELECT * FROM {'. $table .'} WHERE vid = %d';
989
+
990
+      // If we're loading a table for a multiple field,
991
+      // we fetch all rows (values) ordered by delta,
992
+      // else we only fetch one row.
993
+      $result = isset($schema['fields']['delta']) ? db_query($query .' ORDER BY delta', $node->vid) : db_query_range($query, $node->vid, 0, 1);
1016 994
 
1017
-    case 'insert':
1018
-    case 'update':
1019
-      foreach ($type['tables'] as $table) {
1020
-        $schema = drupal_get_schema($table);
1021
-        $record = array();
995
+      // For each table row, populate the fields.
996
+      while ($row = db_fetch_array($result)) {
997
+        // For each field stored in the table, add the field item.
1022 998
         foreach ($schema['content fields'] as $field_name) {
1023
-          if (isset($node->$field_name)) {
1024
-            $field = content_fields($field_name, $type_name);
1025
-            // Multiple fields need specific handling, we'll deal with them later on.
1026
-            if ($field['multiple']) {
1027
-              continue;
1028
-            }
1029
-            $db_info = content_database_info($field);
1030
-            foreach ($db_info['columns'] as $column => $attributes) {
1031
-              $record[$attributes['column']] = $node->{$field_name}[0][$column];
1032
-            }
999
+          $item = array();
1000
+          $field = content_fields($field_name, $type_name);
1001
+          $db_info = content_database_info($field);
1002
+          // For each column declared by the field, populate the item.
1003
+          foreach ($db_info['columns'] as $column => $attributes) {
1004
+            $item[$column] = $row[$attributes['column']];
1033 1005
           }
1006
+
1007
+          // Add the item to the field values for the node.
1008
+          if (!isset($additions[$field_name])) {
1009
+            $additions[$field_name] = array();
1010
+          }
1011
+          $additions[$field_name][] = $item;
1034 1012
         }
1035
-        // $record might be empty because
1036
-        // - the table stores a multiple field :
1037
-        //   we do nothing, this is handled later on
1038
-        // - this is the per-type table and no field is actually stored in it :
1039
-        //   we still store the nid and vid
1040
-        if (count($record) || empty($schema['content fields'])) {
1041
-          $record['nid'] = $node->nid;
1042
-          $record['vid'] = $node->vid;
1043
-          // Can't rely on the insert/update op of the node to decide if this
1044
-          // is an insert or an update, a node or revision may have existed
1045
-          // before any fields were created, so there may not be an entry here.
1046
-
1047
-          // TODO - should we auto create an entry for all existing nodes when
1048
-          // fields are added to content types -- either a NULL value
1049
-          // or the default value? May need to offer the user an option of
1050
-          // how to handle that.
1051
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1052
-            content_write_record($table, $record, array('vid'));
1013
+      }
1014
+    }
1015
+    return $additions;
1016
+
1017
+  case 'insert':
1018
+  case 'update':
1019
+    foreach ($type['tables'] as $table) {
1020
+      $schema = drupal_get_schema($table);
1021
+      $record = array();
1022
+      foreach ($schema['content fields'] as $field_name) {
1023
+        if (isset($node->$field_name)) {
1024
+          $field = content_fields($field_name, $type_name);
1025
+          // Multiple fields need specific handling, we'll deal with them later on.
1026
+          if ($field['multiple']) {
1027
+            continue;
1053 1028
           }
1054
-          else {
1055
-            content_write_record($table, $record);
1029
+          $db_info = content_database_info($field);
1030
+          foreach ($db_info['columns'] as $column => $attributes) {
1031
+            $record[$attributes['column']] = $node->{$field_name}[0][$column];
1056 1032
           }
1057 1033
         }
1058 1034
       }
1035
+      // $record might be empty because
1036
+      // - the table stores a multiple field :
1037
+      //   we do nothing, this is handled later on
1038
+      // - this is the per-type table and no field is actually stored in it :
1039
+      //   we still store the nid and vid
1040
+      if (count($record) || empty($schema['content fields'])) {
1041
+        $record['nid'] = $node->nid;
1042
+        $record['vid'] = $node->vid;
1043
+        // Can't rely on the insert/update op of the node to decide if this
1044
+        // is an insert or an update, a node or revision may have existed
1045
+        // before any fields were created, so there may not be an entry here.
1046
+
1047
+        // TODO - should we auto create an entry for all existing nodes when
1048
+        // fields are added to content types -- either a NULL value
1049
+        // or the default value? May need to offer the user an option of
1050
+        // how to handle that.
1051
+        if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1052
+          content_write_record($table, $record, array('vid'));
1053
+        }
1054
+        else {
1055
+          content_write_record($table, $record);
1056
+        }
1057
+      }
1058
+    }
1059 1059
 
1060
-      // Handle multiple fields.
1061
-      foreach ($type['fields'] as $field) {
1062
-        if ($field['multiple'] && isset($node->$field['field_name'])) {
1063
-          $db_info = content_database_info($field);
1064
-          // Delete and insert, rather than update, in case a value was added.
1065
-          if ($op == 'update') {
1066
-            db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
1067
-          }
1068
-          foreach ($node->$field['field_name'] as $delta => $item) {
1069
-            $record = array();
1070
-            foreach ($db_info['columns'] as $column => $attributes) {
1071
-              $record[$attributes['column']] = $item[$column];
1072
-            }
1073
-            $record['nid'] = $node->nid;
1074
-            $record['vid'] = $node->vid;
1075
-            $record['delta'] = $delta;
1076
-            content_write_record($db_info['table'], $record);
1060
+    // Handle multiple fields.
1061
+    foreach ($type['fields'] as $field) {
1062
+      if ($field['multiple'] && isset($node->$field['field_name'])) {
1063
+        $db_info = content_database_info($field);
1064
+        // Delete and insert, rather than update, in case a value was added.
1065
+        if ($op == 'update') {
1066
+          db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
1067
+        }
1068
+        foreach ($node->$field['field_name'] as $delta => $item) {
1069
+          $record = array();
1070
+          foreach ($db_info['columns'] as $column => $attributes) {
1071
+            $record[$attributes['column']] = $item[$column];
1077 1072
           }
1073
+          $record['nid'] = $node->nid;
1074
+          $record['vid'] = $node->vid;
1075
+          $record['delta'] = $delta;
1076
+          content_write_record($db_info['table'], $record);
1078 1077
         }
1079 1078
       }
1080
-      break;
1079
+    }
1080
+    break;
1081 1081
 
1082
-    case 'delete':
1083
-      foreach ($type['tables'] as $table) {
1084
-        db_query('DELETE FROM {'. $table .'} WHERE nid = %d', $node->nid);
1085
-      }
1086
-      break;
1082
+  case 'delete':
1083
+    foreach ($type['tables'] as $table) {
1084
+      db_query('DELETE FROM {'. $table .'} WHERE nid = %d', $node->nid);
1085
+    }
1086
+    break;
1087 1087
 
1088
-    case 'delete revision':
1089
-      foreach ($type['tables'] as $table) {
1090
-        db_query('DELETE FROM {'. $table .'} WHERE vid = %d', $node->vid);
1091
-      }
1092
-      break;
1088
+  case 'delete revision':
1089
+    foreach ($type['tables'] as $table) {
1090
+      db_query('DELETE FROM {'. $table .'} WHERE vid = %d', $node->vid);
1091
+    }
1092
+    break;
1093 1093
   }
1094 1094
 }
1095 1095
 
@@ -1526,18 +1526,18 @@  discard block
 block discarded – undo
1526 1526
  */
1527 1527
 function content_node_type($op, $info) {
1528 1528
   switch ($op) {
1529
-    case 'insert':
1530
-      module_load_include('inc', 'content', 'includes/content.crud');
1531
-      content_type_create($info);
1532
-      break;
1533
-    case 'update':
1534
-      module_load_include('inc', 'content', 'includes/content.crud');
1535
-      content_type_update($info);
1536
-      break;
1537
-    case 'delete':
1538
-      module_load_include('inc', 'content', 'includes/content.crud');
1539
-      content_type_delete($info);
1540
-      break;
1529
+  case 'insert':
1530
+    module_load_include('inc', 'content', 'includes/content.crud');
1531
+    content_type_create($info);
1532
+    break;
1533
+  case 'update':
1534
+    module_load_include('inc', 'content', 'includes/content.crud');
1535
+    content_type_update($info);
1536
+    break;
1537
+  case 'delete':
1538
+    module_load_include('inc', 'content', 'includes/content.crud');
1539
+    content_type_delete($info);
1540
+    break;
1541 1541
   }
1542 1542
 }
1543 1543
 
@@ -1994,14 +1994,14 @@  discard block
 block discarded – undo
1994 1994
 
1995 1995
   $name = str_replace('-', '_', $name);
1996 1996
   switch ("$version-$storage") {
1997
-    case '0-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1998
-      return "node_$name";
1999
-    case '0-'. CONTENT_DB_STORAGE_PER_FIELD :
2000
-      return "node_data_$name";
2001
-    case '1003-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
2002
-      return "content_type_$name";
2003
-    case '1003-'. CONTENT_DB_STORAGE_PER_FIELD :
2004
-      return "content_$name";
1997
+  case '0-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1998
+    return "node_$name";
1999
+  case '0-'. CONTENT_DB_STORAGE_PER_FIELD :
2000
+    return "node_data_$name";
2001
+  case '1003-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
2002
+    return "content_type_$name";
2003
+  case '1003-'. CONTENT_DB_STORAGE_PER_FIELD :
2004
+    return "content_$name";
2005 2005
   }
2006 2006
 }
2007 2007
 
@@ -2153,13 +2153,13 @@  discard block
 block discarded – undo
2153 2153
  */
2154 2154
 function content_callback($entity, $op, $field) {
2155 2155
   switch ($entity) {
2156
-    case 'field':
2157
-      $info = module_invoke($field['module'], "field_info");
2158
-      return isset($info[$field['type']]['callbacks'][$op]) ? $info[$field['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2156
+  case 'field':
2157
+    $info = module_invoke($field['module'], "field_info");
2158
+    return isset($info[$field['type']]['callbacks'][$op]) ? $info[$field['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2159 2159
 
2160
-    case 'widget':
2161
-      $info = module_invoke($field['widget']['module'], "widget_info");
2162
-      return isset($info[$field['widget']['type']]['callbacks'][$op]) ? $info[$field['widget']['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2160
+  case 'widget':
2161
+    $info = module_invoke($field['widget']['module'], "widget_info");
2162
+    return isset($info[$field['widget']['type']]['callbacks'][$op]) ? $info[$field['widget']['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2163 2163
   }
2164 2164
 }
2165 2165
 
@@ -2183,18 +2183,18 @@  discard block
 block discarded – undo
2183 2183
  */
2184 2184
 function content_handle($entity, $op, $object) {
2185 2185
   switch ($entity) {
2186
-    case 'field':
2187
-      $info = module_invoke($object['module'], "field_info");
2188
-      return isset($info[$object['type']][$op]) ? $info[$object['type']][$op] : CONTENT_HANDLE_CORE;
2189
-
2190
-    case 'widget':
2191
-      $info = module_invoke($object['widget']['module'], "widget_info");
2192
-      return isset($info[$object['widget']['type']][$op]) ? $info[$object['widget']['type']][$op] : CONTENT_HANDLE_CORE;
2193
-
2194
-    case 'formatter':
2195
-      // Much simpler, formatters arrays *are* the 'formatter_info' itself.
2196
-      // We let content_handle deal with them only for code consistency.
2197
-      return isset($object[$op]) ? $object[$op] : CONTENT_HANDLE_CORE;
2186
+  case 'field':
2187
+    $info = module_invoke($object['module'], "field_info");
2188
+    return isset($info[$object['type']][$op]) ? $info[$object['type']][$op] : CONTENT_HANDLE_CORE;
2189
+
2190
+  case 'widget':
2191
+    $info = module_invoke($object['widget']['module'], "widget_info");
2192
+    return isset($info[$object['widget']['type']][$op]) ? $info[$object['widget']['type']][$op] : CONTENT_HANDLE_CORE;
2193
+
2194
+  case 'formatter':
2195
+    // Much simpler, formatters arrays *are* the 'formatter_info' itself.
2196
+    // We let content_handle deal with them only for code consistency.
2197
+    return isset($object[$op]) ? $object[$op] : CONTENT_HANDLE_CORE;
2198 2198
   }
2199 2199
 }
2200 2200
 
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 function content_help($path, $arg) {
19 19
   switch ($path) {
20 20
     case 'admin/help#content':
21
-      $output = '<p>'. t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))) .'</p>';
22
-      $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
-      $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
21
+      $output = '<p>'.t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))).'</p>';
22
+      $output .= '<p>'.t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.').'</p>';
23
+      $output .= '<p>'.t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))).'</p>';
24 24
       $output .= '<ul>';
25
-      $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
-      $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
-      $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
-      $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
-      $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
25
+      $output .= '<li>'.t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.').'</li>';
26
+      $output .= '<li>'.t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.").'</li>';
27
+      $output .= '<li>'.t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).').'</li>';
28
+      $output .= '<li>'.t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.').'</li>';
29
+      $output .= '<li>'.t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.').'</li>';
30 30
       $output .= '</ul>';
31
-      $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
31
+      $output .= '<p>'.t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')).'</p>';
32 32
       return $output;
33 33
   }
34 34
 }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  * Implementation of hook_init().
45 45
  */
46 46
 function content_init() {
47
-  drupal_add_css(drupal_get_path('module', 'content') .'/theme/content-module.css');
47
+  drupal_add_css(drupal_get_path('module', 'content').'/theme/content-module.css');
48 48
   if (module_exists('token') && !function_exists('content_token_values')) {
49 49
     module_load_include('inc', 'content', 'includes/content.token');
50 50
   }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
   // Customize the content types page with our own callback
68 68
   $items['admin/content/types']['page callback'] = 'content_types_overview';
69 69
   $items['admin/content/types']['file'] = 'content.admin.inc';
70
-  $items['admin/content/types']['file path'] = drupal_get_path('module', 'content') .'/includes';
70
+  $items['admin/content/types']['file path'] = drupal_get_path('module', 'content').'/includes';
71 71
 }
72 72
 
73 73
 /**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
       $type_name = $type->type;
98 98
       $content_type = content_types($type_name);
99 99
       $type_url_str = $content_type['url_str'];
100
-      $items['admin/content/node-type/'. $type_url_str .'/fields'] = array(
100
+      $items['admin/content/node-type/'.$type_url_str.'/fields'] = array(
101 101
         'title' => 'Manage fields',
102 102
         'page callback' => 'drupal_get_form',
103 103
         'page arguments' => array('content_field_overview_form', $type_name),
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         'type' => MENU_LOCAL_TASK,
107 107
         'weight' => 1,
108 108
       );
109
-      $items['admin/content/node-type/'. $type_url_str .'/display'] = array(
109
+      $items['admin/content/node-type/'.$type_url_str.'/display'] = array(
110 110
         'title' => 'Display fields',
111 111
         'page callback' => 'drupal_get_form',
112 112
         'page arguments' => array('content_display_overview_form', $type_name),
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
       );
118 118
       $contexts = content_build_modes('_tabs');
119 119
       foreach ($contexts as $key => $tab) {
120
-        $items['admin/content/node-type/'. $type_url_str .'/display/'. $key] = array(
120
+        $items['admin/content/node-type/'.$type_url_str.'/display/'.$key] = array(
121 121
           'title' => $tab['title'],
122 122
           'page arguments' => array('content_display_overview_form', $type_name, $key),
123 123
           'access arguments' => array('administer content types'),
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
       }
128 128
       // Cast as an array in case this is called before any fields have
129 129
       // been added, like when a new content type is created.
130
-      foreach ((array) $content_type['fields'] as $field) {
130
+      foreach ((array)$content_type['fields'] as $field) {
131 131
         $field_name = $field['field_name'];
132
-        $items['admin/content/node-type/'. $type_url_str .'/fields/'. $field_name] = array(
132
+        $items['admin/content/node-type/'.$type_url_str.'/fields/'.$field_name] = array(
133 133
           'title' => $field['widget']['label'],
134 134
           'page callback' => 'drupal_get_form',
135 135
           'page arguments' => array('content_field_edit_form', $type_name, $field_name),
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
           'file' => 'includes/content.admin.inc',
138 138
           'type' => MENU_LOCAL_TASK,
139 139
         );
140
-        $items['admin/content/node-type/'. $type_url_str .'/fields/'. $field_name .'/remove'] = array(
140
+        $items['admin/content/node-type/'.$type_url_str.'/fields/'.$field_name.'/remove'] = array(
141 141
           'title' => 'Remove field',
142 142
           'page callback' => 'drupal_get_form',
143 143
           'page arguments' => array('content_field_remove_form', $type_name, $field_name),
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
  * Implementation of hook_theme().
174 174
  */
175 175
 function content_theme() {
176
-  $path = drupal_get_path('module', 'content') .'/theme';
176
+  $path = drupal_get_path('module', 'content').'/theme';
177 177
   require_once "./$path/theme.inc";
178 178
 
179 179
   return array(
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 function content_views_api() {
216 216
   return array(
217 217
     'api' => 2,
218
-    'path' => drupal_get_path('module', 'content') . '/includes/views',
218
+    'path' => drupal_get_path('module', 'content').'/includes/views',
219 219
   );
220 220
 }
221 221
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
  */
225 225
 function content_ctools_plugin_directory($module, $plugin) {
226 226
   if ($module == 'ctools' && $plugin == 'content_types') {
227
-    return 'includes/panels/' . $plugin;
227
+    return 'includes/panels/'.$plugin;
228 228
   }
229 229
 }
230 230
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
  * cache the loaded object structure and invalidate it during the update process.
238 238
  */
239 239
 function content_load(&$node) {
240
-  $cid = 'content:'. $node->nid .':'. $node->vid;
240
+  $cid = 'content:'.$node->nid.':'.$node->vid;
241 241
   if ($cached = cache_get($cid, content_cache_tablename())) {
242 242
     foreach ($cached->data as $key => $value) {
243 243
       $node->$key = $value;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 function content_update(&$node) {
298 298
   _content_field_invoke('update', $node);
299 299
   _content_field_invoke_default('update', $node);
300
-  cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
300
+  cache_clear_all('content:'.$node->nid.':'.$node->vid, content_cache_tablename());
301 301
 }
302 302
 
303 303
 /**
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 function content_delete(&$node) {
309 309
   _content_field_invoke('delete', $node);
310 310
   _content_field_invoke_default('delete', $node);
311
-  cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), TRUE);
311
+  cache_clear_all('content:'.$node->nid.':', content_cache_tablename(), TRUE);
312 312
 }
313 313
 
314 314
 /**
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 function content_delete_revision(&$node) {
320 320
   _content_field_invoke('delete revision', $node);
321 321
   _content_field_invoke_default('delete revision', $node);
322
-  cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
322
+  cache_clear_all('content:'.$node->nid.':'.$node->vid, content_cache_tablename());
323 323
 }
324 324
 
325 325
 /**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
   // Merge fields.
335 335
   $additions = _content_field_invoke_default('view', $node, $teaser, $page);
336
-  $node->content = array_merge((array) $node->content, $additions);
336
+  $node->content = array_merge((array)$node->content, $additions);
337 337
 }
338 338
 
339 339
 /**
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     // One-field equivalent to _content_field_invoke('sanitize').
372 372
     $field_types = _content_field_types();
373 373
     $module = $field_types[$field['type']]['module'];
374
-    $function = $module .'_field';
374
+    $function = $module.'_field';
375 375
     if (function_exists($function)) {
376 376
       $function('sanitize', $node, $field, $items, $teaser, $page);
377 377
       $node->$field['field_name'] = $items;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
   $additions = _content_field_invoke('prepare translation', $node);
406 406
   // Merge module additions after the default ones to enable overriding
407 407
   // of field values.
408
-  $node = (object) array_merge((array) $node, $default_additions, $additions);
408
+  $node = (object)array_merge((array)$node, $default_additions, $additions);
409 409
 }
410 410
 
411 411
 /**
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
     $type = content_types($node->type);
418 418
     // Save cycles if the type has no CCK fields.
419 419
     if (!empty($type['fields'])) {
420
-      $callback = 'content_'. str_replace(' ', '_', $op);
420
+      $callback = 'content_'.str_replace(' ', '_', $op);
421 421
       if (function_exists($callback)) {
422 422
         $callback($node, $a3, $a4);
423 423
       }
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
  *  Implementation of hook_form_alter().
437 437
  */
438 438
 function content_form_alter(&$form, $form_state, $form_id) {
439
-  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
439
+  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'].'_node_form' == $form_id) {
440 440
     $type = content_types($form['#node']->type);
441 441
     if (!empty($type['fields'])) {
442 442
       module_load_include('inc', 'content', 'includes/content.node_form');
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
   $output = '';
488 488
 
489 489
   if ($field['multiple'] >= 1) {
490
-    $table_id = $element['#field_name'] .'_values';
491
-    $order_class = $element['#field_name'] .'-delta-order';
492
-    $required = !empty($element['#required']) ? '<span class="form-required" title="'. t('This field is required.') .'">*</span>' : '';
490
+    $table_id = $element['#field_name'].'_values';
491
+    $order_class = $element['#field_name'].'-delta-order';
492
+    $required = !empty($element['#required']) ? '<span class="form-required" title="'.t('This field is required.').'">*</span>' : '';
493 493
 
494 494
     $header = array(
495 495
       array(
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
     // preview or failed validation)
505 505
     $items = array();
506 506
     foreach (element_children($element) as $key) {
507
-      if ($key !== $element['#field_name'] .'_add_more') {
507
+      if ($key !== $element['#field_name'].'_add_more') {
508 508
         $items[] = &$element[$key];
509 509
       }
510 510
     }
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
     }
527 527
 
528 528
     $output .= theme('table', $header, $rows, array('id' => $table_id, 'class' => 'content-multiple-table'));
529
-    $output .= $element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '';
530
-    $output .= drupal_render($element[$element['#field_name'] .'_add_more']);
529
+    $output .= $element['#description'] ? '<div class="description">'.$element['#description'].'</div>' : '';
530
+    $output .= drupal_render($element[$element['#field_name'].'_add_more']);
531 531
 
532 532
     drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
533 533
   }
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
       if (variable_get('content_schema_version', -1) < 6007) {
571 571
         return FALSE;
572 572
       }
573
-      db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
573
+      db_query("UPDATE {".content_field_tablename()."} SET active=0 WHERE module='%s'", $module);
574
+      db_query("UPDATE {".content_instance_tablename()."} SET widget_active=0 WHERE widget_module='%s'", $module);
575 575
       content_clear_type_cache(TRUE);
576 576
       break;
577 577
   }
@@ -593,14 +593,14 @@  discard block
 block discarded – undo
593 593
   if ($module_fields) {
594 594
     foreach ($module_fields as $name => $field_info) {
595 595
       watchdog('content', 'Updating field type %type with module %module.', array('%type' => $name, '%module' => $module));
596
-      db_query("UPDATE {". content_field_tablename() ."} SET module = '%s', active = %d WHERE type = '%s'", $module, 1, $name);
596
+      db_query("UPDATE {".content_field_tablename()."} SET module = '%s', active = %d WHERE type = '%s'", $module, 1, $name);
597 597
     }
598 598
   }
599 599
   $module_widgets = module_invoke($module, 'widget_info');
600 600
   if ($module_widgets) {
601 601
     foreach ($module_widgets as $name => $widget_info) {
602 602
       watchdog('content', 'Updating widget type %type with module %module.', array('%type' => $name, '%module' => $module));
603
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_module = '%s', widget_active = %d WHERE widget_type = '%s'", $module, 1, $name);
603
+      db_query("UPDATE {".content_instance_tablename()."} SET widget_module = '%s', widget_active = %d WHERE widget_type = '%s'", $module, 1, $name);
604 604
     }
605 605
   }
606 606
   // This is called from updates and installs, so get the install-safe
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
   foreach ($types as $type_name => $fields) {
612 612
     foreach ($fields as $field) {
613 613
       if ($field['module'] == $module && !in_array($field['field_name'], $fields_set)) {
614
-        $columns = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field);
615
-        db_query("UPDATE {". content_field_tablename() ."} SET db_columns = '%s' WHERE field_name = '%s'", serialize($columns), $field['field_name']);
614
+        $columns = (array)module_invoke($field['module'], 'field_settings', 'database columns', $field);
615
+        db_query("UPDATE {".content_field_tablename()."} SET db_columns = '%s' WHERE field_name = '%s'", serialize($columns), $field['field_name']);
616 616
         $fields_set[] = $field['field_name'];
617 617
       }
618 618
     }
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 
697 697
     case 'presave':
698 698
       if (!empty($node->devel_generate)) {
699
-        include_once('./'. drupal_get_path('module', 'content') .'/includes/content.devel.inc');
699
+        include_once('./'.drupal_get_path('module', 'content').'/includes/content.devel.inc');
700 700
         content_generate_fields($node, $field);
701 701
         $items = $node->{$field['field_name']};
702 702
       }
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 
716 716
       // If there was an AHAH add more button in this field, don't save it.
717 717
       // TODO: is it still needed ?
718
-      unset($items[$field['field_name'] .'_add_more']);
718
+      unset($items[$field['field_name'].'_add_more']);
719 719
 
720 720
       if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
721 721
         // Reorder items to account for drag-n-drop reordering.
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
       // enabled after the field was last edited.
753 753
       $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754 754
       if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
755
-        $theme = $formatter['module'] .'_formatter_'. $formatter_name;
755
+        $theme = $formatter['module'].'_formatter_'.$formatter_name;
756 756
         $single = (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE);
757 757
 
758 758
         $label_display = isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above';
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
               $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
846 846
             }
847 847
           }
848
-          elseif (isset($element['items']['#children']))  {
848
+          elseif (isset($element['items']['#children'])) {
849 849
             // Multiple values formatter.
850 850
             $items[0]['view'] = $element['items']['#children'];
851 851
           }
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 
874 874
       if ($wrapper) {
875 875
         // '#chilren' is not set if the field is empty.
876
-        $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
876
+        $addition[$field['field_name'].'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
877 877
       }
878 878
 
879 879
       return $addition;
@@ -901,8 +901,8 @@  discard block
 block discarded – undo
901 901
 function content_set_empty($field, $items) {
902 902
   // Filter out empty values.
903 903
   $filtered = array();
904
-  $function = $field['module'] .'_content_is_empty';
905
-  foreach ((array) $items as $delta => $item) {
904
+  $function = $field['module'].'_content_is_empty';
905
+  foreach ((array)$items as $delta => $item) {
906 906
     if (!$function($item, $field)) {
907 907
       $filtered[] = $item;
908 908
     }
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
         if (!$schema['content fields']) {
986 986
           continue;
987 987
         }
988
-        $query = 'SELECT * FROM {'. $table .'} WHERE vid = %d';
988
+        $query = 'SELECT * FROM {'.$table.'} WHERE vid = %d';
989 989
 
990 990
         // If we're loading a table for a multiple field,
991 991
         // we fetch all rows (values) ordered by delta,
992 992
         // else we only fetch one row.
993
-        $result = isset($schema['fields']['delta']) ? db_query($query .' ORDER BY delta', $node->vid) : db_query_range($query, $node->vid, 0, 1);
993
+        $result = isset($schema['fields']['delta']) ? db_query($query.' ORDER BY delta', $node->vid) : db_query_range($query, $node->vid, 0, 1);
994 994
 
995 995
         // For each table row, populate the fields.
996 996
         while ($row = db_fetch_array($result)) {
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
           // fields are added to content types -- either a NULL value
1049 1049
           // or the default value? May need to offer the user an option of
1050 1050
           // how to handle that.
1051
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1051
+          if (db_result(db_query("SELECT COUNT(*) FROM {".$table."} WHERE vid = %d", $node->vid))) {
1052 1052
             content_write_record($table, $record, array('vid'));
1053 1053
           }
1054 1054
           else {
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
           $db_info = content_database_info($field);
1064 1064
           // Delete and insert, rather than update, in case a value was added.
1065 1065
           if ($op == 'update') {
1066
-            db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
1066
+            db_query('DELETE FROM {'.$db_info['table'].'} WHERE vid = %d', $node->vid);
1067 1067
           }
1068 1068
           foreach ($node->$field['field_name'] as $delta => $item) {
1069 1069
             $record = array();
@@ -1081,13 +1081,13 @@  discard block
 block discarded – undo
1081 1081
 
1082 1082
     case 'delete':
1083 1083
       foreach ($type['tables'] as $table) {
1084
-        db_query('DELETE FROM {'. $table .'} WHERE nid = %d', $node->nid);
1084
+        db_query('DELETE FROM {'.$table.'} WHERE nid = %d', $node->nid);
1085 1085
       }
1086 1086
       break;
1087 1087
 
1088 1088
     case 'delete revision':
1089 1089
       foreach ($type['tables'] as $table) {
1090
-        db_query('DELETE FROM {'. $table .'} WHERE vid = %d', $node->vid);
1090
+        db_query('DELETE FROM {'.$table.'} WHERE vid = %d', $node->vid);
1091 1091
       }
1092 1092
       break;
1093 1093
   }
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 
1133 1133
   // Convert to an object if needed.
1134 1134
   if (is_array($object)) {
1135
-    $object = (object) $object;
1135
+    $object = (object)$object;
1136 1136
     $array = TRUE;
1137 1137
   }
1138 1138
   else {
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
   // Build the SQL.
1189 1189
   $query = '';
1190 1190
   if (!count($update)) {
1191
-    $query = "INSERT INTO {". $table ."} (". implode(', ', $fields) .') VALUES ('. implode(', ', $placeholders) .')';
1191
+    $query = "INSERT INTO {".$table."} (".implode(', ', $fields).') VALUES ('.implode(', ', $placeholders).')';
1192 1192
     $return = SAVED_NEW;
1193 1193
   }
1194 1194
   else {
@@ -1197,15 +1197,15 @@  discard block
 block discarded – undo
1197 1197
       if ($query) {
1198 1198
         $query .= ', ';
1199 1199
       }
1200
-      $query .= $field .' = '. $placeholders[$id];
1200
+      $query .= $field.' = '.$placeholders[$id];
1201 1201
     }
1202 1202
 
1203 1203
     foreach ($update as $key) {
1204
-      $conditions[] = "$key = ". db_type_placeholder($schema['fields'][$key]['type']);
1204
+      $conditions[] = "$key = ".db_type_placeholder($schema['fields'][$key]['type']);
1205 1205
       $values[] = $object->$key;
1206 1206
     }
1207 1207
 
1208
-    $query = "UPDATE {". $table ."} SET $query WHERE ". implode(' AND ', $conditions);
1208
+    $query = "UPDATE {".$table."} SET $query WHERE ".implode(' AND ', $conditions);
1209 1209
     $return = SAVED_UPDATED;
1210 1210
   }
1211 1211
 
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
 
1221 1221
     // If we began with an array, convert back so we don't surprise the caller.
1222 1222
     if ($array) {
1223
-      $object = (array) $object;
1223
+      $object = (array)$object;
1224 1224
     }
1225 1225
 
1226 1226
     return $return;
@@ -1245,10 +1245,10 @@  discard block
 block discarded – undo
1245 1245
     $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1246 1246
 
1247 1247
     // Make sure AHAH 'add more' button isn't sent to the fields for processing.
1248
-    unset($items[$field['field_name'] .'_add_more']);
1248
+    unset($items[$field['field_name'].'_add_more']);
1249 1249
 
1250 1250
     $module = $field_types[$field['type']]['module'];
1251
-    $function = $module .'_field';
1251
+    $function = $module.'_field';
1252 1252
     if (function_exists($function)) {
1253 1253
       $result = $function($op, $node, $field, $items, $teaser, $page);
1254 1254
       if (is_array($result)) {
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
       return array();
1409 1409
     }
1410 1410
 
1411
-    if (!$reset && $cached = cache_get('content_type_info:'. $language->language, content_cache_tablename())) {
1411
+    if (!$reset && $cached = cache_get('content_type_info:'.$language->language, content_cache_tablename())) {
1412 1412
       $info = $cached->data;
1413 1413
     }
1414 1414
     else {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
       // Populate actual field instances.
1470 1470
       module_load_include('inc', 'content', 'includes/content.crud');
1471 1471
       foreach (node_get_types('types', NULL, TRUE) as $type_name => $data) {
1472
-        $type = (array) $data;
1472
+        $type = (array)$data;
1473 1473
         $type['url_str'] = str_replace('_', '-', $type['type']);
1474 1474
         $type['fields'] = array();
1475 1475
         $type['tables'] = array();
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
         $extra = module_invoke_all('content_extra_fields', $type_name);
1503 1503
         drupal_alter('content_extra_fields', $extra, $type_name);
1504 1504
         // Add saved weights.
1505
-        foreach (variable_get('content_extra_weights_'. $type_name, array()) as $key => $value) {
1505
+        foreach (variable_get('content_extra_weights_'.$type_name, array()) as $key => $value) {
1506 1506
           // Some stored entries might not exist anymore, for instance if uploads
1507 1507
           // have been disabled, or vocabularies removed...
1508 1508
           if (isset($extra[$key])) {
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
         $info['content types'][$type_name] = $type;
1515 1515
       }
1516 1516
 
1517
-      cache_set('content_type_info:'. $language->language, $info, content_cache_tablename());
1517
+      cache_set('content_type_info:'.$language->language, $info, content_cache_tablename());
1518 1518
     }
1519 1519
   }
1520 1520
   return $info;
@@ -1585,10 +1585,10 @@  discard block
 block discarded – undo
1585 1585
     $db_info['table'] = _content_tablename($field['type_name'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1586 1586
   }
1587 1587
 
1588
-  $db_info['columns'] = (array) $field['columns'];
1588
+  $db_info['columns'] = (array)$field['columns'];
1589 1589
   // Generate column names for this field from generic column names.
1590 1590
   foreach ($db_info['columns'] as $column_name => $attributes) {
1591
-    $db_info['columns'][$column_name]['column'] = $field['field_name'] .'_'. $column_name;
1591
+    $db_info['columns'][$column_name]['column'] = $field['field_name'].'_'.$column_name;
1592 1592
   }
1593 1593
 
1594 1594
   return $db_info;
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
 function content_allowed_values($field, $flatten = TRUE) {
1683 1683
   static $allowed_values;
1684 1684
 
1685
-  $cid = $field['field_name'] .':'. ($flatten ? '1' : '0');
1685
+  $cid = $field['field_name'].':'.($flatten ? '1' : '0');
1686 1686
   if (isset($allowed_values[$cid])) {
1687 1687
     return $allowed_values[$cid];
1688 1688
   }
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
       $opt = content_filter_xss($opt);
1711 1711
       if (strpos($opt, '|') !== FALSE) {
1712 1712
         list($key, $value) = explode('|', $opt);
1713
-        $allowed_values[$cid][$key] = (isset($value) && $value !=='') ? $value : $key;
1713
+        $allowed_values[$cid][$key] = (isset($value) && $value !== '') ? $value : $key;
1714 1714
       }
1715 1715
       else {
1716 1716
         $allowed_values[$cid][$opt] = $opt;
@@ -1755,14 +1755,14 @@  discard block
 block discarded – undo
1755 1755
  * List of tags allowed by content_filter_xss().
1756 1756
  */
1757 1757
 function _content_filter_xss_allowed_tags() {
1758
-  return array('a', 'b', 'big',  'code', 'del', 'em', 'i', 'ins',  'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img');
1758
+  return array('a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins', 'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img');
1759 1759
 }
1760 1760
 
1761 1761
 /**
1762 1762
  * Human-readable list of allowed tags, for display in help texts.
1763 1763
  */
1764 1764
 function _content_filter_xss_display_allowed_tags() {
1765
-  return '<'. implode('> <', _content_filter_xss_allowed_tags()) .'>';
1765
+  return '<'.implode('> <', _content_filter_xss_allowed_tags()).'>';
1766 1766
 }
1767 1767
 
1768 1768
 /**
@@ -1795,12 +1795,12 @@  discard block
 block discarded – undo
1795 1795
   }
1796 1796
 
1797 1797
   if (content_access('view', $field, NULL, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1798
-    $theme = $formatter['module'] .'_formatter_'. $formatter_name;
1798
+    $theme = $formatter['module'].'_formatter_'.$formatter_name;
1799 1799
 
1800 1800
     $element = array(
1801 1801
       '#theme' => $theme,
1802 1802
       '#field_name' => $field['field_name'],
1803
-      '#type_name' => isset($node->type) ? $node->type :'',
1803
+      '#type_name' => isset($node->type) ? $node->type : '',
1804 1804
       '#formatter' => $formatter_name,
1805 1805
       '#node' => $node,
1806 1806
       '#delta' => isset($item['#delta']) ? $item['#delta'] : NULL,
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
 
1812 1812
       // hook_field('sanitize') expects an array of items, so we build one.
1813 1813
       $items = array($item);
1814
-      $function = $field['module'] .'_field';
1814
+      $function = $field['module'].'_field';
1815 1815
       if (function_exists($function)) {
1816 1816
         $function('sanitize', $node, $field, $items, FALSE, FALSE);
1817 1817
       }
@@ -1821,7 +1821,7 @@  discard block
 block discarded – undo
1821 1821
     else {
1822 1822
       // Multiple values formatter.
1823 1823
       $items = $item;
1824
-      $function = $field['module'] .'_field';
1824
+      $function = $field['module'].'_field';
1825 1825
       if (function_exists($function)) {
1826 1826
         $function('sanitize', $node, $field, $items, FALSE, FALSE);
1827 1827
       }
@@ -1856,13 +1856,13 @@  discard block
 block discarded – undo
1856 1856
   if (!isset($info)) {
1857 1857
     $data = array();
1858 1858
     foreach (module_implements('content_build_modes') as $module) {
1859
-      $function = $module .'_content_build_modes';
1860
-      $data = array_merge($data, (array) $function());
1859
+      $function = $module.'_content_build_modes';
1860
+      $data = array_merge($data, (array)$function());
1861 1861
     }
1862 1862
     $flat = array();
1863 1863
     foreach ($data as $tab) {
1864 1864
       // Use the + operator to preserve numeric indexes (core build modes).
1865
-      $flat += (array) $tab['build modes'];
1865
+      $flat += (array)$tab['build modes'];
1866 1866
     }
1867 1867
     $info = array('tabs' => $data, 'build modes' => $flat);
1868 1868
   }
@@ -1994,13 +1994,13 @@  discard block
 block discarded – undo
1994 1994
 
1995 1995
   $name = str_replace('-', '_', $name);
1996 1996
   switch ("$version-$storage") {
1997
-    case '0-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1997
+    case '0-'.CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1998 1998
       return "node_$name";
1999
-    case '0-'. CONTENT_DB_STORAGE_PER_FIELD :
1999
+    case '0-'.CONTENT_DB_STORAGE_PER_FIELD :
2000 2000
       return "node_data_$name";
2001
-    case '1003-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
2001
+    case '1003-'.CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
2002 2002
       return "content_type_$name";
2003
-    case '1003-'. CONTENT_DB_STORAGE_PER_FIELD :
2003
+    case '1003-'.CONTENT_DB_STORAGE_PER_FIELD :
2004 2004
       return "content_$name";
2005 2005
   }
2006 2006
 }
@@ -2083,7 +2083,7 @@  discard block
 block discarded – undo
2083 2083
 
2084 2084
   if (!empty($field['columns'])) {
2085 2085
     foreach ($field['columns'] as $column => $attributes) {
2086
-      $column_name =  $field['field_name'] .'_'. $column;
2086
+      $column_name = $field['field_name'].'_'.$column;
2087 2087
       if (isset($attributes['index']) && $attributes['index']) {
2088 2088
         $schema['indexes'][$column_name] = array($column_name);
2089 2089
         unset($attributes['index']);
@@ -2116,7 +2116,7 @@  discard block
 block discarded – undo
2116 2116
   if ($db_type == 'mysql' || $db_type == 'mysqli') {
2117 2117
     if (version_compare(db_version(), '5.0.3') < 0) {
2118 2118
       // Earlier versions of MySQL don't support a WHERE clause for SHOW.
2119
-      $result = db_query('SHOW INDEX FROM {'. $table .'}');
2119
+      $result = db_query('SHOW INDEX FROM {'.$table.'}');
2120 2120
       while ($row = db_fetch_array($result)) {
2121 2121
         if ($row['Key_name'] == $name) {
2122 2122
           return TRUE;
@@ -2124,12 +2124,12 @@  discard block
 block discarded – undo
2124 2124
       }
2125 2125
       return FALSE;
2126 2126
     }
2127
-    return (bool)db_result(db_query("SHOW INDEX FROM {". $table ."} WHERE key_name = '$name'"));
2127
+    return (bool)db_result(db_query("SHOW INDEX FROM {".$table."} WHERE key_name = '$name'"));
2128 2128
   }
2129 2129
   elseif ($db_type == 'pgsql') {
2130 2130
     // Note that the index names in Schema API for PostgreSQL are prefixed by
2131 2131
     // the table name and suffixed by '_idx'.
2132
-    return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{". $table ."}_{$name}_idx'"));
2132
+    return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{".$table."}_{$name}_idx'"));
2133 2133
   }
2134 2134
   return FALSE;
2135 2135
 }
@@ -2226,7 +2226,7 @@  discard block
 block discarded – undo
2226 2226
   elseif (!empty($field['widget']['default_value'])) {
2227 2227
     $default_value = $field['widget']['default_value'];
2228 2228
   }
2229
-  return (array) $default_value;
2229
+  return (array)$default_value;
2230 2230
 }
2231 2231
 
2232 2232
 /**
@@ -2373,7 +2373,7 @@  discard block
 block discarded – undo
2373 2373
       $variables['items'][$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
2374 2374
     }
2375 2375
   }
2376
-  else  {
2376
+  else {
2377 2377
     // Multiple values formatter.
2378 2378
     // We display the 'all items' output as $items[0], as if it was the
2379 2379
     // output of a single valued field.
@@ -2409,9 +2409,9 @@  discard block
 block discarded – undo
2409 2409
     'field_empty' => $field_empty,
2410 2410
     'template_files' => array(
2411 2411
       'content-field',
2412
-      'content-field-'. $element['#field_name'],
2413
-      'content-field-'. $element['#node']->type,
2414
-      'content-field-'. $element['#field_name'] .'-'. $element['#node']->type,
2412
+      'content-field-'.$element['#field_name'],
2413
+      'content-field-'.$element['#node']->type,
2414
+      'content-field-'.$element['#field_name'].'-'.$element['#node']->type,
2415 2415
     ),
2416 2416
   );
2417 2417
   $variables = array_merge($variables, $additions);
@@ -2629,7 +2629,7 @@  discard block
 block discarded – undo
2629 2629
       if (empty($type_name) || $content_type['type'] == $type_name) {
2630 2630
         foreach ($content_type['fields'] as $field) {
2631 2631
           $db_info = content_database_info($field);
2632
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $db_info['table'] ."}")) >= 1) {
2632
+          if (db_result(db_query("SELECT COUNT(*) FROM {".$db_info['table']."}")) >= 1) {
2633 2633
             return 0;
2634 2634
           }
2635 2635
         }
@@ -2642,10 +2642,10 @@  discard block
 block discarded – undo
2642 2642
   else {
2643 2643
     $db_info = content_database_info($field);
2644 2644
     if (!empty($type_name)) {
2645
-      $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2645
+      $delta = db_result(db_query("SELECT MAX(delta) FROM {".$db_info['table']."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2646 2646
     }
2647 2647
     else {
2648
-      $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."}"));
2648
+      $delta = db_result(db_query("SELECT MAX(delta) FROM {".$db_info['table']."}"));
2649 2649
     }
2650 2650
     if ($delta >= 0) {
2651 2651
       return $delta;
Please login to merge, or discard this patch.
Braces   +36 added lines, -72 removed lines patch added patch discarded remove patch
@@ -242,8 +242,7 @@  discard block
 block discarded – undo
242 242
     foreach ($cached->data as $key => $value) {
243 243
       $node->$key = $value;
244 244
     }
245
-  }
246
-  else {
245
+  } else {
247 246
     $default_additions = _content_field_invoke_default('load', $node);
248 247
     if ($default_additions) {
249 248
       foreach ($default_additions as $key => $value) {
@@ -458,8 +457,7 @@  discard block
 block discarded – undo
458 457
       // render arrays. Check we're not on a form first.
459 458
       if (!isset($elements['#build_id']) && isset($value['view']) && isset($elements[$value['view']])) {
460 459
         $elements[$value['view']]['#weight'] = $value['weight'];
461
-      }
462
-      elseif (isset($elements[$key])) {
460
+      } elseif (isset($elements[$key])) {
463 461
         $elements[$key]['#weight'] = $value['weight'];
464 462
       }
465 463
     }
@@ -530,8 +528,7 @@  discard block
 block discarded – undo
530 528
     $output .= drupal_render($element[$element['#field_name'] .'_add_more']);
531 529
 
532 530
     drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
533
-  }
534
-  else {
531
+  } else {
535 532
     foreach (element_children($element) as $key) {
536 533
       $output .= drupal_render($element[$key]);
537 534
     }
@@ -744,8 +741,7 @@  discard block
 block discarded – undo
744 741
       // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745 742
       if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
746 743
         $context = $teaser ? 'teaser' : 'full';
747
-      }
748
-      else {
744
+      } else {
749 745
         $context = $node->build_mode;
750 746
       }
751 747
       // The field may be missing info for $contexts added by modules
@@ -797,8 +793,7 @@  discard block
 block discarded – undo
797 793
             $element['items'][$delta] += $format_info;
798 794
             $element['items'][$delta]['#item']['#delta'] = $delta;
799 795
           }
800
-        }
801
-        else {
796
+        } else {
802 797
           $element['items'] += $format_info;
803 798
         }
804 799
 
@@ -829,8 +824,7 @@  discard block
 block discarded – undo
829 824
       $wrapper = NULL;
830 825
       if (isset($node->content[$field['field_name']])) {
831 826
         $wrapper = $node->content[$field['field_name']];
832
-      }
833
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
827
+      } elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
834 828
         $wrapper = $node->content[$group_name]['group'][$field['field_name']];
835 829
       }
836 830
 
@@ -844,13 +838,11 @@  discard block
 block discarded – undo
844 838
               // '#chilren' is not set if the field is empty.
845 839
               $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
846 840
             }
847
-          }
848
-          elseif (isset($element['items']['#children']))  {
841
+          } elseif (isset($element['items']['#children'])) {
849 842
             // Multiple values formatter.
850 843
             $items[0]['view'] = $element['items']['#children'];
851 844
           }
852
-        }
853
-        else {
845
+        } else {
854 846
           // Hidden or inaccessible field.
855 847
           $items[0]['view'] = '';
856 848
         }
@@ -866,8 +858,7 @@  discard block
 block discarded – undo
866 858
       $wrapper = NULL;
867 859
       if (isset($node->content[$field['field_name']])) {
868 860
         $wrapper = $node->content[$field['field_name']];
869
-      }
870
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
861
+      } elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
871 862
         $wrapper = $node->content[$group_name]['group'][$field['field_name']];
872 863
       }
873 864
 
@@ -1050,8 +1041,7 @@  discard block
 block discarded – undo
1050 1041
           // how to handle that.
1051 1042
           if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1052 1043
             content_write_record($table, $record, array('vid'));
1053
-          }
1054
-          else {
1044
+          } else {
1055 1045
             content_write_record($table, $record);
1056 1046
           }
1057 1047
         }
@@ -1134,8 +1124,7 @@  discard block
 block discarded – undo
1134 1124
   if (is_array($object)) {
1135 1125
     $object = (object) $object;
1136 1126
     $array = TRUE;
1137
-  }
1138
-  else {
1127
+  } else {
1139 1128
     $array = FALSE;
1140 1129
   }
1141 1130
 
@@ -1174,12 +1163,10 @@  discard block
 block discarded – undo
1174 1163
 
1175 1164
         if (empty($info['serialize'])) {
1176 1165
           $values[] = $object->$field;
1177
-        }
1178
-        else {
1166
+        } else {
1179 1167
           $values[] = serialize($object->$field);
1180 1168
         }
1181
-      }
1182
-      else {
1169
+      } else {
1183 1170
         $placeholders[] = 'NULL';
1184 1171
       }
1185 1172
     }
@@ -1190,8 +1177,7 @@  discard block
 block discarded – undo
1190 1177
   if (!count($update)) {
1191 1178
     $query = "INSERT INTO {". $table ."} (". implode(', ', $fields) .') VALUES ('. implode(', ', $placeholders) .')';
1192 1179
     $return = SAVED_NEW;
1193
-  }
1194
-  else {
1180
+  } else {
1195 1181
     $query = '';
1196 1182
     foreach ($fields as $id => $field) {
1197 1183
       if ($query) {
@@ -1253,8 +1239,7 @@  discard block
 block discarded – undo
1253 1239
       $result = $function($op, $node, $field, $items, $teaser, $page);
1254 1240
       if (is_array($result)) {
1255 1241
         $return = array_merge($return, $result);
1256
-      }
1257
-      else if (isset($result)) {
1242
+      } else if (isset($result)) {
1258 1243
         $return[] = $result;
1259 1244
       }
1260 1245
     }
@@ -1279,15 +1264,13 @@  discard block
 block discarded – undo
1279 1264
   // rather than by field.
1280 1265
   if (in_array($op, array('load', 'insert', 'update', 'delete', 'delete revision'))) {
1281 1266
     return content_storage($op, $node);
1282
-  }
1283
-  else {
1267
+  } else {
1284 1268
     foreach ($type['fields'] as $field) {
1285 1269
       $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1286 1270
       $result = content_field($op, $node, $field, $items, $teaser, $page);
1287 1271
       if (is_array($result)) {
1288 1272
         $return = array_merge($return, $result);
1289
-      }
1290
-      else if (isset($result)) {
1273
+      } else if (isset($result)) {
1291 1274
         $return[] = $result;
1292 1275
       }
1293 1276
       if (isset($node->$field['field_name'])) {
@@ -1410,8 +1393,7 @@  discard block
 block discarded – undo
1410 1393
 
1411 1394
     if (!$reset && $cached = cache_get('content_type_info:'. $language->language, content_cache_tablename())) {
1412 1395
       $info = $cached->data;
1413
-    }
1414
-    else {
1396
+    } else {
1415 1397
       $info = array(
1416 1398
         'field types' => array(),
1417 1399
         'widget types' => array(),
@@ -1580,8 +1562,7 @@  discard block
 block discarded – undo
1580 1562
   $db_info = array();
1581 1563
   if ($field['db_storage'] == CONTENT_DB_STORAGE_PER_FIELD) {
1582 1564
     $db_info['table'] = _content_tablename($field['field_name'], CONTENT_DB_STORAGE_PER_FIELD);
1583
-  }
1584
-  else {
1565
+  } else {
1585 1566
     $db_info['table'] = _content_tablename($field['type_name'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1586 1567
   }
1587 1568
 
@@ -1600,8 +1581,7 @@  discard block
 block discarded – undo
1600 1581
 function content_storage_type($field) {
1601 1582
   if ($field['multiple'] > 0) {
1602 1583
     return CONTENT_DB_STORAGE_PER_FIELD;
1603
-  }
1604
-  else {
1584
+  } else {
1605 1585
     module_load_include('inc', 'content', 'includes/content.crud');
1606 1586
     $instances = content_field_instance_read(array('field_name' => $field['field_name']));
1607 1587
     if (count($instances) > 1) {
@@ -1655,8 +1635,7 @@  discard block
 block discarded – undo
1655 1635
     foreach ($array as $key => $value) {
1656 1636
       if (is_array($value)) {
1657 1637
         $result += content_array_flatten($value);
1658
-      }
1659
-      else {
1638
+      } else {
1660 1639
         $result[$key] = $value;
1661 1640
       }
1662 1641
     }
@@ -1711,8 +1690,7 @@  discard block
 block discarded – undo
1711 1690
       if (strpos($opt, '|') !== FALSE) {
1712 1691
         list($key, $value) = explode('|', $opt);
1713 1692
         $allowed_values[$cid][$key] = (isset($value) && $value !=='') ? $value : $key;
1714
-      }
1715
-      else {
1693
+      } else {
1716 1694
         $allowed_values[$cid][$opt] = $opt;
1717 1695
       }
1718 1696
     }
@@ -1733,8 +1711,7 @@  discard block
 block discarded – undo
1733 1711
   foreach ($options as $key => $opt) {
1734 1712
     if (is_array($opt)) {
1735 1713
       content_allowed_values_filter_html($options[$key]);
1736
-    }
1737
-    else {
1714
+    } else {
1738 1715
       $options[$key] = html_entity_decode(strip_tags($opt), ENT_QUOTES);
1739 1716
     }
1740 1717
   }
@@ -1817,8 +1794,7 @@  discard block
 block discarded – undo
1817 1794
       }
1818 1795
 
1819 1796
       $element['#item'] = $items[0];
1820
-    }
1821
-    else {
1797
+    } else {
1822 1798
       // Multiple values formatter.
1823 1799
       $items = $item;
1824 1800
       $function = $field['module'] .'_field';
@@ -1869,11 +1845,9 @@  discard block
 block discarded – undo
1869 1845
 
1870 1846
   if ($selector === '_tabs') {
1871 1847
     return $info['tabs'];
1872
-  }
1873
-  elseif (isset($selector) && isset($info['tabs'][$selector])) {
1848
+  } elseif (isset($selector) && isset($info['tabs'][$selector])) {
1874 1849
     return isset($info['tabs'][$selector]) ? $info['tabs'][$selector]['build modes'] : array();
1875
-  }
1876
-  else {
1850
+  } else {
1877 1851
     return $info['build modes'];
1878 1852
   }
1879 1853
 }
@@ -1987,8 +1961,7 @@  discard block
 block discarded – undo
1987 1961
 
1988 1962
   if ($version < 1003) {
1989 1963
     $version = 0;
1990
-  }
1991
-  else {
1964
+  } else {
1992 1965
     $version = 1003;
1993 1966
   }
1994 1967
 
@@ -2042,8 +2015,7 @@  discard block
 block discarded – undo
2042 2015
 function content_cache_tablename() {
2043 2016
   if (variable_get('content_schema_version', -1) < 6000) {
2044 2017
     return 'cache';
2045
-  }
2046
-  else {
2018
+  } else {
2047 2019
     return 'cache_content';
2048 2020
   }
2049 2021
 }
@@ -2125,8 +2097,7 @@  discard block
 block discarded – undo
2125 2097
       return FALSE;
2126 2098
     }
2127 2099
     return (bool)db_result(db_query("SHOW INDEX FROM {". $table ."} WHERE key_name = '$name'"));
2128
-  }
2129
-  elseif ($db_type == 'pgsql') {
2100
+  } elseif ($db_type == 'pgsql') {
2130 2101
     // Note that the index names in Schema API for PostgreSQL are prefixed by
2131 2102
     // the table name and suffixed by '_idx'.
2132 2103
     return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{". $table ."}_{$name}_idx'"));
@@ -2222,8 +2193,7 @@  discard block
 block discarded – undo
2222 2193
     if (is_array($result)) {
2223 2194
       $default_value = $result;
2224 2195
     }
2225
-  }
2226
-  elseif (!empty($field['widget']['default_value'])) {
2196
+  } elseif (!empty($field['widget']['default_value'])) {
2227 2197
     $default_value = $field['widget']['default_value'];
2228 2198
   }
2229 2199
   return (array) $default_value;
@@ -2336,8 +2306,7 @@  discard block
 block discarded – undo
2336 2306
     || !is_array($object['display_settings'][$context])
2337 2307
     || empty($object['display_settings'][$context]['exclude'])) {
2338 2308
     return FALSE;
2339
-  }
2340
-  else {
2309
+  } else {
2341 2310
     return TRUE;
2342 2311
   }
2343 2312
 }
@@ -2372,8 +2341,7 @@  discard block
 block discarded – undo
2372 2341
       // Use isset() to avoid undefined index message on #children when field values are empty.
2373 2342
       $variables['items'][$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
2374 2343
     }
2375
-  }
2376
-  else  {
2344
+  } else {
2377 2345
     // Multiple values formatter.
2378 2346
     // We display the 'all items' output as $items[0], as if it was the
2379 2347
     // output of a single valued field.
@@ -2392,8 +2360,7 @@  discard block
 block discarded – undo
2392 2360
   foreach ($variables['items'] as $delta => $item) {
2393 2361
     if (!isset($item['view']) || (empty($item['view']) && (string)$item['view'] !== '0')) {
2394 2362
       $variables['items'][$delta]['empty'] = TRUE;
2395
-    }
2396
-    else {
2363
+    } else {
2397 2364
       $field_empty = FALSE;
2398 2365
       $variables['items'][$delta]['empty'] = FALSE;
2399 2366
     }
@@ -2643,8 +2610,7 @@  discard block
 block discarded – undo
2643 2610
     $db_info = content_database_info($field);
2644 2611
     if (!empty($type_name)) {
2645 2612
       $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2646
-    }
2647
-    else {
2613
+    } else {
2648 2614
       $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."}"));
2649 2615
     }
2650 2616
     if ($delta >= 0) {
@@ -2663,8 +2629,7 @@  discard block
 block discarded – undo
2663 2629
   if (!empty($type_name)) {
2664 2630
     $param = array('type_name' => $type_name);
2665 2631
     $inactive = array($type_name => array());
2666
-  }
2667
-  else {
2632
+  } else {
2668 2633
     $param = array();
2669 2634
     $inactive = array();
2670 2635
   }
@@ -2693,8 +2658,7 @@  discard block
 block discarded – undo
2693 2658
   if (!empty($type_name)) {
2694 2659
     $param = array('type_name' => $type_name);
2695 2660
     $inactive = array($type_name => array());
2696
-  }
2697
-  else {
2661
+  } else {
2698 2662
     $param = array();
2699 2663
     $inactive = array();
2700 2664
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
   return array(
180 180
     'content_field' => array(
181 181
       'template' => 'content-field',
182
-      'arguments' => array('element' => NULL),
182
+      'arguments' => array('element' => null),
183 183
       'path' => $path,
184 184
     ),
185 185
     'content_overview_links' => array(
@@ -189,22 +189,22 @@  discard block
 block discarded – undo
189 189
       'template' => 'content-admin-field-overview-form',
190 190
       'file' => 'theme.inc',
191 191
       'path' => $path,
192
-      'arguments' => array('form' => NULL),
192
+      'arguments' => array('form' => null),
193 193
     ),
194 194
     'content_display_overview_form' => array(
195 195
       'template' => 'content-admin-display-overview-form',
196 196
       'file' => 'theme.inc',
197 197
       'path' => $path,
198
-      'arguments' => array('form' => NULL),
198
+      'arguments' => array('form' => null),
199 199
     ),
200 200
     'content_exclude' => array(
201
-      'arguments' => array('content' => NULL, 'object' => array(), 'context' => NULL),
201
+      'arguments' => array('content' => null, 'object' => array(), 'context' => null),
202 202
     ),
203 203
     'content_view_multiple_field' => array(
204
-      'arguments' => array('items' => NULL, 'field' => NULL, 'data' => NULL),
204
+      'arguments' => array('items' => null, 'field' => null, 'data' => null),
205 205
     ),
206 206
     'content_multiple_values' => array(
207
-      'arguments' => array('element' => NULL),
207
+      'arguments' => array('element' => null),
208 208
     ),
209 209
   );
210 210
 }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
  * Implementation of hook_nodeapi 'validate' op.
266 266
  *
267 267
  */
268
-function content_validate(&$node, $form = NULL) {
268
+function content_validate(&$node, $form = null) {
269 269
   _content_field_invoke('validate', $node, $form);
270 270
   _content_field_invoke_default('validate', $node, $form);
271 271
 }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 function content_delete(&$node) {
309 309
   _content_field_invoke('delete', $node);
310 310
   _content_field_invoke_default('delete', $node);
311
-  cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), TRUE);
311
+  cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), true);
312 312
 }
313 313
 
314 314
 /**
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
  *
328 328
  * Generate field render arrays.
329 329
  */
330
-function content_view(&$node, $teaser = FALSE, $page = FALSE) {
330
+function content_view(&$node, $teaser = false, $page = false) {
331 331
   // Let field modules sanitize their data for output.
332 332
   _content_field_invoke('sanitize', $node, $teaser, $page);
333 333
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
  * @return
361 361
  *   The themed output for the field.
362 362
  */
363
-function content_view_field($field, $node, $teaser = FALSE, $page = FALSE) {
363
+function content_view_field($field, $node, $teaser = false, $page = false) {
364 364
   $output = '';
365 365
   if (isset($node->$field['field_name'])) {
366 366
     $items = $node->$field['field_name'];
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
  * Add back the formatted values in the 'view' element for all fields,
392 392
  * so that node templates can use it.
393 393
  */
394
-function content_alter(&$node, $teaser = FALSE, $page = FALSE) {
394
+function content_alter(&$node, $teaser = false, $page = false) {
395 395
   _content_field_invoke_default('alter', $node, $teaser, $page);
396 396
 }
397 397
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 /**
412 412
  * Implementation of hook_nodeapi().
413 413
  */
414
-function content_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
414
+function content_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
415 415
   // Prevent against invalid 'nodes' built by broken 3rd party code.
416 416
   if (isset($node->type)) {
417 417
     $type = content_types($node->type);
@@ -568,11 +568,11 @@  discard block
 block discarded – undo
568 568
       // When CCK modules are disabled before content module's update is run
569 569
       // to add the active column, we can't do this.
570 570
       if (variable_get('content_schema_version', -1) < 6007) {
571
-        return FALSE;
571
+        return false;
572 572
       }
573 573
       db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574 574
       db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
-      content_clear_type_cache(TRUE);
575
+      content_clear_type_cache(true);
576 576
       break;
577 577
   }
578 578
 }
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
   // When CCK modules are enabled before content module's update is run,
588 588
   // to add module and active columns, we can't do this.
589 589
   if (variable_get('content_schema_version', -1) < 6007) {
590
-    return FALSE;
590
+    return false;
591 591
   }
592 592
   $module_fields = module_invoke($module, 'field_info');
593 593
   if ($module_fields) {
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
       // Missing fields on node update are handled in content_storage().
709 709
       if (empty($items) && !isset($node->nid)) {
710 710
         foreach (array_keys($field['columns']) as $column) {
711
-          $items[0][$column] = NULL;
711
+          $items[0][$column] = null;
712 712
         }
713 713
         $node->$field['field_name'] = $items;
714 714
       }
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
           '#type' => 'content_field',
766 766
           '#title' => check_plain(t($field['widget']['label'])),
767 767
           '#field_name' => $field['field_name'],
768
-          '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
768
+          '#access' => $formatter_name != 'hidden' && content_access('view', $field, null, $node),
769 769
           '#label_display' => $label_display,
770 770
           '#node' => $node,
771 771
           '#teaser' => $teaser,
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 
827 827
       // The location of the field's rendered output depends on whether the
828 828
       // field is in a fieldgroup or not.
829
-      $wrapper = NULL;
829
+      $wrapper = null;
830 830
       if (isset($node->content[$field['field_name']])) {
831 831
         $wrapper = $node->content[$field['field_name']];
832 832
       }
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 
864 864
       // The location of the field's rendered output depends on whether the
865 865
       // field is in a fieldgroup or not.
866
-      $wrapper = NULL;
866
+      $wrapper = null;
867 867
       if (isset($node->content[$field['field_name']])) {
868 868
         $wrapper = $node->content[$field['field_name']];
869 869
       }
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
   // Make sure we store the right number of 'empty' values.
912 912
   $empty = array();
913 913
   foreach (array_keys($field['columns']) as $column) {
914
-    $empty[$column] = NULL;
914
+    $empty[$column] = null;
915 915
   }
916 916
   $pad = $field['multiple'] > 1 ? $field['multiple'] : 1;
917 917
   $filtered = array_pad($filtered, $pad, $empty);
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
   // Don't try this before content module's update is run to add
968 968
   // the active and module columns.
969 969
   if (variable_get('content_schema_version', -1) < 6007) {
970
-    return FALSE;
970
+    return false;
971 971
   }
972 972
 
973 973
   $type_name = $node->type;
@@ -1133,15 +1133,15 @@  discard block
 block discarded – undo
1133 1133
   // Convert to an object if needed.
1134 1134
   if (is_array($object)) {
1135 1135
     $object = (object) $object;
1136
-    $array = TRUE;
1136
+    $array = true;
1137 1137
   }
1138 1138
   else {
1139
-    $array = FALSE;
1139
+    $array = false;
1140 1140
   }
1141 1141
 
1142 1142
   $schema = drupal_get_schema($table);
1143 1143
   if (empty($schema)) {
1144
-    return FALSE;
1144
+    return false;
1145 1145
   }
1146 1146
 
1147 1147
   $fields = $defs = $values = $serials = $placeholders = array();
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
     return $return;
1227 1227
   }
1228 1228
 
1229
-  return FALSE;
1229
+  return false;
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
  * For each operation, both this function and _content_field_invoke_default() are
1236 1236
  * called so that the default database handling can occur.
1237 1237
  */
1238
-function _content_field_invoke($op, &$node, $teaser = NULL, $page = NULL) {
1238
+function _content_field_invoke($op, &$node, $teaser = null, $page = null) {
1239 1239
   $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1240 1240
   $type = content_types($type_name);
1241 1241
   $field_types = _content_field_types();
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
 /**
1270 1270
  * Invoke content.module's version of a field hook.
1271 1271
  */
1272
-function _content_field_invoke_default($op, &$node, $teaser = NULL, $page = NULL) {
1272
+function _content_field_invoke_default($op, &$node, $teaser = null, $page = null) {
1273 1273
   $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1274 1274
   $type = content_types($type_name);
1275 1275
   $field_types = _content_field_types();
@@ -1307,9 +1307,9 @@  discard block
 block discarded – undo
1307 1307
  * Do some type checking and set up empty arrays for missing
1308 1308
  * info to avoid foreach errors elsewhere in the code.
1309 1309
  */
1310
-function content_types($type_name = NULL) {
1310
+function content_types($type_name = null) {
1311 1311
   // handle type name with either an underscore or a dash
1312
-  $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : NULL;
1312
+  $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : null;
1313 1313
 
1314 1314
   $info = _content_type_info();
1315 1315
   if (isset($info['content types'])) {
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
  * content_type_name to avoid bad results when the value is set
1337 1337
  * but empty, as sometimes happens in the formatter.
1338 1338
  */
1339
-function content_fields($field_name = NULL, $content_type_name = NULL) {
1339
+function content_fields($field_name = null, $content_type_name = null) {
1340 1340
   $info = _content_type_info();
1341 1341
   if (isset($info['fields'])) {
1342 1342
     if (empty($field_name)) {
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
     $formatter_name = 'default';
1384 1384
   }
1385 1385
 
1386
-  return isset($formatters[$formatter_name]) ? $formatters[$formatter_name] : FALSE;
1386
+  return isset($formatters[$formatter_name]) ? $formatters[$formatter_name] : false;
1387 1387
 }
1388 1388
 
1389 1389
 /**
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
  * @param $reset
1393 1393
  *   If TRUE, clear the cache and fetch the information from the database again.
1394 1394
  */
1395
-function _content_type_info($reset = FALSE) {
1395
+function _content_type_info($reset = false) {
1396 1396
   global $language;
1397 1397
   static $info;
1398 1398
 
@@ -1468,7 +1468,7 @@  discard block
 block discarded – undo
1468 1468
 
1469 1469
       // Populate actual field instances.
1470 1470
       module_load_include('inc', 'content', 'includes/content.crud');
1471
-      foreach (node_get_types('types', NULL, TRUE) as $type_name => $data) {
1471
+      foreach (node_get_types('types', null, true) as $type_name => $data) {
1472 1472
         $type = (array) $data;
1473 1473
         $type['url_str'] = str_replace('_', '-', $type['type']);
1474 1474
         $type['fields'] = array();
@@ -1545,13 +1545,13 @@  discard block
 block discarded – undo
1545 1545
  * Clear the cache of content_types; called in several places when content
1546 1546
  * information is changed.
1547 1547
  */
1548
-function content_clear_type_cache($rebuild_schema = FALSE) {
1549
-  cache_clear_all('*', content_cache_tablename(), TRUE);
1550
-  _content_type_info(TRUE);
1548
+function content_clear_type_cache($rebuild_schema = false) {
1549
+  cache_clear_all('*', content_cache_tablename(), true);
1550
+  _content_type_info(true);
1551 1551
 
1552 1552
   // Refresh the schema to pick up new information.
1553 1553
   if ($rebuild_schema) {
1554
-    $schema = drupal_get_schema(NULL, TRUE);
1554
+    $schema = drupal_get_schema(null, true);
1555 1555
   }
1556 1556
 
1557 1557
   if (module_exists('views')) {
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
  *   FALSE can be used to support optgroups for select widgets
1680 1680
  *   when allowed values list is generated using PHP code.
1681 1681
  */
1682
-function content_allowed_values($field, $flatten = TRUE) {
1682
+function content_allowed_values($field, $flatten = true) {
1683 1683
   static $allowed_values;
1684 1684
 
1685 1685
   $cid = $field['field_name'] .':'. ($flatten ? '1' : '0');
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
     foreach ($list as $opt) {
1709 1709
       // Sanitize the user input with a permissive filter.
1710 1710
       $opt = content_filter_xss($opt);
1711
-      if (strpos($opt, '|') !== FALSE) {
1711
+      if (strpos($opt, '|') !== false) {
1712 1712
         list($key, $value) = explode('|', $opt);
1713 1713
         $allowed_values[$cid][$key] = (isset($value) && $value !=='') ? $value : $key;
1714 1714
       }
@@ -1789,12 +1789,12 @@  discard block
 block discarded – undo
1789 1789
  *   It will have been passed through the necessary check_plain() or check_markup()
1790 1790
  *   functions as necessary.
1791 1791
  */
1792
-function content_format($field, $item, $formatter_name = 'default', $node = NULL) {
1792
+function content_format($field, $item, $formatter_name = 'default', $node = null) {
1793 1793
   if (!is_array($field)) {
1794 1794
     $field = content_fields($field);
1795 1795
   }
1796 1796
 
1797
-  if (content_access('view', $field, NULL, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1797
+  if (content_access('view', $field, null, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1798 1798
     $theme = $formatter['module'] .'_formatter_'. $formatter_name;
1799 1799
 
1800 1800
     $element = array(
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
       '#type_name' => isset($node->type) ? $node->type :'',
1804 1804
       '#formatter' => $formatter_name,
1805 1805
       '#node' => $node,
1806
-      '#delta' => isset($item['#delta']) ? $item['#delta'] : NULL,
1806
+      '#delta' => isset($item['#delta']) ? $item['#delta'] : null,
1807 1807
     );
1808 1808
 
1809 1809
     if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) {
@@ -1813,7 +1813,7 @@  discard block
 block discarded – undo
1813 1813
       $items = array($item);
1814 1814
       $function = $field['module'] .'_field';
1815 1815
       if (function_exists($function)) {
1816
-        $function('sanitize', $node, $field, $items, FALSE, FALSE);
1816
+        $function('sanitize', $node, $field, $items, false, false);
1817 1817
       }
1818 1818
 
1819 1819
       $element['#item'] = $items[0];
@@ -1823,7 +1823,7 @@  discard block
 block discarded – undo
1823 1823
       $items = $item;
1824 1824
       $function = $field['module'] .'_field';
1825 1825
       if (function_exists($function)) {
1826
-        $function('sanitize', $node, $field, $items, FALSE, FALSE);
1826
+        $function('sanitize', $node, $field, $items, false, false);
1827 1827
       }
1828 1828
 
1829 1829
       foreach ($items as $delta => $item) {
@@ -1850,7 +1850,7 @@  discard block
 block discarded – undo
1850 1850
  *   - '_tabs': the list of tabs to be shown on the 'Display fields' screens.
1851 1851
  *   - a string tab id: the build modes in this tab.
1852 1852
  */
1853
-function content_build_modes($selector = NULL) {
1853
+function content_build_modes($selector = null) {
1854 1854
   static $info;
1855 1855
 
1856 1856
   if (!isset($info)) {
@@ -1920,11 +1920,11 @@  discard block
 block discarded – undo
1920 1920
       'build modes' => array(
1921 1921
         'teaser' => array(
1922 1922
           'title' => t('Teaser'),
1923
-          'views style' => TRUE,
1923
+          'views style' => true,
1924 1924
         ),
1925 1925
         'full' => array(
1926 1926
           'title' => t('Full node'),
1927
-          'views style' => TRUE,
1927
+          'views style' => true,
1928 1928
         ),
1929 1929
       ),
1930 1930
     ),
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
       'build modes' => array(
1934 1934
         NODE_BUILD_RSS => array(
1935 1935
           'title' => t('RSS'),
1936
-          'views style' => FALSE,
1936
+          'views style' => false,
1937 1937
         ),
1938 1938
       ),
1939 1939
     ),
@@ -1946,11 +1946,11 @@  discard block
 block discarded – undo
1946 1946
       'build modes' => array(
1947 1947
         NODE_BUILD_SEARCH_INDEX => array(
1948 1948
           'title' => t('Search Index'),
1949
-          'views style' => FALSE,
1949
+          'views style' => false,
1950 1950
         ),
1951 1951
         NODE_BUILD_SEARCH_RESULT => array(
1952 1952
           'title' => t('Search Result'),
1953
-          'views style' => FALSE,
1953
+          'views style' => false,
1954 1954
         ),
1955 1955
       ),
1956 1956
     ),
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
       'build modes' => array(
1964 1964
         NODE_BUILD_PRINT => array(
1965 1965
           'title' => t('Print'),
1966
-          'views style' => TRUE,
1966
+          'views style' => true,
1967 1967
         ),
1968 1968
       ),
1969 1969
     ),
@@ -1980,7 +1980,7 @@  discard block
 block discarded – undo
1980 1980
  * @return
1981 1981
  *   A string containing the generated name for the database table
1982 1982
  */
1983
-function _content_tablename($name, $storage, $version = NULL) {
1983
+function _content_tablename($name, $storage, $version = null) {
1984 1984
   if (is_null($version)) {
1985 1985
     $version = variable_get('content_schema_version', 0);
1986 1986
   }
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
  * to avoid conflicts with field tables that will be prefixed
2014 2014
  * with 'content_field'.
2015 2015
  */
2016
-function content_field_tablename($version = NULL) {
2016
+function content_field_tablename($version = null) {
2017 2017
   if (is_null($version)) {
2018 2018
     $version = variable_get('content_schema_version', 0);
2019 2019
   }
@@ -2025,7 +2025,7 @@  discard block
 block discarded – undo
2025 2025
  *
2026 2026
  * Needed because the table name changes depending on version.
2027 2027
  */
2028
-function content_instance_tablename($version = NULL) {
2028
+function content_instance_tablename($version = null) {
2029 2029
   if (is_null($version)) {
2030 2030
     $version = variable_get('content_schema_version', 0);
2031 2031
   }
@@ -2055,11 +2055,11 @@  discard block
 block discarded – undo
2055 2055
  * Leave $field['columns'] empty to get only the base schema,
2056 2056
  * otherwise the function will return the whole thing.
2057 2057
  */
2058
-function content_table_schema($field = NULL) {
2058
+function content_table_schema($field = null) {
2059 2059
   $schema = array(
2060 2060
     'fields' => array(
2061
-      'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
2062
-      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
2061
+      'vid' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0),
2062
+      'nid' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0)
2063 2063
     ),
2064 2064
     'primary key' => array('vid'),
2065 2065
     'indexes' => array(
@@ -2069,7 +2069,7 @@  discard block
 block discarded – undo
2069 2069
 
2070 2070
   // Add delta column if needed.
2071 2071
   if (!empty($field['multiple'])) {
2072
-    $schema['fields']['delta'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0);
2072
+    $schema['fields']['delta'] = array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0);
2073 2073
     $schema['primary key'][] = 'delta';
2074 2074
   }
2075 2075
   $schema['content fields'] = array();
@@ -2119,10 +2119,10 @@  discard block
 block discarded – undo
2119 2119
       $result = db_query('SHOW INDEX FROM {'. $table .'}');
2120 2120
       while ($row = db_fetch_array($result)) {
2121 2121
         if ($row['Key_name'] == $name) {
2122
-          return TRUE;
2122
+          return true;
2123 2123
         }
2124 2124
       }
2125
-      return FALSE;
2125
+      return false;
2126 2126
     }
2127 2127
     return (bool)db_result(db_query("SHOW INDEX FROM {". $table ."} WHERE key_name = '$name'"));
2128 2128
   }
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
     // the table name and suffixed by '_idx'.
2132 2132
     return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{". $table ."}_{$name}_idx'"));
2133 2133
   }
2134
-  return FALSE;
2134
+  return false;
2135 2135
 }
2136 2136
 
2137 2137
 /**
@@ -2246,7 +2246,7 @@  discard block
 block discarded – undo
2246 2246
  *   TRUE if the operation is allowed;
2247 2247
  *   FALSE if the operation is denied.
2248 2248
  */
2249
-function content_access($op, $field, $account = NULL, $node = NULL) {
2249
+function content_access($op, $field, $account = null, $node = null) {
2250 2250
   global $user;
2251 2251
 
2252 2252
   if (is_null($account)) {
@@ -2254,15 +2254,15 @@  discard block
 block discarded – undo
2254 2254
   }
2255 2255
   // Check for valid field data.
2256 2256
   if (!isset($field['field_name'])) {
2257
-    return FALSE;
2257
+    return false;
2258 2258
   }
2259 2259
   $access = module_invoke_all('field_access', $op, $field, $account, $node);
2260 2260
   foreach ($access as $value) {
2261
-    if ($value === FALSE) {
2262
-      return FALSE;
2261
+    if ($value === false) {
2262
+      return false;
2263 2263
     }
2264 2264
   }
2265
-  return TRUE;
2265
+  return true;
2266 2266
 }
2267 2267
 
2268 2268
  /**
@@ -2335,10 +2335,10 @@  discard block
 block discarded – undo
2335 2335
     || empty($object['display_settings'][$context])
2336 2336
     || !is_array($object['display_settings'][$context])
2337 2337
     || empty($object['display_settings'][$context]['exclude'])) {
2338
-    return FALSE;
2338
+    return false;
2339 2339
   }
2340 2340
   else {
2341
-    return TRUE;
2341
+    return true;
2342 2342
   }
2343 2343
 }
2344 2344
 
@@ -2387,15 +2387,15 @@  discard block
 block discarded – undo
2387 2387
   $variables['teaser'] = $element['#teaser'];
2388 2388
   $variables['page'] = $element['#page'];
2389 2389
 
2390
-  $field_empty = TRUE;
2390
+  $field_empty = true;
2391 2391
 
2392 2392
   foreach ($variables['items'] as $delta => $item) {
2393 2393
     if (!isset($item['view']) || (empty($item['view']) && (string)$item['view'] !== '0')) {
2394
-      $variables['items'][$delta]['empty'] = TRUE;
2394
+      $variables['items'][$delta]['empty'] = true;
2395 2395
     }
2396 2396
     else {
2397
-      $field_empty = FALSE;
2398
-      $variables['items'][$delta]['empty'] = FALSE;
2397
+      $field_empty = false;
2398
+      $variables['items'][$delta]['empty'] = false;
2399 2399
     }
2400 2400
   }
2401 2401
 
@@ -2549,7 +2549,7 @@  discard block
 block discarded – undo
2549 2549
       'weight' => -3
2550 2550
     );
2551 2551
   }
2552
-  if (module_exists('upload') && variable_get("upload_$type_name", TRUE)) {
2552
+  if (module_exists('upload') && variable_get("upload_$type_name", true)) {
2553 2553
     $extra['attachments'] = array(
2554 2554
       'label' => t('File attachments'),
2555 2555
       'description' => t('Upload module form.'),
@@ -2616,7 +2616,7 @@  discard block
 block discarded – undo
2616 2616
  * Fields with only NULL data will show up as being in use.
2617 2617
  * Do we want to eliminate them from the results?
2618 2618
  */
2619
-function content_max_delta($field_name, $type_name = NULL) {
2619
+function content_max_delta($field_name, $type_name = null) {
2620 2620
   $fields = content_fields();
2621 2621
   $field = $fields[$field_name];
2622 2622
 
@@ -2652,13 +2652,13 @@  discard block
 block discarded – undo
2652 2652
     }
2653 2653
   }
2654 2654
   // If we got this far, there is no data for this field.
2655
-  return NULL;
2655
+  return null;
2656 2656
 }
2657 2657
 
2658 2658
 /**
2659 2659
  * Helper function to identify inactive fields.
2660 2660
  */
2661
-function content_inactive_fields($type_name = NULL) {
2661
+function content_inactive_fields($type_name = null) {
2662 2662
   module_load_include('inc', 'content', 'includes/content.crud');
2663 2663
   if (!empty($type_name)) {
2664 2664
     $param = array('type_name' => $type_name);
@@ -2668,7 +2668,7 @@  discard block
 block discarded – undo
2668 2668
     $param = array();
2669 2669
     $inactive = array();
2670 2670
   }
2671
-  $all = content_field_instance_read($param, TRUE);
2671
+  $all = content_field_instance_read($param, true);
2672 2672
   $active = array_keys(content_fields());
2673 2673
   foreach ($all as $field) {
2674 2674
     if (!in_array($field['field_name'], $active)) {
@@ -2688,7 +2688,7 @@  discard block
 block discarded – undo
2688 2688
  * EXCEPT that his function will return inactive instances even 
2689 2689
  * if the fields have other (shared) instances that are still active.
2690 2690
  */
2691
-function content_inactive_instances($type_name = NULL) {
2691
+function content_inactive_instances($type_name = null) {
2692 2692
   module_load_include('inc', 'content', 'includes/content.crud');
2693 2693
   if (!empty($type_name)) {
2694 2694
     $param = array('type_name' => $type_name);
@@ -2698,7 +2698,7 @@  discard block
 block discarded – undo
2698 2698
     $param = array();
2699 2699
     $inactive = array();
2700 2700
   }
2701
-  $all = content_field_instance_read($param, TRUE);
2701
+  $all = content_field_instance_read($param, true);
2702 2702
   foreach ($all as $field) {
2703 2703
     $inactive[$field['type_name']][$field['field_name']] = content_field_instance_expand($field);
2704 2704
   }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/cck/includes/content.devel.inc 5 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -68,6 +68,7 @@
 block discarded – undo
68 68
  * custom multiple value widgets but don't need any other special multiple
69 69
  * values handling. This will call the field generation function
70 70
  * a random number of times and compile the results into a node array.
71
+ * @param string $function
71 72
  */
72 73
 function content_devel_multiple($function, $node, $field) {
73 74
   $node_field = array();
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -19,48 +19,48 @@  discard block
 block discarded – undo
19 19
  * information in each of its CCK fields.
20 20
  **/
21 21
 function content_generate_fields(&$node, $field) {
22
-  $type_name = $node->type;
23
-  $type = content_types($type_name);
24
-  $field_types = _content_field_types();
22
+    $type_name = $node->type;
23
+    $type = content_types($type_name);
24
+    $field_types = _content_field_types();
25 25
 
26
-  if (!empty($type['fields'])) {
26
+    if (!empty($type['fields'])) {
27 27
     foreach ($type['fields'] as $field) {
28
-      $node_field = array();
29
-      // If module handles own multiples, then only call its hook once.
30
-      if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
28
+        $node_field = array();
29
+        // If module handles own multiples, then only call its hook once.
30
+        if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
31 31
         $max = 0;
32
-      }
33
-      else {
32
+        }
33
+        else {
34 34
         switch ($field['multiple']) {
35
-          case 0:
35
+            case 0:
36 36
             $max = 0;
37 37
             break;
38
-          case 1:
38
+            case 1:
39 39
             $max = rand(0, 3); //just an arbitrary number for 'unlimited'
40 40
             break;
41
-          default:
41
+            default:
42 42
             $max = $field['multiple'];
43 43
             break;
44 44
         }
45
-      }
46
-      for ($i = 0; $i <= $max; $i++) {
45
+        }
46
+        for ($i = 0; $i <= $max; $i++) {
47 47
         $module = $field_types[$field['type']]['module'];
48 48
         $function = $module .'_content_generate';
49 49
         if (function_exists($function)) {
50
-          $result = $function($node, $field); // $items, $teaser, $page
51
-          if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
50
+            $result = $function($node, $field); // $items, $teaser, $page
51
+            if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
52 52
             // Fields that handle their own multiples will add their own deltas.
53 53
             $node_field = $result;
54
-          }
55
-          else {
54
+            }
55
+            else {
56 56
             // When multiples are handled by the content module, add a delta for each result.
57 57
             $node_field[$i] = $result;
58
-          }
58
+            }
59 59
         }
60
-      }
61
-      $node->{$field['field_name']} = $node_field;
60
+        }
61
+        $node->{$field['field_name']} = $node_field;
62
+    }
62 63
     }
63
-  }
64 64
 }
65 65
 
66 66
 /**
@@ -70,149 +70,149 @@  discard block
 block discarded – undo
70 70
  * a random number of times and compile the results into a node array.
71 71
  */
72 72
 function content_devel_multiple($function, $node, $field) {
73
-  $node_field = array();
74
-  if (function_exists($function)) {
73
+    $node_field = array();
74
+    if (function_exists($function)) {
75 75
     switch ($field['multiple']) {
76
-      case 0:
76
+        case 0:
77 77
         $max = 0;
78 78
         break;
79
-      case 1:
79
+        case 1:
80 80
         $max = rand(0, 3); //just an arbitrary number for 'unlimited'
81 81
         break;
82
-      default:
82
+        default:
83 83
         $max = $field['multiple'];
84 84
         break;
85 85
     }
86 86
     for ($i = 0; $i <= $max; $i++) {
87
-      $node_field[$i] = $function($node, $field);
87
+        $node_field[$i] = $function($node, $field);
88
+    }
88 89
     }
89
-  }
90
-  return $node_field;
90
+    return $node_field;
91 91
 }
92 92
 
93 93
 if (module_exists('text')) {
94
-  function text_content_generate($node, $field) {
94
+    function text_content_generate($node, $field) {
95 95
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
96
-      return content_devel_multiple('_text_content_generate', $node, $field);
96
+        return content_devel_multiple('_text_content_generate', $node, $field);
97 97
     }
98 98
     else {
99
-      return _text_content_generate($node, $field);
99
+        return _text_content_generate($node, $field);
100
+    }
100 101
     }
101
-  }
102 102
 
103
-  function _text_content_generate($node, $field) {
103
+    function _text_content_generate($node, $field) {
104 104
     $node_field = array();
105 105
     if ($field['widget']['type'] == 'text_textarea') {
106
-      $format = $field['text_processing'] ? rand(0, 3) : 0;
107
-      $node_field['value'] = devel_create_content($format);
108
-      $node_field['format'] = $format;
106
+        $format = $field['text_processing'] ? rand(0, 3) : 0;
107
+        $node_field['value'] = devel_create_content($format);
108
+        $node_field['format'] = $format;
109 109
     }
110 110
     else {
111
-      $allowed_values = content_allowed_values($field);
112
-      if (!empty($allowed_values)) {
111
+        $allowed_values = content_allowed_values($field);
112
+        if (!empty($allowed_values)) {
113 113
         // Just pick one of the specified allowed values.
114 114
         $node_field['value'] = array_rand($allowed_values);
115
-      }
116
-      else {
115
+        }
116
+        else {
117 117
         // Generate a value that respects max_length.
118 118
         if (empty($field['max_length'])) {
119
-          $field['max_length'] = 12;
119
+            $field['max_length'] = 12;
120 120
         }
121 121
         $node_field['value'] = user_password($field['max_length']);
122
-      }
122
+        }
123 123
     }
124 124
     return $node_field;
125
-  }
125
+    }
126 126
 }
127 127
 
128 128
 if (module_exists('number')) {
129
-  function number_content_generate($node, $field) {
129
+    function number_content_generate($node, $field) {
130 130
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
131
-      return content_devel_multiple('_number_content_generate', $node, $field);
131
+        return content_devel_multiple('_number_content_generate', $node, $field);
132 132
     }
133 133
     else {
134
-      return _number_content_generate($node, $field);
134
+        return _number_content_generate($node, $field);
135
+    }
135 136
     }
136
-  }
137 137
 
138
-  function _number_content_generate($node, $field) {
138
+    function _number_content_generate($node, $field) {
139 139
     $node_field = array();
140 140
     $allowed_values = content_allowed_values($field);
141 141
     if (!empty($allowed_values)) {
142
-      // Just pick one of the specified allowed values.
143
-      $node_field['value'] = array_rand($allowed_values);
142
+        // Just pick one of the specified allowed values.
143
+        $node_field['value'] = array_rand($allowed_values);
144 144
     }
145 145
     else {
146
-      $min = is_numeric($field['min']) ? $field['min'] : 0;
147
-      switch ($field['type']) {
146
+        $min = is_numeric($field['min']) ? $field['min'] : 0;
147
+        switch ($field['type']) {
148 148
         case 'number_integer':
149 149
           $max = is_numeric($field['max']) ? $field['max'] : 10000;
150
-          $decimal = 0;
151
-          $scale = 0;
152
-          break;
150
+            $decimal = 0;
151
+            $scale = 0;
152
+            break;
153 153
 
154 154
         case 'number_decimal':
155 155
           $precision = is_numeric($field['precision']) ? $field['precision'] : 10;
156
-          $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157
-          $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
-          $decimal = rand(0, (10 * $scale)) / 100;
159
-          break;
156
+            $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157
+            $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
+            $decimal = rand(0, (10 * $scale)) / 100;
159
+            break;
160 160
 
161 161
         case 'number_float':
162 162
           $precision = rand(10, 32);
163
-          $scale = rand(0, 2);
164
-          $decimal = rand(0, (10 * $scale)) / 100;
165
-          $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166
-          break;
167
-      }
168
-      $node_field['value'] = round((rand($min, $max) + $decimal), $scale);
163
+            $scale = rand(0, 2);
164
+            $decimal = rand(0, (10 * $scale)) / 100;
165
+            $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166
+            break;
167
+        }
168
+        $node_field['value'] = round((rand($min, $max) + $decimal), $scale);
169 169
     }
170 170
     return $node_field;
171
-  }
171
+    }
172 172
 }
173 173
 
174 174
 if (module_exists('nodereference')) {
175
-  function nodereference_content_generate($node, $field) {
175
+    function nodereference_content_generate($node, $field) {
176 176
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
177
-      return content_devel_multiple('_nodereference_content_generate', $node, $field);
177
+        return content_devel_multiple('_nodereference_content_generate', $node, $field);
178 178
     }
179 179
     else {
180
-      return _nodereference_content_generate($node, $field);
180
+        return _nodereference_content_generate($node, $field);
181
+    }
181 182
     }
182
-  }
183 183
 
184
-  function _nodereference_content_generate($node, $field) {
184
+    function _nodereference_content_generate($node, $field) {
185 185
     $node_field = array();
186 186
     $allowed_values = nodereference_allowed_values($field);
187 187
     unset($allowed_values[0]);
188 188
     if (!empty($allowed_values)) {
189
-      // Just pick one of the specified allowed values.
190
-      $node_field['nid'] = array_rand($allowed_values);
189
+        // Just pick one of the specified allowed values.
190
+        $node_field['nid'] = array_rand($allowed_values);
191 191
     }
192 192
     return $node_field;
193
-  }
193
+    }
194 194
 }
195 195
 
196 196
 if (module_exists('userreference')) {
197
-  function userreference_content_generate($node, $field) {
197
+    function userreference_content_generate($node, $field) {
198 198
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
199
-      return content_devel_multiple('_userreference_content_generate', $node, $field);
199
+        return content_devel_multiple('_userreference_content_generate', $node, $field);
200 200
     }
201 201
     else {
202
-      return _userreference_content_generate($node, $field);
202
+        return _userreference_content_generate($node, $field);
203
+    }
203 204
     }
204
-  }
205 205
 
206
-  function _userreference_content_generate($node, $field) {
206
+    function _userreference_content_generate($node, $field) {
207 207
     $node_field = array();
208 208
     $allowed_values = userreference_allowed_values($field);
209 209
     if (isset($allowed_values['none'])) {
210
-      unset($allowed_values['none']);
210
+        unset($allowed_values['none']);
211 211
     }
212 212
     if (!empty($allowed_values)) {
213
-      // Just pick one of the specified allowed values.
214
-      $node_field['uid'] = array_rand($allowed_values);
213
+        // Just pick one of the specified allowed values.
214
+        $node_field['uid'] = array_rand($allowed_values);
215 215
     }
216 216
     return $node_field;
217
-  }
217
+    }
218 218
 }
219 219
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
       }
33 33
       else {
34 34
         switch ($field['multiple']) {
35
-          case 0:
36
-            $max = 0;
37
-            break;
38
-          case 1:
39
-            $max = rand(0, 3); //just an arbitrary number for 'unlimited'
40
-            break;
41
-          default:
42
-            $max = $field['multiple'];
43
-            break;
35
+        case 0:
36
+          $max = 0;
37
+          break;
38
+        case 1:
39
+          $max = rand(0, 3); //just an arbitrary number for 'unlimited'
40
+          break;
41
+        default:
42
+          $max = $field['multiple'];
43
+          break;
44 44
         }
45 45
       }
46 46
       for ($i = 0; $i <= $max; $i++) {
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
   $node_field = array();
74 74
   if (function_exists($function)) {
75 75
     switch ($field['multiple']) {
76
-      case 0:
77
-        $max = 0;
78
-        break;
79
-      case 1:
80
-        $max = rand(0, 3); //just an arbitrary number for 'unlimited'
81
-        break;
82
-      default:
83
-        $max = $field['multiple'];
84
-        break;
76
+    case 0:
77
+      $max = 0;
78
+      break;
79
+    case 1:
80
+      $max = rand(0, 3); //just an arbitrary number for 'unlimited'
81
+      break;
82
+    default:
83
+      $max = $field['multiple'];
84
+      break;
85 85
     }
86 86
     for ($i = 0; $i <= $max; $i++) {
87 87
       $node_field[$i] = $function($node, $field);
@@ -145,25 +145,25 @@  discard block
 block discarded – undo
145 145
     else {
146 146
       $min = is_numeric($field['min']) ? $field['min'] : 0;
147 147
       switch ($field['type']) {
148
-        case 'number_integer':
149
-          $max = is_numeric($field['max']) ? $field['max'] : 10000;
150
-          $decimal = 0;
151
-          $scale = 0;
152
-          break;
148
+      case 'number_integer':
149
+        $max = is_numeric($field['max']) ? $field['max'] : 10000;
150
+        $decimal = 0;
151
+        $scale = 0;
152
+        break;
153 153
 
154
-        case 'number_decimal':
155
-          $precision = is_numeric($field['precision']) ? $field['precision'] : 10;
156
-          $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157
-          $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
-          $decimal = rand(0, (10 * $scale)) / 100;
159
-          break;
154
+      case 'number_decimal':
155
+        $precision = is_numeric($field['precision']) ? $field['precision'] : 10;
156
+        $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157
+        $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
+        $decimal = rand(0, (10 * $scale)) / 100;
159
+        break;
160 160
 
161
-        case 'number_float':
162
-          $precision = rand(10, 32);
163
-          $scale = rand(0, 2);
164
-          $decimal = rand(0, (10 * $scale)) / 100;
165
-          $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166
-          break;
161
+      case 'number_float':
162
+        $precision = rand(10, 32);
163
+        $scale = rand(0, 2);
164
+        $decimal = rand(0, (10 * $scale)) / 100;
165
+        $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166
+        break;
167 167
       }
168 168
       $node_field['value'] = round((rand($min, $max) + $decimal), $scale);
169 169
     }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
       }
46 46
       for ($i = 0; $i <= $max; $i++) {
47 47
         $module = $field_types[$field['type']]['module'];
48
-        $function = $module .'_content_generate';
48
+        $function = $module.'_content_generate';
49 49
         if (function_exists($function)) {
50 50
           $result = $function($node, $field); // $items, $teaser, $page
51 51
           if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
           $precision = is_numeric($field['precision']) ? $field['precision'] : 10;
156 156
           $scale = is_numeric($field['scale']) ? $field['scale'] : 2;
157 157
           $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
158
-          $decimal = rand(0, (10 * $scale)) / 100;
158
+          $decimal = rand(0, (10*$scale))/100;
159 159
           break;
160 160
 
161 161
         case 'number_float':
162 162
           $precision = rand(10, 32);
163 163
           $scale = rand(0, 2);
164
-          $decimal = rand(0, (10 * $scale)) / 100;
164
+          $decimal = rand(0, (10*$scale))/100;
165 165
           $max = is_numeric($field['max']) ? $field['max'] : pow(10, ($precision - $scale));
166 166
           break;
167 167
       }
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,8 +29,7 @@  discard block
 block discarded – undo
29 29
       // If module handles own multiples, then only call its hook once.
30 30
       if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
31 31
         $max = 0;
32
-      }
33
-      else {
32
+      } else {
34 33
         switch ($field['multiple']) {
35 34
           case 0:
36 35
             $max = 0;
@@ -51,8 +50,7 @@  discard block
 block discarded – undo
51 50
           if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
52 51
             // Fields that handle their own multiples will add their own deltas.
53 52
             $node_field = $result;
54
-          }
55
-          else {
53
+          } else {
56 54
             // When multiples are handled by the content module, add a delta for each result.
57 55
             $node_field[$i] = $result;
58 56
           }
@@ -94,8 +92,7 @@  discard block
 block discarded – undo
94 92
   function text_content_generate($node, $field) {
95 93
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
96 94
       return content_devel_multiple('_text_content_generate', $node, $field);
97
-    }
98
-    else {
95
+    } else {
99 96
       return _text_content_generate($node, $field);
100 97
     }
101 98
   }
@@ -106,14 +103,12 @@  discard block
 block discarded – undo
106 103
       $format = $field['text_processing'] ? rand(0, 3) : 0;
107 104
       $node_field['value'] = devel_create_content($format);
108 105
       $node_field['format'] = $format;
109
-    }
110
-    else {
106
+    } else {
111 107
       $allowed_values = content_allowed_values($field);
112 108
       if (!empty($allowed_values)) {
113 109
         // Just pick one of the specified allowed values.
114 110
         $node_field['value'] = array_rand($allowed_values);
115
-      }
116
-      else {
111
+      } else {
117 112
         // Generate a value that respects max_length.
118 113
         if (empty($field['max_length'])) {
119 114
           $field['max_length'] = 12;
@@ -129,8 +124,7 @@  discard block
 block discarded – undo
129 124
   function number_content_generate($node, $field) {
130 125
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
131 126
       return content_devel_multiple('_number_content_generate', $node, $field);
132
-    }
133
-    else {
127
+    } else {
134 128
       return _number_content_generate($node, $field);
135 129
     }
136 130
   }
@@ -141,8 +135,7 @@  discard block
 block discarded – undo
141 135
     if (!empty($allowed_values)) {
142 136
       // Just pick one of the specified allowed values.
143 137
       $node_field['value'] = array_rand($allowed_values);
144
-    }
145
-    else {
138
+    } else {
146 139
       $min = is_numeric($field['min']) ? $field['min'] : 0;
147 140
       switch ($field['type']) {
148 141
         case 'number_integer':
@@ -175,8 +168,7 @@  discard block
 block discarded – undo
175 168
   function nodereference_content_generate($node, $field) {
176 169
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
177 170
       return content_devel_multiple('_nodereference_content_generate', $node, $field);
178
-    }
179
-    else {
171
+    } else {
180 172
       return _nodereference_content_generate($node, $field);
181 173
     }
182 174
   }
@@ -197,8 +189,7 @@  discard block
 block discarded – undo
197 189
   function userreference_content_generate($node, $field) {
198 190
     if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_MODULE) {
199 191
       return content_devel_multiple('_userreference_content_generate', $node, $field);
200
-    }
201
-    else {
192
+    } else {
202 193
       return _userreference_content_generate($node, $field);
203 194
     }
204 195
   }
Please login to merge, or discard this patch.
sites/default/boinc/modules/contrib/cck/includes/content.node_form.inc 6 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
  *   the form_state for the above form
32 32
  * @param $field
33 33
  *   the field array to use to create the form element
34
- * @param $get_delta
34
+ * @param integer $get_delta
35 35
  *   use to get only a specific delta value of a multiple value field, otherwise
36 36
  *   function will return the entire $field form element.
37 37
  */
Please login to merge, or discard this patch.
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
  * chosen widget.
10 10
  */
11 11
 function content_form(&$form, &$form_state) {
12
-  $type = content_types($form['type']['#value']);
13
-  foreach ($type['fields'] as $field_name => $field) {
12
+    $type = content_types($form['type']['#value']);
13
+    foreach ($type['fields'] as $field_name => $field) {
14 14
     $form['#field_info'][$field['field_name']] = $field;
15 15
     $form += (array) content_field_form($form, $form_state, $field);
16
-  }
17
-  return $form;
16
+    }
17
+    return $form;
18 18
 }
19 19
 
20 20
 /**
@@ -36,18 +36,18 @@  discard block
 block discarded – undo
36 36
  *   function will return the entire $field form element.
37 37
  */
38 38
 function content_field_form(&$form, &$form_state, $field, $get_delta = NULL) {
39
-  $form['#cache'] = FALSE;
40
-  $node = $form['#node'];
41
-  $addition = array();
42
-  $form_element = array();
43
-  $field_name = $field['field_name'];
44
-
45
-  $items = array();
46
-
47
-  // TODO: is the "if (function_exists($function)) {" needed ?
48
-  // defining the $function here makes it unclear where it is actually called
49
-  $function = $field['widget']['module'] .'_widget';
50
-  if (function_exists($function)) {
39
+    $form['#cache'] = FALSE;
40
+    $node = $form['#node'];
41
+    $addition = array();
42
+    $form_element = array();
43
+    $field_name = $field['field_name'];
44
+
45
+    $items = array();
46
+
47
+    // TODO: is the "if (function_exists($function)) {" needed ?
48
+    // defining the $function here makes it unclear where it is actually called
49
+    $function = $field['widget']['module'] .'_widget';
50
+    if (function_exists($function)) {
51 51
     // Prepare the values to be filled in the widget.
52 52
     // We look in the following places:
53 53
     // - Form submitted values
@@ -55,88 +55,88 @@  discard block
 block discarded – undo
55 55
     //   creating a new node translation)
56 56
     // - Default values set for the field (when creating a new node).
57 57
     if (!empty($form_state['values'][$field['field_name']])) {
58
-      $items = $form_state['values'][$field['field_name']];
59
-      // If there was an AHAH add more button in this field, don't save it.
60
-      unset($items[$field['field_name'] .'_add_more']);
58
+        $items = $form_state['values'][$field['field_name']];
59
+        // If there was an AHAH add more button in this field, don't save it.
60
+        unset($items[$field['field_name'] .'_add_more']);
61 61
     }
62 62
     elseif (!empty($node->$field['field_name'])) {
63
-      $items = $node->$field['field_name'];
63
+        $items = $node->$field['field_name'];
64 64
     }
65 65
     elseif (empty($node->nid)) {
66
-      if (content_callback('widget', 'default value', $field) != CONTENT_CALLBACK_NONE) {
66
+        if (content_callback('widget', 'default value', $field) != CONTENT_CALLBACK_NONE) {
67 67
         // If a module wants to insert custom default values here,
68 68
         // it should provide a hook_default_value() function to call,
69 69
         // otherwise the content module's content_default_value() function
70 70
         // will be used.
71 71
         $callback = content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'] .'_default_value' : 'content_default_value';
72 72
         if (function_exists($callback)) {
73
-          $items = $callback($form, $form_state, $field, 0);
73
+            $items = $callback($form, $form_state, $field, 0);
74
+        }
74 75
         }
75
-      }
76 76
     }
77 77
 
78 78
     // See if access to this form element is restricted,
79 79
     // if so, skip widget processing and just set the value.
80 80
     $access = content_access('edit', $field, NULL, $node);
81 81
     if (!$access) {
82
-      $addition[$field_name] = array(
82
+        $addition[$field_name] = array(
83 83
         '#access' => $access,
84 84
         '#type' => 'value',
85 85
         '#value' => $items,
86
-      );
87
-      return $addition;
86
+        );
87
+        return $addition;
88 88
     }
89 89
 
90 90
     // If content module handles multiple values for this form element,
91 91
     // and not selecting an individual $delta, process the multiple value form.
92 92
     if (!isset($get_delta) && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
93
-      $form_element = content_multiple_value_form($form, $form_state, $field, $items);
93
+        $form_element = content_multiple_value_form($form, $form_state, $field, $items);
94 94
     }
95 95
     // If the widget is handling multiple values (e.g optionwidgets),
96 96
     // or selecting an individual element, just get a single form
97 97
     // element and make it the $delta value.
98 98
     else {
99
-      $delta = isset($get_delta) ? $get_delta : 0;
100
-      if ($element = $function($form, $form_state, $field, $items, $delta)) {
99
+        $delta = isset($get_delta) ? $get_delta : 0;
100
+        if ($element = $function($form, $form_state, $field, $items, $delta)) {
101 101
         $title = check_plain(t($field['widget']['label']));
102 102
         $description = content_filter_xss(t($field['widget']['description']));
103 103
         $defaults = array(
104
-          '#required' => $get_delta > 0 ? FALSE : $field['required'],
105
-          '#columns'  => array_keys($field['columns']),
106
-          '#title' => $title,
107
-          '#description' => $description,
108
-          '#delta' => $delta,
109
-          '#field_name' => $field['field_name'],
110
-          '#type_name' => $field['type_name'],
104
+            '#required' => $get_delta > 0 ? FALSE : $field['required'],
105
+            '#columns'  => array_keys($field['columns']),
106
+            '#title' => $title,
107
+            '#description' => $description,
108
+            '#delta' => $delta,
109
+            '#field_name' => $field['field_name'],
110
+            '#type_name' => $field['type_name'],
111 111
         );
112 112
         // If we're processing a specific delta value for a field where the
113 113
         // content module handles multiples, set the delta in the result.
114 114
         // For fields that handle their own processing, we can't make assumptions
115 115
         // about how the field is structured, just merge in the returned value.
116 116
         if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
117
-          $form_element[$delta] = array_merge($element, $defaults);
117
+            $form_element[$delta] = array_merge($element, $defaults);
118 118
         }
119 119
         else {
120
-          $form_element = array_merge($element, $defaults);
120
+            $form_element = array_merge($element, $defaults);
121
+        }
121 122
         }
122
-      }
123 123
     }
124 124
 
125 125
     // Field name is needed at top level as well as the individual elements
126 126
     // so the multiple values or other field level theme or processing can find it.
127 127
     if ($form_element) {
128
-      $defaults = array(
128
+        $defaults = array(
129 129
         '#field_name' => $field['field_name'],
130 130
         '#tree' => TRUE,
131 131
         '#weight' => $field['widget']['weight'],
132 132
         '#access' => $access,
133 133
         // TODO: what's the need for #count ? does not seem to be used anywhere ?
134 134
         '#count' => count($form_element),
135
-      );
136
-      $addition[$field['field_name']] = array_merge($form_element, $defaults);
135
+        );
136
+        $addition[$field['field_name']] = array_merge($form_element, $defaults);
137
+    }
137 138
     }
138
-  }
139
-  return $addition;
139
+    return $addition;
140 140
 }
141 141
 
142 142
 /**
@@ -148,42 +148,42 @@  discard block
 block discarded – undo
148 148
  * - drag-n-drop value reordering
149 149
  */
150 150
 function content_multiple_value_form(&$form, &$form_state, $field, $items) {
151
-  $field_name = $field['field_name'];
151
+    $field_name = $field['field_name'];
152 152
 
153
-  switch ($field['multiple']) {
153
+    switch ($field['multiple']) {
154 154
     case 0:
155 155
       $max = 0;
156
-      break;
156
+        break;
157 157
     case 1:
158 158
       $filled_items = content_set_empty($field, $items);
159
-      $current_item_count = isset($form_state['item_count'][$field_name])
159
+        $current_item_count = isset($form_state['item_count'][$field_name])
160 160
                             ? $form_state['item_count'][$field_name]
161 161
                             : count($items);
162
-      // We always want at least one empty icon for the user to fill in.
163
-      $max = ($current_item_count > count($filled_items))
162
+        // We always want at least one empty icon for the user to fill in.
163
+        $max = ($current_item_count > count($filled_items))
164 164
               ? $current_item_count - 1
165 165
               : $current_item_count;
166 166
 
167
-      break;
167
+        break;
168 168
     default:
169 169
       $max = $field['multiple'] - 1;
170
-      break;
171
-  }
170
+        break;
171
+    }
172 172
 
173
-  $title = check_plain(t($field['widget']['label']));
174
-  $description = content_filter_xss(t($field['widget']['description']));
173
+    $title = check_plain(t($field['widget']['label']));
174
+    $description = content_filter_xss(t($field['widget']['description']));
175 175
 
176
-  $form_element = array(
176
+    $form_element = array(
177 177
     '#theme' => 'content_multiple_values',
178 178
     '#title' => $title,
179 179
     '#required' => $field['required'],
180 180
     '#description' => $description,
181
-  );
182
-  $function = $field['widget']['module'] .'_widget';
181
+    );
182
+    $function = $field['widget']['module'] .'_widget';
183 183
 
184
-  for ($delta = 0; $delta <= $max; $delta++) {
184
+    for ($delta = 0; $delta <= $max; $delta++) {
185 185
     if ($element = $function($form, $form_state, $field, $items, $delta)) {
186
-      $defaults = array(
186
+        $defaults = array(
187 187
         '#title' => ($field['multiple'] >= 1) ? '' : $title,
188 188
         '#description' => ($field['multiple'] >= 1) ? '' : $description,
189 189
         '#required' => $delta == 0 && $field['required'],
@@ -192,51 +192,51 @@  discard block
 block discarded – undo
192 192
         '#columns' => array_keys($field['columns']),
193 193
         '#field_name' => $field_name,
194 194
         '#type_name' => $field['type_name'],
195
-      );
195
+        );
196 196
 
197
-      // Add an input field for the delta (drag-n-drop reordering), which will
198
-      // be hidden by tabledrag js behavior.
199
-      if ($field['multiple'] >= 1) {
197
+        // Add an input field for the delta (drag-n-drop reordering), which will
198
+        // be hidden by tabledrag js behavior.
199
+        if ($field['multiple'] >= 1) {
200 200
         // We name the element '_weight' to avoid clashing with column names
201 201
         // defined by field modules.
202 202
         $element['_weight'] = array(
203
-          '#type' => 'weight',
204
-          '#delta' => $max, // this 'delta' is the 'weight' element's property
205
-          '#default_value' => isset($items[$delta]['_weight']) ? $items[$delta]['_weight'] : $delta,
206
-          '#weight' => 100,
203
+            '#type' => 'weight',
204
+            '#delta' => $max, // this 'delta' is the 'weight' element's property
205
+            '#default_value' => isset($items[$delta]['_weight']) ? $items[$delta]['_weight'] : $delta,
206
+            '#weight' => 100,
207 207
         );
208
-      }
208
+        }
209 209
 
210
-      $form_element[$delta] = array_merge($element, $defaults);
210
+        $form_element[$delta] = array_merge($element, $defaults);
211
+    }
211 212
     }
212
-  }
213 213
 
214
-  // Add AHAH add more button, if not working with a programmed form.
215
-  if ($field['multiple'] == 1 && empty($form['#programmed'])) {
214
+    // Add AHAH add more button, if not working with a programmed form.
215
+    if ($field['multiple'] == 1 && empty($form['#programmed'])) {
216 216
     // Make sure the form is cached so ahah can work.
217 217
     $form['#cache'] = TRUE;
218 218
     $content_type = content_types($field['type_name']);
219 219
     $field_name_css = str_replace('_', '-', $field_name);
220 220
 
221 221
     $form_element[$field_name .'_add_more'] = array(
222
-      '#type' => 'submit',
223
-      '#name' => $field_name .'_add_more',
224
-      '#value' => t('Add another item'),
225
-      '#weight' => $field['widget']['weight'] + $max + 1,
226
-      // Submit callback for disabled JavaScript. drupal_get_form() might get
227
-      // the form from the cache, so we can't rely on content_form_alter()
228
-      // including this file. Therefore, call a proxy function to do this.
229
-      '#submit' => array('content_add_more_submit_proxy'),
230
-      '#ahah' => array(
222
+        '#type' => 'submit',
223
+        '#name' => $field_name .'_add_more',
224
+        '#value' => t('Add another item'),
225
+        '#weight' => $field['widget']['weight'] + $max + 1,
226
+        // Submit callback for disabled JavaScript. drupal_get_form() might get
227
+        // the form from the cache, so we can't rely on content_form_alter()
228
+        // including this file. Therefore, call a proxy function to do this.
229
+        '#submit' => array('content_add_more_submit_proxy'),
230
+        '#ahah' => array(
231 231
         'path' => 'content/js_add_more/'. $content_type['url_str'] .'/'. $field_name,
232 232
         'wrapper' => $field_name_css .'-items',
233 233
         'method' => 'replace',
234 234
         'effect' => 'fade',
235
-      ),
236
-      // When JS is disabled, the content_add_more_submit handler will find
237
-      // the relevant field using these entries.
238
-      '#field_name' => $field_name,
239
-      '#type_name' => $field['type_name'],
235
+        ),
236
+        // When JS is disabled, the content_add_more_submit handler will find
237
+        // the relevant field using these entries.
238
+        '#field_name' => $field_name,
239
+        '#type_name' => $field['type_name'],
240 240
     );
241 241
 
242 242
     // Add wrappers for the fields and 'more' button.
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
     $form_element['#suffix'] = '</div>';
245 245
     $form_element[$field_name .'_add_more']['#prefix'] = '<div class="content-add-more clear-block">';
246 246
     $form_element[$field_name .'_add_more']['#suffix'] = '</div>';
247
-  }
248
-  return $form_element;
247
+    }
248
+    return $form_element;
249 249
 }
250 250
 
251 251
 /**
@@ -254,127 +254,127 @@  discard block
 block discarded – undo
254 254
  * entire form is rebuilt during the page reload.
255 255
  */
256 256
 function content_add_more_submit($form, &$form_state) {
257
-  // Set the form to rebuild and run submit handlers.
258
-  node_form_submit_build_node($form, $form_state);
259
-  $field_name = $form_state['clicked_button']['#field_name'];
260
-  $type_name = $form_state['clicked_button']['#type_name'];
257
+    // Set the form to rebuild and run submit handlers.
258
+    node_form_submit_build_node($form, $form_state);
259
+    $field_name = $form_state['clicked_button']['#field_name'];
260
+    $type_name = $form_state['clicked_button']['#type_name'];
261 261
 
262
-  // Make the changes we want to the form state.
263
-  if ($form_state['values'][$field_name][$field_name .'_add_more']) {
262
+    // Make the changes we want to the form state.
263
+    if ($form_state['values'][$field_name][$field_name .'_add_more']) {
264 264
     $form_state['item_count'][$field_name] = count($form_state['values'][$field_name]);
265
-  }
265
+    }
266 266
 }
267 267
 
268 268
 /**
269 269
  * Menu callback for AHAH addition of new empty widgets.
270 270
  */
271 271
 function content_add_more_js($type_name_url, $field_name) {
272
-  $type = content_types($type_name_url);
273
-  $field = content_fields($field_name, $type['type']);
272
+    $type = content_types($type_name_url);
273
+    $field = content_fields($field_name, $type['type']);
274 274
 
275
-  if (($field['multiple'] != 1) || empty($_POST['form_build_id'])) {
275
+    if (($field['multiple'] != 1) || empty($_POST['form_build_id'])) {
276 276
     // Invalid request.
277 277
     drupal_json(array('data' => ''));
278 278
     exit;
279
-  }
279
+    }
280 280
 
281
-  // Retrieve the cached form.
282
-  $form_state = array('submitted' => FALSE);
283
-  $form_build_id = $_POST['form_build_id'];
284
-  $form = form_get_cache($form_build_id, $form_state);
285
-  if (!$form) {
281
+    // Retrieve the cached form.
282
+    $form_state = array('submitted' => FALSE);
283
+    $form_build_id = $_POST['form_build_id'];
284
+    $form = form_get_cache($form_build_id, $form_state);
285
+    if (!$form) {
286 286
     // Invalid form_build_id.
287 287
     drupal_json(array('data' => ''));
288 288
     exit;
289
-  }
290
-
291
-  // We don't simply return a new empty widget to append to existing ones, because
292
-  // - ahah.js won't simply let us add a new row to a table
293
-  // - attaching the 'draggable' behavior won't be easy
294
-  // So we resort to rebuilding the whole table of widgets including the existing ones,
295
-  // which makes us jump through a few hoops.
296
-
297
-  // The form that we get from the cache is unbuilt. We need to build it so that
298
-  // _value callbacks can be executed and $form_state['values'] populated.
299
-  // We only want to affect $form_state['values'], not the $form itself
300
-  // (built forms aren't supposed to enter the cache) nor the rest of $form_data,
301
-  // so we use copies of $form and $form_data.
302
-  $form_copy = $form;
303
-  $form_state_copy = $form_state;
304
-  $form_copy['#post'] = array();
305
-  form_builder($_POST['form_id'], $form_copy, $form_state_copy);
306
-  // Just grab the data we need.
307
-  $form_state['values'] = $form_state_copy['values'];
308
-  // Reset cached ids, so that they don't affect the actual form we output.
309
-  form_clean_id(NULL, TRUE);
310
-
311
-  // Sort the $form_state['values'] we just built *and* the incoming $_POST data
312
-  // according to d-n-d reordering.
313
-  unset($form_state['values'][$field_name][$field['field_name'] .'_add_more']);
314
-  foreach ($_POST[$field_name] as $delta => $item) {
289
+    }
290
+
291
+    // We don't simply return a new empty widget to append to existing ones, because
292
+    // - ahah.js won't simply let us add a new row to a table
293
+    // - attaching the 'draggable' behavior won't be easy
294
+    // So we resort to rebuilding the whole table of widgets including the existing ones,
295
+    // which makes us jump through a few hoops.
296
+
297
+    // The form that we get from the cache is unbuilt. We need to build it so that
298
+    // _value callbacks can be executed and $form_state['values'] populated.
299
+    // We only want to affect $form_state['values'], not the $form itself
300
+    // (built forms aren't supposed to enter the cache) nor the rest of $form_data,
301
+    // so we use copies of $form and $form_data.
302
+    $form_copy = $form;
303
+    $form_state_copy = $form_state;
304
+    $form_copy['#post'] = array();
305
+    form_builder($_POST['form_id'], $form_copy, $form_state_copy);
306
+    // Just grab the data we need.
307
+    $form_state['values'] = $form_state_copy['values'];
308
+    // Reset cached ids, so that they don't affect the actual form we output.
309
+    form_clean_id(NULL, TRUE);
310
+
311
+    // Sort the $form_state['values'] we just built *and* the incoming $_POST data
312
+    // according to d-n-d reordering.
313
+    unset($form_state['values'][$field_name][$field['field_name'] .'_add_more']);
314
+    foreach ($_POST[$field_name] as $delta => $item) {
315 315
     $form_state['values'][$field_name][$delta]['_weight'] = $item['_weight'];
316
-  }
317
-  $form_state['values'][$field_name] = _content_sort_items($field, $form_state['values'][$field_name]);
318
-  $_POST[$field_name] = _content_sort_items($field, $_POST[$field_name]);
319
-
320
-  // Build our new form element for the whole field, asking for one more element.
321
-  $form_state['item_count'] = array($field_name => count($_POST[$field_name]) + 1);
322
-  $form_element = content_field_form($form, $form_state, $field);
323
-  // Let other modules alter it.
324
-  // We pass an empty array as hook_form_alter's usual 'form_state' parameter,
325
-  // instead of $form_state (for reasons we may never remember).
326
-  // However, this argument is still expected to be passed by-reference
327
-  // (and PHP5.3 will throw an error if it isn't.) This leads to:
328
-  $data = &$form_element;
329
-  $empty_form_state = array();
330
-  $data['__drupal_alter_by_ref'] = array(&$empty_form_state);
331
-  drupal_alter('form', $data, 'content_add_more_js');
332
-
333
-  // Add the new element at the right place in the (original, unbuilt) form.
334
-  if (module_exists('fieldgroup') && ($group_name = _fieldgroup_field_get_group($type['type'], $field_name))) {
316
+    }
317
+    $form_state['values'][$field_name] = _content_sort_items($field, $form_state['values'][$field_name]);
318
+    $_POST[$field_name] = _content_sort_items($field, $_POST[$field_name]);
319
+
320
+    // Build our new form element for the whole field, asking for one more element.
321
+    $form_state['item_count'] = array($field_name => count($_POST[$field_name]) + 1);
322
+    $form_element = content_field_form($form, $form_state, $field);
323
+    // Let other modules alter it.
324
+    // We pass an empty array as hook_form_alter's usual 'form_state' parameter,
325
+    // instead of $form_state (for reasons we may never remember).
326
+    // However, this argument is still expected to be passed by-reference
327
+    // (and PHP5.3 will throw an error if it isn't.) This leads to:
328
+    $data = &$form_element;
329
+    $empty_form_state = array();
330
+    $data['__drupal_alter_by_ref'] = array(&$empty_form_state);
331
+    drupal_alter('form', $data, 'content_add_more_js');
332
+
333
+    // Add the new element at the right place in the (original, unbuilt) form.
334
+    if (module_exists('fieldgroup') && ($group_name = _fieldgroup_field_get_group($type['type'], $field_name))) {
335 335
     $form[$group_name][$field_name] = $form_element[$field_name];
336
-  }
337
-  else {
336
+    }
337
+    else {
338 338
     $form[$field_name] = $form_element[$field_name];
339
-  }
340
-
341
-  // Save the new definition of the form.
342
-  $form_state['values'] = array();
343
-  form_set_cache($form_build_id, $form, $form_state);
344
-
345
-  // Build the new form against the incoming $_POST values so that we can
346
-  // render the new element.
347
-  $delta = max(array_keys($_POST[$field_name])) + 1;
348
-  $_POST[$field_name][$delta]['_weight'] = $delta;
349
-  $form_state = array('submitted' => FALSE);
350
-  $form += array(
339
+    }
340
+
341
+    // Save the new definition of the form.
342
+    $form_state['values'] = array();
343
+    form_set_cache($form_build_id, $form, $form_state);
344
+
345
+    // Build the new form against the incoming $_POST values so that we can
346
+    // render the new element.
347
+    $delta = max(array_keys($_POST[$field_name])) + 1;
348
+    $_POST[$field_name][$delta]['_weight'] = $delta;
349
+    $form_state = array('submitted' => FALSE);
350
+    $form += array(
351 351
     '#post' => $_POST,
352 352
     '#programmed' => FALSE,
353
-  );
354
-  $form = form_builder($_POST['form_id'], $form, $form_state);
355
-
356
-  // Render the new output.
357
-  $field_form = (!empty($group_name)) ? $form[$group_name][$field_name] : $form[$field_name];
358
-  // We add a div around the new content to receive the ahah effect.
359
-  $field_form[$delta]['#prefix'] = '<div class="ahah-new-content">'. (isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
360
-  $field_form[$delta]['#suffix'] = (isset($field_form[$delta]['#suffix']) ? $field_form[$delta]['#suffix'] : '') .'</div>';
361
-  // Prevent duplicate wrapper.
362
-  unset($field_form['#prefix'], $field_form['#suffix']);
363
-
364
-  // If a newly inserted widget contains AHAH behaviors, they normally won't
365
-  // work because AHAH doesn't know about those - it just attaches to the exact
366
-  // form elements that were initially specified in the Drupal.settings object.
367
-  // The new ones didn't exist then, so we need to update Drupal.settings
368
-  // by ourselves in order to let AHAH know about those new form elements.
369
-  $javascript = drupal_add_js(NULL, NULL);
370
-  $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
371
-
372
-  $output = theme('status_messages') . drupal_render($field_form) . $output_js;
373
-
374
-  // Using drupal_json() breaks filefield's file upload, because the jQuery
375
-  // Form plugin handles file uploads in a way that is not compatible with
376
-  // 'text/javascript' response type.
377
-  $GLOBALS['devel_shutdown'] =  FALSE;
378
-  print drupal_to_js(array('status' => TRUE, 'data' => $output));
379
-  exit;
353
+    );
354
+    $form = form_builder($_POST['form_id'], $form, $form_state);
355
+
356
+    // Render the new output.
357
+    $field_form = (!empty($group_name)) ? $form[$group_name][$field_name] : $form[$field_name];
358
+    // We add a div around the new content to receive the ahah effect.
359
+    $field_form[$delta]['#prefix'] = '<div class="ahah-new-content">'. (isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
360
+    $field_form[$delta]['#suffix'] = (isset($field_form[$delta]['#suffix']) ? $field_form[$delta]['#suffix'] : '') .'</div>';
361
+    // Prevent duplicate wrapper.
362
+    unset($field_form['#prefix'], $field_form['#suffix']);
363
+
364
+    // If a newly inserted widget contains AHAH behaviors, they normally won't
365
+    // work because AHAH doesn't know about those - it just attaches to the exact
366
+    // form elements that were initially specified in the Drupal.settings object.
367
+    // The new ones didn't exist then, so we need to update Drupal.settings
368
+    // by ourselves in order to let AHAH know about those new form elements.
369
+    $javascript = drupal_add_js(NULL, NULL);
370
+    $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
371
+
372
+    $output = theme('status_messages') . drupal_render($field_form) . $output_js;
373
+
374
+    // Using drupal_json() breaks filefield's file upload, because the jQuery
375
+    // Form plugin handles file uploads in a way that is not compatible with
376
+    // 'text/javascript' response type.
377
+    $GLOBALS['devel_shutdown'] =  FALSE;
378
+    print drupal_to_js(array('status' => TRUE, 'data' => $output));
379
+    exit;
380 380
 }
Please login to merge, or discard this patch.
Switch Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -151,23 +151,23 @@
 block discarded – undo
151 151
   $field_name = $field['field_name'];
152 152
 
153 153
   switch ($field['multiple']) {
154
-    case 0:
155
-      $max = 0;
156
-      break;
157
-    case 1:
158
-      $filled_items = content_set_empty($field, $items);
159
-      $current_item_count = isset($form_state['item_count'][$field_name])
160
-                            ? $form_state['item_count'][$field_name]
161
-                            : count($items);
162
-      // We always want at least one empty icon for the user to fill in.
163
-      $max = ($current_item_count > count($filled_items))
164
-              ? $current_item_count - 1
165
-              : $current_item_count;
166
-
167
-      break;
168
-    default:
169
-      $max = $field['multiple'] - 1;
170
-      break;
154
+  case 0:
155
+    $max = 0;
156
+    break;
157
+  case 1:
158
+    $filled_items = content_set_empty($field, $items);
159
+    $current_item_count = isset($form_state['item_count'][$field_name])
160
+                          ? $form_state['item_count'][$field_name]
161
+                          : count($items);
162
+    // We always want at least one empty icon for the user to fill in.
163
+    $max = ($current_item_count > count($filled_items))
164
+            ? $current_item_count - 1
165
+            : $current_item_count;
166
+
167
+    break;
168
+  default:
169
+    $max = $field['multiple'] - 1;
170
+    break;
171 171
   }
172 172
 
173 173
   $title = check_plain(t($field['widget']['label']));
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
   $type = content_types($form['type']['#value']);
13 13
   foreach ($type['fields'] as $field_name => $field) {
14 14
     $form['#field_info'][$field['field_name']] = $field;
15
-    $form += (array) content_field_form($form, $form_state, $field);
15
+    $form += (array)content_field_form($form, $form_state, $field);
16 16
   }
17 17
   return $form;
18 18
 }
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
   // TODO: is the "if (function_exists($function)) {" needed ?
48 48
   // defining the $function here makes it unclear where it is actually called
49
-  $function = $field['widget']['module'] .'_widget';
49
+  $function = $field['widget']['module'].'_widget';
50 50
   if (function_exists($function)) {
51 51
     // Prepare the values to be filled in the widget.
52 52
     // We look in the following places:
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     if (!empty($form_state['values'][$field['field_name']])) {
58 58
       $items = $form_state['values'][$field['field_name']];
59 59
       // If there was an AHAH add more button in this field, don't save it.
60
-      unset($items[$field['field_name'] .'_add_more']);
60
+      unset($items[$field['field_name'].'_add_more']);
61 61
     }
62 62
     elseif (!empty($node->$field['field_name'])) {
63 63
       $items = $node->$field['field_name'];
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         // it should provide a hook_default_value() function to call,
69 69
         // otherwise the content module's content_default_value() function
70 70
         // will be used.
71
-        $callback = content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'] .'_default_value' : 'content_default_value';
71
+        $callback = content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'].'_default_value' : 'content_default_value';
72 72
         if (function_exists($callback)) {
73 73
           $items = $callback($form, $form_state, $field, 0);
74 74
         }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     '#required' => $field['required'],
180 180
     '#description' => $description,
181 181
   );
182
-  $function = $field['widget']['module'] .'_widget';
182
+  $function = $field['widget']['module'].'_widget';
183 183
 
184 184
   for ($delta = 0; $delta <= $max; $delta++) {
185 185
     if ($element = $function($form, $form_state, $field, $items, $delta)) {
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
     $content_type = content_types($field['type_name']);
219 219
     $field_name_css = str_replace('_', '-', $field_name);
220 220
 
221
-    $form_element[$field_name .'_add_more'] = array(
221
+    $form_element[$field_name.'_add_more'] = array(
222 222
       '#type' => 'submit',
223
-      '#name' => $field_name .'_add_more',
223
+      '#name' => $field_name.'_add_more',
224 224
       '#value' => t('Add another item'),
225 225
       '#weight' => $field['widget']['weight'] + $max + 1,
226 226
       // Submit callback for disabled JavaScript. drupal_get_form() might get
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
       // including this file. Therefore, call a proxy function to do this.
229 229
       '#submit' => array('content_add_more_submit_proxy'),
230 230
       '#ahah' => array(
231
-        'path' => 'content/js_add_more/'. $content_type['url_str'] .'/'. $field_name,
232
-        'wrapper' => $field_name_css .'-items',
231
+        'path' => 'content/js_add_more/'.$content_type['url_str'].'/'.$field_name,
232
+        'wrapper' => $field_name_css.'-items',
233 233
         'method' => 'replace',
234 234
         'effect' => 'fade',
235 235
       ),
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
     );
241 241
 
242 242
     // Add wrappers for the fields and 'more' button.
243
-    $form_element['#prefix'] = '<div id="'. $field_name_css .'-items">';
243
+    $form_element['#prefix'] = '<div id="'.$field_name_css.'-items">';
244 244
     $form_element['#suffix'] = '</div>';
245
-    $form_element[$field_name .'_add_more']['#prefix'] = '<div class="content-add-more clear-block">';
246
-    $form_element[$field_name .'_add_more']['#suffix'] = '</div>';
245
+    $form_element[$field_name.'_add_more']['#prefix'] = '<div class="content-add-more clear-block">';
246
+    $form_element[$field_name.'_add_more']['#suffix'] = '</div>';
247 247
   }
248 248
   return $form_element;
249 249
 }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
   $type_name = $form_state['clicked_button']['#type_name'];
261 261
 
262 262
   // Make the changes we want to the form state.
263
-  if ($form_state['values'][$field_name][$field_name .'_add_more']) {
263
+  if ($form_state['values'][$field_name][$field_name.'_add_more']) {
264 264
     $form_state['item_count'][$field_name] = count($form_state['values'][$field_name]);
265 265
   }
266 266
 }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
   // Sort the $form_state['values'] we just built *and* the incoming $_POST data
312 312
   // according to d-n-d reordering.
313
-  unset($form_state['values'][$field_name][$field['field_name'] .'_add_more']);
313
+  unset($form_state['values'][$field_name][$field['field_name'].'_add_more']);
314 314
   foreach ($_POST[$field_name] as $delta => $item) {
315 315
     $form_state['values'][$field_name][$delta]['_weight'] = $item['_weight'];
316 316
   }
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
   // Render the new output.
357 357
   $field_form = (!empty($group_name)) ? $form[$group_name][$field_name] : $form[$field_name];
358 358
   // We add a div around the new content to receive the ahah effect.
359
-  $field_form[$delta]['#prefix'] = '<div class="ahah-new-content">'. (isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
360
-  $field_form[$delta]['#suffix'] = (isset($field_form[$delta]['#suffix']) ? $field_form[$delta]['#suffix'] : '') .'</div>';
359
+  $field_form[$delta]['#prefix'] = '<div class="ahah-new-content">'.(isset($field_form[$delta]['#prefix']) ? $field_form[$delta]['#prefix'] : '');
360
+  $field_form[$delta]['#suffix'] = (isset($field_form[$delta]['#suffix']) ? $field_form[$delta]['#suffix'] : '').'</div>';
361 361
   // Prevent duplicate wrapper.
362 362
   unset($field_form['#prefix'], $field_form['#suffix']);
363 363
 
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
   // The new ones didn't exist then, so we need to update Drupal.settings
368 368
   // by ourselves in order to let AHAH know about those new form elements.
369 369
   $javascript = drupal_add_js(NULL, NULL);
370
-  $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
370
+  $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '.drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])).');</script>' : '';
371 371
 
372
-  $output = theme('status_messages') . drupal_render($field_form) . $output_js;
372
+  $output = theme('status_messages').drupal_render($field_form).$output_js;
373 373
 
374 374
   // Using drupal_json() breaks filefield's file upload, because the jQuery
375 375
   // Form plugin handles file uploads in a way that is not compatible with
376 376
   // 'text/javascript' response type.
377
-  $GLOBALS['devel_shutdown'] =  FALSE;
377
+  $GLOBALS['devel_shutdown'] = FALSE;
378 378
   print drupal_to_js(array('status' => TRUE, 'data' => $output));
379 379
   exit;
380 380
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,11 +58,9 @@  discard block
 block discarded – undo
58 58
       $items = $form_state['values'][$field['field_name']];
59 59
       // If there was an AHAH add more button in this field, don't save it.
60 60
       unset($items[$field['field_name'] .'_add_more']);
61
-    }
62
-    elseif (!empty($node->$field['field_name'])) {
61
+    } elseif (!empty($node->$field['field_name'])) {
63 62
       $items = $node->$field['field_name'];
64
-    }
65
-    elseif (empty($node->nid)) {
63
+    } elseif (empty($node->nid)) {
66 64
       if (content_callback('widget', 'default value', $field) != CONTENT_CALLBACK_NONE) {
67 65
         // If a module wants to insert custom default values here,
68 66
         // it should provide a hook_default_value() function to call,
@@ -115,8 +113,7 @@  discard block
 block discarded – undo
115 113
         // about how the field is structured, just merge in the returned value.
116 114
         if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
117 115
           $form_element[$delta] = array_merge($element, $defaults);
118
-        }
119
-        else {
116
+        } else {
120 117
           $form_element = array_merge($element, $defaults);
121 118
         }
122 119
       }
@@ -333,8 +330,7 @@  discard block
 block discarded – undo
333 330
   // Add the new element at the right place in the (original, unbuilt) form.
334 331
   if (module_exists('fieldgroup') && ($group_name = _fieldgroup_field_get_group($type['type'], $field_name))) {
335 332
     $form[$group_name][$field_name] = $form_element[$field_name];
336
-  }
337
-  else {
333
+  } else {
338 334
     $form[$field_name] = $form_element[$field_name];
339 335
   }
340 336
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
  *   use to get only a specific delta value of a multiple value field, otherwise
36 36
  *   function will return the entire $field form element.
37 37
  */
38
-function content_field_form(&$form, &$form_state, $field, $get_delta = NULL) {
39
-  $form['#cache'] = FALSE;
38
+function content_field_form(&$form, &$form_state, $field, $get_delta = null) {
39
+  $form['#cache'] = false;
40 40
   $node = $form['#node'];
41 41
   $addition = array();
42 42
   $form_element = array();
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
     // See if access to this form element is restricted,
79 79
     // if so, skip widget processing and just set the value.
80
-    $access = content_access('edit', $field, NULL, $node);
80
+    $access = content_access('edit', $field, null, $node);
81 81
     if (!$access) {
82 82
       $addition[$field_name] = array(
83 83
         '#access' => $access,
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         $title = check_plain(t($field['widget']['label']));
102 102
         $description = content_filter_xss(t($field['widget']['description']));
103 103
         $defaults = array(
104
-          '#required' => $get_delta > 0 ? FALSE : $field['required'],
104
+          '#required' => $get_delta > 0 ? false : $field['required'],
105 105
           '#columns'  => array_keys($field['columns']),
106 106
           '#title' => $title,
107 107
           '#description' => $description,
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     if ($form_element) {
128 128
       $defaults = array(
129 129
         '#field_name' => $field['field_name'],
130
-        '#tree' => TRUE,
130
+        '#tree' => true,
131 131
         '#weight' => $field['widget']['weight'],
132 132
         '#access' => $access,
133 133
         // TODO: what's the need for #count ? does not seem to be used anywhere ?
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
   // Add AHAH add more button, if not working with a programmed form.
215 215
   if ($field['multiple'] == 1 && empty($form['#programmed'])) {
216 216
     // Make sure the form is cached so ahah can work.
217
-    $form['#cache'] = TRUE;
217
+    $form['#cache'] = true;
218 218
     $content_type = content_types($field['type_name']);
219 219
     $field_name_css = str_replace('_', '-', $field_name);
220 220
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
   }
280 280
 
281 281
   // Retrieve the cached form.
282
-  $form_state = array('submitted' => FALSE);
282
+  $form_state = array('submitted' => false);
283 283
   $form_build_id = $_POST['form_build_id'];
284 284
   $form = form_get_cache($form_build_id, $form_state);
285 285
   if (!$form) {
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
   // Just grab the data we need.
307 307
   $form_state['values'] = $form_state_copy['values'];
308 308
   // Reset cached ids, so that they don't affect the actual form we output.
309
-  form_clean_id(NULL, TRUE);
309
+  form_clean_id(null, true);
310 310
 
311 311
   // Sort the $form_state['values'] we just built *and* the incoming $_POST data
312 312
   // according to d-n-d reordering.
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
   // render the new element.
347 347
   $delta = max(array_keys($_POST[$field_name])) + 1;
348 348
   $_POST[$field_name][$delta]['_weight'] = $delta;
349
-  $form_state = array('submitted' => FALSE);
349
+  $form_state = array('submitted' => false);
350 350
   $form += array(
351 351
     '#post' => $_POST,
352
-    '#programmed' => FALSE,
352
+    '#programmed' => false,
353 353
   );
354 354
   $form = form_builder($_POST['form_id'], $form, $form_state);
355 355
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
   // form elements that were initially specified in the Drupal.settings object.
367 367
   // The new ones didn't exist then, so we need to update Drupal.settings
368 368
   // by ourselves in order to let AHAH know about those new form elements.
369
-  $javascript = drupal_add_js(NULL, NULL);
369
+  $javascript = drupal_add_js(null, null);
370 370
   $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
371 371
 
372 372
   $output = theme('status_messages') . drupal_render($field_form) . $output_js;
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
   // Using drupal_json() breaks filefield's file upload, because the jQuery
375 375
   // Form plugin handles file uploads in a way that is not compatible with
376 376
   // 'text/javascript' response type.
377
-  $GLOBALS['devel_shutdown'] =  FALSE;
378
-  print drupal_to_js(array('status' => TRUE, 'data' => $output));
377
+  $GLOBALS['devel_shutdown'] =  false;
378
+  print drupal_to_js(array('status' => true, 'data' => $output));
379 379
   exit;
380 380
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/cck/includes/content.rules.inc 5 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -289,6 +289,7 @@
 block discarded – undo
289 289
 /**
290 290
  * Returns the fields of a given field type only.
291 291
  * Suitable for using it with #options.
292
+ * @param string $type
292 293
  */
293 294
 function content_rules_get_field_names_by_type($type = NULL) {
294 295
   $fields = array();
Please login to merge, or discard this patch.
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_rules_action_info().
11 11
  */
12 12
 function content_rules_action_info() {
13
-  $info = array();
14
-  $info['content_rules_action_populate_field'] = array(
13
+    $info = array();
14
+    $info['content_rules_action_populate_field'] = array(
15 15
     'label' => t('Populate a field'),
16 16
     'arguments' => array(
17
-      'node' => array(
17
+        'node' => array(
18 18
         'type' => 'node',
19 19
         'label' => t('Content'),
20
-      ),
20
+        ),
21 21
     ),
22 22
     'eval input' => array('code'),
23 23
     'help' => t('You should make sure that the used field exists in the given content type.'),
24 24
     'module' => 'CCK',
25
-  );
26
-  return $info;
25
+    );
26
+    return $info;
27 27
 }
28 28
 
29 29
 /**
30 30
  * Action: populate a field.
31 31
  */
32 32
 function content_rules_action_populate_field($node, $settings, $element, &$state) {
33
-  // Get information about the field.
34
-  $field = content_fields($settings['field_name'], $node->type);
35
-  $value = _content_rules_get_field_value($settings, $state);
33
+    // Get information about the field.
34
+    $field = content_fields($settings['field_name'], $node->type);
35
+    $value = _content_rules_get_field_value($settings, $state);
36 36
 
37
-  if (!empty($field) && is_array($value)) {
37
+    if (!empty($field) && is_array($value)) {
38 38
     $node->$settings['field_name'] = $value;
39 39
     return array('node' => $node);
40
-  }
40
+    }
41 41
 }
42 42
 
43 43
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
  * This is a multistep form!
47 47
  */
48 48
 function content_rules_action_populate_field_form($settings, &$form, &$form_state) {
49
-  $settings += array('field_name' => '', 'code' => '', 'value' => NULL);
50
-  if (empty($settings['field_name'])) {
49
+    $settings += array('field_name' => '', 'code' => '', 'value' => NULL);
50
+    if (empty($settings['field_name'])) {
51 51
     $form['settings']['field_name'] = array(
52
-      '#type' => 'select',
53
-      '#title' => t('Field'),
54
-      '#options' => content_rules_get_field_names_by_type(),
55
-      '#default_value' => $settings['field_name'],
56
-      '#description' => t('Select the machine-name of the field.'),
57
-      '#required' => TRUE,
52
+        '#type' => 'select',
53
+        '#title' => t('Field'),
54
+        '#options' => content_rules_get_field_names_by_type(),
55
+        '#default_value' => $settings['field_name'],
56
+        '#description' => t('Select the machine-name of the field.'),
57
+        '#required' => TRUE,
58 58
     );
59 59
     // Hide some form elements in the first step.
60 60
     $form['negate']['#access'] = FALSE;
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
     // Replace the usual submit handlers with a own handler.
65 65
     $form['submit']['#submit'] = array('content_rules_action_populate_field_form_step_submit');
66 66
     $form['submit']['#value'] = t('Continue');
67
-  }
68
-  else {
67
+    }
68
+    else {
69 69
     // Show the fields form here.
70 70
     module_load_include('inc', 'content', 'includes/content.node_form');
71 71
     $field = content_fields($settings['field_name']);
@@ -78,111 +78,111 @@  discard block
 block discarded – undo
78 78
 
79 79
     unset($form['#cache']);
80 80
 
81
-      // Advanced: PHP code.
81
+        // Advanced: PHP code.
82 82
     $form['advanced_options'] = array(
83
-      '#type' => 'fieldset',
84
-      '#title' => t('Advanced: Specify the fields value with PHP code'),
85
-      '#collapsible' => TRUE,
86
-      '#collapsed' => empty($settings['code']),
87
-      '#weight' => 5,
83
+        '#type' => 'fieldset',
84
+        '#title' => t('Advanced: Specify the fields value with PHP code'),
85
+        '#collapsible' => TRUE,
86
+        '#collapsed' => empty($settings['code']),
87
+        '#weight' => 5,
88 88
     );
89 89
 
90 90
     $db_info = content_database_info($field);
91 91
     $columns = array_keys($db_info['columns']);
92 92
     foreach ($columns as $key => $column) {
93
-      $columns[$key] = t("'@column' => value for @column", array('@column' => $column));
93
+        $columns[$key] = t("'@column' => value for @column", array('@column' => $column));
94 94
     }
95 95
     $sample = t("return array(\n  0 => array(@columns),\n  // You'll usually want to stop here. Provide more values\n  // if you want your 'default value' to be multi-valued:\n  1 => array(@columns),\n  2 => ...\n);", array('@columns' => implode(', ', $columns)));
96 96
 
97 97
     $form['advanced_options']['code'] = array(
98
-      '#type' => 'textarea',
99
-      '#title' => t('Code'),
100
-      '#default_value' => $settings['code'],
101
-      '#rows' => 6,
102
-      '#description' => t('Advanced usage only: PHP code that returns the value to set. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the value returned by this code will override any value specified above. Expected format: <pre>!sample</pre>Using <a href="@link_devel">devel.module\'s</a> \'devel load\' tab on a content page might help you figure out the expected format.', array(
98
+        '#type' => 'textarea',
99
+        '#title' => t('Code'),
100
+        '#default_value' => $settings['code'],
101
+        '#rows' => 6,
102
+        '#description' => t('Advanced usage only: PHP code that returns the value to set. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the value returned by this code will override any value specified above. Expected format: <pre>!sample</pre>Using <a href="@link_devel">devel.module\'s</a> \'devel load\' tab on a content page might help you figure out the expected format.', array(
103 103
         '!sample' => $sample,
104 104
         '@link_devel' => 'http://www.drupal.org/project/devel',
105
-      )),
105
+        )),
106 106
     );
107 107
 
108 108
     // Add this file to be included when the form is built by rules
109 109
     // as it's needed by CCKs add more button.
110 110
     // See rules_after_build_include_files().
111 111
     $form['#includes'][] = './'. drupal_get_path('module', 'node') .'/node.pages.inc';
112
-  }
112
+    }
113 113
 }
114 114
 
115 115
 function content_rules_action_populate_field_form_step_submit($form, &$form_state) {
116
-  $form_state['element']['#settings']['field_name'] = $form_state['values']['settings']['field_name'];
116
+    $form_state['element']['#settings']['field_name'] = $form_state['values']['settings']['field_name'];
117 117
 }
118 118
 
119 119
 /**
120 120
  * Validate the chosen value or php code.
121 121
  */
122 122
 function content_rules_action_populate_field_validate($form, &$form_state) {
123
-  if (!isset($form_state['element']['#settings']['field_name'])) {
123
+    if (!isset($form_state['element']['#settings']['field_name'])) {
124 124
     //Just validate the last step.
125 125
     return;
126
-  }
126
+    }
127 127
 
128
-  if (isset($form_state['values']['code']) && ($php = $form_state['values']['code'])) {
128
+    if (isset($form_state['values']['code']) && ($php = $form_state['values']['code'])) {
129 129
     if (strpos($php, 'return') === FALSE) {
130
-      form_set_error('code', t('You have to return the default value in the expected format.'));
130
+        form_set_error('code', t('You have to return the default value in the expected format.'));
131 131
     }
132
-  }
133
-  else {
132
+    }
133
+    else {
134 134
     // Validate the field.
135 135
     $settings = $form_state['element']['#settings'];
136 136
     $field = content_fields($settings['field_name']);
137 137
     $field_types = _content_field_types();
138 138
     $function = $field_types[$field['type']]['module'] .'_field';
139 139
     if (function_exists($function)) {
140
-      $form['#node'] = (object)array('type' => '', $settings['field_name'] => $form_state['values'][$settings['field_name']]);
141
-      $items = isset($form['#node']->$field['field_name']) ? $form['#node']->$field['field_name'] : array();
140
+        $form['#node'] = (object)array('type' => '', $settings['field_name'] => $form_state['values'][$settings['field_name']]);
141
+        $items = isset($form['#node']->$field['field_name']) ? $form['#node']->$field['field_name'] : array();
142 142
 
143
-      //Make sure AHAH 'add more' button isn't sent to the fields
144
-      // for processing.
145
-      unset($items[$field['field_name'] .'_add_more']);
143
+        //Make sure AHAH 'add more' button isn't sent to the fields
144
+        // for processing.
145
+        unset($items[$field['field_name'] .'_add_more']);
146 146
 
147
-      $function('validate', $form['#node'], $field, $items, $form, NULL);
148
-      content_field('validate', $form['#node'], $field, $items, $form, NULL);
147
+        $function('validate', $form['#node'], $field, $items, $form, NULL);
148
+        content_field('validate', $form['#node'], $field, $items, $form, NULL);
149
+    }
149 150
     }
150
-  }
151 151
 }
152 152
 
153 153
 function content_rules_action_populate_field_submit(&$settings, $form, &$form_state) {
154
-  // Take over field values and filter out private properties added by CCK
155
-  $settings['value'] = array_filter($form_state['values'][$settings['field_name']], 'is_array');
154
+    // Take over field values and filter out private properties added by CCK
155
+    $settings['value'] = array_filter($form_state['values'][$settings['field_name']], 'is_array');
156 156
 
157
-  foreach ($settings['value'] as $key => $data) {
157
+    foreach ($settings['value'] as $key => $data) {
158 158
     foreach (array_filter(array_keys($data)) as $col) {
159
-      if ($col[0] == '_') {
159
+        if ($col[0] == '_') {
160 160
         unset($settings['value'][$key][$col]);
161
-      }
161
+        }
162 162
     }
163 163
     if ($key && count(array_filter($settings['value'][$key])) == 0) {
164
-      // For multi-valued fields don't check for any additional empty values.
165
-      unset($settings['value'][$key]);
164
+        // For multi-valued fields don't check for any additional empty values.
165
+        unset($settings['value'][$key]);
166
+    }
166 167
     }
167
-  }
168 168
 
169
-  $settings['code'] = $form_state['values']['code'];
169
+    $settings['code'] = $form_state['values']['code'];
170 170
 
171
-  if (function_exists('rules_action_custom_php_submit')) {
171
+    if (function_exists('rules_action_custom_php_submit')) {
172 172
     // Support adding variables to the php code, if php module is present.
173 173
     rules_action_custom_php_submit($settings, $form, $form_state);
174
-  }
174
+    }
175 175
 
176
-  // Add all values to the input evaluator, so that textfields / textares can
177
-  // make use of it.
178
-  $names = array('code');
176
+    // Add all values to the input evaluator, so that textfields / textares can
177
+    // make use of it.
178
+    $names = array('code');
179 179
 
180
-  foreach ($settings['value'] as $key => $data) {
180
+    foreach ($settings['value'] as $key => $data) {
181 181
     foreach (array_filter($data, 'is_string') as $col => $value) {
182
-      $names[] = "value|$key|$col";
182
+        $names[] = "value|$key|$col";
183
+    }
183 184
     }
184
-  }
185
-  $form_state['element']['#info']['eval input'] = $names;
185
+    $form_state['element']['#info']['eval input'] = $names;
186 186
 }
187 187
 
188 188
 
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
  * Label callback: Improve the label of the action.
191 191
  */
192 192
 function content_rules_action_populate_field_label($settings, $argument_labels) {
193
-  return t("Populate @node's field '@field'", array('@field' => $settings['field_name']) + $argument_labels);
193
+    return t("Populate @node's field '@field'", array('@field' => $settings['field_name']) + $argument_labels);
194 194
 }
195 195
 
196 196
 function workflow_ng_action_populate_field_upgrade(&$element) {
197
-  $element['#name'] = 'content_rules_action_populate_field';
198
-  $element['#settings']['code'] = $element['#settings']['default_value_php'];
199
-  $element['#settings'][$element['#settings']['field_name']] = array();
200
-  unset($element['#settings']['default_value_php']);
197
+    $element['#name'] = 'content_rules_action_populate_field';
198
+    $element['#settings']['code'] = $element['#settings']['default_value_php'];
199
+    $element['#settings'][$element['#settings']['field_name']] = array();
200
+    unset($element['#settings']['default_value_php']);
201 201
 }
202 202
 
203 203
 
@@ -205,84 +205,84 @@  discard block
 block discarded – undo
205 205
  * Implementation of hook_rules_condition_info().
206 206
  */
207 207
 function content_rules_condition_info() {
208
-  $info = array();
209
-  $info['content_rules_field_has_value'] = array(
208
+    $info = array();
209
+    $info['content_rules_field_has_value'] = array(
210 210
     'label' => t('Field has value'),
211 211
     'arguments' => array(
212
-      'node' => array('type' => 'node', 'label' => t('Content')),
212
+        'node' => array('type' => 'node', 'label' => t('Content')),
213 213
     ),
214 214
     'eval input' => array('code'),
215 215
     'help' => t('You should make sure that the used field exists in the given content type. The condition returns TRUE, if the selected field has the given value.'),
216 216
     'module' => 'CCK',
217
-  );
218
-  $info['content_rules_field_changed'] = array(
217
+    );
218
+    $info['content_rules_field_changed'] = array(
219 219
     'label' => t('Field has changed'),
220 220
     'arguments' => array(
221
-      'node' => array('type' => 'node', 'label' => t('Content containing changes')),
222
-      'node_unchanged' => array('type' => 'node', 'label' => t('Content not containing changes')),
221
+        'node' => array('type' => 'node', 'label' => t('Content containing changes')),
222
+        'node_unchanged' => array('type' => 'node', 'label' => t('Content not containing changes')),
223 223
     ),
224 224
     'help' => t('You should make sure that the used field exists in the given content type.'),
225 225
     'module' => 'CCK',
226
-  );
227
-  return $info;
226
+    );
227
+    return $info;
228 228
 }
229 229
 
230 230
 /**
231 231
  * Condition: Check the value of a field.
232 232
  */
233 233
 function content_rules_field_has_value($node, $settings) {
234
-  // Get information about the field.
235
-  $field = content_fields($settings['field_name'], $node->type);
236
-  $value = _content_rules_get_field_value($settings, $state);
234
+    // Get information about the field.
235
+    $field = content_fields($settings['field_name'], $node->type);
236
+    $value = _content_rules_get_field_value($settings, $state);
237 237
 
238
-  if (empty($field) || !is_array($value)) {
238
+    if (empty($field) || !is_array($value)) {
239 239
     return FALSE;
240
-  }
240
+    }
241 241
 
242
-  return _content_rules_field_has_value($node->$settings['field_name'], $value);
242
+    return _content_rules_field_has_value($node->$settings['field_name'], $value);
243 243
 }
244 244
 
245 245
 /**
246 246
  * Use the same configuration form as the "populate field" action.
247 247
  */
248 248
 function content_rules_field_has_value_form($settings, &$form, &$form_state) {
249
-  content_rules_action_populate_field_form($settings, $form, $form_state);
249
+    content_rules_action_populate_field_form($settings, $form, $form_state);
250 250
 }
251 251
 function content_rules_field_has_value_validate($form, &$form_state) {
252
-  content_rules_action_populate_field_validate($form, $form_state);
252
+    content_rules_action_populate_field_validate($form, $form_state);
253 253
 }
254 254
 function content_rules_field_has_value_submit(&$settings, $form, &$form_state) {
255
-  content_rules_action_populate_field_submit($settings, $form, $form_state);
255
+    content_rules_action_populate_field_submit($settings, $form, $form_state);
256 256
 }
257 257
 
258 258
 function content_rules_field_has_value_label($settings, $argument_labels) {
259
-  return t("@node's field '@field' has value", array('@field' => $settings['field_name']) + $argument_labels);
259
+    return t("@node's field '@field' has value", array('@field' => $settings['field_name']) + $argument_labels);
260 260
 }
261 261
 
262 262
 /**
263 263
  * Condition: Check if the field has changed.
264 264
  */
265 265
 function content_rules_field_changed($node1, $node2, $settings) {
266
-  // Get information about the field.
267
-  $field = content_fields($settings['field_name'], $node1->type);
266
+    // Get information about the field.
267
+    $field = content_fields($settings['field_name'], $node1->type);
268 268
 
269
-  return !empty($field) && !_content_rules_field_has_value($node1->$settings['field_name'], $node2->$settings['field_name']);
269
+    return !empty($field) && !_content_rules_field_has_value($node1->$settings['field_name'], $node2->$settings['field_name']);
270 270
 }
271 271
 
272 272
 function content_rules_field_changed_form($settings, &$form, &$form_state) {
273
-  $settings += array('field_name' => '');
274
-  $form['settings']['field_name'] = array(
273
+    $settings += array('field_name' => '');
274
+    $form['settings']['field_name'] = array(
275 275
     '#type' => 'select',
276 276
     '#title' => t('Field'),
277 277
     '#options' => content_rules_get_field_names_by_type(),
278 278
     '#default_value' => $settings['field_name'],
279 279
     '#description' => t('Select the machine-name of the field to look at.'),
280 280
     '#required' => TRUE,
281
-  );
281
+    );
282 282
 }
283 283
 
284 284
 function content_rules_field_changed_label($settings, $argument_labels) {
285
-  return t("@node's field '@field' has been changed", array('@field' => $settings['field_name']) + $argument_labels);
285
+    return t("@node's field '@field' has been changed", array('@field' => $settings['field_name']) + $argument_labels);
286 286
 }
287 287
 
288 288
 
@@ -291,32 +291,32 @@  discard block
 block discarded – undo
291 291
  * Suitable for using it with #options.
292 292
  */
293 293
 function content_rules_get_field_names_by_type($type = NULL) {
294
-  $fields = array();
295
-  foreach (content_fields() as $field) {
294
+    $fields = array();
295
+    foreach (content_fields() as $field) {
296 296
     if (!isset($type) || $field['type'] == $type) {
297
-      $fields[$field['field_name']] = $field['field_name'];
297
+        $fields[$field['field_name']] = $field['field_name'];
298
+    }
298 299
     }
299
-  }
300
-  asort($fields);
301
-  return $fields;
300
+    asort($fields);
301
+    return $fields;
302 302
 }
303 303
 
304 304
 function _content_rules_get_field_value($settings, &$state) {
305
-  if ($settings['code']) {
305
+    if ($settings['code']) {
306 306
     if (function_exists('rules_input_evaluator_php_apply')) {
307
-      // Support adding variables to the php code, if php module is present.
308
-      $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, FALSE);
307
+        // Support adding variables to the php code, if php module is present.
308
+        $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, FALSE);
309 309
     }
310 310
     else {
311
-      ob_start();
312
-      $value = eval($settings['code']);
313
-      ob_end_clean();
311
+        ob_start();
312
+        $value = eval($settings['code']);
313
+        ob_end_clean();
314 314
     }
315
-  }
316
-  else {
315
+    }
316
+    else {
317 317
     $value = $settings['value'];
318
-  }
319
-  return $value;
318
+    }
319
+    return $value;
320 320
 }
321 321
 
322 322
 /**
@@ -329,20 +329,20 @@  discard block
 block discarded – undo
329 329
  * @param $value The value to check for.
330 330
  */
331 331
 function _content_rules_field_has_value($node_value, $value) {
332
-  if (count($value) != count($node_value)) {
332
+    if (count($value) != count($node_value)) {
333 333
     return FALSE;
334
-  }
335
-  // Loop over multiple fields
336
-  foreach ($value as $delta => $sub_value) {
334
+    }
335
+    // Loop over multiple fields
336
+    foreach ($value as $delta => $sub_value) {
337 337
     // Check if all properties of the value are there in the node value too
338 338
     if (is_array($sub_value) && is_array($node_value[$delta])) {
339
-      if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
339
+        if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
340 340
         return FALSE;
341
-      }
341
+        }
342 342
     }
343 343
     elseif ($sub_value !== $node_value[$delta]) {
344
-      return FALSE;
344
+        return FALSE;
345
+    }
345 346
     }
346
-  }
347
-  return TRUE;
347
+    return TRUE;
348 348
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
     $form['#node'] = (object)array('type' => '', $settings['field_name'] => $settings['value']);
74 74
     $form['#field_info'][$field['field_name']] = $field;
75 75
     // We can't put it into $form['settings'] as this would break AHAH callbacks
76
-    $form += (array) content_field_form($form, $form_state, $field);
77
-    $form[ $settings['field_name'] ]['#weight'] = 4;
76
+    $form += (array)content_field_form($form, $form_state, $field);
77
+    $form[$settings['field_name']]['#weight'] = 4;
78 78
 
79 79
     unset($form['#cache']);
80 80
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     // Add this file to be included when the form is built by rules
109 109
     // as it's needed by CCKs add more button.
110 110
     // See rules_after_build_include_files().
111
-    $form['#includes'][] = './'. drupal_get_path('module', 'node') .'/node.pages.inc';
111
+    $form['#includes'][] = './'.drupal_get_path('module', 'node').'/node.pages.inc';
112 112
   }
113 113
 }
114 114
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
     $settings = $form_state['element']['#settings'];
136 136
     $field = content_fields($settings['field_name']);
137 137
     $field_types = _content_field_types();
138
-    $function = $field_types[$field['type']]['module'] .'_field';
138
+    $function = $field_types[$field['type']]['module'].'_field';
139 139
     if (function_exists($function)) {
140 140
       $form['#node'] = (object)array('type' => '', $settings['field_name'] => $form_state['values'][$settings['field_name']]);
141 141
       $items = isset($form['#node']->$field['field_name']) ? $form['#node']->$field['field_name'] : array();
142 142
 
143 143
       //Make sure AHAH 'add more' button isn't sent to the fields
144 144
       // for processing.
145
-      unset($items[$field['field_name'] .'_add_more']);
145
+      unset($items[$field['field_name'].'_add_more']);
146 146
 
147 147
       $function('validate', $form['#node'], $field, $items, $form, NULL);
148 148
       content_field('validate', $form['#node'], $field, $items, $form, NULL);
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -64,8 +64,7 @@  discard block
 block discarded – undo
64 64
     // Replace the usual submit handlers with a own handler.
65 65
     $form['submit']['#submit'] = array('content_rules_action_populate_field_form_step_submit');
66 66
     $form['submit']['#value'] = t('Continue');
67
-  }
68
-  else {
67
+  } else {
69 68
     // Show the fields form here.
70 69
     module_load_include('inc', 'content', 'includes/content.node_form');
71 70
     $field = content_fields($settings['field_name']);
@@ -129,8 +128,7 @@  discard block
 block discarded – undo
129 128
     if (strpos($php, 'return') === FALSE) {
130 129
       form_set_error('code', t('You have to return the default value in the expected format.'));
131 130
     }
132
-  }
133
-  else {
131
+  } else {
134 132
     // Validate the field.
135 133
     $settings = $form_state['element']['#settings'];
136 134
     $field = content_fields($settings['field_name']);
@@ -306,14 +304,12 @@  discard block
 block discarded – undo
306 304
     if (function_exists('rules_input_evaluator_php_apply')) {
307 305
       // Support adding variables to the php code, if php module is present.
308 306
       $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, FALSE);
309
-    }
310
-    else {
307
+    } else {
311 308
       ob_start();
312 309
       $value = eval($settings['code']);
313 310
       ob_end_clean();
314 311
     }
315
-  }
316
-  else {
312
+  } else {
317 313
     $value = $settings['value'];
318 314
   }
319 315
   return $value;
@@ -339,8 +335,7 @@  discard block
 block discarded – undo
339 335
       if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
340 336
         return FALSE;
341 337
       }
342
-    }
343
-    elseif ($sub_value !== $node_value[$delta]) {
338
+    } elseif ($sub_value !== $node_value[$delta]) {
344 339
       return FALSE;
345 340
     }
346 341
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
  * This is a multistep form!
47 47
  */
48 48
 function content_rules_action_populate_field_form($settings, &$form, &$form_state) {
49
-  $settings += array('field_name' => '', 'code' => '', 'value' => NULL);
49
+  $settings += array('field_name' => '', 'code' => '', 'value' => null);
50 50
   if (empty($settings['field_name'])) {
51 51
     $form['settings']['field_name'] = array(
52 52
       '#type' => 'select',
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
       '#options' => content_rules_get_field_names_by_type(),
55 55
       '#default_value' => $settings['field_name'],
56 56
       '#description' => t('Select the machine-name of the field.'),
57
-      '#required' => TRUE,
57
+      '#required' => true,
58 58
     );
59 59
     // Hide some form elements in the first step.
60
-    $form['negate']['#access'] = FALSE;
61
-    $form['input_help']['#access'] = FALSE;
62
-    $form['weight']['#access'] = FALSE;
60
+    $form['negate']['#access'] = false;
61
+    $form['input_help']['#access'] = false;
62
+    $form['weight']['#access'] = false;
63 63
 
64 64
     // Replace the usual submit handlers with a own handler.
65 65
     $form['submit']['#submit'] = array('content_rules_action_populate_field_form_step_submit');
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     $form['advanced_options'] = array(
83 83
       '#type' => 'fieldset',
84 84
       '#title' => t('Advanced: Specify the fields value with PHP code'),
85
-      '#collapsible' => TRUE,
85
+      '#collapsible' => true,
86 86
       '#collapsed' => empty($settings['code']),
87 87
       '#weight' => 5,
88 88
     );
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
   }
127 127
 
128 128
   if (isset($form_state['values']['code']) && ($php = $form_state['values']['code'])) {
129
-    if (strpos($php, 'return') === FALSE) {
129
+    if (strpos($php, 'return') === false) {
130 130
       form_set_error('code', t('You have to return the default value in the expected format.'));
131 131
     }
132 132
   }
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
       // for processing.
145 145
       unset($items[$field['field_name'] .'_add_more']);
146 146
 
147
-      $function('validate', $form['#node'], $field, $items, $form, NULL);
148
-      content_field('validate', $form['#node'], $field, $items, $form, NULL);
147
+      $function('validate', $form['#node'], $field, $items, $form, null);
148
+      content_field('validate', $form['#node'], $field, $items, $form, null);
149 149
     }
150 150
   }
151 151
 }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
   $value = _content_rules_get_field_value($settings, $state);
237 237
 
238 238
   if (empty($field) || !is_array($value)) {
239
-    return FALSE;
239
+    return false;
240 240
   }
241 241
 
242 242
   return _content_rules_field_has_value($node->$settings['field_name'], $value);
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     '#options' => content_rules_get_field_names_by_type(),
278 278
     '#default_value' => $settings['field_name'],
279 279
     '#description' => t('Select the machine-name of the field to look at.'),
280
-    '#required' => TRUE,
280
+    '#required' => true,
281 281
   );
282 282
 }
283 283
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
  * Returns the fields of a given field type only.
291 291
  * Suitable for using it with #options.
292 292
  */
293
-function content_rules_get_field_names_by_type($type = NULL) {
293
+function content_rules_get_field_names_by_type($type = null) {
294 294
   $fields = array();
295 295
   foreach (content_fields() as $field) {
296 296
     if (!isset($type) || $field['type'] == $type) {
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
   if ($settings['code']) {
306 306
     if (function_exists('rules_input_evaluator_php_apply')) {
307 307
       // Support adding variables to the php code, if php module is present.
308
-      $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, FALSE);
308
+      $value = rules_input_evaluator_php_apply($settings['code'], $settings['vars'], $state, false);
309 309
     }
310 310
     else {
311 311
       ob_start();
@@ -330,19 +330,19 @@  discard block
 block discarded – undo
330 330
  */
331 331
 function _content_rules_field_has_value($node_value, $value) {
332 332
   if (count($value) != count($node_value)) {
333
-    return FALSE;
333
+    return false;
334 334
   }
335 335
   // Loop over multiple fields
336 336
   foreach ($value as $delta => $sub_value) {
337 337
     // Check if all properties of the value are there in the node value too
338 338
     if (is_array($sub_value) && is_array($node_value[$delta])) {
339 339
       if (count(array_diff_assoc($sub_value, $node_value[$delta])) != 0) {
340
-        return FALSE;
340
+        return false;
341 341
       }
342 342
     }
343 343
     elseif ($sub_value !== $node_value[$delta]) {
344
-      return FALSE;
344
+      return false;
345 345
     }
346 346
   }
347
-  return TRUE;
347
+  return true;
348 348
 }
Please login to merge, or discard this patch.