Exemplo n.º 1
0
 /**
  * Constructor
  * @param string     gallery id
  * @param sgGallery  reference to the parent gallery
  */
 function sgGallery($id, &$parent)
 {
     $this->id = $id;
     $this->parent = $parent;
     $this->config = sgConfig::getInstance();
     $this->translator = Translator::getInstance();
 }
Exemplo n.º 2
0
 public function __construct()
 {
     $this->_view = View::getInstance();
     $this->_request = Request::getInstance();
     $this->_validator = Validator::getInstance();
     $this->_translator = Translator::getInstance();
 }
Exemplo n.º 3
0
 public static function __callStatic($name, $arguments)
 {
     $translator = Translator::getInstance();
     $callback = array();
     if (in_array($name, array('addCatalog', 'setCacheDir'))) {
         $callback = array($translator, $name);
     }
     if (!is_callable($callback)) {
         throw new UnexistentMethodException('core.message_undefined_method', __CLASS__, $name);
     }
     return call_user_func_array($callback, $arguments);
 }
Exemplo n.º 4
0
 /**
  * Fetches gallery info for the specified gallery and immediate children.
  * @param string  gallery id
  * @param string  language code spec for this request (optional)
  * @param int     number of levels of child galleries to fetch (optional)
  * @return sgGallery  the gallery object created
  */
 function &getGallery($galleryId, &$parent, $getChildGalleries = 1, $language = null)
 {
     $gal = new sgGallery($galleryId, $parent);
     if ($language == null) {
         $translator = Translator::getInstance();
         $language = $translator->language;
     }
     //try to open language specific metadata
     $fp = @fopen($this->config->base_path . $this->config->pathto_galleries . $galleryId . "/metadata.{$language}.csv", "r");
     //if fail then try to open generic metadata
     if (!$fp) {
         $fp = @fopen($this->config->base_path . $this->config->pathto_galleries . $galleryId . "/metadata.csv", "r");
     }
     if ($fp) {
         while ($temp[] = fgetcsv($fp, 2048)) {
         }
         fclose($fp);
         list($gal->filename, $gal->thumbnail, $gal->owner, $gal->groups, $gal->permissions, $gal->categories, $gal->name, $gal->artist, $gal->email, $gal->copyright, $gal->desc, $gal->summary, $gal->date) = $temp[1];
         //only fetch individual images if child galleries are required
         if ($getChildGalleries) {
             for ($i = 0; $i < count($temp) - 3; $i++) {
                 $gal->images[$i] = new sgImage($temp[$i + 2][0], $gal, $this->config);
                 list(, $gal->images[$i]->thumbnail, $gal->images[$i]->owner, $gal->images[$i]->groups, $gal->images[$i]->permissions, $gal->images[$i]->categories, $gal->images[$i]->name, $gal->images[$i]->artist, $gal->images[$i]->email, $gal->images[$i]->copyright, $gal->images[$i]->desc, $gal->images[$i]->location, $gal->images[$i]->date, $gal->images[$i]->camera, $gal->images[$i]->lens, $gal->images[$i]->film, $gal->images[$i]->darkroom, $gal->images[$i]->digital) = $temp[$i + 2];
                 //get image size and type
                 list($gal->images[$i]->width, $gal->images[$i]->height, $gal->images[$i]->type) = @GetImageSize($gal->images[$i]->realPath());
             }
             //otherwise just fill in empty images
         } else {
             if (count($temp) > 3) {
                 for ($i = 0; $i < count($temp) - 3; $i++) {
                     $gal->images[$i] = new sgImage($temp[$i + 2][0], $gal);
                 }
             }
         }
     } else {
         //no metadata found so use iifn method implemented in superclass
         return parent::getGallery($galleryId, $parent, $getChildGalleries, $language);
     }
     //discover child galleries
     $dir = Singapore::getListing($this->config->base_path . $this->config->pathto_galleries . $galleryId . "/");
     if ($getChildGalleries) {
         //but only fetch their info if required too
         foreach ($dir->dirs as $gallery) {
             $gal->galleries[] = $this->getGallery($galleryId . "/" . $gallery, $gal, $getChildGalleries - 1, $language);
         }
     } else {
         //otherwise just copy their names in so they can be counted
         $gal->galleries = $dir->dirs;
     }
     return $gal;
 }
