Skip to content

Commit

Permalink
Added the ability to specify a skin for all forms via the config file…
Browse files Browse the repository at this point in the history
… or for a single form.
  • Loading branch information
jayrose committed May 24, 2012
1 parent d585c50 commit 5bac201
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
8 changes: 7 additions & 1 deletion DependencyInjection/Configuration.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,13 @@ public function getConfigTreeBuilder()
->defaultNull()
->setInfo("The location of the script that handles file uploads in the Flash dialog window.")
->end()
->end()
->end()
->children()
->scalarNode('skin')
->defaultNull()
->setInfo("The location and name of the skin to be used.")
->end()
->end()
;

return $treeBuilder;
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/TrsteelCkeditorExtension.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter('trsteel_ckeditor.ckeditor.filebrowser_image_upload_url', $config['filebrowser_image_upload_url']);
$container->setParameter('trsteel_ckeditor.ckeditor.filebrowser_flash_browse_url', $config['filebrowser_flash_browse_url']);
$container->setParameter('trsteel_ckeditor.ckeditor.filebrowser_flash_upload_url', $config['filebrowser_flash_upload_url']);
$container->setParameter('trsteel_ckeditor.ckeditor.skin', $config['skin']);
}

private function getDefaultGroups()
Expand Down
5 changes: 4 additions & 1 deletion Form/Type/CkeditorType.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function buildForm(FormBuilder $builder, array $options)
->setAttribute('filebrowser_image_upload_url', $options['filebrowser_image_upload_url'])
->setAttribute('filebrowser_flash_browse_url', $options['filebrowser_flash_browse_url'])
->setAttribute('filebrowser_flash_upload_url', $options['filebrowser_flash_upload_url'])
->setAttribute('skin', $options['skin'])
;
}

Expand Down Expand Up @@ -107,6 +108,7 @@ public function buildView(FormView $view, FormInterface $form)
->set('filebrowser_image_upload_url', $form->getAttribute('filebrowser_image_upload_url'))
->set('filebrowser_flash_browse_url', $form->getAttribute('filebrowser_flash_browse_url'))
->set('filebrowser_flash_upload_url', $form->getAttribute('filebrowser_flash_upload_url'))
->set('skin', $form->getAttribute('skin'))
;
}

Expand All @@ -130,7 +132,8 @@ public function getDefaultOptions()
'filebrowser_image_browse_url' => $this->container->getParameter('trsteel_ckeditor.ckeditor.filebrowser_image_browse_url'),
'filebrowser_image_upload_url' => $this->container->getParameter('trsteel_ckeditor.ckeditor.filebrowser_image_upload_url'),
'filebrowser_flash_browse_url' => $this->container->getParameter('trsteel_ckeditor.ckeditor.filebrowser_flash_browse_url'),
'filebrowser_flash_upload_url' => $this->container->getParameter('trsteel_ckeditor.ckeditor.filebrowser_flash_upload_url'),
'filebrowser_flash_upload_url' => $this->container->getParameter('trsteel_ckeditor.ckeditor.filebrowser_flash_upload_url'),
'skin' => $this->container->getParameter('trsteel_ckeditor.ckeditor.skin'),
);
}

Expand Down
3 changes: 3 additions & 0 deletions Resources/views/Form/ckeditor_widget.html.twig
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
{% endif %}
{% if filebrowser_flash_upload_url is not null %}
filebrowserFlashUploadUrl: '{{ filebrowser_flash_upload_url }}',
{% endif %}
{% if skin is not null %}
skin: '{{ skin }}',
{% endif %}
toolbar: {{ toolbar | json_encode | raw }}
});
Expand Down
17 changes: 16 additions & 1 deletion Tests/Form/CkeditorTypeTest.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -421,5 +421,20 @@ public function testFilebrowserFlashUploadUrl()
$filebrowserFlashUploadUrl = $view->get('filebrowser_flash_upload_url');

$this->assertEquals($filebrowserFlashUploadUrl, '/myfilebrowser/uploads');
}
}

/**
* Checks skin property
*/
public function testSkin()
{
$form = $this->factory->create('ckeditor', null, array(
'skin' => 'myskin,/skins/myskin/',
));

$view = $form->createView();
$skin = $view->get('skin');

$this->assertEquals($skin, 'myskin,/skins/myskin/');
}
}

0 comments on commit 5bac201

Please sign in to comment.