ZF-11802: Zend_Dojo_View_Helper_Dijitt Improvement

Description

Currently Zend_Dojo_View_Helper_Dijit::setDijitParam() does not allow Javascript objects to be passed as parameters. I propose we add support for Zend_Json_Expr to be passed. Many parameters require objects to be passed to have the dijit work properly.

A direct result of this change will require the Elements to support more than strings being passed to them.

Line 241 of Zend_Dojo_View_Helper_Dijit only allows scalar values to be passed.



                    foreach ($params[$param] as $key => $value) {
                        if (!is_scalar($value)) {
                            continue;
                        }
                        $values[$key] = $value;
                    }

to


                    foreach ($params[$param] as $key => $value) {
                        if (!is_scalar($value)) {
                            if(!($value instanceof Zend_Json_Expr))
                                continue;
                            
                        }
                        $values[$key] = $value;
                    }

One we allow Zend_Json_Expr we need to have Zend_Json look for the expressions on line 252:



                $values = Zend_Json::encode($values);

to


                 $values = Zend_Json::encode($values, false, array('enableJsonExprFinder' => true) );

Issue came up because I was trying to load additional plugins with Zend_Dojo_Form_Element_Editor. The plugin required more then a string to configure. Additional changes needed were in Zend_Dojo_Form_Element_Editor::addPlugin(). Has to remove the $plugin being cast to a string.


  public function addPlugin($plugin)
    {
        $plugin = (string) $plugin;
        $plugins = $this->getPlugins();
        if (in_array($plugin, $plugins) && $plugin !== '|') {
            return $this;
        }

        $plugins[] = (string) $plugin;
        $this->setDijitParam('plugins', $plugins);
        return $this;
    }

to


  public function addPlugin($plugin)
    {
        $plugin = $plugin;
        $plugins = $this->getPlugins();
        if (in_array($plugin, $plugins) && $plugin !== '|') {
            return $this;
        }

        $plugins[] = $plugin;
        $this->setDijitParam('plugins', $plugins);
        return $this;
    }

Comments

You will need to sign and submit a CLA before we can review and possibly implement your proposed solution. See here: http://framework.zend.com/wiki/display/…