Skip to content

Commit

Permalink
Fixed Facebook support and added Open Graph plugin support.
Browse files Browse the repository at this point in the history
  • Loading branch information
dziudek committed Oct 25, 2012
1 parent 7011419 commit 5f1ad27
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
41 changes: 41 additions & 0 deletions meet_gavern/html/com_content/article/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,47 @@
// URL for Social API
$cur_url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

// OpenGraph support
$template_config = new JConfig();
$uri = JURI::getInstance();
$article_attribs = json_decode($this->item->attribs, true);
$pin_image = '';
$og_title = $this->escape($this->item->title);
$og_type = 'article';
$og_url = $cur_url;
if (isset($images->image_fulltext) and !empty($images->image_fulltext)) { $og_image = $uri->root() . htmlspecialchars($images->image_fulltext);
$pin_image = $uri->root() . htmlspecialchars($images->image_fulltext);
} else {
$og_image = '';
preg_match('/src="([^"]*)"/', $this->item->text, $matches);

if(isset($matches[0])) {
$pin_image = $uri->root() . substr($matches[0], 5,-1);
}
}

$og_site_name = $template_config->sitename;
$og_desc = '';


if(isset($article_attribs['og:title'])) {
$og_title = ($article_attribs['og:title'] == '') ? $this->escape($this->item->title) : $this->escape($article_attribs['og:title']);
$og_type = $this->escape($article_attribs['og:type']);
$og_url = $cur_url;
$og_image = ($article_attribs['og:image'] == '') ? $og_image : $uri->root() . $article_attribs['og:image'];
$og_site_name = ($article_attribs['og:site_name'] == '') ? $template_config->sitename : $this->escape($article_attribs['og:site_name']);
$og_desc = $this->escape($article_attribs['og:description']);
}

$doc = JFactory::getDocument();
$doc->setMetaData( 'og:title', $og_title );
$doc->setMetaData( 'og:type', $og_type );
$doc->setMetaData( 'og:url', $og_url );
$doc->setMetaData( 'og:image', $og_image );
$doc->setMetaData( 'og:site_name', $og_site_name );
$doc->setMetaData( 'og:description', $og_desc );


?>

<div class="item-page<?php echo $this->pageclass_sfx?> gk-item-page">
Expand Down
26 changes: 26 additions & 0 deletions meet_gavern/layouts/facebook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
*
* Facebook view
*
* @version 3.0.0
* @package Gavern Framework
* @copyright Copyright (C) 2010 - 2012 GavickPro. All rights reserved.
*
*/

// No direct access.
defined('_JEXEC') or die;

?>
<!DOCTYPE html>
<html>
<head>
<jdoc:include type="head" />
</head>
<body>
<jdoc:include type="message" />
<jdoc:include type="component" />
</body>
</html>
2 changes: 1 addition & 1 deletion meet_gavern/lib/gk.framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getParameters() {
public function getLayout($mode) {
// check layout saved in cookie
if ($mode == 'facebook') { // facebook mode
$layoutpath = $this->API->URLtemplatepath() . DS . 'layouts' . DS . $this->API->get('facebook_layout', 'facebook') . '.php';
$layoutpath = $this->API->URLtemplatepath() . DS . 'layouts' . DS . 'facebook.php';
if (is_file($layoutpath)) include ($layoutpath);
else echo 'Facebook layout doesn\'t exist!';
} else { // normal mode
Expand Down

0 comments on commit 5f1ad27

Please sign in to comment.