Ejemplo n.º 1
0
 public function executeEdit(sfRequest $request)
 {
     $this->logMessage("====== in aInsetAreaSlotActions::executeEdit", "info");
     $this->editSetup();
     // Work around FCK's incompatibility with AJAX and bracketed field names
     // (it insists on making the ID bracketed too which won't work for AJAX)
     // Don't forget, there's a CSRF field out there too. We need to grep through
     // the submitted fields and get all of the relevant ones, reinventing what
     // PHP's bracket syntax would do for us if FCK were compatible with it
     $values = $request->getParameterHolder()->getAll();
     $value = array();
     foreach ($values as $k => $v) {
         if (preg_match('/^slot-form-' . $this->id . '-(.*)$/', $k, $matches)) {
             $value[$matches[1]] = $v;
         }
     }
     $this->form = new aInsetAreaSlotForm($this->id, $this->options);
     $this->form->bind($value);
     if ($this->form->isValid()) {
         $value = $this->form->getValue('value');
         $this->slot->value = $value;
         $result = $this->editSave();
         return $result;
     } else {
         // Makes $this->form available to the next iteration of the
         // edit view so that validation errors can be seen
         return $this->editRetry();
     }
 }
Ejemplo n.º 2
0
 public static function decomposeURL(sfContext $context, sfRequest $request)
 {
     $module = $context->getModuleName();
     $action = $context->getActionName();
     $parameters = $request->getParameterHolder()->getAll();
     return array("module" => $module, "action" => $action, "parameters" => $parameters);
 }
Ejemplo n.º 3
0
 /**
  * DOCUMENT ME
  * @param sfRequest $request
  * @return mixed
  */
 public function executeEdit(sfRequest $request)
 {
     $this->editSetup();
     // Work around FCK's incompatibility with AJAX and bracketed field names
     // (it insists on making the ID bracketed too which won't work for AJAX)
     // Don't forget, there's a CSRF field out there too. We need to grep through
     // the submitted fields and get all of the relevant ones, reinventing what
     // PHP's bracket syntax would do for us if FCK were compatible with it
     $values = $request->getParameterHolder()->getAll();
     $value = array();
     foreach ($values as $k => $v) {
         if (preg_match('/^slot-form-' . $this->id . '-(.*)$/', $k, $matches)) {
             $value[$matches[1]] = $v;
         }
     }
     // HTML is carefully filtered to allow only elements, attributes and styles that
     // make sense in the context of a rich text slot, and you can adjust that.
     // See aHtml::simplify(). You can do slot-specific overrides by setting the
     // allowed-tags, allowed-attributes and allowed-styles options
     $this->form = new aRichTextForm($this->id, $this->options);
     $this->form->bind($value);
     if ($this->form->isValid()) {
         // The form validator took care of validating well-formed HTML
         // and removing elements, attributes and styles we don't permit
         $this->slot->value = $this->form->getValue('value');
         return $this->editSave();
     } else {
         // Makes $this->form available to the next iteration of the
         // edit view so that validation errors can be seen (although there
         // aren't any in this case)
         return $this->editRetry();
     }
 }
Ejemplo n.º 4
0
 /**
  * Сохранить настройки напоминаний
  */
 public function executeSaveReminders(sfRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $user = $this->getUser()->getUserRecord();
     $request_params = $request->getParameterHolder()->getAll();
     // отображение имён параметров, пришедших в запросе, на имена полей в БД
     $fields_map = array('timezone' => 'time_zone', 'smsPhone' => 'sms_phone', 'mailEnabled' => 'reminder_mail_default_enabled', 'smsEnabled' => 'reminder_sms_default_enabled', 'mailDaysBefore' => 'reminder_mail_days', 'mailHour' => 'reminder_mail_hour', 'mailMinutes' => 'reminder_mail_minutes', 'smsDaysBefore' => 'reminder_sms_days', 'smsHour' => 'reminder_sms_hour', 'smsMinutes' => 'reminder_sms_minutes');
     $reminders_array = array();
     // сюда складываем настройки оповещений для json-ответа
     foreach ($fields_map as $parameter_name => $field_name) {
         if (isset($request_params[$parameter_name])) {
             /**
              * в запросе значения checkbox'ов приходят строками ('true', 'false'),
              * надо менять на integer, чтобы корректно писалось в базу
              */
             if ($request_params[$parameter_name] == 'true') {
                 $request_params[$parameter_name] = 1;
             } elseif ($request_params[$parameter_name] == 'false') {
                 $request_params[$parameter_name] = 0;
             }
             if ('timezone' == $parameter_name) {
                 if (!isset(myDateTimezoneHelper::$zones[$request_params[$parameter_name]])) {
                     continue;
                 }
             }
             $user->set($field_name, $request_params[$parameter_name]);
             $reminders_array[$parameter_name] = $request_params[$parameter_name];
         }
     }
     $user->save();
     $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
     $ret = array('result' => array('text' => 'Настройки напоминаний сохранены'), 'reminders' => $reminders_array);
     return $this->renderText(json_encode($ret));
 }
