예제 #1
0
function image_tag($source, $options = array(), $html = false)
{
    $url_path = odContext::getInstance()->get_request("request.initial")->get_referer();
    $url_path .= "/images/" . $source;
    if (!is_array($options)) {
        $options_tab = __transform_string_into_tab($options);
    } else {
        $options_tab = $options;
    }
    $options_tab = array_merge(array("src" => $url_path), $options_tab);
    if (array_key_exists("size", $options_tab)) {
        $size_exploded = explode("x", $options_tab["size"]);
        unset($options_tab["size"]);
        if (isset($size_exploded[0])) {
            $options_tab = array_merge($options_tab, array("width" => $size_exploded[0]));
        }
        if (isset($size_exploded[1])) {
            $options_tab = array_merge($options_tab, array("height" => $size_exploded[1]));
        }
    }
    if ($html) {
        return html_simple_tag("img", $options_tab);
    } else {
        simple_tag("img", $options_tab);
    }
}
예제 #2
0
function l($text, $query = NULL, $attributes = array())
{
    if (0 < preg_match("/^(http|ftp|mailto):/", $query)) {
        $attributes['href'] = $query;
    } else {
        if (substr($query, 0, 1) == '/') {
            $attributes['href'] = $query;
        } else {
            $attributes['href'] = url($query);
        }
    }
    return simple_tag("a", check_form($text), $attributes);
}
예제 #3
0
 function ulist($content, $attributes)
 {
     //global $app;
     $defaultValues = trim($content) == "";
     $name = $attributes["name"];
     $field = array_key_exists("label", $attributes) ? $this->process($attributes["label"]) : "name";
     $selected = array_key_exists("selected", $attributes) ? $this->process($attributes["selected"]) : NULL;
     $result = "";
     $options = Options::parse($attributes["options"]);
     if (array_key_exists("values", $attributes)) {
         $values = explode(";", $attributes["values"]);
         foreach ($values as $value) {
             $data = explode(":", $value);
             $liData = array("id" => $data[0]);
             if ($item->id == $selected) {
                 $liData["class"] = "active";
             }
             $liContent = strtolower($options["addlinks"]) == "true" ? link_tag($data[1], "#") : $data[1];
             $result .= simple_tag("li", $liContent, $liData);
         }
     }
     if (array_key_exists("collection", $attributes)) {
         if ($defaultValues) {
             $collection = $this->data->get($attributes["collection"]);
             if (is_array($collection)) {
                 foreach ($collection as $item) {
                     //$field = (isset($item->name)) ? "name" : "name_".$app->language;
                     //echo $item->name_sp;
                     if (!property_exists($item, $field) && $item->__use_language__) {
                         $field .= "_" . $this->data->get("language")->id;
                     }
                     $label = $item->{$field};
                     //$result .= option_tag($item->$field,$item->id,($item->id==$selected));
                     $liData = array("id" => $item->id);
                     if ($item->id == $selected) {
                         $liData["class"] = "active";
                     }
                     $liContent = strtolower($options["addlinks"]) == "true" ? link_tag($item->{$field}, "#") : $item->{$field};
                     $result .= simple_tag("li", $liContent, $liData);
                 }
             }
         } else {
             $this->data->setTemporal("selected", $selected);
             $result .= $this->loop($content, $attributes);
             $this->data->clear("selected");
         }
     }
     $select = simple_tag("ul", $result, $options);
     return $select;
 }
예제 #4
0
function span_tag($content, $options)
{
    return simple_tag("span", $content, $options);
}