yii-elfinder2 This extension allows use elFinder file manager in your Yii application.

  1. Requirements
  2. Installation
  3. Usage
  4. Resources

This extension allows use elFinder file manager in your Yii application. Possible usage:

  • chose file on server side (ServerFileInput widget)
  • manage files in specified folder (ElFinder widget)
  • add file browser to tinyMce wysiwyg editor

Based on elfinder extension by Bogdan Savluk with updated elFinder and some code improvements.

Requirements

Tested with Yii 1.1.14, but should work with previous versions too.

Installation

Copy extension files to your project to protected/extensions/elFinder

Usage

  1. Create controller for connector action, and configure it params
~~~
[php]
class ElfinderController extends Controller {

	// don't forget configure access rules

	public function actions() {
		return array(
			// main action for elFinder connector
			'connector' => array(
				'class' => 'ext.elFinder.ElFinderConnectorAction',
				// elFinder connector configuration
				// https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options
				'settings' => array(
					'roots' => array(
						array(
							'driver' => 'LocalFileSystem',
							'path' => Yii::getPathOfAlias('webroot') . '/files/',
							'URL' => Yii::app()->baseUrl . '/files/',
							'alias' => 'Root Alias',
							'acceptedName' => '/^[^\.].*$/', // disable creating dotfiles
							'attributes' => array(
								array(
									'pattern' => '/\/[.].*$/', // hide dotfiles
									'read' => false,
									'write' => false,
									'hidden' => true,
								),
							),
						)
					),
				)
			),
			// action for TinyMCE popup with elFinder widget
			'elfinderTinyMce' => array(
				'class' => 'ext.elFinder.TinyMceElFinderPopupAction',
				'connectorRoute' => 'connector', // main connector action id
			),
			// action for file input popup with elFinder widget
			'elfinderFileInput' => array(
				'class' => 'ext.elFinder.ServerFileInputElFinderPopupAction',
				'connectorRoute' => 'connector', // main connector action id
			),
		);
	}

}
~~~
  1. ServerFileInput - use this widget to choose file on server using elFinder pop-up

    [php]
    $this->widget('ext.elFinder.ServerFileInput', array(
    	'model' => $model,
    	'attribute' => 'field_name',
    	'popupConnectorRoute' => 'elfinder/elfinderFileInput', // relative route for file input action
    	// ability to customize "Browse" button
    //	'customButton' => TbHtml::button('Browse images', array(
    //		'id' => TbHtml::getIdByName(TbHtml::activeName($model, 'field_name')) . 'browse',
    //		'class' => 'btn', 'color' => TbHtml::BUTTON_COLOR_DEFAULT,
    //		'size' => TbHtml::BUTTON_SIZE_DEFAULT, 'style' => 'margin-left:10px;')),
    	// title for popup window (optional)
    	'popupTitle' => 'Files',
    ));
    
  2. ElFinderWidget - use this widget to manage files

    [php]
    $this->widget('ext.elFinder.ElFinderWidget', array(
    	'connectorRoute' => 'elfinder/connector', // relative route for elFinder connector action
    ));
    
  3. TinyMceElFinder - use this widget to integrate elFinder with yii-tinymce

    [php]
    $this->widget('ext.tinymce.TinyMce', array(
    	'model' => $model,
    	'attribute' => 'content',
    	'fileManager' => array(
    		'class' => 'ext.elFinder.TinyMceElFinder',
    		'popupConnectorRoute' => 'elfinder/elfinderTinyMce', // relative route for TinyMCE popup action
    		// title for popup window (optional)
    		'popupTitle' => "Files",
    	),
    ));
    

Resources

1 0
7 followers
1 615 downloads
Yii Version: 1.1.*
License: BSD-2-Clause
Category: User Interface
Developed by: rob006
Created on: Apr 14, 2014
Last updated: 8 months ago
Code Repository

Downloads

show all

Related Extensions