コード例 #1
0
    /**
     * 
     * @return eZTemplate
     */
    public function tpl()
    {
        $tpl = parent::tpl();

        // test if user is logged
        $userId         = MMUsers::getCurrentUserId();
        $currentUser    = MMUsers::fetchById( $userId );
        $isLogged       = !empty($currentUser);

        $salt = eZINI::instance( 'merck.ini' )->variable( 'TicketLogin', 'DESKey' );
        $hash = sha1($this->getApplicationId() . $salt);

        $tpl->setVariable('application_id', $this->getApplicationId());
        $tpl->setVariable('is_logged'     , $isLogged);
        $tpl->setVariable('hash'          , $hash);

        // applications for anonymous users
        $applications_anonymous = array();

        if( !$isLogged )
        {
            $ids = CountryAppsBar::fetchAppsBarApplicationIds();

            // convert ids in string
            $applications_anonymous = explode(',', implode(',', $ids));
        }

        $tpl->setVariable('applications_anonymous', $applications_anonymous);

        if( $isLogged && SolrSafeOperatorHelper::featureIsActive( 'GoogleAnalytics' ) )
        {
            $gtmVariables = array(
                'visitorSpecialtyLabel' => SolrSafeOperatorHelper::getTaxoTranslation( 'user_specialty', $this->user()->userSpecialityId() ),
                'visitorTypeLabel'      => SolrSafeOperatorHelper::getTaxoTranslation( 'customer_type',  $this->user()->customerTypeId() )
            );
            $gtmToPush = isset( $this->_result['gtm_variables'] ) ? array_merge( $this->_result['gtm_variables'], $gtmVariables ) : $gtmVariables;
            $tpl->setVariable( 'gtm_visitorvariables', $gtmToPush );
        }

        return $tpl;
    }