<commit_before><?php
class Kwc_Directories_List_ViewMap_Component extends Kwc_Directories_List_View_Component
{
    public static function getSettings()
    {
        $ret = parent::getSettings();
        $ret['assets']['files'][] = 'kwf/Kwc/Directories/List/ViewMap/Component.js';
        $ret['assets']['dep'][] = 'ExtCore';
        $ret['assets']['dep'][] = 'KwfGoogleMap';
        $ret['assets']['dep'][] = 'ExtUtilJson';
        $ret['generators']['child']['component']['paging'] = null;
        $ret['generators']['coordinates'] = array( // if removed markers are loaded directly
            'class'     => 'Kwf_Component_Generator_Page_Static',
            'component' => 'Kwc_Directories_List_ViewMap_Coordinates_Component',
            'name'      => 'Coordinates'
        );
        $ret['mapOptions'] = array(
            'zoom' => null,
            'zoom_properties' => 0,
            'height' => 400,
            'width' => 550,
            'scale' => 1,
            'satelite' => 1,
            'overview' => 1,
//             'minimumResolution' => 7, // min zoomstufe wenn nötig
//             'maximumResolution' => 12, // max zoomstufe wenn nötig
        );
        return $ret;
    }

    public function getTemplateVars()
    {
        $ret = parent::getTemplateVars();
        $ret['options'] = $this->_getSetting('mapOptions');
        if ($this->getData()->getChildComponent('_coordinates')) {
            $ret['options'] = array_merge(
                $ret['options'],
                array('markers' => $this->getData()->getChildComponent('_coordinates')->getUrl()),
                $this->_noMarkersOptions()
            );
        }
        return $ret;
    }

    public function getPartialVars($partial, $nr, $info)
    {
        $ret = parent::getPartialVars($partial, $nr, $info);

        $row = $ret['item']->getRow();
        if (empty($row->coordinates) && (
            !(isset($row->longitude) && isset($row->latitude))
            || (is_null($row->longitude) && is_null($row->latitude))
        )) {
            $marker = false;
        } else {
            $marker = array();
            if (isset($row->longitude) && isset($row->latitude)
                && !is_null($row->longitude) && !is_null($row->latitude)
            ) {
                $marker['latitude']  = $row->latitude;
                $marker['longitude'] = $row->longitude;
            } else if (!empty($row->coordinates)) {
                $coords = explode(';', $row->coordinates);
                $marker['latitude']  = $coords[0];
                $marker['longitude'] = $coords[1];
            } else {
                throw new Kwf_Exception('Either longitude and latitude, or coordinates has to exist in model');
            }

            $marker['infoHtml'] = call_user_func_array(
                array($this->getData()->componentClass, 'getInfoWindowHtml'), array($ret['item'])
            );
        }

        $ret['markerData'] = $marker;
        return $ret;
    }

    /**
     * Options that are used if no markers are available
     */
    protected function _noMarkersOptions()
    {
        return array(
            'longitude' => 13.24444771,
            'latitude'  => 47.95334614
        );
    }

    /**
     * Static for performance reasons. Is also called in sub-component "Coordinates"
     */
    static public function getInfoWindowHtml($data)
    {
        $row = $data->getRow();
        $link = new Kwf_Component_View_Helper_ComponentLink();
        return $link->componentLink($data);
    }
}<commit_msg>fix info window html escaping, componentLink returned {cc ... which was replaced later (after escaping)<commit_after><?php
class Kwc_Directories_List_ViewMap_Component extends Kwc_Directories_List_View_Component
{
    public static function getSettings()
    {
        $ret = parent::getSettings();
        $ret['assets']['files'][] = 'kwf/Kwc/Directories/List/ViewMap/Component.js';
        $ret['assets']['dep'][] = 'ExtCore';
        $ret['assets']['dep'][] = 'KwfGoogleMap';
        $ret['assets']['dep'][] = 'ExtUtilJson';
        $ret['generators']['child']['component']['paging'] = null;
        $ret['generators']['coordinates'] = array( // if removed markers are loaded directly
            'class'     => 'Kwf_Component_Generator_Page_Static',
            'component' => 'Kwc_Directories_List_ViewMap_Coordinates_Component',
            'name'      => 'Coordinates'
        );
        $ret['mapOptions'] = array(
            'zoom' => null,
            'zoom_properties' => 0,
            'height' => 400,
            'width' => 550,
            'scale' => 1,
            'satelite' => 1,
            'overview' => 1,
//             'minimumResolution' => 7, // min zoomstufe wenn nötig
//             'maximumResolution' => 12, // max zoomstufe wenn nötig
        );
        return $ret;
    }

    public function getTemplateVars()
    {
        $ret = parent::getTemplateVars();
        $ret['options'] = $this->_getSetting('mapOptions');
        if ($this->getData()->getChildComponent('_coordinates')) {
            $ret['options'] = array_merge(
                $ret['options'],
                array('markers' => $this->getData()->getChildComponent('_coordinates')->getUrl()),
                $this->_noMarkersOptions()
            );
        }
        return $ret;
    }

    public function getPartialVars($partial, $nr, $info)
    {
        $ret = parent::getPartialVars($partial, $nr, $info);

        $row = $ret['item']->getRow();
        if (empty($row->coordinates) && (
            !(isset($row->longitude) && isset($row->latitude))
            || (is_null($row->longitude) && is_null($row->latitude))
        )) {
            $marker = false;
        } else {
            $marker = array();
            if (isset($row->longitude) && isset($row->latitude)
                && !is_null($row->longitude) && !is_null($row->latitude)
            ) {
                $marker['latitude']  = $row->latitude;
                $marker['longitude'] = $row->longitude;
            } else if (!empty($row->coordinates)) {
                $coords = explode(';', $row->coordinates);
                $marker['latitude']  = $coords[0];
                $marker['longitude'] = $coords[1];
            } else {
                throw new Kwf_Exception('Either longitude and latitude, or coordinates has to exist in model');
            }

            $marker['infoHtml'] = call_user_func_array(
                array($this->getData()->componentClass, 'getInfoWindowHtml'), array($ret['item'])
            );
        }

        $ret['markerData'] = $marker;
        return $ret;
    }

    /**
     * Options that are used if no markers are available
     */
    protected function _noMarkersOptions()
    {
        return array(
            'longitude' => 13.24444771,
            'latitude'  => 47.95334614
        );
    }

    /**
     * Static for performance reasons. Is also called in sub-component "Coordinates"
     */
    static public function getInfoWindowHtml($data)
    {
        return "<a href=\"$data->url\" rel=\"$data->rel\">$data->name</a>";
    }
}
{'fraction_non_alphanumeric': 0.16299002388646902, 'fraction_numerical': 0.009835604889700717, 'mean_word_length': 2.061505376344086, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 86, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1447445', 'n_tokens_mistral': 2119, 'n_tokens_neox': 2026, 'n_words': 380}