/**
     * @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;
        }
    }
    /**
     * @return bool
     */
    public function htmlBuildSeoResult()
    {
        $this->pushResult("application_headline", $this->applicationLocalized()->headline);
        $this->pushResult("application_identifier", $this->applicationObject()->attribute("identifier"));

        // Speciality list
        if(!isset($this->seoParams["speciality"]) && !isset($this->seoParams["keyword"]))
        {
            $this->pushResult("list_specialities", true);

            $seos = Seo::fetchSpecialities($this->applicationObject()->identifier);

            $rows = array();
            foreach ( $seos as $seo )
            {
                $seo['nb_results'] = $seo['count'];
                $letter            = strtoupper( substr( $seo['speciality'], 0, 1 ) );
                
                if ( !isset( $rows[$letter] ) )
                    $rows[$letter]=array();

                $rows[$letter][]=$seo;
            }
            $this->pushResult("rows", $rows);

            // Speciality list headline
            $this->pushResult("seoTitle", ezpI18n::tr("seo/speciality-list", "HEADLINE", null, array(
                "%application" => $this->applicationLocalized()->headline
            )));
        }
        // Keyword list
        else if(isset($this->seoParams["speciality"]) && !isset($this->seoParams["keyword"]))
        {
            $keywords = Seo::fetchKeywords($this->applicationObject()->identifier, $this->seoParams["speciality"], 1, 100);
            $count    = Seo::fetchKeywordsCount($this->applicationObject()->identifier, $this->seoParams["speciality"]);

            $this->pushResult("list_keywords", true);
            $this->pushResult("speciality", $this->seoParams["speciality"]);
            // keyword list
            $this->pushResult("rows", $keywords);
            // random keyword for description
            $shuffle = $keywords;
            shuffle($shuffle);
            $randKeys = array_rand($shuffle, 3);
            $randKeywords = array();
            foreach($randKeys as $rand)
            {
                $randKeywords[] = $shuffle[$rand]["keyword"];
            }
            $this->pushResult("randKeywords", $randKeywords);

            $this->pushResult("count", $count);
            $this->pushResult("page", 1);

            // Keyword list (no speciality)
            if(!SolrSafeOperatorHelper::applicationHasSeoSpeciality($this->applicationObject()->identifier))
            {
                $this->pushResult("seoTitle", ezpI18n::tr("seo/keyword-list-no-spe", "HEADLINE", null, array(
                    "%application"  => $this->applicationLocalized()->headline,
                    "%speciality"   => $this->seoParams["speciality"]
                )));
            }
            // Keyword list (by speciality)
            else
            {
                $this->pushResult("seoTitle", ezpI18n::tr("seo/keyword-list-spe", "HEADLINE", null, array(
                    "%application"  => $this->applicationLocalized()->headline,
                    "%speciality"   => $this->seoParams["speciality"]
                )));
            }
        }
        // Article list (by keyword)
        else
        {
            $this->pushResult("keyword", $this->seoParams["keyword"]);
            $this->pushResult("keywordEncode", urlencode($this->seoParams["keyword"]));
            $this->pushResult("seoTitle", ezpI18n::tr("seo/article-list", "HEADLINE", null, array(
                "%application"  => $this->applicationLocalized()->headline,
                "%keyword"  => $this->seoParams["keyword"]
            )));
        }

        return true;
    }
    /**
     * @return array
     */
    public function getSeoMetas()
    {
        $keywords    = '';
        $title       = '';
        $description = '';

        // Speciality list
        if(!isset($this->seoParams["speciality"]) && !isset($this->seoParams["keyword"]))
        {
            $specialities = Seo::fetchSpecialities($this->applicationObject()->identifier, 1, 10);
            $specialities = array_map(function($speciality) {
                return $speciality['speciality'];
            }, $specialities);
            $keywords = Seo::fetchKeywords($this->applicationObject()->identifier, $specialities, 1, 10);
            $title = ezpI18n::tr("seo/speciality-list", "META TITLE", null, array(
                "%application" => $this->applicationLocalized()->headline
            ));

            // get seo_index_description in mm_application_seo
            $description = SolrSafeOperatorHelper::getSeoParam(
                $this->applicationLocalized(),
                "meta_speciality_list_description",
                array(
                    '%application' => $this->applicationLocalized()->headline
                )
            );
        }
        // Keyword list
        else if(isset($this->seoParams["speciality"]) && !isset($this->seoParams["keyword"]))
        {
            $params = array(
                '%application' => $this->applicationLocalized()->headline,
                '%speciality' => $this->seoParams["speciality"]
            );

            // Keyword list (no speciality)
            if(!SolrSafeOperatorHelper::applicationHasSeoSpeciality($this->applicationObject()->identifier))
            {
                $title = ezpI18n::tr("seo/keyword-list-no-spe", "META TITLE", null, array(
                    "%application" => $this->applicationLocalized()->headline
                ));

                $description = SolrSafeOperatorHelper::getSeoParam(
                    $this->applicationLocalized(),
                    "meta_keyword_list_no_speciality_description",
                    $params
                );

                $keywords = Seo::fetchKeywords($this->applicationObject()->identifier, null, 1, 10);
            }
            // Keyword list (by speciality)
            else
            {
                $title = ezpI18n::tr("seo/keyword-list-spe", "META TITLE", null, array(
                    "%application" => $this->applicationLocalized()->headline,
                    "%speciality"  => $this->seoParams['speciality'],
                ));

                $description = SolrSafeOperatorHelper::getSeoParam(
                    $this->applicationLocalized(),
                    "meta_keyword_list_speciality_description",
                    $params
                );

                $keywords = Seo::fetchKeywords($this->applicationObject()->identifier, $this->seoParams["speciality"], 1, 10);
            }
        }
        // Article list (by keyword)
        else if(isset($this->seoParams["keyword"]))
        {
            $params = array(
                '%application' => $this->applicationLocalized()->headline,
                '%speciality'  => $this->seoParams["speciality"],
                "%keyword"     => $this->seoParams["keyword"]
            );

            $title = ezpI18n::tr("seo/article-list", "META TITLE", null, array(
                "%application" => $this->applicationLocalized()->headline,
                "%keyword"    => $params["%keyword"],
            ));

            $description = SolrSafeOperatorHelper::getSeoParam(
                $this->applicationLocalized(),
                "meta_article_list_description",
                $params
            );

            $keywords = $this->seoParams['keyword'];
        }

        if (is_array($keywords)) {
            $keywords = implode(',', array_map(function($keyword) {
                return $keyword['keyword'];
            }, $keywords));
        }
        return array(
            "title"       => $title,
            "description" => $description,
            "keywords"    => $keywords
        );
    }