Example #1
0
function actions_ul($actions = array(), $attributes = array())
{
    if (!is_array($actions)) {
        $actions = array($actions);
    }
    $children = array();
    foreach ($actions as $action) {
        $children[] = li_tag($action);
    }
    $attributes = try_set_attribute($attributes, 'class', 'actions');
    return ul_tag($children, $attributes);
}
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 paginator_ul($records, $limit = null, $page_symbol_name = null, $limit_symbol_name = null, $attributes = array())
{
    if (!is_integer($records)) {
        $records = count($records);
    }
    $limit_symbol_name = $limit_symbol_name ? $limit_symbol_name : moojon_config::get('paginator_limit_symbol_name');
    if (!$limit) {
        $limit = moojon_request::has($limit_symbol_name) ? moojon_request::get($limit_symbol_name) : moojon_config::get('paginator_limit');
    }
    if ($records > $limit) {
        $page_symbol_name = $page_symbol_name ? $page_symbol_name : moojon_config::get('paginator_page_symbol_name');
        $page = moojon_request::has($page_symbol_name) ? moojon_request::get($page_symbol_name) : 1;
        $page = $page < 1 ? 1 : (int) $page;
        $children = array();
        $params = moojon_get::get_data();
        $get = $params;
        if (array_key_exists($limit_symbol_name, $get)) {
            $get[$limit_symbol_name] = $limit;
        }
        $get[$page_symbol_name] = ":{$page_symbol_name}";
        foreach ($get as $key => $value) {
            $get[$key] = "{$key}={$value}";
        }
        $querystring = moojon_uri::get_uri() . '?' . implode('&', $get);
        for ($i = 1; $i < ceil($records / $limit) + 1; $i++) {
            $params[$page_symbol_name] = $i;
            $attributes = $i == $page ? array('class' => 'selected') : array();
            $children[] = li_tag(a_tag($i, moojon_base::parse_symbols($querystring, $params), $attributes));
        }
        $return = ul_tag($children);
    } else {
        $return = '';
    }
    return $return;
}