Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
neuro-images
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Александр Чаплыгин
neuro-images
Commits
8443f829
Commit
8443f829
authored
Jun 03, 2022
by
Александр Чаплыгин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Закгрузка данных из архивной папки
parent
ee953aa2
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
312 additions
and
1509 deletions
+312
-1509
.gitignore
.gitignore
+1
-0
routes-admin.global.php
src/config/autoload/routes-admin.global.php
+15
-0
styles-main.css
src/public/css/styles-main.css
+11
-5
1--1.jpg
src/public/fotos-arch/B-KazwCAcxM/1--1.jpg
+0
-0
1--4.jpg
src/public/fotos-arch/B-KazwCAcxM/1--4.jpg
+0
-0
2.jpg
src/public/fotos-arch/B-KazwCAcxM/2.jpg
+0
-0
3.jpg
src/public/fotos-arch/B-KazwCAcxM/3.jpg
+0
-0
script-main.js
src/public/js/script-main.js
+211
-93
Feeds.php
src/src/App/Action/Admin/Feeds.php
+0
-253
Index.php
src/src/App/Action/Admin/Index.php
+1
-0
Main.php
src/src/App/Action/Admin/Main.php
+56
-14
Banners.php
src/src/App/Model/AmSystem/Banners.php
+0
-41
Campaigns.php
src/src/App/Model/AmSystem/Campaigns.php
+0
-41
Groups.php
src/src/App/Model/AmSystem/Groups.php
+0
-41
Categories.php
src/src/App/Model/Feeds/Categories.php
+0
-40
CategoryFees.php
src/src/App/Model/Feeds/CategoryFees.php
+0
-92
Feeds.php
src/src/App/Model/Feeds/Feeds.php
+0
-57
OrdersStatus.php
src/src/App/Model/Feeds/OrdersStatus.php
+0
-94
ShopFeeds.php
src/src/App/Model/Feeds/ShopFeeds.php
+0
-40
Shops.php
src/src/App/Model/Feeds/Shops.php
+0
-39
Statistics.php
src/src/App/Model/Statistics.php
+0
-651
main.phtml
src/templates/app/main.phtml
+17
-8
No files found.
.gitignore
View file @
8443f829
...
@@ -7,3 +7,4 @@ srt/public/fotos-test/
...
@@ -7,3 +7,4 @@ srt/public/fotos-test/
srt/public/fotos-arch/
srt/public/fotos-arch/
src/config/autoload/routes-admin.global.php
View file @
8443f829
...
@@ -119,6 +119,21 @@ return [
...
@@ -119,6 +119,21 @@ return [
]
]
],
],
],
],
[
'name'
=>
'adm.main.loadfolderslist'
,
'path'
=>
'/[:lang/]support/main/loadfolderslist/'
,
'middleware'
=>
App\Action\Admin\Main
::
class
,
'allowed_methods'
=>
[
'POST'
,
'GET'
],
'options'
=>
[
'constraints'
=>
[
'lang'
=>
'[a-z]{2,3}'
,
],
'defaults'
=>
[
'lang'
=>
\App\Model\Locales
::
DEFAULT_LANG_ADMIN
,
'action'
=>
App\Action\Admin\Main
::
LOAD_FOLDERS_LIST
,
]
],
],
[
[
'name'
=>
'adm.init'
,
'name'
=>
'adm.init'
,
'path'
=>
'/[:lang/]support/init/'
,
'path'
=>
'/[:lang/]support/init/'
,
...
...
src/public/css/styles-main.css
View file @
8443f829
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
}
}
.b-list_folders
{
.b-list_folders
{
display
:
none
;
margin
:
8px
0
4px
0
;
margin
:
8px
0
4px
0
;
height
:
calc
(
100vh
-
140px
);
height
:
calc
(
100vh
-
140px
);
overflow-y
:
auto
;
overflow-y
:
auto
;
...
@@ -35,15 +36,15 @@
...
@@ -35,15 +36,15 @@
right
:
0
;
right
:
0
;
}
}
.b-list_folders-item.
viewed
.b-list_folders-item.
active
{
{
opacity
:
0.45
;
font-weight
:
bold
;
opacity
:
1
!important
;
}
}
.b-list_folders
-item.active
.b-list_folders
.new
.b-list_folders-item.viewed
{
{
font-weight
:
bold
;
opacity
:
0.45
;
opacity
:
1
;
}
}
.b-preview
.b-preview
...
@@ -52,6 +53,11 @@
...
@@ -52,6 +53,11 @@
overflow
:
auto
;
overflow
:
auto
;
}
}
.b-preview_inner
{
display
:
none
;
}
.b-loading
{
.b-loading
{
display
:
none
;
display
:
none
;
position
:
absolute
;
position
:
absolute
;
...
...
src/public/fotos-arch/B-KazwCAcxM/1--1.jpg
deleted
100644 → 0
View file @
ee953aa2
188 KB
src/public/fotos-arch/B-KazwCAcxM/1--4.jpg
deleted
100644 → 0
View file @
ee953aa2
213 KB
src/public/fotos-arch/B-KazwCAcxM/2.jpg
deleted
100644 → 0
View file @
ee953aa2
228 KB
src/public/fotos-arch/B-KazwCAcxM/3.jpg
deleted
100644 → 0
View file @
ee953aa2
228 KB
src/public/js/script-main.js
View file @
8443f829
...
@@ -2,10 +2,16 @@ $(document).ready(function(){
...
@@ -2,10 +2,16 @@ $(document).ready(function(){
var
var
$body
=
$
(
'body'
),
$body
=
$
(
'body'
),
$listFolders
=
$
(
'.b-list_folders'
),
$listFoldersNew
=
$
(
'.b-list_folders.new'
),
$listFoldersArch
=
$
(
'.b-list_folders.arch'
),
$foldersContentWrap
=
$
(
'.b-preview'
),
$foldersContentWrap
=
$
(
'.b-preview'
),
$foldersContentWrapInner
=
$
(
'.b-preview_inner'
),
$foldersNewContentWrap
=
$
(
'.b-preview_inner.new'
),
$foldersArchContentWrap
=
$
(
'.b-preview_inner.arch'
),
$loading
=
$
(
'.b-loading'
),
$loading
=
$
(
'.b-loading'
),
$saveButton
=
$
(
'.btn.btn-primary.save-folders'
),
colorsActive
=
$foldersContentWrap
.
data
(
'colors'
),
colorsActive
=
$foldersContentWrap
.
data
(
'colors'
),
freeNumbers
=
[
1
,
2
,
3
,
4
,
5
],
pairsCount
=
$foldersContentWrap
.
data
(
'pairs_count'
),
pairsCount
=
$foldersContentWrap
.
data
(
'pairs_count'
),
currentNumToSelect
=
{},
currentNumToSelect
=
{},
hasSelectedFoto
=
{};
hasSelectedFoto
=
{};
...
@@ -20,29 +26,41 @@ $(document).ready(function(){
...
@@ -20,29 +26,41 @@ $(document).ready(function(){
$loading
.
hide
();
$loading
.
hide
();
}
}
function
MarkFolderSelected
(
$folderNam
e
)
function
getFoldersList
(
typ
e
)
{
{
$
(
'.b-list_folders-item'
).
removeClass
(
'active'
);
if
(
type
==
'new'
)
return
$listFoldersNew
;
$folderName
.
addClass
(
'active'
);
if
(
type
==
'arch'
)
return
$listFoldersArch
;
}
function
MarkFolderSelected
(
$folder
,
type
)
{
var
$foldersList
=
getFoldersList
(
type
);
$
(
'.b-list_folders-item'
,
$foldersList
).
removeClass
(
'active'
);
$folder
.
addClass
(
'active'
);
}
}
function
MarkFolderViewed
(
$folderName
)
function
MarkFolderViewed
(
$folderName
)
{
{
$folderName
.
addClass
(
'viewed'
);
$folderName
.
addClass
(
'viewed'
);
$saveButton
.
removeClass
(
'disabled'
);
}
}
function
RenderFilesList
(
folderName
,
data
)
function
RenderFilesList
(
folderName
,
folderType
,
data
)
{
{
// Добавляем содержимое папки:
// Добавляем содержимое папки:
var
var
templateFolderContent
=
_
.
template
(
''
+
$target
,
'<div class="b-folder-content row active" data-folder="<%= folder %>">'
+
folder
,
cols
,
templateFolderContent
=
_
.
template
(
''
+
'<div class="b-folder-content row active" data-folder="<%= folderName %>">'
+
' <div class="sorted">'
+
' <div class="sorted">'
+
' </div>'
+
' </div>'
+
' <div class="not-sorted col row">'
+
' <div class="not-sorted col row">'
+
' <% _.each(files, function(item, ind) { %>
\
n'
+
' <% _.each(files, function(item, ind) { %>
\
n'
+
' <div class="b-foto col-<%= cols %> order-<%= ind+1 %>" data-id="<%= item %>" data-ind="<%= ind+1 %>">'
+
' <div class="b-foto col-<%= cols %> order-<%= ind+1 %>" data-id="<%= item %>" data-ind="<%= ind+1 %>">'
+
' <div class="b-foto_inner" style="background-image: url(/fotos/
<%= folder %>/<%= item %>)" data-foto="<%= item %>" data-num="">'
+
' <div class="b-foto_inner" style="background-image: url(
<%= folder %>/<%= item %>)" data-foto="<%= item %>" data-num="">'
+
' <div class="b-foto_number"></div>'
+
' <div class="b-foto_number"></div>'
+
' </div>'
+
' </div>'
+
' </div>'
+
' </div>'
+
...
@@ -51,20 +69,14 @@ $(document).ready(function(){
...
@@ -51,20 +69,14 @@ $(document).ready(function(){
'</div>'
'</div>'
);
);
/*
if
(
folderType
==
'new'
)
{
var templateFolderContent = _.template('' +
folder
=
'/fotos/'
+
folderName
;
'<div class="b-folder-content row active" data-folder="<%= folder %>">' +
$target
=
$foldersNewContentWrap
;
' <% _.each(files, function(item) { %> \n' +
}
' <div class="b-foto col-<%= cols %> order-12" data-id="<%= item %>">' +
if
(
folderType
==
'arch'
)
{
' <div class="b-foto_inner" style="background-image: url(/fotos/<%= folder %>/<%= item %>)" data-foto="<%= item %>" data-num="">' +
folder
=
'/fotos-arch/'
+
folderName
;
' <div class="b-foto_number"></div>' +
$target
=
$foldersArchContentWrap
;
' </div>' +
}
' </div>' +
' <% }) %> \n' +
'</div>'
);
*/
var
cols
;
switch
(
data
.
length
)
{
switch
(
data
.
length
)
{
case
2
:
case
2
:
...
@@ -90,11 +102,55 @@ $(document).ready(function(){
...
@@ -90,11 +102,55 @@ $(document).ready(function(){
cols
=
2
;
cols
=
2
;
}
}
$
foldersContentWrap
.
append
(
templateFolderContent
({
folder
:
folderName
,
files
:
data
,
cols
:
cols
}));
$
target
.
append
(
templateFolderContent
({
folderName
:
folderName
,
folder
:
folder
,
files
:
data
,
cols
:
cols
}));
currentNumToSelect
[
folderName
]
=
1
;
currentNumToSelect
[
folderName
]
=
1
;
hasSelectedFoto
[
folderName
]
=
false
;
// Выбрали одну картинку (есть подсвеченное фото)
hasSelectedFoto
[
folderName
]
=
false
;
// Выбрали одну картинку (есть подсвеченное фото)
}
}
function
SetPairedFotos
(
folderName
,
folderType
,
data
)
{
if
(
folderType
==
'arch'
)
{
console
.
log
(
'AAA data = '
,
data
);
var
pairedFotos
=
{};
data
.
forEach
(
function
(
item
){
var
itemData
=
item
.
split
(
'-'
);
if
(
itemData
.
length
>
1
)
{
if
(
!
pairedFotos
[
itemData
[
0
]])
{
pairedFotos
[
itemData
[
0
]]
=
[];
}
pairedFotos
[
itemData
[
0
]].
push
(
item
);
}
});
console
.
log
(
'AAA pairedFotos = '
,
pairedFotos
);
var
pairs
=
Object
.
keys
(
pairedFotos
);
if
(
pairs
>
0
)
{
pairs
.
forEach
(
function
(
pair
){
$
(
'.b-foto_inner[data-foto="'
+
pairedFotos
[
pair
][
0
]
+
'"] '
,
$foldersArchContentWrap
).
click
();
$
(
'.b-foto_inner[data-foto="'
+
pairedFotos
[
pair
][
1
]
+
'"] '
,
$foldersArchContentWrap
).
click
();
});
}
}
}
function
RenderFoldersList
(
type
,
data
)
{
var
$target
,
templateFoldersList
=
_
.
template
(
''
+
'<% _.each(folders, function(item) { %>
\
n'
+
' <li class="b-list_folders-item" data-folder="<%= item %>"><%= item %><b></b></li>'
+
'<% }) %>
\
n'
);
if
(
type
==
'new'
)
$target
=
$listFoldersNew
;
if
(
type
==
'arch'
)
$target
=
$listFoldersArch
;
$target
.
append
(
templateFoldersList
({
folders
:
data
}));
}
function
getCurrenNumToSelect
(
$folderWrap
)
function
getCurrenNumToSelect
(
$folderWrap
)
{
{
for
(
let
n
=
1
;
n
<=
pairsCount
;
n
++
)
{
for
(
let
n
=
1
;
n
<=
pairsCount
;
n
++
)
{
...
@@ -165,46 +221,53 @@ $(document).ready(function(){
...
@@ -165,46 +221,53 @@ $(document).ready(function(){
}
}
// Клик на папку для загрузки фотографий:
function
ShowFoldersNew
()
$
(
'.b-list_folders-item'
).
on
(
'click'
,
function
(){
{
$listFoldersNew
.
show
();
$foldersNewContentWrap
.
show
();
}
function
ShowFoldersArch
()
{
$listFoldersArch
.
show
();
$foldersArchContentWrap
.
show
();
}
// Обработка нажатия клавиш:
$body
.
keyup
(
function
(
e
)
{
// Пробел
if
(
e
.
keyCode
==
32
)
{
var
var
$this
=
$
(
this
),
$activeFolder
=
$
(
'.b-folder-content.active'
,
$foldersContentWrap
),
$foldersContent
=
$
(
'.b-folder-content'
),
$fotos
=
$
(
'.b-foto_inner'
,
$activeFolder
);
$form
=
$
(
'#load-folder-form'
),
action
=
$form
.
attr
(
'action'
),
method
=
$form
.
attr
(
'method'
),
folderName
=
$
(
this
).
data
(
'folder'
),
data
=
{
folder
:
folderName
};
$foldersContent
.
hide
().
removeClass
(
'active'
);
if
(
$fotos
.
length
==
2
)
{
$fotos
.
first
().
click
();
}
}
if
(
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
).
length
>
0
)
{
// Вниз
console
.
log
(
'AAA отображаем'
);
if
(
e
.
keyCode
==
40
)
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
).
show
().
addClass
(
'active'
);
{
MarkFolderSelected
(
$this
);
var
}
else
{
$activeFolderItemList
=
$
(
'.b-list_folders-item.active'
),
console
.
log
(
'AAA подгружаем'
);
$nextFolderItem
=
$activeFolderItemList
.
next
();
StartLoading
();
$
.
ajax
(
action
,
{
$nextFolderItem
.
click
();
type
:
method
,
data
:
data
,
success
:
function
(
data
)
{
//console.log('AAA success', data);
StopLoading
();
RenderFilesList
(
folderName
,
data
);
MarkFolderSelected
(
$this
);
MarkFolderViewed
(
$this
);
},
error
:
function
(
rew
,
status
,
err
)
{
console
.
log
(
status
,
err
);
}
}
});
// Вверх
if
(
e
.
keyCode
==
38
)
{
var
$activeFolderItemList
=
$
(
'.b-list_folders-item.active'
),
$previousFolderItem
=
$activeFolderItemList
.
prev
();
$previousFolderItem
.
click
();
}
}
return
false
;
});
});
// Клик на фото:
// Клик на фото:
...
@@ -215,8 +278,9 @@ $(document).ready(function(){
...
@@ -215,8 +278,9 @@ $(document).ready(function(){
num
,
num
,
$currentFolderWrap
=
$this
.
parents
(
'.b-folder-content'
),
$currentFolderWrap
=
$this
.
parents
(
'.b-folder-content'
),
folderName
=
$currentFolderWrap
.
data
(
'folder'
),
folderName
=
$currentFolderWrap
.
data
(
'folder'
),
$pairedFoto
,
$pairedFoto
;
fadeDuration
=
100
;
console
.
log
(
'AAA folderName '
,
folderName
);
if
(
!
$this
.
hasClass
(
'selected'
))
if
(
!
$this
.
hasClass
(
'selected'
))
{
{
...
@@ -224,7 +288,7 @@ $(document).ready(function(){
...
@@ -224,7 +288,7 @@ $(document).ready(function(){
if
(
!
hasSelectedFoto
[
folderName
])
{
if
(
!
hasSelectedFoto
[
folderName
])
{
// выбор первого фото для пары:
// выбор первого фото для пары:
//
console.log('AAA 1-е фото в пару');
console
.
log
(
'AAA 1-е фото в пару'
);
num
=
currentNumToSelect
[
folderName
];
num
=
currentNumToSelect
[
folderName
];
hasSelectedFoto
[
folderName
]
=
true
;
hasSelectedFoto
[
folderName
]
=
true
;
$currentFolderWrap
.
addClass
(
'has-selected'
);
$currentFolderWrap
.
addClass
(
'has-selected'
);
...
@@ -308,45 +372,98 @@ $(document).ready(function(){
...
@@ -308,45 +372,98 @@ $(document).ready(function(){
SetCountPairedInFolderItemList
(
folderName
);
SetCountPairedInFolderItemList
(
folderName
);
});
});
//
Обработка нажатия клавиш
:
//
Клик на папку для загрузки фотографий
:
$
body
.
keyup
(
function
(
e
)
{
$
listFolders
.
on
(
'click'
,
'.b-list_folders-item'
,
function
()
{
// Пробел
if
(
e
.
keyCode
==
32
)
{
var
var
$activeFolder
=
$
(
'.b-folder-content.active'
,
$foldersContentWrap
),
$this
=
$
(
this
),
$fotos
=
$
(
'.b-foto_inner'
,
$activeFolder
);
$form
=
$
(
'#load-folder-form'
),
action
=
$form
.
attr
(
'action'
),
method
=
$form
.
attr
(
'method'
),
folderName
=
$this
.
data
(
'folder'
),
folderType
=
$this
.
parent
(
'.b-list_folders'
).
data
(
'type'
),
$foldersContent
=
$
(
'.b-preview_inner.'
+
folderType
+
' .b-folder-content'
),
data
=
{
folder
:
folderName
,
type
:
folderType
};
if
(
$fotos
.
length
==
2
)
{
$fotos
.
first
().
click
();
$foldersContent
.
hide
().
removeClass
(
'active'
);
if
(
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
).
length
>
0
)
{
console
.
log
(
'AAA отображаем'
);
$
(
'.b-folder-content[data-folder="'
+
folderName
+
'"]'
).
show
().
addClass
(
'active'
);
MarkFolderSelected
(
$this
,
folderType
);
}
else
{
console
.
log
(
'AAA подгружаем'
);
StartLoading
();
$
.
ajax
(
action
,
{
type
:
method
,
data
:
data
,
success
:
function
(
data
)
{
//console.log('AAA success', data);
StopLoading
();
RenderFilesList
(
folderName
,
folderType
,
data
);
SetPairedFotos
(
folderName
,
folderType
,
data
);
MarkFolderSelected
(
$this
,
folderType
);
MarkFolderViewed
(
$this
);
},
error
:
function
(
rew
,
status
,
err
)
{
console
.
log
(
status
,
err
);
$foldersContent
.
show
().
addClass
(
'active'
);
}
}
});
}
}
// Вниз
return
false
;
if
(
e
.
keyCode
==
40
)
});
{
var
$activeFolderItemList
=
$
(
'.b-list_folders-item.active'
),
$nextFolderItem
=
$activeFolderItemList
.
next
();
$nextFolderItem
.
click
();
// Изменение типа отображаемой папки:
}
$
(
'.b-list_select-folders'
).
on
(
'change'
,
function
(){
var
type
=
$
(
this
).
val
();
$listFolders
.
hide
();
$foldersContentWrapInner
.
hide
();
if
(
type
==
'new'
)
ShowFoldersNew
();
if
(
type
==
'arch'
)
ShowFoldersArch
();
// Загрузка списка папок:
if
(
$
(
'li'
,
$
(
'.b-list_folders.'
+
type
)).
length
==
0
)
{
console
.
log
(
'AAA загружаем список'
);
// Вверх
if
(
e
.
keyCode
==
38
)
{
var
var
$activeFolderItemList
=
$
(
'.b-list_folders-item.active'
),
$form
=
$
(
'#load-folders-list-form'
),
$previousFolderItem
=
$activeFolderItemList
.
prev
();
action
=
$form
.
attr
(
'action'
),
method
=
$form
.
attr
(
'method'
),
data
=
{
type
:
type
};
StartLoading
();
$
.
ajax
(
action
,
{
type
:
method
,
data
:
data
,
success
:
function
(
data
)
{
console
.
log
(
'AAA success'
,
data
);
StopLoading
();
RenderFoldersList
(
type
,
data
);
},
error
:
function
(
rew
,
status
,
err
)
{
console
.
log
(
status
,
err
);
}
});
$previousFolderItem
.
click
();
}
}
});
});
// Клик на "Сохранить" для объявления:
// Клик на "Сохранить" для объявления:
$
(
'.btn.btn-primary.save-folders'
)
.
on
(
'click'
,
function
(){
$
saveButton
.
on
(
'click'
,
function
(){
//if (!confirm('Применить действия над изображениями?')) return false;
//if (!confirm('Применить действия над изображениями?')) return false;
...
@@ -393,17 +510,17 @@ $(document).ready(function(){
...
@@ -393,17 +510,17 @@ $(document).ready(function(){
type
:
method
,
type
:
method
,
data
:
data
,
data
:
data
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
log
(
'AAA success'
,
data
);
/*
if
(
data
)
{
if
(
data
)
{
if(data.result === true && data.redirect) {
console
.
log
(
'AAA success'
,
data
);
document.location.href = data.redirect;
if
(
data
.
result
===
true
)
{
//document.location.href = data.redirect;
document
.
location
.
reload
();
}
}
if
(
data
.
result
===
false
&&
data
.
msg
)
{
if
(
data
.
result
===
false
&&
data
.
msg
)
{
$.showMessage('error', data.msg);
//
$.showMessage('error', data.msg);
}
}
}
}
*/
},
},
error
:
function
(
rew
,
status
,
err
)
{
error
:
function
(
rew
,
status
,
err
)
{
console
.
log
(
status
,
err
);
console
.
log
(
status
,
err
);
...
@@ -411,11 +528,11 @@ $(document).ready(function(){
...
@@ -411,11 +528,11 @@ $(document).ready(function(){
});
});
return
false
;
return
false
;
});
});
// Отображаем содержимое первой папки при загрузке страницы:
// Отображаем содержимое первой папки new при загрузке страницы:
$
(
'.b-list_folders-item'
).
first
().
click
();
ShowFoldersNew
();
//$('.b-list_folders-item').first().click();
});
});
\ No newline at end of file
src/src/App/Action/Admin/Feeds.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Action\Admin
;
use
App\Entity\Feeds\Feed
;
use
Psr\Http\Message\ResponseInterface
;
use
Psr\Http\Message\ServerRequestInterface
;
use
Slim\Flash\Messages
;
use
Zend\Diactoros\Response\HtmlResponse
;
use
Zend\Diactoros\Response\JsonResponse
;
use
Zend\Diactoros\Response\RedirectResponse
;
use
Zend\Hydrator\DelegatingHydrator
;
/**
* Class Feeds
* @package App\Action\Admin
*/
class
Feeds
extends
Common
{
const
ACTION_CREATE
=
'create'
;
const
ACTION_EDIT
=
'edit'
;
const
ACTION_LIST
=
'list'
;
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable|null $next
* @return HtmlResponse
*/
function
__invoke
(
ServerRequestInterface
$request
,
ResponseInterface
$response
,
callable
$next
=
null
)
{
if
(
$request
->
getMethod
()
==
'POST'
)
{
try
{
switch
(
$request
->
getAttribute
(
'action'
))
{
case
self
::
ACTION_CREATE
:
$response
=
$this
->
create
(
$request
);
break
;
case
self
::
ACTION_EDIT
:
$response
=
$this
->
edit
(
$request
);
break
;
default
:
}
}
catch
(
\Exception
$e
)
{
$data
=
[
'result'
=>
false
,
'msg'
=>
$e
->
getMessage
(),
];
$response
=
new
JsonResponse
(
$data
);
}
return
$response
;
}
elseif
(
$request
->
getAttribute
(
'action'
)
==
self
::
ACTION_CREATE
||
$request
->
getAttribute
(
'action'
)
==
self
::
ACTION_EDIT
)
{
$feed_id
=
$request
->
getAttribute
(
'id'
);
if
(
$feed_id
)
{
/** @var \App\Model\Feeds $feedsModel */
$feedsModel
=
$this
->
container
->
get
(
\App\Model\Feeds\Feeds
::
class
);
$feed
=
$feedsModel
->
findById
(
$feed_id
);
}
/** @var \App\Model\Currencies $currencyModel */
$currencyModel
=
$this
->
container
->
get
(
\App\Model\Currencies
::
class
);
$currencies
=
[];
foreach
(
$currencyModel
->
findAll
()
as
$currency
)
{
$currencies
[
$currency
->
getCode
()]
=
$currency
->
getName
();
}
/** @var \App\Model\Users $usersModel */
$usersModel
=
$this
->
container
->
get
(
\App\Model\Users
::
class
);
$all_users
=
$usersModel
->
findAll
();
/** @var \App\Model\Sites $sitesModel */
$sitesModel
=
$this
->
container
->
get
(
\App\Model\Sites
::
class
);
$sites
=
$sitesModel
->
findAll
()
->
toArray
();
$sites_users
=
[];
foreach
(
$sites
as
$site
)
{
$sites_users
[]
=
$site
[
'users_id'
];
}
$sites_users
=
array_unique
(
$sites_users
);
$users
=
[];
foreach
(
$all_users
as
$user
)
{
$user_id
=
$user
->
getId
();
if
(
!
in_array
(
$user_id
,
$sites_users
))
{
$users
[
$user_id
]
=
$user
->
getFullname
();
}
}
$response
=
new
HtmlResponse
(
$this
->
template
->
render
(
'adm::feeds/feed'
,
[
'lang'
=>
$request
->
getAttribute
(
'layoutInfo'
)
->
getLang
(),
'feed'
=>
$feed
,
'users'
=>
$users
,
'currencies'
=>
$currencies
,
'formats'
=>
$this
->
container
->
get
(
'config'
)[
'feed_conf'
][
'formats'
]
]));
return
$response
;
}
else
{
/** @var \App\Model\Sites $sitesModel */
$usersModel
=
$this
->
container
->
get
(
\App\Model\Users
::
class
);
/** @var \App\Model\Feeds $feedsModel */
$feedsModel
=
$this
->
container
->
get
(
\App\Model\Feeds\Feeds
::
class
);
$feeds
=
$feedsModel
->
findAll
()
->
toArray
();
foreach
(
$feeds
as
$key
=>
$feed
)
{
$user
=
$usersModel
->
findById
(
$feed
[
'clientid'
]);
if
(
$user
)
{
$feeds
[
$key
][
'clientid'
]
=
$user
->
getFullname
();
}
}
$response
=
new
HtmlResponse
(
$this
->
template
->
render
(
'adm::feeds/list'
,
[
'lang'
=>
$request
->
getAttribute
(
'layoutInfo'
)
->
getLang
(),
'feeds'
=>
$feeds
,
]));
return
$response
;
}
}
/**
* @param ServerRequestInterface $request
* @return HtmlResponse|RedirectResponse
*/
private
function
create
(
ServerRequestInterface
$request
)
{
/** @var \App\Model\Feeds $feedsModel */
$feedsModel
=
$this
->
container
->
get
(
\App\Model\Feeds\Feeds
::
class
);
/** @var DelegatingHydrator $hydrator */
$hydrator
=
$this
->
container
->
get
(
DelegatingHydrator
::
class
);
$data
=
$request
->
getParsedBody
();
$data
=
array
(
'title'
=>
(
trim
(
$data
[
'title'
])
!=
""
)
?
trim
(
$data
[
'title'
])
:
NULL
,
'active'
=>
(
bool
)
$data
[
'active'
],
'clientid'
=>
(
int
)
$data
[
'clientid'
],
'url'
=>
$data
[
'url'
],
'format'
=>
$data
[
'format'
],
'defaultcur'
=>
$data
[
'defaultcur'
],
);
$feed
=
$hydrator
->
hydrate
(
$data
,
new
Feed
());
// Проверка наличия фида с таким же названием:
if
((
$existed
=
$feedsModel
->
findOne
([
'title'
=>
$data
[
'title'
]])))
{
throw
new
\Exception
(
sprintf
(
'Feed with title <%s> already exists'
,
$data
[
'title'
]));
}
$result
=
$feedsModel
->
saveRetarg
(
$feed
);
if
(
!
$result
)
{
throw
new
\Exception
(
'DB error'
);
}
$response
=
new
JsonResponse
([
'result'
=>
true
,
'redirect'
=>
$this
->
router
->
generateUri
(
'adm.feed.edit'
,
[
'lang'
=>
$request
->
getAttribute
(
'layoutInfo'
)
->
getLang
(),
'id'
=>
$result
,
])
]);
return
$response
;
}
private
function
edit
(
ServerRequestInterface
$request
)
{
/** @var \App\Model\Feeds $feedsModel */
$feedsModel
=
$this
->
container
->
get
(
\App\Model\Feeds\Feeds
::
class
);
/** @var DelegatingHydrator $hydrator */
$hydrator
=
$this
->
container
->
get
(
DelegatingHydrator
::
class
);
$data
=
$request
->
getParsedBody
();
$feed_id
=
$request
->
getAttribute
(
'id'
);
$feed
=
$feedsModel
->
findById
(
$feed_id
);
if
(
!
$feed
)
{
throw
new
\Exception
(
'Feed not found'
);
}
//return new JsonResponse($data);
$data
[
'title'
]
=
(
trim
(
$data
[
'title'
])
!=
""
)
?
trim
(
$data
[
'title'
])
:
NULL
;
$feed
->
setTitle
(
$data
[
'title'
]);
$feed
->
setActive
((
bool
)
$data
[
'active'
]);
$feed
->
setClientid
((
int
)
$data
[
'clientid'
]);
$feed
->
setUrl
(
$data
[
'url'
]);
$feed
->
setFormat
(
$data
[
'format'
]);
$feed
->
setDefaultcur
(
$data
[
'defaultcur'
]);
// Проверка наличия фида с таким же названием:
if
((
$existed
=
$feedsModel
->
findOne
([
'title'
=>
$data
[
'title'
]])))
{
if
(
$existed
->
getId
()
!=
$feed
->
getId
())
{
throw
new
\Exception
(
sprintf
(
'Feed with title <%s> already exists'
,
$data
[
'title'
]));
}
}
//$result = $feedsModel->save($feed);
$result
=
$feedsModel
->
saveRetarg
(
$feed
);
if
(
!
$result
)
{
throw
new
\Exception
(
'DB error'
);
}
$response
=
new
JsonResponse
([
'result'
=>
true
,
'redirect'
=>
$this
->
router
->
generateUri
(
'adm.feed.edit'
,
[
'lang'
=>
$request
->
getAttribute
(
'layoutInfo'
)
->
getLang
(),
'id'
=>
$feed_id
,
])
]);
return
$response
;
}
}
\ No newline at end of file
src/src/App/Action/Admin/Index.php
View file @
8443f829
...
@@ -55,6 +55,7 @@ class Index extends Common
...
@@ -55,6 +55,7 @@ class Index extends Common
}
}
}
}
/** @var SupportService $auth */
/** @var SupportService $auth */
/*
/*
$auth = $this->container->get(SupportService::class);
$auth = $this->container->get(SupportService::class);
...
...
src/src/App/Action/Admin/Main.php
View file @
8443f829
...
@@ -43,6 +43,9 @@ class Main extends Common
...
@@ -43,6 +43,9 @@ class Main extends Common
{
{
const
SAVE_FOLDERS
=
'save_folders'
;
const
SAVE_FOLDERS
=
'save_folders'
;
const
LOAD_FOLDER
=
'load_folder'
;
const
LOAD_FOLDER
=
'load_folder'
;
const
LOAD_FOLDERS_LIST
=
'load_folders_list'
;
/**
/**
...
@@ -64,6 +67,9 @@ class Main extends Common
...
@@ -64,6 +67,9 @@ class Main extends Common
case
self
::
LOAD_FOLDER
:
case
self
::
LOAD_FOLDER
:
$response
=
$this
->
loadFolder
(
$request
);
$response
=
$this
->
loadFolder
(
$request
);
break
;
break
;
case
self
::
LOAD_FOLDERS_LIST
:
$response
=
$this
->
loadFoldersList
(
$request
);
break
;
default
:
default
:
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
...
@@ -81,14 +87,21 @@ class Main extends Common
...
@@ -81,14 +87,21 @@ class Main extends Common
private
function
saveFolders
(
ServerRequestInterface
$request
)
private
function
saveFolders
(
ServerRequestInterface
$request
)
{
{
$data
=
$request
->
getParsedBody
();
$data
=
$request
->
getParsedBody
();
//return new JsonResponse($data);
$folders_list
=
[];
$folders_list
=
[];
chdir
(
'public/'
);
return
new
JsonResponse
(
$data
);
foreach
(
$data
as
$folder
=>
$pairs
)
{
/*
$resp = [
'result' => true,
'folders' => $folders_list,
];
return new JsonResponse($resp);
*/
chdir
(
'public/'
);
foreach
(
$data
as
$folder
=>
$pairs
)
{
$from
=
"fotos/
$folder
"
;
$from
=
"fotos/
$folder
"
;
$to
=
"fotos-arch/
$folder
"
;
$to
=
"fotos-arch/
$folder
"
;
...
@@ -109,12 +122,10 @@ class Main extends Common
...
@@ -109,12 +122,10 @@ class Main extends Common
$pair_num
=
''
;
$pair_num
=
''
;
foreach
(
$pairs
as
$pair
=>
$pair_files
)
{
foreach
(
$pairs
as
$pair
=>
$pair_files
)
{
if
(
in_array
(
$entry
,
$pair_files
))
{
if
(
in_array
(
$entry
,
$pair_files
))
{
$pair_num
=
$pair
.
'-
-
'
;
$pair_num
=
$pair
.
'-'
;
break
;
break
;
}
}
}
}
//$folders_list[] = $folder;
copy
(
"
$from
/
$entry
"
,
"
$to
/
$pair_num$entry
"
);
copy
(
"
$from
/
$entry
"
,
"
$to
/
$pair_num$entry
"
);
}
else
{
}
else
{
copy
(
"
$from
/
$entry
"
,
"
$to
/
$entry
"
);
copy
(
"
$from
/
$entry
"
,
"
$to
/
$entry
"
);
...
@@ -138,22 +149,24 @@ class Main extends Common
...
@@ -138,22 +149,24 @@ class Main extends Common
chdir
(
'..'
);
chdir
(
'..'
);
return
new
JsonResponse
(
$folders_list
);
$resp
=
[
// Сформировать тестовые данные для статистики по фидам:
'result'
=>
true
,
if
(
$data
[
'feedTestData'
])
{
'folders'
=>
$folders_list
,
return
$this
->
renderFeedTestData
(
$request
)
;
]
;
}
return
new
JsonResponse
(
$resp
);
}
}
private
function
loadFolder
(
ServerRequestInterface
$request
)
private
function
loadFolder
(
ServerRequestInterface
$request
)
{
{
$data
=
$request
->
getParsedBody
();
$data
=
$request
->
getParsedBody
();
if
(
$data
[
'folder'
])
{
if
(
$data
[
'folder'
]
&&
$data
[
'type'
])
{
if
(
$data
[
'type'
]
==
'new'
)
$folder
=
'fotos'
;
if
(
$data
[
'type'
]
==
'arch'
)
$folder
=
'fotos-arch'
;
chdir
(
'public/fotos/'
.
$data
[
'folder'
]);
chdir
(
"public/
$folder
/"
.
$data
[
'folder'
]);
$dir
=
getcwd
();
$dir
=
getcwd
();
chdir
(
'../../..'
);
chdir
(
'../../..'
);
$entries
=
scandir
(
$dir
);
$entries
=
scandir
(
$dir
);
...
@@ -172,7 +185,36 @@ class Main extends Common
...
@@ -172,7 +185,36 @@ class Main extends Common
$data
=
$filelist
;
$data
=
$filelist
;
$response
=
new
JsonResponse
(
$data
);
$response
=
new
JsonResponse
(
$data
);
}
else
{
$data
=
[
'result'
=>
false
,
];
$response
=
new
JsonResponse
(
$data
);
}
return
$response
;
}
private
function
loadFoldersList
(
ServerRequestInterface
$request
)
{
$data
=
$request
->
getParsedBody
();
if
(
$data
[
'type'
])
{
if
(
$data
[
'type'
]
==
'new'
)
$folder
=
'fotos'
;
if
(
$data
[
'type'
]
==
'arch'
)
$folder
=
'fotos-arch'
;
chdir
(
"public/
$folder
"
);
$dir
=
getcwd
();
chdir
(
'../..'
);
$folders
=
scandir
(
$dir
);
foreach
(
$folders
as
$key
=>
$folder_name
)
{
if
(
strpos
(
$folder_name
,
'.'
)
>
-
1
)
{
unset
(
$folders
[
$key
]);
}
}
$response
=
new
JsonResponse
(
$folders
);
}
else
{
}
else
{
$data
=
[
$data
=
[
'result'
=>
false
,
'result'
=>
false
,
...
...
src/src/App/Model/AmSystem/Banners.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Model\AmSystem
;
use
App\Model\Common
;
/**
* Class Banners
* @package App\Model
*/
class
Banners
extends
Common
{
}
\ No newline at end of file
src/src/App/Model/AmSystem/Campaigns.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Model\AmSystem
;
use
App\Model\Common
;
/**
* Class Campaigns
* @package App\Model
*/
class
Campaigns
extends
Common
{
}
\ No newline at end of file
src/src/App/Model/AmSystem/Groups.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Model\AmSystem
;
use
App\Model\Common
;
/**
* Class Groups
* @package App\Model
*/
class
Groups
extends
Common
{
}
\ No newline at end of file
src/src/App/Model/Feeds/Categories.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Model\Feeds
;
use
App\Model\Common
;
/**
* Class Categories
* @package App\Model
*/
class
Categories
extends
Common
{
}
\ No newline at end of file
src/src/App/Model/Feeds/CategoryFees.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Model\Feeds
;
use
App\Model\Common
;
/**
* Class CategoryFees
* @package App\Model
*/
class
CategoryFees
extends
Common
{
public
function
saveRetargCatFee
(
$entity
,
$action
)
{
$data_entity
=
$this
->
delegatingHydrator
->
extract
(
$entity
);
$table_fields
=
$this
->
tableGateway
->
getColumns
();
$data
=
[];
foreach
(
$table_fields
as
$field
)
{
if
(
isset
(
$data_entity
[
mb_strtolower
(
$field
)]))
{
$data
[
$field
]
=
$data_entity
[
mb_strtolower
(
$field
)];
}
}
if
(
$action
==
'insert'
)
{
$query
=
function
(
$data
)
{
$this
->
tableGateway
->
insert
(
$data
);
return
$data
[
'CatID'
];
};
}
if
(
$action
==
'update'
)
{
$query
=
function
(
$data
)
{
$id
=
$data
[
'CatID'
];
unset
(
$data
[
'CatID'
]);
$this
->
tableGateway
->
update
(
$data
,
[
'CatID'
=>
$id
]);
return
$id
;
};
}
try
{
$this
->
tableGateway
->
getAdapter
()
->
getDriver
()
->
getConnection
()
->
beginTransaction
();
$id
=
$query
(
$data
);
$this
->
tableGateway
->
getAdapter
()
->
getDriver
()
->
getConnection
()
->
commit
();
}
catch
(
\Exception
$e
)
{
$this
->
tableGateway
->
getAdapter
()
->
getDriver
()
->
getConnection
()
->
rollback
();
throw
$e
;
}
return
$id
;
}
public
function
deleteRetargCatFee
(
$entity
)
{
$result
=
false
;
$cat_id
=
$entity
->
getCatid
();
if
(
$entity
)
{
$result
=
$this
->
tableGateway
->
delete
([
'CatID'
=>
$cat_id
]);
}
else
{
throw
new
\Exception
(
"Record not found ID:"
.
$cat_id
);
}
return
$result
;
}
}
\ No newline at end of file
src/src/App/Model/Feeds/Feeds.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Model\Feeds
;
use
App\Model\Common
;
/**
* Class Feeds
* @package App\Model
*/
class
Feeds
extends
Common
{
public
function
getIdListByUser
(
$userId
)
{
$feeds
=
$this
->
findAll
([
'clientid'
=>
$userId
])
->
toArray
();
if
(
$feeds
)
{
$feed_id_list
=
[];
foreach
(
$feeds
as
$feed_item
)
{
$feed_id
=
$feed_item
[
'id'
];
if
(
!
in_array
(
$feed_id
,
$feed_id_list
))
{
$feed_id_list
[]
=
$feed_id
;
}
}
}
return
$feed_id_list
;
}
}
\ No newline at end of file
src/src/App/Model/Feeds/OrdersStatus.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Model\Feeds
;
use
App\Model\Common
;
/**
* Class OrdersStatus
* @package App\Model
*/
class
OrdersStatus
extends
Common
{
public
function
saveRetargOrderStatus
(
$entity
,
$action
)
{
$data_entity
=
$this
->
delegatingHydrator
->
extract
(
$entity
);
$table_fields
=
$this
->
tableGateway
->
getColumns
();
$data
=
[];
foreach
(
$table_fields
as
$field
)
{
if
(
isset
(
$data_entity
[
mb_strtolower
(
$field
)]))
{
$data
[
$field
]
=
$data_entity
[
mb_strtolower
(
$field
)];
}
}
if
(
$action
==
'insert'
)
{
$query
=
function
(
$data
)
{
$this
->
tableGateway
->
insert
(
$data
);
return
$data
[
'order_id'
];
};
}
if
(
$action
==
'update'
)
{
$query
=
function
(
$data
)
{
$id
=
$data
[
'order_id'
];
unset
(
$data
[
'order_id'
]);
$this
->
tableGateway
->
update
(
$data
,
[
'order_id'
=>
$id
]);
return
$id
;
};
}
try
{
$this
->
tableGateway
->
getAdapter
()
->
getDriver
()
->
getConnection
()
->
beginTransaction
();
$id
=
$query
(
$data
);
$this
->
tableGateway
->
getAdapter
()
->
getDriver
()
->
getConnection
()
->
commit
();
}
catch
(
\Exception
$e
)
{
$this
->
tableGateway
->
getAdapter
()
->
getDriver
()
->
getConnection
()
->
rollback
();
throw
$e
;
}
return
$id
;
}
public
function
deleteRetargOrderStatus
(
$entity
)
{
$result
=
false
;
$feed_id
=
$entity
->
getFeedId
();
$order_id
=
$entity
->
getOrderId
();
if
(
$entity
)
{
$result
=
$this
->
tableGateway
->
delete
([
'feed_id'
=>
$feed_id
,
'order_id'
=>
$order_id
]);
}
else
{
throw
new
\Exception
(
"Record not found ID:"
.
$feed_id
.
" "
.
$order_id
);
}
return
$result
;
}
}
\ No newline at end of file
src/src/App/Model/Feeds/ShopFeeds.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Model\Feeds
;
use
App\Model\Common
;
/**
* Class ShopFeeds
* @package App\Model
*/
class
ShopFeeds
extends
Common
{
}
\ No newline at end of file
src/src/App/Model/Feeds/Shops.php
deleted
100644 → 0
View file @
ee953aa2
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Model\Feeds
;
use
App\Model\Common
;
/**
* Class Shops
* @package App\Model
*/
class
Shops
extends
Common
{
}
\ No newline at end of file
src/src/App/Model/Statistics.php
deleted
100644 → 0
View file @
ee953aa2
<?php
namespace
App\Model
;
use
DateTime
;
class
Statistics
{
private
$hashSolt
=
''
;
public
function
__construct
(
/*Sites $sites, Zones $zones, $countries*/
)
{
$this
->
hashSolt
=
'FsRpCKc021PzwqOR8o1mXLe8AIS6YmnfkDvECBY6MzGWHhceS4EvdOnW7dYHt7AA'
;
}
// Данные по отчетам фидов
public
function
getFeedStatData
(
$report_type
,
$feed_id_list
,
$dates
,
$report_conf
)
{
$timeDiff
=
(
strtotime
(
$dates
[
1
])
-
strtotime
(
$dates
[
0
]))
/
(
24
*
60
*
60
);
// Определяем разрешение выборки (группировку) по времени:
if
(
$timeDiff
==
0
)
// Одни сутки
{
$dates_group
=
"Min"
;
}
else
// Несколько суток
{
$dates_group
=
"Day"
;
}
$dates
=
array
(
'group'
=>
$dates_group
,
'start'
=>
$dates
[
0
],
'end'
=>
$dates
[
1
],
);
// Параметры запроса по типу отчета:
$type
=
$report_conf
[
'type'
];
$fields
=
$report_conf
[
'fields'
];
// Данные для запроса:
if
(
$report_type
==
'common'
)
{
$dataRequest
=
array
(
'method'
=>
"reports"
,
'data'
=>
array
(
'type'
=>
$type
,
'filters'
=>
array
(
'FeedID'
=>
array
(
'values'
=>
$feed_id_list
),
),
'fields'
=>
$fields
,
'dates'
=>
$dates
,
)
);
}
if
(
$report_type
==
'transactions'
)
{
$dataRequest
=
array
(
'method'
=>
$type
,
'data'
=>
array
(
'feed_id'
=>
$feed_id_list
,
'start_date'
=>
$dates
[
'start'
],
'end_date'
=>
$dates
[
'end'
],
)
);
}
//return $dataRequest;
//$stats = $this->apiRequest($dataRequest);
//return $stats;
try
{
$stats
=
$this
->
apiRequest
(
$dataRequest
);
}
catch
(
\Exception
$e
)
{
$stats
[
'status'
]
=
'Error'
;
}
//return $stats;
// В запросе ошибка или отсутствуют данные для статистики:
if
(
$stats
[
'status'
]
==
'Error'
)
{
return
$stats
;
}
if
(
$stats
[
'data'
]
==
[])
{
return
null
;
}
$dataStats
=
array
();
$dataStats
[
'report'
]
=
$report_type
;
// Данные для отчета 'common':
if
(
$report_type
==
'common'
)
{
$period
=
array
();
// Формируем данные для временного промежутка
function
AddDataStats
(
&
$data_stats
,
$data
,
$date_type
)
{
$min_koef
=
(
$date_type
==
'interval'
)
?
1
:
5
;
foreach
(
$data
as
$cat
=>
$value
)
{
$data_stats
[
$cat
][]
=
$value
/
$min_koef
;
}
//$data_stats['AdMoney'][] = 224 * $data['Orders']; // временно
}
function
AddDataStatsFixedAdMoney
(
&
$data_stats
,
$data
,
$date_type
)
{
foreach
(
$data
as
$cat
=>
$value
)
{
if
(
$cat
==
'AdMoney'
)
{
$data_stats
[
'AdMoney'
][]
=
224
*
$data
[
'Orders'
];
}
else
{
$data_stats
[
$cat
][]
=
$value
;
}
}
}
// Формируем пустые данные для временного промежутка
function
AddDataStatsNull
(
&
$data_stats
,
$cats
)
{
foreach
(
$cats
as
$cat
)
{
$data_stats
[
$cat
][]
=
0
;
}
//$data_stats['AdMoney'][] = 0; // временно
}
// Логика формирования данных по временному интервалу:
/*
if (false) {
if ($timeDiff == 0) // Одни сутки
{
$dataStats['type'] = 'day';
// Формируем пустые данные (для отсутствующих значений во временной точке):
foreach ($stats['data']['Day'] as $day=>$value_day) {
foreach ($value_day['Min'] as $min=>$data) {
$data_null = $data;
break;
}
break;
}
foreach ($data_null as $key=>$value) {
$data_null[$key] = 0;
}
// Формируем 5-минутные интервалы:
for ($i=0; $i<288; $i++) {
$min = $i * 60 * 5;
$period[] = gmdate("H:i", $min);
}
foreach ($stats['data']['Day'] as $day) {
// Формируем временные интервалы, для которых есть значения:
$dates_min = [];
foreach (array_keys($day['Min']) as $min) {
$dates_min[date("H:i", strtotime($min))] = $min;
}
foreach ($period as $min_value) {
$value_min = ($dates_min[$min_value]) ? $day['Min'][$dates_min[$min_value]] : $data_null;
AddDataStats($dataStats, $value_min, $metric, $dataStats['type']);
}
}
}
elseif (!$by_days) // Набор дат
{
$dataStats['type'] = 'compare';
// Формируем пустые данные (для отсутствующих значений во временной точке):
foreach ($stats['data']['Day'] as $day=>$value_day) {
foreach ($value_day['Min'] as $min=>$data) {
$data_null = $data;
break;
}
break;
}
foreach ($data_null as $key=>$value) {
$data_null[$key] = 0;
}
// Формируем 5-минутные интервалы:
for ($i=0; $i<288; $i++) {
$min = $i * 60 * 5;
$period[] = gmdate("H:i", $min);
}
foreach ($stats['data']['Day'] as $day=>$value_day) {
$dataStats[date("Y-m-d", strtotime($day))] = [];
// Формируем временные интервалы, для которых есть значения:
$dates_min = [];
foreach (array_keys($value_day['Min']) as $min) {
$dates_min[date("H:i", strtotime($min))] = $min;
}
foreach ($period as $min_value) {
$data = ($dates_min[$min_value]) ? $value_day['Min'][$dates_min[$min_value]] : $data_null;
AddDataStats($dataStats[date("Y-m-d", strtotime($day))], $data, $metric, $dataStats['type']);
}
}
}
else // Несколько суток
{
$dataStats['type'] = 'interval';
foreach ($stats['data']['Day'] as $day=>$value_day) {
$period[] = $day;
AddDataStats($dataStats, $value_day, $metric, $dataStats['type']);
}
}
}
*/
$dataStats
[
'type'
]
=
'interval'
;
// Спискок всех дат из запроса стастистики:
$all_period
=
array
();
$begin
=
new
DateTime
(
$dates
[
'start'
]);
$end
=
new
DateTime
(
$dates
[
'end'
]);
for
(
$i
=
$begin
;
$i
<=
$end
;
$i
->
modify
(
'+1 day'
)){
$all_period
[]
=
$i
->
format
(
"Y-m-d"
);
}
// Список дат, полученных в статистике:
$stat_days
=
array_keys
(
$stats
[
'data'
][
'Day'
]);
// Список категорий в данных статистики:
$stat_cats
=
array_keys
(
$stats
[
'data'
][
'Day'
][
$stat_days
[
0
]]);
foreach
(
$all_period
as
$day_item
)
{
$item
=
new
DateTime
(
$day_item
);
$stat_from
=
new
DateTime
(
$stat_days
[
0
]);
$stat_to
=
new
DateTime
(
$stat_days
[
count
(
$stat_days
)
-
1
]);
//if (($item>= $stat_from) && ($item<= $stat_to)) {
if
((
$item
>=
$stat_from
))
{
$period
[]
=
$day_item
;
if
(
$stats
[
'data'
][
'Day'
][
$day_item
])
{
AddDataStats
(
$dataStats
,
$stats
[
'data'
][
'Day'
][
$day_item
],
$dataStats
[
'type'
]);
/*
if (strtotime($day_item)< strtotime('2019-04-01')) {
AddDataStatsFixedAdMoney($dataStats, $stats['data']['Day'][$day_item], $dataStats['type']);
} else {
AddDataStats($dataStats, $stats['data']['Day'][$day_item], $dataStats['type']);
}
*/
}
else
{
AddDataStatsNull
(
$dataStats
,
$stat_cats
);
}
}
}
/*
foreach ($stats['data']['Day'] as $day=>$value_day) {
$period[] = $day;
AddDataStats($dataStats, $value_day, $dataStats['type']);
}
*/
$dataStats
[
'period'
]
=
$period
;
}
// Данные для отчета 'transactions':
if
(
$report_type
==
'transactions'
)
{
foreach
(
$stats
[
'data'
]
as
$item
)
{
$dataStats
[
'period'
][]
=
[
$item
[
'ForeignID'
],
$item
[
'FeedID'
]];
$dataStats
[
'ViewID'
][]
=
$item
[
'ViewID'
];
$dataStats
[
'Timestamp'
][]
=
$item
[
'Timestamp'
];
$dataStats
[
'OrderSum'
][]
=
$item
[
'OrderSum'
];
$dataStats
[
'Basket'
][]
=
$item
[
'Basket'
];
$dataStats
[
'AdMoney'
][]
=
$item
[
'AdMoney'
];
/*
if (strtotime($item['Timestamp'])< strtotime('2019-04-01')) {
$dataStats['AdMoney'][] = 224;
} else {
$dataStats['AdMoney'][] = $item['AdMoney'];
}
*/
}
}
$stats
=
$dataStats
;
return
$stats
;
}
// Данные по статистике по клику
public
function
getViewIdStatData
(
$feed_id
,
$view_id
)
{
$dataRequest
=
array
(
'method'
=>
'feed_click_history'
,
'data'
=>
array
(
'feed_id'
=>
(
int
)
$feed_id
,
'view_id'
=>
$view_id
)
);
//return $dataRequest;
//$stats = $this->apiRequest($dataRequest);
//return $stats;
try
{
$stats
=
$this
->
apiRequest
(
$dataRequest
);
}
catch
(
\Exception
$e
)
{
$stats
[
'status'
]
=
'Error'
;
}
// В запросе ошибка или отсутствуют данные для статистики:
if
(
$stats
[
'status'
]
==
'Error'
)
{
return
$stats
;
}
if
(
$stats
[
'data'
]
==
[])
{
return
null
;
}
$stats
=
$stats
[
'data'
];
return
$stats
;
}
// Данные по статистике по заказу фида
public
function
getOrderIdStatData
(
$feed_id
,
$order_id
)
{
$dataRequest
=
array
(
'method'
=>
'feed_order_history'
,
'data'
=>
array
(
'feed_id'
=>
(
int
)
$feed_id
,
'order_id'
=>
$order_id
)
);
//return $dataRequest;
//$stats = $this->apiRequest($dataRequest);
//return $stats;
try
{
$stats
=
$this
->
apiRequest
(
$dataRequest
);
}
catch
(
\Exception
$e
)
{
$stats
[
'status'
]
=
'Error'
;
}
// В запросе ошибка или отсутствуют данные для статистики:
if
(
$stats
[
'status'
]
==
'Error'
)
{
return
$stats
;
}
if
(
$stats
[
'data'
]
==
[])
{
return
null
;
}
$stats
=
$stats
[
'data'
];
return
$stats
;
}
// Добавление спец. полей в статистики по кампаниям (баннерам)
private
function
AddSpecialFields
(
&
$stats
)
{
if
(
$taget_action
==
'load'
)
{
$stats
[
'views'
]
=
$stats
[
'loads'
];
$stats
[
'reach'
]
=
$stats
[
'reach_load'
];
}
else
{
$stats
[
'reach'
]
=
$stats
[
'reach_view'
];
}
unset
(
$stats
[
'loads'
]);
unset
(
$stats
[
'reach_load'
]);
unset
(
$stats
[
'reach_view'
]);
$views
=
$stats
[
'views'
];
$money
=
$stats
[
'money'
];
$clicks
=
$stats
[
'clicks'
];
$stats
[
'ctr'
]
=
(
$views
!=
0
)
?
round
((
$clicks
/
$views
)
*
100
,
2
)
:
0
;
$stats
[
'cpm'
]
=
(
$views
!=
0
)
?
round
((
$money
/
$views
)
*
1000
,
3
)
:
0
;
$stats
[
'cpc'
]
=
(
$clicks
!=
0
)
?
round
((
$money
/
$clicks
),
2
)
:
0
;
$stats
[
'money'
]
=
round
(
$stats
[
'money'
],
2
);
}
// Данные для статистики по баннерам
public
function
getBannersStat
(
$banners_id_list
,
$taget_action
,
$dates
)
{
$dataRequest
=
array
(
'method'
=>
(
$dates
)
?
'banner_day'
:
'banner_total'
,
'data'
=>
array
(
'ids'
=>
$banners_id_list
,
)
);
if
(
$dates
)
{
$dataRequest
[
'data'
][
'start_date'
]
=
$dates
[
0
];
$dataRequest
[
'data'
][
'end_date'
]
=
$dates
[
1
];
}
//return $dataRequest;
try
{
$stats
=
$this
->
apiRequest
(
$dataRequest
);
}
catch
(
\Exception
$e
)
{
$stats
[
'status'
]
=
'Error'
;
}
//return $stats;
if
(
$stats
)
{
$this
->
AddSpecialFields
(
$stats
);
$dataStats
=
$stats
;
}
return
$dataStats
;
}
// Данные для статистики по кампании (баннеры)
public
function
getCampaignsStat
(
$type
,
$id_list
,
$taget_action
,
$dates
,
$by_days
=
false
)
{
if
(
$type
==
'campaign'
)
{
$method
=
(
$dates
)
?
'camp_day'
:
'camp_total'
;
}
else
{
$method
=
(
$dates
)
?
'cgroup_day'
:
'cgroup_total'
;
}
$dataRequest
=
array
(
'method'
=>
$method
,
'data'
=>
array
(
'ids'
=>
$id_list
,
)
);
if
(
$dates
)
{
$dataRequest
[
'data'
][
'start_date'
]
=
$dates
[
0
];
if
(
$dates
[
1
]
&&
$dates
[
1
]
<
date
(
"Y-m-d"
))
{
$date_end
=
$dates
[
1
];
}
else
{
$date_end
=
date
(
"Y-m-d"
);
}
$dataRequest
[
'data'
][
'end_date'
]
=
$date_end
;
// последние 90 дней, если кампания долго идет
/*
$dateStart = new \DateTime($dates[0]);
$dateEnd = new \DateTime($date_end);
$interval = $dateEnd->diff($dateStart);
if ($interval->d > 3) {
$dataRequest['data']['start_date'] = $dateEnd->modify('-3 day')->format('Y-m-d');
}
*/
if
(
$by_days
)
{
$dataRequest
[
'data'
][
'by_days'
]
=
true
;
}
}
//return $dataRequest;
try
{
$stats
=
$this
->
apiRequest
(
$dataRequest
);
}
catch
(
\Exception
$e
)
{
$stats
[
'status'
]
=
'Error'
;
return
$stats
;
}
//return $stats;
if
(
$stats
)
{
if
(
!
$dates
||
!
$by_days
)
{
$this
->
AddSpecialFields
(
$stats
);
$dataStats
=
$stats
;
}
else
{
foreach
(
$stats
as
$day
=>
$stat
)
{
$this
->
AddSpecialFields
(
$stats
[
$day
]);
}
// Формируем данные для временного промежутка
function
AddDataStats
(
&
$data_stats
,
$data
)
{
foreach
(
$data
as
$cat
=>
$value
)
{
$data_stats
[
$cat
][]
=
$value
;
}
}
// Формируем пустые данные для временного промежутка
function
AddDataStatsNull
(
&
$data_stats
,
$cats
)
{
foreach
(
$cats
as
$cat
)
{
$data_stats
[
$cat
][]
=
0
;
}
}
// Спискок всех дат из запроса стастистики:
$all_period
=
array
();
$begin
=
new
DateTime
(
$dates
[
0
]);
$end
=
new
DateTime
(
$dates
[
1
]);
for
(
$i
=
$begin
;
$i
<=
$end
;
$i
->
modify
(
'+1 day'
)){
$all_period
[]
=
$i
->
format
(
"Y-m-d"
);
}
// Список дат, полученных в статистике:
$stat_days
=
array_keys
(
$stats
);
// Список категорий в данных статистики:
$stat_cats
=
array_keys
(
$stats
[
$stat_days
[
0
]]);
$dataStats
=
[];
foreach
(
$all_period
as
$day_item
)
{
$item
=
new
DateTime
(
$day_item
);
$stat_from
=
new
DateTime
(
$stat_days
[
0
]);
$stat_to
=
new
DateTime
(
$stat_days
[
count
(
$stat_days
)
-
1
]);
if
(
$dates
[
1
]
&&
$dates
[
1
]
<
date
(
"Y-m-d"
))
{
$period
[]
=
$day_item
;
if
(
$stats
[
$day_item
])
{
AddDataStats
(
$dataStats
,
$stats
[
$day_item
]);
}
else
{
AddDataStatsNull
(
$dataStats
,
$stat_cats
);
}
}
else
{
//Если у кампании конца нет, то по последний день когда были показы:
//if (($item >= $stat_from) && ($item <= $stat_to)) {
//if (($item >= $stat_from)) {
if
((
$item
<=
$stat_to
))
{
$period
[]
=
$day_item
;
if
(
$stats
[
$day_item
])
{
AddDataStats
(
$dataStats
,
$stats
[
$day_item
]);
}
else
{
AddDataStatsNull
(
$dataStats
,
$stat_cats
);
}
}
}
}
$dataStats
[
'period'
]
=
$period
;
}
}
return
$dataStats
;
}
// Данные для статистики кампании по сайтам
public
function
getCampaignsSitesStat
(
$type
,
$id
,
$taget_action
,
$dates
)
{
if
(
$type
==
'campaign'
)
{
$method
=
'camp_zone'
;
}
else
{
$method
=
'cgroup_zone'
;
}
$dataRequest
=
array
(
'method'
=>
$method
,
'data'
=>
array
(
'id'
=>
$id
,
'start_date'
=>
$dates
[
0
],
'end_date'
=>
$dates
[
1
]
)
);
//return $dataRequest;
try
{
$stats
=
$this
->
apiRequest
(
$dataRequest
);
}
catch
(
\Exception
$e
)
{
$stats
[
'status'
]
=
'Error'
;
return
$stats
;
}
//return $stats;
if
(
$stats
)
{
foreach
(
$stats
as
$site
=>
$stat
)
{
$this
->
AddSpecialFields
(
$stats
[
$site
]);
if
(
$stat
[
'sub'
])
{
foreach
(
$stat
[
'sub'
]
as
$sub
=>
$stat
)
{
$this
->
AddSpecialFields
(
$stats
[
$site
][
'sub'
][
$sub
]);
}
}
}
$dataStats
=
$stats
;
}
return
$dataStats
;
}
// Данные для статистики кампании по регионам
public
function
getCampaignsRegionsStat
(
$type
,
$id
,
$taget_action
,
$dates
)
{
if
(
$type
==
'campaign'
)
{
$method
=
'camp_geo'
;
}
else
{
$method
=
'cgroup_geo'
;
}
$dataRequest
=
array
(
'method'
=>
$method
,
'data'
=>
array
(
'id'
=>
$id
,
'start_date'
=>
$dates
[
0
],
'end_date'
=>
$dates
[
1
]
)
);
//return $dataRequest;
try
{
$stats
=
$this
->
apiRequest
(
$dataRequest
);
}
catch
(
\Exception
$e
)
{
$stats
[
'status'
]
=
'Error'
;
return
$stats
;
}
//return $stats;
if
(
$stats
)
{
foreach
(
$stats
as
$region
=>
$stat
)
{
$this
->
AddSpecialFields
(
$stats
[
$region
]);
if
(
$stat
[
'sub'
])
{
foreach
(
$stat
[
'sub'
]
as
$sub
=>
$stat
)
{
$this
->
AddSpecialFields
(
$stats
[
$region
][
'sub'
][
$sub
]);
}
}
}
$dataStats
=
$stats
;
}
return
$dataStats
;
}
// Запрос к API:
private
function
apiRequest
(
$data
)
{
$playload
=
json_encode
(
$data
);
$url
=
'http://stat.instraroam.net/json/'
.
md5
(
$playload
.
$this
->
hashSolt
);
//$url = 'https://9261bdc7.ngrok.io/json/'.md5($playload . $this->hashSolt);
$cl
=
curl_init
();
curl_setopt
(
$cl
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$cl
,
CURLOPT_POST
,
true
);
curl_setopt
(
$cl
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$cl
,
CURLOPT_HTTPHEADER
,
array
(
'Content-Type:application/json'
));
curl_setopt
(
$cl
,
CURLOPT_POSTFIELDS
,
$playload
);
$result
=
curl_exec
(
$cl
);
$info
=
curl_getinfo
(
$cl
);
curl_close
(
$cl
);
if
(
$info
[
'http_code'
]
!=
200
)
{
throw
new
\Exception
(
'Error. '
.
$info
[
'http_code'
]);
}
return
json_decode
(
$result
,
1
);
}
}
src/templates/app/main.phtml
View file @
8443f829
...
@@ -34,8 +34,9 @@ $this->headLink()
...
@@ -34,8 +34,9 @@ $this->headLink()
->
appendStylesheet
(
'/css/styles-main.css'
)
->
appendStylesheet
(
'/css/styles-main.css'
)
;
;
$form_save_link
=
$this
->
url
(
'adm.main.save'
,[
'lang'
=>
$this
->
lang
]);
$form_save_link
=
$this
->
url
(
'adm.main.save'
);
$form_load_link
=
$this
->
url
(
'adm.main.loadfolder'
,[
'lang'
=>
$this
->
lang
]);
$form_load_link
=
$this
->
url
(
'adm.main.loadfolder'
);
$form_loadlist_link
=
$this
->
url
(
'adm.main.loadfolderslist'
);
$colors_active
=
$this
->
colors_active
;
$colors_active
=
$this
->
colors_active
;
$folders
=
$this
->
folders
;
$folders
=
$this
->
folders
;
...
@@ -49,27 +50,35 @@ $dir = $this->dir;
...
@@ -49,27 +50,35 @@ $dir = $this->dir;
<div
class=
"b-list"
>
<div
class=
"b-list"
>
<select
class=
"b-list_select-folders form-control"
>
<select
class=
"b-list_select-folders form-control"
>
<option
value=
"new"
>
Новые
</option>
<option
value=
"new"
>
Новые
</option>
<option
value=
"arch
ive
"
>
Архив
</option>
<option
value=
"arch"
>
Архив
</option>
</select>
</select>
<ul
class=
"b-list_folders"
>
<ul
class=
"b-list_folders
new"
data-type=
"new
"
>
<?php
foreach
(
$folders
as
$folder
)
:
?>
<?php
foreach
(
$folders
as
$folder
)
:
?>
<li
class=
"b-list_folders-item"
data-folder=
"
<?=
$folder
?>
"
>
<?=
$folder
?>
<b></b></li>
<li
class=
"b-list_folders-item"
data-folder=
"
<?=
$folder
?>
"
>
<?=
$folder
?>
<b></b></li>
<?php
endforeach
;
?>
<?php
endforeach
;
?>
</ul>
</ul>
<form
id=
"save-folders-form"
action=
"
<?=
$form_save_link
?>
"
method=
"POST"
></form>
<ul
class=
"b-list_folders arch"
data-type=
"arch"
>
</ul>
<form
id=
"load-folders-list-form"
action=
"
<?=
$form_loadlist_link
?>
"
method=
"POST"
></form>
<form
id=
"load-folder-form"
action=
"
<?=
$form_load_link
?>
"
method=
"POST"
></form>
<form
id=
"load-folder-form"
action=
"
<?=
$form_load_link
?>
"
method=
"POST"
></form>
<a
class=
"btn btn-primary save-folders"
href=
"#"
>
Сохранить
</a>
<form
id=
"save-folders-form"
action=
"
<?=
$form_save_link
?>
"
method=
"POST"
></form>
<a
class=
"btn btn-primary save-folders disabled"
href=
"#"
disabled
>
Сохранить
</a>
</div>
</div>
<div
class=
"b-preview col"
data-colors=
<?=
(
$colors_active
?
json_encode
(
$colors_active
)
:
''
)
?>
data-pairs_count=
<?=
(
$pairs_count
?
json_encode
(
$pairs_count
)
:
''
)
?>
>
<div
class=
"b-preview col"
data-colors=
<?=
(
$colors_active
?
json_encode
(
$colors_active
)
:
''
)
?>
data-pairs_count=
<?=
(
$pairs_count
?
json_encode
(
$pairs_count
)
:
''
)
?>
>
<div
class=
"b-loading"
></div>
<div
class=
"b-loading"
></div>
<div
class=
"b-preview_inner new col"
>
</div>
<div
class=
"b-preview_inner arch col"
>
</div>
</div>
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment