[Flow] Flow and RTE (maybe Aloha)?
Alexander Wende
a_wende at web.de
Wed Aug 6 10:04:35 CEST 2014
Quote: Jan Greth (jafix) wrote on Wed, 06 August 2014 09:33
----------------------------------------------------
> Also looks interesting - can you provide an example how you integrated it?
----------------------------------------------------
I used the jsonSave Method. Here is a short description how to update a "page" object.
VIEW
1. Just include raptor.css and .js
2. Too init the raptor editor I used the snipped from the docs.
---------------------------------
<script type="text/javascript">
jQuery(function($){
$('.editable').raptor({
autoEnable: true,
plugins: {
// The save UI plugin/button
save: {
// Specifies the UI to call the saveJson plugin to do the actual saving
plugin: 'saveJson'
},
saveJson: {
// The URI to send the content to
url: $('.hiddenEditForm').attr('action') + "?" + $('.hiddenEditForm').serialize(),
// The POST parameter name to use (e.g. for $_POST['raptor-content'] in PHP)
postName: 'jsonPayload',
// The ID of the content (or a function the returns the ID)
id: function() {
return this.raptor.getElement().data('id');
}
}
}
});
});
</script>
---------------------------------
3. For each inputfield, which should use the editor, add an element with class "editable" and data-id attribute. The data-Id is the identifier we need later in our controller
4. Last we need a hidden Form element. This is needed for raptor to determinate the correct url to send the json data.
---------------------------------
<f:form action="updatePage" controller="JsonServiceApi" package="COMPANY.Package" style="display:none" class="hiddenEditForm" object="{page}" objectName="page">
</f:form>
---------------------------------
CONTROLLER "JsonServiceApiController"
/**
* @param \COMPANY\Package\Domain\Model\Page $page
* @param string $jsonPayload the payload of the json request
*/
public function updateAction(\COMPANY\Package\Domain\Model\Page $page,$jsonPayload){
$payload = json_decode($jsonPayload);
try{
foreach ($payload as $propertyName => $propertyValue){
switch ($propertyName){
case 'content':
$page->setContent($propertyValue);
break;
case 'title':
$page->setTitle($propertyValue);
break;
default:
throw new \TYPO3\Flow\Exception('not allowed to modify the requested property using JsonService');
}
}
$this->pageRepository->update($page);
}catch(\TYPO3\Flow\Exception $e){
$this->getControllerContext()->getResponse()->setStatus(500);
return json_encode(false);
}
return json_encode(true);
}
Attention: This is just a 'proof of concept'. You will have to validate the input in production context!!
More information about the Flow
mailing list