Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
daveewbl committed Nov 24, 2022
1 parent d5bdc1d commit edfc078
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions plugin/src/AlgoliaSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
use Joomla\String\StringHelper;
use stdClass;
use Type;
use PlgSystemLanguageFilter;

class AlgoliaSync
{

private static bool $routerRulesLoaded = false;
private App $zoo;
private ItemRenderer $renderer;
private ?SearchClient $client = null;
Expand Down Expand Up @@ -523,8 +523,7 @@ private function getItemUrls(\Item $item, $lang)
$menu_item_frontpage = $this->findMenuItem('frontpage', $item->application_id, $lang);

// build item link
$langCode = $lang === 'en-GB' ? 'en' : 'it';
$link = $this->getLinkBase() . '&task=item&item_id=' . $item->id . '&lang=' . $langCode;
$link = $this->getLinkBase() . '&task=item&item_id=' . $item->id . '&lang=' . $lang;
$categories = $item->getRelatedCategories(true);
$primary_category = $item->getPrimaryCategory();

Expand Down Expand Up @@ -635,8 +634,7 @@ private function getCategoryUrl(\Category $category, $lang)
$menu_item_frontpage = $this->findMenuItem('frontpage', $category->application_id, $lang);

// build category link
$langCode = $lang === 'en-GB' ? 'en' : 'it';
$link = $this->getLinkBase() . '&task=category&category_id=' . $category->id . '&lang=' . $langCode;
$link = $this->getLinkBase() . '&task=category&category_id=' . $category->id . '&lang=' . $lang;

$itemid = null;
if ($menu_item = $this->findInCategoryPath($category, $lang)) {
Expand Down Expand Up @@ -724,8 +722,11 @@ private function array_flatten(array $array): array

private function loadRouterLanguageRules(): void
{
if (self::$routerRulesLoaded) {
return;
}

$this->app = CMSApplication::getInstance('site');
$this->mode_sef = $this->app->get('sef', 0);
$this->lang_codes = LanguageHelper::getLanguages('lang_code');
$this->default_lang = ComponentHelper::getParams('com_languages')->get('site', 'en-GB');
$this->current_lang = isset($this->lang_codes[$this->default_lang]) ? $this->default_lang : 'en-GB';
Expand Down Expand Up @@ -755,6 +756,8 @@ private function loadRouterLanguageRules(): void
$this,
'parseRule'
), Router::PROCESS_BEFORE);

self::$routerRulesLoaded = true;
}

/**
Expand Down

0 comments on commit edfc078

Please sign in to comment.