From fd60b4bc5a1df474a02dae844570943747f53bd1 Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Fri, 2 Sep 2011 20:21:31 +0000
Subject: [PATCH] [gh-183] Merging from testing into staging

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1013 20a16fea-79d4-4915-8869-1ea9d5ebf173
---
 sites/all/modules/unl/unl_migration.php | 37 +++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/sites/all/modules/unl/unl_migration.php b/sites/all/modules/unl/unl_migration.php
index f10b2c63..9cfa2fc9 100644
--- a/sites/all/modules/unl/unl_migration.php
+++ b/sites/all/modules/unl/unl_migration.php
@@ -147,6 +147,7 @@ class Unl_Migration_Tool
     private $_hrefTransform       = array();
     private $_hrefTransformFiles  = array();
     private $_menu                = array();
+    private $_breadcrumbs         = array();
     private $_nodeMap             = array();
     private $_pageTitles          = array();
     private $_log                 = array();
@@ -220,6 +221,7 @@ class Unl_Migration_Tool
             // Parse the menu
             $this->_processMenu();
             $this->_process_blocks();
+            $this->_process_breadcrumbs();
             $this->_state = self::STATE_PROCESSING_PAGES;
         }
         
@@ -277,6 +279,7 @@ class Unl_Migration_Tool
             
             $this->_createMenu();
             $this->_create_blocks();
+            $this->_create_breadcrumbs();
             
             $this->_state = self::STATE_DONE;
         }
@@ -515,6 +518,40 @@ class Unl_Migration_Tool
         ->execute();
     }
     
+    private function _process_breadcrumbs() {
+      $content = $this->_getUrl($this->_baseUrl);
+      $html = $content['content'];
+      
+      $dom = new DOMDocument();
+      $dom->loadHTML($html);
+      $breadcrumbs_node = $dom->getElementById('breadcrumbs');
+      if (!$breadcrumbs_node) {
+        return;
+      }
+      
+      $link_nodes = $breadcrumbs_node->getElementsByTagName('a');
+      $list_nodes = $breadcrumbs_node->getElementsByTagName('li');
+      $unlinked_node = FALSE;
+      if ($list_nodes->length > $link_nodes->length) {
+        $unlinked_node = TRUE;
+      }
+      
+      // Scan each of the breadcrumb links, skipping the first and the last (but only if there's an un-linked "true" last breadcrumb)
+      for ($i = 1; $i < $link_nodes->length - ($unlinked_node ? 1 : 0); $i++) {
+        $link_node = $link_nodes->item($i);
+        $this->_breadcrumbs[] = array(
+          'text' => trim($link_node->textContent),
+          'href' => $this->_makeLinkAbsolute($link_node->getAttribute('href', ''))
+        );
+      }
+    }
+    
+    private function _create_breadcrumbs() {
+      $current_settings = variable_get('theme_unl_wdn_settings', array());
+      $current_settings['intermediate_breadcrumbs'] = $this->_breadcrumbs;
+      variable_set('theme_unl_wdn_settings', $current_settings);
+    }
+    
     private function _processPage($path)
     {
         $this->_addProcessedPage($path);
-- 
GitLab