Exemple #1
0
 /**
  * Class constructor
  *
  * @param array $options (Optional) Options to set
  */
 public function __construct($options = null)
 {
     if (!class_exists('Archive_Tar')) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
         try {
             IfwPsn_Zend_Loader::loadClass('Archive_Tar');
         } catch (IfwPsn_Vendor_Zend_Exception $e) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Filter/Exception.php';
             throw new IfwPsn_Vendor_Zend_Filter_Exception('This filter needs PEARs Archive_Tar', 0, $e);
         }
     }
     parent::__construct($options);
 }
Exemple #2
0
 /**
  * @param  mixed    $value
  * @param  string   $classBaseName
  * @param  array    $args          OPTIONAL
  * @param  mixed    $namespaces    OPTIONAL
  * @return boolean
  * @throws IfwPsn_Vendor_Zend_Validate_Exception
  */
 public static function is($value, $classBaseName, array $args = array(), $namespaces = array())
 {
     $namespaces = array_merge((array) $namespaces, self::$_defaultNamespaces, array('IfwPsn_Vendor_Zend_Validate'));
     $className = ucfirst($classBaseName);
     try {
         if (!class_exists($className, false)) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
             foreach ($namespaces as $namespace) {
                 $class = $namespace . '_' . $className;
                 $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
                 if (IfwPsn_Zend_Loader::isReadable($file)) {
                     IfwPsn_Zend_Loader::loadClass($class);
                     $className = $class;
                     break;
                 }
             }
         }
         $class = new ReflectionClass($className);
         if ($class->implementsInterface('IfwPsn_Vendor_Zend_Validate_Interface')) {
             if ($class->hasMethod('__construct')) {
                 $keys = array_keys($args);
                 $numeric = false;
                 foreach ($keys as $key) {
                     if (is_numeric($key)) {
                         $numeric = true;
                         break;
                     }
                 }
                 if ($numeric) {
                     $object = $class->newInstanceArgs($args);
                 } else {
                     $object = $class->newInstance($args);
                 }
             } else {
                 $object = $class->newInstance();
             }
             return $object->isValid($value);
         }
     } catch (IfwPsn_Vendor_Zend_Validate_Exception $ze) {
         // if there is an exception while validating throw it
         throw $ze;
     } catch (Exception $e) {
         // fallthrough and continue for missing validation classes
     }
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Validate/Exception.php';
     throw new IfwPsn_Vendor_Zend_Validate_Exception("Validate class not found from basename '{$classBaseName}'");
 }
