diff --git a/components/com_contact/router.php b/components/com_contact/router.php index 5b971ea00b066..d2762055b287a 100644 --- a/components/com_contact/router.php +++ b/components/com_contact/router.php @@ -71,20 +71,18 @@ public function getCategorySegment($id, $query) if ($category) { + $path = array_reverse($category->getPath(), true); + $path[0] = '1:root'; + if ($this->noIDs) { - $path = array_reverse($category->getPath(), true); foreach ($path as &$segment) { list($id, $segment) = explode(':', $segment, 2); } - - return $path; - } - else - { - return array_reverse($category->getPath(), true); } + + return $path; } return array(); @@ -113,25 +111,23 @@ public function getCategoriesSegment($id, $query) */ public function getContactSegment($id, $query) { + if (!strpos($id, ':')) + { + $db = JFactory::getDbo(); + $dbquery = $db->getQuery(true); + $dbquery->select($dbquery->qn('alias')) + ->from($dbquery->qn('#__contact_details')) + ->where('id = ' . $dbquery->q((int) $id)); + $db->setQuery($dbquery); + + $id .= ':' . $db->loadResult(); + } + if ($this->noIDs) { - if (strpos($id, ':')) - { - list($void, $segment) = explode(':', $id, 2); + list($void, $segment) = explode(':', $id, 2); - return array($void => $segment); - } - else - { - $db = JFactory::getDbo(); - $dbquery = $db->getQuery(true); - $dbquery->select($dbquery->qn('alias')) - ->from($dbquery->qn('#__contact_details')) - ->where('id = ' . $dbquery->q((int) $id)); - $db->setQuery($dbquery); - - return array($id => $id . ':' . $db->loadResult()); - } + return array($void => $segment); } return array((int) $id => $id); diff --git a/components/com_content/router.php b/components/com_content/router.php index 26be5f9b13218..cfae32d20805a 100644 --- a/components/com_content/router.php +++ b/components/com_content/router.php @@ -73,20 +73,18 @@ public function getCategorySegment($id, $query) if ($category) { + $path = array_reverse($category->getPath(), true); + $path[0] = '1:root'; + if ($this->noIDs) { - $path = array_reverse($category->getPath(), true); foreach ($path as &$segment) { list($id, $segment) = explode(':', $segment, 2); } - - return $path; - } - else - { - return array_reverse($category->getPath(), true); } + + return $path; } return array(); @@ -115,25 +113,23 @@ public function getCategoriesSegment($id, $query) */ public function getArticleSegment($id, $query) { - if ($this->noIDs) + if (!strpos($id, ':')) { - if (strpos($id, ':')) - { - list($void, $segment) = explode(':', $id, 2); + $db = JFactory::getDbo(); + $dbquery = $db->getQuery(true); + $dbquery->select($dbquery->qn('alias')) + ->from($dbquery->qn('#__content')) + ->where('id = ' . $dbquery->q($id)); + $db->setQuery($dbquery); - return array($void => $segment); - } - else - { - $db = JFactory::getDbo(); - $dbquery = $db->getQuery(true); - $dbquery->select($dbquery->qn('alias')) - ->from($dbquery->qn('#__content')) - ->where('id = ' . $dbquery->q($id)); - $db->setQuery($dbquery); + $id .= ':' . $db->loadResult(); + } - return array($id => $id . ':' . $db->loadResult()); - } + if ($this->noIDs) + { + list($void, $segment) = explode(':', $id, 2); + + return array($void => $segment); } return array((int) $id => $id); diff --git a/components/com_newsfeeds/router.php b/components/com_newsfeeds/router.php index 86a3008e9bb06..2a074f60aa315 100644 --- a/components/com_newsfeeds/router.php +++ b/components/com_newsfeeds/router.php @@ -69,20 +69,18 @@ public function getCategorySegment($id, $query) $category = JCategories::getInstance($this->getName())->get($id); if ($category) { + $path = array_reverse($category->getPath(), true); + $path[0] = '1:root'; + if ($this->noIDs) { - $path = array_reverse($category->getPath(), true); foreach ($path as &$segment) { list($id, $segment) = explode(':', $segment, 2); } - - return $path; - } - else - { - return array_reverse($category->getPath(), true); } + + return $path; } return array(); @@ -111,25 +109,23 @@ public function getCategoriesSegment($id, $query) */ public function getNewsfeedSegment($id, $query) { + if (!strpos($id, ':')) + { + $db = JFactory::getDbo(); + $dbquery = $db->getQuery(true); + $dbquery->select($dbquery->qn('alias')) + ->from($dbquery->qn('#__newsfeeds')) + ->where('id = ' . $dbquery->q((int) $id)); + $db->setQuery($dbquery); + + $id .= ':' . $db->loadResult(); + } + if ($this->noIDs) { - if (strpos($id, ':')) - { - list($void, $segment) = explode(':', $id, 2); + list($void, $segment) = explode(':', $id, 2); - return array($void => $segment); - } - else - { - $db = JFactory::getDbo(); - $dbquery = $db->getQuery(true); - $dbquery->select($dbquery->qn('alias')) - ->from($dbquery->qn('#__newsfeeds')) - ->where('id = ' . $dbquery->q((int) $id)); - $db->setQuery($dbquery); - - return array($id => $id . ':' . $db->loadResult()); - } + return array($void => $segment); } return array((int) $id => $id);