Skip to content

Commit

Permalink
Merge pull request #46 from kosssi/feature/ckeditor
Browse files Browse the repository at this point in the history
integrate ckeditor
  • Loading branch information
dbu committed Apr 15, 2013
2 parents a410879 + 0e1858f commit 8919fb4
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.DS_Store
/vendor/
Resources/public/vendor/hallo
vendor/
Resources/public/vendor/hallo
Resources/public/vendor/ckeditor
64 changes: 64 additions & 0 deletions Composer/ScriptHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,68 @@ public static function initSubmodules($event)
die("Running git submodule --init --recursive failed with $status\n");
}
}

public static function downloadCkeditor($event)
{
$extra = $event->getComposer()->getPackage()->getExtra();

// directory where the repository should be clone into
if (isset($extra['ckeditor-directory'])) {
$directory = getcwd() . '/' . $extra['ckeditor-directory'];
} else {
$directory = __DIR__ . '/../Resources/public/vendor/ckeditor';
}

// git repository
if (isset($extra['ckeditor-repository'])) {
$repository = $extra['ckeditor-repository'];
} else {
$repository = 'https://github.com/ckeditor/ckeditor-releases.git';
}

// commit id
if (isset($extra['ckeditor-commit'])) {
$commit = $extra['ckeditor-commit'];
} else {
$commit = 'bba29309f93a1ace1e2e3a3bd086025975abbad0';
}

ScriptHandler::gitSynchronize($directory, $repository, $commit);
}

/**
* @param string $directory The directory where the repository should be clone into
* @param string $repository The git repository
* @param string $commitId The commit id
*/
public static function gitSynchronize($directory, $repository, $commitId)
{
$currentDirectory = getcwd();
$parentDirectory = dirname($directory);
$projectDirectory = basename($directory);

$status = null;
$output = array();
chdir($parentDirectory);

if (is_dir($projectDirectory)) {
chdir($projectDirectory);
exec("git remote update", $output, $status);
if ($status) {
die("Running git pull $repository failed with $status\n");
}
} else {
exec("git clone $repository $projectDirectory", $output, $status);
if ($status) {
die("Running git clone $repository failed with $status\n");
}
}

exec("git checkout $commitId", $output, $status);
if ($status) {
die("Running git clone $repository failed with $status\n");
}

chdir($currentDirectory);
}
}
12 changes: 10 additions & 2 deletions Controller/JsloaderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class JsloaderController
*/
private $plainTextTypes;

/**
* @var string
*/
private $editorBasePath;


