@@ -13,44 +13,56 @@ The javascript library `create.js`_ provides a comprehensive web editing
13
13
interface for Content Management Systems. It is designed to provide a modern,
14
14
fully browser-based HTML5 environment for managing content. Create.js can be
15
15
adapted to work on almost any content management backend. Create.js makes your
16
- content editable based on RDFa annotations in the HTML content. Data is saved
17
- through backbone.js, CreateBundle providing the endpoint for the requests.
18
- The default editor used in the CreateBundle is CKEditor, but you can also use
19
- the lightweight `hallo.js `_ editor bundled with the create.js distribution.
16
+ content editable based on `RDF `_ information. The CreateBundle provides the
17
+ means to load create.js, provide the RDF information and handle the save
18
+ requests send by create.js.
20
19
21
- ` CreatePHP `_ is a PHP library that helps you putting the RDFa attributes into
22
- your HTML for ` create .js `_ and map back from the JSON-LD sent by backbone .js
23
- to your model classes .
20
+ For WYSIWYG text, the default editor is ` CKEditor `_, but you can also use
21
+ the lightweight ` hallo .js `_ editor bundled with the create .js distribution
22
+ or integrate your own editor .
24
23
25
24
Concepts
26
25
--------
27
26
28
- CreatePHP uses `RDFa `_ metadata about your model classes. This metadata is
29
- used to map between your model and the RDFa information. If you know Doctrine,
30
- you have seen the idea of metadata to know how class fields map to database
31
- columns.
27
+ To know the RDF model of your data, create.js parses the page DOM for `RDFa `_
28
+ attributes. Whenever it encounters an `about ` attribute, it knows that this
29
+ section is an editable content. The `typeof ` attribute tells what type the
30
+ content has. The `property ` attributes mean that the parts inside that tag are
31
+ editable. An article might look like this:
32
32
33
- The CreatePHP metadata is modelled by the ``Type `` class. CreatePHP provides
34
- metadata loaders that read XML, php arrays and one that just introspects
35
- objects and creates non-semantical metadata that will be enough for create.js
36
- to edit.
33
+ .. code-block :: html
37
34
38
- An ``RdfMapper `` is used to translate between your storage layer and CreatePHP.
39
- It is passed the model instance and the relevant metadata object.
35
+ <div about =" /cms/content/home" typeof =" schema:WebPage" xmlns:schema =" http://schema.org/" >
36
+ <h1 property =" schema:headline" >The Title</h1 >
37
+ <div property =" schema:text" >
38
+ <h2 >Welcome to the Symfony CMF Demo</h2 >
39
+ <p >If you see this page, it means that the...</p >
40
+ </div >
41
+ </div >
42
+
43
+ Each property has a type. You can configure what editor to use for which type.
44
+ CreateBundle comes with two editors: `plaintext ` with no formatting, and
45
+ WYSIWYG editing. You can also define your own editors.
46
+
47
+ Create.js uses backbone.js to save edited data to the server in the JSON-LD
48
+ format. You may have several objects editable on a single page. There will be
49
+ one request per editable content that was actually modified.
40
50
41
- With the metadata and the twig helper, the content is rendered with RDFa
42
- annotations. create.js is loaded and enables editing the content. Note that
43
- you may have several objects editable on a single page. Save operations happen
44
- through backbone.js with ajax calls containing JSON-LD data. There is one
45
- request per editable content that was actually modified. The CreateBundle REST
46
- controller handles those ajax calls and maps the JSON-LD data back onto your
47
- model classes and stores them in the database.
51
+ The `CreatePHP `_ library provides the RDF information for `create.js `_ by
52
+ creating `RDFa `_ attributes on your data in the templates. It also maps
53
+ the JSON-LD sent by backbone.js back to your domain objects.
48
54
49
- For image support, CKEditor can use elfinder to upload, browse and insert
50
- images into the content. See the
51
- :doc: `MediaBundle elfinder adapter documentation<../media/adapters/elfinder> `
52
- to enable this powerful image browser.
55
+ The `CreatePHP `_ library contains a metadata tool to define the mapping between
56
+ your domain objects and the RDF information. It provides a twig extension to
57
+ enrich your HTML pages with the RDFa attributes, similar to how you output forms.
58
+ CreatePHP also provides the means to store the JSON-LD data sent by backbone.js
59
+ back into your domain objects and save them. If you know Doctrine, this is a
60
+ similar job to how Doctrine reads data from database columns and loads them
61
+ into your domain objects.
53
62
63
+ The CreateBundle finally registers the twig extension in Symfony and provides
64
+ a REST controller for the backbone.js ajax calls. It also provides helpers to
65
+ bootstrap create.js in your templates.
54
66
55
67
.. index :: CreateBundle
56
68
@@ -68,7 +80,7 @@ which in turn needs the JmsSerializerBundle. Make sure you load all those
68
80
bundles in your kernel and properly configure Assetic as described below.
69
81
70
82
To upload and display images the :doc: `MediaBundle <../media/introduction >` is
71
- used.
83
+ used. CKEditor uses the :doc: ` elfinder adapter < ../media/adapters/elfinder >`.
72
84
73
85
.. _bundle-create-ckeditor :
74
86
@@ -343,10 +355,10 @@ you need to adjust your templates to output that information.
343
355
344
356
.. note ::
345
357
346
- If you use custom models that did not come with RDFa mapping files, see
358
+ If you use custom types that did not come with RDFa mapping files, see
347
359
the remainder of this page to learn how to define the mappings.
348
360
349
- To render your model named ``cmfMainContent `` with a handle you call ``rdf ``, use the
361
+ To render your data named ``cmfMainContent `` with a handle you call ``rdf ``, use the
350
362
``createphp `` twig tag as follows:
351
363
352
364
.. code-block :: html+jinja
@@ -360,9 +372,9 @@ To render your model named ``cmfMainContent`` with a handle you call ``rdf``, us
360
372
361
373
The ``noautotag `` tells CreatePHP to not automatically output a ``<div> `` with
362
374
namespace declarations and the ``about `` property containing the id of your
363
- model . When using ``noautotag ``, it is your responsibility to call
364
- ``createphp_attributes() `` inside a container tag that contains all fields of
365
- one model instance .
375
+ object . When using ``noautotag ``, it is your responsibility to call
376
+ ``createphp_attributes() `` inside a container tag that contains the fields of
377
+ the object .
366
378
367
379
You can also output a whole field complete with tag, attributes and content by
368
380
just calling ``{{ rdf.body|raw }} ``. (Without the ``raw `` filter, the HTML
@@ -384,15 +396,15 @@ your HTML structure if you want.
384
396
Metadata
385
397
--------
386
398
387
- CreatePHP needs metadata information for each class of your domain model . By
399
+ CreatePHP needs metadata information for each class of your domain objects . By
388
400
default, the create bundle uses the XML metadata driver and looks for metadata
389
401
in every bundles at ``<Bundle>/Resources/rdf-mappings ``. If you use a third
390
402
party bundle that does not come with RDFa mapping, you can simply include a
391
403
mapping file for it in any of your bundles, or specify a directory containing
392
404
mapping files with the ``rdf_config_dirs `` option.
393
405
394
- The mapping file name needs to be the fully qualified class name of your model
395
- class, having the backslash (``\\ ``) replaced by a dot (``. ``), i.e.
406
+ The mapping file name needs to be the fully qualified class name, having the
407
+ backslash (``\\ ``) replaced by a dot (``. ``), i.e.
396
408
``Symfony.Cmf.Bundle.ContentBundle.Doctrine.Phpcr.StaticContent.xml ``.
397
409
398
410
A basic mapping look as follows:
@@ -457,11 +469,11 @@ reads like this:
457
469
All of these issues will hopefully be fixed in later versions if people
458
470
step up and contribute pull requests.
459
471
460
- Mapping Requests to Domain Model
461
- --------------------------------
472
+ Mapping Requests to Domain Objects
473
+ ----------------------------------
462
474
463
475
One last piece is the mapping between CreatePHP data and the application
464
- domain model . Data needs to be stored back into the database.
476
+ domain objects . Data needs to be stored back into the database.
465
477
466
478
In version 1.0, the CreateBundle only provides a service to map to Doctrine
467
479
PHPCR-ODM. If you do not enable the phpcr persistence layer, you need to
@@ -479,8 +491,10 @@ into the CreatePHP and CreateBundle and do a pull request to enable this feature
479
491
480
492
.. _`create.js` : http://createjs.org
481
493
.. _`hallo.js` : http://hallojs.org
494
+ .. _`CKEditor` : http://ckeditor.com/
482
495
.. _`CreatePHP` : https://github.com/flack/createphp
483
496
.. _`with composer` : http://getcomposer.org
484
497
.. _`symfony-cmf/create-bundle` : https://packagist.org/packages/symfony-cmf/create-bundle
498
+ .. _`RDF` : http://en.wikipedia.org/wiki/Resource_Description_Framework
485
499
.. _`RDFa` : http://en.wikipedia.org/wiki/RDFa
486
500
.. _`Symfony2 security chapter` : http://symfony.com/doc/current/book/security.html
0 commit comments