Skip to content

Commit

Permalink
Source code indentation problem #35
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailDev committed Jul 3, 2015
1 parent 56c3402 commit 64b4257
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 274 deletions.
50 changes: 25 additions & 25 deletions Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@

class Assets extends AssetBundle
{
public $css = array(
'css/elfinder.min.css',
'css/theme.css',
);
public $js = array(
'js/elfinder.min.js'
);
public $depends = array(
'yii\jui\JuiAsset',
);
public $css = array(
'css/elfinder.min.css',
'css/theme.css',
);
public $js = array(
'js/elfinder.min.js'
);
public $depends = array(
'yii\jui\JuiAsset',
);

public function init()
{
$this->sourcePath = __DIR__."/assets";
parent::init();
}
public function init()
{
$this->sourcePath = __DIR__."/assets";
parent::init();
}

/**
* @param string $lang
* @param \yii\web\View $view
*/
public static function addLangFile($lang, $view){
$lang = ElFinder::getSupportedLanguage($lang);
/**
* @param string $lang
* @param \yii\web\View $view
*/
public static function addLangFile($lang, $view){
$lang = ElFinder::getSupportedLanguage($lang);

if ($lang !== false && $lang !== 'en'){
list(,$path) = \Yii::$app->assetManager->publish(__DIR__."/assets");
if ($lang !== false && $lang !== 'en'){
list(,$path) = \Yii::$app->assetManager->publish(__DIR__."/assets");
$view->registerJsFile($path.'/js/i18n/elfinder.' . $lang . '.js', ['depends' => [Assets::className()]]);
}
}
}
}

/**
* @param \yii\web\View $view
Expand Down
22 changes: 11 additions & 11 deletions AssetsCallBack.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
use yii\web\AssetBundle;

class AssetsCallBack extends AssetBundle{
public $js = array(
'js/elfinder.callback.js'
);
public $depends = array(
'yii\web\JqueryAsset'
);
public $js = array(
'js/elfinder.callback.js'
);
public $depends = array(
'yii\web\JqueryAsset'
);

public function init()
{
$this->sourcePath = __DIR__."/assets";
parent::init();
}
public function init()
{
$this->sourcePath = __DIR__."/assets";
parent::init();
}
}
1 change: 0 additions & 1 deletion BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public function getManagerOptions(){
}

public function actionManager(){

return $this->renderFile(__DIR__."/views/manager.php", ['options'=>$this->getManagerOptions()]);
}
}
121 changes: 59 additions & 62 deletions BasePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,59 @@
*/
class BasePath extends BaseComponent{

public $driver = 'LocalFileSystem';
public $driver = 'LocalFileSystem';

public $name = 'Root';
public $name = 'Root';

public $options = [];
public $options = [];

public $access = ['read' => '*', 'write' => '*'];
public $access = ['read' => '*', 'write' => '*'];

public $tmbPath;

public function getAlias(){
if(is_array($this->name)){
return Yii::t($this->name['category'], $this->name['message']);
}

return $this->name;
}

public function isAvailable(){
return $this->defaults['read'];
}

private $_defaults;

public function getDefaults(){
if($this->_defaults !== null)
return $this->_defaults;
$this->_defaults['read'] = false;
$this->_defaults['write'] = false;

if(isset($this->access['write'])){
$this->_defaults['write'] = true;
if($this->access['write'] != '*'){
$this->_defaults['write'] = Yii::$app->user->can($this->access['write']);
}
}

if($this->_defaults['write']){
$this->_defaults['read'] = true;
}elseif(isset($this->access['read'])){
$this->_defaults['read'] = true;
if($this->access['read'] != '*'){
$this->_defaults['read'] = Yii::$app->user->can($this->access['read']);
}
}

return $this->_defaults;
}

public function getRoot(){
$options['driver'] = $this->driver;
$options['defaults'] = $this->getDefaults();
$options['alias'] = $this->getAlias();
public function getAlias(){
if(is_array($this->name)){
return Yii::t($this->name['category'], $this->name['message']);
}

return $this->name;
}

public function isAvailable(){
return $this->defaults['read'];
}

private $_defaults;

public function getDefaults(){
if($this->_defaults !== null)
return $this->_defaults;
$this->_defaults['read'] = false;
$this->_defaults['write'] = false;

if(isset($this->access['write'])){
$this->_defaults['write'] = true;
if($this->access['write'] != '*'){
$this->_defaults['write'] = Yii::$app->user->can($this->access['write']);
}
}

if($this->_defaults['write']){
$this->_defaults['read'] = true;
}elseif(isset($this->access['read'])){
$this->_defaults['read'] = true;
if($this->access['read'] != '*'){
$this->_defaults['read'] = Yii::$app->user->can($this->access['read']);
}
}

return $this->_defaults;
}

public function getRoot(){
$options['driver'] = $this->driver;
$options['defaults'] = $this->getDefaults();
$options['alias'] = $this->getAlias();

$options['tmpPath'] = Yii::getAlias('@runtime/elFinderTmpPath');
if(!empty($this->tmbPath)){
Expand All @@ -84,21 +84,18 @@ public function getRoot(){
FileHelper::createDirectory($options['tmbPath']);


$options['mimeDetect'] = 'internal';
$options['imgLib'] = 'auto';
$options['attributes'][] = [
'pattern' => '#.*(\.tmb|\.quarantine)$#i',
'read' => false,
'write' => false,
'hidden' => true,
'locked' => false
];
$options['mimeDetect'] = 'internal';
$options['imgLib'] = 'auto';
$options['attributes'][] = [
'pattern' => '#.*(\.tmb|\.quarantine)$#i',
'read' => false,
'write' => false,
'hidden' => true,
'locked' => false
];

//var_export($options);exit;

return \yii\helpers\ArrayHelper::merge($options, $this->options);
}



}
return \yii\helpers\ArrayHelper::merge($options, $this->options);
}
}
2 changes: 0 additions & 2 deletions ButtonWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ public function init()
}

public function run(){

AssetsCallBack::register($this->getView());

echo Html::tag($this->tag, $this->name, $this->options);

$this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->_managerOptions['id']) . ", " . Json::encode($this->callback) . ");"); // register callback Function
$this->getView()->registerJs("\$(document).on('click', '#" . $this->options['id'] . "', function(){mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});");//on click button open manager

}
}
40 changes: 20 additions & 20 deletions Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@


