Open graph with Facebook APP ID and bug fixes

This commit is contained in:
Diego Najar 2018-11-28 22:10:41 +01:00
parent 484d4f0116
commit 27fe6081cb
15 changed files with 53 additions and 19 deletions

View File

@ -3,5 +3,7 @@
{ {
"name": "Open Graph", "name": "Open Graph",
"description": "Open Graph ви позволява да свържете вашето съдържание със социални мрежи." "description": "Open Graph ви позволява да свържете вашето съдържание със социални мрежи."
} },
"set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -4,5 +4,6 @@
"name": "Open Graph", "name": "Open Graph",
"description": "Plugin zur Verwendung des Open Graph Protocols (beispielsweise für Facebook)." "description": "Plugin zur Verwendung des Open Graph Protocols (beispielsweise für Facebook)."
}, },
"default-image": "Standardbild" "set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -4,5 +4,6 @@
"name": "Open Graph", "name": "Open Graph",
"description": "Plugin zur Verwendung des Open Graph Protocols (beispielsweise für Facebook)." "description": "Plugin zur Verwendung des Open Graph Protocols (beispielsweise für Facebook)."
}, },
"default-image": "Standardbild" "set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -4,5 +4,6 @@
"name": "Open Graph", "name": "Open Graph",
"description": "The Open Graph protocol enables any web page to become a rich object in a social graph." "description": "The Open Graph protocol enables any web page to become a rich object in a social graph."
}, },
"default-image": "Default image" "set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -4,5 +4,6 @@
"name": "Open Graph", "name": "Open Graph",
"description": "Este complemento mejora las publicaciones en las redes sociales con este plugin." "description": "Este complemento mejora las publicaciones en las redes sociales con este plugin."
}, },
"default-image": "Imagen predeterminada" "set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -3,5 +3,7 @@
{ {
"name": "Open Graph", "name": "Open Graph",
"description": "Permets à nimporte quelle page web de devenir lobjet enrichi dun graphe social. Par exemple, il est utilisé sur Facebook pour permettre à une page web de bénéficier des mêmes fonctionnalités que nimporte quel autre objet sur Facebook." "description": "Permets à nimporte quelle page web de devenir lobjet enrichi dun graphe social. Par exemple, il est utilisé sur Facebook pour permettre à une page web de bénéficier des mêmes fonctionnalités que nimporte quel autre objet sur Facebook."
} },
"set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -4,5 +4,6 @@
"name": "Open Graph", "name": "Open Graph",
"description": "Il protocollo Open Graph permette a qualsiasi pagina web di diventare un rich object in un social graph." "description": "Il protocollo Open Graph permette a qualsiasi pagina web di diventare un rich object in un social graph."
}, },
"default-image": "Immagine predefinita" "set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -3,5 +3,7 @@
{ {
"name": "Open Graph", "name": "Open Graph",
"description": "Open Graph protocol(OGP)を有効にすると、Webページがソーシャルグラフ上のリッチなオブジェクトになります。" "description": "Open Graph protocol(OGP)を有効にすると、Webページがソーシャルグラフ上のリッチなオブジェクトになります。"
} },
"set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -3,5 +3,7 @@
{ {
"name": "Open Graph", "name": "Open Graph",
"description": "De Open Graph protocol kan van elke webpagina een rich object in een sociale grafiek maken." "description": "De Open Graph protocol kan van elke webpagina een rich object in een sociale grafiek maken."
} },
"set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -3,5 +3,7 @@
{ {
"name": "Open Graph", "name": "Open Graph",
"description": "Protokół Open Graph zezwala stronie na stosowanie meta tagów używanych w serwisach społecznościowych." "description": "Protokół Open Graph zezwala stronie na stosowanie meta tagów używanych w serwisach społecznościowych."
} },
"set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -3,5 +3,7 @@
{ {
"name": "Open Graph", "name": "Open Graph",
"description": "Протокол Open Graph дает возможность связывать свой контент с социальными сетями." "description": "Протокол Open Graph дает возможность связывать свой контент с социальными сетями."
} },
"set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -4,5 +4,6 @@
"name": "Open Graph", "name": "Open Graph",
"description": "Open Graph protokolü sosyal bir grafikte zengin bir nesne halinde herhangi bir web sayfasını sağlar." "description": "Open Graph protokolü sosyal bir grafikte zengin bir nesne halinde herhangi bir web sayfasını sağlar."
}, },
"default-image": "Varsayılan resim" "set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -3,5 +3,7 @@
{ {
"name": "Open Graph", "name": "Open Graph",
"description": "Протокол Open Graph дозволяє ділитися будь-якою веб-сторінкою у соціальних мережах." "description": "Протокол Open Graph дозволяє ділитися будь-якою веб-сторінкою у соціальних мережах."
} },
"set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -3,5 +3,7 @@
{ {
"name": "開放社交關係圖", "name": "開放社交關係圖",
"description": "開放社交關係圖協定可以讓任何網頁變成豐富的物件" "description": "開放社交關係圖協定可以讓任何網頁變成豐富的物件"
} },
"set-a-default-image-for-content": "Set a default image for the content without pictures.",
"set-your-facebook-app-id": "Set your Facebook App ID."
} }

