Author: jablko
Date: Fri Oct 29 12:13:46 2010
New Revision: 8659

Log:
Turn slugs into properties, to avoid trying to insert duplicate slugs

Modified:
   trunk/lib/helper/QubitHelper.php
   trunk/lib/task/migrate/QubitMigrate109.class.php

Modified: trunk/lib/helper/QubitHelper.php
==============================================================================
--- trunk/lib/helper/QubitHelper.php    Fri Oct 29 12:10:26 2010        (r8658)
+++ trunk/lib/helper/QubitHelper.php    Fri Oct 29 12:13:46 2010        (r8659)
@@ -117,16 +117,16 @@
 
 function render_value($value)
 {
-  ProjectConfiguration::getActive()->loadHelpers('Text');
+  //ProjectConfiguration::getActive()->loadHelpers('Text');
 
-  $value = auto_link_text($value);
+  //$value = auto_link_text($value);
 
   // Simple lists
   $value = preg_replace('/(?:^\*.*\r?\n)*(?:^\*.*)/m', "<ul>\n$0\n</ul>", 
$value);
   $value = preg_replace('/(?:^-.*\r?\n)*(?:^-.*)/m', "<ul>\n$0\n</ul>", 
$value);
-  $value = preg_replace('/^(?:\*|-)\s*(.*)/m', '<li>$1</li>', $value);
+  $value = preg_replace('/^(?:\*|-)\s*(.*)(?:\r?\n)?/m', '<li>$1</li>', 
$value);
 
-  $value = preg_replace('/(?:\r?\n){2,}/', "</p>\n<p>", $value, -1, $count);
+  $value = preg_replace('/(?:\r?\n){2,}/', "</p><p>", $value, -1, $count);
   if (0 < $count)
   {
     $value = "<p>$value</p>";

Modified: trunk/lib/task/migrate/QubitMigrate109.class.php
==============================================================================
--- trunk/lib/task/migrate/QubitMigrate109.class.php    Fri Oct 29 12:10:26 
2010        (r8658)
+++ trunk/lib/task/migrate/QubitMigrate109.class.php    Fri Oct 29 12:13:46 
2010        (r8659)
@@ -229,6 +229,41 @@
   }
 
   /**
+   * Slugs are inserted when some resources are inserted, but slugs are dumped
+   * separately when data is dumped.  So loading slug data will try to insert
+   * duplicate slugs.  To work around this, turn slugs into resource properties
+   * and drop slug data
+   */
+  protected function slugData()
+  {
+    if (!isset($this->data['QubitSlug']))
+    {
+      return $this;
+    }
+
+    $slug = array();
+    foreach ($this->data['QubitSlug'] as $item)
+    {
+      $slug[$item['object_id']] = $item['slug'];
+    }
+
+    unset($this->data['QubitSlug']);
+
+    foreach ($this->data as $table => $value)
+    {
+      foreach ($value as $row => $value)
+      {
+        if (isset ($slug[$row]))
+        {
+          $this->data[$table][$row]['slug'] = $slug[$row];
+        }
+      }
+    }
+
+    return $this;
+  }
+
+  /**
    * Call all sort methods
    *
    * @return QubitMigrate109 this object
@@ -247,6 +282,8 @@
 
   public function execute()
   {
+    $this->slugData();
+
     // Find version
     foreach ($this->data['QubitSetting'] as $key => $value)
     {

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to