/**
* Create the Controller
Expand All @@ -62,13 +67,15 @@ public function __construct(
$fixedToolbar = true,
$plainTextTypes = array(),
$requiredRole = "IS_AUTHENTICATED_ANONYMOUSLY",
SecurityContextInterface $securityContext = null
SecurityContextInterface $securityContext = null,
$editorBasePath = null
) {
$this->viewHandler = $viewHandler;
$this->stanbolUrl = $stanbolUrl;
$this->imageClass = $imageClass;
$this->fixedToolbar = $fixedToolbar;
$this->plainTextTypes = $plainTextTypes;
$this->editorBasePath = $editorBasePath;

$this->requiredRole = $requiredRole;
$this->securityContext = $securityContext;
Expand Down Expand Up @@ -105,7 +112,8 @@ public function includeJSFilesAction($editor = 'hallo')
'cmfCreateStanbolUrl' => $this->stanbolUrl,
'cmfCreateImageUploadEnabled' => (boolean) $this->imageClass,
'cmfCreateHalloFixedToolbar' => (boolean) $this->fixedToolbar,
'cmfCreateHalloPlainTextTypes' => json_encode($this->plainTextTypes)
'cmfCreatePlainTextTypes' => json_encode($this->plainTextTypes),
'cmfCreateEditorBasePath' => $this->editorBasePath,
)
);

Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getConfigTreeBuilder()
->scalarNode('phpcr_odm')->defaultFalse()->end()
->scalarNode('stanbol_url')->defaultValue('http://dev.iks-project.eu:8081')->end()
->scalarNode('fixed_toolbar')->defaultTrue()->end()
->scalarNode('editor_base_path')->end()
->arrayNode('plain_text_types')
->useAttributeAsKey('name')
->prototype('scalar')->end()
Expand Down
2 changes: 2 additions & 0 deletions DependencyInjection/SymfonyCmfCreateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public function load(array $configs, ContainerBuilder $container)

$container->setParameter($this->getAlias().'.fixed_toolbar', $config['fixed_toolbar']);

$container->setParameter($this->getAlias().'.editor_base_path', $config['editor_base_path']);

if (empty($config['plain_text_types'])) {
$config['plain_text_types'][] = 'dcterms:title';
}
Expand Down
1 change: 1 addition & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<argument>%symfony_cmf_create.plain_text_types%</argument>
<argument>%symfony_cmf_create.role%</argument>
<argument type="service" id="security.context" on-invalid="ignore"/>
<argument>%symfony_cmf_create.editor_base_path%</argument>

This comment has been minimized.

Copy link
@gezpage

gezpage Apr 15, 2013

This change breaks system as value is not present - can you provide default value and / or offer default config setting in docs?

This comment has been minimized.

Copy link
@dbu

dbu Apr 15, 2013

Author Member

ups. i made that optional in 9ae0c7f for now. @kossi ideally you would check in the DI extension if the value is non-null if we are in the ckeditor mode as then it would be invalid to not set that path.

</service>

<service id="symfony_cmf_create.rest.controller" class="%symfony_cmf_create.rest.controller.class%">
Expand Down
1 change: 0 additions & 1 deletion Resources/public/.gitignore

This file was deleted.

26 changes: 26 additions & 0 deletions Resources/public/js/init-create-ckeditor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
jQuery(document).ready(function() {
jQuery('body').midgardCreate({
url: function() {
if (this.id) {
if (this.id.charAt(0) == "<") {
return cmfCreatePutDocument + this.id.substring(1, this.id.length - 1);
}
return cmfCreatePutDocument + "/" + this.id;
}
return cmfCreatePutDocument;
},
stanbolUrl: cmfCreateStanbolUrl,
tags: true,
editorOptions: {
ckeditor: {
widget: 'ckeditorWidget'
}
},
collectionWidgets: {
'default': null,
'feature': 'midgardCollectionAdd'
}
});

window.CKEDITOR.basePath = cmfCreateEditorBasePath;
});
2 changes: 1 addition & 1 deletion Resources/public/js/init-create-hallo.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jQuery(document).ready(function() {
parentElement: cmfCreateHalloParentElement
});

jQuery(cmfCreateHalloPlainTextTypes).each(function(index, value) {
jQuery(cmfCreatePlainTextTypes).each(function(index, value) {
jQuery('body').midgardCreate('setEditorForProperty', value, 'title');
});
jQuery('body').midgardCreate('setEditorForProperty', 'default', 'default');
Expand Down
9 changes: 9 additions & 0 deletions Resources/views/includejsfiles-ckeditor.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% include "SymfonyCmfCreateBundle::includejsfiles-create.html.twig" %}

<script>window.CKEDITOR_BASEPATH = cmfCreateEditorBasePath;</script>
{% javascripts output="/js/ckeditor.js"
'@SymfonyCmfCreateBundle/Resources/public/js/init-create-ckeditor.js'
'@SymfonyCmfCreateBundle/Resources/public/vendor/ckeditor/ckeditor.js'
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
2 changes: 1 addition & 1 deletion Resources/views/includejsfiles-create.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
var cmfCreateHalloFixedToolbar = 'halloToolbarContextual';
var cmfCreateHalloParentElement = 'body';
{% endif %}
var cmfCreateHalloPlainTextTypes = {{ cmfCreateHalloPlainTextTypes|raw }};
var cmfCreatePlainTextTypes = {{ cmfCreatePlainTextTypes|raw }};
</script>

{% javascripts output="js/create.js"
Expand Down

0 comments on commit 8919fb4

Please sign in to comment.