Example #1
0
 /**
  * Creates JavaScript function for remote AJAX call
  *
  * This function creates the javascript needed to make a remote call
  * it is primarily used as a helper for AjaxHelper::link.
  *
  * @param array $options options for javascript
  * @return string html code for link to remote action
  * @see AjaxHelper::link() for docs on options parameter.
  */
 function remoteFunction($options)
 {
     if (isset($options['update'])) {
         if (!is_array($options['update'])) {
             $func = "new Ajax.Updater('{$options['update']}',";
         } else {
             $func = "new Ajax.Updater(document.createElement('div'),";
         }
         if (!isset($options['requestHeaders'])) {
             $options['requestHeaders'] = array();
         }
         if (is_array($options['update'])) {
             $options['update'] = join(' ', $options['update']);
         }
         $options['requestHeaders']['X-Update'] = $options['update'];
     } else {
         $func = "new Ajax.Request(";
     }
     $func .= "'" . $this->url(isset($options['url']) ? $options['url'] : "") . "'";
     $func .= ", " . $this->__optionsForAjax($options) . ")";
     if (isset($options['before'])) {
         $func = "{$options['before']}; {$func}";
     }
     if (isset($options['after'])) {
         $func = "{$func}; {$options['after']};";
     }
     if (isset($options['condition'])) {
         $func = "if ({$options['condition']}) { {$func}; }";
     }
     if (isset($options['confirm'])) {
         $func = "if (confirm('" . $this->Javascript->escapeString($options['confirm']) . "')) { {$func}; } else { event.returnValue = false; return false; }";
     }
     return $func;
 }
Example #2
0
 /**
  * Creates JavaScript function for remote AJAX call
  *
  * This function creates the javascript needed to make a remote call
  * it is primarily used as a helper for AjaxHelper::link.
  *
  * @see AjaxHelper::link() for docs on options parameter.
  * @param array $options options for javascript
  * @return string html code for link to remote action
  */
 function remoteFunction($options = null, $function = 'jQuery.ajax')
 {
     if (isset($options['confirm'])) {
         $confirm = $options['confirm'];
         unset($options['confirm']);
     }
     $func = "{$function}(" . $this->__optionsForAjax($options) . ")";
     if (isset($options['before'])) {
         $func = "{$options['before']}; {$func}";
     }
     if (isset($options['after'])) {
         $func = "{$func}; {$options['after']};";
     }
     if (isset($options['condition'])) {
         $func = "if ({$options['condition']}) { {$func}; }";
     }
     if (isset($confirm)) {
         $func = "if (confirm('" . $this->Javascript->escapeString($confirm) . "')) { {$func}; } else { event.returnValue = false; return false; }";
     }
     return $func;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function escape($param)
 {
     return $this->dbHandle->escapeString($param);
 }
 function addslashes($value)
 {
     return $this->dbConn->escapeString($value);
 }