<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Filemanager extends Admin_Controller
{
    function __construct() 
    {
        parent::__construct();
        
        //defined('FILEROOT') OR define('FILEROOT', 'assets/uploads/blog/');
        //defined('FILEMANAGER_PATH') OR define('FILEMANAGER_PATH', BUPATH.'modules/filemanager/third_party/filemanager/');
    }
    
    public function browser()
    {
		Template::set_theme('filemanager');
        
        Assets::add_module_css('filemanager',array(
            'filemanager/reset.css',
        	'filemanager/filemanager.css'  
        ));
        
        Assets::add_css(array(
        	'plugins/jquery.contextmenu/dist/jquery.contextMenu.min.css',
        	'plugins/custom-scrollbar-plugin/jquery.mCustomScrollbar.min.css',
        	'plugins/alertify.js/dist/css/alertify.css'    
        ));
        
        Assets::add_js(array(
            'plugins/jquery/jquery-1.11.3.min.js',
            'plugins/jquery-ui/jquery-ui.min.js',
    		'plugins/jquery-browser.js',
    		'plugins/knockout-3.4.0.js',
    		'plugins/jquery.splitter/dist/jquery-splitter.js',
    		'plugins/jquery.contextmenu/dist/jquery.contextMenu.min.js',
    		'plugins/alertify.js/dist/js/alertify.js',
    		'plugins/zeroclipboard/dist/ZeroClipboard.js',
            'plugins/jquery.fileDownload/jquery.fileDownload.min.js',
    		'plugins/javascript-templates/js/tmpl.min.js',
    		'plugins/toast/lib/toast.min.js',
    		'plugins/purl/purl.min.js',
    		'plugins/filemanager.js',
		));
		
		Assets::add_module_js('filemanager',array(
		    'filemanager.init.js'
	    ));
		
		Template::set_view('browser_view');
		
		Template::render();        
    }
    
    public function connectors()
    {
        $get = $this->input->get();
        if(isset($get['mode'])) // tratamento de segurança para não permitir excluir as pastas default
        {
            $actions = array('rename','move');
            $folders = array('/blog/','/postagens/','/servicos/','/slideshow/');
            //if(in_array($get['mode'],$actions) && in_array($get['old'],$folders)){ return false; } 
            //if($get['mode'] == 'delete' && in_array($get['path'],$folders)){ return false; } 
        }

        //include_once('../builder/modules/filemanager/third_party/filemanager/filemanager.php');
        include_once('../application/modules/blog/controllers/Midias_new.php');
    }
}