View File

@ -6,7 +6,8 @@ class pluginOpenGraph extends Plugin {
{ {
// Fields and default values for the database of this plugin // Fields and default values for the database of this plugin
$this->dbFields = array( $this->dbFields = array(
'defaultImage'=>'' 'defaultImage'=>'',
'fbAppId'=>''
); );
} }
@ -21,7 +22,13 @@ class pluginOpenGraph extends Plugin {
$html .= '<div>'; $html .= '<div>';
$html .= '<label>'.$L->get('Default image').'</label>'; $html .= '<label>'.$L->get('Default image').'</label>';
$html .= '<input id="jsdefaultImage" name="defaultImage" type="text" value="'.$this->getValue('defaultImage').'" placeholder="https://">'; $html .= '<input id="jsdefaultImage" name="defaultImage" type="text" value="'.$this->getValue('defaultImage').'" placeholder="https://">';
$html .= '<span class="tip">Set a default image for the content without pictures.</span>'; $html .= '<span class="tip">'.$L->g('set-a-default-image-for-content').'</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('Facebook App ID').'</label>';
$html .= '<input name="fbAppId" type="text" value="'.$this->getValue('fbAppId').'" placeholder="App ID">';
$html .= '<span class="tip">'.$L->g('set-your-facebook-app-id').'</span>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
@ -60,8 +67,10 @@ class pluginOpenGraph extends Plugin {
// The user is in the homepage // The user is in the homepage
default: default:
$pageContent = ''; $pageContent = '';
// The image it's from the first page if (Text::isNotEmpty($this->getValue('defaultImage'))) {
if (isset($content[0]) ) { $og['image'] = $this->getValue('defaultImage');
}
elseif (isset($content[0]) ) {
$og['image'] = $content[0]->coverImage($absolute=true); $og['image'] = $content[0]->coverImage($absolute=true);
$pageContent = $content[0]->content(); $pageContent = $content[0]->content();
} }
@ -74,7 +83,7 @@ class pluginOpenGraph extends Plugin {
$html .= '<meta property="og:title" content="'.$og['title'].'">'.PHP_EOL; $html .= '<meta property="og:title" content="'.$og['title'].'">'.PHP_EOL;
$html .= '<meta property="og:description" content="'.$og['description'].'">'.PHP_EOL; $html .= '<meta property="og:description" content="'.$og['description'].'">'.PHP_EOL;
$html .= '<meta property="og:url" content="'.$og['url'].'">'.PHP_EOL; $html .= '<meta property="og:url" content="'.$og['url'].'">'.PHP_EOL;
$html .= '<meta property="og:siteName" content="'.$og['siteName'].'">'.PHP_EOL; $html .= '<meta property="og:site_name" content="'.$og['siteName'].'">'.PHP_EOL;
// If the page doesn't have a coverImage try to get an image from the HTML content // If the page doesn't have a coverImage try to get an image from the HTML content
if (empty($og['image'])) { if (empty($og['image'])) {
@ -90,6 +99,9 @@ class pluginOpenGraph extends Plugin {
} }
$html .= '<meta property="og:image" content="'.$og['image'].'">'.PHP_EOL; $html .= '<meta property="og:image" content="'.$og['image'].'">'.PHP_EOL;
if (Text::isNotEmpty($this->getValue('fbAppId'))) {
$html .= '<meta property="fb:app_id" content="'. $this->getValue('fbAppId').'">'.PHP_EOL;
}
return $html; return $html;
} }