/**
     * @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
        );
    }