Example #1
0
function _convert_options_to_javascript($html_options, $url = 'this.href')
{
    // confirm
    $confirm = isset($html_options['confirm']) ? $html_options['confirm'] : '';
    unset($html_options['confirm']);
    // popup
    $popup = isset($html_options['popup']) ? $html_options['popup'] : '';
    unset($html_options['popup']);
    // method
    $method = isset($html_options['method']) ? $html_options['method'] : (isset($html_options['post']) && $html_options['post'] ? 'post' : false);
    unset($html_options['post'], $html_options['method']);
    $onclick = isset($html_options['onclick']) ? $html_options['onclick'] : '';
    if ($popup && $method) {
        throw new sfConfigurationException('You can\'t use "popup", "method" and "post" in the same link.');
    } else {
        if ($confirm && $popup) {
            $html_options['onclick'] = $onclick . 'if (' . _confirm_javascript_function($confirm) . ') { ' . _popup_javascript_function($popup, $url) . ' };return false;';
        } else {
            if ($confirm && $method) {
                $html_options['onclick'] = $onclick . 'if (' . _confirm_javascript_function($confirm) . ') { ' . _method_javascript_function($method) . ' };return false;';
            } else {
                if ($confirm) {
                    if ($onclick) {
                        $html_options['onclick'] = 'if (' . _confirm_javascript_function($confirm) . ') { return ' . $onclick . '} else return false;';
                    } else {
                        $html_options['onclick'] = 'return ' . _confirm_javascript_function($confirm) . ';';
                    }
                } else {
                    if ($method) {
                        $html_options['onclick'] = $onclick . _method_javascript_function($method) . 'return false;';
                    } else {
                        if ($popup) {
                            $html_options['onclick'] = $onclick . _popup_javascript_function($popup, $url) . 'return false;';
                        }
                    }
                }
            }
        }
    }
    return $html_options;
}
Example #2
0
function _convert_options_to_javascript($html_options, $internal_uri = '')
{
    // confirm
    $confirm = isset($html_options['confirm']) ? $html_options['confirm'] : '';
    unset($html_options['confirm']);
    // popup
    $popup = isset($html_options['popup']) ? $html_options['popup'] : '';
    unset($html_options['popup']);
    // post
    $post = isset($html_options['post']) ? $html_options['post'] : '';
    unset($html_options['post']);
    $onclick = isset($html_options['onclick']) ? $html_options['onclick'] : '';
    if ($popup && $post) {
    } else {
        if ($confirm && $popup) {
            $html_options['onclick'] = $onclick . 'if (' . _confirm_javascript_function($confirm) . ') { ' . _popup_javascript_function($popup, $internal_uri) . ' };return false;';
        } else {
            if ($confirm && $post) {
                $html_options['onclick'] = $onclick . 'if (' . _confirm_javascript_function($confirm) . ') { ' . _post_javascript_function() . ' };return false;';
            } else {
                if ($confirm) {
                    if ($onclick) {
                        $html_options['onclick'] = 'if (' . _confirm_javascript_function($confirm) . ') {' . $onclick . '}';
                    } else {
                        $html_options['onclick'] = 'return ' . _confirm_javascript_function($confirm) . ';';
                    }
                } else {
                    if ($post) {
                        $html_options['onclick'] = $onclick . _post_javascript_function() . 'return false;';
                    } else {
                        if ($popup) {
                            $html_options['onclick'] = $onclick . _popup_javascript_function($popup, $internal_uri) . 'return false;';
                        }
                    }
                }
            }
        }
    }
    return $html_options;
}
Example #3
0
function _convert_options_to_javascript($html_options, $target = '')
{
    // confirm
    $confirm = isset($html_options['confirm']) ? $html_options['confirm'] : '';
    unset($html_options['confirm']);
    // popup
    $popup = isset($html_options['popup']) ? $html_options['popup'] : '';
    unset($html_options['popup']);
    // post
    $post = isset($html_options['post']) ? $html_options['post'] : '';
    unset($html_options['post']);
    $onclick = isset($html_options['onclick']) ? $html_options['onclick'] : '';
    if ($popup && $post) {
        show_error('You can\'t use "popup" and "post" in the same link');
    } else {
        if ($confirm && $popup) {
            $html_options['onclick'] = $onclick . 'if (' . _confirm_javascript_function($confirm) . ') { ' . _popup_javascript_function($popup, $target) . ' };return false;';
        } else {
            if ($confirm && $post) {
                $html_options['onclick'] = $onclick . 'if (' . _confirm_javascript_function($confirm) . ') { ' . _post_javascript_function() . ' };return false;';
            } else {
                if ($confirm) {
                    if ($onclick) {
                        $html_options['onclick'] = 'if (' . _confirm_javascript_function($confirm) . ') {' . $onclick . '}';
                    } else {
                        $html_options['onclick'] = 'return ' . _confirm_javascript_function($confirm) . ';';
                    }
                } else {
                    if ($post) {
                        $html_options['onclick'] = $onclick . _post_javascript_function() . 'return false;';
                    } else {
                        if ($popup) {
                            $html_options['onclick'] = $onclick . _popup_javascript_function($popup, $target) . 'return false;';
                        }
                    }
                }
            }
        }
    }
    return $html_options;
}
Example #4
0
function _convert_options_to_javascript($html_options, $internal_uri = '')
{
    // confirm
    $confirm = isset($html_options['confirm']) ? $html_options['confirm'] : '';
    unset($html_options['confirm']);
    // popup
    $popup = isset($html_options['popup']) ? $html_options['popup'] : '';
    unset($html_options['popup']);
    // post
    $post = isset($html_options['post']) ? $html_options['post'] : '';
    unset($html_options['post']);
    $onclick = isset($html_options['onclick']) ? $html_options['onclick'] : '';
    if ($popup && $post) {
        throw new sfConfigurationException('You can\'t use "popup" and "post" in the same link');
    } else {
        if ($confirm && $popup) {
            $html_options['onclick'] = $onclick . 'if (' . _confirm_javascript_function($confirm) . ') { ' . _popup_javascript_function($popup, $internal_uri) . ' };return false;';
        } else {
            if ($confirm && $post) {
                $html_options['onclick'] = $onclick . 'if (' . _confirm_javascript_function($confirm) . ') { ' . _post_javascript_function() . ' };return false;';
            } else {
                if ($confirm) {
                    if ($onclick) {
                        $html_options['onclick'] = 'if (' . _confirm_javascript_function($confirm) . ') { return ' . $onclick . '} else return false;';
                    } else {
                        $html_options['onclick'] = 'return ' . _confirm_javascript_function($confirm) . ';';
                    }
                } else {
                    if ($post) {
                        $html_options['onclick'] = $onclick . _post_javascript_function() . 'return false;';
                    } else {
                        if ($popup) {
                            $html_options['onclick'] = $onclick . _popup_javascript_function($popup, $internal_uri) . 'return false;';
                        }
                    }
                }
            }
        }
    }
    return $html_options;
}