Exemple #3
0
 /**
  * Factory for IfwPsn_Vendor_Zend_Navigation_Page classes
  *
  * A specific type to construct can be specified by specifying the key
  * 'type' in $options. If type is 'uri' or 'mvc', the type will be resolved
  * to IfwPsn_Vendor_Zend_Navigation_Page_Uri or IfwPsn_Vendor_Zend_Navigation_Page_Mvc. Any other value
  * for 'type' will be considered the full name of the class to construct.
  * A valid custom page class must extend IfwPsn_Vendor_Zend_Navigation_Page.
  *
  * If 'type' is not given, the type of page to construct will be determined
  * by the following rules:
  * - If $options contains either of the keys 'action', 'controller',
  *   'module', or 'route', a IfwPsn_Vendor_Zend_Navigation_Page_Mvc page will be created.
  * - If $options contains the key 'uri', a IfwPsn_Vendor_Zend_Navigation_Page_Uri page
  *   will be created.
  *
  * @param  array|IfwPsn_Vendor_Zend_Config $options  options used for creating page
  * @return IfwPsn_Vendor_Zend_Navigation_Page        a page instance
  * @throws IfwPsn_Vendor_Zend_Navigation_Exception   if $options is not array/IfwPsn_Vendor_Zend_Config
  * @throws IfwPsn_Vendor_Zend_Exception              if 'type' is specified and
  *                                     IfwPsn_Vendor_Zend_Loader is unable to load the
  *                                     class
  * @throws IfwPsn_Vendor_Zend_Navigation_Exception   if something goes wrong during
  *                                     instantiation of the page
  * @throws IfwPsn_Vendor_Zend_Navigation_Exception   if 'type' is given, and the specified
  *                                     type does not extend this class
  * @throws IfwPsn_Vendor_Zend_Navigation_Exception   if unable to determine which class
  *                                     to instantiate
  */
 public static function factory($options)
 {
     if ($options instanceof IfwPsn_Vendor_Zend_Config) {
         $options = $options->toArray();
     }
     if (!is_array($options)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Navigation/Exception.php';
         throw new IfwPsn_Vendor_Zend_Navigation_Exception('Invalid argument: $options must be an array or IfwPsn_Vendor_Zend_Config');
     }
     if (isset($options['type'])) {
         $type = $options['type'];
     } elseif (self::getDefaultPageType() != null) {
         $type = self::getDefaultPageType();
     }
     if (isset($type)) {
         if (is_string($type) && !empty($type)) {
             switch (strtolower($type)) {
                 case 'mvc':
                     $type = 'IfwPsn_Vendor_Zend_Navigation_Page_Mvc';
                     break;
                 case 'uri':
                     $type = 'IfwPsn_Vendor_Zend_Navigation_Page_Uri';
                     break;
             }
             if (!class_exists($type)) {
                 require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
                 @IfwPsn_Zend_Loader::loadClass($type);
             }
             $page = new $type($options);
             if (!$page instanceof IfwPsn_Vendor_Zend_Navigation_Page) {
                 require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Navigation/Exception.php';
                 throw new IfwPsn_Vendor_Zend_Navigation_Exception(sprintf('Invalid argument: Detected type "%s", which ' . 'is not an instance of IfwPsn_Vendor_Zend_Navigation_Page', $type));
             }
             return $page;
         }
     }
     $hasUri = isset($options['uri']);
     $hasMvc = isset($options['action']) || isset($options['controller']) || isset($options['module']) || isset($options['route']) || isset($options['params']);
     if ($hasMvc) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Navigation/Page/Mvc.php';
         return new IfwPsn_Vendor_Zend_Navigation_Page_Mvc($options);
     } elseif ($hasUri) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Navigation/Page/Uri.php';
         return new IfwPsn_Vendor_Zend_Navigation_Page_Uri($options);
     } else {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Navigation/Exception.php';
         $message = 'Invalid argument: Unable to determine class to instantiate';
         if (isset($options['label'])) {
             $message .= ' (Page label: ' . $options['label'] . ')';
         }
         throw new IfwPsn_Vendor_Zend_Navigation_Exception($message);
     }
 }
Exemple #4
0
 /**
  * Sets new encryption options
  *
  * @param  string|array $options (Optional) Encryption options
  * @return IfwPsn_Vendor_Zend_Filter_Encrypt
  */
 public function setAdapter($options = null)
 {
     if (is_string($options)) {
         $adapter = $options;
     } else {
         if (isset($options['adapter'])) {
             $adapter = $options['adapter'];
             unset($options['adapter']);
         } else {
             $adapter = 'Mcrypt';
         }
     }
     if (!is_array($options)) {
         $options = array();
     }
     if (IfwPsn_Zend_Loader::isReadable('IfwPsn/Vendor/Zend/Filter/Encrypt/' . ucfirst($adapter) . '.php')) {
         $adapter = 'IfwPsn_Vendor_Zend_Filter_Encrypt_' . ucfirst($adapter);
     }
     if (!class_exists($adapter)) {
         IfwPsn_Zend_Loader::loadClass($adapter);
     }
     $this->_adapter = new $adapter($options);
     if (!$this->_adapter instanceof IfwPsn_Vendor_Zend_Filter_Encrypt_Interface) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Filter/Exception.php';
         throw new IfwPsn_Vendor_Zend_Filter_Exception("Encoding adapter '" . $adapter . "' does not implement IfwPsn_Vendor_Zend_Filter_Encrypt_Interface");
     }
     return $this;
 }
