示例#1
0
function uploaded_file_tag(moojon_base_model $model, $column_name, $mime_type_column = null)
{
    $value = $model->{$column_name};
    if ($value) {
        if (!$mime_type_column) {
            $mime_type_column = $column_name . '_' . moojon_config::get('mime_type_column');
        }
        $mime_type = $model->has_column($mime_type_column) ? $model->{$mime_type_column} : moojon_files::get_mime_content_type($value);
        $path = moojon_paths::get_public_column_upload_path($model, $column_name);
        if (substr($mime_type, 0, 5) == 'image') {
            $content = img_tag($path, $model);
        } else {
            $content = $path;
        }
        return a_tag($content, $path, array('target' => '_blank'));
    } else {
        return p_tag('Not set');
    }
}
示例#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);
}
示例#3
0
function back_button($value = 'Back', $attributes = array())
{
    if (moojon_server::has('HTTP_REFERER')) {
        $attributes = try_set_attribute($attributes, 'class', 'cancel');
        return a_tag($value, array('href' => moojon_server::get('HTTP_REFERER')));
    }
}