0byt3m1n1
Path:
/
data
/
applications
/
aps
/
gallery
/
2.3-2
/
standard
/
htdocs
/
modules
/
colorpack
/
classes
/
[
Home
]
File: ColorPackImpl.class
<?php /* * Gallery - a web based photo album viewer and editor * Copyright (C) 2000-2008 Bharat Mediratta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ GalleryCoreApi::requireOnce('modules/colorpack/classes/ColorPackInterface_1_0.class'); /** * Implementation of the ColorPackInterface for including colorpack css * @package ColorPack * @subpackage Classes * @author Alan Harder <alan.harder@sun.com> * @version $Revision: 17580 $ */ class ColorPackImpl extends ColorPackInterface_1_0 { /** * @see ColorPackInterface_1_0::getColorPacks */ function getColorPacks() { global $gallery; $platform =& $gallery->getPlatform(); $colorpacks = array(); $dir = dirname(dirname(__FILE__)) . '/packs'; if ($platform->is_dir($dir) && $platform->is_readable($dir) && $fd = $platform->opendir($dir)) { ob_start(); while ($file = $platform->readdir($fd)) { $subdir = "$dir/$file"; $inc = "$subdir/color.css"; if ($platform->is_dir($subdir) && $platform->file_exists($inc)) { $colorpackName = null; include($inc); $colorpacks[$file] = isset($colorpackName) ? $this->translate($colorpackName) : $file; } } ob_end_clean(); $platform->closedir($fd); asort($colorpacks); } return array(null, array_merge(array('' => $this->translate('None')), $colorpacks)); } /** * @see ColorPackInterface_1_0::selectColorPack */ function selectColorPack(&$template, $colorpack) { if (!empty($colorpack)) { $template->style("modules/colorpack/packs/$colorpack/color.css"); } return null; } /** * Translate given string * @param string $string * @return translated string */ function translate($string) { global $gallery; $translator =& $gallery->getTranslator(); list ($ret, $content) = $translator->translateDomain('modules_colorpack', $string); if ($ret) { return $string; } return $content; } } ?>