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; }
public static function redirection($fallback = null) { $redirection = moojon_request::get_or_null(moojon_config::get('redirection_key')); $referer = self::get_or_null('HTTP_REFERER'); if ($redirection) { $return = $redirection; } else { if ($fallback) { $return = $fallback; } else { if ($referer) { $return = $referer; } else { $return = '#'; } } } return $return; }