Exemple #5
0
 /**
  * _processValidator() - internal function that is called in the existence of VALID metadata
  *
  * @throws IfwPsn_Vendor_Zend_Session_Exception
  * @return void
  */
 private static function _processValidators()
 {
     foreach ($_SESSION['__ZF']['VALID'] as $validator_name => $valid_data) {
         if (!class_exists($validator_name)) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
             IfwPsn_Zend_Loader::loadClass($validator_name);
         }
         $validator = new $validator_name();
         if ($validator->validate() === false) {
             /** @see IfwPsn_Vendor_Zend_Session_Exception */
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Session/Exception.php';
             throw new IfwPsn_Vendor_Zend_Session_Exception("This session is not valid according to {$validator_name}.");
         }
     }
 }
Exemple #6
0
 /**
  * Load the connection adapter
  *
  * While this method is not called more than one for a client, it is
  * seperated from ->request() to preserve logic and readability
  *
  * @param IfwPsn_Vendor_Zend_Http_Client_Adapter_Interface|string $adapter
  * @return null
  * @throws IfwPsn_Vendor_Zend_Http_Client_Exception
  */
 public function setAdapter($adapter)
 {
     if (is_string($adapter)) {
         try {
             IfwPsn_Zend_Loader::loadClass($adapter);
         } catch (IfwPsn_Vendor_Zend_Exception $e) {
             /** @see IfwPsn_Vendor_Zend_Http_Client_Exception */
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Http/Client/Exception.php';
             throw new IfwPsn_Vendor_Zend_Http_Client_Exception("Unable to load adapter '{$adapter}': {$e->getMessage()}", 0, $e);
         }
         $adapter = new $adapter();
     }
     if (!$adapter instanceof IfwPsn_Vendor_Zend_Http_Client_Adapter_Interface) {
         /** @see IfwPsn_Vendor_Zend_Http_Client_Exception */
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Http/Client/Exception.php';
         throw new IfwPsn_Vendor_Zend_Http_Client_Exception('Passed adapter is not a HTTP connection adapter');
     }
     $this->adapter = $adapter;
     $config = $this->config;
     unset($config['adapter']);
     $this->adapter->setConfig($config);
 }
Exemple #7
0
 /**
  * Get a route frm a config instance
  *
  * @param  IfwPsn_Vendor_Zend_Config $info
  * @return IfwPsn_Vendor_Zend_Controller_Router_Route_Interface
  */
 protected function _getRouteFromConfig(IfwPsn_Vendor_Zend_Config $info)
 {
     $class = isset($info->type) ? $info->type : 'IfwPsn_Vendor_Zend_Controller_Router_Route';
     if (!class_exists($class)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
         IfwPsn_Zend_Loader::loadClass($class);
     }
     $route = call_user_func(array($class, 'getInstance'), $info);
     if (isset($info->abstract) && $info->abstract && method_exists($route, 'isAbstract')) {
         $route->isAbstract(true);
     }
     return $route;
 }
Exemple #8
0
 /**
  * Set plugin loader
  *
  * @param  string $type Type of plugin loader; one of 'storage', (?)
  * @param  string|IfwPsn_Vendor_Zend_Loader_PluginLoader $loader
  * @return IfwPsn_Vendor_Zend_Http_UserAgent
  */
 public function setPluginLoader($type, $loader)
 {
     $type = $this->_validateLoaderType($type);
     if (is_string($loader)) {
         if (!class_exists($loader)) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
             IfwPsn_Zend_Loader::loadClass($loader);
         }
         $loader = new $loader();
     } elseif (!is_object($loader)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Http/UserAgent/Exception.php';
         throw new IfwPsn_Vendor_Zend_Http_UserAgent_Exception(sprintf('Expected a plugin loader class or object; received %s', gettype($loader)));
     }
     if (!$loader instanceof IfwPsn_Vendor_Zend_Loader_PluginLoader) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Http/UserAgent/Exception.php';
         throw new IfwPsn_Vendor_Zend_Http_UserAgent_Exception(sprintf('Expected an object extending IfwPsn_Vendor_Zend_Loader_PluginLoader; received %s', get_class($loader)));
     }
     $basePrefix = 'IfwPsn_Vendor_Zend_Http_UserAgent_';
     $basePath = IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Http/UserAgent/';
     switch ($type) {
         case 'storage':
             $prefix = $basePrefix . 'Storage';
             $path = $basePath . 'Storage';
             break;
         case 'device':
             $prefix = $basePrefix;
             $path = $basePath;
             break;
     }
     $loader->addPrefixPath($prefix, $path);
     $this->_loaders[$type] = $loader;
     return $this;
 }
