/** * Handles the form submit for a given slot. This could come from two sources: * 1) Inline, frontend editing. (ajax request) * 2) Admin, non-inline editing (non-ajax request) */ public function executeSlot_save(sfWebRequest $request) { $this->contentSlot = $this->setupContentSlot($request); $this->form = $this->contentSlot->getEditForm(); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $this->form->save(); $this->getUser()->setFlash('saved', __('Slot saved'), false); // if we close editor on save, just return the flash js and the editor close js if ($request->isXmlHttpRequest() && sfSympalConfig::get('inline_editing', 'close_editor_on_save', false)) { $this->getContext()->getConfiguration()->loadHelpers('SympalContentSlotEditor'); $this->renderText(trigger_flash_from_user($this->getUser())); $this->renderText(sprintf(' <script type="text/javascript"> $(document).ready(function() { $("#sympal_slot_wrapper_%s").sympalSlot("closeEditor"); }); </script> ', $this->contentSlot->id)); return sfView::NONE; } } else { $this->getUser()->setFlash('error', __('There was an error saving your slot'), false); } // we need to route the response appropriately based on ajax/non-ajax if ($request->isXmlHttpRequest()) { // ajax, just re-show the form $this->renderPartial('sympal_edit_slot/slot_editor_form'); } else { // handle non-ajax, which come from sympal_content/edit_slots // this is a bit of a hack, we redirect even on errors, which is technically a fail $this->redirect('@sympal_content_edit_slots?id=' . $this->contentSlot->getContentRenderedFor()->id); } return sfView::NONE; }
<?php use_helper('SympalContentSlotEditor'); echo trigger_flash_from_user($sf_user); if ($contentSlot->getIsColumn()) { ?> <?php if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot') && !isset($form[$contentSlot->getName()])) { ?> <?php echo $form[$sf_user->getEditCulture()][$contentSlot->getName()]; ?> <?php } else { ?> <?php echo $form[$contentSlot->getName()]; ?> <?php } } else { ?> <?php echo $form['galleries_list']; ?> <a class="gallery_toggle_detail" href="#" onclick="return false;">Gallery parameters</a> <div class="gallery_parameters" style="display: none"> <?php echo $form['gallery_parameters']; ?>