Skip to content

Commit cd7eae9

Browse files
VINADES.,JSCvuthao
VINADES.,JSC
authored andcommitted
banners: update select image for editors
1 parent bca05f4 commit cd7eae9

File tree

3 files changed

+127
-80
lines changed

3 files changed

+127
-80
lines changed

modules/banners/admin.functions.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function nv_banners_client_theme($contents)
238238
*/
239239
function nv_add_plan_theme($contents)
240240
{
241-
global $global_config, $module_file;
241+
global $global_config, $module_file, $module_upload;
242242
$xtpl = new XTemplate('add_plan.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
243243
$xtpl->assign('CONTENTS', $contents);
244244
$xtpl->assign('CLASS', $contents['is_error'] ? ' class="error"' : '');
@@ -259,7 +259,7 @@ function nv_add_plan_theme($contents)
259259
$xtpl->parse('main.form');
260260
}
261261
if ($contents['description'][5] and nv_function_exists('nv_aleditor')) {
262-
$description = nv_aleditor($contents['description'][1], $contents['description'][3], $contents['description'][4], $contents['description'][2]);
262+
$description = nv_aleditor($contents['description'][1], $contents['description'][3], $contents['description'][4], $contents['description'][2], '', NV_UPLOADS_DIR . '/' . $module_upload, NV_UPLOADS_DIR . '/' . $module_upload . '/files');
263263
} else {
264264
$description = '<textarea name="' . $contents['description'][1] . '" id="' . $contents['description'][1] . '" style="width:' . $contents['description'][3] . ';height:' . $contents['description'][4] . '">' . $contents['description'][2] . '</textarea>\n';
265265
}
@@ -275,8 +275,8 @@ function nv_add_plan_theme($contents)
275275
*/
276276
function nv_edit_plan_theme($contents)
277277
{
278-
global $global_config, $module_file;
279-
//print_r($contents);die();
278+
global $global_config, $module_file, $module_upload;
279+
280280
$xtpl = new XTemplate('edit_plan.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
281281
$xtpl->assign('CONTENTS', $contents);
282282
$xtpl->assign('CLASS', $contents['is_error'] ? ' class="error"' : '');
@@ -302,7 +302,7 @@ function nv_edit_plan_theme($contents)
302302
$xtpl->parse('main.form');
303303
}
304304
if ($contents['description'][5] and nv_function_exists('nv_aleditor')) {
305-
$description = nv_aleditor($contents['description'][1], $contents['description'][3], $contents['description'][4], $contents['description'][2]);
305+
$description = nv_aleditor($contents['description'][1], $contents['description'][3], $contents['description'][4], $contents['description'][2], '', NV_UPLOADS_DIR . '/' . $module_upload, NV_UPLOADS_DIR . '/' . $module_upload . '/files');
306306
} else {
307307
$description = '<textarea name="' . $contents['description'][1] . '" id="' . $contents['description'][1] . '" style="width:' . $contents['description'][3] . ';height:' . $contents['description'][4] . '">' . $contents['description'][2] . '</textarea>\n';
308308
}

modules/banners/admin/add_banner.php

+121-74
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @Createdate 3/12/2010 12:11
99
*/
1010

11-
if (! defined('NV_IS_FILE_ADMIN')) {
11+
if (!defined('NV_IS_FILE_ADMIN')) {
1212
die('Stop!!!');
1313
}
1414

@@ -34,7 +34,7 @@
3434
include NV_ROOTDIR . '/includes/footer.php';
3535
}
3636

37-
$sql = 'SELECT id,login,full_name FROM ' . NV_BANNERS_GLOBALTABLE. '_clients ORDER BY login ASC';
37+
$sql = 'SELECT id,login,full_name FROM ' . NV_BANNERS_GLOBALTABLE . '_clients ORDER BY login ASC';
3838
$result = $db->query($sql);
3939

4040
$clients = array();
@@ -44,10 +44,10 @@
4444

4545
$plans = array();
4646
$plans_form = array();
47-
$sql = 'SELECT id, title, blang, form, require_image FROM ' . NV_BANNERS_GLOBALTABLE. '_plans ORDER BY blang, title ASC';
47+
$sql = 'SELECT id, title, blang, form, require_image FROM ' . NV_BANNERS_GLOBALTABLE . '_plans ORDER BY blang, title ASC';
4848
$result = $db->query($sql);
4949
while ($row = $result->fetch()) {
50-
$plans[$row['id']] = $row['title'] . ' (' . (! empty($row['blang']) ? $language_array[$row['blang']]['name'] : $lang_module['blang_all']) . ')';
50+
$plans[$row['id']] = $row['title'] . ' (' . (!empty($row['blang']) ? $language_array[$row['blang']]['name'] : $lang_module['blang_all']) . ')';
5151
$require_image[$row['id']] = $row['require_image'];
5252
$plans_form[$row['id']] = $row['form'];
5353
}
@@ -64,42 +64,42 @@
6464
$clid = $nv_Request->get_int('clid', 'post', 0);
6565
$file_alt = nv_htmlspecialchars(strip_tags($nv_Request->get_string('file_alt', 'post', '')));
6666
$target = $nv_Request->get_string('target', 'post', '');
67-
if (! isset($targets[$target])) {
67+
if (!isset($targets[$target])) {
6868
$target = '_blank';
6969
}
7070
$bannerhtml = $nv_Request->get_editor('bannerhtml', '', NV_ALLOWED_HTML_TAGS);
7171
$click_url = strip_tags($nv_Request->get_string('click_url', 'post', ''));
7272
$publ_date = strip_tags($nv_Request->get_string('publ_date', 'post', ''));
7373
$exp_date = strip_tags($nv_Request->get_string('exp_date', 'post', ''));
7474

75-
if (! empty($publ_date) and ! preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $publ_date)) {
75+
if (!empty($publ_date) and !preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $publ_date)) {
7676
$publ_date = '';
7777
}
78-
if (! empty($exp_date) and ! preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $exp_date)) {
78+
if (!empty($exp_date) and !preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$/', $exp_date)) {
7979
$exp_date = '';
8080
}
8181

82-
if (! empty($clid) and ! isset($clients[$clid])) {
82+
if (!empty($clid) and !isset($clients[$clid])) {
8383
$clid = 0;
8484
}
8585
if ($click_url == 'http://') {
8686
$click_url = '';
8787
}
8888

89-
$sql = 'SELECT require_image FROM ' . NV_BANNERS_GLOBALTABLE. '_plans where id = ' . $pid;
90-
$result = $db->query($sql);
91-
$array_require_image = $result->fetchAll();
89+
$sql = 'SELECT require_image FROM ' . NV_BANNERS_GLOBALTABLE . '_plans where id = ' . $pid;
90+
$result = $db->query($sql);
91+
$array_require_image = $result->fetchAll();
9292

93-
if (empty($title)) {
93+
if (empty($title)) {
9494
$error = $lang_module['title_empty'];
95-
} elseif (empty($pid) or ! isset($plans[$pid])) {
95+
} elseif (empty($pid) or !isset($plans[$pid])) {
9696
$error = $lang_module['plan_not_selected'];
97-
} elseif (! empty($click_url) and ! nv_is_url($click_url)) {
97+
} elseif (!empty($click_url) and !nv_is_url($click_url)) {
9898
$error = $lang_module['click_url_invalid'];
99-
} elseif (! is_uploaded_file($_FILES['banner']['tmp_name']) && $array_require_image[0]['require_image'] == 1 ) {
100-
$error = $lang_module['file_upload_empty'];
99+
} elseif (!is_uploaded_file($_FILES['banner']['tmp_name']) && $array_require_image[0]['require_image'] == 1) {
100+
$error = $lang_module['file_upload_empty'];
101101
} else {
102-
if (empty($publ_date)) {
102+
if (empty($publ_date)) {
103103
$publtime = NV_CURRENTTIME;
104104
} else {
105105
unset($m);
@@ -124,64 +124,63 @@
124124

125125
$_weight = 0;
126126
if ($plans_form[$pid] == 'sequential') {
127-
$_weight = $db->query('SELECT MAX(weight) FROM ' . NV_BANNERS_GLOBALTABLE. '_rows WHERE pid=' . $pid)->fetchColumn();
127+
$_weight = $db->query('SELECT MAX(weight) FROM ' . NV_BANNERS_GLOBALTABLE . '_rows WHERE pid=' . $pid)->fetchColumn();
128128
$_weight = intval($_weight) + 1;
129129
}
130-
if (! is_uploaded_file($_FILES['banner']['tmp_name'])){
131-
$file_name = 'no_image';
130+
if (!is_uploaded_file($_FILES['banner']['tmp_name'])) {
131+
$file_name = 'no_image';
132132
$file_ext = 'no_image';
133133
$file_mime = 'no_image';
134134
$width = 0;
135135
$height = 0;
136-
$_sql = "INSERT INTO " . NV_BANNERS_GLOBALTABLE. "_rows ( title, pid, clid, file_name, file_ext, file_mime, width, height, file_alt, imageforswf, click_url, target, bannerhtml, add_time, publ_time, exp_time, hits_total, act, weight) VALUES
136+
$_sql = "INSERT INTO " . NV_BANNERS_GLOBALTABLE . "_rows ( title, pid, clid, file_name, file_ext, file_mime, width, height, file_alt, imageforswf, click_url, target, bannerhtml, add_time, publ_time, exp_time, hits_total, act, weight) VALUES
137137
( :title, " . $pid . ", " . $clid . ", :file_name, :file_ext, :file_mime,
138138
" . $width . ", " . $height . ", :file_alt, '', :click_url, :target, :bannerhtml, " . NV_CURRENTTIME . ", " . $publtime . ", " . $exptime . ",
139139
0, 1, " . $_weight . ")";
140140

141-
$data_insert = array();
142-
$data_insert['title'] = $title;
143-
$data_insert['file_name'] = $file_name;
144-
$data_insert['file_ext'] = $file_ext;
145-
$data_insert['file_mime'] = $file_mime;
146-
$data_insert['file_alt'] = $file_alt;
147-
$data_insert['click_url'] = $click_url;
148-
$data_insert['target'] = $target;
149-
$data_insert['bannerhtml'] = $bannerhtml;
150-
$id = $db->insert_id($_sql, 'id', $data_insert);
151-
}else{
152-
$upload = new NukeViet\Files\Upload($contents['file_allowed_ext'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
153-
$upload_info = $upload->save_file($_FILES['banner'], NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR, false);
154-
@unlink($_FILES['banner']['tmp_name']);
155-
156-
if (! empty($upload_info['error'])) {
157-
$error = $upload_info['error'];
158-
} else {
159-
@chmod($upload_info['name'], 0644);
160-
$file_name = $upload_info['basename'];
161-
$file_ext = $upload_info['ext'];
162-
$file_mime = $upload_info['mime'];
163-
$width = $upload_info['img_info'][0];
164-
$height = $upload_info['img_info'][1];
165-
166-
167-
$_sql = "INSERT INTO " . NV_BANNERS_GLOBALTABLE. "_rows ( title, pid, clid, file_name, file_ext, file_mime, width, height, file_alt, imageforswf, click_url, target, bannerhtml, add_time, publ_time, exp_time, hits_total, act, weight) VALUES
141+
$data_insert = array();
142+
$data_insert['title'] = $title;
143+
$data_insert['file_name'] = $file_name;
144+
$data_insert['file_ext'] = $file_ext;
145+
$data_insert['file_mime'] = $file_mime;
146+
$data_insert['file_alt'] = $file_alt;
147+
$data_insert['click_url'] = $click_url;
148+
$data_insert['target'] = $target;
149+
$data_insert['bannerhtml'] = $bannerhtml;
150+
$id = $db->insert_id($_sql, 'id', $data_insert);
151+
} else {
152+
$upload = new NukeViet\Files\Upload($contents['file_allowed_ext'], $global_config['forbid_extensions'], $global_config['forbid_mimes'], NV_UPLOAD_MAX_FILESIZE, NV_MAX_WIDTH, NV_MAX_HEIGHT);
153+
$upload_info = $upload->save_file($_FILES['banner'], NV_UPLOADS_REAL_DIR . '/' . NV_BANNER_DIR, false);
154+
@unlink($_FILES['banner']['tmp_name']);
155+
156+
if (!empty($upload_info['error'])) {
157+
$error = $upload_info['error'];
158+
} else {
159+
@chmod($upload_info['name'], 0644);
160+
$file_name = $upload_info['basename'];
161+
$file_ext = $upload_info['ext'];
162+
$file_mime = $upload_info['mime'];
163+
$width = $upload_info['img_info'][0];
164+
$height = $upload_info['img_info'][1];
165+
166+
$_sql = "INSERT INTO " . NV_BANNERS_GLOBALTABLE . "_rows ( title, pid, clid, file_name, file_ext, file_mime, width, height, file_alt, imageforswf, click_url, target, bannerhtml, add_time, publ_time, exp_time, hits_total, act, weight) VALUES
168167
( :title, " . $pid . ", " . $clid . ", :file_name, :file_ext, :file_mime,
169168
" . $width . ", " . $height . ", :file_alt, '', :click_url, :target, :bannerhtml, " . NV_CURRENTTIME . ", " . $publtime . ", " . $exptime . ",
170169
0, 1, " . $_weight . ")";
171170

172-
$data_insert = array();
173-
$data_insert['title'] = $title;
174-
$data_insert['file_name'] = $file_name;
175-
$data_insert['file_ext'] = $file_ext;
176-
$data_insert['file_mime'] = $file_mime;
177-
$data_insert['file_alt'] = $file_alt;
178-
$data_insert['click_url'] = $click_url;
179-
$data_insert['target'] = $target;
180-
$data_insert['bannerhtml'] = $bannerhtml;
181-
$id = $db->insert_id($_sql, 'id', $data_insert);
182-
}
183-
}
184-
nv_insert_logs(NV_LANG_DATA, $module_name, 'log_add_banner', 'bannerid ' . $id, $admin_info['userid']);
171+
$data_insert = array();
172+
$data_insert['title'] = $title;
173+
$data_insert['file_name'] = $file_name;
174+
$data_insert['file_ext'] = $file_ext;
175+
$data_insert['file_mime'] = $file_mime;
176+
$data_insert['file_alt'] = $file_alt;
177+
$data_insert['click_url'] = $click_url;
178+
$data_insert['target'] = $target;
179+
$data_insert['bannerhtml'] = $bannerhtml;
180+
$id = $db->insert_id($_sql, 'id', $data_insert);
181+
}
182+
}
183+
nv_insert_logs(NV_LANG_DATA, $module_name, 'log_add_banner', 'bannerid ' . $id, $admin_info['userid']);
185184
nv_CreateXML_bannerPlan();
186185
$op2 = ($file_ext == 'swf') ? 'edit_banner' : 'info_banner';
187186
nv_redirect_location(NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op2 . '&id=' . $id);
@@ -202,32 +201,80 @@
202201
}
203202
}
204203

205-
$contents['info'] = (! empty($error)) ? $error : $lang_module['add_banner_info'];
206-
$contents['is_error'] = (! empty($error)) ? 1 : 0;
204+
$contents['info'] = (!empty($error)) ? $error : $lang_module['add_banner_info'];
205+
$contents['is_error'] = (!empty($error)) ? 1 : 0;
207206
$contents['file_allowed_ext'] = implode(', ', $contents['file_allowed_ext']);
208207
$contents['submit'] = $lang_module['add_banner'];
209208
$contents['action'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&amp;' . NV_NAME_VARIABLE . '=' . $module_name . '&amp;' . NV_OP_VARIABLE . '=add_banner';
210-
$contents['title'] = array( $lang_module['title'], 'title', $title, 255 );
211-
$contents['plan'] = array( $lang_module['in_plan'], 'pid', $plans, $pid, $row, $require_image );
212-
$contents['client'] = array( $lang_module['of_client'], 'clid', $clients, $clid );
213-
$contents['upload'] = array( sprintf($lang_module['upload'], $contents['file_allowed_ext']), 'banner' );
214-
$contents['file_alt'] = array( $lang_module['file_alt'], 'file_alt', $file_alt, 255 );
215-
$contents['click_url'] = array( $lang_module['click_url'], 'click_url', $click_url, 255 );
216-
$contents['target'] = array( $lang_module['target'], 'target', $targets, $target );
217-
$contents['publ_date'] = array( $lang_module['publ_date'], 'publ_date', $publ_date, 10 );
218-
$contents['exp_date'] = array( $lang_module['exp_date'], 'exp_date', $exp_date, 10 );
209+
$contents['title'] = array(
210+
$lang_module['title'],
211+
'title',
212+
$title,
213+
255
214+
);
215+
$contents['plan'] = array(
216+
$lang_module['in_plan'],
217+
'pid',
218+
$plans,
219+
$pid,
220+
$row,
221+
$require_image
222+
);
223+
$contents['client'] = array(
224+
$lang_module['of_client'],
225+
'clid',
226+
$clients,
227+
$clid
228+
);
229+
$contents['upload'] = array(
230+
sprintf($lang_module['upload'], $contents['file_allowed_ext']),
231+
'banner'
232+
);
233+
$contents['file_alt'] = array(
234+
$lang_module['file_alt'],
235+
'file_alt',
236+
$file_alt,
237+
255
238+
);
239+
$contents['click_url'] = array(
240+
$lang_module['click_url'],
241+
'click_url',
242+
$click_url,
243+
255
244+
);
245+
$contents['target'] = array(
246+
$lang_module['target'],
247+
'target',
248+
$targets,
249+
$target
250+
);
251+
$contents['publ_date'] = array(
252+
$lang_module['publ_date'],
253+
'publ_date',
254+
$publ_date,
255+
10
256+
);
257+
$contents['exp_date'] = array(
258+
$lang_module['exp_date'],
259+
'exp_date',
260+
$exp_date,
261+
10
262+
);
219263
$contents['bannerhtml'] = htmlspecialchars(nv_editor_br2nl($bannerhtml));
220264

221265
if (defined('NV_EDITOR')) {
222266
require_once NV_ROOTDIR . '/' . NV_EDITORSDIR . '/' . NV_EDITOR . '/nv.php';
223267
}
224268

225269
if (defined('NV_EDITOR') and nv_function_exists('nv_aleditor')) {
226-
$contents['bannerhtml'] = nv_aleditor('bannerhtml', '100%', '300px', $contents['bannerhtml']);
270+
$contents['bannerhtml'] = nv_aleditor('bannerhtml', '100%', '300px', $contents['bannerhtml'], '', NV_UPLOADS_DIR . '/' . $module_upload, NV_UPLOADS_DIR . '/' . $module_upload . '/files');
227271
} else {
228272
$contents['bannerhtml'] = '<textarea style="width:100%;height:300px" name="bannerhtml">' . $contents['bannerhtml'] . '</textarea>';
229273
}
230-
$contents['bannerhtml'] = array($lang_module['bannerhtml'], $contents['bannerhtml']);
274+
$contents['bannerhtml'] = array(
275+
$lang_module['bannerhtml'],
276+
$contents['bannerhtml']
277+
);
231278

232279
include NV_ROOTDIR . '/includes/header.php';
233280
echo nv_admin_theme(nv_add_banner_theme($contents));

modules/banners/admin/edit_banner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@
246246
}
247247

248248
if (defined('NV_EDITOR') and nv_function_exists('nv_aleditor')) {
249-
$contents['bannerhtml'] = nv_aleditor('bannerhtml', '100%', '300px', $contents['bannerhtml']);
249+
$contents['bannerhtml'] = nv_aleditor('bannerhtml', '100%', '300px', $contents['bannerhtml'], '', NV_UPLOADS_DIR . '/' . $module_upload, NV_UPLOADS_DIR . '/' . $module_upload . '/files');
250250
} else {
251251
$contents['bannerhtml'] = '<textarea style="width:100%;height:300px" name="bannerhtml">' . $contents['bannerhtml'] . '</textarea>';
252252
}

0 commit comments

Comments
 (0)