Exemple #9
0
 /**
  * Set the class name to use for the default registry instance.
  * Does not affect the currently initialized instance, it only applies
  * for the next time you instantiate.
  *
  * @param string $registryClassName
  * @return void
  * @throws IfwPsn_Vendor_Zend_Exception if the registry is initialized or if the
  *   class name is not valid.
  */
 public static function setClassName($registryClassName = 'IfwPsn_Vendor_Zend_Registry')
 {
     if (self::$_registry !== null) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Exception.php';
         throw new IfwPsn_Vendor_Zend_Exception('Registry is already initialized');
     }
     if (!is_string($registryClassName)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Exception.php';
         throw new IfwPsn_Vendor_Zend_Exception("Argument is not a class name");
     }
     /**
      * @see IfwPsn_Vendor_Zend_Loader
      */
     if (!class_exists($registryClassName)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
         IfwPsn_Zend_Loader::loadClass($registryClassName);
     }
     self::$_registryClassName = $registryClassName;
 }
Exemple #10
0
 /**
  * Returns a value filtered through a specified filter class, without requiring separate
  * instantiation of the filter object.
  *
  * The first argument of this method is a data input value, that you would have filtered.
  * The second argument is a string, which corresponds to the basename of the filter class,
  * relative to the IfwPsn_Vendor_Zend_Filter namespace. This method automatically loads the class,
  * creates an instance, and applies the filter() method to the data input. You can also pass
  * an array of constructor arguments, if they are needed for the filter class.
  *
  * @param  mixed        $value
  * @param  string       $classBaseName
  * @param  array        $args          OPTIONAL
  * @param  array|string $namespaces    OPTIONAL
  * @return mixed
  * @throws IfwPsn_Vendor_Zend_Filter_Exception
  */
 public static function filterStatic($value, $classBaseName, array $args = array(), $namespaces = array())
 {
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
     $namespaces = array_merge((array) $namespaces, self::$_defaultNamespaces, array('IfwPsn_Vendor_Zend_Filter'));
     foreach ($namespaces as $namespace) {
         $className = $namespace . '_' . ucfirst($classBaseName);
         if (!class_exists($className, false)) {
             try {
                 $file = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
                 if (IfwPsn_Zend_Loader::isReadable($file)) {
                     IfwPsn_Zend_Loader::loadClass($className);
                 } else {
                     continue;
                 }
             } catch (IfwPsn_Vendor_Zend_Exception $ze) {
                 continue;
             }
         }
         $class = new ReflectionClass($className);
         if ($class->implementsInterface('IfwPsn_Vendor_Zend_Filter_Interface')) {
             if ($class->hasMethod('__construct')) {
                 $object = $class->newInstanceArgs($args);
             } else {
                 $object = $class->newInstance();
             }
             return $object->filter($value);
         }
     }
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Filter/Exception.php';
     throw new IfwPsn_Vendor_Zend_Filter_Exception("Filter class not found from basename '{$classBaseName}'");
 }
