public this repo is viewable by everyone
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
Using each commands with references instead of foreach for module 
callbacks
Removed some modules that went into a misc repository


git-svn-id: http://svn.cmsmadesimple.org/svn/cmsmadesimple/trunk@2439 
3d254a34-79dc-0310-9e5f-be208747d8a0
tedkulp (author)
over 2 years ago
commit  7baeb7d3a130cac603a3388a32a05f41006c8e31
tree    d40a8c7c7dc06d3a8338adae5ea3734b16ac8661
parent  776457f7fcf280dad754a2b056a065a6a7306496
...
142
143
144
145
 
 
146
 
147
148
149
...
153
154
155
156
 
 
157
 
158
159
160
...
142
143
144
 
145
146
147
148
149
150
151
...
155
156
157
 
158
159
160
161
162
163
164
0
@@ -142,8 +142,10 @@ if ((get_site_preference('enablecustom404') == '' || get_site_preference('enable
0
 if (!$cached)
0
 {
0
   #Perform the content postrendernoncached callback
0
-  foreach($gCms->modules as $key=>$value)
0
+  reset($gCms->modules);
0
+  while (list($key) = each($gCms->modules))
0
   {
0
+    $value =& $gCms->modules[$key];
0
     if ($gCms->modules[$key]['installed'] == true &&
0
       $gCms->modules[$key]['active'] == true)
0
     {
0
@@ -153,8 +155,10 @@ if (!$cached)
0
 }
0
 
0
 #Perform the content postrender callback
0
-foreach($gCms->modules as $key=>$value)
0
+reset($gCms->modules);
0
+while (list($key) = each($gCms->modules))
0
 {
0
+  $value =& $gCms->modules[$key];
0
   if ($gCms->modules[$key]['installed'] == true &&
0
     $gCms->modules[$key]['active'] == true)
0
   {
...
214
215
216
217
218
 
 
 
 
219
220
221
...
214
215
216
 
 
217
218
219
220
221
222
223
0
@@ -214,8 +214,10 @@ class AdminTheme
0
     {
0
       # Are there any modules with an admin interface?
0
         $cmsmodules = $this->cms->modules;
0
- foreach ($cmsmodules as $key=>$value)
0
- {
0
+    reset($cmsmodules);
0
+    while (list($key) = each($cmsmodules))
0
+    {
0
+      $value =& $cmsmodules[$key];
0
             if (isset($cmsmodules[$key]['object'])
0
                 && $cmsmodules[$key]['installed'] == true
0
                 && $cmsmodules[$key]['active'] == true
...
192
193
194
195
 
 
196
 
197
198
199
...
256
257
258
259
 
 
260
 
261
262
263
...
281
282
283
284
 
 
285
 
286
287
288
...
293
294
295
296
 
 
297
 
298
299
300
...
308
309
310
311
 
 
312
 
313
314
315
...
321
322
323
324
 
 
325
 
326
327
328
...
394
395
396
397
 
 
398
 
399
400
401
...
471
472
473
474
 
 
475
 
476
477
478
...
481
482
483
484
 
 
485
 
486
487
488
...
554
555
556
557
 
 
558
 
559
560
561
...
565
566
567
568
 
 
569
 
570
571
572
...
689
690
691
692
 
 
693
 
694
695
696
...
715
716
717
718
 
 
719
 
720
721
722
...
728
729
730
731
 
 
732
 
733
734
735
...
787
788
789
790
 
 
791
 
792
793
794
...
805
806
807
808
 
 
809
 
810
811
812
...
1038
1039
1040
1041
 
 
1042
 
1043
1044
1045
...
192
193
194
 
195
196
197
198
199
200
201
...
258
259
260
 
261
262
263
264
265
266
267
...
285
286
287
 
288
289
290
291
292
293
294
...
299
300
301
 
302
303
304
305
306
307
308
...
316
317
318
 
319
320
321
322
323
324
325
...
331
332
333
 
334
335
336
337
338
339
340
...
406
407
408
 
409
410
411
412
413
414
415
...
485
486
487
 
488
489
490
491
492
493
494
...
497
498
499
 
500
501
502
503
504
505
506
...
572
573
574
 
575
576
577
578
579
580
581
...
585
586
587
 
588
589
590
591
592
593
594
...
711
712
713
 
714
715
716
717
718
719
720
...
739
740
741
 
742
743
744
745
746
747
748
...
754
755
756
 
757
758
759
760
761
762
763
...
815
816
817
 
818
819
820
821
822
823
824
...
835
836
837
 
838
839
840
841
842
843
844
...
1070
1071
1072
 
1073
1074
1075
1076
1077
1078
1079
0
@@ -192,8 +192,10 @@ class Smarty_CMS extends Smarty {
0
       $text = $oneblob->content;
0
 
0
       #Perform the content htmlblob callback
0
-      foreach($gCms->modules as $key=>$value)
0
+      reset($gCms->modules);
0
+      while (list($key) = each($gCms->modules))
0
       {
0
+        $value =& $gCms->modules[$key];
0
         if ($gCms->modules[$key]['installed'] == true &&
0
           $gCms->modules[$key]['active'] == true)
0
         {
0
@@ -256,8 +258,10 @@ class Smarty_CMS extends Smarty {
0
     $tpl_source = $data["template"];
0
 
0
     #Perform the content template callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
0
@@ -281,8 +285,10 @@ class Smarty_CMS extends Smarty {
0
     }
0
     
0
     #Perform the content stylesheet callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       $gCms->modules[$key]['object']->ContentStylesheet($stylesheet);
0
     }
0
 
0
@@ -293,8 +299,10 @@ class Smarty_CMS extends Smarty {
0
     $content = $data["content"];
0
 
0
     #Perform the content data callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
0
@@ -308,8 +316,10 @@ class Smarty_CMS extends Smarty {
0
     $menutext = $data['menutext'];
0
 
0
     #Perform the content title callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
0
@@ -321,8 +331,10 @@ class Smarty_CMS extends Smarty {
0
     $tpl_source = ereg_replace("\{menutext\}", $menutext, $tpl_source);
0
 
0
     #Perform the content prerender callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
0
@@ -394,8 +406,10 @@ class Smarty_CMS extends Smarty {
0
           }
0
 
0
           #Perform the content template callback
0
-          foreach($gCms->modules as $key=>$value)
0
+          reset($gCms->modules);
0
+          while (list($key) = each($gCms->modules))
0
           {
0
+            $value =& $gCms->modules[$key];
0
             if ($gCms->modules[$key]['installed'] == true &&
0
               $gCms->modules[$key]['active'] == true)
0
             {
0
@@ -471,8 +485,10 @@ class Smarty_CMS extends Smarty {
0
 
0
         #Perform the content data callback
0
         #This needs to go...
0
-        foreach($gCms->modules as $key=>$value)
0
+        reset($gCms->modules);
0
+        while (list($key) = each($gCms->modules))
0
         {
0
+          $value =& $gCms->modules[$key];
0
           if ($gCms->modules[$key]['installed'] == true &&
0
             $gCms->modules[$key]['active'] == true)
0
           {
0
@@ -481,8 +497,10 @@ class Smarty_CMS extends Smarty {
0
         }
0
 
0
         #Perform the content prerender callback
0
-        foreach($gCms->modules as $key=>$value)
0
+        reset($gCms->modules);
0
+        while (list($key) = each($gCms->modules))
0
         {
0
+          $value =& $gCms->modules[$key];
0
           if ($gCms->modules[$key]['installed'] == true &&
0
             $gCms->modules[$key]['active'] == true)
0
           {
0
@@ -554,8 +572,10 @@ class Smarty_CMS extends Smarty {
0
       $tpl_source = $modoutput;
0
 
0
       #Perform the content data callback
0
-      foreach($gCms->modules as $key=>$value)
0
+      reset($gCms->modules);
0
+      while (list($key) = each($gCms->modules))
0
       {
0
+        $value =& $gCms->modules[$key];
0
         if ($gCms->modules[$key]['installed'] == true &&
0
           $gCms->modules[$key]['active'] == true)
0
         {
0
@@ -565,8 +585,10 @@ class Smarty_CMS extends Smarty {
0
     }
0
 
0
     #Perform the content prerender callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
0
@@ -689,8 +711,10 @@ class Smarty_CMS extends Smarty {
0
         }
0
 
0
         #Perform the content template callback
0
-        foreach($gCms->modules as $key=>$value)
0
+        reset($gCms->modules);
0
+        while (list($key) = each($gCms->modules))
0
         {
0
+          $value =& $gCms->modules[$key];
0
           if ($gCms->modules[$key]['installed'] == true &&
0
             $gCms->modules[$key]['active'] == true)
0
           {
0
@@ -715,8 +739,10 @@ class Smarty_CMS extends Smarty {
0
           $content = $contentobj->Show();
0
 
0
           #Perform the content data callback
0
-          foreach($gCms->modules as $key=>$value)
0
+          reset($gCms->modules);
0
+          while (list($key) = each($gCms->modules))
0
           {
0
+            $value =& $gCms->modules[$key];
0
             if ($gCms->modules[$key]['installed'] == true &&
0
               $gCms->modules[$key]['active'] == true)
0
             {
0
@@ -728,8 +754,10 @@ class Smarty_CMS extends Smarty {
0
           $menutext = $contentobj->MenuText();
0
 
0
           #Perform the content title callback
0
-          foreach($gCms->modules as $key=>$value)
0
+          reset($gCms->modules);
0
+          while (list($key) = each($gCms->modules))
0
           {
0
+            $value =& $gCms->modules[$key];
0
             if ($gCms->modules[$key]['installed'] == true &&
0
               $gCms->modules[$key]['active'] == true)
0
             {
0
@@ -787,8 +815,10 @@ class Smarty_CMS extends Smarty {
0
         $tpl_source = ereg_replace("\{menutext\}", $menutext, $tpl_source);
0
 
0
         #Perform the content prerender callback
0
-        foreach($gCms->modules as $key=>$value)
0
+        reset($gCms->modules);
0
+        while (list($key) = each($gCms->modules))
0
         {
0
+          $value =& $gCms->modules[$key];
0
           if ($gCms->modules[$key]['installed'] == true &&
0
             $gCms->modules[$key]['active'] == true)
0
           {
0
@@ -805,8 +835,10 @@ class Smarty_CMS extends Smarty {
0
           $tpl_source = get_site_preference('custom404');
0
 
0
           #Perform the content prerender callback
0
-          foreach($gCms->modules as $key=>$value)
0
+          reset($gCms->modules);
0
+          while (list($key) = each($gCms->modules))
0
           {
0
+            $value =& $gCms->modules[$key];
0
             if ($gCms->modules[$key]['installed'] == true &&
0
               $gCms->modules[$key]['active'] == true)
0
             {
0
@@ -1038,8 +1070,10 @@ function global_content_regex_callback($matches)
0
       $text = $oneblob->content;
0
 
0
       #Perform the content htmlblob callback
0
-      foreach($gCms->modules as $key=>$value)
0
+      reset($gCms->modules);
0
+      while (list($key) = each($gCms->modules))
0
       {
0
+        $value =& $gCms->modules[$key];
0
         if ($gCms->modules[$key]['installed'] == true &&
0
           $gCms->modules[$key]['active'] == true)
0
         {
...
680
681
682
683
 
 
684
 
685
686
687
...
913
914
915
916
 
 
917
 
918
919
920
...
680
681
682
 
683
684
685
686
687
688
689
...
915
916
917
 
918
919
920
921
922
923
924
0
@@ -680,8 +680,10 @@ function create_textarea($enablewysiwyg, $text, $name, $classname='', $id='', $e
0
     $userid = get_userid();
0
     $wysiwyg = get_preference($userid, 'wysiwyg');
0
 
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if (get_preference(get_userid(), 'wysiwyg')!="" &&
0
         $gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true &&
0
@@ -913,8 +915,10 @@ function wysiwyg_form_submit()
0
   if (isset($wysiwyg) && $wysiwyg != '')
0
   {
0
     #Perform the content title callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
...
72
73
74
75
 
 
76
 
77
78
79
...
97
98
99
100
 
 
101
 
102
103
104
...
109
110
111
112
 
 
113
 
114
115
116
...
124
125
126
127
 
 
128
 
129
130
131
...
162
163
164
165
 
 
166
 
167
168
169
...
72
73
74
 
75
76
77
78
79
80
81
...
99
100
101
 
102
103
104
105
106
107
108
...
113
114
115
 
116
117
118
119
120
121
122
...
130
131
132
 
133
134
135
136
137
138
139
...
170
171
172
 
173
174
175
176
177
178
179
0
@@ -72,8 +72,10 @@ class Smarty_Preview extends Smarty {
0
     $tpl_source = $data["template"];
0
 
0
     #Perform the content template callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
0
@@ -97,8 +99,10 @@ class Smarty_Preview extends Smarty {
0
     }
0
     
0
     #Perform the content stylesheet callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       $gCms->modules[$key]['object']->ContentStylesheet($stylesheet);
0
     }
0
 
0
@@ -109,8 +113,10 @@ class Smarty_Preview extends Smarty {
0
     $content = $data["content"];
0
 
0
     #Perform the content data callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
0
@@ -124,8 +130,10 @@ class Smarty_Preview extends Smarty {
0
     $menutext = $data['menutext'];
0
 
0
     #Perform the content title callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
0
@@ -162,8 +170,10 @@ class Smarty_Preview extends Smarty {
0
     }
0
 
0
     #Perform the content prerender callback
0
-    foreach($gCms->modules as $key=>$value)
0
+    reset($gCms->modules);
0
+    while (list($key) = each($gCms->modules))
0
     {
0
+      $value =& $gCms->modules[$key];
0
       if ($gCms->modules[$key]['installed'] == true &&
0
         $gCms->modules[$key]['active'] == true)
0
       {
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
0
@@ -1,326 +0,0 @@
0
-<?php
0
-# This is a string replacement module (c) 2005 by INTESOL SRL (Mihai Cimpoeru & Sorin Sbarnea)
0
-# to enhance the project
0
-#CMS - CMS Made Simple
0
-#(c)2004 by Ted Kulp (wishy@users.sf.net)
0
-#This project's homepage is: http://cmsmadesimple.sf.net
0
-#
0
-#$Id$
0
-
0
-class PermaLinks extends CMSModule
0
-{
0
-
0
- function GetName()
0
- {
0
- return 'PermaLinks';
0
- }
0
-
0
- function GetVersion()
0
- {
0
- return '0.1';
0
- }
0
-
0
- function GetHelp($lang = 'en_US')
0
- {
0
-   return '<h3>What does this do?</h3>
0
- <p>This should enable writing of rewrite rules for apache</p>';
0
- }
0
-
0
- function GetDescription($lang = 'en_US')
0
- {
0
- return '.';
0
- }
0
-
0
- function GetChangeLog()
0
- {
0
- return '<p>0.1 First version</p>';
0
- }
0
-
0
- function GetAuthor()
0
- {
0
- return 'INTERSOL SRL';
0
- }
0
-
0
- function GetAuthorEmail()
0
- {
0
- return 'support@intersol.ro';
0
- }
0
-
0
-
0
- function IsContentModule()
0
- {
0
- return true;
0
- }
0
-
0
- function HasAdmin()
0
- {
0
- return false;
0
- }
0
-
0
- function InstallPostMessage()
0
- {
0
- return 'No further action required.';
0
- }
0
-
0
- function Install()
0
- {
0
- $this->Audit( 0, 'Module_PermaLinks', 'Install V'.$this->getVersion());
0
- }
0
-
0
- function Upgrade($oldversion, $newversion) {
0
-
0
- $current_version = $oldversion;
0
- $ret = 0;
0
-
0
- switch($current_version)
0
- {
0
- default:break;
0
- }
0
- if ($current_version == $this->GetVersion()) {
0
- $this->Audit( 0, 'Module_PermaLinks', 'Update V'.$oldversion.' &rarr; V'.$newversion);
0
- return FALSE;
0
- }
0
- else return 'Module_PermaLinks upgrade failed!';
0
- }
0
-
0
-
0
- function Uninstall()
0
- {
0
- $this->Audit( 0, 'Module_PermaLinks', 'Uninstall V'.$this->getVersion());
0
- }
0
-
0
-
0
- function ContentEditPost()
0
-  {
0
-    if (!$this->save_mod_rewrite_rules())
0
-     return "Could not rewrite .htaccess.";
0
-  }
0
-
0
- function ContentDeletePost()
0
-  {
0
-    if (!$this->save_mod_rewrite_rules())
0
-     return "Could not rewrite .htaccess.";
0
-  }
0
-
0
-  function trailingslashit($string) {
0
-   if ( '/' != substr($string, -1)) {
0
-   $string .= '/';
0
-   }
0
-   return $string;
0
-  }
0
-  
0
-   function mod_rewrite_rules() {
0
- global $config;
0
-    $site_root = $config['root_url'];
0
-    $home_root = $this->trailingslashit($config['root_path']);
0
-
0
-
0
-    $rules = "<IfModule mod_rewrite.c>\n";
0
-    $rules .= "RewriteEngine On\n";
0
-    $rules .= "RewriteBase \"$home_root\"\n";
0
-    $this->matches = '';
0
-    $rewrite = $this->rewrite_rules();
0
-    $num_rules = count($rewrite);
0
-/*
0
-     // This is the old version, new version is trying static pages but not folders. So the virtual page will be used instead of the index of the folder.
0
-    $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
0
-      "RewriteCond %{REQUEST_FILENAME} -d\n" .
0
-      "RewriteRule ^.*$ - [S=$num_rules]\n";
0
-*/
0
-    $rules .= "RewriteCond %{REQUEST_FILENAME} -f\n" .
0
-      "RewriteRule ^.*$ - [S=$num_rules]\n";
0
-    
0
-    foreach ($rewrite as $match => $query) {
0
-      // Apache 1.3 does not support the reluctant (non-greedy) modifier.
0
-      $match = str_replace('.+?', '.+', $match);
0
-
0
-      // If the match is unanchored and greedy, prepend rewrite conditions
0
-      // to avoid infinite redirects and eclipsing of real files.
0
-      if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
0
-        //nada.
0
-      }
0
-/* I don't understand this section below. $home_root is a filesystem path, so the
0
- rewrite would fail, it seems to me. I'm no mod_rewrite expert, though.
0
- In any case, $this->index is undefined, so that first clause would never
0
- get triggered. So I chopped it. SjG
0
-      if (strstr($query, $this->index)) {
0
-        $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
0
-      } else {
0
-        $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
0
-      }
0
-*/ $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
0
-
0
-    }
0
-    $rules .= "</IfModule>\n";
0
-
0
-    return $rules;
0
-  }
0
-
0
-
0
-  function save_mod_rewrite_rules() {
0
-    global $config;
0
-
0
-    if ( ! ((!file_exists($config['root_path'].'/.htaccess') && is_writable($config['root_path'] . '/')) || is_writable($config['root_path'].'/.htaccess')) )
0
-    return;
0
-
0
-    $rules = explode("\n", $this->mod_rewrite_rules());
0
-    $this->insert_with_markers($config['root_path'].'/.htaccess', 'PermaLinks', $rules);
0
-
0
-    return true;
0
-  }
0
-// --------------------
0
-  function rewrite_rules() {
0
-  $rewrite = array();
0
-
0
-  global $db;
0
-  $allcontent = ContentManager::GetAllContent();
0
-
0
-  # defining variables
0
-  $menu = "";
0
-  $last_level = 0;
0
-  $count = 0;
0
-  $in_hr = 0;
0
-
0
-  foreach ($allcontent as $onecontent)
0
-  {
0
-    #Handy little trick to figure out how deep in the tree we are
0
-    #Remember, content comes to use in order of how it should be displayed in the tree already
0
-    $depth = count(split('\.', $onecontent->Hierarchy()));
0
-
0
-    #If hierarchy starts with the start_element (if it's set), then continue on
0
-    if (isset($params['start_element']))
0
-    {
0
-      if (!(strpos($onecontent->Hierarchy(), $params['start_element']) !== FALSE && strpos($onecontent->Hierarchy(), $params['start_element']) == 0))
0
-      {
0
-        continue;
0
-      }
0
-    }
0
-
0
-    #Now check to make sure we're not too many levels deep if number_of_levels is set
0
-    if (isset($params['number_of_levels']))
0
-    {
0
-      $number_of_levels = $params['number_of_levels'] - 1;
0
-      $base_level = 1;
0
-      
0
-      #Is start_element set? If so, reset the base_level to it's level
0
-      if (isset($params['start_element']))
0
-      {
0
-        $base_level = count(split('\.', $params['start_element']));
0
-      }
0
-
0
-      #If this element's level is more than base_level + number_of_levels, then scratch it
0
-      if ($base_level + $number_of_levels < $depth)
0
-      {
0
-        continue;
0
-      }
0
-    }
0
-
0
-    if (!$onecontent->Active())
0
-    {
0
-      continue;
0
-    }
0
-
0
-    if ($onecontent->Type() == 'separator')
0
-    {
0
-      continue;
0
-    }
0
-
0
-    if ($onecontent->Type() == 'sectionheader')
0
-    {
0
-      if ($in_hr == 1)
0
-      {
0
-        $in_hr = 0;
0
-      }
0
- $rewrite[$onecontent->MenuText() . '/?$']="/index.php?page=" . $onecontent->MenuText();
0
-
0
-      if ($count > 0 && $in_hr == 0)
0
-      {
0
-        $in_hr = 1;
0
-      }
0
-    }
0
-    else
0
-    {
0
-      $menu .= "<li><h2><a href=\"".$onecontent->GetURL()."\">".$onecontent->MenuText();
0
-      if ($onecontent->Name() != '')
0
-      {
0
- $rewrite[ $onecontent->Alias() . '/?$']="/index.php?page=" . $onecontent->Alias();
0
-
0
-      }
0
-      $in_hr = 1;
0
-      $last_level = $depth;
0
-    }
0
-    $count++;
0
-  }
0
-
0
-    return $rewrite;
0
-  }
0
-// --------------------
0
-
0
-// Inserts an array of strings into a file (.htaccess), placing it between
0
-// BEGIN and END markers. Replaces existing marked info. Retains surrounding
0
-// data. Creates file if none exists.
0
-// Returns true on write success, false on failure.
0
-function insert_with_markers($filename, $marker, $insertion) {
0
-  if (!file_exists($filename) || is_writeable($filename)) {
0
-    if (!file_exists($filename)) {
0
-      $markerdata = '';
0
-    } else {
0
-      $markerdata = ex