function action_index($language, $text) { if (isset($_POST['call'])) { if (!empty($_POST['name_people']) && !empty($_POST['tel_people']) && !empty($_POST['keystring'])) { if (isset($_SESSION['captcha_keystring']) && strtolower($_SESSION['captcha_keystring']) == strtolower($_POST['keystring'])) { $this->model->call($_POST['name_people'], $_POST['tel_people'], $_POST['comment_people']); } else { echo '<p style="color:#ff0f0f;">Ошибка - неправильный ввод числа</p>'; } } else { echo '<p style="color:#ff0f0f;">Вы не заполнили обязательные поля</p>'; } } $data = Model::get_data($language, 'call'); $this->view->generate('call_view.php', 'template_view.php', $language, $text, $data); }
public function action_login($language, $text, $id) { if (isset($_FILES)) { $files = $_FILES; } if (isset($_POST)) { $post = $_POST; } if (isset($post['submitt']) && $files['file']['error'] == 0) { $this->model->action_upload($files, $post); echo "<script language='JavaScript'>window.location.pathname = '/" . $language . "/main/login'</script>"; } if (!empty($id)) { $view_user = $this->model->view_user($id); } $adir = $this->model->view_description(); $data = Model::get_data($language, 'main/login'); $users = $this->model->all_users(); if (isset($_SESSION['login'])) { $this->view->generate('login_view.php', 'template_view.php', $language, $text, $data, $adir, $users, $view_user); } else { $this->view->generate('login_panel_view.php', 'template_view.php', $language, $text, $data, $adir, $users, $view_user); } }
function action_contacts($language, $text) { $data = Model::get_data($language, 'about/contacts'); $this->view->generate('contacts_view.php', 'template_view.php', $language, $text, $data); }
function action_door5($language, $text) { $data = Model::get_data($language, 'production/door5'); $this->view->generate('door1_view.php', 'template_view.php', $language, $text, $data); }
function action_warranty($language, $text) { $data = Model::get_data($language, 'services/warranty'); $this->view->generate('warranty_view.php', 'template_view.php', $language, $text, $data); }
function action_tel($language, $text) { $data = Model::get_data($language, 'action/tel'); $this->view->generate('tel_view.php', 'template_view.php', $language, $text, $data); }
function action_more($language, $text) { $data = Model::get_data($language, 'complectation/more'); $this->view->generate('more_view.php', 'template_view.php', $language, $text, $data); }
public function edit() { $id = Core::get_args(2) && is_int(intval(Core::get_args(2))) ? Core::get_args(2) : false; if ($id !== false) { /** Load the model */ $model = Model::load($this->model); /** Determine the primary key and retrieve the record */ $primary_key = $model->getPrimaryKey(); $result = $model->get(array('where' => array($primary_key => $id))); $result = is_array($result) ? array_shift($result) : $result; /** Determine the permission value give the controller, method, user and model entry */ $user_ctrl = Controller::load('user'); $auth = $user_ctrl->auth($this->name, 'edit', null, $result); /** Ensure the user has permission to perform with operation */ if ($auth) { /** We were not able to find a matching record so declare 404 status. */ if ($result === false) { /** @TODO Make this go to an entry not found error page or flag it for 404 to describe */ Core::error('404'); } elseif (!$_POST) { /** Load the schema and populate it with the retrieved values */ $schema = $model->set_data($model->getSchema(), $result); /** Populate the form and present it */ Core::set_response($model->form($schema)); Core::display(); } else { /** Get a copy of the model's schema */ $schema = $model->getSchema(); /** Remove disabled fields from the form */ foreach ($schema as $key => $val) { if ($val['disabled']) { unset($schema[$key]); } } /** Load the validate controller */ $validate = Controller::load('validate'); /** The data validates, attempt to edit the item. */ if ($validate->fields($_POST, $schema)) { $data = Model::get_data($schema); /** Determine fields we never want to update */ $final_set = array(); foreach ($schema as $key => $val) { if (in_array('final', array_keys($val))) { $final_set[] = $key; } } $final_set[] = $primary_key; /** Remove any unset or protected fields to prevent accidental overwrite */ $set = array(); foreach ($data as $key => $val) { if (isset($val) && $val != '' && !in_array($key, $final_set)) { $set[$key] = $val; } } /** Build the set query */ $query = array(); $query['set'] = $set; $query['where'] = array($primary_key => $id); $query['entry'] = $result; /** Perform the update */ $result = $model->set($query); /** One or more unique fields were detected in the db */ if (is_array($result)) { /** Flag the offenders with an error message. */ foreach ($result as $key => $val) { if (!$val) { $schema[$key]['error'] = 'This ' . $schema[$key]['label'] . ' is already in use.'; } } /** Display the annotated form data */ Core::set_response($model->form($schema)); Core::display(); } elseif ($result) { header('Location: ' . Core::url('/' . $this->name . '/view')); } else { header('Location: ' . Core::url('/' . $this->name . '/error')); } } else { Core::set_response($model->form($schema)); Core::display(); } } } else { Core::error('403'); } } else { Core::error('404'); } }
public function testInitFromArrayWithoutId() { $r = new Model(array('test_attr2' => 6.0, 'test_attr1' => 4)); $data = $r->get_data(); $this->assertSame(1, $data['prim']); $this->assertSame(4, $data['test_attr1']); $this->assertSame(6.0, $data['test_attr2']); $this->assertSame('foo', $data['test_attr3']); $this->assertArrayNotHasKey('inactive', $data, 'removes the `inactive` attribute'); }
function action_corp($language, $text) { $data = Model::get_data($language, 'cooperation/corp'); $this->view->generate('corp_view.php', 'template_view.php', $language, $text, $data); }
function action_art6($language, $text) { $data = Model::get_data($language, 'press/art6'); $this->view->generate('art6_view.php', 'template_view.php', $language, $text, $data); }