| 1 |
= sfPropelSlotBehaviorPlugin plugin = |
|---|
| 2 |
|
|---|
| 3 |
== Overview == |
|---|
| 4 |
|
|---|
| 5 |
This plugin implements a behavior that permits to manage template and slots for different models. |
|---|
| 6 |
|
|---|
| 7 |
Slots are additional data linked to an object depends of his template. |
|---|
| 8 |
|
|---|
| 9 |
The plugin include an interface to edit, save & retrieve the value from slots. |
|---|
| 10 |
It also include tools to load templates & slots configuration. |
|---|
| 11 |
|
|---|
| 12 |
Slots can be define for different models (like page, product, mailing, ...) |
|---|
| 13 |
Slots can be multilingual. |
|---|
| 14 |
|
|---|
| 15 |
== Installation == |
|---|
| 16 |
|
|---|
| 17 |
* Install the plugin |
|---|
| 18 |
|
|---|
| 19 |
{{{ |
|---|
| 20 |
symfony plugin-install http://plugins.symfony-project.com/sfPropelSlotBehaviorPlugin |
|---|
| 21 |
}}} |
|---|
| 22 |
|
|---|
| 23 |
* Add new "template" fields to model(s) of your schema.yml |
|---|
| 24 |
|
|---|
| 25 |
* Enable Propel behavior support in `propel.ini`: |
|---|
| 26 |
|
|---|
| 27 |
{{{ |
|---|
| 28 |
propel.builder.AddBehaviors = true |
|---|
| 29 |
}}} |
|---|
| 30 |
|
|---|
| 31 |
If you have to enable the behavior support, rebuild your model: |
|---|
| 32 |
|
|---|
| 33 |
{{{ |
|---|
| 34 |
symfony propel-build-model |
|---|
| 35 |
}}} |
|---|
| 36 |
|
|---|
| 37 |
* Enable the behavior for one of your Propel model: |
|---|
| 38 |
|
|---|
| 39 |
{{{ |
|---|
| 40 |
#!php |
|---|
| 41 |
<?php |
|---|
| 42 |
// lib/model/Page.php |
|---|
| 43 |
class Page |
|---|
| 44 |
{ |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
$columns_map = array('pk' => PagePeer::ID, |
|---|
| 48 |
'template' => PagePeer::TEMPLATE); |
|---|
| 49 |
|
|---|
| 50 |
sfPropelBehavior::add('Page', array('sfPropelSlotBehavior' => array('columns' => $columns_map))); |
|---|
| 51 |
}}} |
|---|
| 52 |
|
|---|
| 53 |
The ''column map'' is used by the behavior to know which columns hold information it needs : |
|---|
| 54 |
|
|---|
| 55 |
* pk : Model column holding primary key (default : id) |
|---|
| 56 |
* template : Model column holding template name (default : template) |
|---|
| 57 |
|
|---|
| 58 |
== Usage == |
|---|
| 59 |
|
|---|
| 60 |
=== Configuration === |
|---|
| 61 |
|
|---|
| 62 |
Configuration permits to define templates and slots for different models. |
|---|
| 63 |
|
|---|
| 64 |
First, each models can be listed in "sfPropelSlot" section, it is not compulsory but it will simplify plugin use. |
|---|
| 65 |
When using this plugin with sfDynamicCMS Plugin, you don't need to configure plugin. |
|---|
| 66 |
|
|---|
| 67 |
Each model have its own templates and slots configuration, then you must specify the section where each model slots & templates are setup. |
|---|
| 68 |
Optionnaly you can define a default model. |
|---|
| 69 |
|
|---|
| 70 |
For each model configuration: |
|---|
| 71 |
* You can define default slot options by slot type |
|---|
| 72 |
* you have to list available templates for the model, each template must have a title and optionally slots |
|---|
| 73 |
* you must define all slots used by templates, each slots must have a title and a type and optionally options and parameters |
|---|
| 74 |
|
|---|
| 75 |
example: |
|---|
| 76 |
|
|---|
| 77 |
{{{ |
|---|
| 78 |
sfPropelSlot: |
|---|
| 79 |
default_model: Page |
|---|
| 80 |
models: |
|---|
| 81 |
Page: myCMS |
|---|
| 82 |
|
|---|
| 83 |
myCMS: |
|---|
| 84 |
default_slot_options: |
|---|
| 85 |
RichText: |
|---|
| 86 |
params: tinymce_options=height:250,width:600,language:"en",theme:"advanced",theme_advanced_disable:"flash,image,paste",plugins:"contextmenu,paste",theme_advanced_buttons1_add:"hr",theme_advanced_buttons3:"cut,copy,pastetext,pasteword,separator,formatselect,fontsizeselect,forecolor" |
|---|
| 87 |
File: |
|---|
| 88 |
params: include_remove=true |
|---|
| 89 |
templates: |
|---|
| 90 |
intro_template: |
|---|
| 91 |
title: "Intro page" |
|---|
| 92 |
slots: [] |
|---|
| 93 |
home_template: |
|---|
| 94 |
title: "Homepage" |
|---|
| 95 |
slots: [text] |
|---|
| 96 |
page1_template: |
|---|
| 97 |
title: "Page model 1" |
|---|
| 98 |
slots: [text, image, doc_file] |
|---|
| 99 |
page2_template: |
|---|
| 100 |
title: "Page model 2" |
|---|
| 101 |
slots: [column1, date, products_ads] |
|---|
| 102 |
contact_template: |
|---|
| 103 |
title: "Contact" |
|---|
| 104 |
slots: [text_contact, email] |
|---|
| 105 |
slots: |
|---|
| 106 |
text: |
|---|
| 107 |
title: "Text" |
|---|
| 108 |
type: Text |
|---|
| 109 |
i18n: true |
|---|
| 110 |
params : size=100x10 |
|---|
| 111 |
column1: |
|---|
| 112 |
title: "Text - 1st column" |
|---|
| 113 |
type: Text |
|---|
| 114 |
help: Don't use "CTRL+V" keystroke but "paste" icons. |
|---|
| 115 |
date: |
|---|
| 116 |
title: "Publication date" |
|---|
| 117 |
type: Date |
|---|
| 118 |
products_ads: |
|---|
| 119 |
title: "Products" |
|---|
| 120 |
type: Double_list |
|---|
| 121 |
params: related_class=Products retrieve_method=doSelectPublished |
|---|
| 122 |
doc_file: |
|---|
| 123 |
title: "Documentation" |
|---|
| 124 |
type: File |
|---|
| 125 |
upload_dir: doc_pdf |
|---|
| 126 |
help: "Download a pdf file" |
|---|
| 127 |
email: |
|---|
| 128 |
title: "E-mail address" |
|---|
| 129 |
type: Input |
|---|
| 130 |
params: size=40 |
|---|
| 131 |
}}} |
|---|
| 132 |
|
|---|
| 133 |
=== Extends admin generator === |
|---|
| 134 |
|
|---|
| 135 |
See example located in data directory of the plugin. |
|---|
| 136 |
|
|---|
| 137 |
== Slot types options and params == |
|---|
| 138 |
|
|---|
| 139 |
=== Input : basic input field === |
|---|
| 140 |
|
|---|
| 141 |
Options and params are the same than object_input_tag |
|---|
| 142 |
|
|---|
| 143 |
=== Text : textarea field === |
|---|
| 144 |
|
|---|
| 145 |
Options and params are the same than object_textarea_tag |
|---|
| 146 |
|
|---|
| 147 |
=== RichText : rich textarea field === |
|---|
| 148 |
|
|---|
| 149 |
Options and parameters are the same than object_textarea_tag |
|---|
| 150 |
"rich" option is true by default and there is some default tinymce_options |
|---|
| 151 |
Parameters : |
|---|
| 152 |
* rich (default : true) |
|---|
| 153 |
* tinymce_options (default : ) |
|---|
| 154 |
|
|---|
| 155 |
=== Select : selectbox === |
|---|
| 156 |
|
|---|
| 157 |
2 way to use it : |
|---|
| 158 |
* With a related class like object_select_tag, you have to define "related_class" option and maybe "peer_method" and "text_method" |
|---|
| 159 |
* With a related class & method to retrieve available options : you have to define "related_class" AND "options_method" options |
|---|
| 160 |
|
|---|
| 161 |
=== Checkbox : checkbox === |
|---|
| 162 |
|
|---|
| 163 |
Options and params are the same than object_checkbox_tag |
|---|
| 164 |
Options : |
|---|
| 165 |
* default_value (optionnal) |
|---|
| 166 |
|
|---|
| 167 |
=== File : file upload === |
|---|
| 168 |
|
|---|
| 169 |
Options and params are the same than object_admin_input_file_tag : |
|---|
| 170 |
{{{ |
|---|
| 171 |
params: include_link=my_directory include_remove=true |
|---|
| 172 |
upload_dir: my_directory |
|---|
| 173 |
}}} |
|---|
| 174 |
|
|---|
| 175 |
include_link is equal to upload_dir by default |
|---|
| 176 |
|
|---|
| 177 |
=== Date : date field === |
|---|
| 178 |
|
|---|
| 179 |
Options and params are the same than object_input_date_tag |
|---|
| 180 |
|
|---|
| 181 |
=== DoubleList === |
|---|
| 182 |
|
|---|
| 183 |
Options: |
|---|
| 184 |
* related_class (required) |
|---|
| 185 |
* retrieve_method (default : doSelect) |
|---|
| 186 |
* size (default : doSelect) |
|---|
| 187 |
* unassociated_label (default : "Unassociated") |
|---|
| 188 |
* associated_label (default : "Associated") |
|---|
| 189 |
|
|---|
| 190 |
== Public API == |
|---|
| 191 |
|
|---|
| 192 |
=== Object behavior methods === |
|---|
| 193 |
|
|---|
| 194 |
The behavior implement the following methods: |
|---|
| 195 |
|
|---|
| 196 |
* getSlots() : return all slots object used by object |
|---|
| 197 |
* initSlots($slot_name, $culture, $values, $culture) : initialize object's slot (retrieve or create them) |
|---|
| 198 |
* initSlot($slot_name, $culture, $value, $culture) : initialize a slot (retrieve or create it) |
|---|
| 199 |
* getSlot($slot_name, $culture) : return a slot object by name from the object |
|---|
| 200 |
* getSlotValue($slot_name, $culture) : return a slot value by name from the object |
|---|
| 201 |
* setSlot(slot_name, $type, $name, $value, $culture) : add or set a slot |
|---|
| 202 |
* removeSlot(slot_name) : remove a slot by name from the object |
|---|
| 203 |
* clearSlots() : remove all slots of the object |
|---|
| 204 |
* hasSlots() |
|---|
| 205 |
* hasSlot($slot_name) |
|---|
| 206 |
* getTemplate : return object's template |
|---|
| 207 |
* getTemplateOptions : return options of template used by object |
|---|
| 208 |
* getTemplateSlots : return slots and their options for each slots of the template used by object |
|---|
| 209 |
* setTemplate($template_name) : set the template of the object |
|---|
| 210 |
* updateSlotsFromRequest($request, $cultures) : update object's slots from request |
|---|
| 211 |
|
|---|
| 212 |
=== sfPropelSlot Tools === |
|---|
| 213 |
|
|---|
| 214 |
* getTemplates() : return templates (name => title) of a model |
|---|
| 215 |
* getTemplateOptions($template_name) : return options of a template |
|---|
| 216 |
* getTemplateSlots(template_name) : return slots and their options of a template |
|---|
| 217 |
* getSlots() : return all slots defined for a model |
|---|
| 218 |
* getSlotOptions($slot_name) : return options of a slot |
|---|
| 219 |
|
|---|
| 220 |
== Development == |
|---|
| 221 |
|
|---|
| 222 |
This plugin will probably used for next versions of sfDynamicCMS Plugin. |
|---|
| 223 |
If you want to help and improve it, please contact Sylvain Papet (my firstname @ com-ocean.com). |
|---|
| 224 |
|
|---|
| 225 |
I encourage every one to contribute to this plugin or even lead it. |
|---|
| 226 |
|
|---|
| 227 |
== Todo == |
|---|
| 228 |
|
|---|
| 229 |
* doSelectWithSlots method (which use a single query to retrieve objects and populate slots) |
|---|
| 230 |
* improve existing slot interface |
|---|
| 231 |
* add new slot widgets |
|---|
| 232 |
|
|---|
| 233 |
== Changelog == |
|---|
| 234 |
|
|---|
| 235 |
=== 2008-11-18 | 0.1.12 Alpha === |
|---|
| 236 |
|
|---|
| 237 |
* sylvio: bugfix (i18n_slots) |
|---|
| 238 |
* sylvio: plugin tested with Symfony 1.1 & Symfony 1.2, it might be compatible |
|---|
| 239 |
|
|---|
| 240 |
=== 2008-11-12 | 0.1.11 Alpha === |
|---|
| 241 |
|
|---|
| 242 |
* sylvio: bugfix (sfSlotFile) |
|---|
| 243 |
|
|---|
| 244 |
=== 2008-10-29 | 0.1.10 Alpha === |
|---|
| 245 |
|
|---|
| 246 |
* sylvio: minor refactor & bug fixes (ticket #3822) |
|---|
| 247 |
|
|---|
| 248 |
=== 2008-10-28 | 0.1.9 Alpha === |
|---|
| 249 |
|
|---|
| 250 |
* sylvio: refactor & bug fixes (regression) |
|---|
| 251 |
|
|---|
| 252 |
=== 2008-10-22 | 0.1.8 Alpha === |
|---|
| 253 |
|
|---|
| 254 |
* sylvio: refactor & bug fixes |
|---|
| 255 |
|
|---|
| 256 |
=== 2008-10-17 | 0.1.7 Alpha === |
|---|
| 257 |
|
|---|
| 258 |
* sylvio: some improvement & new features (sfSelect) |
|---|
| 259 |
|
|---|
| 260 |
=== 2008-06-30 | 0.1.6 Alpha === |
|---|
| 261 |
|
|---|
| 262 |
* sylvio: fix some bugs (sfSlotDate and others) |
|---|
| 263 |
|
|---|
| 264 |
=== 2008-06-13 | 0.1.5 Alpha === |
|---|
| 265 |
|
|---|
| 266 |
* sylvio: fix some bugs |
|---|
| 267 |
|
|---|
| 268 |
=== 2008-06-06 | 0.1.4 Alpha === |
|---|
| 269 |
|
|---|
| 270 |
* sylvio: fix some bugs |
|---|
| 271 |
* sylvio: sfPropelSlot configuration section is optionnal (you can specify configuration section in your code) |
|---|
| 272 |
* sylvio: make plugin compatible with new sfDynamicCMS version to come (0.3.0) |
|---|
| 273 |
|
|---|
| 274 |
=== 2008-05-28 | 0.1.3 Alpha === |
|---|
| 275 |
|
|---|
| 276 |
* sylvio: add updateSlotsFromRequest method |
|---|
| 277 |
* sylvio: update and improve admin generator usage example |
|---|
| 278 |
|
|---|
| 279 |
=== 2008-05-28 | 0.1.2 Alpha === |
|---|
| 280 |
|
|---|
| 281 |
* sylvio: refactor a lot of things |
|---|
| 282 |
* sylvio: improve configuration |
|---|
| 283 |
* sylvio: fix major bugs |
|---|
| 284 |
|
|---|
| 285 |
=== 2008-05-27 | 0.1.1 Alpha === |
|---|
| 286 |
|
|---|
| 287 |
* sylvio: initial release |
|---|