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 !
* Added a "match" Twig filter.
* Modified the "replace" Twig filter to use preg_replace if the search begins 
with "/".
* Documentation updates.
* Moved the "Feather" interface to its own folder.
* Improved pluralize() and depluralize()
* Added the "top" Trigger back in.
* Only call the "runtime" filter if INDEX is true.
vito (author)
Tue Jul 22 22:50:18 -0700 2008
commit  10325041c602fd9c9d19b20be17810975b6f3917
tree    b0ebc8df4a9b79d1fa270fae04a8d5dfac678918
parent  7ec872a10a4e88fccdc1e45a1f75570d0db7ab75
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 <?php
0
   /**
0
    * Class: Query
0
-   * Handles a query based on the <SQL.interface>.
0
+   * Handles a query based on the <SQL.method>.
0
    */
0
   class Query {
0
     # Variable: $query
...
6
7
8
9
 
10
11
12
...
37
38
39
 
 
 
 
40
41
42
...
6
7
8
 
9
10
11
12
...
37
38
39
40
41
42
43
44
45
46
0
@@ -6,7 +6,7 @@
0
   class SQL {
0
     # Array: $yaml
0
     # An associative array of YAML-parsed settings.
0
-    # This is what gets altered/added to when using <SQL.set.
0
+    # This is what gets altered/added to when using <SQL.set>.
0
     public $yaml = array();
0
 
0
     # Array: $debug
0
@@ -37,6 +37,10 @@
0
       $this->connected = false;
0
     }
0
 
0
+    /**
0
+     * Function: method
0
+     * Returns the proper method of connecting and interacting with the database.
0
+     */
0
     public function method() {
0
       # We really don't need PDO anymore, since we have the two we supported with it hardcoded (kinda).
0
       # Keeping this here for when/if we decide to add support for more database engines, like Postgres and MSSQL.
...
43
44
45
 
46
47
48
...
273
274
275
276
 
 
 
 
 
 
 
277
278
279
...
43
44
45
46
47
48
49
...
274
275
276
 
277
278
279
280
281
282
283
284
285
286
0
@@ -43,6 +43,7 @@ $twig_filters = array(
0
   'normalize' =>        'normalize',
0
   'truncate' =>         'truncate',
0
   'replace' =>          'twig_replace_filter',
0
+  'match' =>            'twig_match_filter',
0
   'linebreaks' =>       'nl2br',
0
   'camelize' =>         'camelize',
0
   'strip_tags' =>       'strip_tags',
0
@@ -273,7 +274,13 @@ function twig_is_odd_filter($value)
0
 
0
 function twig_replace_filter($str, $search, $replace)
0
 {
0
-  return str_replace($search, $replace, $str);
0
+  $func = ($str[0] == "/") ? "preg_replace" : "str_replace" ;
0
+  return $func($search, $replace, $str);
0
+}
0
+
0
+function twig_match_filter($str, $match)
0
+{
0
+  return preg_match($match, $str);
0
 }
0
 
0
 
...
174
175
176
177
178
179
180
181
182
183
184
...
208
209
210
 
 
 
 
 
211
212
213
...
322
323
324
325
326
327
 
 
328
329
330
...
174
175
176
 
 
 
 
 
177
178
179
...
203
204
205
206
207
208
209
210
211
212
213
...
322
323
324
 
325
 
326
327
328
329
330
0
@@ -174,11 +174,6 @@
0
   #     <Module>
0
   require_once INCLUDES_DIR."/class/Modules.php";
0
 
0
-  # File: Feather
0
-  # See Also:
0
-  #     <Feather>
0
-  require_once INCLUDES_DIR."/class/Feather.php";
0
-
0
   # File: Feathers
0
   # See Also:
0
   #     <Feathers>
0
@@ -208,6 +203,11 @@
0
   #     <Admin Controller>
0
   require_once INCLUDES_DIR."/controller/Admin.php";
0
 
0
+  # File: Feather
0
+  # See Also:
0
+  #     <Feather>
0
+  require_once INCLUDES_DIR."/interface/Feather.php";
0
+
0
   timer_start();
0
 
0
   $flash = Flash::current();
0
@@ -322,9 +322,9 @@
0
       $route->check_viewing_post();
0
       $route->check_viewing_page(true);
0
     }
0
-  }
0
 
0
-  $trigger->call("runtime");
0
+    $trigger->call("runtime");
0
+  }
0
 
0
   # Array: $statuses
0
   # An array of post statuses that <Visitor> can view.
...
172
173
174
175
 
176
177
178
...
183
184
185
 
 
 
 
186
187
188
...
191
192
193
 
194
195
196
...
204
205
206
207
208
209
210
211
212
213
214
215
216
 
217
218
 
219
220
221
...
239
240
241
242
243
244
245
...
247
248
249
250
 
251
252
253
...
262
263
264
265
266
267
268
269
270
271
272
273
274
 
275
276
 
277
278
279
...
172
173
174
 
