Esempio n. 1
0
<?php

/* @type $Params string[] */

$clusterIdentifier     = ClusterTool::clusterIdentifier();
$page                  = $Params['Page'];
$speciality            = $Params['Speciality'];
$applicationidentifier = $Params['ApplicationIdentifier'];
$result = "";

if ( isset($applicationidentifier) && isset($page) && $page >= 1 && isset($speciality) )
{
    $keywords = Seo::fetchKeywords($applicationidentifier, $speciality, $page);
    $count    = Seo::fetchKeywordsCount($applicationidentifier, $speciality);

    $tpl = eZTemplate::factory();
    $tpl->setVariable('rows', $keywords);
    $tpl->setVariable('count', $count);
    $tpl->setVariable('application_name', $applicationidentifier);
    $tpl->setVariable('speciality', $speciality);
    $tpl->setVariable('page', $page);

    $result = $tpl->fetch('design:esibuild/app_content/seo/keywords_list.tpl');
}

echo $result;

flush();
eZExecution::cleanExit();
    /**
     * @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;
    }