/**
     * @param ApplicationDefault $app
     * @param string $path
     * @return ApplicationDefault
     */
    public static function initSeo(ApplicationDefault $app, $path)
    {
        preg_match('#^/all(?:/(?<spe>[^/]+))?(?:/(?<keyword>[^/]+))?#', $path, $m);
        $app->seoParams["noSpeciality"] = false;

        if(!Seo::hasSpeciality($app->applicationObject()->identifier))
        {
            $app->seoParams["noSpeciality"] = true;
        }
        if( isset($m[0]) )
        {
            if(isset($m["spe"]))
            {
                if($app->seoParams["noSpeciality"])
                {
                    $row = Seo::fetchSpecialityByUrl($app->applicationObject()->identifier, "");
                    if(!$row || !isset($row["speciality"]))
                        return $app;
                    $app->seoParams["speciality"] = "";
                }
                else
                {
                    $row = Seo::fetchSpecialityByUrl($app->applicationObject()->identifier, $m["spe"]);
                    if(!$row || !isset($row["speciality"]))
                        return $app;

                    $app->seoParams["speciality"] = $row["speciality"];
                }

                if(isset($m["keyword"]))
                {
                    $row = Seo::fetchKeywordByUrl($app->applicationObject()->identifier, $m["keyword"]);
                    if(!$row || !isset($row["keyword"]))
                        return $app;

                    $app->seoParams["keyword"] = $row["keyword"];
                }
            }

            $app->setStatus('seo');
        }
        return $app;
    }
 /**
  * @param ApplicationDefault $app
  * @return bool
  */
 public static function hasHomepage($app)
 {
     $result = $app->applicationLocalized()->getCustomParameter('HasHomepage');
     if ( $result === false )
         $result = $app->applicationObject()->getCustomParameter('HasHomepage');
     
     return ($result == '1');
 }
    public function htmlBuildResult()
    {
        $lessFiles = SolrSafeOperatorHelper::getLessFiles(
            ($this->app) ? $this->app->applicationObject()->attribute('identifier') : $this->applicationName(),
            $this->app
        );
        $this->tpl()->setVariable( 'applicationLessFiles', $lessFiles );

        if ( !$this->app )
            return;

        if ( $this->app->isFull )
        {
            if ( $this->app->node && $this->app->node instanceof eZContentObjectTreeNode )
            {
                $dataMap     = $this->app->node->dataMap();
                if($dataMap["serialized_taxonomies"]){
                    $taxonomies = $dataMap["serialized_taxonomies"]->content();
                    $publisherPath = $taxonomies["publisher_folder"][0];
                    $publisherFolder = $this->app->applicationLocalized()->getPublisherFolderFromPath($publisherPath);

                    if (isset($taxonomies['language']) && $publisherFolder instanceof PublisherFolder) {
                        $publisherLanguages = $publisherFolder->getLanguages();
                        $languageList = $taxonomies['language'];
                        //$languageTranslations = FacetFilteringTool::getTaxonomyTranslation('language');

                        $availableLanguages = array();

                        foreach (array_keys($this->app->node->object()->allLanguages()) as $locale) {
                            if (is_array($publisherLanguages) && in_array($locale, $publisherLanguages)) {
                                $key = LocaleTool::languageISO639Code($locale);
                                $availableLanguages[$key] = $locale;
                            }
                        }
                    }

                    $uri = eZURI::instance();
                    $uriParams = $uri->UserParameters();
                    if(isset($uriParams['language']))
                        $uriLang = $uriParams['language'];

                    if ($uriLang) {
                        $this->app->node->setCurrentLanguage($uriLang);
                    }
                    if (in_array($publisherLanguages[0], $availableLanguages)){
                        if ($this->app->node->currentLanguage() != $publisherLanguages[0]) {
                            $this->app->node->setCurrentLanguage($publisherLanguages[0]);
                        }
                    }
                }
            }
            
            if ( SolrSafeOperatorHelper::featureIsActive( "SocialSharing" ) && SolrSafeOperatorHelper::feature( "SocialSharing", "EntryExit" ) )
            {
                $this->pushResult( "socialInfos", $this->app->getSocialInfos() );
            }

            if ( $this->app->node instanceof eZContentObjectTreeNode )
                $this->pushResult( "current_node", $this->app->node );
        }
        else if ( $this->app->isSeo )
        {
            $goToSpeciality = null;
            if ( is_null( $this->app->seoParams["speciality"] ) && $this->app->seoParams["noSpeciality"] )
            {
                $goToSpeciality = "all/speciality";
            }

            $this->pushResult( "seoMetas", $this->app->getSeoMetas() );
            $this->pushResult( "doSpecialityRedirect", $goToSpeciality );
        }

    }