Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Added ability to pass config manually #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

enumag
Copy link

@enumag enumag commented Jun 6, 2015

Personally I don't like the configuration via session thing. Instead I want to have my own logic in my app that would check privileges and such and then call the KCFinder directly. Here is what I use in my project:

<?php

use kcfinder\browser;
use kcfinder\uploader;

class FileManagerPresenter extends BasePresenter
{

    public function actionBrowse()
    {
        require_once $this->wwwDir . '/support/kcfinder/core/autoload.php';
        $browser = new browser($this->getConfig());
        $browser->action();
    }

    public function actionUpload()
    {
        require_once $this->wwwDir . '/support/kcfinder/core/autoload.php';
        $uploader = new uploader($this->getConfig());
        $uploader->upload();
    }

    private function getConfig()
    {
        // some logic to put the desired config together
    }

}

Now this means that the constructor should accept configuration array as an optional argument.

As a sideeffect since I have different URL it breaks autoloading, searching for lang files, javascript, css and such. I have fixed all that as well.

@enumag enumag force-pushed the patch-1 branch 2 times, most recently from 8172232 to dbca7ce Compare June 6, 2015 13:39
@tomaswindsor
Copy link

Since you are using [] array notation (PHP 5.4 feature), why not also use __DIR__ magical constant (PHP 5.3 feature) instead of dirname(__FILE__)?

@enumag
Copy link
Author

enumag commented Jun 14, 2015

The 5.4 array notation was not intended, KCFinder is currently compatible with 5.3 and it was not my intention to break it. Thanks for pointing it out.

@enumag
Copy link
Author

enumag commented Jun 15, 2015

@tomaswindsor Fixed compatibility with 5.3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants