/** * @param string $fileName * @return \Application\SharedKernel\SqliteDbFile */ public static function initializeFromDist($fileName) { $dist = new self($fileName . '.dist'); ErrorHandler::start(); copy($dist->toString(), $fileName); ErrorHandler::stop(true); return new self($fileName); }
public static function responseSuccess($message, $data = null, $format = 'JSON') { $ajax = new self(); $ajax->message = $message; $ajax->type = self::SUCCESS; if ($data != null) { $ajax->data = $data; } return $ajax->toString(); }
/** * Checks if a locale identifier is a real locale or not * Examples: * "en_XX" refers to "en", which returns true * "XX_yy" refers to "root", which returns false * * @param string|Zend_Locale $locale Locale to check for * @param boolean $create If true, create a default locale, if $locale is empty * @return false|string false if given locale is not a locale, else the locale identifier is returned */ public static function isLocale($locale, $create = false) { if (empty($locale) and $create === true) { $locale = new self(); } if ($locale instanceof Zend_Locale) { return $locale->toString(); } if (!is_string($locale)) { return false; } if (empty(self::$_auto)) { $temp = new self($locale); self::$_auto = $temp->getDefault(null, false); self::$_browser = $temp->getDefault(self::BROWSER, false); self::$_environment = $temp->getDefault(self::ENVIRONMENT, false); } if ($locale == 'auto') { $locale = self::$_auto; } if ($locale == 'browser') { $locale = self::$_browser; } if ($locale == 'environment') { $locale = self::$_environment; } if (is_array($locale)) { $locale = key($locale); } if (array_key_exists($locale, self::$_localeData)) { return $locale; } else { $locale = explode('_', $locale); if (array_key_exists($locale[0], self::$_localeData)) { return $locale[0]; } } return false; }
public function toString($sql) { $hold = $this->_hold; $hold_len = strlen($hold); $unions = $sql->getPart('unions'); $sql = $this->_renderSql($sql); $values = $this->getValues(); foreach ($values as $value) { if (is_string($value)) { $value = "'" . $this->escape($value) . "'"; } elseif (is_array($value)) { foreach ($value as &$v) { $v = $this->escape($v); } $value = "'" . implode("', '", $value) . "'"; } if (false !== ($pos = strpos($sql, $hold))) { $sql = substr_replace($sql, $value, $pos, $hold_len); } } if ($unions) { foreach ($unions as $union) { $b = new self($this->_db); $sql .= ' UNION (' . $b->toString($union) . ')'; } } return $sql; }
/** * Merge the data and the XML template into an HTML page. * @param type $xslDocument the template. * @return type * @throws Dom\Exception */ public function transform($xslDocument) { if ($xslDocument->domDocument) { $processor = new \XsltProcessor(); $processor->importStylesheet($xslDocument->domDocument); $htmlDomDocument = new self(); $htmlDomDocument->domDocument = $processor->transformToDoc($this->domDocument); if (!$htmlDomDocument->domDocument) { throw new Dom\Exception('The XSL transformation has failed.'); } } else { throw new Dom\Exception('There is no XSL template to transform with.'); } try { return $htmlDomDocument->toString(false); } catch (\Exception $exception) { $this->logger->error($exception->getMessage()); throw new Dom\Exception("dom-transform-failed"); } }
/** * @param File[] * @param string * @param bool * @return void * @throws IOException */ private function getFilesR(&$files, $dir) { $dir = rtrim($dir, '/'); if (!($dh = @opendir($dir))) { throw new IOException('Failed to open directory for reading: ' . $dir); } try { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..') { $f = new self($dir . '/' . $file); $files[] = $f; if ($f->isDir()) { $this->getFilesR($files, $f->toString()); } } } closedir($dh); } catch (Exception $e) { closedir($dh); throw $e; } }