function simple_tag($name, $options = null) { echo sprintf("<%s", $name); foreach ($options as $key => $value) { __echo_property($key, $value); } echo "/>"; }
function link_to($content, $route, $options = array()) { $format = "<a href='%s'"; if (strtolower(substr($route, 0, 11)) == "javascript:" or strtolower(substr($route, 0, 7)) == "mailto:") { echo sprintf($format, $route); } else { //echo sprintf($format, make_url($route, isset($options["absolute"]) ? $options["absolute"] : true)); $request_referer = odContext::getInstance()->get_request("request.initial")->get_referer(); //echo $request_referer; echo sprintf($format, $request_referer . "/" . $route); } if (is_array($options)) { if (isset($options["confirm"])) { __echo_property("onclick", sprintf("return confirm(\"%s\");", str_replace("_", " ", $options["confirm"]))); } if (isset($options["popup"])) { if (is_array($options["popup"])) { if (count($options["popup"]) != 2) { // Lever une exception throw new odException('The popup option parameter must be contain 2 entries in link_to helper.'); } else { __echo_property("onclick", sprintf("window.open(this.href,\"%s\",\"%s\");return false;", $options["popup"][0], $options["popup"][1])); } } else { __echo_property("onclick", "window.open(this.href);return false;"); } } if (isset($options["class"])) { __echo_property("class", $options["class"]); } if (isset($options["style"])) { __echo_property("style", $options["style"]); } if (isset($options["target"])) { __echo_property("target", $options["target"]); } if (isset($options["id"])) { __echo_property("id", $options["id"]); } } else { __echo_properties($options); } $format = ">%s</a>"; echo sprintf($format, $content); }