Mai
07
2008
0

Kleine Helfer

Hin und wieder möchte man übergebene Werte gleich als Session-Variablen speichern... hab mir hierfür 'ne kleine Helferfunktion geschrieben, welche mit Hilfe der hier schon einmal vorgestellten get_var()-Funktion genau das durchführt, oder `false´ zurückgibt.

  1. /**
  2.  * Checks if a Variable is submitted, and if so, puts it as session var
  3.  * if $allowed_values -> checks if value is allowed to be set
  4.  *
  5.  * @param string $var
  6.  * @param array $allowed_values
  7.  * @return bool
  8.  */
  9. function check_and_set_session_var($var, $allowed_values = NULL) {
  10. $do = false;
  11. if (get_var($var)) {
  12. if (is_array($allowed_values)) {
  13. if (in_array(get_var($var),$allowed_values)) {
  14. $do = true;
  15. }
  16. } else {
  17. $do = true;
  18. }
  19. }
  20. if ($do === true) {
  21. $_SESSION[$var] = get_var($var);
  22. return true;
  23. } else {
  24. return false;
  25. }
  26. }

Auch ganz hilfreich ist vielleicht der folgende Einzeiler, der 'nen Link auf eine URL erstellt und eventuell übergebene Parameter anhängt:

  1. /**
  2.  * Create a simple link with some parameters
  3.  *
  4.  * @param array $param
  5.  * @param string $url
  6.  * @return string
  7.  */
  8. function c_link($param = NULL, $url = 'index.php') {
  9. return $url . ((is_array($param) != '') ? '?' . join('&',$param) : NULL);
  10. }
  11.  

Die Parameter in der Form array("parameter=wert", "parameter2=wert") übergeben werden, vll. baue ich auch noch eine Prüfung ein, ob das übergebene Array überhaupt als GET angehängt werden kann.

Written by in: PHP,Snippets | Schlagwörter: , , ,
Mai
06
2008
42

Workaround (area rel) for Lightbox using Firefox

Hi folks,

This post is kept in English, because of some users in the Lighbox forum (Thread) having the same problem.

Bug description
Using Lightbox 2.04 with area tags an rel="lightbox" or rel="lightbox[Group]" in Firefox will result in a java-script error.

Reason for the Bug:
rel is not an attribute of area neither in HTML 4 (see http://www.w3.org/TR/html4/index/attributes.html) nor in XHTML 1.0 Strict/Transitional (see http://www.w3.org/TR/xhtml1/#defs and take a look at the DTS..).
Consequence: imageLink.rel doesn't work with Firefox.

Workaround:
But Prototype is still able to get the attribute :)
So just replace imageLink.rel with Element.readAttribute($(imageLink), "rel") and enjoy Lightbox!

Powered by WordPress | Theme: Aeros 2.0 by TheBuckmaker.com