Jump to content

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


ealio
 Share

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?

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More