Example #1
0
 protected static function factory($class)
 {
     if (!self::$instance) {
         self::$instance = new $class();
     }
     return self::$instance;
 }
 public function login()
 {
     $this->authenticated = moojon_security::authenticate();
     if ($this->authenticated && moojon_server::is_post()) {
         moojon_flash::set('notification', moojon_config::get('security_login_message'));
         $this->redirect(moojon_server::get('PHP_SELF'));
     }
 }
Example #3
0
 public function get_layout()
 {
     if ($this->layout === false) {
         return false;
     } elseif ($this->layout != null) {
         return $this->layout;
     } else {
         return moojon_server::is_ajax() ? false : self::get_app_name($this);
     }
 }
 protected function init()
 {
     $this->actions = array_key_exists('actions', $this->params) ? $this->params['actions'] : array('index', '_new', 'show', 'edit', 'delete', 'update', 'create', 'destroy');
     $this->resource = moojon_inflect::pluralize($this->pattern);
     $this->params['resource'] = $this->resource;
     $this->app = array_key_exists('app', $this->params) ? $this->params['app'] : moojon_config::get_or_null('default_app');
     $this->params['app'] = $this->app;
     $this->params['controller'] = array_key_exists('controller', $this->params) ? $this->params['controller'] : $this->resource;
     $this->id_property = array_key_exists('id_property', $this->params) ? $this->params['id_property'] : moojon_primary_key::NAME;
     $this->method = strtolower(moojon_server::method());
     $this->custom_collection_routes = array_key_exists('custom_collection_routes', $this->params) ? $this->params['custom_collection_routes'] : array();
     $this->custom_member_routes = array_key_exists('custom_member_routes', $this->params) ? $this->params['custom_member_routes'] : array();
     $model_class = moojon_inflect::singularize($this->pattern);
     $model = new $model_class();
     $this->relationship_routes = $model->get_relationship_names();
 }
Example #5
0
function belongs_to_tag(moojon_model_collection $models = null, moojon_base_model $model, moojon_base_column $column, moojon_base_relationship $relationship, $attributes = array())
{
    $return = false;
    $name = $column->get_name();
    $attributes = try_set_name_and_id_attributes($attributes, $model, $column);
    $foreign_key = $relationship->get_foreign_key();
    $key = $relationship->get_key();
    $return = div_tag();
    if ($value = moojon_request::get_or_null($name)) {
        $return->add_child(redirection_tag(moojon_server::redirection()));
        if ($foreign_key_value = moojon_request::get_or_null($foreign_key)) {
            $value = $foreign_key_value;
        } else {
            if ($model->{$key} == $value) {
                $value = 0;
            }
        }
    } else {
        $value = 0;
    }
    $attributes['value'] = $value;
    $return->add_child(hidden_input_tag($attributes));
    return $return;
}
Example #6
0
 public static function login_attempt($security_key)
 {
     return moojon_server::is_post() && moojon_post::has($security_key);
 }
Example #7
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')));
    }
}