dev005 remplacement de l'API Google de capture d'écran
This commit is contained in:
parent
2f5c0be4c7
commit
ba9c5bd98b
|
@ -47,7 +47,7 @@ class common {
|
||||||
// Numéro de version
|
// Numéro de version
|
||||||
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/';
|
const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/';
|
||||||
|
|
||||||
const ZWII_VERSION = '11.6.00-dev004';
|
const ZWII_VERSION = '11.6.00-dev005';
|
||||||
const ZWII_UPDATE_CHANNEL = "test";
|
const ZWII_UPDATE_CHANNEL = "test";
|
||||||
|
|
||||||
public static $actions = [];
|
public static $actions = [];
|
||||||
|
@ -1913,7 +1913,11 @@ class common {
|
||||||
* Affiche la meta image (site screenshot)
|
* Affiche la meta image (site screenshot)
|
||||||
*/
|
*/
|
||||||
public function showMetaImage() {
|
public function showMetaImage() {
|
||||||
echo '<meta property="og:image" content="' . helper::baseUrl() .self::FILE_DIR.'source/screenshot.jpg" />';
|
$items ='<meta property="og:image" content="' . helper::baseUrl() .self::FILE_DIR.'source/screenshot.jpg" />';
|
||||||
|
$items .= '<meta property="og:image:type" content="image/jpeg" />';
|
||||||
|
$items .= '<meta property="og:image:width" content="1200" />';
|
||||||
|
$items .= '<meta property="og:image:height" content="627" />';
|
||||||
|
echo $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1927,7 +1931,7 @@ class common {
|
||||||
if(common::$inputNotices) {
|
if(common::$inputNotices) {
|
||||||
$notification = 'Impossible de soumettre le formulaire, car il contient des erreurs';
|
$notification = 'Impossible de soumettre le formulaire, car il contient des erreurs';
|
||||||
$notificationClass = 'notificationError';
|
$notificationClass = 'notificationError';
|
||||||
//var_dump(common::$inputNotices) ;
|
var_dump(common::$inputNotices) ;
|
||||||
}
|
}
|
||||||
if (common::$coreNotices) {
|
if (common::$coreNotices) {
|
||||||
$notification = 'Données absentes, restauration de <p> | ';
|
$notification = 'Données absentes, restauration de <p> | ';
|
||||||
|
|
|
@ -255,35 +255,38 @@ class config extends common {
|
||||||
public function configMetaImage() {
|
public function configMetaImage() {
|
||||||
// fonction désactivée pour un site local
|
// fonction désactivée pour un site local
|
||||||
if ( strpos(helper::baseUrl(false),'localhost') > 0 OR strpos(helper::baseUrl(false),'127.0.0.1') > 0) {
|
if ( strpos(helper::baseUrl(false),'localhost') > 0 OR strpos(helper::baseUrl(false),'127.0.0.1') > 0) {
|
||||||
$site = 'https://zwiicms.fr/'; } else {
|
$site = 'https://zwiicms.fr/';
|
||||||
$site = helper::baseUrl(false); }
|
} else {
|
||||||
|
$site = helper::baseUrl(false);
|
||||||
|
}
|
||||||
|
// Clé de l'API
|
||||||
|
$token = $this->getData(['config', 'seo', 'keyApi']);
|
||||||
|
|
||||||
// Succès de la'opération par défaut
|
// Succès de la'opération par défaut
|
||||||
$success = false;
|
$success = false;
|
||||||
|
|
||||||
// Tente de connecter 5 fois l'API Google
|
// Tente de connecter 5 fois l'API
|
||||||
for ($i=0; $i < 5 ; $i++) {
|
for ($i=0; $i < 5 ; $i++) {
|
||||||
$googlePagespeedData = helper::getUrlContents('https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url='. $site .'&screenshot=true');
|
//$googlePagespeedData = helper::getUrlContents('https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url='. $site .'&screenshot=true');
|
||||||
if ($googlePagespeedData !== false) {
|
$data = helper::getUrlContents('https://shot.screenshotapi.net/screenshot?token=' . $token . '&url=' . $site . '&width=1200&height=627&output=json&file_type=jpeg&no_cookie_banners=true&wait_for_event=load');
|
||||||
|
if ($data !== false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Traitement des données reçues valides.
|
|
||||||
if ($googlePagespeedData !== false) {
|
|
||||||
$googlePagespeedData = json_decode($googlePagespeedData, true);
|
|
||||||
$data = str_replace('_','/',$googlePagespeedData['lighthouseResult']['audits']['final-screenshot']['details']['data']);
|
|
||||||
$data = str_replace('-','+',$data);
|
|
||||||
$img = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $data));
|
|
||||||
// Effacer l'image et la miniature png
|
|
||||||
if (file_exists(self::FILE_DIR.'thumb/screenshot.jpg')) {
|
|
||||||
unlink (self::FILE_DIR.'thumb/screenshot.jpg');
|
|
||||||
}
|
|
||||||
if (file_exists(self::FILE_DIR.'source/screenshot.jpg')) {
|
|
||||||
unlink (self::FILE_DIR.'source/screenshot.jpg');
|
|
||||||
}
|
|
||||||
$success = file_put_contents( self::FILE_DIR.'source/screenshot.jpg',$img) ;
|
|
||||||
|
|
||||||
|
|
||||||
|
// Traitement des données reçues valides.
|
||||||
|
if ($data !== false) {
|
||||||
|
$data = json_decode($data, true);
|
||||||
|
$img = $data['screenshot'];
|
||||||
|
// Effacer l'image et la miniature png
|
||||||
|
if (file_exists(self::FILE_DIR .'thumb/screenshot.jpg')) {
|
||||||
|
unlink (self::FILE_DIR .'thumb/screenshot.jpg');
|
||||||
|
}
|
||||||
|
if (file_exists(self::FILE_DIR .'source/screenshot.jpg')) {
|
||||||
|
unlink (self::FILE_DIR .'source/screenshot.jpg');
|
||||||
|
}
|
||||||
|
$success = copy ($img, self::FILE_DIR .'source/screenshot.jpg');
|
||||||
}
|
}
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
|
@ -467,10 +470,8 @@ class config extends common {
|
||||||
'cookies' => [
|
'cookies' => [
|
||||||
// Les champs sont obligatoires si l'option consentement des cookies est active
|
// Les champs sont obligatoires si l'option consentement des cookies est active
|
||||||
'mainLabel' => $this->getInput('localeCookiesZwiiText', helper::FILTER_STRING_LONG, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
'mainLabel' => $this->getInput('localeCookiesZwiiText', helper::FILTER_STRING_LONG, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
||||||
'gaLabel' => $this->getInput('localeCookiesGaText', helper::FILTER_STRING_LONG, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
|
||||||
'titleLabel' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
'titleLabel' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
||||||
'linkLegalLabel' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
'linkLegalLabel' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
||||||
'checkboxGaLabel' => $this->getInput('localeCookiesCheckboxGaText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
|
||||||
'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN)),
|
||||||
'buttonValidLabel' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN))
|
'buttonValidLabel' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getInput('configCookieConsent', helper::FILTER_BOOLEAN))
|
||||||
]
|
]
|
||||||
|
@ -513,7 +514,8 @@ class config extends common {
|
||||||
'sender' => $this->getInput('smtpSender',helper::FILTER_MAIL)
|
'sender' => $this->getInput('smtpSender',helper::FILTER_MAIL)
|
||||||
],
|
],
|
||||||
'seo' => [
|
'seo' => [
|
||||||
'robots' => $this->getInput('seoRobots',helper::FILTER_BOOLEAN)
|
'robots' => $this->getInput('seoRobots',helper::FILTER_BOOLEAN),
|
||||||
|
'keyApi' => $this->getInput('seoKeyApi',helper::FILTER_STRING_SHORT),
|
||||||
],
|
],
|
||||||
'connect' => [
|
'connect' => [
|
||||||
'attempt' => $this->getInput('connectAttempt',helper::FILTER_INT),
|
'attempt' => $this->getInput('connectAttempt',helper::FILTER_INT),
|
||||||
|
@ -799,7 +801,7 @@ class config extends common {
|
||||||
public function copyBackups() {
|
public function copyBackups() {
|
||||||
|
|
||||||
$success = $this->copyDir(self::BACKUP_DIR, self::FILE_DIR . 'source/backup' );
|
$success = $this->copyDir(self::BACKUP_DIR, self::FILE_DIR . 'source/backup' );
|
||||||
|
|
||||||
// Valeurs en sortie
|
// Valeurs en sortie
|
||||||
$this->addOutput([
|
$this->addOutput([
|
||||||
'title' => 'Configuration du site',
|
'title' => 'Configuration du site',
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col12">
|
<div class="col12">
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<h4>Paramètres
|
<h4>Capture Open Graph
|
||||||
<span id="specialeHelpButton" class="helpDisplayButton">
|
<span id="specialeHelpButton" class="helpDisplayButton">
|
||||||
<a href="https://doc.zwiicms.fr/referencement" target="_blank" title="Cliquer pour consulter l'aide en ligne">
|
<a href="https://doc.zwiicms.fr/referencement" target="_blank" title="Cliquer pour consulter l'aide en ligne">
|
||||||
<?php echo template::ico('help', ['margin' => 'left']);?>
|
<?php echo template::ico('help', ['margin' => 'left']);?>
|
||||||
|
@ -11,6 +11,15 @@
|
||||||
</h4>
|
</h4>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col4 offset1">
|
<div class="col4 offset1">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col12">
|
||||||
|
<?php echo template::text('seoKeyApi', [
|
||||||
|
'label' => 'Clé de l\'API <a href="https://app.screenshotapi.net/" target="_blank">ScreenShotApi</a>',
|
||||||
|
'value' => $this->getData(['config', 'seo', 'keyApi']),
|
||||||
|
'help' => 'Saisir la clé, puis valider le formulaire avant de cliquer sur le bouton de génération'
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col12">
|
<div class="col12">
|
||||||
<?php echo template::button('socialMetaImage', [
|
<?php echo template::button('socialMetaImage', [
|
||||||
|
@ -19,21 +28,6 @@
|
||||||
]); ?>
|
]); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col12">
|
|
||||||
<?php echo template::button('socialSiteMap', [
|
|
||||||
'href' => helper::baseUrl() . 'config/siteMap',
|
|
||||||
'value' => 'Générer sitemap.xml et robots.txt'
|
|
||||||
]); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col12">
|
|
||||||
<?php echo template::checkbox('seoRobots', true, 'Autoriser les robots à référencer le site', [
|
|
||||||
'checked' => $this->getData(['config', 'seo','robots'])
|
|
||||||
]); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col6 offset1">
|
<div class="col6 offset1">
|
||||||
<?php if (file_exists(self::FILE_DIR.'source/screenshot.jpg')): ?>
|
<?php if (file_exists(self::FILE_DIR.'source/screenshot.jpg')): ?>
|
||||||
|
@ -51,7 +45,27 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col12">
|
<div class="col12">
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<h4>Réseaux sociaux
|
<h4>Référencement</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col4 offset1">
|
||||||
|
<?php echo template::button('socialSiteMap', [
|
||||||
|
'href' => helper::baseUrl() . 'config/siteMap',
|
||||||
|
'value' => 'Générer sitemap.xml et robots.txt'
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
<div class="col4 offset1">
|
||||||
|
<?php echo template::checkbox('seoRobots', true, 'Autoriser les robots à référencer le site', [
|
||||||
|
'checked' => $this->getData(['config', 'seo','robots'])
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col12">
|
||||||
|
<div class="block">
|
||||||
|
<h4>Comptes des réseaux sociaux
|
||||||
<span id="specialeHelpButton" class="helpDisplayButton">
|
<span id="specialeHelpButton" class="helpDisplayButton">
|
||||||
<a href="https://doc.zwiicms.fr/reseaux-sociaux" target="_blank" title="Cliquer pour consulter l'aide en ligne">
|
<a href="https://doc.zwiicms.fr/reseaux-sociaux" target="_blank" title="Cliquer pour consulter l'aide en ligne">
|
||||||
<?php echo template::ico('help', ['margin' => 'left']);?>
|
<?php echo template::ico('help', ['margin' => 'left']);?>
|
||||||
|
|
|
@ -26,7 +26,8 @@ class init extends common {
|
||||||
'enable' => false,
|
'enable' => false,
|
||||||
],
|
],
|
||||||
'seo' => [
|
'seo' => [
|
||||||
'robots' => true
|
'robots' => true,
|
||||||
|
'keyApi' => 'Connecter https://app.screenshotapi.net/'
|
||||||
],
|
],
|
||||||
'connect' => [
|
'connect' => [
|
||||||
'timeout' => 600,
|
'timeout' => 600,
|
||||||
|
|
Loading…
Reference in New Issue