Example #1
0
function file_tag(moojon_base_model $model, moojon_base_column $column, $attributes = array())
{
    $column_name = $column->get_name();
    $value = $column->get_value();
    $return = div_tag();
    $return->add_child(hidden_input_tag(array('name' => model_control_name($model, $column_name), 'value' => $value)));
    $return->add_child(label_tag(title_text($column_name) . ':', $column_name));
    $attributes = try_set_name_and_id_attributes($attributes, $model, $column);
    $attributes['class'] = 'file';
    $return->add_child(file_input_tag($attributes));
    if (!$column->get_null() && $value) {
        $return->add_child(uploaded_file_tag($model, $column_name));
        $attributes['id'] = "clear_{$column_name}";
        $attributes['name'] = model_control_name($model, "clear_{$column_name}");
        $attributes['class'] = 'checkbox';
        $attributes['value'] = 1;
        $return->add_child(label_tag(title_text("Clear {$column_name}") . ':', "clear_{$column_name}"));
        $return->add_child(checkbox_input_tag($attributes));
    }
    return $return;
}
Example #2
0
function rest_breadcrumb($attributes = array())
{
    $attributes = try_set_attribute($attributes, 'class', 'breadcrumb');
    $segments = explode('/', moojon_uri::get_match_pattern());
    if ($segments[0] == APP) {
        array_shift($segments);
    }
    $count = count($segments);
    $ul = ul_tag();
    $href = '/';
    for ($i = 0; $i < $count; $i++) {
        $segment = $segments[$i];
        $attributes = $i == $count - 1 ? array('class' => 'last') : array();
        $link = true;
        if (moojon_base::is_symbol($segment)) {
            $symbol_name = moojon_base::get_symbol_name($segment);
            $href .= moojon_request::get($symbol_name) . '/';
            if ($symbol_name != moojon_primary_key::NAME) {
                if (moojon_paths::get_model_path($segment)) {
                    $content = model_from_symbol($segment);
                }
            } else {
                $content = model_from_id($segments[$i - 1]);
            }
        } else {
            if ($i == $count - 1) {
                $link = true;
            }
            $content = title_text($segment);
            $href .= $segment . '/';
        }
        if ($content) {
            if ($i == $count - 1) {
                $ul->add_child(li_tag($content, $attributes));
            } else {
                $ul->add_child(li_tag(a_tag($content, $href), $attributes));
            }
        }
    }
    return div_tag($ul, $attributes);
}
Example #3
0
 function flash($content, $data, $attributes)
 {
     $options = Options::parse($attributes["options"]);
     //TemplateLogic::getOptions($attributes["options"]);
     $options["class"] = array_key_exists("type", $attributes) ? $attributes["type"] : "error";
     $options["id"] = array_key_exists("name", $attributes) ? $attributes["name"] : "error";
     //$options["style"] = "margin: -15px 0px 0px;";
     return div_tag($content, $options) . "<script type=\"text/javascript\">var mySlide = new Fx.Slide('" . $options["id"] . "');mySlide.hide();</script>";
 }
Example #4
0
function datetime_select_options($attributes = null, $format = null, $selected = null, $start = null, $end = null, $label = false)
{
    if (!$format) {
        $format = moojon_config::get('datetime_format');
    }
    $return = div_tag(null, array('class' => 'datetime'));
    $attributes = try_set_attribute($attributes, 'name', 'datetime_select');
    $attributes = try_set_attribute($attributes, 'id', $attributes['name']);
    for ($i = 0; $i < strlen($format) + 1; $i++) {
        $select = null;
        $select_attributes = $attributes;
        $f = substr($format, $i, 1);
        $select_attributes['name'] = $attributes['name'] . "[{$f}]";
        if ($i) {
            $select_attributes['id'] = $attributes['id'] . "_{$f}";
        } else {
            $select_attributes['id'] = $attributes['id'];
        }
        switch ($f) {
            case 'Y':
            case 'y':
                $select = year_select_options($start, $end, $select_attributes, $selected, $f);
                $label_text = 'Year';
                break;
            case 'm':
            case 'n':
                $select = month_select_options($select_attributes, $selected, $f);
                $label_text = 'Month';
                break;
            case 'd':
            case 'j':
                $select = day_select_options($select_attributes, $selected, $f);
                $label_text = 'Day';
                break;
            case 'G':
            case 'H':
                $select = hour_select_options($select_attributes, $selected, $f);
                $label_text = 'Hour';
                break;
            case 'i':
                $select = minute_select_options($select_attributes, $selected);
                $label_text = 'Minute';
                break;
            case 's':
                $select = second_select_options($select_attributes, $selected);
                $label_text = 'Second';
                break;
        }
        if ($select) {
            if ($label) {
                $return->add_child(label_tag("{$label_text}:", $select_attributes['id']));
            }
            $return->add_child($select);
        }
    }
    return $return;
}