Exemple #11
0
 /**
  * Create a new IfwPsn_Vendor_Zend_Uri object for a URI.  If building a new URI, then $uri should contain
  * only the scheme (http, ftp, etc).  Otherwise, supply $uri with the complete URI.
  *
  * @param  string $uri       The URI form which a IfwPsn_Vendor_Zend_Uri instance is created
  * @param  string $className The name of the class to use in order to manipulate URI
  * @throws IfwPsn_Vendor_Zend_Uri_Exception When an empty string was supplied for the scheme
  * @throws IfwPsn_Vendor_Zend_Uri_Exception When an illegal scheme is supplied
  * @throws IfwPsn_Vendor_Zend_Uri_Exception When the scheme is not supported
  * @throws IfwPsn_Vendor_Zend_Uri_Exception When $className doesn't exist or doesn't implements IfwPsn_Vendor_Zend_Uri
  * @return IfwPsn_Vendor_Zend_Uri
  * @link   http://www.faqs.org/rfcs/rfc2396.html
  */
 public static function factory($uri = 'http', $className = null)
 {
     // Separate the scheme from the scheme-specific parts
     $uri = explode(':', $uri, 2);
     $scheme = strtolower($uri[0]);
     $schemeSpecific = isset($uri[1]) === true ? $uri[1] : '';
     if (strlen($scheme) === 0) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Uri/Exception.php';
         throw new IfwPsn_Vendor_Zend_Uri_Exception('An empty string was supplied for the scheme');
     }
     // Security check: $scheme is used to load a class file, so only alphanumerics are allowed.
     if (ctype_alnum($scheme) === false) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Uri/Exception.php';
         throw new IfwPsn_Vendor_Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted');
     }
     if ($className === null) {
         /**
          * Create a new IfwPsn_Vendor_Zend_Uri object for the $uri. If a subclass of IfwPsn_Vendor_Zend_Uri exists for the
          * scheme, return an instance of that class. Otherwise, a IfwPsn_Vendor_Zend_Uri_Exception is thrown.
          */
         switch ($scheme) {
             case 'http':
                 // Break intentionally omitted
             // Break intentionally omitted
             case 'https':
                 $className = 'IfwPsn_Vendor_Zend_Uri_Http';
                 break;
             case 'mailto':
                 // TODO
             // TODO
             default:
                 require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Uri/Exception.php';
                 throw new IfwPsn_Vendor_Zend_Uri_Exception("Scheme \"{$scheme}\" is not supported");
                 break;
         }
     }
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
     try {
         IfwPsn_Zend_Loader::loadClass($className);
     } catch (Exception $e) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Uri/Exception.php';
         throw new IfwPsn_Vendor_Zend_Uri_Exception("\"{$className}\" not found");
     }
     $schemeHandler = new $className($scheme, $schemeSpecific);
     if (!$schemeHandler instanceof IfwPsn_Vendor_Zend_Uri) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Uri/Exception.php';
         throw new IfwPsn_Vendor_Zend_Uri_Exception("\"{$className}\" is not an instance of IfwPsn_Vendor_Zend_Uri");
     }
     return $schemeHandler;
 }
Exemple #12
0
 /**
  * Sets a new adapter
  *
  * @param  array|IfwPsn_Vendor_Zend_Config $options Options to use
  * @throws IfwPsn_Vendor_Zend_Translate_Exception
  */
 public function setAdapter($options = array())
 {
     if ($options instanceof IfwPsn_Vendor_Zend_Config) {
         $options = $options->toArray();
     } else {
         if (func_num_args() > 1) {
             $args = func_get_args();
             $options = array();
             $options['adapter'] = array_shift($args);
             if (!empty($args)) {
                 $options['content'] = array_shift($args);
             }
             if (!empty($args)) {
                 $options['locale'] = array_shift($args);
             }
             if (!empty($args)) {
                 $opt = array_shift($args);
                 $options = array_merge($opt, $options);
             }
         } else {
             if (!is_array($options)) {
                 $options = array('adapter' => $options);
             }
         }
     }
     if (IfwPsn_Zend_Loader::isReadable('IfwPsn/Vendor/Zend/Translate/Adapter/' . ucfirst($options['adapter']) . '.php')) {
         $options['adapter'] = 'IfwPsn_Vendor_Zend_Translate_Adapter_' . ucfirst($options['adapter']);
     }
     if (!class_exists($options['adapter'])) {
         IfwPsn_Zend_Loader::loadClass($options['adapter']);
     }
     if (array_key_exists('cache', $options)) {
         IfwPsn_Vendor_Zend_Translate_Adapter::setCache($options['cache']);
     }
     $adapter = $options['adapter'];
     unset($options['adapter']);
     $this->_adapter = new $adapter($options);
     if (!$this->_adapter instanceof IfwPsn_Vendor_Zend_Translate_Adapter) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Translate/Exception.php';
         throw new IfwPsn_Vendor_Zend_Translate_Exception("Adapter " . $adapter . " does not extend IfwPsn_Vendor_Zend_Translate_Adapter");
     }
 }
