function model_control_name($model, $column_name) { $model = is_object($model) ? get_class($model) : $model; return attribute_array_name($model, $column_name); }
function login_form($authenticated = false, $message = null, $redirect = null, $attributes = array()) { if (!$authenticated) { $security_identity_label = moojon_config::get('security_identity_label'); $security_password_label = moojon_config::get('security_password_label'); $security_remember_label = moojon_config::get('security_remember_label'); $security_key = moojon_config::get('security_key'); $security_identity_key = moojon_config::get('security_identity_key'); $security_password_key = moojon_config::get('security_password_key'); $security_remember_key = moojon_config::get('security_remember_key'); if (moojon_security::login_attempt($security_key)) { $security = moojon_request::get($security_key); $security_identity_value = $security[$security_identity_key]; $security_password_value = $security[$security_password_key]; $security_remember_value = $security[$security_remember_key]; } else { $security_remember_value = null; $security_identity_value = null; $security_password_value = null; $security_checked_value = null; } $child = form_tag(null, array('action' => '#', 'method' => 'post')); if ($redirect) { $child->add_child(redirection_tag($redirect)); } if ($message) { $child->add_child(p_tag($message, array('class' => 'error'))); } $fieldset = fieldset_tag(); $fieldset->add_child(label_tag($security_identity_label, $security_identity_key)); $fieldset->add_child(text_input_tag(array('id' => $security_identity_key, 'name' => attribute_array_name($security_key, $security_identity_key), 'value' => $security_identity_value))); $fieldset->add_child(label_tag($security_password_label, $security_password_key)); $fieldset->add_child(password_input_tag(array('id' => $security_password_key, 'name' => attribute_array_name($security_key, $security_password_key), 'value' => $security_password_value))); $div = div_tag(null, array('class' => 'checkbox')); $div->add_child(hidden_input_tag(array('name' => attribute_array_name($security_key, $security_remember_key), 'value' => 0))); $remember_attributes = array('name' => attribute_array_name($security_key, $security_remember_key), 'value' => 1, 'id' => $security_remember_key); if ($security_remember_value) { $remember_attributes['checked'] = 'checked'; } $div->add_child(checkbox_input_tag($remember_attributes)); $div->add_child(label_tag($security_remember_label, $security_remember_key)); $fieldset->add_child($div); $child->add_child($fieldset); $child->add_child(submit_input_tag(array('name' => attribute_array_name($security_key, 'submit'), 'value' => 'Login'))); } else { $child = p_tag('You are logged in.'); } return div_tag($child, array('id' => 'login_div')); }