protected function __construct() { require_once MOOJON_DIRECTORY . '/classes/moojon.exception.class.php'; require_once MOOJON_DIRECTORY . '/classes/moojon.config.class.php'; require_once MOOJON_DIRECTORY . '/classes/moojon.files.class.php'; require_once MOOJON_DIRECTORY . '/classes/moojon.paths.class.php'; require_once MOOJON_DIRECTORY . '/classes/moojon.base.cli.class.php'; require_once MOOJON_DIRECTORY . '/classes/moojon.cli.class.php'; require_once MOOJON_DIRECTORY . '/functions/moojon.core.functions.php'; switch (strtoupper(UI)) { case 'CGI': ini_set('memory_limit', '256M'); $uri = moojon_uri::get_uri(); moojon_config::update(moojon_paths::get_project_config_environment_app_directory(ENVIRONMENT, APP)); echo self::render_app($uri); break; case 'CLI': moojon_config::get_data(); $cli_class = CLI; new $cli_class(); break; default: throw new moojon_exception('Invalid UI (' . UI . ')'); break; } }
function get_member_uri(moojon_base_model $model) { $route = get_collection_rest_route($model); $id_property = $route->get_id_property(); $current_uri = moojon_uri::get_uri(); //die(moojon_uri::reparse(array($id_property => $model->$id_property))); $table_slash_id_slash = $model->get_table() . '/' . $model->{$id_property} . '/'; $position = strpos($current_uri, $table_slash_id_slash); if ($position !== false) { return substr($current_uri, 0, $position + strlen($table_slash_id_slash)); } else { $collection_uri = get_collection_uri($model); //Need to test belongs_to exception $id_property_uri = substr($collection_uri, 0 - strlen($model->{$id_property} . '/')) == $model->{$id_property} . '/' ? '' : $model->{$id_property} . '/'; return $collection_uri . $id_property_uri; } }
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; }