Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
customQueries
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bolt Extensions
customQueries
Commits
179d70d4
Commit
179d70d4
authored
Dec 04, 2018
by
Van
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(all) : autocomplete first item fixed. Exclude and include empty . All fields bt contenttypes
parent
fe66bb39
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
20 deletions
+33
-20
CustomQueriesExtension.php
src/CustomQueriesExtension.php
+28
-17
app.css
web/css/app.css
+5
-3
app.js
web/js/app.js
+0
-0
No files found.
src/CustomQueriesExtension.php
View file @
179d70d4
...
@@ -73,10 +73,11 @@ class CustomQueriesExtension extends SimpleExtension
...
@@ -73,10 +73,11 @@ class CustomQueriesExtension extends SimpleExtension
public
function
getQueriesResults
(
$input
)
public
function
getQueriesResults
(
$input
)
{
{
if
(
$input
==
''
)
{
if
(
$input
==
''
)
{
return
''
;
return
''
;
}
}
$json
=
json_decode
(
$input
,
true
);
$json
=
json_decode
(
$input
,
true
);
if
(
!
$json
||
empty
(
$json
))
{
if
(
!
$json
||
empty
(
$json
))
{
return
''
;
return
''
;
}
}
...
@@ -85,7 +86,11 @@ class CustomQueriesExtension extends SimpleExtension
...
@@ -85,7 +86,11 @@ class CustomQueriesExtension extends SimpleExtension
$storage
=
$this
->
getContainer
()[
'storage'
];
$storage
=
$this
->
getContainer
()[
'storage'
];
foreach
(
$json
as
$contentType
=>
$fields
)
{
foreach
(
$json
as
$contentType
=>
$fields
)
{
$query
=
$this
->
_buildQuery
(
$contentType
,
$fields
);
$query
=
false
;
if
(
$contentType
!=
'all'
){
$query
=
$this
->
_buildQuery
(
$json
,
$contentType
,
$fields
);
}
if
(
!
empty
(
$query
))
if
(
!
empty
(
$query
))
{
{
...
@@ -97,24 +102,24 @@ class CustomQueriesExtension extends SimpleExtension
...
@@ -97,24 +102,24 @@ class CustomQueriesExtension extends SimpleExtension
$contents
=
$storage
->
getContent
(
$contentType
,
[
'id'
=>
implode
(
' || '
,
$ids
),
'paging'
=>
true
,
'limit'
=>
99999
]);
$contents
=
$storage
->
getContent
(
$contentType
,
[
'id'
=>
implode
(
' || '
,
$ids
),
'paging'
=>
true
,
'limit'
=>
99999
]);
if
(
is_array
(
$contents
))
{
if
(
is_array
(
$contents
))
{
$records
=
array_merge
(
$records
,
$contents
);
$records
=
array_merge
(
$records
,
$contents
);
}
else
{
}
else
{
$records
=
array_merge
(
$records
,
[
$contents
]);
$records
=
array_merge
(
$records
,
[
$contents
]);
}
}
}
}
}
}
return
$this
->
getContainer
()[
'twig'
]
->
render
(
"custom_queries.twig"
,
[
'records'
=>
$records
]);
return
$this
->
getContainer
()[
'twig'
]
->
render
(
"custom_queries.twig"
,
[
'records'
=>
$records
]);
}
}
/**
/**
* @return false|mixed
* @return false|mixed
*/
*/
public
function
queriesArrayResults
(
$input
)
public
function
queriesArrayResults
(
$input
)
{
{
if
(
$input
==
''
)
{
if
(
$input
==
''
)
{
return
''
;
return
''
;
}
}
$json
=
json_decode
(
$input
,
true
);
$json
=
json_decode
(
$input
,
true
);
...
@@ -149,13 +154,13 @@ class CustomQueriesExtension extends SimpleExtension
...
@@ -149,13 +154,13 @@ class CustomQueriesExtension extends SimpleExtension
return
[
'records'
=>
$records
];
return
[
'records'
=>
$records
];
}
}
/**
/**
* @return false|mixed
* @return false|mixed
*/
*/
public
function
countResults
(
$input
)
public
function
countResults
(
$input
)
{
{
if
(
$input
==
''
)
{
if
(
$input
==
''
)
{
return
''
;
return
''
;
}
}
$json
=
json_decode
(
$input
,
true
);
$json
=
json_decode
(
$input
,
true
);
...
@@ -189,32 +194,38 @@ class CustomQueriesExtension extends SimpleExtension
...
@@ -189,32 +194,38 @@ class CustomQueriesExtension extends SimpleExtension
return
count
(
$records
);
return
count
(
$records
);
}
}
/**
/**
* @param array $json
* @param $contentType
* @param array $fields
* @param array $fields
* @return string
* @return string
*/
*/
protected
function
_buildQuery
(
$contentType
,
array
$fields
=
[])
{
protected
function
_buildQuery
(
array
$json
,
$contentType
,
array
$fields
=
[])
{
if
(
!
$contentType
)
{
if
(
!
$contentType
)
{
return
''
;
return
''
;
}
}
$storage
=
$this
->
getContainer
()[
'storage'
];
$storage
=
$this
->
getContainer
()[
'storage'
];
$tableName
=
$storage
->
getContenttypeTablename
(
$contentType
);
$tableName
=
$storage
->
getContenttypeTablename
(
$contentType
);
if
(
!
$tableName
)
{
if
(
!
$tableName
)
{
return
''
;
return
''
;
}
}
$query
=
'SELECT id FROM '
.
$tableName
;
$query
=
'SELECT id FROM '
.
$tableName
;
$where
=
$this
->
_buildWhere
(
$fields
);
if
(
!
isset
(
$json
[
'all'
])
||
!
\in_array
(
$contentType
,
$json
[
'all'
]))
{
if
(
$where
)
{
$where
=
$this
->
_buildWhere
(
$fields
);
$query
.=
$where
;
if
(
$where
)
{
$query
.=
$where
;
}
}
}
return
$query
;
return
$query
;
}
}
/**
/**
* @param array $fields
* @param array $fields
* @return bool
* @return bool
*/
*/
...
@@ -257,7 +268,7 @@ class CustomQueriesExtension extends SimpleExtension
...
@@ -257,7 +268,7 @@ class CustomQueriesExtension extends SimpleExtension
}
}
}
}
}
}
return
$where
;
return
$where
;
}
}
...
...
web/css/app.css
View file @
179d70d4
...
@@ -15,13 +15,15 @@
...
@@ -15,13 +15,15 @@
margin-right
:
1em
;
margin-right
:
1em
;
}
}
/* Autocomplete css */
.chooseField
{
.chooseField
{
height
:
26px
!important
;
height
:
26px
!important
;
width
:
20em
!important
;
text-align
:
center
!important
;
}
}
.select
span
{
.select2-container
{
width
:
20em
;
text-align
:
left
;
text-align
:
center
;
}
}
.addContentTypeContainer
{
.addContentTypeContainer
{
...
...
web/js/app.js
View file @
179d70d4
This diff is collapsed.
Click to expand it.
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