Exemplo n.º 5
0
 /**
  * 
  */
 public function __construct(Gw2Account $account = null)
 {
     $trans = Translator::getInstance();
     // GENERAL
     $menu = Menu::create($trans['menu.general']);
     $menu->addItem('account', $trans['menu.general.account']);
     $menu->addItem('wallet', $trans['menu.general.wallet'])->setPermission(Gw2Account::PERMISSION_WALLET);
     $menu->addItem('golds', $trans['menu.general.golds']);
     $menu->addItem('search', $trans['menu.general.search']);
     $menu->addItem('pvp', $trans['menu.general.pvp'])->setPermission(Gw2Account::PERMISSION_PVP);
     $menu->addItem('statistics', $trans['menu.general.statistics']);
     $this->addMenu($menu);
     // CHARACTERS
     $menu = Menu::create($trans['menu.characters']);
     $menu->addItem('characters', $trans['menu.characters.characters']);
     $menu->addItem('equipments', $trans['menu.characters.equipments']);
     $menu->addItem('inventories', $trans['menu.characters.inventories'])->setPermission(Gw2Account::PERMISSION_INVENTORIES);
     $menu->addItem('attributes', $trans['menu.characters.attributes']);
     $menu->addItem('builds', $trans['menu.characters.builds'])->setPermission(Gw2Account::PERMISSION_BUILDS);
     if ($account) {
         $menu->addSeparator();
         foreach ($account->getCharacterNames() as $name) {
             $menu->addItem('character/' . $name, $name, 'character/' . $name);
         }
     }
     $this->addMenu($menu);
     // VAULTS
     $menu = Menu::create($trans['menu.vaults']);
     $menu->addItem('bank', $trans['menu.vaults.bank'])->setPermission(Gw2Account::PERMISSION_INVENTORIES);
     $menu->addItem('collectibles', $trans['menu.vaults.collectibles'])->setPermission(Gw2Account::PERMISSION_INVENTORIES);
     $this->addMenu($menu);
     // UNLOCKS
     $menu = Menu::create($trans['menu.unlocks']);
     $menu->addItem('wardrobe_armors', $trans['menu.unlocks.wardrobe_armors'])->setPermission(Gw2Account::PERMISSION_UNLOCKS);
     $menu->addItem('wardrobe_weapons', $trans['menu.unlocks.wardrobe_weapons'])->setPermission(Gw2Account::PERMISSION_UNLOCKS);
     $menu->addItem('dyes', $trans['menu.unlocks.dyes'])->setPermission(Gw2Account::PERMISSION_UNLOCKS);
     $menu->addItem('minis', $trans['menu.unlocks.minis'])->setPermission(Gw2Account::PERMISSION_UNLOCKS);
     $this->addMenu($menu);
     // TRADING POST
     $menu = Menu::create($trans['menu.tp']);
     $menu->addItem('tp_buys', $trans['menu.tp.tp_buys'])->setPermission(Gw2Account::PERMISSION_TRADINGPOST);
     $menu->addItem('tp_sells', $trans['menu.tp.tp_sells'])->setPermission(Gw2Account::PERMISSION_TRADINGPOST);
     $this->addMenu($menu);
     // ACHIEVMENTS
     $menu = Menu::create($trans['menu.achievements']);
     $menu->addItem('achievements_daily', $trans['menu.achievements.daily']);
     $this->addMenu($menu);
 }
Exemplo n.º 6
0
function __()
{
    if (func_num_args() < 1) {
        return false;
    }
    $translator = Translator::getInstance();
    $config = Config::singleton();
    $lang = is_null(Session::get("lang")) ? $config->get("defaultLang") : Session::get("lang");
    $args = func_get_args();
    $str = array_shift($args);
    if (count($args)) {
        return vsprintf($translator->get($str, $lang), $args);
    } else {
        return $translator->get($str, $lang);
    }
}
Exemplo n.º 7
0
 public function reservationList($date)
 {
     $dateStart = DateTime::createFromFormat(DATE_FORMAT, $date);
     $sql = "\r\n            SELECT \r\n                t.tableId, \r\n                t.tableName, \r\n                t.tablePerson,\r\n                b.bookingFrom,\r\n                b.bookingTo\r\n            FROM tables t\r\n            LEFT JOIN booking b USING(tableId)\r\n            WHERE \r\n                bookingFrom >= ? AND bookingTo <= ?\r\n            ORDER BY b.bookingFrom, tablePerson\r\n\r\n        ";
     $start = $dateStart->format("Y-m-d 00:00:00");
     $end = $dateStart->format("Y-m-d 23:59:59");
     $stmt = $this->_connection->prepare($sql);
     $stmt->bind_param('ss', $start, $end);
     $stmt->execute();
     $stmt->bind_result($tableId, $tableName, $tablePerson, $bookingFrom, $bookingTo);
     $t = Translator::getInstance();
     $tables = array();
     while ($stmt->fetch()) {
         $tables[] = array($tableId, $t->translate($tableName), $tablePerson, $bookingFrom, $bookingTo);
     }
     return $tables;
 }
