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
0110623c
Commit
0110623c
authored
Feb 15, 2019
by
Simonas
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of git.biuro.lt:biuro/dev.biuro into dev
parents
d8cb3c33
4f3c01ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
23 deletions
+60
-23
JobsImporter.php
wp-content/plugins/jobs-importer/JobsImporter.php
+11
-12
jobs-importer.php
wp-content/plugins/jobs-importer/jobs-importer.php
+49
-11
No files found.
wp-content/plugins/jobs-importer/JobsImporter.php
View file @
0110623c
...
...
@@ -94,6 +94,12 @@ class JobsImporter
$relations
);
// if ($ad['properties'][$this->primaryKey] == 14531) {
//
// var_dump($ad);
// var_dump($adData);
// }
// Unique key of post
$primaryKey
=
$adData
[
$this
->
primaryKey
];
...
...
@@ -104,6 +110,8 @@ class JobsImporter
try
{
$podId
=
$pod
->
save
(
$adData
);
// Set post language
$this
->
setPostLang
(
$podId
,
$ad
[
'lang'
]);
print_r
(
"Old record (
$this->primaryKey
:
$primaryKey
) has been updated. <br>"
);
}
catch
(
Exception
$e
)
{
...
...
@@ -115,24 +123,15 @@ class JobsImporter
try
{
$podId
=
$this
->
pods
->
add
(
$adData
);
// Set post language
$this
->
setPostLang
(
$podId
,
$ad
[
'lang'
]);
$this
->
getPod
(
$primaryKey
)
->
save
(
$adData
);
// Save related data, cause didn't saved on creation
print_r
(
"New record (
$this->primaryKey
:
$primaryKey
) has been created. <br>"
);
}
catch
(
Exception
$e
)
{
print_r
(
"Error while creating record (
$this->primaryKey
:
$primaryKey
). Error:
$e->getMessage
()<br>"
);
}
}
if
(
isset
(
$podId
))
{
// Set post language
$this
->
setPostLang
(
$podId
,
$ad
[
'lang'
]);
// if (isset($custom_uri)) {
// $permalink_manager_uris[$podId] = $custom_uri;
// update_option('permalink-manager-uris', $permalink_manager_uris);
// }
}
}
}
...
...
wp-content/plugins/jobs-importer/jobs-importer.php
View file @
0110623c
...
...
@@ -38,10 +38,14 @@ function importer_admin_menu()
*/
function
do_import
()
{
// Set environment type
// $env = 'prod';
$env
=
'dev'
;
$env
=
'prod'
;
//Set dev env. only on dev subdomain
$subDomain
=
strstr
(
$_SERVER
[
'SERVER_NAME'
],
'.biuro.lt'
,
true
);
if
(
$subDomain
==
'dev'
)
{
$env
=
'dev'
;
}
// Set data source path by environment type
if
(
$env
===
'dev'
)
{
...
...
@@ -51,30 +55,64 @@ function do_import()
$inputFile
=
"http://export.biuro.lt/wp_biuro.php"
;
}
print_r
(
"<div style='background: lightgrey;'>
<small style='float: right;'>Working in <strong>
$env
</strong> mode</small>
<div style='clear: both;'></div>
</div>"
);
echo
"<pre>"
;
print_r
(
'<h4>Biuro Jobs importer</h4>'
);
print_r
(
"Running in <strong>
$env
</strong> environment."
);
echo
"<br><br>"
;
print_r
(
"Data source:
$inputFile
<br>"
);
// if (pll_current_language() != '')
// {
// print_r("<h5 class='warning'>Polylang must be set in 'All languages' mode.</h5>");
// pll_the_languages( array( 'dropdown' => 1 ) );
// exit();
// }
print_r
(
"Data source:
$inputFile
<br><br>"
);
// JSON reader
$ads
=
(
new
JsonDataCollector
(
$inputFile
))
->
getData
();
// var_dump($ads);
// exit();
print_r
(
"Found "
.
count
(
$ads
)
.
" ads from Biuro.<br>"
);
if
(
count
(
$ads
)
>
0
)
{
print_r
(
"importing....<br><br>"
);
if
(
empty
(
$_POST
))
{
// Form for import start, set polylang to 'All lang.' for action
print_r
(
"<form method='post' action='"
.
current_location
()
.
"&lang=all'>"
);
print_r
(
"<div style='margin-top: 10px;'><button name='import' value='true'>Import</button></div>"
);
print_r
(
"</form>"
);
}
// Posts (via Pods framework) creator
(
new
JobsImporter
(
$ads
))
->
import
();
// for cron, needs add to url ...&lang=all&proceed=1
if
(
isset
(
$_POST
[
'import'
])
||
isset
(
$_GET
[
'proceed'
]))
{
print_r
(
"importing....<br><br>"
);
// Posts (via Pods framework) creator
(
new
JobsImporter
(
$ads
))
->
import
();
}
}
else
{
print_r
(
"<br>There is nothing more to do."
);
}
echo
"</pre>"
;
}
function
current_location
()
{
if
(
isset
(
$_SERVER
[
'HTTPS'
])
&&
(
$_SERVER
[
'HTTPS'
]
==
'on'
||
$_SERVER
[
'HTTPS'
]
==
1
)
||
isset
(
$_SERVER
[
'HTTP_X_FORWARDED_PROTO'
])
&&
$_SERVER
[
'HTTP_X_FORWARDED_PROTO'
]
==
'https'
)
{
$protocol
=
'https://'
;
}
else
{
$protocol
=
'http://'
;
}
return
$protocol
.
$_SERVER
[
'HTTP_HOST'
]
.
$_SERVER
[
'REQUEST_URI'
];
}
\ No newline at end of file
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