/**
  * @see sfWebController
  */
 public function genUrl($parameters = array(), $absolute = false)
 {
     $url = parent::genUrl($parameters, $absolute);
     if (sfJpMobile::isDocomo()) {
         if (!preg_match('/(\\?|&)guid=/', $url)) {
             $url .= (strpos($url, '?') === false ? '?' : '&') . 'guid=ON';
         }
     }
     return $url;
 }
 public function redirect($url, $delay = 0, $statusCode = 302)
 {
     $actionInstance = $this->context->getActionStack()->getLastEntry()->getActionInstance();
     $result = sfView::SUCCESS;
     if ($this->context->getUser()->hasFlash('error')) {
         $result = sfView::ERROR;
     }
     opExecutionFilter::notifyPostExecuteActionEvent($this, $this->dispatcher, $actionInstance, $result);
     parent::redirect($url, $delay, $statusCode);
 }
 /**
  * @see sfWebController
  */
 public function redirect($url, $delay = 0, $statusCode = 302)
 {
     $url = $this->genUrl($url, true);
     if (!$this->context->getRequest()->isCookie()) {
         $matchd = '/' . preg_quote(session_name(), '/') . '=.*([&|#]?)/';
         if (preg_match($matchd, $url)) {
             $url = preg_replace($matchd, SID . '\\1', $url);
         } else {
             if (strpos($url, '?') !== false) {
                 $url .= '&';
             } else {
                 $url .= '?';
             }
             $url .= SID;
         }
     }
     parent::redirect($url, $delay, $statusCode);
 }
  public function send()
  {
  }
}

$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['SCRIPT_NAME'] = '/index.php';
sfConfig::set('sf_max_forwards', 10);
$context = sfContext::getInstance(array(
  'routing'  => 'sfNoRouting',
  'request'  => 'sfWebRequest',
  'response' => 'myWebResponse',
));

$controller = new sfFrontWebController($context, null);

$tests = array(
  'module/action' => array(
    '',
    array(
      'module' => 'module',
      'action' => 'action',
    ),
  ),
  'module/action?id=12' => array(
    '',
    array(
      'module' => 'module',
      'action' => 'action',
      'id'     => 12,
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $class = array('class' => '');
     if (isset($attributes['class'])) {
         $class = array_merge($class, $attributes);
         $attributes['class'] .= ' hidden';
     }
     $class = ' ' . $class['class'];
     $values = array_merge(array('text' => '', 'is_empty' => false), is_array($value) ? $value : array());
     $obj_name = $this->getName($value);
     if ($this->getOption('default_name')) {
         $obj_name = $this->getOption('default_name');
     }
     $input = parent::render($name, $value, $attributes, $errors);
     if (strlen($this->getOption('button_class')) > 0) {
         $class .= ' ' . $this->getOption('button_class');
     }
     if ($this->getOption('button_is_hidden') && $value == 0) {
         $class .= ' hidden';
     }
     $input .= '<div title="' . $this->getOption('box_title') . '" id="' . $this->generateId($name) . '_button" class="ref_name' . $class . '">';
     $in_text = '<span class="on">' . __('Choose !') . '</span>';
     $url_params = '';
     if (count($this->getOption('url_params')) != 0) {
         $url_params = '?';
         foreach ($this->getOption('url_params') as $k => $v) {
             $url_params .= urlencode($k) . '=' . urlencode($v);
         }
     }
     $partial_url_params = '';
     if (count($this->getOption('partial_url_params')) != 0) {
         $partial_url_params = '?';
         foreach ($this->getOption('partial_url_params') as $k => $v) {
             $partial_url_params .= urlencode($k) . '=' . urlencode($v);
         }
     }
     $hidden = ' hidden';
     $json_splited_values = array();
     $rendered_partial = '';
     if (!empty($value)) {
         if (is_int($value) > 0) {
             $json_splited_values[] = array("id" => $value);
             $hidden = '';
         } else {
             $splited_values = preg_split('/[,]/', $value);
             if (count($splited_values) > 0) {
                 $hidden = '';
                 foreach ($splited_values as $split_val) {
                     if (intval($split_val) > 0) {
                         $json_splited_values[] = array("id" => $split_val);
                     }
                 }
             }
         }
     }
     if (count($json_splited_values) > 0) {
         try {
             $context = sfContext::getInstance();
             $partial_request = new sfWebRequest($context->getEventDispatcher());
             $partial_request->setMethod('POST');
             $partial_request->setParameter('field_id', $this->generateId($name));
             $partial_request->setParameter('row_data', $json_splited_values);
             $partial_request->setParameter('from_db', '1');
             $partial_request->setParameter('catalogue', $this->getOption('model'));
             $partial_controler = new sfFrontWebController($context);
             $partial_controler_action = $partial_controler->getAction($this->getOption('partial_controler'), $this->getOption('partial_action'));
             $rendered_partial = $partial_controler_action->execute($partial_request);
         } catch (Exception $e) {
             $hidden = ' hidden';
             $rendered_partial = '';
         }
     }
     $input .= '<a href="' . url_for($this->getOption('link_url')) . $url_params . '" class="but_text_multiple">' . $in_text . '</a>';
     $input .= '</div>';
     $input .= '<div id="' . $this->generateId($name) . '_result_table" class="results_container but_ref_multiple' . $hidden . '">
              <table class="results">
                <thead>
                  <tr>
                    <th>' . __('Name') . '</th>
                    <th>' . __('Level') . '</th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>';
     $input .= $rendered_partial;
     $input .= '     </tbody>
              </table>
            </div>
           ';
     $input .= '<script  type="text/javascript">
              $(document).ready(function () {
                $("#' . $this->generateId($name) . '_button a.but_text_multiple").button_ref_multiple({
                  q_tip_text : "Choose a ' . $this->getLabel() . '",
                  update_row_fct: $.fn.button_ref_multiple.addEntry,
                  ids_list_target_input_id: "#' . $this->generateId($name) . '",
                  names_list_target_table_id: "#' . $this->generateId($name) . '_result_table",
                  partial_url:"' . url_for($this->getOption('partial_url')) . $partial_url_params . '",
                  attached_field_id:"' . $this->generateId($name) . '"
                });';
     $on_change_attached_to_id = $this->getOption('on_change_attached_to_id');
     $on_change_url_for_widget_renew = $this->getOption('on_change_url_for_widget_renew');
     if (!empty($on_change_attached_to_id) && !empty($on_change_url_for_widget_renew)) {
         $input .= '
              $("#' . $this->getOption('on_change_attached_to_id') . '").off("change").on(
                  "change",
                  {
                      control_to_replace:"' . $this->generateId($name) . '",
                      replacement_url:"' . url_for($this->getOption('on_change_url_for_widget_renew')) . '",
                      replacement_url_name_param:"' . $this->getOption('on_change_url_for_widget_renew_params', '') . '",
                      widget_button_ref_multiple_refresh:1
                  },
                  $.fn.button_ref_multiple.replaceControl
              );';
     }
     $input .= '  });
            </script>';
     return $input;
 }
Esempio n. 6
0
 /**
  * @see sfFrontWebController
  */
 public function redirect($url, $delay = 0, $statusCode = 302)
 {
     $this->dispatcher->notify(new sfEvent($this, 'dm.controller.redirect'));
     return parent::redirect($url, $delay, $statusCode);
 }