/** * Constructor. * * @see Horde_Exception::__construct() * * @param mixed $message The exception message, a PEAR_Error * object, or an Exception object. * @param integer $code A numeric error code. */ public function __construct($message = null, $code = null) { if (is_null($message)) { $message = Horde_Exception_Translation::t("Not Found"); } parent::__construct($message, $code); }
/** * Returns the plural translation of a message. * * @param string $singular The singular version to translate. * @param string $plural The plural version to translate. * @param integer $number The number that determines singular vs. plural. * * @return string The string translation, or the original string if no * translation exists. */ public static function ngettext($singular, $plural, $number) { self::$_domain = 'Horde_Exception'; self::$_directory = '/usr/share/php/data' == '@' . 'data_dir' . '@' ? __DIR__ . '/../../../locale' : '/usr/share/php/data/Horde_Exception/locale'; return parent::ngettext($singular, $plural, $number); }
/** * Return a cost object hash. * * @param string $id The cost object id. * * @return array The cost object hash. Keys differ depending on the * API queried, but should always contain: * - id: * - name: * * @throws Horde_ExceptionNotFound */ public static function getCostObjectByID($id) { static $cost_objects; if (strpos($id, ':') !== false) { list($app, $app_id) = explode(':', $id, 2); if (!isset($cost_objects[$app])) { $results = $GLOBALS['registry']->callByPackage($app, 'listCostObjects', array(array())); $cost_objects[$app] = $results; } foreach (array_keys($cost_objects[$app]) as $catkey) { foreach (array_keys($cost_objects[$app][$catkey]['objects']) as $objkey) { if ($cost_objects[$app][$catkey]['objects'][$objkey]['id'] == $app_id) { return $cost_objects[$app][$catkey]['objects'][$objkey]; } } } } throw new Horde_Exception_NotFound(sprintf('%s (%s)', Horde_Exception_Translation::t("Not Found"), $id)); }