diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 03:00:32 -0500 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 03:38:46 -0500 |
commit | ef4d3660605efc7f1328d4533b0f4bfb6c1107e2 (patch) | |
tree | e4377fb129a899e65aaaf421f8c97098aecaedd5 /lib/class/ajax.class.php | |
parent | 8a750c3e875d590d351c3042570a134fcdf03e5d (diff) | |
download | ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.tar.gz ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.tar.bz2 ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.zip |
Cosmetics: death to tabs
The refactoring I've been doing has reminded me of my strong preference
for spaces, and I feel inclined to impose my will on the tree.
Diffstat (limited to 'lib/class/ajax.class.php')
-rw-r--r-- | lib/class/ajax.class.php | 270 |
1 files changed, 135 insertions, 135 deletions
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php index 04098861..e19301bf 100644 --- a/lib/class/ajax.class.php +++ b/lib/class/ajax.class.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -30,185 +30,185 @@ */ class Ajax { - private static $include_override; + private static $include_override; - /** - * constructor - * This is what is called when the class is loaded - */ - public function __construct() { + /** + * constructor + * This is what is called when the class is loaded + */ + public function __construct() { - // Rien a faire + // Rien a faire - } // constructor - - /** - * observe - * This returns a string with the correct and full ajax 'observe' stuff - * from prototype - */ - public static function observe($source,$method,$action,$post='') { - - $non_quoted = array('document','window'); + } // constructor + + /** + * observe + * This returns a string with the correct and full ajax 'observe' stuff + * from prototype + */ + public static function observe($source,$method,$action,$post='') { + + $non_quoted = array('document','window'); - if (in_array($source,$non_quoted)) { - $source_txt = $source; - } - else { - $source_txt = "'$source'"; - } + if (in_array($source,$non_quoted)) { + $source_txt = $source; + } + else { + $source_txt = "'$source'"; + } - // If it's a post then we need to stop events - if ($post) { - $action = 'Event.stop(e); ' . $action; - } + // If it's a post then we need to stop events + if ($post) { + $action = 'Event.stop(e); ' . $action; + } - $observe = "<script type=\"text/javascript\">"; - $observe .= "Event.observe($source_txt,'$method',function(e){" . $action . ";});"; - $observe .= "</script>"; + $observe = "<script type=\"text/javascript\">"; + $observe .= "Event.observe($source_txt,'$method',function(e){" . $action . ";});"; + $observe .= "</script>"; - return $observe; + return $observe; - } // observe + } // observe - /** - * url - * This takes a string and makes an URL - */ - public static function url($action) { - return Config::get('ajax_url') . $action; - } + /** + * url + * This takes a string and makes an URL + */ + public static function url($action) { + return Config::get('ajax_url') . $action; + } - /** - * action - * This takes the action, the source and the post (if passed) and - * generates the full ajax link - */ - public static function action($action,$source,$post='') { + /** + * action + * This takes the action, the source and the post (if passed) and + * generates the full ajax link + */ + public static function action($action,$source,$post='') { - $url = self::url($action); + $url = self::url($action); - $non_quoted = array('document','window'); + $non_quoted = array('document','window'); - if (in_array($source,$non_quoted)) { - $source_txt = $source; - } - else { - $source_txt = "'$source'"; - } + if (in_array($source,$non_quoted)) { + $source_txt = $source; + } + else { + $source_txt = "'$source'"; + } - if ($post) { - $ajax_string = "ajaxPost('$url','$post',$source_txt)"; - } - else { - $ajax_string = "ajaxPut('$url',$source_txt)"; - } - - return $ajax_string; + if ($post) { + $ajax_string = "ajaxPost('$url','$post',$source_txt)"; + } + else { + $ajax_string = "ajaxPut('$url',$source_txt)"; + } + + return $ajax_string; - } // action + } // action - /** - * button - * This prints out an img of the specified icon with the specified alt - * text and then sets up the required ajax for it. - */ - public static function button($action,$icon,$alt,$source='',$post='',$class='') { + /** + * button + * This prints out an img of the specified icon with the specified alt + * text and then sets up the required ajax for it. + */ + public static function button($action,$icon,$alt,$source='',$post='',$class='') { - // Get the correct action - $ajax_string = self::action($action,$source,$post); + // Get the correct action + $ajax_string = self::action($action,$source,$post); - // If they passed a span class - if ($class) { - $class = ' class="' . $class . '"'; - } + // If they passed a span class + if ($class) { + $class = ' class="' . $class . '"'; + } - $string = UI::get_icon($icon,$alt); + $string = UI::get_icon($icon,$alt); - // Generate an <a> so that it's more compliant with older - // browsers (ie :hover actions) and also to unify linkbuttons - // (w/o ajax) display - $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>".$string."</a>\n"; + // Generate an <a> so that it's more compliant with older + // browsers (ie :hover actions) and also to unify linkbuttons + // (w/o ajax) display + $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>".$string."</a>\n"; - $string .= self::observe($source,'click',$ajax_string); + $string .= self::observe($source,'click',$ajax_string); - return $string; + return $string; - } // button + } // button - /** - * text - * This prints out the specified text as a link and sets up the required - * ajax for the link so it works correctly - */ - public static function text($action,$text,$source,$post='',$class='') { + /** + * text + * This prints out the specified text as a link and sets up the required + * ajax for the link so it works correctly + */ + public static function text($action,$text,$source,$post='',$class='') { - // Format the string we wanna use - $ajax_string = self::action($action,$source,$post); + // Format the string we wanna use + $ajax_string = self::action($action,$source,$post); - // If they passed a span class - if ($class) { - $class = ' class="' . $class . '"'; - } + // If they passed a span class + if ($class) { + $class = ' class="' . $class . '"'; + } - // If we pass a source put it in the ID - $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>$text</a>\n"; + // If we pass a source put it in the ID + $string = "<a href=\"javascript:void(0);\" id=\"$source\" $class>$text</a>\n"; - $string .= self::observe($source,'click',$ajax_string); + $string .= self::observe($source,'click',$ajax_string); - return $string; + return $string; - } // text + } // text - /** - * run - * This runs the specified action no questions asked - */ - public static function run($action) { + /** + * run + * This runs the specified action no questions asked + */ + public static function run($action) { - echo "<script type=\"text/javascript\"><!--\n"; - echo "$action"; - echo "\n--></script>"; + echo "<script type=\"text/javascript\"><!--\n"; + echo "$action"; + echo "\n--></script>"; - } // run + } // run - /** - * set_include_override - * This sets the including div override, used only one place. Kind of a - * hack. - */ - public static function set_include_override($value) { + /** + * set_include_override + * This sets the including div override, used only one place. Kind of a + * hack. + */ + public static function set_include_override($value) { - self::$include_override = make_bool($value); + self::$include_override = make_bool($value); - } // set_include_override + } // set_include_override - /** - * start_container - * This checks to see if we're AJAXin'. If we aren't then it echoes out - * the html needed to start a container that can be replaced by Ajax. - */ - public static function start_container($name) { + /** + * start_container + * This checks to see if we're AJAXin'. If we aren't then it echoes out + * the html needed to start a container that can be replaced by Ajax. + */ + public static function start_container($name) { - if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; } + if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; } - echo '<div id="' . scrub_out($name) . '">'; + echo '<div id="' . scrub_out($name) . '">'; - } // start_container + } // start_container - /** - * end_container - * This ends the container if we're not doing the AJAX thing - */ - public static function end_container() { + /** + * end_container + * This ends the container if we're not doing the AJAX thing + */ + public static function end_container() { - if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; } + if (defined('AJAX_INCLUDE') && !self::$include_override) { return true; } - echo "</div>"; + echo "</div>"; - self::$include_override = false; + self::$include_override = false; - } // end_container + } // end_container } // end Ajax class ?> |