Skip to content

Instantly share code, notes, and snippets.

@johnnyajax
Created May 6, 2013 16:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save johnnyajax/9594aab026a9a2d62451 to your computer and use it in GitHub Desktop.
<?php
/*
+------------------------------------------------------------------------+
| Phalcon Framework |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2012 Phalcon Team (http://www.phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file docs/LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to license@phalconphp.com so we can send you a copy immediately. |
+------------------------------------------------------------------------+
| Authors: JohnnyAjax <janis.marnauza@gmail.com> |
+------------------------------------------------------------------------+
*/
namespace Phalcon;
abstract class MetaTag extends Tag
{
protected static $_documentDescription = '';
protected static $_documentKeywords = array();
/**
* Set meta description for current document
*
* @param string $description
*/
public static function setDescription($description) {
self::$_documentDescription = $description;
}
/**
* Get current document meta description
*
* @param boolean $tags
* @return string
*/
public static function getDescription($tags = true) {
if ($tags) {
return '<meta name="description" content="'. self::$_documentDescription .'">';
}
return self::$_documentDescription;
}
/**
* Set meta keywords for current document
*
* @param string|array $keywords
*/
public static function setKeywords($keywords) {
self::$_documentKeywords = (array)$keywords;
}
/**
* Add keywords to current document meta keywords
*
* @param string|array $keywords
*/
public static function addKeywords($keywords) {
self::$_documentKeywords = array_merge(self::$_documentKeywords, (array)$keywords);
}
/**
* Get current document meta keywords
*
* @param boolean $tags
* @return string
*/
public static function getKeywords($tags = true) {
$keywords = implode(',', self::$_documentKeywords);
if ($tags) {
return '<meta name="keywords" content="'. $keywords .'">';
}
return $keywords;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment