Skip to content

Commit

Permalink
make the directory a dropdown list
Browse files Browse the repository at this point in the history
make @brianteeman happy :)
  • Loading branch information
dgrammatiko committed Apr 2, 2017
1 parent 0f12c52 commit 48acb76
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
74 changes: 74 additions & 0 deletions plugins/editors/tinymce/field/uploaddirs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.tinymce
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

jimport('joomla.form.helper');

JFormHelper::loadFieldClass('list');

/**
* Generates the list of directories available for drag and drop upload.
*
* @package Joomla.Plugin
* @subpackage Editors.tinymce
* @since __DEPLOY_VERSION__
*/
class JFormFieldUploaddirs extends JFormFieldList
{
protected $type = 'uploaddirs';

/**
* Method to get the directories options.
*
* @return array The skins option objects.
*
* @since __DEPLOY_VERSION__
*/
public function getOptions()
{
$options = array();
$root = JComponentHelper::getParams('com_media')->get('image_path');


$directories = glob(JPATH_ROOT . '/' . $root . '/*', GLOB_ONLYDIR);

$options[] = JHtml::_('select.option', '', '');

for ($i = 0; $i < count($directories); ++$i)
{
$dir = basename($directories[$i]);
$options[] = JHtml::_('select.option', $i, $dir);
}

$options = array_merge(parent::getOptions(), $options);

return $options;
}

/**
* Method to get the field input markup for the list of directories.
*
* @return string The field input markup.
*
* @since __DEPLOY_VERSION__
*/
protected function getInput()
{
$html = array();

// Get the field options.
$options = (array) $this->getOptions();

// Create a regular list.
$html[] = JHtml::_('select.genericlist', $options, $this->name, '', 'value', 'text', $this->value, $this->id);

return implode($html);
}
}
2 changes: 1 addition & 1 deletion plugins/editors/tinymce/form/setoptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

<field
name="path"
type="text"
type="uploaddirs"
label="PLG_TINY_FIELD_CUSTOM_PATH_LABEL"
description="PLG_TINY_FIELD_CUSTOM_PATH_DESC"
class="input-xxlarge"
Expand Down
8 changes: 7 additions & 1 deletion plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,13 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons

if (!empty($tempPath))
{
$tempPath = ltrim(rtrim($tempPath, '/'));
// List the skins
$uplloadDirs = glob(JPATH_ROOT . '/' . JComponentHelper::getParams('com_media')->get('image_path') . '/*', GLOB_ONLYDIR);

if ((int) $tempPath < count($uplloadDirs))
{
$tempPath = basename($uplloadDirs[(int) $tempPath - 1]);
}
}

JText::script('PLG_TINY_ERR_UNSUPPORTEDBROWSER');
Expand Down

0 comments on commit 48acb76

Please sign in to comment.