Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mms] Abstract CSS caching/compressions into Horde_Themes_Css framework.
- Loading branch information
Showing
9 changed files
with
455 additions
and
130 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* Copyright 2014 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file COPYING for license information (LGPL). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
* | ||
* @category Horde | ||
* @copyright 2014 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @link http://pear.horde.org/index.php?package=Core | ||
* @package Core | ||
*/ | ||
|
||
/** | ||
* A Horde_Injector based factory for creating the CSS caching object. | ||
* | ||
* @author Michael Slusarz <slusarz@horde.org> | ||
* @category Horde | ||
* @copyright 2014 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @link http://pear.horde.org/index.php?package=Core | ||
* @package Core | ||
* @since 2.12.0 | ||
*/ | ||
class Horde_Core_Factory_CssCache extends Horde_Core_Factory_Injector | ||
{ | ||
/** | ||
*/ | ||
public function create(Horde_Injector $injector) | ||
{ | ||
global $conf; | ||
|
||
$driver = empty($conf['cachecss']) | ||
? 'none' | ||
: strtolower($conf['cachecssparams']['driver']); | ||
|
||
switch ($driver) { | ||
case 'filesystem': | ||
$driver = 'Horde_Themes_Css_Cache_File'; | ||
$params = $conf['cachecssparams']; | ||
break; | ||
|
||
case 'horde_cache': | ||
$driver = 'Horde_Themes_Css_Cache_HordeCache'; | ||
$params = $conf['cachecssparams']; | ||
break; | ||
|
||
case 'none': | ||
default: | ||
$driver = 'Horde_Themes_Css_Cache_Null'; | ||
$params = array(); | ||
break; | ||
} | ||
|
||
return new $driver($params); | ||
} | ||
|
||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* Copyright 2014 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file COPYING for license information (LGPL). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
* | ||
* @category Horde | ||
* @copyright 2014 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @package Core | ||
*/ | ||
|
||
/** | ||
* Object handling storage of cached CSS data. | ||
* | ||
* @author Michael Slusarz <slusarz@horde.org> | ||
* @category Horde | ||
* @copyright 2014 Horde LLC | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
* @package Core | ||
* @since 2.12.0 | ||
*/ | ||
abstract class Horde_Themes_Css_Cache | ||
{ | ||
/** | ||
* Configuration parameters. | ||
* | ||
* @var array | ||
*/ | ||
protected $_params; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param array $params Configuration parameters. | ||
*/ | ||
public function __construct(array $params = array()) | ||
{ | ||
$this->_params = $params; | ||
} | ||
|
||
/** | ||
* Process a list of CSS files. | ||
* | ||
* @param array $css See Horde_Themes_Css#getStylesheets(). | ||
* @param string $cacheid Cache ID. | ||
* | ||
* @return array The list of URLs to display (Horde_Url objects). | ||
*/ | ||
abstract public function process($css, $cacheid); | ||
|
||
/** | ||
* Perform garbage collection. | ||
*/ | ||
public function gc() | ||
{ | ||
} | ||
|
||
} |
Oops, something went wrong.