Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dev.biuro
Project
Project
Details
Activity
Releases
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
Biuro
dev.biuro
Commits
d7d6d4b9
Commit
d7d6d4b9
authored
Mar 29, 2019
by
Simonas
Browse files
Options
Browse Files
Download
Plain Diff
merge conflict
parents
785ef064
e2129363
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
58 deletions
+19
-58
JsonDataCollector.php
wp-content/plugins/jobs-importer/JsonDataCollector.php
+19
-58
No files found.
wp-content/plugins/jobs-importer/JsonDataCollector.php
View file @
d7d6d4b9
...
...
@@ -12,7 +12,7 @@ class JsonDataCollector
'title'
=>
'pareigos'
,
'post_content'
=>
'aprasymas'
,
'slug'
=>
'seo_url'
,
'contact'
=>
'
kontaktai
'
,
'contact'
=>
'
contacts
'
,
'salary_from'
=>
'atlygis_nuo'
,
'salary_to'
=>
'atlygis_iki'
,
// 'email' => 'email',
...
...
@@ -32,14 +32,21 @@ class JsonDataCollector
],
'field'
=>
[
'slug'
=>
'kategorija'
,
'name'
=>
'sritis'
'name'
=>
'sritis'
,
'__primary'
=>
true
,
'additionalCategories'
=>
[
'slug'
=>
'category_id'
,
'name'
=>
'category_name'
,
]
],
'company'
=>
[
'name'
=>
'imone'
],
'type'
=>
[
'slug'
=>
'type'
,
'name'
=>
'type'
'types'
=>
[
'slug'
=>
'type_id'
,
'name'
=>
'type_name'
]
],
// 'tag'
// 'position',
...
...
@@ -53,17 +60,6 @@ class JsonDataCollector
],
];
protected
$collections
=
[
'city'
=>
[
'name'
=>
'additionalCities'
,
'map'
=>
[
'slug'
=>
'city_id'
,
'name'
=>
'city'
,
],
'append'
=>
'terms:city'
]
];
// Language map
protected
$lang
=
'kalba'
;
...
...
@@ -139,25 +135,6 @@ class JsonDataCollector
$item
[
'posts'
]
=
$this
->
getPosts
(
$ad
);
$item
[
'relations'
]
=
$this
->
relationsMap
;
// foreach ($this->dataMap as $mapKey => $dataKey) {
// $dataValue = $ad->{$dataKey};
// $itemValue = $this->getValue($dataValue);
// $postValue = $this->getValue($dataValue);
// $item[$mapKey] = $itemValue;
//
//// if (array_key_exists($mapKey, $this->relationsMap)) {
//// $item['related_items'][$mapKey] = $this->relationsMap[$mapKey];
//// }
// }
//
// foreach ($this->relationsMap as $keyItem => $valueItem) {
// if (array_key_exists($keyItem, $item) && array_key_exists($valueItem, $item)) {
// $item[$valueItem] = [$valueItem . '_' . $item[$keyItem] => $item[$valueItem]];
// unset($item[$keyItem]);
// }
// }
$result
[]
=
$item
;
};
...
...
@@ -184,11 +161,18 @@ class JsonDataCollector
foreach
(
$this
->
terms
as
$termKey
=>
$termProperties
)
{
$result
[
$termKey
][]
=
$this
->
getEntity
(
$ad
,
$termProperties
);
$entity
=
$this
->
getEntity
(
$ad
,
$termProperties
);
if
(
!
empty
(
$entity
))
{
$result
[
$termKey
][]
=
$entity
;
}
$appends
=
array_filter
(
$termProperties
,
function
(
$item
)
{
return
is_array
(
$item
);
});
foreach
(
$appends
as
$propertyKey
=>
$propertyValues
)
{
if
(
isset
(
$ad
->
{
$propertyKey
}))
{
...
...
@@ -238,29 +222,6 @@ class JsonDataCollector
return
$result
;
}
private
function
getCollection
(
$ad
,
$collectionMap
)
{
$result
=
[];
foreach
(
$this
->
collections
as
$collection
)
{
if
(
isset
(
$ad
->
{
$collection
[
'name'
]}))
{
$data
=
$ad
->
{
$collection
[
'name'
]};
}
$entity
=
[];
foreach
(
$collection
[
'map'
]
as
$propertyKey
=>
$propertyValue
)
{
if
(
preg_match
(
'/^\_\_/'
,
$propertyKey
))
{
$entity
[
$propertyKey
]
=
$propertyValue
;
}
elseif
(
isset
(
$data
[
$propertyValue
]))
{
$dataValue
=
$data
[
$propertyValue
];
$entity
[
$propertyKey
]
=
$this
->
getValue
(
$dataValue
);
}
}
}
}
private
function
getValue
(
$value
)
{
return
(
is_array
(
$value
))
?
$value
:
html_entity_decode
(
$value
);
...
...
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