/**
  * @since       1.1.0
  */
 public function onFieldsandfiltersRequestJSON($context, JObject $data)
 {
     if ($context != 'com_fieldsandfilters.filters.content') {
         return;
     }
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $document = JFactory::getDocument();
     $basePath = sprintf('%s/%s/%s/overrides', JPATH_PLUGINS, $this->_type, $this->_name);
     $contentPath = JPATH_SITE . '/components/com_content';
     $id = $jinput->get('id', 0, 'int');
     $context = $jinput->get('context');
     if (!in_array($context, $this->_contexts)) {
         return false;
     }
     // Load PluginExtensions Helper
     $extension = FieldsandfiltersFactory::getExtensions()->getExtensionsByName($this->_name)->get($this->_name);
     if ($context == $this->_contexts['category'] && !$id || !$extension) {
         return false;
     }
     list($option, $class) = explode('.', $context);
     // set new jinput values
     $jinput->set('option', $option);
     $jinput->set('view', $class);
     $jinput->set('id', $jinput->get('id', 0, 'int'));
     // Include dependancies
     JLoader::import('com_content.helpers.route', JPATH_SITE . '/components');
     JLoader::import('com_content.helpers.query', JPATH_SITE . '/components');
     // Get controller Instance
     if (!($controller = KextensionsController::getInstance(null, 'contentController', array('base_path' => $contentPath, 'view_path' => $basePath . '/views')))) {
         return false;
     }
     // add model path
     $prefix = get_class($this);
     $controller->addModelPath($basePath . '/models', $prefix . 'Model');
     if (!($model = $controller->getModel($class, $prefix . 'Model', array('ignore_request' => false, 'table_path' => JPATH_ADMINISTRATOR . '/components/' . $option . '/tables')))) {
         return false;
     }
     $fieldsandfilters = $jinput->get('fieldsandfilters', array(), 'array');
     if (!empty($fieldsandfilters)) {
         $extensionsParams = new JObject(array('plugin.value' => $this->params->get('comparison_between_filters')));
         if ($moduleID = $jinput->get('module', 0, 'int')) {
             $extensionsParams->set('module.id', $moduleID);
         }
         $betweenFilters = FieldsandfiltersExtensionsHelper::getParams('comparison_between_filters', $extensionsParams, 'OR');
         $extensionsParams->set('plugin.value', $this->params->get('comparison_between_values_filters'));
         $betweenValues = FieldsandfiltersExtensionsHelper::getParams('comparison_between_values_filters', $extensionsParams, 'OR');
         $itemsID = FieldsandfiltersFiltersHelper::getItemsIDByFilters($extension->content_type_id, $fieldsandfilters, $model->getState('filter.published'), $betweenFilters, $betweenValues);
     } else {
         $itemsID = FieldsandfiltersFiltersHelper::getSimpleItemsID(false);
     }
     // load view
     if (!($view = $controller->getView($class, 'html', $prefix . 'View', array('base_path' => $contentPath, 'layout' => $jinput->get('layout', 'default'))))) {
         return false;
     }
     // For joomla 2.5 && Key Reference
     if (!FieldsandfiltersFactory::isVersion()) {
         $view->addTemplatePath(JPATH_THEMES . '/' . $app->getTemplate() . '/html/com_content/' . $class);
     }
     // set module to view
     $view->setModel($model, true);
     $view->document = $document;
     // add helpers
     JHtml::addIncludePath(JPATH_SITE . '/components/com_content/helpers');
     JHtml::addIncludePath(JPATH_SITE . '/components/com_content/helpers/html');
     KextensionsLanguage::load($option);
     $emptyItemsID = $itemsID->get('empty', false);
     $model->setState('fieldsandfilters.itemsID', (array) $itemsID->get('itemsID'));
     $model->setState('fieldsandfilters.emptyItemsID', $emptyItemsID);
     if ($jinput->get('random', false) && KextensionsModule::getParams($jinput->get('module'))->get('show_random', 0) && JComponentHelper::getParams('com_fieldsandfilters')->get('random_type_filters') == 'selected') {
         $model->setState('fieldsandfilters.random.selected', true);
         $model->setState('fieldsandfilters.random.limit', JComponentHelper::getParams('com_fieldsandfilters')->get('random_items_limit_filters', 0));
     }
     if (!$emptyItemsID) {
         ob_start();
         $view->display();
         $body = ob_get_contents();
         ob_end_clean();
     } else {
         $this->loadLanguage();
         $variables = new JObject();
         $variables->type = $this->_type;
         $variables->name = $this->_name;
         $variables->params = $this->params;
         $variables->extension = $extension;
         $body = KextensionsPlugin::renderLayout($variables, FieldsandfiltersPlugin::getLayout($this->params, 'empty_layout', 'empty'));
     }
     $itemsID = $model->getState('fieldsandfilters.itemsID', array());
     $fieldsID = $jinput->get('fields', array(), 'array');
     if (!empty($itemsID) && !empty($fieldsID) && !$emptyItemsID) {
         // Load Filters Helper
         $counts = (array) FieldsandfiltersFiltersHelper::getFiltersValuesCount($extension->content_type_id, $fieldsID, $itemsID, $model->getState('filter.published'));
         $data->set('counts', $counts);
     } else {
         if ($emptyItemsID) {
             // [TODO] when is empty display all fields with 0 counts or display special buttons to reset filters
             $data->set('empty', $emptyItemsID);
         }
     }
     $document->setBuffer($body, array('type' => 'component', 'name' => 'fieldsandfilters', 'title' => null));
     if (!$emptyItemsID) {
         // [TODO] move to another place because we need this only once
         $script[] = 'jQuery(document).ready(function($) {';
         $script[] = '	$("' . $this->params->get('selector_pagination_filters', '.pagination') . '").fieldsandfilters("pagination"' . ($app->get('sef', 0) ? ',{pagination: "start"}' : '') . ');';
         $script[] = '});';
         $document->addScriptDeclaration(implode("\n", $script));
     }
 }
 if (isset($filtersRequest['extensionID']) && $filtersRequest['extensionID'] && !empty($counts)) {
     $componentParams = JComponentHelper::getParams('com_fieldsandfilters');
     $request = array('option' => 'com_fieldsandfilters', 'task' => 'request.filters', 'tmpl' => 'component', 'format' => 'json', 'Itemid' => $app->input->get('Itemid', 0, 'int'), 'context' => $context);
     $request = array_merge($request, $filtersRequest);
     $options = array('url' => JRoute::_(JURI::root(true) . '/index.php'), 'token' => JSession::getFormToken(), 'fields' => $fieldsID, 'module' => $module->id, 'counts' => $counts, 'request' => $request, 'pagination' => $pagination);
     // get selectors
     $selectors = $filters->get('selectors');
     if (!empty($selectors) && is_array($selectors)) {
         if (empty($selectors['body'])) {
             unset($selectors['body']);
         }
         $options['selectors'] = $selectors;
     }
     // get functions
     $extensionsParams->set('module.value', $params->get('function_done_filters'));
     if ($functionDone = trim(FieldsandfiltersExtensionsHelper::getParams('function_done_filters', $extensionsParams))) {
         $fn['done'] = '\\' . $functionDone;
     }
     // hash navigation
     if ($componentParams->get('hash_navigation_enabled')) {
         $options['hashNavigation'] = array('enabled' => true, 'prefix' => $componentParams->get('hash_navigation_prefix', '#!'));
     }
     if (!empty($fn) && is_array($fn)) {
         $options['fn'] = $fn;
     }
     // Import JS && CSS
     JHtml::_('FieldsandfiltersHtml.filters.framework');
     if (FieldsandfiltersFactory::isVersion()) {
         $options = JHtml::getJSObject($options);
     } else {
         $options = JHtml::_('FieldsandfiltersHtml.joomla.getJSObject', $options);