public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
* Improved QueryBuilder::tablefy
* Improved gettext scanner
vito (author)
Wed Jul 23 17:46:41 -0700 2008
commit  c252c563f30d461d23c3172e68cab4db2de1921e
tree    941bd081477c4438f03df798bfc4897fc90e2f93
parent  5650e9ed3092294fb418d7a0c2e1e706e8510a43
...
98
99
100
101
 
102
103
104
...
110
111
112
113
 
114
115
116
...
122
123
124
125
 
126
127
128
...
134
135
136
137
 
138
139
140
...
146
147
148
149
 
150
151
152
...
158
159
160
161
 
162
163
164
...
98
99
100
 
101
102
103
104
...
110
111
112
 
113
114
115
116
...
122
123
124
 
125
126
127
128
...
134
135
136
 
137
138
139
140
...
146
147
148
 
149
150
151
152
...
158
159
160
 
161
162
163
164
0
@@ -98,7 +98,7 @@ class Gettext
0
   end
0
 
0
   def scan_normal(text, line, filename, clean_filename)
0
-    text.gsub(/__\(("|')([^"]+)\1#{@domain}\)/) do
0
+    text.gsub(/__\(("|')([^\1]+)\1#{@domain}\)/) do
0
       if @translations[$2].nil?
0
         @translations[$2] = { :places => [clean_filename + ":" + line.to_s],
0
                               :filter => false,
0
@@ -110,7 +110,7 @@ class Gettext
0
   end
0
 
0
   def scan_filter(text, line, filename, clean_filename)
0
-    text.gsub(/_f\(("|')([^"]+)\1, .*?#{@domain}\)/) do
0
+    text.gsub(/_f\(("|')([^\1]+)\1, .*?#{@domain}\)/) do
0
       if @translations[$2].nil?
0
         @translations[$2] = { :places => [clean_filename + ":" + line.to_s],
0
                               :filter => true,
0
@@ -122,7 +122,7 @@ class Gettext
0
   end
0
 
0
   def scan_plural(text, line, filename, clean_filename)
0
-    text.gsub(/_p\(("|')([^"]+)\1, ("|')([^"]+)\3, .*?#{@domain}\)/) do
0
+    text.gsub(/_p\(("|')([^\1]+)\1, ("|')([^\3]+)\3, .*?#{@domain}\)/) do
0
       if @translations[$2].nil?
0
         @translations[$2] = { :places => [clean_filename + ":" + line.to_s],
0
                               :filter => true,
0
@@ -134,7 +134,7 @@ class Gettext
0
   end
0
 
0
   def scan_twig(text, line, filename, clean_filename)
0
-    text.gsub(/("|')([^"]+)\1 ?\| ?translate(?!_plural)#{@twig_domain}(?! ?\| ?format)/) do
0
+    text.gsub(/("|')([^\1]+)\1 ?\| ?translate(?!_plural)#{@twig_domain}(?! ?\| ?format)/) do
0
       if @translations[$2].nil?
0
         @translations[$2] = { :places => [clean_filename + ":" + line.to_s],
0
                               :filter => false,
0
@@ -146,7 +146,7 @@ class Gettext
0
   end
0
 
0
   def scan_twig_filter(text, line, filename, clean_filename)
0
-    text.gsub(/("|')([^"]+)\1 ?\| ?translate(?!_plural)#{@twig_domain} ?\| ?format\(.*?\).*?/) do
0
+    text.gsub(/("|')([^\1]+)\1 ?\| ?translate(?!_plural)#{@twig_domain} ?\| ?format\(.*?\).*?/) do
0
       if @translations[$2].nil?
0
         @translations[$2] = { :places => [clean_filename + ":" + line.to_s],
0
                               :filter => true,
0
@@ -158,7 +158,7 @@ class Gettext
0
   end
0
 
0
   def scan_twig_plural(text, line, filename, clean_filename)
0
-    text.gsub(/("|')([^"]+)\1 ?\| ?translate_plural\(("|')([^"]+)\3, .*?#{@domain}\) ?\| ?format\(.*?\)/) do
0
+    text.gsub(/("|')([^\1]+)\1 ?\| ?translate_plural\(("|')([^\3]+)\3, .*?#{@domain}\) ?\| ?format\(.*?\)/) do
0
       if @translations[$2].nil?
0
         @translations[$2] = { :places => [clean_filename + ":" + line.to_s],
0
                               :filter => true,
...
193
194
195
 
 
 
 
 
 
 
 
196
197
198
...
207
208
209
210
 
211
212
213
...
215
216
217
218
 
219
220
221
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
...
215
216
217
 
218
219
220
221
...
223
224
225
 
226
227
228
229
0
@@ -193,6 +193,14 @@
0
       return $query;
0
     }
0
 
0
+    /**
0
+     * Function: tablefy
0
+     * Automatically prepends tables and table prefixes to a field if it doesn't already have them.
0
+     *
0
+     * Parameters:
0
+     *     $field - The field to "tablefy".
0
+     *     $tables - An array of tables. The first one will be used for prepending.
0
+     */
0
     public static function tablefy(&$field, $tables) {
0
       if (!preg_match_all("/(\(|^)?([a-z_\.]+)/", $field, $matches))
0
         return;
0
@@ -207,7 +215,7 @@
0
         # Does it not already have a table specified?
0
         if (!substr_count($full, ".")) {
0
                                # Don't replace things that are already either prefixed or paramized.
0
-          $field = preg_replace("/([^\.:'_]|^)".preg_quote($full, "/")."/",
0
+          $field = preg_replace("/([^\.:'\"_]|^)".preg_quote($full, "/")."/",
0
                                 "\\1".$paren."__".$tables[0].".".$name,
0
                                 $field,
0
                                 1);
0
@@ -215,7 +223,7 @@
0
           # Okay, it does, but is the table prefixed?
0
           if (substr($full, 0, 2) != "__") {
0
                                    # Don't replace things that are already either prefixed or paramized.
0
-            $field = preg_replace("/([^\.:'_]|^)".preg_quote($full, "/")."/",
0
+            $field = preg_replace("/([^\.:'\"_]|^)".preg_quote($full, "/")."/",
0
                                   "\\1".$paren."__".$name,
0
                                   $field,
0
                                   1);

Comments