protected function validateHeaderSettings()
    {
        $errors = $header = array();
        $lines = gplcart_string_explode_multiline($this->getSubmitted('header', ''));

        foreach ($lines as $pos => $line) {

            $pos++;
            $data = array_filter(array_map('trim', explode(' ', $line, 2)));

            if (count($data) != 2) {
                $errors[] = $pos;
                continue;
            }

            list($key, $label) = $data;

            if (preg_match('/^[a-z_]+$/', $key) !== 1) {
                $errors[] = $pos;
                continue;
            }

            $header[$key] = $label;
        }

        if (empty($errors)) {
            $this->setSubmitted('header', $header);
        } else {
            $vars = array('@num' => implode(',', $errors));
            $this->setError('header', $this->text('Error on line @num', $vars));
        }
    }
protected function validateHeaderSettings()
    {
        $errors = $header = array();
        $lines = gplcart_string_explode_multiline($this->getSubmitted('header', ''));

        foreach ($lines as $pos => $line) {

            $pos++;
            $data = array_filter(array_map('trim', explode(' ', $line, 2)));

            if (count($data) != 2) {
                $errors[] = $pos;
                continue;
            }

            list($key, $label) = $data;

            if (preg_match('/^[a-z_]+$/', $key) !== 1) {
                $errors[] = $pos;
                continue;
            }

            $header[$key] = $label;
        }

        if (empty($errors)) {
            $this->setSubmitted('header', $header);
        } else {
            $vars = array('@num' => implode(',', $errors));
            $this->setError('header', $this->text('Error on line @num', $vars));
        }
    }
protected function validateHeaderSettings ( ) { $ errors = $ header = array ( ) ; $ lines = gplcart_string_explode_multiline ( $ this -> getSubmitted ( 'header' , '' ) ) ; foreach ( $ lines as $ pos => $ line ) { $ pos ++ ; $ data = array_filter ( array_map ( 'trim' , explode ( ' ' , $ line , 2 ) ) ) ; if ( count ( $ data ) != 2 ) { $ errors [ ] = $ pos ; continue ; } list ( $ key , $ label ) = $ data ; if ( preg_match ( '/^[a-z_]+$/' , $ key ) !== 1 ) { $ errors [ ] = $ pos ; continue ; } $ header [ $ key ] = $ label ; } if ( empty ( $ errors ) ) { $ this -> setSubmitted ( 'header' , $ header ) ; } else { $ vars = array ( '@num' => implode ( ',' , $ errors ) ) ; $ this -> setError ( 'header' , $ this -> text ( 'Error on line @num' , $ vars ) ) ; } }
Validate header mapping
Validate header mapping