0 users online. Create an account or sign in to join them.Users

Search

Please excuse the double post here and in the bug tracker, but maybe someone in the forum has a solution for this problem:

I have a data source that returns course names as parameter output. It’s working just fine, expect for those course names containing a comma, because commas are used as parameter delimiter:

$ds-teilnehmen-kurse: 'Stricken geht los 1: Anschlag, Rand- und rechte Maschen, Stricken geht los 2: Linke Maschen und Musterkombinationen, Stricken geht los 3: Abketten und was nun?'

The parameter `$ds-teilnehmen-kurse represents three courses:

  • Stricken geht los 1: Anschlag, Rand- und rechte Maschen
  • Stricken geht los 2: Linke Maschen und Musterkombinationen
  • Stricken geht los 3: Abketten und was nun?

But apparently it’s interpreted as four separate items:

  • Stricken geht los 1: Anschlag
  • Rand- und rechte Maschen
  • Stricken geht los 2: Linke Maschen und Musterkombinationen
  • Stricken geht los 3: Abketten und was nun?

Does anybody know where in the code these commas should be escaped and how this could be done without breaking other parts of the system?

Thanks for your help!
Nils

I believe Field::getParameterPoolValue() is called on the field. If the field does not specify this itself, the definition in class.field returns Field::prepareTableValue.

The value gets written to the param pool in datasource.section.php by the looks of things:

if(isset($this->dsParamPARAMOUTPUT) && $this->dsParamPARAMOUTPUT == $fieldPool[$field_id]->get('element_name')){
    $param_pool[$key][] = $fieldPool[$field_id]->getParameterPoolValue($values);
}

Looks like these might be converted into strings in class.frontendpage.php:

        if(is_array($this->_env['pool']) && !empty($this->_env['pool'])){
            foreach($this->_env['pool'] as $handle => $p){

                if(!is_array($p)) $p = array($p);
                foreach($p as $key => $value){

                    if(is_array($value) && !empty($value)){
                        foreach($value as $kk => $vv){
                            $this->_param[$handle] .= @implode(', ', $vv) . ',';
                        }
                    }

                    else{
                        $this->_param[$handle] = @implode(', ', $p);
                    }
                }

                $this->_param[$handle] = trim($this->_param[$handle], ',');
            }
        }

Okay, this is how the pool is populated. But how would it be possible to escape the commas in the field values so that they won’t be recognized when the string is separated into its parts again (using explode or preg_replace)?

Maybe one for Alistair ;-)

Hopefully :)

git push master:alistair --bug

Wish this thread had shown up a bit earlier. Alistair just did some work on that bit of code last night.

I’ll take a look at it today.

Posted on the issue tracker. http://github.com/symphony/symphony-2/issues/#issue/120 I’d rather keep it there, so going to close this thread.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.1
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details