Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
Tourinsoft
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
Tourinsoft
Commits
3edcd00c
Commit
3edcd00c
authored
May 11, 2018
by
Frédéric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Field Mapping
parent
dc7a6ad6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
6 deletions
+156
-6
config.yml.dist
config/config.yml.dist
+88
-1
Synchronisation.php
src/Synchronisation/Synchronisation.php
+16
-2
ContentTypeFile.php
src/Utils/ContentTypeFile.php
+32
-3
Schema.php
src/Utils/Schema.php
+20
-0
No files found.
config/config.yml.dist
View file @
3edcd00c
tourinsoft:
tourinsoft:
url: 'http://wcf.tourinsoft.com/Syndication/3.0/'
url: 'http://wcf.tourinsoft.com/Syndication/3.0/'
ot_key: '
cdt64
'
ot_key: ''
cdn_url: ''
cdn_url: ''
field_mapping:
SyndicObjectID:
label: Identifiant de l'offre
Published:
label: Date de création de l’offre
Updated:
label: Date de mise à jour de l’offre
SyndicObjectName:
label: Le nom de l’offre touristique
SyndicStructureId:
label: Identifiant de la structure
GmapLatitude:
label: Coordonnées Latitude google map
GmapLongitude:
label: Coordonnées Longitude google map
ObjectTypeFix:
label: Identifiant du bordereau
ObjectTypeName:
label: Nom du bordereau
SyndicObjectOrder:
label: Ordre d’affichage
ACCES:
label: Point d'accès
ACCESHANDI:
label: Accessible aux personnes à mobilité réduite
AD1:
label: Adresse 1
AD1SUITE:
label: Adresse 1 suite
AD2:
label: Adresse 2
AD3:
label: Adresse 3
COMMUNE:
label: Commune touristique
COMMUNEINSEE:
label: INSEE Commune
CP:
label: Code Postal
DESCRIPTIF:
label: Description commerciale
FACEBOOK:
label: Facebook
FICHIER:
label: Fichier
FICHIER_NOM:
label: Fichier
FLICKR:
label: Flickr URL de la Galerie
GOOGLE_AD:
label: Google Adresses
LANG_PARLE:
label: Langues parlées
LAT:
label: Latitude
LOCALISATION:
label: Type de localisation
LON:
label: Longitude
MAILCOMPLET:
label: Coordonnées Télécom
NOM_OFFRE:
label: Raison sociale
OUVERTURE:
label: Ouverture
OUVERTURECOMPLETAVECJOURS:
label: Ouverture avec jours
PHOTO:
label: Photo
PHOTOCOMPLET:
label: Photo complet
QRCODE:
label: QR Code
TEL_COMPLET:
label: Téléphone
TEL_MOB_COMPLET:
label: Téléphone mobile
TWITTER:
label: Twitter
TYPE:
label: Type de commerces et services
VIDEO_CODE:
label: Code de la vidéo
VIDEO_URL:
label: URL vidéo
VISITE_VIRT:
label: Visite virtuelle
src/Synchronisation/Synchronisation.php
View file @
3edcd00c
...
@@ -6,6 +6,7 @@ use Bolt\Application;
...
@@ -6,6 +6,7 @@ use Bolt\Application;
use
Bolt\Extension\Appolo\Tourinsoft\Storage\Entity\Flux
;
use
Bolt\Extension\Appolo\Tourinsoft\Storage\Entity\Flux
;
use
Bolt\Extension\Appolo\Tourinsoft\Utils\ContentTypeFile
;
use
Bolt\Extension\Appolo\Tourinsoft\Utils\ContentTypeFile
;
use
Bolt\Extension\Appolo\Tourinsoft\Utils\Parser
;
use
Bolt\Extension\Appolo\Tourinsoft\Utils\Parser
;
use
Bolt\Extension\Appolo\Tourinsoft\Utils\Schema
;
class
Synchronisation
class
Synchronisation
{
{
...
@@ -23,7 +24,7 @@ class Synchronisation
...
@@ -23,7 +24,7 @@ class Synchronisation
private
$application
;
private
$application
;
/**
/**
*
TourinsoftParser
constructor.
*
Synchornisation
constructor.
* @param array $config
* @param array $config
* @param Flux $flux
* @param Flux $flux
* @throws \Exception
* @throws \Exception
...
@@ -44,18 +45,30 @@ class Synchronisation
...
@@ -44,18 +45,30 @@ class Synchronisation
public
function
sync
()
{
public
function
sync
()
{
$options
=
$this
->
config
[
'tourinsoft'
];
$options
=
$this
->
config
[
'tourinsoft'
];
$options
[
'key'
]
=
$this
->
flux
->
getKey
();
$options
[
'key'
]
=
$this
->
flux
->
getKey
();
// Parse tourinsoft flux
$parser
=
new
Parser
(
$options
);
$parser
=
new
Parser
(
$options
);
$keys
=
$parser
->
getKeys
();
$keys
=
$parser
->
getKeys
();
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
->
getContentType
(),
$keys
);
// Write in contenttypes.yml file
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
->
getContentType
(),
$keys
,
$options
);
$file
->
updateInFile
();
$file
->
updateInFile
();
// Sync database
$schema
=
new
Schema
(
$this
->
application
);
$schema
->
update
();
}
}
/**
/**
*
*
*/
*/
public
function
delete
()
{
public
function
delete
()
{
// Write in contenttypes.yml file
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
->
getContentType
(),
[]);
$file
=
new
ContentTypeFile
(
$this
->
application
,
$this
->
flux
->
getContentType
(),
[]);
$file
->
deleteInFile
();
$file
->
deleteInFile
();
// Sync database
$schema
=
new
Schema
(
$this
->
application
);
$schema
->
update
();
}
}
}
}
\ No newline at end of file
src/Utils/ContentTypeFile.php
View file @
3edcd00c
...
@@ -20,15 +20,20 @@ class ContentTypeFile
...
@@ -20,15 +20,20 @@ class ContentTypeFile
* @var Application
* @var Application
*/
*/
private
$application
;
private
$application
;
/**
* @var array
*/
private
$options
;
/**
/**
* ContentTypeFile constructor.
* ContentTypeFile constructor.
* @param Application $application
* @param Application $application
* @param string $contentType
* @param string $contentType
* @param array $keys
* @param array $keys
* @param array $options
* @throws \Exception
* @throws \Exception
*/
*/
public
function
__construct
(
Application
$application
,
$contentType
=
''
,
array
$keys
=
[])
public
function
__construct
(
Application
$application
,
$contentType
=
''
,
array
$keys
=
[]
,
array
$options
=
[]
)
{
{
if
(
empty
(
$contentType
))
{
if
(
empty
(
$contentType
))
{
throw
new
\Exception
(
'Le content type est requis.'
);
throw
new
\Exception
(
'Le content type est requis.'
);
...
@@ -36,6 +41,7 @@ class ContentTypeFile
...
@@ -36,6 +41,7 @@ class ContentTypeFile
$this
->
contentType
=
$contentType
;
$this
->
contentType
=
$contentType
;
$this
->
keys
=
$keys
;
$this
->
keys
=
$keys
;
$this
->
application
=
$application
;
$this
->
application
=
$application
;
$this
->
options
=
$options
;
}
}
/**
/**
...
@@ -68,7 +74,10 @@ class ContentTypeFile
...
@@ -68,7 +74,10 @@ class ContentTypeFile
$fields
=
[];
$fields
=
[];
foreach
(
$this
->
keys
as
$key
)
{
foreach
(
$this
->
keys
as
$key
)
{
$fields
[
$key
]
=
[
'type'
=>
'text'
];
$fields
[
$key
]
=
[
'type'
=>
'text'
,
'label'
=>
$this
->
getFieldLabel
(
$key
)
];
}
}
$fields
[
'slug'
]
=
[
$fields
[
'slug'
]
=
[
...
@@ -93,11 +102,30 @@ class ContentTypeFile
...
@@ -93,11 +102,30 @@ class ContentTypeFile
if
(
$delete
)
{
if
(
$delete
)
{
unset
(
$yamlData
[
$this
->
contentType
]);
unset
(
$yamlData
[
$this
->
contentType
]);
}
else
{
}
else
{
if
(
!
empty
(
$yamlData
[
$this
->
contentType
]))
{
unset
(
$yamlData
[
$this
->
contentType
]);
}
$yamlData
+=
$data
;
$yamlData
+=
$data
;
}
}
$file
->
dump
(
$yamlData
,
[
'inline'
=>
4
]);
$file
->
dump
(
$yamlData
,
[
'inline'
=>
4
]);
}
}
}
}
/**
* @param $key
* @return mixed
*/
private
function
getFieldLabel
(
$key
)
{
if
(
empty
(
$this
->
options
)
||
empty
(
$this
->
options
[
'field_mapping'
])
||
empty
(
$this
->
options
[
'field_mapping'
][
$key
])
||
empty
(
$this
->
options
[
'field_mapping'
][
$key
][
'label'
])
)
{
return
$key
;
}
return
$this
->
options
[
'field_mapping'
][
$key
][
'label'
];
}
}
}
\ No newline at end of file
src/Utils/Schema.php
View file @
3edcd00c
...
@@ -2,7 +2,26 @@
...
@@ -2,7 +2,26 @@
namespace
Bolt\Extension\Appolo\Tourinsoft\Utils
;
namespace
Bolt\Extension\Appolo\Tourinsoft\Utils
;
use
Bolt\Application
;
class
Schema
class
Schema
{
{
/**
* @var Application
*/
private
$application
;
/**
* Schema constructor.
* @param Application $application
*/
public
function
__construct
(
Application
$application
)
{
$this
->
application
=
$application
;
}
public
function
update
()
{
$output
=
$this
->
application
[
'schema'
]
->
update
();
$this
->
application
[
'session'
]
->
set
(
'dbupdate_result'
,
$output
->
getResponseStrings
());
}
}
}
\ 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