<?php

function pixelcms_articlesBuildRoute(&$query)
{
    $segments = array();
    if (isset($query['articleId'])) {
        $segments[] = is_array($query['articleId']) ? implode(',', $query['articleId']) : $query['articleId'] ;
        unset($query['articleId']);
    };
    unset($query['print_btn']);
    unset($query['price_style']);
    unset($query['tracktorpool_alias']);
    unset($query['view']);
    unset($query['model']);
    unset($query['page_size']);
    unset($query['disable_title_image']);
    unset($query['show_contact']);
    unset($query['decimals']);
    unset($query['show_gallery_desc']);
    return $segments;
}

function pixelcms_articlesParseRoute($segments)
{
    $vars = [];
    $app = JFactory::getApplication();
    $menu = $app->getMenu();
    $item = $menu->getActive();
    // Count segments
    $count = count($segments);
    // Handle View and Identifier
    $vars['view'] = $item->query['view'];
    $vars['model'] = $item->query['model'];
    $vars['articleId'] = explode(':', $segments[$count - 1])[0];
    return $vars;
}
