Skip to content
This repository has been archived by the owner on Jul 12, 2019. It is now read-only.

Commit

Permalink
Added HeadMeta
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Sep 3, 2014
1 parent 7324461 commit ab9e92e
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions src/HeadMeta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
/**
* @author: Patsura Dmitry @ovr <talk@dmtry.me>
*/

namespace Phalcony;

/**
* Class HeadMeta
* @package Phalcony
*/
class HeadMeta
{
/**
* Types of attributes
* @var array
*/
protected $_typeKeys = array('name', 'http-equiv', 'charset', 'property');
protected $_requiredKeys = array('content');
protected $_modifierKeys = array('lang', 'scheme');

protected $_register = [];

/**
* @param null $content
* @param null $keyValue
* @param string $keyType
*/
public function append($content = null, $keyValue = null, $keyType = 'name')
{
$this->_register[] = [
strtolower($keyType) => $keyValue,
'content' => $content
];
}

/**
* @param null $content
* @param null $keyValue
* @param string $keyType
*/
public function prepend($content = null, $keyValue = null, $keyType = 'name')
{
/**
* @todo Сделать
*/
}

/**
* @param $name
* @param $content
*/
public function appendName($name, $content)
{
$this->_register[] = [
'name' => $name,
'content' => $content
];
}

protected function _normalizeType($type)
{
switch ($type) {
case 'Name':
case 'name':
return 'name';
case 'HttpEquiv':
return 'http-equiv';
case 'Property':
return 'property';
default:
exit();
}
}

public function __toString()
{
$html = '';

if (count($this->_register) == 0) {
return $html;
}

foreach ($this->_register as $tag) {
$html .= "\t" . \Phalcon\Tag::tagHtml('meta', $tag) . "\n";
}

return $html;
}
}

0 comments on commit ab9e92e

Please sign in to comment.