Ejemplo n.º 5
0
 /**
  * Returns request parameter holders as an array.
  *
  * @param sfRequest $request A sfRequest instance
  *
  * @return array The request parameter holders
  */
 public static function requestAsArray(sfRequest $request = null)
 {
     if (!$request) {
         return array();
     }
     return array('options' => $request->getOptions(), 'parameterHolder' => self::flattenParameterHolder($request->getParameterHolder(), true), 'attributeHolder' => self::flattenParameterHolder($request->getAttributeHolder(), true));
 }
Ejemplo n.º 6
0
 /**
  * Executes sortProfileOption action
  *
  * @param sfRequest $request A request object
  */
 public function executeSortProfileOption($request)
 {
     if ($request->isXmlHttpRequest()) {
         $request->checkCSRFProtection();
         $parameters = $request->getParameterHolder();
         $keys = $parameters->getNames();
         foreach ($keys as $key) {
             if (preg_match('/^profile_options_\\d+$/', $key, $match)) {
                 $order = $parameters->get($match[0]);
                 for ($i = 0; $i < count($order); $i++) {
                     $profileOption = Doctrine::getTable('ProfileOption')->find($order[$i]);
                     if ($profileOption) {
                         $profileOption->setSortOrder($i * 10);
                         $profileOption->save();
                     }
                 }
                 break;
             }
         }
     }
     return sfView::NONE;
 }
Ejemplo n.º 7
0
 public function executeUploadImages(sfRequest $request)
 {
     // Belongs at the beginning, not the end
     $this->forward404Unless(aMediaTools::userHasUploadPrivilege());
     $this->form = new aMediaUploadImagesForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('a_media_items'), $request->getFiles('a_media_items'));
         if ($this->form->isValid()) {
             $request->setParameter('first_pass', true);
             $active = array();
             // Saving embedded forms is weird. We can get the form objects
             // via getEmbeddedForms(), but those objects were never really
             // bound, so getValue will fail on them. We have to look at the
             // values array of the parent form instead. The widgets and
             // validators of the embedded forms are rolled into it.
             // See:
             // http://thatsquality.com/articles/can-the-symfony-forms-framework-be-domesticated-a-simple-todo-list
             for ($i = 0; $i < aMediaTools::getOption('batch_max'); $i++) {
                 $values = $this->form->getValues();
                 if ($values["item-{$i}"]['file']) {
                     $active[] = $i;
                 } else {
                     // So the editImagesForm validator won't complain about these
                     $items = $request->getParameter("a_media_items");
                     unset($items["item-{$i}"]);
                     $request->setParameter("a_media_items", $items);
                 }
             }
             $request->setParameter('active', implode(",", $active));
             // We'd like to just do this...
             // $this->forward('aMedia', 'editImages');
             // But we need to break out of the iframe, and
             // modern browsers ignore Window-target: _top which
             // would otherwise be perfect for this.
             // Fortunately, the persistent file upload widget can tolerate
             // a GET-method redirect very nicely as long as we pass the
             // persistids. So we make the current parameters available
             // to a template that breaks out of the iframe via
             // JavaScript and passes the prameters on.
             $this->parameters = $request->getParameterHolder('a_media_items')->getAll();
             // If I don't do this I just get redirected back to myself
             unset($this->parameters['module']);
             unset($this->parameters['action']);
             return 'Redirect';
         }
     }
 }