Exemple #13
0
 /**
  * Returns the current adapter, instantiating it if necessary
  *
  * @return string
  */
 public function getAdapter()
 {
     if ($this->_adapter instanceof IfwPsn_Vendor_Zend_Filter_Compress_CompressInterface) {
         return $this->_adapter;
     }
     $adapter = $this->_adapter;
     $options = $this->getAdapterOptions();
     if (!class_exists($adapter)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
         if (IfwPsn_Zend_Loader::isReadable('IfwPsn/Vendor/Zend/Filter/Compress/' . ucfirst($adapter) . '.php')) {
             $adapter = 'IfwPsn_Vendor_Zend_Filter_Compress_' . ucfirst($adapter);
         }
         IfwPsn_Zend_Loader::loadClass($adapter);
     }
     $this->_adapter = new $adapter($options);
     if (!$this->_adapter instanceof IfwPsn_Vendor_Zend_Filter_Compress_CompressInterface) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Filter/Exception.php';
         throw new IfwPsn_Vendor_Zend_Filter_Exception("Compression adapter '" . $adapter . "' does not implement IfwPsn_Vendor_Zend_Filter_Compress_CompressInterface");
     }
     return $this->_adapter;
 }
Exemple #14
0
 /**
  * Sets a new barcode adapter
  *
  * @param  string|IfwPsn_Vendor_Zend_Validate_Barcode $adapter Barcode adapter to use
  * @param  array  $options Options for this adapter
  * @return void
  * @throws IfwPsn_Vendor_Zend_Validate_Exception
  */
 public function setAdapter($adapter, $options = null)
 {
     $adapter = ucfirst(strtolower($adapter));
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
     if (IfwPsn_Zend_Loader::isReadable('IfwPsn/Vendor/Zend/Validate/Barcode/' . $adapter . '.php')) {
         $adapter = 'IfwPsn_Vendor_Zend_Validate_Barcode_' . $adapter;
     }
     if (!class_exists($adapter)) {
         IfwPsn_Zend_Loader::loadClass($adapter);
     }
     $this->_adapter = new $adapter($options);
     if (!$this->_adapter instanceof IfwPsn_Vendor_Zend_Validate_Barcode_AdapterInterface) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Validate/Exception.php';
         throw new IfwPsn_Vendor_Zend_Validate_Exception("Adapter " . $adapter . " does not implement IfwPsn_Vendor_Zend_Validate_Barcode_AdapterInterface");
     }
     return $this;
 }
Exemple #15
0
 /**
  * Add a display group
  *
  * Groups named elements for display purposes.
  *
  * If a referenced element does not yet exist in the form, it is omitted.
  *
  * @param  array $elements
  * @param  string $name
  * @param  array|IfwPsn_Vendor_Zend_Config $options
  * @return IfwPsn_Vendor_Zend_Form
  * @throws IfwPsn_Vendor_Zend_Form_Exception if no valid elements provided
  */
 public function addDisplayGroup(array $elements, $name, $options = null)
 {
     $group = array();
     foreach ($elements as $element) {
         if ($element instanceof IfwPsn_Vendor_Zend_Form_Element) {
             $elementName = $element->getName();
             if (!isset($this->_elements[$elementName])) {
                 $this->addElement($element);
             }
             $element = $elementName;
         }
         if (isset($this->_elements[$element])) {
             $add = $this->getElement($element);
             if (null !== $add) {
                 $group[] = $add;
             }
         }
     }
     if (empty($group)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Form/Exception.php';
         throw new IfwPsn_Vendor_Zend_Form_Exception('No valid elements specified for display group');
     }
     $name = (string) $name;
     if (is_array($options)) {
         $options['form'] = $this;
         $options['elements'] = $group;
     } elseif ($options instanceof IfwPsn_Vendor_Zend_Config) {
         $options = $options->toArray();
         $options['form'] = $this;
         $options['elements'] = $group;
     } else {
         $options = array('form' => $this, 'elements' => $group);
     }
     if (isset($options['displayGroupClass'])) {
         $class = $options['displayGroupClass'];
         unset($options['displayGroupClass']);
     } else {
         $class = $this->getDefaultDisplayGroupClass();
     }
     if (!class_exists($class)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
         IfwPsn_Zend_Loader::loadClass($class);
     }
     $this->_displayGroups[$name] = new $class($name, $this->getPluginLoader(self::DECORATOR), $options);
     if (!empty($this->_displayGroupPrefixPaths)) {
         $this->_displayGroups[$name]->addPrefixPaths($this->_displayGroupPrefixPaths);
     }
     $this->_order[$name] = $this->_displayGroups[$name]->getOrder();
     $this->_orderUpdated = true;
     return $this;
 }