175
176
177
178
...
183
184
185
186
187
188
189
190
191
192
...
195
196
197
198
199
200
201
...
209
210
211
 
 
 
 
 
 
 
 
 
 
212
213
 
214
215
216
217
...
235
236
237
 
238
239
240
...
242
243
244
 
245
246
247
248
...
257
258
259
 
 
 
 
 
 
 
 
 
 
260
261
 
262
263
264
265
0
@@ -172,7 +172,7 @@
0
 
0
   /**
0
    * Function: pluralize
0
-   * Returns a pluralized string. This is a port of Rails' pluralizer.
0
+   * Returns a pluralized string. This is a port of Rails's pluralizer.
0
    *
0
    * Parameters:
0
    *     $string - The string to pluralize.
0
@@ -183,6 +183,10 @@
0
       return $pluralizations[$string];
0
     else {
0
       $uncountable = array("moose", "sheep", "fish", "series", "species", "rice", "money", "information", "equipment", "piss");
0
+
0
+      if (in_array($string, $uncountable))
0
+        return $string;
0
+
0
       $replacements = array("/person/i" => "people",
0
                             "/man/i" => "men",
0
                             "/child/i" => "children",
0
@@ -191,6 +195,7 @@
0
                             "/(penis)$/i" => "\\1es", # Take that, Rails!
0
                             "/(ax|test)is$/i" => "\\1es",
0
                             "/(octop|vir)us$/i" => "\\1ii",
0
+                            "/(cact)us$/i" => "\\1i",
0
                             "/(alias|status)$/i" => "\\1es",
0
                             "/(bu)s$/i" => "\\1ses",
0
                             "/(buffal|tomat)o$/i" => "\\1oes",
0
@@ -204,18 +209,9 @@
0
                             "/([m|l])ouse$/i" => "\\1ice",
0
                             "/(quiz)$/i" => "\\1zes");
0
 
0
-      $replaced = $string;
0
-      foreach ($replacements as $key => $val) {
0
-        if (in_array($string, $uncountable))
0
-          break;
0
-
0
-        $replaced = preg_replace($key, $val, $string);
0
-
0
-        if ($replaced != $string)
0
-          break;
0
-      }
0
+      $replaced = preg_replace(array_keys($replacements), array_values($replacements), $string, 1);
0
 
0
-      if ($replaced == $string and !in_array($string, $uncountable))
0
+      if ($replaced == $string)
0
         return $string."s";
0
       else
0
         return $replaced;
0
@@ -239,7 +235,6 @@
0
     if (isset($reversed[$string]))
0
       return $reversed[$string];
0
     else {
0
-      $uncountable = array("moose", "sheep", "fish", "series", "species", "rice", "money", "information", "equipment", "piss");
0
       $replacements = array("/people/i" => "person",
0
                             "/^men/i" => "man",
0
                             "/children/i" => "child",
0
@@ -247,7 +242,7 @@
0
                             "/geese/i" => "goose",
0
                             "/(penis)es$/i" => "\\1",
0
                             "/(ax|test)es$/i" => "\\1is",
0
-                            "/(octop|vir)ii$/i" => "\\1us",
0
+                            "/(octopi|viri|cact)i$/i" => "\\1us",
0
                             "/(alias|status)es$/i" => "\\1",
0
                             "/(bu)ses$/i" => "\\1s",
0
                             "/(buffal|tomat)oes$/i" => "\\1o",
0
@@ -262,18 +257,9 @@
0
                             "/([m|l])ice$/i" => "\\1ouse",
0
                             "/(quiz)zes$/i" => "\\1");
0
 
0
-      $replaced = $string;
0
-      foreach ($replacements as $key => $val) {
0
-        if (in_array($string, $uncountable))
0
-          break;
0
-
0
-        $replaced = preg_replace($key, $val, $string, 1);
0
-
0
-        if ($replaced != $string)
0
-          break;
0
-      }
0
+      $replaced = preg_replace(array_keys($replacements), array_values($replacements), $string, 1);
0
 
0
-      if ($replaced == $string and !in_array($string, $uncountable) and substr($string, -1) == "s")
0
+      if ($replaced == $string and substr($string, -1) == "s")
0
         return substr($string, 0, -1);
0
       else
0
         return $replaced;
...
1
2
3
 
 
4
5
6
...
1
2
3
4
5
6
7
8
0
@@ -1,6 +1,8 @@
0
 <?php
0
   require_once "includes/common.php";
0
 
0
+  $trigger->call("top");
0
+
0
   switch($route->action) {
0
     case "index": case "search": case "drafts": case "feather":
0
       $context = array("posts" => $posts);
...
6
7
8
9
 
...
6
7
8
 
9
0
@@ -6,4 +6,4 @@ author:
0
   name: Alex Suraci
0
   url: http://i.am.toogeneric.com/
0
 notifications:
0
-  - Please make sure that /includes/cache is writable by the server. If you are not certain whether it is or not, CHMOD it to 777.
0
+  - Please make sure that /includes/caches is writable by the server. If you are not certain whether it is or not, CHMOD it to 777.

Comments