<commit_before><?php defined('SYSPATH') or die('No direct access allowed.');

class Kohana_Controller_Filebrowser extends Controller_Template {

	/**
	 * View  page template
	 *
	 * @var View
	 */
	public $template = 'wysiwyg/filebrowser/overall';

	/**
	 * Config array
	 *
	 * @var array
	 */
	protected $_config = array();

	/**
	 * Path
	 *
	 * @var string
	 */
	protected $_path;

	/**
	 * Local directory that store static files
	 *
	 * @var string
	 */
	protected $_directory;

	public function before()
	{
		parent::before();

		$this->template
			->set('js',      Media::instance('js'))
			->set('css',     Media::instance('css'))
			->set('title',   '')
			->set('content', '');

		/**
		 * Load config
		 */
		$this->_config = Arr::merge(Kohana::$config->load('media')->as_array(),
			Kohana::$config->load('wysiwyg.default'));

		$this->_directory = $this->_config['media_directory']
			.DIRECTORY_SEPARATOR
			.Kohana::$config->load('filebrowser.uploads_directory')
			.DIRECTORY_SEPARATOR;

		$this->_path = $this->request->param('path');
	}

	public function action_browse()
	{
		$this->template->title = __('Files :path', array(
			':path' => '/'.$this->_path
			));

		$this->_filebrowser();
	}

	public function action_dirs()
	{
		$this->auto_render = FALSE;

		$dirs = Filebrowser::list_dirs($this->_directory.$this->_path);

		foreach($dirs as $key => $val)
		{
			$dirname = $this->_directory.$this->_path.DIRECTORY_SEPARATOR.$key;

			$subdirs = Filebrowser::list_files($dirname);

			$dirs[$key] = sizeof($subdirs[0]);
		}

		return $this->response->body(json_encode(array('dirs' => $dirs)));
	}

	public function action_files()
	{
		$this->auto_render = FALSE;

		return $this->response->body(json_encode(array(
			'files' => Filebrowser::list_files($this->_directory.$this->_path)
			)));
	}

	public function action_images()
	{
		$this->template->title = __('Images :path', array(
			':path' => '/'.$this->_path
			));

		$this->_filebrowser();
	}

	public function action_flash()<commit_msg>Fixed errors in filebrowser controller<commit_after><?php defined('SYSPATH') or die('No direct access allowed.');

class Kohana_Controller_Filebrowser extends Controller_Template {

	/**
	 * View  page template
	 *
	 * @var View
	 */
	public $template = 'wysiwyg/filebrowser/overall';

	/**
	 * Config array
	 *
	 * @var array
	 */
	protected $_config = array();

	/**
	 * Path
	 *
	 * @var string
	 */
	protected $_path;

	/**
	 * Local directory that store static files
	 *
	 * @var string
	 */
	protected $_directory;

	public function before()
	{
		parent::before();

		$this->template
			->set('js',      Media::instance('js'))
			->set('css',     Media::instance('css'))
			->set('title',   '')
			->set('content', '');

		/**
		 * Load config
		 */
		$this->_config = Arr::merge(Kohana::$config->load('media')->as_array(),
			Kohana::$config->load('wysiwyg.default'));

		$this->_directory = $this->_config['media_directory']
			.DIRECTORY_SEPARATOR
			.Kohana::$config->load('filebrowser.uploads_directory')
			.DIRECTORY_SEPARATOR;

		$this->_path = $this->request->param('path');
	}

	public function action_browse()
	{
		$this->template->title = __('Files :path', array(
			':path' => '/'.$this->_path
			));

		$this->_filebrowser();
	}

	public function action_dirs()
	{
		$this->auto_render = FALSE;

		$dirs = Filebrowser::list_dirs($this->_directory.$this->_path);

		foreach($dirs as $key => $val)
		{
			$dirname = $this->_directory.$this->_path.DIRECTORY_SEPARATOR.$key;

			$subdirs = Filebrowser::list_files($dirname);

			$dirs[$key] = sizeof($subdirs);
		}

		return $this->response->body(json_encode(array('dirs' => $dirs)));
	}

	public function action_files()
	{
		$this->auto_render = FALSE;

		return $this->response->body(json_encode(array(
			'files' => Filebrowser::list_files($this->_directory.$this->_path)
			)));
	}

	public function action_images()
	{
		$this->template->title = __('Images :path', array(
			':path' => '/'.$this->_path
			));

		$this->_filebrowser();
	}

	public function action_flash()
{'fraction_non_alphanumeric': 0.19467718087727945, 'fraction_numerical': 0.0002464268112370626, 'mean_word_length': 3.8035502958579883, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4811308', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1345, 'n_words': 235}