Exemple #16
0
 /**
  * Set the container class to use
  *
  * @param  string $name
  * @return IfwPsn_Vendor_Zend_View_Helper_Placeholder_Registry
  */
 public function setContainerClass($name)
 {
     if (!class_exists($name)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
         IfwPsn_Zend_Loader::loadClass($name);
     }
     $reflection = new ReflectionClass($name);
     if (!$reflection->isSubclassOf(new ReflectionClass('IfwPsn_Vendor_Zend_View_Helper_Placeholder_Container_Abstract'))) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/View/Helper/Placeholder/Registry/Exception.php';
         $e = new IfwPsn_Vendor_Zend_View_Helper_Placeholder_Registry_Exception('Invalid Container class specified');
         $e->setView($this->view);
         throw $e;
     }
     $this->_containerClass = $name;
     return $this;
 }
Exemple #17
0
 /**
  * Construct a filter or writer from config
  *
  * @param string $type 'writer' of 'filter'
  * @param mixed $config IfwPsn_Vendor_Zend_Config or Array
  * @param string $namespace
  * @return object
  * @throws IfwPsn_Vendor_Zend_Log_Exception
  */
 protected function _constructFromConfig($type, $config, $namespace)
 {
     if ($config instanceof IfwPsn_Vendor_Zend_Config) {
         $config = $config->toArray();
     }
     if (!is_array($config) || empty($config)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Log/Exception.php';
         throw new IfwPsn_Vendor_Zend_Log_Exception('Configuration must be an array or instance of IfwPsn_Vendor_Zend_Config');
     }
     $params = isset($config[$type . 'Params']) ? $config[$type . 'Params'] : array();
     $className = $this->getClassName($config, $type, $namespace);
     if (!class_exists($className)) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
         IfwPsn_Zend_Loader::loadClass($className);
     }
     $reflection = new ReflectionClass($className);
     if (!$reflection->implementsInterface('IfwPsn_Vendor_Zend_Log_FactoryInterface')) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Log/Exception.php';
         throw new IfwPsn_Vendor_Zend_Log_Exception($className . ' does not implement IfwPsn_Vendor_Zend_Log_FactoryInterface and can not be constructed from config.');
     }
     return call_user_func(array($className, 'factory'), $params);
 }
Exemple #18
0
 /**
  * Set response class/object
  *
  * Set the response object.  The response is a container for action
  * responses and headers. Usage is optional.
  *
  * If a class name is provided, instantiates a response object.
  *
  * @param string|IfwPsn_Vendor_Zend_Controller_Response_Abstract $response
  * @throws IfwPsn_Vendor_Zend_Controller_Exception if invalid response class
  * @return IfwPsn_Vendor_Zend_Controller_Front
  */
 public function setResponse($response)
 {
     if (is_string($response)) {
         if (!class_exists($response)) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
             IfwPsn_Zend_Loader::loadClass($response);
         }
         $response = new $response();
     }
     if (!$response instanceof IfwPsn_Vendor_Zend_Controller_Response_Abstract) {
         require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Controller/Exception.php';
         throw new IfwPsn_Vendor_Zend_Controller_Exception('Invalid response class');
     }
     $this->_response = $response;
     return $this;
 }
Exemple #19
0
 /**
  * Initialize action helper
  *
  * @return void
  */
 protected function _initHelper()
 {
     $helperClass = $this->getHelperClass();
     require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Controller/Action/HelperBroker.php';
     if (!IfwPsn_Vendor_Zend_Controller_Action_HelperBroker::hasHelper('layout')) {
         if (!class_exists($helperClass)) {
             require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Zend/Loader.php';
             IfwPsn_Zend_Loader::loadClass($helperClass);
         }
         IfwPsn_Vendor_Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-90, new $helperClass($this));
     }
 }