Jump to content

Is it a bug for the method of addJqueryPlugin method in /class/controller/Controller.php?


ealio

Recommended Posts

Is it a bug for the method of addJqueryPlugin method in /class/controller/Controller.php?

 

public function addJqueryPlugin($name, $folder = null)
    {
        $plugin_path = array();
        if (is_array($name))
        {
            foreach ($name as $plugin)
            {
                $plugin_path = Media::getJqueryPluginPath($plugin, $folder);
                if(!empty($plugin_path['js']))
                    $this->addJS($plugin_path['js']);
                if(!empty($plugin_path['css']))        
                    $this->addCSS($plugin_path['css']);
            }
        }
        else
            $plugin_path = Media::getJqueryPluginPath($name, $folder);

        if(!empty($plugin_path['css']))
            $this->addCSS($plugin_path['css']);
        if(!empty($plugin_path['js']))
            $this->addJS($plugin_path['js']);
    }

 

If the parameter of $name is an array, the last

        if(!empty($plugin_path['css']))
            $this->addCSS($plugin_path['css']);
        if(!empty($plugin_path['js']))
            $this->addJS($plugin_path['js']);

should not be executed.

 

I think it should be changed to

public function addJqueryPlugin($name, $folder = null)
    {
        $plugin_path = array();
        if (is_array($name))
        {
            foreach ($name as $plugin)
            {
                $plugin_path = Media::getJqueryPluginPath($plugin, $folder);
                if(!empty($plugin_path['js']))
                    $this->addJS($plugin_path['js']);
                if(!empty($plugin_path['css']))        
                    $this->addCSS($plugin_path['css']);
            }
        }
        else{
            $plugin_path = Media::getJqueryPluginPath($name, $folder);

            if(!empty($plugin_path['css']))
                $this->addCSS($plugin_path['css']);
            if(!empty($plugin_path['js']))
                $this->addJS($plugin_path['js']);

        }
    }

 

What do you think?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...