class Controller extends BaseController{
public $roots = [];
public $disabledCommands = ['netmount'];
public $roots = [];
public $disabledCommands = ['netmount'];
public $watermark;

private $_options;
private $_options;

public function getOptions()
{
if($this->_options !== null)
return $this->_options;
public function getOptions()
{
if($this->_options !== null)
return $this->_options;

$this->_options['roots'] = [];
$this->_options['roots'] = [];

foreach($this->roots as $root){
if(is_string($root))
$root = ['path' => $root];
foreach($this->roots as $root){
if(is_string($root))
$root = ['path' => $root];

if(!isset($root['class']))
$root['class'] = 'mihaildev\elfinder\LocalPath';
if(!isset($root['class']))
$root['class'] = 'mihaildev\elfinder\LocalPath';

$root = Yii::createObject($root);
$root = Yii::createObject($root);

/** @var \mihaildev\elfinder\LocalPath $root*/
/** @var \mihaildev\elfinder\LocalPath $root*/

if($root->isAvailable())
$this->_options['roots'][] = $root->getRoot();
}
if($root->isAvailable())
$this->_options['roots'][] = $root->getRoot();
}

if(!empty($this->watermark)){
$this->_options['bind']['upload.presave'] = 'Plugin.Watermark.onUpLoadPreSave';
Expand All @@ -65,6 +65,6 @@ public function getOptions()

$this->_options = ArrayHelper::merge($this->_options, $this->connectOptions);

return $this->_options;
}
return $this->_options;
}
}
Loading

0 comments on commit 64b4257

Please sign in to comment.