/gist:9594aab026a9a2d62451 Secret
Created
May 6, 2013 16:09
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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