Development

Changeset 2743

You must first sign up to be able to contribute.

Changeset 2743

Show
Ignore:
Timestamp:
11/17/06 18:01:24 (7 years ago)
Author:
superhaggis
Message:

Added initial yui_link_to_remote() helper.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfYUIPlugin/lib/helper/YUIConnectionHelper.php

    r2738 r2743  
    133133} 
    134134 
     135/** 
     136 * Returns a link to a remote action defined by 'url' 
     137 * (using the 'url_for()' format). 
     138 * 
     139 * Example usage: 
     140 * 
     141 *   <div id="results"></div> 
     142 *   <?php echo yui_link_to_remote('Grab results', array( 
     143 *     'url' => 'results/fetch', 
     144 *     'success' => "function(o) { document.getElementById('results').innerHTML = o.responseText; }", 
     145 *     'failure' => "function(o) { alert('unable to fetch the data: ' + o.statusText); }", 
     146 *   )) ?> 
     147 * 
     148 * @param string $name 
     149 * @param array $options 
     150 * @see link_to_function() 
     151 */ 
     152function yui_link_to_remote($name, $options = array(), $html_options = array()) 
     153{ 
     154  $url = ''; 
     155  $method = 'GET'; 
     156  $callbacks = array(); 
     157  $postData = ''; 
    135158 
     159  if (isset($options['method'])) 
     160  { 
     161    $method = $options['method'];     
     162  } 
    136163 
     164  if (isset($options['url'])) 
     165  { 
     166    $url = $options['url']; 
     167  } 
    137168 
     169  if (isset($options['success'])) 
     170  { 
     171    $callbacks['success'] = $options['success']; 
     172  } 
     173   
     174  if (isset($options['failure'])) 
     175  { 
     176    $callbacks['failure'] = $options['failure']; 
     177  } 
    138178 
     179  if (isset($options['postData'])) 
     180  { 
     181    $postData = $options['postData']; 
     182  } 
    139183 
     184  return link_to_function($name, yui_connection($method, $url, $callbacks, $postData), $html_options);   
     185}