/** */ function edit() { $_GET['id'] = intval($_GET['id']); // Do save data if (!empty($_POST)) { // Position could not be empty if (empty($_POST['ad'])) { _re('Place is empty'); } // Content html could not be empty if (empty($_POST['html'])) { _re('Html is empty'); } if (!_ee()) { return $this->save(); } } $info = db()->query_fetch('SELECT * FROM ' . db('advertising') . ' WHERE id=' . $_GET['id']); $editor = db()->query_fetch('SELECT * FROM ' . db('sys_admin') . ' WHERE id=' . $info['edit_user_id']); $replace = ['form_action' => './?object=' . $_GET['object'] . '&action=' . $_GET['action'] . '&id=' . $_GET['id'], 'ad' => $info['ad'], 'editor' => $editor['first_name'] . ' ' . $editor['last_name'], 'edit_date' => date('d/m/Y', $info['edit_date']), 'customer' => $info['customer'], 'date_start' => $info['date_start'] ? $info['date_start'] : time(), 'date_end' => $info['date_end'] ? $info['date_end'] : time(), 'cur_date' => time(), 'html' => stripslashes($info['html']), 'active' => $info['active'], 'error_message' => _e(), 'back_link' => './?object=' . $_GET['object'] . '&action=listing']; return form2($replace)->info('ad', 'Placeholder')->info('editor', 'Last editor')->info('edit_date', 'Edit date')->text('customer', 'Customer')->text('ad', 'Placeholder')->textarea('html', 'Content')->date_box('date_start', '', ['desc' => 'Date start'])->date_box('date_end', '', ['desc' => 'Date end'])->active_box()->save_and_back(); }
/** */ function edit_var() { $_GET['id'] = trim($_GET['id']); // Try to find numeric id for the given string var if (!empty($_GET['id']) && !is_numeric($_GET['id'])) { $_GET['id'] = urldecode($_GET['id']); $var_info = db()->query_fetch('SELECT * FROM ' . db('locale_vars') . ' WHERE LOWER(REPLACE(CONVERT(value USING utf8), " ", "_")) = "' . _es($_GET['id']) . '"'); if ($var_info) { $_GET['id'] = $var_info['id']; } else { db()->insert_safe('locale_vars', ['value' => $_GET['id']]); $_GET['id'] = db()->INSERT_ID(); } } $_GET['id'] = intval($_GET['id']); $var_info = db()->query_fetch('SELECT * FROM ' . db('locale_vars') . ' WHERE id=' . intval($_GET['id'])); if (empty($var_info['id'])) { _re('No such var!', 'id'); return _e(); } $Q = db()->query('SELECT * FROM ' . db('locale_translate') . ' WHERE var_id=' . intval($var_info['id'])); while ($A = db()->fetch_assoc($Q)) { $var_tr[$A['locale']] = $A['value']; } if (is_post()) { if (!_ee()) { foreach ((array) $this->_cur_langs_array as $lang_id => $lang_info) { if (!isset($_POST[$lang_info['locale']])) { continue; } $sql_data = ['var_id' => intval($var_info['id']), 'value' => _es($_POST[$lang_info['locale']]), 'locale' => _es($lang_info['locale'])]; if (isset($var_tr[$lang_info['locale']])) { db()->UPDATE('locale_translate', $sql_data, 'var_id=' . intval($var_info['id']) . " AND locale='" . _es($lang_info["locale"]) . "'"); } else { db()->INSERT('locale_translate', $sql_data); } cache_del('locale_translate_' . $lang_info['locale']); } common()->admin_wall_add(['locale var updated: ' . $var_info['value'], $_GET['id']]); return js_redirect('/@object/show_vars'); } } foreach ((array) $this->_cur_langs_array as $lang_id => $lang_info) { // Paste default value for the english locale (if translation is absent) $tr_value = !isset($var_tr[$lang_info['locale']]) && $lang_info['locale'] == 'en' ? $var_info['value'] : $var_tr[$lang_info['locale']]; $langs[$lang_info['locale']] = ['locale' => $lang_info['locale'], 'name' => _prepare_html($lang_info['name']), 'tr_value' => _prepare_html(trim($tr_value))]; } $replace = ['form_action' => url('/@object/@action/@id'), 'back_link' => url('/@object/show_vars'), 'error_message' => _e(), 'langs' => $langs, 'var_value' => _prepare_html($var_info['value']), 'location' => $this->DISPLAY_VARS_LOCATIONS ? $this->_prepare_locations($var_info['location']) : '']; return tpl()->parse('@object/edit_var', $replace); }
/** */ function view() { $ds = $this->_get_dashboard_data($_GET['id']); if (!$ds['id']) { return _e('No such record'); } if (main()->is_post()) { if (!_ee()) { db()->update('dashboards2', db()->es(['data' => json_encode($_POST['ds_data'])]), 'id=' . intval($ds['id'])); common()->admin_wall_add(['dashboard updated: ' . $ds['name'], $_GET['id']]); return js_redirect('./?object=' . $_GET['object'] . '&action=' . $_GET['object']); } } $rows = ""; if (isset($ds['data']['rows']) && is_array($ds['data']['rows'])) { $rows = $this->_get_grid($ds['data']['rows'], false); } $replace = ['save_link' => './?object=' . $_GET['object'] . '&action=save&id=' . $ds['id'], 'parse_structure' => './?object=' . $_GET['object'] . '&action=parse_structure&id=' . $ds['id'], 'lock_link' => './?object=' . $_GET['object'] . '&action=lock&id=' . $ds['id'], 'dashboard_name' => $ds['name'], 'rows' => $rows, 'lock' => $ds['lock']]; return tpl()->parse(__CLASS__ . '/edit_main', $replace); }
/** */ function edit() { $ds = $this->_get_dashboard_data($_GET['id']); if (!$ds['id']) { return _e('No such record'); } if (main()->is_post()) { if (!_ee()) { db()->update('dashboards', db()->es(['data' => json_encode($_POST['ds_data'])]), 'id=' . intval($ds['id'])); common()->admin_wall_add(['dashboard updated: ' . $ds['name'], $_GET['id']]); return js_redirect('./?object=' . $_GET['object'] . '&action=' . $_GET['object']); } } $items_configs = $ds['data']['items_configs']; $ds_settings = $ds['data']['settings']; $num_columns = isset($this->_col_classes[$ds_settings['columns']]) ? $ds_settings['columns'] : 3; foreach ((array) $ds['data']['columns'] as $column_id => $column_items) { $columns[$column_id] = ['num' => $column_id, 'class' => $this->_col_classes[$num_columns], 'items' => $this->_show_edit_widget_items($column_items, $ds)]; } // Fix empty drag places foreach (range(1, $num_columns) as $num) { if (!$columns[$num]) { $columns[$num] = ['num' => $num, 'class' => $this->_col_classes[$num_columns], 'items' => '']; } } $replace = ['save_link' => './?object=' . $_GET['object'] . '&action=edit&id=' . $ds['id'], 'columns' => $columns]; return tpl()->parse(__CLASS__ . '/edit_main', $replace); }