/** * Enable to use Modalbox script : http://www.wildbit.com/labs/modalbox/ * * * * @author Gerald Estadieu <*****@*****.**> * @since 15 Apr 2007 * */ function m_link_to($name, $url, $html_options = array(), $modal_options = array()) { use_helper('Javascript'); if (array_key_exists('title', $html_options)) { $modal_options = array_merge($modal_options, array('title' => 'this.title')); } $params_to_escape = sfConfig::get('app_params_to_escape_list'); // escape strings for js foreach ($modal_options as $option => $value) { if (in_array($option, $params_to_escape)) { $modal_options[$option] = "'" . $value . "'"; } } $js_options = _options_for_javascript($modal_options); $html_options['onclick'] = "Modalbox.show(this.href, " . $js_options . "); return false;"; return link_to($name, $url, $html_options); }
/** * @package sfModalBoxPlugin * * @author Vitalii Tverdokhlib <*****@*****.**> * @since 11 oct 2008 * @version 1.0.0 * */ function m_link_to_element($url, $modal_options = array(), $modal = false) { use_helper('Javascript'); if (isset($modal_options['title'])) { $modal_options = array_merge($modal_options, array('title' => $modal_options['title'])); } $params_to_escape = sfConfig::get('app_params_to_escape_list'); // escape strings for js foreach ($modal_options as $option => $value) { if (in_array($option, $params_to_escape)) { $modal_options[$option] = "'" . $value . "'"; } } $js_options = _options_for_javascript($modal_options); $result = "Modalbox.show(" . $url . ", " . $js_options . "); "; if ($modal) { $result .= "Modalbox.deactivate()"; } return $result; }
function m_link_to($name, $url, $html_options = array(), $modal_options = array()) { use_helper('Javascript'); if (is_string($html_options)) { $html_options = array('title' => __($html_options)); } elseif (!is_array($html_options)) { $html_options = array(); } // modalbox specific options if (array_key_exists('title', $html_options)) { $modal_options = array_merge($modal_options, array('title' => 'this.title')); } if (!array_key_exists('remote', $modal_options)) { $modal_options['remote'] = 'this.href'; } $js_options = _options_for_javascript($modal_options); if (!c2cTools::mobileVersion()) { $html_options['onclick'] = "\$.modalbox.show({$js_options}); return false;"; } return link_to($name, $url, $html_options); }
function _options_for_ajax($options) { $js_options = _build_callbacks($options); $js_options['asynchronous'] = isset($options['type']) && $options['type'] == 'synchronous' ? 'false' : 'true'; if (isset($options['method'])) { $js_options['method'] = _method_option_to_s($options['method']); } if (isset($options['position'])) { $js_options['insertion'] = "Insertion." . sfInflector::camelize($options['position']); } $js_options['evalScripts'] = !isset($options['script']) || $options['script'] == '0' || $options['script'] == false ? 'false' : 'true'; if (isset($options['form'])) { $js_options['parameters'] = 'Form.serialize(this)'; } else { if (isset($options['submit'])) { $js_options['parameters'] = "Form.serialize(document.getElementById('{$options['submit']}'))"; } else { if (isset($options['with'])) { $js_options['parameters'] = $options['with']; } } } return _options_for_javascript($js_options); }
/** * link_to_prototype_window creates a window using prototype. * * Example: * <code> * <?php use_helper('Window'); ?> * <?php if(sfConfig::get('sf_debug')) { echo link_to_function('open debug window', 'showDebug()'); } ?> * <?php echo link_to_prototype_window('Google', 'google', array('title' => 'Google', 'url' => 'http://google.com', 'width' => '520', 'height' => '350', 'center' => 'true', 'className' => 'alphacube'), array('absolute' => true)); ?> * <?php echo link_to_prototype_window('DW', 'dw', array('title' => 'DW', 'url' => '@homepage', 'width' => '520', 'height' => '350', 'center' => 'true', 'className' => 'alphacube')); ?> * </code> * * @link http://prototype-window.xilinus.com/documentation.html#initialize * * @param string $name * @param string $window_id must be unique and it's destroyed on window close. * @param array $options options for this helper: http://prototype-window.xilinus.com/documentation.html#initialize * @param array $options_html * @return string */ function link_to_prototype_window($name, $window_id, $options, $options_html = array()) { $request = sfContext::getInstance()->getResponse(); $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/prototype'); $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/scriptaculous'); $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/effects'); $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/window'); $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/window_ext'); $request->addStylesheet(sfConfig::get('sf_prototype_web_dir').'/themes/default.css'); if(isset($options['className']) && ($options['className'] != 'default')) { $request->addStylesheet(sfConfig::get('sf_prototype_web_dir').'/themes/'.$options['className'].'.css'); } if(sfConfig::get('sf_debug')) { $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/debug'); $request->addJavascript(sfConfig::get('sf_prototype_web_dir').'/extended_debug'); } $options = array_merge(array('title' => 'New Window', 'className' => 'dialog', 'width' => '600', 'height' => '450', 'zIndex' => '100', 'draggable' => 'true', 'resizable' => 'true', 'opacity' => 1, 'showEffect' => 'Effect.BlindDown', 'hideEffect' => 'Effect.SwitchOff'), _parse_attributes($options)); if (isset($options['title'])) { $options['title'] = _method_option_to_s($options['title']); } if (isset($options['className'])) { $options['className'] = _method_option_to_s($options['className']); } $absolute = isset($options_html['absolute']) ? true : false; unset($options_html['absolute']); if (isset($options['url'])) { $options['url'] = _method_option_to_s(url_for($options['url'], $absolute)); } $front = isset($options['front']) ? $window_id.'.toFront();' : ''; unset($options['front']); $status = isset($options['status']) ? $window_id.'.setStatusBar('.$options['status'].');' : ''; unset($options['status']); $show = isset($options['center']) ? $window_id.'.showCenter();' : $window_id.'.show();'; unset($options['center']); $options = _options_for_javascript($options); $options_html = _parse_attributes($options_html); $js_code = 'var ' . $window_id . ' = new Window('.$window_id.', '.$options.');'.$front.$status.$show.$window_id.'.setDestroyOnClose();'; $options_html['href'] = isset($options_html['href']) ? $options_html['href'] : '#'; $options_html['onclick'] = isset($options_html['onclick']) ? $options_html['onclick'] . $js_code : $js_code; return content_tag('a', $name, $options_html); }
function _auto_complete_field($field_id, $url, $options = array()) { $javascript = "new Ajax.Autocompleter("; $javascript .= "'{$field_id}', "; if (isset($options['update'])) { $javascript .= "'" . $options['update'] . "', "; } else { $javascript .= "'{$field_id}_auto_complete', "; } $javascript .= "'" . system_url($url) . "'"; $js_options = array(); if (isset($options['tokens'])) { $js_options['tokens'] = _array_or_string_for_javascript($options['tokens']); } if (isset($options['with'])) { $js_options['callback'] = "function(element, value) { return" . $options['with'] . "}"; } if (isset($options['indicator'])) { $js_options['indicator'] = "'" . $options['indicator'] . "'"; } if (isset($options['on_show'])) { $js_options['onShow'] = $options['on_show']; } if (isset($options['on_hide'])) { $js_options['onHide'] = $options['on_hide']; } if (isset($options['min_chars'])) { $js_options['min_chars'] = $options['min_chars']; } $javascript .= ', ' . _options_for_javascript($js_options) . ');'; return javascript_tag($javascript); }
/** * Returns a javascript to specify parameters for gWidgets (optional) * * @param array $options Options of gWidgets * * @author Gerald Estadieu <*****@*****.**> * @since 15 Apr 2007 * */ function gwidgets_js($options = array()) { _loadRessources(); $opt = _options_for_javascript($options); return javascript_tag("\n\tvar gWidget_Options = {$opt};\n\t"); }
function bbcode_toolbar_img_tag($document, $target_id) { $id = $document->getId(); $options = array('title' => __('Insert image'), 'onclick' => "\$.modalbox.show(" . _options_for_javascript(array('title' => 'this.title', 'width' => 710, 'remote' => "'/insertimagetag/" . $document->getModule() . "/{$id}/{$target_id}'")) . '); return false;'); if (!(isset($id) && trim($id) != '')) { $options['disabled'] = 'disabled'; } $title = __('img button title'); return tag('input', array_merge(array('value' => 'img', 'title' => $title, 'type' => 'button', 'name' => 'insert img'), $options)) . ' '; }