/** * * @global type $smarty * @param type $edit_id */ public function prepareFieldsOfAd() { $view = $this->view; $view->assign('lesson_number', 16); $view->assign('organization_form', array('0' => 'Частное лицо', '1' => 'Организация')); $view->assign('cities', City::get_column_values('name')); $view->assign('labels', Category::find_all_categories()); $view->assign('subcategories', Category::get_array_of_subcategories()); $view->assign('ad_person', 'Ваше имя'); }
<?php header("Content-Type: text/html; charset=utf-8"); require_once './includes/initialize.php'; function __autoload($class_name) { if ($class_name != 'DbSimple_Mysqli' && $class_name != 'Smarty') { require_once CLASS_PATH . '/class.' . $class_name . '.php'; } } $smarty->assign('lesson_number', 10); $smarty->assign('organization_form', array('0' => 'Частное лицо', '1' => 'Организация')); $smarty->assign('cities', City::get_column_values('name')); $smarty->assign('labels', Category::find_all_categories()); $smarty->assign('subcategories', Category::get_array_of_subcategories()); $object_storage = Ad::find_all(); $edit_id = ''; if (request_is_post()) { $tmp_post = $_POST; //escape POST array; can be more complex foreach ($tmp_post as $key => $value) { $tmp_post[$key] = strip_tags($value); } //checking checkbox. if it's not checked then there is no value in POST array if (!isset($tmp_post['allow_mails'])) { $tmp_post['allow_mails'] = ""; } $ad = Ad::build($tmp_post); //create new object $ad->save(); //save object in database