cvs: pear /File_Gettext Gettext.php

From: Date: Thu, 29 Apr 2004 19:13:18 +0000
Subject: cvs: pear /File_Gettext Gettext.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-18968@lists.php.net to get a copy of this message
mike Thu Apr 29 15:13:18 2004 EDT Modified files: /pear/File_Gettext Gettext.php Log: * don't inlcude PEAR.php by default * added raiseError() * phpdoc http://cvs.php.net/diff.php/pear/File_Gettext/Gettext.php?r1=1.1&r2=1.2&ty=u Index: pear/File_Gettext/Gettext.php diff -u pear/File_Gettext/Gettext.php:1.1 pear/File_Gettext/Gettext.php:1.2 --- pear/File_Gettext/Gettext.php:1.1 Tue Mar 30 12:03:14 2004 +++ pear/File_Gettext/Gettext.php Thu Apr 29 15:13:17 2004 @@ -11,7 +11,7 @@ // | Copyright (c) 2004 Michael Wallner <mike@iworks.at> | // +----------------------------------------------------------------------+ // -// $Id: Gettext.php,v 1.1 2004/03/30 17:03:14 mike Exp $ +// $Id: Gettext.php,v 1.2 2004/04/29 19:13:17 mike Exp $ /** * File::Gettext @@ -21,7 +21,7 @@ * @category FileFormats */ -require_once 'PEAR.php'; +ini_set('track_errors', true); /** * File_Gettext @@ -33,7 +33,7 @@ * ## ### * * @author Michael Wallner <mike@php.net> -* @version $Revision: 1.1 $ +* @version $Revision: 1.2 $ * @access public */ class File_Gettext @@ -70,7 +70,7 @@ /** * Factory * - * @static + * @note This method should be called statically. * @access public * @return object Returns File_Gettext_PO or File_Gettext_MO on success * or PEAR_Error on failure. @@ -81,7 +81,7 @@ { $format = strToUpper($format); if (!@include_once 'File/Gettext/' . $format . '.php') { - return PEAR::raiseError($php_errormsg); + return File_Gettext::raiseError($php_errormsg); } $class = 'File_Gettext_' . $format; return new $class($file); @@ -93,7 +93,7 @@ * That's a simple fake of the 'msgfmt' console command. It reads the * contents of a GNU PO file and saves them to a GNU MO file. * - * @static + * @note This method should be called statically. * @access public * @return mixed Returns true on success or PEAR_Error on failure. * @param string $pofile path to GNU PO file @@ -102,18 +102,18 @@ function poFile2moFile($pofile, $mofile) { if (!is_file($pofile)) { - return PEAR::raiseError("File $pofile doesn't exist."); + return File_Gettext::raiseError("File $pofile doesn't exist."); } include_once 'File/Gettext/PO.php'; $PO = &new File_Gettext_PO($pofile); - if (PEAR::isError($e = $PO->load())) { + if (true !== ($e = $PO->load())) { return $e; } $MO = &$PO->toMO(); - if (PEAR::isError($e = $MO->save($mofile))) { + if (true !== ($e = $MO->save($mofile))) { return $e; } unset($PO, $MO); @@ -124,7 +124,7 @@ /** * prepare * - * @static + * @note This method should be called statically. * @access protected * @return string * @param string $string @@ -146,7 +146,7 @@ /** * meta2array * - * @static + * @note This method should be called statically. * @access public * @return array * @param string $meta @@ -260,5 +260,20 @@ return $PO; } + /** + * Raise PEAR error + * + * @note This method should be called statically. + * @access protected + * @return object + * @param string $error + * @param int $code + */ + function raiseError($error = null, $code = null) + { + include_once 'PEAR.php'; + return PEAR::raiseError($error, $code); + } + } ?> \ No newline at end of file

« previous php.pear.cvs (#18968) next »