public function prepareTemplate(Template $objTemplate, $arrRowData, $objSettings)
    {
        parent::prepareTemplate($objTemplate, $arrRowData, $objSettings);

        $base = Environment::get('base');
        $lang = $this->getActiveLanguageArray();

        $strEmpty = $this->ensureImage(
            $this->get('rating_emtpy'),
            'bundles/metamodelsattributerating/star-empty.png'
        );
        $strFull  = $this->ensureImage(
            $this->get('rating_full'),
            'bundles/metamodelsattributerating/star-full.png'
        );
        $strHover = $this->ensureImage(
            $this->get('rating_hover'),
            'bundles/metamodelsattributerating/star-hover.png'
        );

        if (\file_exists(TL_ROOT . '/' . $strEmpty)) {
            $size = \getimagesize(TL_ROOT . '/' . $strEmpty);
        } else {
            $size = \getimagesize(TL_ROOT . '/web/' . $strEmpty);
        }
        $objTemplate->imageWidth = $size[0];
        $objTemplate->rateHalf   = $this->get('rating_half') ? 'true' : 'false';
        $objTemplate->name       = 'rating_attribute_'.$this->get('id').'_'.$arrRowData['id'];

        $objTemplate->ratingDisabled = (
            $this->scopeDeterminator->currentScopeIsBackend()
            || $objSettings->get('rating_disabled')
            || $this->getSessionBag()->get($this->getLockId($arrRowData['id']))
        );

        $value  = ($this->get('rating_max') * (float) $arrRowData[$this->getColName()]['meanvalue']);
        $intInc = \strlen($this->get('rating_half')) ? .5 : 1;

        $objTemplate->currentValue = (\round(($value / $intInc), 0) * $intInc);
        $objTemplate->tipText      = \sprintf(
            $lang['metamodel_rating_label'],
            '[VALUE]',
            $this->get('rating_max')
        );
        $objTemplate->ajaxUrl      = $this->router->generate('metamodels.attribute_rating.rate');
        $objTemplate->ajaxData     = \json_encode(
            [
                'id'   => $this->get('id'),
                'pid'  => $this->get('pid'),
                'item' => $arrRowData['id'],
            ]
        );

        $arrOptions = [];
        $intValue   = $intInc;

        while ($intValue <= $this->get('rating_max')) {
            $arrOptions[] = $intValue;
            $intValue    += $intInc;
        }
        $objTemplate->options = $arrOptions;

        $objTemplate->imageEmpty = $base.$strEmpty;
        $objTemplate->imageFull  = $base.$strFull;
        $objTemplate->imageHover = $base.$strHover;
    }
public function prepareTemplate(Template $objTemplate, $arrRowData, $objSettings)
    {
        parent::prepareTemplate($objTemplate, $arrRowData, $objSettings);

        $base = Environment::get('base');
        $lang = $this->getActiveLanguageArray();

        $strEmpty = $this->ensureImage(
            $this->get('rating_emtpy'),
            'bundles/metamodelsattributerating/star-empty.png'
        );
        $strFull  = $this->ensureImage(
            $this->get('rating_full'),
            'bundles/metamodelsattributerating/star-full.png'
        );
        $strHover = $this->ensureImage(
            $this->get('rating_hover'),
            'bundles/metamodelsattributerating/star-hover.png'
        );

        if (\file_exists(TL_ROOT . '/' . $strEmpty)) {
            $size = \getimagesize(TL_ROOT . '/' . $strEmpty);
        } else {
            $size = \getimagesize(TL_ROOT . '/web/' . $strEmpty);
        }
        $objTemplate->imageWidth = $size[0];
        $objTemplate->rateHalf   = $this->get('rating_half') ? 'true' : 'false';
        $objTemplate->name       = 'rating_attribute_'.$this->get('id').'_'.$arrRowData['id'];

        $objTemplate->ratingDisabled = (
            $this->scopeDeterminator->currentScopeIsBackend()
            || $objSettings->get('rating_disabled')
            || $this->getSessionBag()->get($this->getLockId($arrRowData['id']))
        );

        $value  = ($this->get('rating_max') * (float) $arrRowData[$this->getColName()]['meanvalue']);
        $intInc = \strlen($this->get('rating_half')) ? .5 : 1;

        $objTemplate->currentValue = (\round(($value / $intInc), 0) * $intInc);
        $objTemplate->tipText      = \sprintf(
            $lang['metamodel_rating_label'],
            '[VALUE]',
            $this->get('rating_max')
        );
        $objTemplate->ajaxUrl      = $this->router->generate('metamodels.attribute_rating.rate');
        $objTemplate->ajaxData     = \json_encode(
            [
                'id'   => $this->get('id'),
                'pid'  => $this->get('pid'),
                'item' => $arrRowData['id'],
            ]
        );

        $arrOptions = [];
        $intValue   = $intInc;

        while ($intValue <= $this->get('rating_max')) {
            $arrOptions[] = $intValue;
            $intValue    += $intInc;
        }
        $objTemplate->options = $arrOptions;

        $objTemplate->imageEmpty = $base.$strEmpty;
        $objTemplate->imageFull  = $base.$strFull;
        $objTemplate->imageHover = $base.$strHover;
    }
