Skip to content

Commit

Permalink
Update to Froala 2.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sguionni committed Dec 19, 2017
1 parent 79588c9 commit c9b40ee
Show file tree
Hide file tree
Showing 262 changed files with 647 additions and 685 deletions.
39 changes: 19 additions & 20 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace KMS\FroalaEditorBundle\DependencyInjection;

use KMS\FroalaEditorBundle\Utility\UConfiguration;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
Expand Down Expand Up @@ -42,30 +42,29 @@ public function getConfigTreeBuilder()
$this->addFroalaConfigTree( $nodeBuilder );
// "profiles" are treated separetely as they repeat main option structures
$profileSubTreeBuilder = $nodeBuilder
->arrayNode('profiles')
->useAttributeAsKey('name')
->prototype('array')
->children();
$this->addFroalaConfigTree( $profileSubTreeBuilder , false );
->arrayNode( 'profiles' )
->useAttributeAsKey( 'name' )
->prototype( 'array' )
->children();
$this->addFroalaConfigTree( $profileSubTreeBuilder, false );
$profileSubTreeBuilder->end()->end();
$nodeBuilder->end();

return $treeBuilder;
}

/**
* Add all options to configuration subtree
*
* @param NodeBuilder $nodeBuilder
*/
private function addFroalaConfigTree( & $nodeBuilder , $addDefaultValue = true )
{
/**
* Add all options to configuration subtree
* @param NodeBuilder $nodeBuilder
*/
private function addFroalaConfigTree( & $nodeBuilder, $addDefaultValue = true )
{

UConfiguration::addArrOptionBoolean( $nodeBuilder , $addDefaultValue );
UConfiguration::addArrOptionInteger( $nodeBuilder , $addDefaultValue );
UConfiguration::addArrOptionString( $nodeBuilder, $addDefaultValue );
UConfiguration::addArrOptionArray( $nodeBuilder , $addDefaultValue );
UConfiguration::addArrOptionObject( $nodeBuilder , $addDefaultValue );
UConfiguration::addArrOptionBoolean( $nodeBuilder, $addDefaultValue );
UConfiguration::addArrOptionInteger( $nodeBuilder, $addDefaultValue );
UConfiguration::addArrOptionString( $nodeBuilder, $addDefaultValue );
UConfiguration::addArrOptionArray( $nodeBuilder, $addDefaultValue );
UConfiguration::addArrOptionObject( $nodeBuilder, $addDefaultValue );

}
}
}
63 changes: 34 additions & 29 deletions DependencyInjection/KMSFroalaEditorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,40 @@ private function loadResources( ContainerBuilder $p_container )
* @param array $p_arrConfig
*/
private function loadConfig( ContainerBuilder $p_container, array $p_arrConfig )
{
// ------------------------- DECLARE ---------------------------//

// Load defined options in config file.
foreach (UConfiguration::getArrOptionAll() as $option) {
if (empty($p_arrConfig [$option]) == false || //
$p_arrConfig [$option] === false || //
$p_arrConfig [$option] === 0
) {
$p_container->setParameter(Configuration::$NODE_ROOT.'.'.$option, $p_arrConfig [$option]);
}

}

$parameterProfiles = array();

foreach ($p_arrConfig['profiles'] as $key => $profile) {
$parameterProfiles[$key] = array();
foreach ($profile as $optionKey => $optionValue) {
if (empty($optionValue) == false || //
$optionValue === false || //
$optionValue === 0
) {
$parameterProfiles[$key][$optionKey] = $optionValue;
}
}
}

$p_container->setParameter(Configuration::$NODE_ROOT.'.profiles', $parameterProfiles);
{
// ------------------------- DECLARE ---------------------------//

// Load defined options in config file.
foreach( UConfiguration::getArrOptionAll() as $option )
{
if( empty( $p_arrConfig [ $option ] ) == false || //
$p_arrConfig [ $option ] === false || //
$p_arrConfig [ $option ] === 0
)
{
$p_container->setParameter( Configuration::$NODE_ROOT . '.' . $option, $p_arrConfig [ $option ] );
}

}

$parameterProfiles = array();

foreach( $p_arrConfig[ 'profiles' ] as $key => $profile )
{
$parameterProfiles[ $key ] = array();
foreach( $profile as $optionKey => $optionValue )
{
if( empty( $optionValue ) == false || //
$optionValue === false || //
$optionValue === 0
)
{
$parameterProfiles[ $key ][ $optionKey ] = $optionValue;
}
}
}

$p_container->setParameter( Configuration::$NODE_ROOT . '.profiles', $parameterProfiles );


}
Expand Down
33 changes: 19 additions & 14 deletions Form/Type/FroalaEditorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,27 @@ public function buildView( FormView $p_view, FormInterface $p_form, array $p_opt
$arrOption = array();
$arrPluginEnabled = isset( $p_options [ "pluginsEnabled" ] ) ? $p_options [ "pluginsEnabled" ] : array();
$arrPluginDisabled = isset( $p_options [ "pluginsDisabled" ] ) ? $p_options [ "pluginsDisabled" ] : array();
$profile = isset( $p_options [ "profile"] ) ? $p_options [ "profile" ] : null;
$arrEvent = isset( $p_options [ "events" ] ) ? $p_options [ "events" ] : array();
$profile = isset( $p_options [ "profile" ] ) ? $p_options [ "profile" ] : null;
// ------------------------- DECLARE ---------------------------//

if ($profile && $this->m_container->hasParameter(Configuration::$NODE_ROOT . '.profiles'))
{
if( $profile && $this->m_container->hasParameter( Configuration::$NODE_ROOT . '.profiles' ) )
{

$profiles = $this->m_container->getParameter(Configuration::$NODE_ROOT . '.profiles');
$profiles = $this->m_container->getParameter( Configuration::$NODE_ROOT . '.profiles' );

if (array_key_exists($profile, $profiles))
{
$profileConfig = $profiles[$profile];
$p_options = array_merge($p_options, $profileConfig);
} else {
throw new \Exception( 'Could not find profile "' . $profile . '", defined profiles: [' . join(',', $profiles ).']' );
}
if( array_key_exists( $profile, $profiles ) )
{
$profileConfig = $profiles[ $profile ];
$p_options = array_merge( $p_options, $profileConfig );
}
else
{
throw new \Exception( 'Could not find profile "' . $profile . '", defined profiles: [' .
join( ',', $profiles ) . ']' );
}

}
}

// Prepare options.
$this->m_optionManager->prepareOptions( $p_options );
Expand All @@ -138,7 +142,7 @@ public function buildView( FormView $p_view, FormInterface $p_form, array $p_opt
}
}
}

// Options.
$p_view->vars [ "arrOption" ] = $arrOption;

Expand All @@ -152,6 +156,7 @@ public function buildView( FormView $p_view, FormInterface $p_form, array $p_opt
$this->m_pluginProvider->obtainArrPluginJS( $arrPlugin );
$p_view->vars [ "arrPluginCSS" ] =
$this->m_pluginProvider->obtainArrPluginCSS( $arrPlugin );
$p_view->vars [ "events" ] = $arrEvent;
}

/**
Expand Down Expand Up @@ -179,7 +184,7 @@ public function configureOptions( OptionsResolver $p_resolver )
}


$arrDefined[] = 'profile';
$arrDefined[] = 'profile';
$p_resolver->setDefined( $arrDefined );
$p_resolver->setDefaults( $arrDefault );

Expand Down
7 changes: 0 additions & 7 deletions Resources/public/froala_editor_2.7.2/css/froala_style.min.css

This file was deleted.

7 changes: 0 additions & 7 deletions Resources/public/froala_editor_2.7.2/css/plugins/file.min.css

This file was deleted.

Loading

0 comments on commit c9b40ee

Please sign in to comment.