Exemplo n.º 8
0
 /**
  * Admin constructor. Doesn't call {@link Singapore} constructor.
  * @param string the path to the base singapore directory
  */
 function sgAdmin($basePath = "")
 {
     //import class definitions
     //io handler class included once config is loaded
     require_once $basePath . "includes/translator.class.php";
     require_once $basePath . "includes/thumbnail.class.php";
     require_once $basePath . "includes/gallery.class.php";
     require_once $basePath . "includes/config.class.php";
     require_once $basePath . "includes/image.class.php";
     require_once $basePath . "includes/user.class.php";
     //start execution timer
     $this->scriptStartTime = microtime();
     //remove slashes
     if (get_magic_quotes_gpc()) {
         $_REQUEST = array_map(array("Singapore", "arraystripslashes"), $_REQUEST);
         //as if magic_quotes_gpc wasn't insane enough, php doesn't add slashes
         //to the tmp_name variable so I have to add them manually. Grrrr.
         foreach ($_FILES as $key => $nothing) {
             $_FILES[$key]["tmp_name"] = addslashes($_FILES[$key]["tmp_name"]);
         }
         $_FILES = array_map(array("Singapore", "arraystripslashes"), $_FILES);
     }
     $galleryId = isset($_REQUEST["gallery"]) ? $_REQUEST["gallery"] : ".";
     //load config from singapore root directory
     $this->config = sgConfig::getInstance();
     $this->config->loadConfig($basePath . "singapore.ini");
     $this->config->loadConfig($basePath . "secret.ini.php");
     //set runtime values
     $this->config->pathto_logs = $this->config->pathto_data_dir . "logs/";
     $this->config->pathto_cache = $this->config->pathto_data_dir . "cache/";
     $this->config->pathto_current_template = $this->config->pathto_templates . $this->config->default_template . "/";
     $this->config->pathto_admin_template = $this->config->pathto_templates . $this->config->admin_template_name . "/";
     //load config from admin template ini file (admin.ini) if present
     $this->config->loadConfig($basePath . $this->config->pathto_admin_template . "admin.ini");
     $this->template = $this->config->default_template;
     //do not load gallery-specific ini files
     //set current language from request vars or config
     $this->language = isset($_REQUEST["lang"]) ? $_REQUEST["lang"] : $this->config->default_language;
     //read the language file
     $this->translator = Translator::getInstance($this->language);
     $this->translator->readLanguageFile($this->config->base_path . $this->config->pathto_locale . "singapore." . $this->language . ".pmo");
     $this->translator->readLanguageFile($this->config->base_path . $this->config->pathto_locale . "singapore.admin." . $this->language . ".pmo");
     //include IO handler class and create instance
     require_once $basePath . "includes/io_" . $this->config->io_handler . ".class.php";
     $ioClassName = "sgIO_" . $this->config->io_handler;
     $this->io = new $ioClassName($this->config);
     //set character set
     if (!empty($this->translator->languageStrings[0]["charset"])) {
         $this->character_set = $this->translator->languageStrings[0]["charset"];
     } else {
         $this->character_set = $this->config->default_charset;
     }
     //set action to perform
     if (empty($_REQUEST["action"])) {
         $this->action = "menu";
     } else {
         $this->action = $_REQUEST["action"];
     }
     //set page title
     $this->pageTitle = $this->config->gallery_name;
     //set root node of crumb line
     $holder = new sgGallery("", new stdClass());
     $holder->name = $this->config->gallery_name;
     $this->ancestors = array($holder);
 }
Exemplo n.º 9
0
<title>language cache updater</title>
<link rel="stylesheet" type="text/css" href="tools.css" />
</head>

<body>

<h1>language cache updater</h1>

<p><?php 
$files = parseDirectory($OUTPUTPATH, 'pmo');
$availableLanguages = array();
foreach ($files as $file) {
    if (!preg_match("/singapore\\.([\\w]+)\\.pmo\$/i", $file, $matches)) {
        continue;
    }
    $i18n = Translator::getInstance($matches[1]);
    $i18n->readLanguageFile($sgConfig->base_path . $sgConfig->pathto_locale . "singapore." . $i18n->language . ".pmo");
    $availableLanguages[$matches[1]] = $i18n->languageStrings[0]['language'];
    echo "Added {$matches['1']} => " . $i18n->languageStrings[0]['language'] . " to available languages.<br />\n";
}
//add english which has no translation files
$availableLanguages["en"] = "English";
ksort($availableLanguages);
if (saveCache($availableLanguages, $OUTPUTFILE)) {
    echo "Cache file saved as " . $OUTPUTFILE;
} else {
    echo "Could not save cache file as " . $OUTPUTFILE;
}
?>
</p>
Exemplo n.º 10
0
 public function __construct()
 {
     if (!$this->isAvailable()) {
         throw new Exception(Translator::getInstance()->trans("The archiver :name is not available. Please install the php extension :extension first.", [':name' => $this->getName(), ':extension' => $this->getExtension()]));
     }
 }
