Source for file Pel.php

Documentation is available at Pel.php

  1. <?php
  2.  
  3. /* PEL: PHP EXIF Library. A library with support for reading and
  4. * writing all EXIF headers in JPEG and TIFF images using PHP.
  5. *
  6. * Copyright (C) 2004 Martin Geisler <gimpster@users.sourceforge.net>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program in the file COPYING; if not, write to the
  20. * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  21. * Boston, MA 02111-1307 USA
  22. */
  23.  
  24. /* Pel.php,v 1.11 2004/06/26 20:39:10 gimpster Exp */
  25.  
  26.  
  27. /**
  28. * Miscellaneous stuff for the overall behavior of PEL.
  29. *
  30. * @author Martin Geisler <gimpster@users.sourceforge.net>
  31. * @version 1.11
  32. * @date 2004/06/26 20:39:10
  33. * @license http://www.gnu.org/licenses/gpl.html GNU General Public
  34. * License (GPL)
  35. * @package PEL
  36. */
  37.  
  38.  
  39. /* Initialize Gettext. This must be done before any part of PEL calls
  40. * Pel::tra() or Pel::fmt() --- this is ensured if every piece of code
  41. * using those two functions require() this file.
  42. *
  43. * The PEL translations are stored in './locale'. It is important to
  44. * use an absolute path here because the lookups will be relative to
  45. * the current directory. */
  46. bindtextdomain('pel', dirname(__FILE__) . '/locale');
  47.  
  48.  
  49. /**
  50. * Class with miscellaneous static methods.
  51. *
  52. * This class will contain various methods that govern the overall
  53. * behavior of PEL.
  54. *
  55. * @author Martin Geisler <gimpster@users.sourceforge.net>
  56. * @package PEL
  57. */
  58. class Pel {
  59.  
  60. /**
  61. * Flag for controlling debug information.
  62. *
  63. * The methods producing debug information ({@link debug()} and
  64. * {@link warning()}) will only output something if this variable is
  65. * set to true.
  66. *
  67. * @var boolean
  68. */
  69. static $debug = false;
  70.  
  71. /**
  72. * Conditionally output debug information.
  73. *
  74. * This method works just like printf() except that it always
  75. * terminates the output with a newline, and that it only outputs
  76. * something if the PEL_DEBUG defined to some true value.
  77. *
  78. * @param string $format the format string.
  79. *
  80. * @param mixed $args,... any number of arguments can be given. The
  81. * arguments will be available for the format string as usual with
  82. * sprintf().
  83. */
  84. static function debug() {
  85. if (self::$debug) {
  86. $args = func_get_args();
  87. $str = array_shift($args);
  88. vprintf($str . "\n", $args);
  89. }
  90. }
  91.  
  92. /**
  93. * Conditionally output a warning.
  94. *
  95. * This method works just like printf() except that it prepends the
  96. * output with the string 'Warning: ', terminates the output with a
  97. * newline, and that it only outputs something if the PEL_DEBUG
  98. * defined to some true value.
  99. *
  100. * @param string $format the format string.
  101. *
  102. * @param mixed $args,... any number of arguments can be given. The
  103. * arguments will be available for the format string as usual with
  104. * sprintf().
  105. */
  106. static function warning() {
  107. if (self::$debug) {
  108. $args = func_get_args();
  109. $str = array_shift($args);
  110. vprintf('Warning: ' . $str . "\n", $args);
  111. }
  112. }
  113.  
  114.  
  115. /**
  116. * Translate a string.
  117. *
  118. * This static function will use Gettext to translate a string. By
  119. * always using this function for static string one is assured that
  120. * the translation will be taken from the correct text domain.
  121. * Dynamic strings should be passed to {@link fmt} instead.
  122. *
  123. * @param string the string that should be translated.
  124. *
  125. * @return string the translated string, or the original string if
  126. * no translation could be found.
  127. */
  128. static function tra($str) {
  129. return dgettext('pel', $str);
  130. }
  131.  
  132. /**
  133. * Translate and format a string.
  134. *
  135. * This static function will first use Gettext to translate a format
  136. * string, which will then have access to any extra arguments. By
  137. * always using this function for dynamic string one is assured that
  138. * the translation will be taken from the correct text domain. If
  139. * the string is static, use {@link tra} instead as it will be
  140. * faster.
  141. *
  142. * @param string $format the format string. This will be translated
  143. * before being used as a format string.
  144. *
  145. * @param mixed $args,... any number of arguments can be given. The
  146. * arguments will be available for the format string as usual with
  147. * sprintf().
  148. *
  149. * @return string the translated string, or the original string if
  150. * no translation could be found.
  151. */
  152. static function fmt() {
  153. $args = func_get_args();
  154. $str = array_shift($args);
  155. return vsprintf(dgettext('pel', $str), $args);
  156. }
  157.  
  158. }
  159.  
  160. ?>

SourceForge.net Logo Documentation generated on Wed, 21 Jul 2004 19:12:54 +0200 by phpDocumentor 1.3.0RC3