Skip to content

Commit 19ef497

Browse files
committed
В первом приближении новая админка готова, остались мелочи
1 parent 2db4232 commit 19ef497

File tree

20 files changed

+127
-35
lines changed

20 files changed

+127
-35
lines changed

install/languages/en/base.sql

+2-1
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ CREATE TABLE `{#}users` (
14181418
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Users';
14191419

14201420
INSERT INTO `{#}users` (`id`, `groups`, `email`, `password_hash`, `is_admin`, `nickname`, `date_reg`, `date_log`, `date_group`, `ip`, `is_locked`, `lock_until`, `lock_reason`, `pass_token`, `date_token`, `friends_count`, `subscribers_count`, `time_zone`, `karma`, `rating`, `theme`, `notify_options`, `privacy_options`, `status_id`, `status_text`, `inviter_id`, `invites_count`, `date_invites`, `birth_date`, `city`, `city_cache`, `hobby`, `avatar`, `icq`, `skype`, `phone`, `music`, `movies`, `site`) VALUES
1421-
(1, '---\n- 6\n', 'admin@example.com', NULL, 1, 'admin', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '127.0.0.1', NULL, NULL, NULL, NULL, NULL, 468, 2, 'Europe/London', 0, 0, '---\nbg_img: null\nbg_color: ''#ffffff''\nbg_repeat: no-repeat\nbg_pos_x: left\nbg_pos_y: top\nmargin_top: 0\n', '---\nusers_friend_add: both\nusers_friend_delete: both\ncomments_new: both\ncomments_reply: email\nusers_friend_accept: pm\ngroups_invite: email\nusers_wall_write: email\n', '---\nusers_profile_view: anyone\nmessages_pm: anyone\n', NULL, NULL, NULL, 0, NULL, '1985-10-15 00:00:00', 12008, 'London', 'Style too own civil out along. Perfectly offending attempted add arranging age gentleman concluded.', NULL, '987654321', 'admin', '100-20-30', 'Disco House, Minimal techno', 'various interesting', 'instantcms.ru');
1421+
(1, '---\n- 6\n', 'admin@example.com', NULL, 1, 'admin', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, '127.0.0.1', NULL, NULL, NULL, NULL, NULL, 0, 0, 'Europe/London', 0, 0, '---\nbg_img: null\nbg_color: ''#ffffff''\nbg_repeat: no-repeat\nbg_pos_x: left\nbg_pos_y: top\nmargin_top: 0\n', '---\nusers_friend_add: both\nusers_friend_delete: both\ncomments_new: both\ncomments_reply: email\nusers_friend_accept: pm\ngroups_invite: email\nusers_wall_write: email\n', '---\nusers_profile_view: anyone\nmessages_pm: anyone\n', NULL, NULL, NULL, 0, NULL, '1985-10-15 00:00:00', 12008, 'London', 'Style too own civil out along. Perfectly offending attempted add arranging age gentleman concluded.', NULL, '987654321', 'admin', '100-20-30', 'Disco House, Minimal techno', 'various interesting', 'instantcms.ru');
14221422

14231423
DROP TABLE IF EXISTS `{#}users_contacts`;
14241424
CREATE TABLE `{#}users_contacts` (
@@ -1695,6 +1695,7 @@ CREATE TABLE `{#}widgets` (
16951695
`is_external` tinyint(1) DEFAULT '1',
16961696
`files` text COMMENT 'List of widget files (for third-party widgets)',
16971697
`addon_id` int(11) UNSIGNED DEFAULT NULL,
1698+
`image_hint_path` varchar(100) DEFAULT NULL COMMENT 'Hint image',
16981699
PRIMARY KEY (`id`),
16991700
KEY `version` (`version`),
17001701
KEY `name` (`name`),

install/languages/ru/base.sql

+1
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,7 @@ CREATE TABLE `{#}widgets` (
16941694
`is_external` tinyint(1) DEFAULT '1',
16951695
`files` text COMMENT 'Список файлов виджета (для стороних виджетов)',
16961696
`addon_id` int(11) UNSIGNED DEFAULT NULL COMMENT 'ID дополнения в официальном каталоге',
1697+
`image_hint_path` varchar(100) DEFAULT NULL COMMENT 'Поясняющее изображение',
16971698
PRIMARY KEY (`id`),
16981699
KEY `version` (`version`),
16991700
KEY `name` (`name`),

install/steps/config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function create_config($path, $file){
4747
'date_format_js' => LANG_CFG_DATE_FORMAT_JS,
4848
'time_zone' => LANG_CFG_TIME_ZONE,
4949
'template' => 'default',
50-
'template_admin' => 'default',
50+
'template_admin' => 'admincoreui',
5151
'template_mobile' => '',
5252
'template_tablet' => '',
5353
'db_host' => $_SESSION['install']['db']['host'],

system/controllers/activity/model.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function getEntries(){
190190

191191
foreach($item['images'] as $key => $image){
192192
if (strpos($image['src'], 'http') !== 0) {
193-
if (!file_exists($config->upload_path . '/' . $image['src'])){
193+
if (!file_exists($config->upload_path . $image['src'])){
194194
continue;
195195
}
196196
$image['src'] = $config->upload_host . '/' . $image['src'];

system/controllers/admin/actions/install_finish.php

+17
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,21 @@ private function componentUpdate($manifest) {
202202

203203
}
204204

205+
private function copyWidgetImageHint($manifest) {
206+
207+
if (empty($manifest['info']['image_hint'])){
208+
return null;
209+
}
210+
211+
$file_path = 'package-images/widgets/'.($manifest['package']['controller'] ? $manifest['package']['controller'].'_' : '').$manifest['package']['name'].'.'.strtolower(pathinfo($manifest['info']['image_hint'], PATHINFO_EXTENSION));
212+
213+
if(copy($manifest['info']['image_hint'], $this->cms_config->upload_path.$file_path)){
214+
return $file_path;
215+
}
216+
217+
return null;
218+
}
219+
205220
private function widgetInstall($manifest) {
206221

207222
$model = new cmsModel();
@@ -215,6 +230,7 @@ private function widgetInstall($manifest) {
215230
'version' => $manifest['version']['major'] . '.' . $manifest['version']['minor'] . '.' . $manifest['version']['build'],
216231
'files' => (!empty($manifest['contents']) ? $manifest['contents'] : null),
217232
'addon_id' => (!empty($manifest['info']['addon_id']) ? (int)$manifest['info']['addon_id'] : null),
233+
'image_hint_path' => $this->copyWidgetImageHint($manifest),
218234
'is_external' => 1
219235
));
220236

@@ -230,6 +246,7 @@ private function widgetUpdate($manifest) {
230246
'title' => $manifest['info']['title'],
231247
'author' => (isset($manifest['author']['name']) ? $manifest['author']['name'] : LANG_CP_PACKAGE_NONAME),
232248
'url' => (isset($manifest['author']['url']) ? $manifest['author']['url'] : null),
249+
'image_hint_path' => $this->copyWidgetImageHint($manifest),
233250
'version' => $manifest['version']['major'] . '.' . $manifest['version']['minor'] . '.' . $manifest['version']['build']
234251
);
235252

system/controllers/admin/actions/install_ftp.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private function uploadDirectoryToFTP($conn_id, $src_dir, $dst_dir) {
150150

151151
if (!@ftp_chdir($conn_id, $dst_dir."/".$file)) {
152152
$result = @ftp_mkdir($conn_id, $dst_dir."/".$file);
153-
if (!$result) {throw new Exception(LANG_CP_FTP_MKDIR_FAILED);}
153+
if (!$result) {throw new Exception(LANG_CP_FTP_MKDIR_FAILED.': '.$dst_dir."/".$file);}
154154
if($is_function_exists_ftp_chmod){
155155
@ftp_chmod($conn_id, 0755, $dst_dir."/".$file);
156156
}

system/controllers/admin/actions/widgets_remove.php

+20-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,33 @@
22

33
class actionAdminWidgetsRemove extends cmsAction {
44

5-
public function run($id=false){
5+
public function run($id = false) {
66

7-
if (!$this->request->isAjax()){ cmsCore::error404(); }
7+
if (!$this->request->isAjax()) { cmsCore::error404(); }
88

9-
if (!$id){ cmsCore::error404(); }
9+
if (!$id) { cmsCore::error404(); }
1010

1111
$widgets_model = cmsCore::getModel('widgets');
1212

13+
$widget = $widgets_model->getWidgetBinding($id);
14+
if (!$widget) {
15+
return cmsCore::error404();
16+
}
17+
18+
if($widget['image_hint_path']){
19+
20+
$widget['image_hint_path'] = str_replace($this->cms_config->upload_host.'/', '', $widget['image_hint_path']);
21+
22+
@unlink($this->cms_config->upload_path.$widget['image_hint_path']);
23+
24+
}
25+
1326
$widgets_model->deleteWidget($id);
1427

15-
$this->halt();
28+
return $this->cms_template->renderJSON(array(
29+
'error' => false,
30+
'success_text' => LANG_CP_WIDGET_REMOVE_SUCCESS
31+
));
1632

1733
}
1834

system/controllers/admin/actions/widgets_update.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public function run() {
5454
return $this->cms_template->renderJSON(array(
5555
'errors' => false,
5656
'callback' => 'widgetUpdated',
57-
'widget' => $widget
57+
'widget' => $widget,
58+
'success_text' => LANG_CP_SAVE_SUCCESS
5859
));
5960

6061
}

system/controllers/admin/frontend.php

+6
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,12 @@ public function parsePackageManifest(){
600600
$manifest['info']['image'];
601601
}
602602

603+
if (isset($manifest['info']['image_hint'])){
604+
$manifest['info']['image_hint'] = $this->cms_config->upload_path .
605+
$this->installer_upload_path . '/' .
606+
$manifest['info']['image_hint'];
607+
}
608+
603609
if((isset($manifest['install']) || isset($manifest['update']))){
604610

605611
$action = (isset($manifest['install']) ? 'install' : 'update');

system/controllers/widgets/model.php

+16-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,12 @@ public function getAvailableWidgets() {
193193
$widgets = $this->orderByList(array(
194194
array('by' => 'controller', 'to' => 'asc'),
195195
array('by' => 'name', 'to' => 'asc')
196-
))->get('widgets');
196+
))->get('widgets', function ($item, $model){
197+
if($item['image_hint_path']){
198+
$item['image_hint_path'] = cmsConfig::get('upload_host').'/'.$item['image_hint_path'];
199+
}
200+
return $item;
201+
});
197202

198203
if (!$widgets) { return false; }
199204

@@ -222,12 +227,16 @@ public function getWidgetBinding($id) {
222227
$this->select('w.controller', 'controller');
223228
$this->select('w.name', 'name');
224229
$this->select('w.title', 'widget_title');
230+
$this->select('w.image_hint_path', 'image_hint_path');
225231

226232
$this->join('widgets', 'w', 'w.id = i.widget_id');
227233

228234
$this->useCache('widgets.bind');
229235

230236
return $this->getItemById('widgets_bind', $id, function($item, $model) {
237+
if($item['image_hint_path']){
238+
$item['image_hint_path'] = cmsConfig::get('upload_host').'/'.$item['image_hint_path'];
239+
}
231240
$item['options'] = cmsModel::yamlToArray($item['options']);
232241
$item['groups_view'] = cmsModel::yamlToArray($item['groups_view']);
233242
$item['groups_hide'] = cmsModel::yamlToArray($item['groups_hide']);
@@ -257,6 +266,7 @@ public function getWidgetBindingsScheme($page_id, $template_name) {
257266
filterIsNull('bp.position')->
258267
filterEnd()->
259268
select('w.title', 'name')->
269+
select('w.image_hint_path', 'image_hint_path')->
260270
select('bp.*')->
261271
select('IFNULL(bp.bind_id,i.id)', 'bind_id')->
262272
joinInner('widgets', 'w', 'w.id = i.widget_id')->
@@ -287,13 +297,18 @@ public function getWidgetBindingsScheme($page_id, $template_name) {
287297
$bind['position'] = '_unused';
288298
}
289299

300+
if($bind['image_hint_path']){
301+
$bind['image_hint_path'] = cmsConfig::get('upload_host').'/'.$bind['image_hint_path'];
302+
}
303+
290304
$positions[$bind['position']][] = array(
291305
'id' => $bind['id'],
292306
'bind_id' => $bind['bind_id'],
293307
'widget_id' => $bind['widget_id'],
294308
'title' => $bind['title'],
295309
'position' => $bind['position'],
296310
'languages' => $bind['languages'],
311+
'image_hint_path' => $bind['image_hint_path'],
297312
'device_type_names' => $bind['device_types'],
298313
'device_types' => $device_types,
299314
'name' => $bind['name'],

system/languages/en/controllers/admin/admin.php

+3
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@
352352
define('LANG_CP_MENU_IS_FIXED', 'This menu cannot be deleted');
353353

354354
define('LANG_CP_WIDGETS_PAGE', 'Page');
355+
define('LANG_CP_WIDGETS_PAGES', 'Pages');
356+
define('LANG_CP_WIDGETS_ALL', 'All widgets');
355357
define('LANG_CP_WIDGETS_ADD', 'Add Widget');
356358
define('LANG_CP_WIDGETS_ADD_PAGE', 'Add Page');
357359
define('LANG_CP_WIDGETS_EDIT_PAGE', 'Edit');
@@ -362,6 +364,7 @@
362364
define('LANG_CP_WIDGET_COPY_CONFIRM', 'Copy the widget, duplicating it at the same position?');
363365
define('LANG_CP_WIDGET_DELETE_CONFIRM', 'Delete widget?');
364366
define('LANG_CP_WIDGET_REMOVE_CONFIRM', 'Are you sure you want to permanently remove the widget from the system?');
367+
define('LANG_CP_WIDGET_REMOVE_SUCCESS', 'Widget successfully deleted');
365368
define('LANG_CP_WIDGET_PAGE_CREATED', 'Page «%s» has been created');
366369
define('LANG_CP_WIDGET_PAGE_URLS', 'URL binding');
367370
define('LANG_CP_WIDGET_PAGE_URL_MASK', 'Positive masks');

system/languages/ru/controllers/admin/admin.php

+3
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@
353353
define('LANG_CP_MENU_IS_FIXED', 'Нельзя удалить системное меню');
354354

355355
define('LANG_CP_WIDGETS_PAGE', 'Страница');
356+
define('LANG_CP_WIDGETS_PAGES', 'Страницы');
357+
define('LANG_CP_WIDGETS_ALL', 'Все виджеты');
356358
define('LANG_CP_WIDGETS_ADD', 'Создать виджет');
357359
define('LANG_CP_WIDGETS_ADD_PAGE', 'Создать страницу');
358360
define('LANG_CP_WIDGETS_EDIT_PAGE', 'Редактировать');
@@ -363,6 +365,7 @@
363365
define('LANG_CP_WIDGET_COPY_CONFIRM', 'Копировать виджет, дублируя его на этой же позиции?');
364366
define('LANG_CP_WIDGET_DELETE_CONFIRM', 'Удалить виджет?');
365367
define('LANG_CP_WIDGET_REMOVE_CONFIRM', 'Вы действительно хотите окончательно удалить виджет из системы?');
368+
define('LANG_CP_WIDGET_REMOVE_SUCCESS', 'Виджет успешно удалён');
366369
define('LANG_CP_WIDGET_PAGE_CREATED', 'Страница «%s» создана');
367370
define('LANG_CP_WIDGET_PAGE_URLS', 'Фильтрация URL');
368371
define('LANG_CP_WIDGET_PAGE_URL_MASK', 'Положительные маски');

templates/admincoreui/controllers/admin/styles.css

+6-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ form .child_field{margin-left: 20px}
546546
display: inline-block;
547547
padding: .5rem;
548548
}
549-
#cp-widgets-layout .position li:not(.disabled) > .title {
549+
#cp-widgets-layout .position li:not(.disabled) > .title, #cp-widgets-list li > .title {
550550
cursor: move;
551551
}
552552
#cp-widgets-layout .position li.placeholder{
@@ -605,6 +605,11 @@ form .child_field{margin-left: 20px}
605605
background-color: #f9d46b;
606606
border: solid 1px #ccab49;
607607
}
608+
#cp-widgets-list li > img, #cp-widgets-layout .position li > img {
609+
width: 100%;
610+
border-radius: inherit;
611+
display: block;
612+
}
608613
#site_settings #fset_2 .chosen-container,
609614
#site_settings #fset_5 .chosen-container { width:300px !important; }
610615
#site_settings #fset_2 label, #site_settings #fset_5 label { display: block; }

templates/admincoreui/controllers/admin/widgets.tpl.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@
7575
<div class="card-body bg-white h-100 pt-3 no-overflow">
7676
<ul class="nav nav-tabs">
7777
<li class="nav-item">
78-
<a class="nav-link active" data-toggle="tab" href="#datatree">Страницы</a>
78+
<a class="nav-link active" data-toggle="tab" href="#datatree"><?php echo LANG_CP_WIDGETS_PAGES; ?></a>
7979
</li>
8080
<li class="nav-item">
81-
<a class="nav-link" data-toggle="tab" href="#all-widgets">Все виджеты</a>
81+
<a class="nav-link" data-toggle="tab" href="#all-widgets"><?php echo LANG_CP_WIDGETS_ALL; ?></a>
8282
</li>
8383
</ul>
8484
<div class="tab-content border-right-0 border-bottom-0 border-left-0">
@@ -108,13 +108,18 @@
108108
</a>
109109
<ul class="mt-3 px-2 list-unstyled collapse <?php echo !$controller_name ? 'show' : ''; ?>" id="w-<?php echo $controller_name; ?>" data-parent="#accordion">
110110
<?php foreach($widgets as $widget){ ?>
111-
<li rel="new" data-id="<?php echo $widget['id']; ?>">
111+
<li rel="new" data-id="<?php echo $widget['id']; ?>">
112112
<span class="title"><?php echo $widget['title']; ?></span>
113113
<?php if($widget['is_external']){ ?>
114-
<span class="actions">
115-
<a class="delete" href="#" title="<?php echo LANG_DELETE; ?>"></a>
114+
<span class="actions float-md-right d-flex">
115+
<a class="delete" href="#" title="<?php echo LANG_DELETE; ?>">
116+
<i class="icon-close icons font-xl d-block"></i>
117+
</a>
116118
</span>
117119
<?php } ?>
120+
<?php if($widget['image_hint_path']){ ?>
121+
<img src="<?php echo $widget['image_hint_path']; ?>">
122+
<?php } ?>
118123
</li>
119124
<?php } ?>
120125
</ul>
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
<?php
22
$this->addTplJSNameFromContext('widgets_options/'.$widget['controller'].'_'.$widget['name']);
33
?>
4+
<?php ob_start(); ?>
5+
<div class="widget_modal_help_link float-right mt-3">
6+
<a target="_blank" class="btn btn-light" href="<?php echo LANG_HELP_URL_WIDGETS_CFG; ?>">
7+
<i class="icon-question"></i> <?php echo LANG_HELP; ?>
8+
</a>
9+
</div>
10+
<?php $help_btn = ob_get_clean(); ?>
11+
412
<div class="modal_form">
513
<?php
614
$this->renderForm($form, $widget, array(
715
'action' => $this->href_to('widgets_update'),
16+
'append_html' => $help_btn,
817
'method' => 'ajax',
918
'toolbar' => false
1019
), $errors);
1120
?>
12-
</div>
13-
<div class="widget_modal_help_link float-right">
14-
<a target="_blank" class="btn" href="<?php echo LANG_HELP_URL_WIDGETS_CFG; ?>">
15-
<i class="icon-question"></i> <?php echo LANG_HELP; ?>
16-
</a>
1721
</div>

templates/admincoreui/js/admin-dashboard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ $(function(){
143143
id_list.push(name);
144144
});
145145
$.post($('#dashboard').data('save_order_url'), {items: id_list}, function(result){
146-
toastr.success(result.success_text, '', {preventDuplicates: true});
146+
toastr.success(result.success_text);
147147
}, 'json');
148148
}
149149
}).disableSelection();

0 commit comments

Comments
 (0)