mirror of
https://github.com/letrunghieu/favicon.git
synced 2025-01-29 10:18:27 +01:00
Implement Config class
This commit is contained in:
parent
67b8f0ed03
commit
408fa1d93b
@ -36,7 +36,7 @@ auxiliary.org-netbeans-modules-editor-indent.text.x-php5.CodeStyle.project.text-
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-php5.CodeStyle.project.useTraitBodyBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-php5.CodeStyle.project.whileBracePlacement=NEW_LINE
|
||||
include.path=${php.global.include.path}
|
||||
php.version=PHP_54
|
||||
php.version=PHP_53
|
||||
source.encoding=UTF-8
|
||||
src.dir=.
|
||||
tags.asp=false
|
||||
|
170
src/Config.php
170
src/Config.php
@ -7,6 +7,172 @@ namespace HieuLe\Favicon;
|
||||
*
|
||||
* @author Hieu Le <letrunghieu.cse09@gmail.com>
|
||||
*/
|
||||
class Config {
|
||||
//put your code here
|
||||
class Config
|
||||
{
|
||||
|
||||
/**
|
||||
* Name of PNG sizes that we want to generate favicon
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_turnedOnSizes = array();
|
||||
|
||||
/**
|
||||
* The background color of Windows tite
|
||||
*
|
||||
* @var type
|
||||
*/
|
||||
private $_msapplicationTileColor = '#FFFFFF';
|
||||
|
||||
/**
|
||||
* Supported PNG sizes and its description
|
||||
*
|
||||
* @var type
|
||||
*/
|
||||
private static $_sizes = array(
|
||||
// general icons
|
||||
'touch' => array(
|
||||
'size' => 152,
|
||||
'label' => 'Touch icon for iOS 2.0+ and Android 2.1+',
|
||||
),
|
||||
'fav' => array(
|
||||
'size' => 32,
|
||||
'label' => 'Favicons targeted to any additional png sizes',
|
||||
),
|
||||
'fav-57' => array(
|
||||
'size' => 57,
|
||||
'label' => 'For non-Retina iPhone, iPod Touch, and Android 2.1+ devices',
|
||||
),
|
||||
'ms' => array(
|
||||
'size' => 144,
|
||||
'label' => 'IE 10 Metro tile icon (Metro equivalent of apple-touch-icon)',
|
||||
),
|
||||
// touch icons
|
||||
'touch-152' => array(
|
||||
'size' => 152,
|
||||
'label' => 'For iPad with high-resolution Retina display running iOS ≥ 7',
|
||||
),
|
||||
'touch-144' => array(
|
||||
'size' => 144,
|
||||
'label' => 'For iPad with high-resolution Retina display running iOS ≤ 6',
|
||||
),
|
||||
'touch-120' => array(
|
||||
'size' => 120,
|
||||
'label' => 'For iPhone with high-resolution Retina display running iOS ≥ 7',
|
||||
),
|
||||
'touch-114' => array(
|
||||
'size' => 114,
|
||||
'label' => 'For iPhone with high-resolution Retina display running iOS ≤ 6',
|
||||
),
|
||||
'touch-72' => array(
|
||||
'size' => 72,
|
||||
'label' => 'For first- and second-generation iPad',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Generate PNG favicon for all sizes
|
||||
*
|
||||
* @return \HieuLe\Favicon\Config
|
||||
*/
|
||||
public function allOn()
|
||||
{
|
||||
foreach (self::$_sizes as $name => $_)
|
||||
{
|
||||
$this->_turnedOnSizes[$name] = true;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not generate any PNG favicon
|
||||
*
|
||||
* @return \HieuLe\Favicon\Config
|
||||
*/
|
||||
public function allOff()
|
||||
{
|
||||
$this->_turnedOnSizes = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate PNG favicon for this size
|
||||
*
|
||||
* @param string $size
|
||||
* @return \HieuLe\Favicon\Config
|
||||
*/
|
||||
public function turnOn($size)
|
||||
{
|
||||
if (isset(self::$_sizes[$size]))
|
||||
{
|
||||
$this->_turnedOnSizes[$size] = true;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not generate PNG for this size
|
||||
*
|
||||
* @param string $size
|
||||
* @return \HieuLe\Favicon\Config
|
||||
*/
|
||||
public function turnOff($size)
|
||||
{
|
||||
if (isset($this->_turnedOnSizes[$size]))
|
||||
{
|
||||
unset($this->_turnedOnSizes[$size]);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background color for Windows tile
|
||||
*
|
||||
* @param string $hexColor hex value of background color (e.g: #000000)
|
||||
* @return \HieuLe\Favicon\Config
|
||||
*/
|
||||
public function setTileBackground($hexColor)
|
||||
{
|
||||
$this->_msapplicationTileColor = $hexColor;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Windows tile background color
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTileBackground()
|
||||
{
|
||||
return $this->_msapplicationTileColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get turned on sizes name and width as an array (name => width)
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function getTurnedOnSizes()
|
||||
{
|
||||
$result = array();
|
||||
foreach ($this->_turnedOnSizes as $size => $on)
|
||||
{
|
||||
if ($on)
|
||||
{
|
||||
$result[$size] = self::$_sizes[$size];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get supported PNG sizes and description
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getSizes()
|
||||
{
|
||||
return self::$_sizes;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user