"; $observe .= "Event.observe($source_txt,'$method',function(e){" . $action . ";});"; $observe .= ""; return $observe; } // observe /** * action * This takes the action, the source and the post (if passed) and generated the full * ajax link */ public static function action($action,$source,$post='') { $url = Config::get('ajax_url') . $action; $non_quoted = array('document','window'); 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; } // 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='') { // Get the correct action $ajax_string = self::action($action,$source,$post); // If they passed a span class if ($class) { $class_txt = ' class="' . $class . '"'; } $string = get_user_icon($icon,$alt); // Generate a so that it's more compliant with older browsers // (ie :hover actions) and also to unify linkbuttons (w/o ajax) display $string = "".$string."\n"; $string .= self::observe($source,'click',$ajax_string); return $string; } // button /** * text * This prints out the specified text as a link and setups 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); // If they passed a span class if ($class) { $class_txt = ' class="' . $class . '"'; } // If we pass a source put it in the ID $string = "$text\n"; $string .= self::observe($source,'click',$ajax_string); return $string; } // text /** * run * This runs the specified action no questions asked */ public static function run($action) { echo ""; } // run /** * set_include_override * This sets the cinlduing div override, used only one place kind of a hack */ public static function set_include_override($value) { self::$include_override = make_bool($value); } // set_include_override /** * start_container * This checks to see if we're AJAX'in if we aren't then it echos out the * html needed to start a container that can be replaced by Ajax */ public static function start_container($name) { if (AJAX_INCLUDE == '1' AND !self::$include_override) { return true; } echo '
'; } // start_container /** * end_container * This ends the container if we're not doing the AJAX thing */ public static function end_container() { if (AJAX_INCLUDE == '1' AND !self::$include_override) { return true; } echo "
"; self::$include_override = false; } // end_container } // end Ajax class ?>