Exemplo n.º 11
0
 /**
  * Constructor, does all init type stuff. This code is a total mess.
  * @param string the path to the base singapore directory
  */
 function Singapore($basePath = "")
 {
     //import class definitions
     //io handler class included once config is loaded
     require_once $basePath . "includes/translator.class.php";
     require_once $basePath . "includes/thumbnail.class.php";
     require_once $basePath . "includes/gallery.class.php";
     require_once $basePath . "includes/config.class.php";
     require_once $basePath . "includes/image.class.php";
     require_once $basePath . "includes/user.class.php";
     //start execution timer
     $this->scriptStartTime = microtime();
     //remove slashes
     if (get_magic_quotes_gpc()) {
         $_REQUEST = array_map(array("Singapore", "arraystripslashes"), $_REQUEST);
     }
     //desanitize request
     $_REQUEST = array_map("htmlentities", $_REQUEST);
     //load config from singapore root directory
     $this->config = sgConfig::getInstance();
     $this->config->loadConfig($basePath . "singapore.ini");
     $this->config->loadConfig($basePath . "secret.ini.php");
     //if instantiated remotely...
     if (!empty($basePath)) {
         //...try to guess base path and relative url
         if (empty($this->config->base_path)) {
             $this->config->base_path = $basePath;
         }
         if (empty($this->config->base_url)) {
             $this->config->base_url = $basePath;
         }
         //...load local config if present
         //may over-ride guessed values above
         $this->config->loadConfig("singapore.local.ini");
     }
     //set current gallery to root if not specified in url
     $galleryId = isset($_GET[$this->config->url_gallery]) ? $_GET[$this->config->url_gallery] : ".";
     //load config from gallery ini file (gallery.ini) if present
     $this->config->loadConfig($basePath . $this->config->pathto_galleries . $galleryId . "/gallery.ini");
     //set current template from request vars or config
     //first, preset template to default one
     $this->template = $this->config->default_template;
     //then check if requested template exists
     if (!empty($_REQUEST[$this->config->url_template])) {
         $templates = Singapore::getListing($this->config->base_path . $this->config->pathto_templates);
         foreach ($templates->dirs as $single) {
             if ($single == $_REQUEST[$this->config->url_template]) {
                 $this->template = $single;
                 break;
             }
         }
     }
     $this->config->pathto_current_template = $this->config->pathto_templates . $this->template . '/';
     //load config from template ini file (template.ini) if present
     $this->config->loadConfig($basePath . $this->config->pathto_current_template . "template.ini");
     //set runtime values
     $this->config->pathto_logs = $this->config->pathto_data_dir . "logs/";
     $this->config->pathto_cache = $this->config->pathto_data_dir . "cache/";
     $this->config->pathto_admin_template = $this->config->pathto_templates . $this->config->admin_template_name . "/";
     //set current language from request vars or config
     if (!empty($_REQUEST[$this->config->url_lang])) {
         $this->language = $_REQUEST[$this->config->url_lang];
     } else {
         $this->language = $this->config->default_language;
         if ($this->config->detect_language) {
             foreach ($this->getBrowserLanguages() as $lang) {
                 if ($lang == "en" || file_exists($basePath . $this->config->pathto_locale . "singapore." . $lang . ".pmo")) {
                     $this->language = $lang;
                     break;
                 }
             }
         }
     }
     //read the language file
     $this->translator = Translator::getInstance($this->language);
     $this->translator->readLanguageFile($this->config->base_path . $this->config->pathto_locale . "singapore." . $this->language . ".pmo");
     //clear the UMASK
     umask(0);
     //include IO handler class and create instance
     require_once $basePath . "includes/io_" . $this->config->io_handler . ".class.php";
     $ioClassName = "sgIO_" . $this->config->io_handler;
     $this->io = new $ioClassName($this->config);
     //load gallery and image info
     $this->selectGallery($galleryId);
     //set character set
     if (!empty($this->translator->languageStrings[0]["charset"])) {
         $this->character_set = $this->translator->languageStrings[0]["charset"];
     } else {
         $this->character_set = $this->config->default_charset;
     }
     if (ini_get("mbstring.func_overload") == "7") {
         $this->character_set = "UTF-8";
     }
     //set action to perform
     if (empty($_REQUEST["action"])) {
         $this->action = "view";
     } else {
         $this->action = $_REQUEST["action"];
     }
 }
Exemplo n.º 12
0
 public function _($key)
 {
     $this->_translator = Translator::getInstance();
     return $this->_translator->translate($key);
 }
Exemplo n.º 13
0
 /**
  * Translate a plural message.
  *
  * @param string $singular
  * @param string $plural
  * @param int    $number
  * @param string $domain
  * @param string $locale
  *
  * @return string
  */
 public function translatePlural($singular, $plural, $number, $domain = null, $locale = null)
 {
     return Translator::getInstance()->translatePlural($singular, $plural, $number, $domain, $locale);
 }