public function getTrial($trialId)
    {
        $detailsField = "attr_clinical_trials_details_s";
        $clusterIdentifier = ClusterTool::clusterIdentifier();
        $fields = array(
            'details' => $detailsField,
            'headline' => 'attr_headline_s',
            'online_date' => 'attr_date_dt',
            'recruitment_status' => 'subattr_recruitment_status___source_id____s',
            'conditions' => 'attr_clinical_trials_conditions_s',
            'gender' => 'subattr_gender___source_id____s',
            'min_age' => 'attr_clinical_trials_min_age_i',
            'max_age' => 'attr_clinical_trials_max_age_i',
            'country' => "attr_clinical_trials_country____s",
            'online_date_stamp' => 'attr_online_date_dt',
            'guid' => 'meta_guid_ms',
        );

        $fq = array(
            "attr_{$clusterIdentifier}_url_s: \"{$trialId}\"",
        );
        $params = array(
            'indent'        => 'on',
            'q'             => '*:*',
            'fq'            => implode(' AND ', $fq),
            'start'         => $this->offset,
            'rows'          => 1,
            'fl'            => implode(',',$fields),
            'qt'            => 'ezpublish',
            'explainOther'  => '',
            'hl.fl'         => '',
            'sort'          => "attr_online_date_dt desc",
        );

        $result =  SolrTool::rawSearch( $params, 'php', true, false );

        if ($result['response']['numFound'] <= 0)
        {
            return null;
        }

        $result = $result['response']['docs'][0];

        $doc = array();
        foreach ($fields as $mapping => $value)
        {
            $doc[$mapping] = $result[$value];
        }

        $doc['online_date'] = strtotime($doc['online_date']) > 3600*24*2 ? SolrTool::getTimestampFromSolr($doc['online_date']) : 0;
        $doc['details'] = json_decode($doc['details'], true);
        $doc['country'] = implode(', ', $doc['country']);
        foreach (array('update_date', 'register_date', 'enrollement_date') as $dateField)
        {
            $doc['details'][$dateField] = strtotime($doc['details'][$dateField]) > 3600*24*2 ? SolrTool::getTimestampFromSolr($doc['details'][$dateField]) : 0;
        }
        $doc['details']['secondary_outcome'] = implode(', ', $doc['details']['secondary_outcome']);
        $doc['details']['secondary_id'] = implode(', ', $doc['details']['secondary_id']);
        $doc['details']['secondary_sponsor'] = implode(', ', $doc['details']['secondary_sponsor']);

        $doc['id'] = $trialId;
        return $doc;

    }
    /**
     * @param eZTemplate $tpl
     * @param string $operatorName
     * @param array $operatorParameters
     * @param string $rootNamespace
     * @param string $currentNamespace
     * @param mixed $operatorValue
     * @param array $namedParameters
     */
    function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
    {
        switch ($operatorName)
        {
            /*******************************************************************************/
            /*                             Solr Safe Operators                             */
            /*******************************************************************************/

            case 'ezfind_raw_fetch':
                $operatorValue = SolrSafeOperatorHelper::ezfindRawFetch(
                    $namedParameters['params'],
                    $namedParameters['nodeIdsOnly']
                );
                break;
            case 'getUrlSolr':
                $operatorValue = SolrSafeOperatorHelper::getUrlSolr($namedParameters['solrdata']);
                break;
            case 'getDatesPDFavailable':
                $operatorValue = SolrSafeOperatorHelper::getDatesPDFavailable(
                    $namedParameters['onlineDate'],
                    $namedParameters['daysAvailable']
                );
                break;
            case 'getViewCounter':
                $operatorValue = SolrSafeOperatorHelper::getViewCounter(
                    $namedParameters['remoteId'],
                    $namedParameters['clusterIdentifier']
                );
                break;
            case 'getRatings':
                $operatorValue = SolrSafeOperatorHelper::getRatings(
                    $namedParameters['remoteId'],
                    $namedParameters['clusterIdentifier']
                );
                break;
            case 'getJavascriptFiles':
                $operatorValue = SolrSafeOperatorHelper::getJavascriptFiles(
                    $namedParameters['application_name'],
                    $namedParameters['type'],
                    $namedParameters['isConsult']
                );
                break;
            case 'getLessFiles':
                $operatorValue = SolrSafeOperatorHelper::getLessFiles(
                    $namedParameters['application_name'],
                    $namedParameters['application'],
                    $namedParameters['isConsult']
                );
                break;
            case 'getInfosApp':
                $operatorValue = SolrSafeOperatorHelper::getInfosApp($namedParameters['application_identifier']);
                break;
            case 'getHostNameFromURL':
                $operatorValue = SolrSafeOperatorHelper::getHostNameFromURL($namedParameters['url']);
                break;
            case 'context':
                $operatorValue = SolrSafeOperatorHelper::context($namedParameters['url']);
                break;
            case 'getMetas':
                $operatorValue = SolrSafeOperatorHelper::getMetas($namedParameters['applicationName']);
                break;
            case 'getSolrData':
                $operatorValue = SolrSafeOperatorHelper::getSolrData(
                    $namedParameters['remoteId'],
                    $namedParameters['clusterIdentifier'],
                    $namedParameters['extended_fields']
                );
                break;
            case 'getCustomParameter':
                $operatorValue = SolrSafeOperatorHelper::getCustomParameter(
                    $namedParameters['application'],
                    $namedParameters['parameter_name'],
                    $namedParameters['context']
                );
                break;
            case 'getAppIdentifierForIcon':
                $operatorValue = SolrSafeOperatorHelper::getAppIdentifierForIcon($namedParameters['application']);
                break;
            case 'getApplicationUrl':
                $operatorValue = SolrSafeOperatorHelper::getApplicationUrl($namedParameters['identifier']);
                break;
            case 'mappingNameSpe':
                $operatorValue = SolrSafeOperatorHelper::mappingNameSpe($namedParameters['specialtie']);
                break;
            case 'getMappingSpe':
                $operatorValue = SolrSafeOperatorHelper::getMappingSpe();
                break;
            case 'getCustomerTypes':
                $operatorValue = SolrSafeOperatorHelper::getCustomerTypes();
                break;
            case 'getMainSpecialities':
                $operatorValue = SolrSafeOperatorHelper::getMainSpecialities();
                break;
            case 'getUserSpecialities':
                $operatorValue = SolrSafeOperatorHelper::getUserSpecialities();
                break;
            case 'noSeoLink':
                $operatorValue = SolrSafeOperatorHelper::noSeoLink($operatorValue);
                break;
            case 'getTaxoTranslation':
                $operatorValue = SolrSafeOperatorHelper::getTaxoTranslation(
                    $namedParameters['identifier'],
                    $namedParameters['remote_id']
                );
                break;
            case 'cluster_ini':
                $operatorValue = SolrSafeOperatorHelper::clusterIni(
                    $namedParameters['section'],
                    $namedParameters['variable'],
                    $namedParameters['ini_file']
                );
                break;
            case 'truncateContentRelated':
                $operatorValue = SolrSafeOperatorHelper::truncateContentRelated($namedParameters['text']);
                break;
            case 'myCertificatesEnabled':
                $operatorValue = SolrSafeOperatorHelper::featureIsActive("MyCertificates");
                break;
            case 'appHasSpeciality':
                $operatorValue = SolrSafeOperatorHelper::appHasSpeciality();
                break;
            case 'setClusterIdentifier':
                // No $operatorValue modification is normal
                SolrSafeOperatorHelper::setClusterIdentifier($namedParameters['clusterIdentifier']);
                break;
            case 'featureIsActive':
                $operatorValue = SolrSafeOperatorHelper::featureIsActive($namedParameters['featureCode']);
                break;
            case 'feature':
                $operatorValue = SolrSafeOperatorHelper::feature(
                    $namedParameters['featureCode'],
                    $namedParameters['value']
                );
                break;
            case 'alphabet':
                $operatorValue = SolrSafeOperatorHelper::alphabet();
                break;
            case 'generateIso6391':
                $operatorValue = SolrSafeOperatorHelper::generateIso6391($namedParameters['regionalSettingsLocale']);
                break;
            case 'staticfile':
                $operatorValue = SolrSafeOperatorHelper::staticFile(
                    $operatorValue,
                    $namedParameters['quote'],
                    $namedParameters['skip_slash']
                );
                break;
            case 'showHelpDeskPhoneInHeader':
                $operatorValue = !(SolrSafeOperatorHelper::feature('HelpDeskSettings', 'HidePhoneNumberInHeader'));
                break;
            case 'showHelpDeskPhoneOnPage':
                $operatorValue = !(SolrSafeOperatorHelper::feature('HelpDeskSettings', 'HidePhoneNumberOnPage'));
                break;
            case 'getFooterHTML':
                $operatorValue = SolrSafeOperatorHelper::getFooterHTML($namedParameters['footerBlockIdentifier']);
                break;
            case 'getLocaleBySystemCode':
                $operatorValue = SolrSafeOperatorHelper::getLocaleBySystemCode($namedParameters['systemCode']);
                break;
            case 'buildExitUrl':
                $operatorValue = SolrSafeOperatorHelper::buildExitUrl($namedParameters['url']);
                break;
            case 'getUserToken':
                $operatorValue = SolrSafeOperatorHelper::getUserToken();
                break;
            case 'clusterHasFeaturedChannel':
                $operatorValue = SolrSafeOperatorHelper::clusterHasFeaturedChannel();
                break;
            case 'aliasDimensions':
                $operatorValue = SolrSafeOperatorHelper::aliasDimensions($namedParameters['alias']);
                break;
            case 'hasImageArticleFromSolr':
                $operatorValue = SolrSafeOperatorHelper::hasImageArticleFromSolr(
                    $namedParameters['solrdata'],
                    $namedParameters['media_case']
                );
                break;
            case 'getImageArticleUrl':
                $operatorValue = SolrSafeOperatorHelper::getImageArticleUrl(
                    $namedParameters['media_case'],
                    $namedParameters['object_id'],
                    $namedParameters['language'],
                    $namedParameters['alias']
                );
                break;
            case 'getImageArticleUrlFromSolr':
                $operatorValue = SolrSafeOperatorHelper::getImageArticleUrl(
                    $namedParameters['media_case'],
                    $namedParameters['solrdata']['object_id'],
                    $namedParameters['solrdata']['language'],
                    $namedParameters['alias']
                );
                break;
            case 'isHidden':
                $operatorValue = SolrSafeOperatorHelper::isHidden($namedParameters['contentobject_id']);
                break;
            case 'isObjectGloballyVisible':
                $operatorValue = SolrSafeOperatorHelper::isObjectGloballyVisible($namedParameters['contentobject_id']);
                break;
            case 'getClusterVisibilities':
                $operatorValue = SolrSafeOperatorHelper::getClusterVisibilities($namedParameters['contentobject_id']);
                break;
            case 'parseTranslationTagParams':
                $operatorValue = SolrSafeOperatorHelper::parseTranslationTagParams($namedParameters['params']);
                break;
            case 'isSendToColleagueDisabled':
                $operatorValue = SolrSafeOperatorHelper::featureIsActive('DisableSendToColleague')
                    ? SolrSafeOperatorHelper::feature('DisableSendToColleague', 'IsDisabled')
                    : false;
                break;
            case 'getListOfValueOptions':
                $operatorValue = SolrSafeOperatorHelper::getListOfValueOptions( $namedParameters['business_name'], $namedParameters['filter'] );
                break;
            case 'getListOfValues':
                $operatorValue = SolrSafeOperatorHelper::getListOfValues( $namedParameters['business_name'], $namedParameters['filter'] );
                break;
            case 'solrDateToStamp':
                $operatorValue = strtotime($namedParameters['date']) > 3600*24*2 ? SolrTool::getTimestampFromSolr($namedParameters['date']) : 0;
                break;
            case 'getSeoParam':
                $operatorValue = SolrSafeOperatorHelper::getSeoParam($namedParameters['applicationLocalized'], $namedParameters['name'], $namedParameters['params']);
                break;
            case 'applicationHasSeoSpeciality':
                $operatorValue = SolrSafeOperatorHelper::applicationHasSeoSpeciality($namedParameters['applicationIdentifier']);
                break;
            case 'seoIsEnabled':
                $operatorValue = SolrSafeOperatorHelper::seoIsEnabled($namedParameters['applicationIdentifier']);
                break;
            case 'includeEsi':
                $operatorValue = SolrSafeOperatorHelper::includeEsi( $namedParameters['src'], $namedParameters['debug'] );
                break;
            case 'imageDecHash':
                $operatorValue = SolrSafeOperatorHelper::imageDecHash( $operatorValue );
                break;
            case 'bannerDecHash':
                $operatorValue = SolrSafeOperatorHelper::bannerDecHash( $operatorValue );
                break;
            case 'getAndStoreGPNotebookHS':
                $operatorValue = self::getAndStoreGPNotebookHS( );
                break;
            case 'isPromoTaxonomyVisible':
                $operatorValue = SolrSafeOperatorHelper::isPromoTaxonomyVisible( $namedParameters['values'] );
                break;
            case 'translateTaxonomy':
                $operatorValue = SolrSafeOperatorHelper::translateTaxonomy( $namedParameters['code'] );
                break;
            case 'getPublisherArticleUrl':
                $operatorValue = SolrSafeOperatorHelper::getPublisherArticleUrl( $namedParameters['publisher'], $namedParameters['articleId'] );
                break;
        }
    }
    /**
     * @param string $taxonomyCategory
     * @param float $taxonomyValue
     * @param int $limit
     * @param boolean $includeAllValues
     * @return array
     */
    public function getRelatedContent($taxonomyCategory, $taxonomyValue, $limit, $includeAllValues, $nodeId)
    {
        $fields = $this->mappingFieldsSolr;

        $filters = array();
        if ($includeAllValues)
        {
            foreach ($taxonomyValue as $tv)
            {
                $filters[] =  "subattr_{$taxonomyCategory}___source_id____s: \"{$tv}\"";
            }
        }
        else
        {
            $filter = "subattr_{$taxonomyCategory}___source_id____s: (%s)";
            $taxonomyValue = array_map( function($v) {
                return "\"{$v}\"";
            }, $taxonomyValue);
            $filter = sprintf($filter, implode(' OR ', $taxonomyValue));

            $filters[] = $filter;
        }

        $filters[] = '-meta_node_id_si: ' . $nodeId;
        $locale = LocaleTool::languageFromLocale();
        $filters[] = "meta_language_code_ms:".$locale.'*';

        $params = array(
            'indent'        => 'on',
            'q'             => '*:*',
            'fq'            => implode(' AND ' , $filters),
            'start'         => $this->offset,
            'rows'          => $limit,
            'fl'            => implode(',',$fields),
            'qt'            => 'ezpublish',
            'explainOther'  => '',
            'hl.fl'         => '',
            'sort'          => "attr_online_date_dt desc",
        );

        $solrResult =  SolrTool::rawSearch( $params, 'php', true, false );

        foreach ( $solrResult['response']['docs'] as $doc )
        {
            $nodeId                     = $doc['meta_node_id_si'][0];
            $articleNodeIDs[]           = $nodeId;
            $solrApplicationIndexes     = isset ( $doc[$fields['apps']] ) ? $doc[$fields['apps']] : array();
            $solrApplicationNames       = array();
            $solrApplicationIdentifiers = array();
            $app                        = null;

            foreach( $solrApplicationIndexes as $applicationIndex )
            {
                list ( $cluster, /* unused */, $applicationId ) = explode( '##', $applicationIndex );

                if ( $cluster == ClusterTool::clusterIdentifier() )
                {
                    $app = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId );

                    if ( !($app instanceof ApplicationLocalized) )
                        continue;

                    $solrApplicationNames[] = $app->attribute('name');
                    $solrApplicationIdentifiers[] = $app->applicationObject()->attribute('identifier');
                }
            }

            $url = isset( $doc[$fields['url']] ) ? $doc[$fields['url']] : null;

            if ( empty( $solrApplicationIdentifiers ) )
            {
                eZDebug::writeError( "Could not get application id for cluster for node $nodeId - Falling back to current application" );
                $solrApplicationIdentifiers = array( $this->contentList->applicationObject()->attribute('identifier') );
            }

            $masterApps = $this->contentList->iniMerck()->hasSection('MasterAppSettings') && $this->contentList->iniMerck()->hasVariable( 'MasterAppSettings', 'MasterAppList' )
                ? $this->contentList->iniMerck()->variable( 'MasterAppSettings', 'MasterAppList' )
                : array();

            $applicationIdentifier = $solrApplicationIdentifiers[0];

            if (!empty($masterApps))
            {
                foreach ($solrApplicationIdentifiers as $solrApplicationIdentifierKey => $solrApplicationIdentifier)
                {
                    if (in_array($solrApplicationIdentifier, $masterApps))
                    {
                        $applicationIdentifier = $solrApplicationIdentifier;
                        unset( $solrApplicationIdentifiers[$solrApplicationIdentifierKey] );
                        $solrApplicationIdentifiers = array_merge( array( $applicationIdentifier ), $solrApplicationIdentifiers );

                        break;
                    }
                }
            }

            $application       = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier );
            $applicationObject = $application->applicationObject();
            $applicationType   = $applicationObject->applicationType()->attribute('type_identifier');
            $publisherPath     = $doc[$fields['publisher_path']][0];
            $publisherInfo     = PublisherFolderTool::getPathToIDMapping($publisherPath);
            $publisherFolderId = $publisherInfo['pfid'];
            $onlineDateStamp   = strtotime($doc[$fields['online_date']]) > 3600*24*2 ? SolrTool::getTimestampFromSolr($doc[$fields['online_date']]) : 0;
            $mediaTypes        = isset( $doc[$fields['media_types']] )
                ? json_decode( base64_decode($doc[$fields['media_types']]), true )
                : array();
            $mediaCount        = 0;
            $hasImage          = isset( $doc[$fields['has_image']] )
                ? json_decode( base64_decode($doc[$fields['has_image']]), true )
                : array();
            $url               = ($applicationType == 'first-child')
                ? $application->attribute('url_alias')
                : $application->attribute('url_alias') . '/' . $publisherFolderId . '/' . $url;

            $result[$nodeId] = array(
                'object_id'            => isset( $doc[$fields['object_id']] )            ? $doc[$fields['object_id']]            : null,
                'language'             => isset( $doc[$fields['language']] )             ? $doc[$fields['language']]             : null,
                'headline'             => isset( $doc[$fields['headline']] )             ? $doc[$fields['headline']]             : null,
                'promo_description'    => isset( $doc[$fields['promo_description']] )    ? $doc[$fields['promo_description']]    : null,
                'online_date'          => strtotime($doc[$fields['online_date']]) > 3600*24*2 ? SolrTool::getDateFromSolr($doc[$fields['online_date']]) : 0,
                'has_image'            => $hasImage,
                'url'                  => $url,
                'node_id'              => $nodeId,
                'internal_id'          => isset( $doc[$fields['internal_id']] )          ? $doc[$fields['internal_id']]            : null,
                'application'          => $application,
            );
        }
        return $result;
    }