Добавил open graph

This commit is contained in:
Krivchikov Dmitry 2014-07-05 00:09:30 +04:00
parent 32c43b03c0
commit baf1c91ec9
3 changed files with 33 additions and 1 deletions

View File

@ -6,6 +6,7 @@ abstract class Controller
static $layout = 'layout.php';
static private $styles = array();
static private $scripts = array();
static private $og = array();
static private $vars = array();

View File

@ -47,10 +47,28 @@ class IndexController extends Controller
$res = App::$DB->query("SELECT COUNT(`id`) pointsCount FROM `points`")->fetch(PDO::FETCH_ASSOC);
App::setConfig('title', $res['pointsCount'].' или даже больше поводов не сидеть дома');
if($_GET['point'] && is_numeric($_GET['point']))
{
$id = (int) $_GET['point'];
$point = new Point();
$point = $point->getByPK($id);
$point->descriptionHtml = htmlspecialchars($point->description);
$point->name = htmlspecialchars($point->name);
$og['title'] = $point->name . ' - wikipoints.ru';
$og['description'] = $point->descriptionHtml;
$og['site_name'] = 'WikiPoints - '.$res['pointsCount'].' или даже больше поводов не сидеть дома';
$og['type'] = 'article';
$og['url'] = 'http://wikipoints.ru/?point='.$id;
$og['image'] = $point->img;
}
self::render('indexTemplate.php', array(
'categories' => $category->getAll('', 'ord'),
'user' => App::$user,
'routes' => $routes,
'og' => $og,
));
}

View File

@ -1,5 +1,9 @@
<!DOCTYPE html>
<html>
<html xmlns="http://www.w3.org/1999/xhtml"
lang="ru"
prefix="og: http://ogp.me/ns#"
xmlns:fb="http://ogp.me/ns/fb#"
xmlns:og="http://ogp.me/ns#">
<head>
<title><?= App::getConfig('title') ?></title>
@ -15,6 +19,15 @@
<?php endforeach; ?>
<?php endif; ?>
<?php if($data['og']): ?>
<meta property="og:title" content="<?=$data['og']['title']?>" />
<meta property="og:description" content="<?=$data['og']['description']?>" />
<meta property="og:site_name" content="<?=$data['og']['site_name']?>" />
<meta property="og:type" content="<?=$data['og']['type']?>" />
<meta property="og:url" content="<?=$data['og']['url']?>" />
<meta property="og:image" content="<?=$data['og']['image']?>" />
<?php endif; ?>
<?php if ($vars): ?>
<script type="text/javascript">
<?php foreach ($vars as $varName => $var): ?>