[dev] [commit] r1063 - phplib/models

automailer at dexonline.ro automailer at dexonline.ro
Fri Jan 17 10:55:10 EET 2014


Author: cata
Date: Fri Jan 17 10:55:10 2014
New Revision: 1063

Log:
Capture the {{cc|...}} and {{ccd|...}} formats when importing wiki articles.

Modified:
   phplib/models/WikiArticle.php

Modified: phplib/models/WikiArticle.php
==============================================================================
--- phplib/models/WikiArticle.php	Thu Jan 16 14:52:48 2014	(r1062)
+++ phplib/models/WikiArticle.php	Fri Jan 17 10:55:10 2014	(r1063)
@@ -4,17 +4,24 @@
   public static $_table = 'WikiArticle';
 
   public function extractKeywords() {
-    $matches = array();
-    if (!preg_match_all('/\{\{CuvinteCheie\|([^\}]+)\}\}/', $this->wikiContents, $matches)) {
-      return array();
-    }
     $result = array();
+
+    // Capture the {{CuvinteCheie|...}} template
+    $matches = array();
+    preg_match_all('/\{\{CuvinteCheie\|([^\}]+)\}\}/', $this->wikiContents, $matches);
     foreach ($matches[1] as $match) {
       $parts = explode(',', $match);
       foreach ($parts as $part) {
         $result[] = mb_strtolower(trim($part));
       }
     }
+
+    // Capture the {{cc|...}} and {{ccd|...}} templates
+    preg_match_all('/\{\{ccd?\|([^\}]+)\}\}/i', $this->wikiContents, $matches);
+    foreach ($matches[1] as $match) {
+      $parts = explode('|', $match);
+      $result[] = mb_strtolower(trim($parts[0]));
+    }
     return $result;
   }
 


More information about the Dev mailing list