public function prepareTemplate ( Template $ objTemplate , $ arrRowData , $ objSettings ) { parent :: prepareTemplate ( $ objTemplate , $ arrRowData , $ objSettings ) ; $ base = Environment :: get ( 'base' ) ; $ lang = $ this -> getActiveLanguageArray ( ) ; $ strEmpty = $ this -> ensureImage ( $ this -> get ( 'rating_emtpy' ) , 'bundles/metamodelsattributerating/star-empty.png' ) ; $ strFull = $ this -> ensureImage ( $ this -> get ( 'rating_full' ) , 'bundles/metamodelsattributerating/star-full.png' ) ; $ strHover = $ this -> ensureImage ( $ this -> get ( 'rating_hover' ) , 'bundles/metamodelsattributerating/star-hover.png' ) ; if ( \ file_exists ( TL_ROOT . '/' . $ strEmpty ) ) { $ size = \ getimagesize ( TL_ROOT . '/' . $ strEmpty ) ; } else { $ size = \ getimagesize ( TL_ROOT . '/web/' . $ strEmpty ) ; } $ objTemplate -> imageWidth = $ size [ 0 ] ; $ objTemplate -> rateHalf = $ this -> get ( 'rating_half' ) ? 'true' : 'false' ; $ objTemplate -> name = 'rating_attribute_' . $ this -> get ( 'id' ) . '_' . $ arrRowData [ 'id' ] ; $ objTemplate -> ratingDisabled = ( $ this -> scopeDeterminator -> currentScopeIsBackend ( ) || $ objSettings -> get ( 'rating_disabled' ) || $ this -> getSessionBag ( ) -> get ( $ this -> getLockId ( $ arrRowData [ 'id' ] ) ) ) ; $ value = ( $ this -> get ( 'rating_max' ) * ( float ) $ arrRowData [ $ this -> getColName ( ) ] [ 'meanvalue' ] ) ; $ intInc = \ strlen ( $ this -> get ( 'rating_half' ) ) ? .5 : 1 ; $ objTemplate -> currentValue = ( \ round ( ( $ value / $ intInc ) , 0 ) * $ intInc ) ; $ objTemplate -> tipText = \ sprintf ( $ lang [ 'metamodel_rating_label' ] , '[VALUE]' , $ this -> get ( 'rating_max' ) ) ; $ objTemplate -> ajaxUrl = $ this -> router -> generate ( 'metamodels.attribute_rating.rate' ) ; $ objTemplate -> ajaxData = \ json_encode ( [ 'id' => $ this -> get ( 'id' ) , 'pid' => $ this -> get ( 'pid' ) , 'item' => $ arrRowData [ 'id' ] , ] ) ; $ arrOptions = [ ] ; $ intValue = $ intInc ; while ( $ intValue <= $ this -> get ( 'rating_max' ) ) { $ arrOptions [ ] = $ intValue ; $ intValue += $ intInc ; } $ objTemplate -> options = $ arrOptions ; $ objTemplate -> imageEmpty = $ base . $ strEmpty ; $ objTemplate -> imageFull = $ base . $ strFull ; $ objTemplate -> imageHover = $ base . $ strHover ; }
Initialize the template with values.

@param Template $objTemplate The Template instance to populate.
@param array    $arrRowData  The row data for the current item.
@param ISimple  $objSettings The render settings to use for this attribute.

@return void
Initialize the template with values .