/** * Returns a string with an article id, in accordance * with various settings * @param $id * @param $view * @param $option * @param $shLangName */ function shGetArticleIdString( $id, $view, $option, $shLangName) { $sefConfig = & Sh404sefFactory::getConfig(); // V 1.5.7 : article id, on some categories only $articleId= ''; if ($sefConfig->ContentTitleInsertArticleId && isset($sefConfig->shInsertContentArticleIdCatList) && !empty($id) && ($view == 'article')) { $slugsModel = Sh404sefModelSlugs::getInstance(); $article = $slugsModel->getArticle( $id); if(empty($article[$shLangName])) { $shLangName = '*'; } // check if article categogy is in the settings categories list, // or that the categories list is empty, which means user selected the "All categories" option if (!empty($article[$shLangName])) { $foundCat = (!empty($sefConfig->shInsertContentArticleIdCatList) && empty($sefConfig->shInsertContentArticleIdCatList[0])) || in_array( $article[$shLangName]->catid, $sefConfig->shInsertContentArticleIdCatList); if ($foundCat !== null && $foundCat !== false) { $articleId = $article[$shLangName]->id; } } } return $articleId; }
public static function getContentSlugsArray($view, $id, $layout, $Itemid = 0, $shLang = null, $sefConfig = null) { $slugsArray = array(); // if config is not injected, get default one if (is_null($sefConfig)) { $sefConfig =& Sh404sefFactory::getConfig(); } $id = empty($id) ? 0 : intval($id); // TODO: this will not work when we have Joomfish (probably). With JF, default should be // $shLang = empty($shLang) ? $shPageInfo->currentLanguageTag : $shLang; ?? $requestedLanguage = empty($shLang) ? '*' : $shLang; try { $slugsModel = Sh404sefModelSlugs::getInstance(); $menuItemTitle = getMenuTitle(null, $view, isset($Itemid) ? $Itemid : null, '', $shLang); $uncategorizedPath = $sefConfig->slugForUncategorizedContent == shSEFConfig::COM_SH404SEF_UNCATEGORIZED_EMPTY ? '' : $menuItemTitle; switch ($view) { case 'category': if (empty($layout) || $layout != 'blog') { if ($sefConfig->shInsertContentTableName) { $prefix = empty($sefConfig->shContentTableName) ? $menuItemTitle : $sefConfig->shContentTableName; if (!empty($prefix)) { $prefixArray[] = $prefix; } } if (!empty($id)) { // we have a category id $slugsArray = $slugsModel->getCategorySlugArray('com_content', $id, $sefConfig->includeContentCatCategories, $sefConfig->useCatAlias, $insertId = false, $menuItemTitle, $requestedLanguage); } else { // no category id, use menu item title if (!$sefConfig->shInsertContentTableName || empty($sefConfig->shContentTableName)) { if (!empty($menuItemTitle)) { $slugsArray[] = $menuItemTitle; } } } } else { // blog category if ($sefConfig->shInsertContentBlogName) { $prefix = empty($sefConfig->shContentBlogName) ? $menuItemTitle : $sefConfig->shContentBlogName; if (!empty($prefix)) { $prefixArray[] = $prefix; } } if (!empty($id)) { $slugsArray = $slugsModel->getCategorySlugArray('com_content', $id, $sefConfig->includeContentCatCategories, $sefConfig->useCatAlias, $insertId = false, $menuItemTitle, $requestedLanguage); } else { // this should not happen, probably a malformed url if (!$sefConfig->shInsertContentBlogName || empty($sefConfig->shContentBlogName)) { if (!empty($menuItemTitle)) { $slugsArray[] = $menuItemTitle; } } } } if (!empty($prefixArray)) { $slugsArray = array_merge($prefixArray, $slugsArray); } $slugsArray[] = '/'; break; case 'categories': // now get category(ies) path if (!empty($id)) { $slugsArray = $slugsModel->getCategorySlugArray('com_content', $id, $sefConfig->includeContentCatCategories, $sefConfig->useCatAlias, $insertId = false, $menuItemTitle, $requestedLanguage); // insert a suffix to distinguish from normal category listing if (!empty($sefConfig->contentCategoriesSuffix)) { $slugsArray[] = $sefConfig->contentCategoriesSuffix; } // end with a directory sign $slugsArray[] = '/'; } else { if (!empty($menuItemTitle)) { $slugsArray[] = $menuItemTitle; } } break; case 'featured': if (!empty($menuItemTitle)) { $slugsArray[] = $menuItemTitle; } break; case 'article': $article = $slugsModel->getArticle($id); $language = $requestedLanguage; if (empty($article[$requestedLanguage])) { $language = '*'; } // still no luck, use whatever is available if (empty($article[$language])) { $languages = array_keys($article); $language = array_shift($languages); } // get category(ies) $slugsArray = $slugsModel->getCategorySlugArray('com_content', $article[$language]->catid, $sefConfig->includeContentCat, $sefConfig->useCatAlias, $insertId = false, $uncategorizedPath, $requestedLanguage); // get article slug, optionnally including article id inurl $insertIdCatList = $sefConfig->ContentTitleInsertArticleId ? $sefConfig->shInsertContentArticleIdCatList : array(); $articleSlug = $slugsModel->getArticleSlug($id, $sefConfig->UseAlias, $sefConfig->ContentTitleInsertArticleId, $insertIdCatList, $requestedLanguage); $slugsArray[] = $articleSlug; break; default: break; } } catch (Exception $e) { ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); } return $slugsArray; }
if ($dosef == false) { return; } // ------------------ standard plugin initialize function - don't change --------------------------- // ------------------ load language file - adjust as needed ---------------------------------------- $shLangIso = shLoadPluginLanguage('com_newsfeeds', $shLangIso, 'COM_SH404SEF_CREATE_NEW_NEWSFEED'); // ------------------ load language file - adjust as needed ---------------------------------------- $shNewsfeedName = shGetComponentPrefix($option); $shNewsfeedName = empty($shNewsfeedName) ? getMenuTitle($option, isset($view) ? $view : null, isset($Itemid) ? $Itemid : null, null, $shLangName) : $shNewsfeedName; $shNewsfeedName = empty($shNewsfeedName) || $shNewsfeedName == '/' ? 'Newsfeed' : $shNewsfeedName; if (!empty($shNewsfeedName)) { $title[] = $shNewsfeedName; } // V 1.2.4.t $view = isset($view) ? $view : null; $slugsModel = Sh404sefModelSlugs::getInstance(); switch ($view) { case 'newsfeed': if (!empty($catid)) { // V 1.2.4.q try { $title = $slugsModel->getCategorySlugArray('com_newsfeeds', $catid, shSEFConfig::CAT_ALL_NESTED_CAT, $useAlias = false, $insertId = false, $menuItemTitle = '', $shLangName); } catch (Exception $e) { ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage()); $dosef = false; } } if (!empty($id)) { try { $rows = ShlDbHelper::selectObjectList('#__newsfeeds', array('name', 'id'), array('id' => $id)); } catch (Exception $e) {