From 46d1747c31d4f0f7c6911efabcc1a60bf5d856f5 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Wed, 17 Aug 2011 21:25:54 +0000 Subject: [PATCH] [gh-130] Merging from testing into staging git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@941 20a16fea-79d4-4915-8869-1ea9d5ebf173 --- sites/all/modules/unl/unl_migration.php | 32 ++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/sites/all/modules/unl/unl_migration.php b/sites/all/modules/unl/unl_migration.php index 76953e6a..f10b2c63 100644 --- a/sites/all/modules/unl/unl_migration.php +++ b/sites/all/modules/unl/unl_migration.php @@ -613,19 +613,29 @@ class Unl_Migration_Tool } } + // If there is no WDN compliant title, search for others if (!$pageTitle) { - $titleText = ''; - $titleNodes = $dom->getElementsByTagName('title'); - if ($titleNodes->length > 0) { - $titleText = $titleNodes->item(0)->textContent; - } - $titleParts = explode('|', $titleText); - if (count($titleParts) > 2) { - $pageTitle = trim(array_pop($titleParts)); - } - else { - $pageTitle = $titleText; + // First, check for a WDN compliant <title> + $titleText = ''; + $titleNodes = $dom->getElementsByTagName('title'); + if ($titleNodes->length > 0) { + $titleText = $titleNodes->item(0)->textContent; + } + $titleParts = explode('|', $titleText); + if (count($titleParts) > 2) { + $pageTitle = trim(array_pop($titleParts)); + } + // Finally, combine what title does exist with the last part of the path + else { + $filename = trim($path, '/'); + $filename = explode('/', $filename); + $filename = array_pop($filename); + // Strip off a file extension if it exists. + if (strrpos($filename, '.') !== FALSE) { + $filename = substr($filename, 0, strrpos($filename, '.')); } + $pageTitle = "$titleText ($filename)"; + } } if (!$pageTitle) { -- GitLab