diff options
Diffstat (limited to 'vendor/flexi/lib/helper')
| -rw-r--r-- | vendor/flexi/lib/helper/js_helper.php | 135 | ||||
| -rw-r--r-- | vendor/flexi/lib/helper/prototype_helper.php | 764 | ||||
| -rw-r--r-- | vendor/flexi/lib/helper/scriptaculous_helper.php | 142 | ||||
| -rw-r--r-- | vendor/flexi/lib/helper/tag_helper.php | 122 | ||||
| -rw-r--r-- | vendor/flexi/lib/helper/text_helper.php | 183 |
5 files changed, 0 insertions, 1346 deletions
diff --git a/vendor/flexi/lib/helper/js_helper.php b/vendor/flexi/lib/helper/js_helper.php deleted file mode 100644 index b641f4e..0000000 --- a/vendor/flexi/lib/helper/js_helper.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -/** - * Provides functionality for working with JavaScript in your views. - * - * @package flexi - * @subpackage helper - * - * @author Marcus Lunzenauer (mlunzena@uos.de) - * @author David Heinemeier Hansson - * @copyright (c) Authors - * @version $Id: js_helper.php 3437 2006-05-27 11:38:58Z mlunzena $ - */ - -class JsHelper { - - /** - * Returns a link that'll trigger a javascript function using the - * onclick handler and return false after the fact. - * - * Example: - * JsHelper::link_to_function('Greeting', "alert('Hello world!')"); - * - * @param type <description> - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function link_to_function($name, $function, $html = array()) { - $html['href'] = isset($html['href']) ? $html['href'] : '#'; - $html['onclick'] = $function.'; return false;'; - return TagHelper::content_tag('a', $name, $html); - } - - /** - * Returns a link that'll trigger a JavaScript function using the onclick - * handler. - * - * Examples: - * JsHelper::button_to_function("Greeting", "alert('Hello world!')"); - * - * @param type <description> - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function button_to_function($name, $function, $html_options = array()) { - - $html_options['type'] = 'button'; - $html_options['value'] = $name; - $html_options['onclick'] = sprintf('%s%s;', - isset($html_options['onclick']) ? $html_options['onclick'] . '; ' : '', - $function); - return TagHelper::tag('input', $html_options); - } - - /** - * Escape carrier returns and single and double quotes for Javascript - * segments. - * - * @param type <description> - * - * @return type <description> - */ - function escape_javascript($javascript = '') { - $pattern = array(); $replace = array(); - $pattern[] = '/\\\\/'; $replace[] = '\\\\\\'; - $pattern[] = '/<\//'; $replace[] = '<\\/'; - $pattern[] = "/\r\n/"; $replace[] = '\n'; - $pattern[] = "/\n/"; $replace[] = '\n'; - $pattern[] = "/\r/"; $replace[] = '\n'; - $pattern[] = '/"/'; $replace[] = '\\"'; - $pattern[] = "/'/"; $replace[] = "\\'"; - - $javascript = preg_replace($pattern, $replace, $javascript); - return $javascript; - } - - /** - * Returns a JavaScript tag with the '$content' inside. - * Example: - * JsHelper::javascript_tag("alert('All is good')"); - * => <script type="text/javascript">alert('All is good')</script> - * - * @param type <description> - * - * @return type <description> - */ - function javascript_tag($content) { - return TagHelper::content_tag('script', - JsHelper::js_cdata_section($content), - array('type' => 'text/javascript')); - } - - /** - * @ignore - */ - function js_cdata_section($content) { - return "\n//".TagHelper::cdata_section("\n$content\n//")."\n"; - } - - /** - * @ignore - */ - function options_for_javascript($opt) { - $opts = array(); - foreach ($opt as $key => $value) - $opts[] = "$key:$value"; - sort($opts); - - return '{'.join(', ', $opts).'}'; - } -} diff --git a/vendor/flexi/lib/helper/prototype_helper.php b/vendor/flexi/lib/helper/prototype_helper.php deleted file mode 100644 index 33f8821..0000000 --- a/vendor/flexi/lib/helper/prototype_helper.php +++ /dev/null @@ -1,764 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -/** - * PrototypeHelper. - * - * - * @package flexi - * @subpackage helper - * - * @author Marcus Lunzenauer (mlunzena@uos.de) - * @author David Heinemeier Hansson - * @copyright (c) Authors - * @version $Id: prototype_helper.php 3437 2006-05-27 11:38:58Z mlunzena $ - */ - -class PrototypeHelper { - - /** - * Returns a link to a remote action defined by 'url' (using the 'url_for()' - * format) that's called in the background using XMLHttpRequest. The result of - * that request can then be inserted into a DOM object whose id can be - * specified with 'update'. - * - * Examples: - * link_to_remote('Delete this post', - * array('update' => 'posts', 'url' => 'destroy?id='.$id)) - * - * You can also specify a hash for 'update' to allow for - * easy redirection of output to an other DOM element if a server-side error - * occurs: - * - * Example: - * link_to_remote('Delete this post', - * array('update' => array('success' => 'posts', - * 'failure' => 'error'), - * 'url' => 'destroy?id='.$id)) - * - * Optionally, you can use the 'position' parameter to influence - * how the target DOM element is updated. It must be one of 'before', 'top', - * 'bottom', or 'after'. - * - * By default, these remote requests are processed asynchronous during - * which various JavaScript callbacks can be triggered (for progress - * indicators and the likes). All callbacks get access to the 'request' - * object, which holds the underlying XMLHttpRequest. - * - * The callbacks that may be specified are (in order): - * - * 'loading' Called when the remote document is being - * loaded with data by the browser. - * 'loaded' Called when the browser has finished loading - * the remote document. - * 'interactive' Called when the user can interact with the - * remote document, even though it has not - * finished loading. - * 'success' Called when the XMLHttpRequest is completed, - * and the HTTP status code is in the 2XX range. - * 'failure' Called when the XMLHttpRequest is completed, - * and the HTTP status code is not in the 2XX - * range. - * 'complete' Called when the XMLHttpRequest is complete - * (fires after success/failure if present). - * - * You can further refine 'success' and 'failure' by adding additional - * callbacks for specific status codes: - * - * Example: - * link_to_remote($word, array('url' => $rule, - * '404' => "alert('Not found...?')", - * 'failure' => "alert('HTTPError!')")) - * - * A status code callback overrides the success/failure handlers if present. - * - * If you for some reason or another need synchronous processing (that'll - * block the browser while the request is happening), you can specify - * 'type' => 'synchronous'. - * - * You can customize further browser side call logic by passing - * in JavaScript code snippets via some optional parameters. In - * their order of use these are: - * - * 'confirm' Adds confirmation dialog. - * 'condition' Perform remote request conditionally - * by this expression. Use this to - * describe browser-side conditions when - * request should not be initiated. - * 'before' Called before request is initiated. - * 'after' Called immediately after request was - * initiated and before 'loading'. - * 'submit' Specifies the DOM element ID that's used - * as the parent of the form elements. By - * default this is the current form, but - * it could just as well be the ID of a - * table row or any other DOM element. - * - * @param type <description> - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function link_to_remote($name, $options = array(), $html_options = array()) { - return JsHelper::link_to_function($name, - PrototypeHelper::remote_function($options), $html_options); - } - - /** - * Periodically calls the specified url ['url'] every ['frequency'] seconds - * (default is 10). Usually used to update a specified div ['update'] with the - * results of the remote call. The options for specifying the target with - * 'url' and defining callbacks is the same as 'link_to_remote()'. - * - * @param type <description> - * - * @return type <description> - */ - function periodically_call_remote($options = array()) { - $frequency = isset($options['frequency']) ? $options['frequency'] : 10; - $code = sprintf('new PeriodicalExecuter(function() {%s}, %d)', - PrototypeHelper::remote_function($options), $frequency); - return JsHelper::javascript_tag($code); - } - - /** - * Returns a form tag that will submit using XMLHttpRequest in the background - * instead of the regular reloading POST arrangement. Even though it's using - * JavaScript to serialize the form elements, the form submission will work - * just like a regular submission as viewed by the receiving side - * (all elements available in 'params'). The options for specifying the target - * with 'url' and defining callbacks are the same as 'link_to_remote()'. - * - * A "fall-through" target for browsers that don't do JavaScript can be - * specified with the 'action' and 'method' options on '$html_options'. - * - * Example: - * form_remote_tag(array( - * 'url' => 'tag_add', - * 'update' => 'question_tags', - * 'loading' => "Element.show('indicator'); tag.value = ''", - * 'complete' => "Element.hide('indicator');". - * visual_effect('highlight', 'question_tags'))) - * - * The hash passed as a second argument is equivalent to the options (2nd) - * argument in the form_tag() helper. - * - * @param type <description> - * - * @return type <description> - */ - function form_remote_tag($options = array(), $html_options = array()) { - - $options = TagHelper::_parse_attributes($options); - $html_options = TagHelper::_parse_attributes($html_options); - - $options['form'] = TRUE; - - $html_options['onsubmit'] = PrototypeHelper::remote_function($options). - '; return false;'; - $html_options['action'] = isset($html_options['action']) - ? $html_options['action'] - : $options['url']; - - $html_options['method'] = isset($html_options['method']) - ? $html_options['method'] - : 'post'; - - return TagHelper::tag('form', $html_options, TRUE); - } - - /** - * Returns a button input tag that will submit form using XMLHttpRequest in - * the background instead of regular reloading POST arrangement. The '$opt' - * argument is the same as in 'form_remote_tag()'. - * - * @param type <description> - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function submit_to_remote($name, $value, $options = array()) { - - if (!isset($options['with'])) - $options['with'] = 'Form.serialize(this.form)'; - - if (!isset($options['html'])) - $options['html'] = array(); - - $options['html']['type'] = 'button'; - $options['html']['onclick'] = PrototypeHelper::remote_function($options). - '; return false;'; - $options['html']['name'] = $name; - $options['html']['value'] = $value; - - return TagHelper::tag('input', $options['html']); - } - - /** - * Returns a Javascript function (or expression) that will update a DOM - * element '$element_id' according to the '$opt' passed. - * - * Possible '$opt' are: - * 'content' The content to use for updating. - * 'action' Valid options are 'update' (default), 'empty', 'remove' - * 'position' If the 'action' is 'update', you can optionally specify one of - * the following positions: 'before', 'top', 'bottom', 'after'. - * - * Example: - * update_element_function('products', - * array('position' => 'bottom', - * 'content' => "<p>New product!</p>")); - * - * - * This method can also be used in combination with remote method call - * where the result is evaluated afterwards to cause multiple updates on a - * page. - * - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function update_element_function($element_id, $options = array()) { - - $content = JsHelper::escape_javascript(isset($options['content']) - ? $options['content'] - : ''); - - $value = isset($options['action']) ? $options['action'] : 'update'; - - switch ($value) { - - case 'update': - $js_func = $options['position'] - ? sprintf("new Insertion.%s('%s','%s')", - TextHelper::camelize($options['position']), - $element_id, $content) - : "\$('$element_id').innerHTML = '$content'"; - break; - - case 'empty': - $js_func = "\$('$element_id').innerHTML = ''"; - break; - - case 'remove': - $js_func = "Element.remove('$element_id')"; - break; - - default: - trigger_error('Invalid action, choose one of update, remove, empty'); - exit; - } - - $js_func .= ";\n"; - - return isset($options['binding']) ? $js_func.$options['binding'] : $js_func; - } - - /** - * Returns 'eval(request.responseText)', which is the Javascript function that - * 'form_remote_tag()' can call in 'complete' to evaluate a multiple update - * return document using 'update_element_function()' calls. - * - * @return type <description> - */ - function evaluate_remote_response() { - return 'eval(request.responseText)'; - } - - /** - * Returns the javascript needed for a remote function. - * Takes the same arguments as 'link_to_remote()'. - * - * Example: - * <select id="options" onchange="<?= - * remote_function(array('update' => 'options', - * 'url' => '@update_options')) ?>"> - * <option value="0">Hello</option> - * <option value="1">World</option> - * </select> - * - * @param type <description> - * - * @return type <description> - */ - function remote_function($options) { - $javascript_options = PrototypeHelper::options_for_ajax($options); - - $update = ''; - if (isset($options['update']) && is_array($options['update'])) { - - $update = array(); - if (isset($options['update']['success'])) - $update[] = "success:'".$options['update']['success']."'"; - - if (isset($options['update']['failure'])) - $update[] = "failure:'".$options['update']['failure']."'"; - - $update = '{'.join(',', $update).'}'; - - } else if (isset($options['update'])) { - $update .= "'".$options['update']."'"; - } - - $function = sprintf("new Ajax.%s(%s'%s', %s)", - $update ? 'Updater' : 'Request', - $update ? "$update, " : '', - $options['url'], - $javascript_options); - - if (isset($options['before'])) - $function = $options['before'].'; '.$function; - - if (isset($options['after'])) - $function = $function.'; '.$options['after']; - - if (isset($options['condition'])) - $function = 'if ('.$options['condition'].') { '.$function.'; }'; - - if (isset($options['confirm'])) { - $function = "if (confirm('" . - JsHelper::escape_javascript($options['confirm']) . - "')) { $function; }"; - if (isset($options['cancel'])) - $function .= ' else { '.$options['cancel'].' }'; - } - - return $function; - } - - /** - * Observes the field with the DOM ID specified by '$field_id' and makes - * an AJAX call when its contents have changed. - * - * Required '$options' are: - * 'url' 'url_for()'-style options for the action to call - * when the field has changed. - * - * Additional options are: - * 'frequency' The frequency (in seconds) at which changes to - * this field will be detected. Not setting this - * option at all or to a value equal to or less than - * zero will use event based observation instead of - * time based observation. - * 'update' Specifies the DOM ID of the element whose - * innerHTML should be updated with the - * XMLHttpRequest response text. - * 'with' A JavaScript expression specifying the - * parameters for the XMLHttpRequest. This defaults - * to 'value', which in the evaluated context - * refers to the new field value. - * - * Additionally, you may specify any of the options documented in - * link_to_remote(). - * - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function observe_field($field_id, $options = array()) { - $name = isset($options['frequency']) && $options['frequency'] > 0 - ? 'Form.Element.Observer' - : 'Form.Element.EventObserver'; - return PrototypeHelper::build_observer($name, $field_id, $options); - } - - /** - * Like 'observe_field()', but operates on an entire form identified by the - * DOM ID '$form_id'. '$options' are the same as 'observe_field()', except - * the default value of the 'with' option evaluates to the - * serialized (request string) value of the form. - * - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function observe_form($form_id, $options = array()) { - $name = isset($options['frequency']) && $options['frequency'] > 0 - ? 'Form.Observer' - : 'Form.EventObserver'; - return PrototypeHelper::build_observer($name, $form_id, $options); - } - - /** - * @ignore - */ - function options_for_ajax($options) { - $js_opt = PrototypeHelper::build_callbacks($options); - - $js_opt['asynchronous'] = isset($options['type']) - ? $options['type'] != 'synchronous' : 'true'; - - if (isset($options['method'])) - $js_opt['method'] = PrototypeHelper::method_option_to_s($options['method']); - - if (isset($options['position'])) - $js_opt['insertion'] = 'Insertion.'.TextHelper::camelize($options['position']); - - $js_opt['evalScripts'] = !isset($options['script']) || - $options['script'] == '0' || - $options['script'] == 'false' - ? 'false' : 'true'; - - if (isset($options['form'])) - $js_opt['parameters'] = 'Form.serialize(this)'; - else if (isset($options['submit'])) - $js_opt['parameters'] = "Form.serialize(document.getElementById('{$options['submit']}'))"; - else if (isset($options['with'])) - $js_opt['parameters'] = $options['with']; - - return JsHelper::options_for_javascript($js_opt); - } - - /** - * @ignore - */ - function method_option_to_s($method) { - return is_string($method) && $method[0] == "'" ? $method : "'$method'"; - } - - /** - * @ignore - */ - function build_observer($klass, $name, $options = array()) { - if (!isset($options['with']) && $options['update']) - $options['with'] = 'value'; - - $callback = PrototypeHelper::remote_function($options); - - $javascript = 'new '.$klass.'("'.$name.'", '; - if (isset($options['frequency'])) - $javascript .= $options['frequency'].", "; - - $javascript .= 'function(element, value) {'; - $javascript .= $callback.'});'; - - return JsHelper::javascript_tag($javascript); - } - - /** - * @ignore - */ - function build_callbacks($options) { - $callbacks = array(); - foreach (PrototypeHelper::get_callbacks() as $callback) { - if (isset($options[$callback])) { - $name = 'on'.ucfirst($callback); - $code = $options[$callback]; - $callbacks[$name] = 'function(request, json){'.$code.'}'; - } - } - - return $callbacks; - } - - /** - * @ignore - */ - function get_callbacks() { - static $callbacks; - if (!$callbacks) - $callbacks = array_merge(range(100, 599), - array('uninitialized', 'loading', 'loaded', - 'interactive', 'complete', 'failure', - 'success')); - return $callbacks; - } - - /** - * @ignore - */ - function get_ajax_options() { - static $ajax_options; - if (!$ajax_options) - $ajax_options = array('before', 'after', 'condition', 'url', - 'asynchronous', 'method', 'insertion', 'position', - 'form', 'with', 'update', 'script') - + PrototypeHelper::get_callbacks(); - return $ajax_options; - } -} - -/** - * JavaScriptGenerator generates blocks of JavaScript code that allow you to - * change the content and presentation of multiple DOM elements. Use this in - * your Ajax response bodies, either in a <script> tag or as plain JavaScript - * sent with a Content-type of "text/javascript". - * - * @package flexi - * - * @author Marcus Lunzenauer (mlunzena@uos.de) - * @copyright (c) Authors - * @version $Id: prototype_helper.php 3437 2006-05-27 11:38:58Z mlunzena $ - */ - -class Flexi_JavascriptGenerator { - - /** - * internal variables - * @ignore - */ - var $lines = array(); - - /** - * @ignore - */ - function to_s() { - $javascript = implode("\n", $this->lines); - return "try {\n".$javascript."\n} catch (e) { ". - "alert('JS error:\\n\\n' + e.toString()); throw e }"; - } - -################################################################################ -# function [] -# function select -# function draggable -# function drop_receiving -# function sortable -################################################################################ - - /** - * Inserts HTML at the specified 'position' relative to the DOM element - * identified by the given 'id'. - * - * 'position' may be one of: - * - * 'top':: HTML is inserted inside the element, before the - * element's existing content. - * 'bottom':: HTML is inserted inside the element, after the - * element's existing content. - * 'before':: HTML is inserted immediately preceeding the element. - * 'after':: HTML is inserted immediately following the element. - * - * @param type <description> - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function insert_html($position, $id, $content) { - $insertion = TextHelper::camelize($position); - $this->call('new Insertion.'.$insertion, $id, $content); - } - - /** - * Replaces the inner HTML of the DOM element with the given 'id'. - * - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function replace_html($id, $content) { - $this->call('Element.update', $id, $content); - } - - /** - * Replaces the "outer HTML" (i.e., the entire element, not just its - * contents) of the DOM element with the given 'id'. - * - * @param type <description> - * @param type <description> - * - * @return void - */ - function replace($id, $content) { - $this->call('Element.replace', $id, $content); - } - - /** - * Removes the DOM elements with the given 'ids' from the page. - * - * @param type <description> - * - * @return void - */ - function remove($ids) { - $ids = func_get_args(); - $this->record($this->javascript_object_for($ids).".each(Element.remove)"); - } - - /** - * Shows hidden DOM elements with the given 'ids'. - * - * @param type <description> - * - * @return void - */ - function show($ids) { - $ids = func_get_args(); - array_unshift($ids, 'Element.show'); - call_user_func_array(array(&$this, 'call'), $ids); - } - - /** - * Hides the visible DOM elements with the given 'ids'. - * - * @param type <description> - * - * @return void - */ - function hide($ids) { - $ids = func_get_args(); - array_unshift($ids, 'Element.hide'); - call_user_func_array(array(&$this, 'call'), $ids); - } - - /** - * Toggles the visibility of the DOM elements with the given 'ids'. - * - * @param type <description> - * - * @return void - */ - function toggle($ids) { - $ids = func_get_args(); - array_unshift($ids, 'Element.toggle'); - call_user_func_array(array(&$this, 'call'), $ids); - } - - /** - * Displays an alert dialog with the given 'message'. - * - * @param string the given message. - * - * @return void - */ - function alert($message) { - $this->call('alert', $message); - } - - /** - * Redirects the browser to the given 'location'. - * - * @param type <description> - * - * @return void - */ - function redirect_to($location) { - $this->assign('window.location.href', $location); - } - - /** - * Calls the JavaScript 'function', optionally with the given 'arguments'. - * - * @param type <description> - * - * @return void - */ - function call($function) { - $arguments = func_get_args(); - array_shift($arguments); - $this->record($function.'('.$this->arguments_for_call($arguments).')'); - } - - /** - * Assigns the JavaScript 'variable' the given 'value'. - * - * @param type <description> - * @param type <description> - * - * @return void - */ - function assign($variable, $value) { - $this->record($variable.' = '.$this->javascript_object_for($value)); - } - - /** - * Writes raw JavaScript to the page. - * - * @param string the raw JavaScript - * - * @return void - */ - function append($javascript) { - $this->lines[] = $javascript; - } - - /** - * Executes the given javascript after a delay of 'seconds'. - * - * # TODO (mlunzena) this function has side effects and has to be explained or deleted - * - * @param type <description> - * - * @return void - */ - function delay($seconds = 1) { - static $in_delay = FALSE; - - if (!$in_delay) { - $in_delay = TRUE; - $this->record("setTimeout(function() {\n\n"); - } - - else { - $in_delay = FALSE; - $this->record(sprintf("\n}, %d)", $seconds * 1000)); - } - - return $in_delay; - } - - /** - * Starts a script.aculo.us visual effect. See - * ScriptaculousHelper for more information. - * - * @param type <description> - * @param type <description> - * @param type <description> - * - * @return void - */ - function visual_effect($name, $id = FALSE, $js_opt = array()) { - $this->record(ScriptaculousHelper::visual_effect($name, $id, $js_opt)); - } - - /** - * @ignore - */ - function record($line) { - $line = preg_replace('/\;$/', '', rtrim($line)) . ';'; - $this->append($line); - } - - /** - * @ignore - */ - function javascript_object_for($object) { - return json_encode($object); - } - - /** - * @ignore - */ - function arguments_for_call($arguments) { - $mapped = array(); - foreach ($arguments as $argument) - $mapped[] = $this->javascript_object_for($argument); - return join(',', $mapped); - } -} diff --git a/vendor/flexi/lib/helper/scriptaculous_helper.php b/vendor/flexi/lib/helper/scriptaculous_helper.php deleted file mode 100644 index 643ad24..0000000 --- a/vendor/flexi/lib/helper/scriptaculous_helper.php +++ /dev/null @@ -1,142 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -/** - * ScriptaculousHelper. - * - * - * @package flexi - * @subpackage helper - * - * @author Marcus Lunzenauer (mlunzena@uos.de) - * @author David Heinemeier Hansson - * @copyright (c) Authors - * @version $Id: scriptaculous_helper.php 3437 2006-05-27 11:38:58Z mlunzena $ - */ - -class ScriptaculousHelper { - - /** - * Returns a JavaScript snippet to be used on the AJAX callbacks for starting - * visual effects. - * - * Example: - * ScriptaculousHelper::visual_effect('highlight', 'posts', - * array('duration' => 0.5 )); - * - * If no '$element_id' is given, it assumes "element" which should be a local - * variable in the generated JavaScript execution context. This can be used - * for example with drop_receiving_element(): - * - * ScriptaculousHelper::drop_receving_element(..., array(... - * 'loading' => ScriptaculousHelper::visual_effect('fade'))); - * - * This would fade the element that was dropped on the drop receiving element. - * - * You can change the behaviour with various options, see - * http://script.aculo.us for more documentation. - * - * @param type <description> - * @param type <description> - * @param type <description> - * - * @return string <description> - */ - function visual_effect($name, $element_id = FALSE, $js_opt = array()) { - - $element = $element_id ? "'$element_id'" : 'element'; - - switch ($name) { - case 'toggle_appear': - case 'toggle_blind': - case 'toggle_slide': - return sprintf("new Effect.toggle(%s, '%s', %s)", - $element, substr($name, 7), - JsHelper::options_for_javascript($js_opt)); - } - - return sprintf("new Effect.%s(%s, %s)", - TextHelper::camelize($name), - $element, JsHelper::options_for_javascript($js_opt)); - } - - - /** - * Makes the elements with the DOM ID specified by '$element_id' sortable - * by drag-and-drop and make an AJAX call whenever the sort order has - * changed. By default, the action called gets the serialized sortable - * element as parameters. - * - * Example: - * <php echo sortable_element($my_list, array( - * 'url' => '@order', - * )) ?> - * - * In the example, the action gets a '$my_list' array parameter - * containing the values of the ids of elements the sortable consists - * of, in the current order. - * - * You can change the behaviour with various options, see - * http://script.aculo.us for more documentation. - */ - function sortable_element($element_id, $options = array()) { - - if (!isset($options['with'])) - $options['with'] = "Sortable.serialize('$element_id')"; - - if (!isset($options['onUpdate'])) - $options['onUpdate'] = - sprintf('function(){%s}', PrototypeHelper::remote_function($options)); - - foreach (PrototypeHelper::get_ajax_options() as $key) - unset($options[$key]); - - foreach (array('tag', 'overlap', 'constraint', 'handle') as $option) - if (isset($options[$option])) - $options[$option] = "'{$options[$option]}'"; - - if (isset($options['containment'])) - $options['containment'] = self::array_or_string_for_javascript($options['containment']); - - if (isset($options['hoverclass'])) - $options['hoverclass'] = "'{$options['hoverclass']}'"; - - if (isset($options['only'])) - $options['only'] = self::array_or_string_for_javascript($options['only']); - - return JsHelper::javascript_tag( - sprintf("Sortable.create('%s', %s)", - $element_id, JsHelper::options_for_javascript($options))); - } - - - /** - * @ignore - */ - function array_or_string_for_javascript($option) { - if (is_array($option)) { - return "['".join("','", $option)."']"; - } else if ($option) { - return "'$option'"; - } - } -} diff --git a/vendor/flexi/lib/helper/tag_helper.php b/vendor/flexi/lib/helper/tag_helper.php deleted file mode 100644 index 673c5c1..0000000 --- a/vendor/flexi/lib/helper/tag_helper.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -/** - * TagHelper defines some base helpers to construct html tags. - * This is poor man’s Builder for the rare cases where you need to - * programmatically make tags but can’t use Builder. - * - * @package flexi - * @subpackage helper - * - * @author Marcus Lunzenauer (mlunzena@uos.de) - * @author Fabien Potencier <fabien.potencier@symfony-project.com> - * @author David Heinemeier Hansson - * @copyright (c) Authors - * @version $Id: tag_helper.php 3437 2006-05-27 11:38:58Z mlunzena $ - */ - -class TagHelper { - - /** - * Constructs an html tag. - * - * @param $name string tag name - * @param $options array tag options - * @param $open boolean true to leave tag open - * - * @return string - */ - function tag($name, $options = array(), $open = false) { - if (!$name) return ''; - return '<'.$name.TagHelper::_tag_options($options).($open ? '>' : ' />'); - } - - /** - * Helper function for content tags. - * - * @param type <description> - * @param type <description> - * @param type <description> - * - * @return type <description> - */ - function content_tag($name, $content = '', $options = array()) { - if (!$name) return ''; - return '<'.$name.TagHelper::_tag_options($options).'>'.$content.'</'.$name.'>'; - } - - /** - * Helper function for CDATA sections. - * - * @param type <description> - * - * @return type <description> - */ - function cdata_section($content) { - return '<![CDATA['.$content.']]>'; - } - - /** - * @ignore - */ - function _tag_options($options = array()) { - $options = TagHelper::_parse_attributes($options); - $html = ''; - foreach ($options as $key => $value) - $html .= ' '.$key.'="'.$value.'"'; - return $html; - } - - /** - * @ignore - */ - function _parse_attributes($string) { - return is_array($string) ? $string : TagHelper::string_to_array($string); - } - - /** - * <MethodDescription> - * - * @param string <description> - * - * @return array <description> - */ - function string_to_array($string) { - preg_match_all('/ - \s*(\w+) # key \\1 - \s*=\s* # = - (\'|")? # values may be included in \' or " \\2 - (.*?) # value \\3 - (?(2) \\2) # matching \' or " if needed \\4 - \s*(?: - (?=\w+\s*=) | \s*$ # followed by another key= or the end of the string - ) - /x', $string, $matches, PREG_SET_ORDER); - - $attributes = array(); - foreach ($matches as $val) - $attributes[$val[1]] = $val[3]; - - return $attributes; - } -} diff --git a/vendor/flexi/lib/helper/text_helper.php b/vendor/flexi/lib/helper/text_helper.php deleted file mode 100644 index c596727..0000000 --- a/vendor/flexi/lib/helper/text_helper.php +++ /dev/null @@ -1,183 +0,0 @@ -<?php - -# Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -/** - * TextHelper. - * - * - * @package flexi - * @subpackage helper - * - * @author Marcus Lunzenauer (mlunzena@uos.de) - * @copyright (c) Authors - * @version $Id$ - */ - -class TextHelper { - - /** - * Holds the internal cycles. - * - * @ignore - */ - private static $cycles = array(); - - - /** - * Returns a camelized string from a lower case and underscored string by - * replacing slash with underscore and upper-casing each letter preceded - * by an underscore. - * - * @param string String to camelize. - * - * @return string Camelized string. - */ - function camelize($word) { - return str_replace(' ', '', - ucwords(str_replace(array('_', '/'), - array(' ', ' '), $word))); - } - - - /** - * Creates a Cycle object whose +__toString method cycles through elements of - * an array every time it is called. This can be used for example, to - * alternate classes for table rows: - * - * <? foreach ($items as $item) : ?> - * <tr class="<?= TextHelper::cycle('odd', 'even') ?>"> - * <td><?= item ?></td> - * </tr> - * <? endforeach ?> - * - * You can use named cycles to allow nesting in loops. Passing a single array - * as the only parameter with a <tt>name</tt> key will create a named cycle. - * You can manually reset a cycle by calling reset_cycle and passing the - * name of the cycle. - * - * <? foreach($items as $item) : ?> - * <tr class="<?= TextHelper::cycle(array("even", "odd", "name" => "row_class")) ?>"> - * <td> - * <? foreach ($item->values as $value) : ?> - * <span style="color:<?= TextHelper::cycle(array("red", "green", "blue", "name" => "colors")) : ?>"> - * <?= $value ?> - * </span> - * <? endforeach ?> - * <? TextHelper::reset_cycle("colors") ?> - * </td> - * </tr> - * <? endforeach ?> - */ - static function cycle($first_value) { - - $values = func_get_args(); - - - if (sizeof($values) == 1 && is_array($values[0])) { - $values = $values[0]; - $name = isset($values['name']) ? $values['name'] : 'default'; - unset($values['name']); - } - else { - $name = 'default'; - } - - $cycle = self::get_cycle($name); - if (is_null($cycle) || $cycle->values !== $values) { - $cycle = self::set_cycle($name, new TextHelperCycle($values)); - } - - return (string) $cycle; - } - - - /** - * Resets a cycle so that it starts from the first element the next time - * it is called. Pass in +name+ to reset a named cycle. - * - * @param string an optional name of a cycle - * - * @return void - */ - public static function reset_cycle($name = 'default') { - $cycle = self::get_cycle($name); - if (isset($cycle)) { - $cycle->reset(); - } - } - - - /** - * @ignore - */ - private static function get_cycle($name) { - return isset(self::$cycles[$name]) ? self::$cycles[$name] : NULL; - } - - /** - * @ignore - */ - private static function set_cycle($name, $cycle) { - return self::$cycles[$name] = $cycle; - } -} - - -/** - * This class holds an array of string and cycles through them. - * - * @package flexi - * @subpackage helper - * - * @author Marcus Lunzenauer (mlunzena@uos.de) - * @copyright (c) Authors - * @version $Id$ - */ - -class TextHelperCycle { - - - public $values; - - - function __construct($values) { - $this->values = (array) $values; - } - - - function cycle() { - $result = current($this->values); - if (next($this->values) === FALSE) - $this->reset(); - return $result; - } - - - function reset() { - reset($this->values); - } - - - function __toString() { - return $this->cycle(); - } -} |
