/** * Sets new encryption options * * @param string|array $options (Optional) Encryption options * @return 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 (Loader::isReadable('Zend/Filter/Encrypt/' . ucfirst($adapter) . '.php')) { $adapter = 'Zend\\Filter\\Encrypt\\' . ucfirst($adapter); } if (!class_exists($adapter)) { throw new Exception\DomainException(sprintf('%s expects a valid registry class name; received "%s", which did not resolve', __METHOD__, $adapter)); } $this->_adapter = new $adapter($options); if (!$this->_adapter instanceof Encrypt\EncryptionAlgorithmInterface) { throw new Exception\InvalidArgumentException("Encoding adapter '" . $adapter . "' does not implement Zend\\Filter\\Encrypt\\EncryptionAlgorithmInterface"); } return $this; }
public function setUp() { if (!class_exists('Archive_Tar')) { try { \Zend\Loader::loadClass('Archive_Tar'); } catch (\Zend\Loader\Exception $e) { $this->markTestSkipped('This filter needs PEARs Archive_Tar'); } } $files = array(dirname(__DIR__) . '/_files/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First/Second/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First/Second', dirname(__DIR__) . '/_files/_compress/Compress/First/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First', dirname(__DIR__) . '/_files/_compress/Compress/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress', dirname(__DIR__) . '/_files/_compress/zipextracted.txt', dirname(__DIR__) . '/_files/_compress', dirname(__DIR__) . '/_files/compressed.tar'); foreach ($files as $file) { if (file_exists($file)) { if (is_dir($file)) { rmdir($file); } else { unlink($file); } } } if (!file_exists(dirname(__DIR__) . '/_files/Compress/First/Second')) { mkdir(dirname(__DIR__) . '/_files/Compress/First/Second', 0777, true); file_put_contents(dirname(__DIR__) . '/_files/Compress/First/Second/zipextracted.txt', 'compress me'); file_put_contents(dirname(__DIR__) . '/_files/Compress/First/zipextracted.txt', 'compress me'); file_put_contents(dirname(__DIR__) . '/_files/Compress/zipextracted.txt', 'compress me'); } }
/** * Returns true if and only if the fileextension of $value is not included in the * set extension list * * @param string $value Real file to check for extension * @param array $file File data from \Zend\File\Transfer\Transfer * @return boolean */ public function isValid($value, $file = null) { if ($file === null) { $file = array('name' => basename($value)); } // Is file readable ? if (!Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } if ($file !== null) { $info['extension'] = substr($file['name'], strrpos($file['name'], '.') + 1); } else { $info = pathinfo($value); } $extensions = $this->getExtension(); if ($this->getCase() and !in_array($info['extension'], $extensions)) { return true; } else { if (!$this->getCase()) { $found = false; foreach ($extensions as $extension) { if (strtolower($extension) == strtolower($info['extension'])) { $found = true; } } if (!$found) { return true; } } } return $this->_throw($file, self::FALSE_EXTENSION); }
public function setAdapter($adapter) { if (is_string($adapter)) { $storageAdapterClass = 'Zend\\Tool\\Framework\\Client\\Storage\\' . ucfirst($adapter); \Zend\Loader::loadClass($storageAdapterClass); $adapter = new $storageAdapterClass(); } $this->_adapter = $adapter; }
/** * ZF-2017: Test bind use of the Zend_Db_Select class. */ public function testSelectQueryWithBinds() { $select = $this->_select()->where('product_id = :product_id')->bind(array(':product_id' => 1)); $sql = preg_replace('/\\s+/', ' ', $select->__toString()); $this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE (product_id = :product_id)', $sql); $stmt = $select->query(); \Zend\Loader::loadClass('Zend_Db_Statement_Static'); $this->assertInstanceOf('Zend_Db_Statement_Static', $stmt); }
/** * Returns true if the mimetype of the file does not matche the given ones. Also parts * of mimetypes can be checked. If you give for example "image" all image * mime types will not be accepted like "image/gif", "image/jpeg" and so on. * * @param string $value Real file to check for mimetype * @param array $file File data from \Zend\File\Transfer\Transfer * @return boolean */ public function isValid($value, $file = null) { if ($file === null) { $file = array( 'type' => null, 'name' => $value ); } // Is file readable ? if (!\Zend\Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } $mimefile = $this->getMagicFile(); if (class_exists('finfo', false)) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; if (!empty($mimefile)) { $mime = new \finfo($const, $mimefile); } else { $mime = new \finfo($const); } if (!empty($mime)) { $this->_type = $mime->file($value); } unset($mime); } if (empty($this->_type)) { if (function_exists('mime_content_type') && ini_get('mime_magic.magicfile')) { $this->_type = mime_content_type($value); } elseif ($this->_headerCheck) { $this->_type = $file['type']; } } if (empty($this->_type)) { return $this->_throw($file, self::NOT_DETECTED); } $mimetype = $this->getMimeType(true); if (in_array($this->_type, $mimetype)) { return $this->_throw($file, self::FALSE_TYPE); } $types = explode('/', $this->_type); $types = array_merge($types, explode('-', $this->_type)); foreach($mimetype as $mime) { if (in_array($mime, $types)) { return $this->_throw($file, self::FALSE_TYPE); } } return true; }
/** * Class constructor * * @param array $options (Optional) Options to set */ public function __construct($options = null) { if (!class_exists('Archive_Tar')) { try { \Zend\Loader::loadClass('Archive_Tar'); } catch (\Exception $e) { throw new Exception\ExtensionNotLoadedException('This filter needs PEARs Archive_Tar', 0, $e); } } parent::__construct($options); }
public function addContextClass($contextClass) { if (!class_exists($contextClass)) { \Zend\Loader::loadClass($contextClass); } $reflectionContextClass = new \ReflectionClass($contextClass); if ($reflectionContextClass->isInstantiable()) { $context = new $contextClass(); return $this->addContext($context); } return $this; }
/** * _getFiles() * * @return array Array of files to load */ protected function _getFiles() { $paths = \Zend\Loader::explodeIncludePath(); // used for checking similarly named files $relativeItems = array(); $files = array(); $isZendTraversed = false; foreach ($paths as $path) { // default patterns to use $filterDenyDirectoryPattern = '.*(/|\\\\).svn'; $filterAcceptFilePattern = '.*(?:Manifest|Provider)\\.php$'; if (!file_exists($path) || $path[0] == '.') { continue; } $realIncludePath = realpath($path); // ensure that we only traverse a single version of Zend Framework on all include paths if (file_exists($realIncludePath . '/Zend/Tool/Framework/Loader/IncludePathLoader.php')) { if ($isZendTraversed === false) { $isZendTraversed = true; } else { // use the deny directory pattern that includes the path to 'Zend', it will not be accepted $filterDenyDirectoryPattern = '.*((/|\\\\).svn|' . preg_quote($realIncludePath . DIRECTORY_SEPARATOR) . 'Zend)'; } } // create recursive directory iterator $rdi = new \RecursiveDirectoryIterator($path); // pass in the RecursiveDirectoryIterator & the patterns $filter = new RecursiveFilterIterator($rdi, $filterDenyDirectoryPattern, $filterAcceptFilePattern); // build the rii with the filter $iterator = new \RecursiveIteratorIterator($filter); // iterate over the accepted items foreach ($iterator as $item) { $file = (string) $item; if ($this->_fileIsBlacklisted($file)) { continue; } // ensure that the same named file from separate include_paths is not loaded $relativeItem = preg_replace('#^' . preg_quote($realIncludePath . DIRECTORY_SEPARATOR, '#') . '#', '', $item->getRealPath()); // no links allowed here for now if ($item->isLink()) { continue; } // no items that are relavitely the same are allowed if (in_array($relativeItem, $relativeItems)) { continue; } $relativeItems[] = $relativeItem; $files[] = $item->getRealPath(); } } return $files; }
protected function _getTable($tableClass, $options = array()) { if (is_array($options) && !isset($options['db'])) { $options['db'] = $this->_db; } if (!class_exists($tableClass)) { $this->_useMyIncludePath(); \Zend\Loader::loadClass($tableClass); $this->_restoreIncludePath(); } $table = new $tableClass($options); return $table; }
/** * Sets a new adapter * * @param string $adapter Adapter to use * @param boolean $direction OPTIONAL False means Download, true means upload * @param array $options OPTIONAL Options to set for this adapter * @throws \Zend\File\Transfer\Exception */ public function setAdapter($adapter, $direction = false, $options = array()) { if (\Zend\Loader::isReadable('Zend/File/Transfer/Adapter/' . ucfirst($adapter) . '.php')) { $adapter = 'Zend\\File\\Transfer\\Adapter\\' . ucfirst($adapter); } if (!class_exists($adapter)) { \Zend\Loader::loadClass($adapter); } $direction = (int) $direction; $this->_adapter[$direction] = new $adapter($options); if (!$this->_adapter[$direction] instanceof Adapter\AbstractAdapter) { throw new Transfer\Exception("Adapter " . $adapter . " does not extend Zend_File_Transfer_Adapter_Abstract"); } return $this; }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if the counted words are at least min and * not bigger than max (when max is not null). * * @param string $value Filename to check for word count * @param array $file File data from \Zend\File\Transfer\Transfer * @return boolean */ public function isValid($value, $file = null) { // Is file readable ? if (!\Zend\Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } $content = file_get_contents($value); $this->_count = str_word_count($content); if ($this->_max !== null && $this->_count > $this->_max) { return $this->_throw($file, self::TOO_MUCH); } if ($this->_min !== null && $this->_count < $this->_min) { return $this->_throw($file, self::TOO_LESS); } return true; }
/** * Converts a DOMElement object into the specific class * * @throws \Zend\InfoCard\XML\Exception * @param DOMElement $e The DOMElement object to convert * @param string $classname The name of the class to convert it to (must inhert from \Zend\InfoCard\XML\Element) * @return \Zend\InfoCard\XML\Element a Xml Element object from the DOM element */ public static function convertToObject(\DOMElement $e, $classname) { if (!class_exists($classname)) { \Zend\Loader::loadClass($classname); } if (!is_subclass_of($classname, 'Zend\\InfoCard\\XML\\Element')) { throw new Exception\InvalidArgumentException("DOM element must be converted to an instance of Zend_InfoCard_Xml_Element"); } $sxe = simplexml_import_dom($e, $classname); if (!$sxe instanceof Element) { // Since we just checked to see if this was a subclass of Zend_infoCard_Xml_Element this shoudl never fail // @codeCoverageIgnoreStart throw new Exception\RuntimeException("Failed to convert between DOM and SimpleXML"); // @codeCoverageIgnoreEnd } return $sxe; }
/** * Returns true if the mimetype of the file does not matche the given ones. Also parts * of mimetypes can be checked. If you give for example "image" all image * mime types will not be accepted like "image/gif", "image/jpeg" and so on. * * @param string $value Real file to check for mimetype * @param array $file File data from \Zend\File\Transfer\Transfer * @return boolean */ public function isValid($value, $file = null) { if ($file === null) { $file = array('type' => null, 'name' => $value); } // Is file readable ? if (!Loader::isReadable($value)) { return $this->createError($file, self::NOT_READABLE); } $mimefile = $this->getMagicFile(); if (class_exists('finfo', false)) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; if (!$this->isMagicFileDisabled() && (!empty($mimefile) && empty($this->finfo))) { $this->finfo = finfo_open($const, $mimefile); } if (empty($this->finfo)) { $this->finfo = finfo_open($const); } $this->type = null; if (!empty($this->finfo)) { $this->type = finfo_file($this->finfo, $value); } } if (empty($this->type) && (function_exists('mime_content_type') && ini_get('mime_magic.magicfile'))) { $this->type = mime_content_type($value); } if (empty($this->type) && $this->getHeaderCheck()) { $this->type = $file['type']; } if (empty($this->type)) { return $this->createError($file, self::NOT_DETECTED); } $mimetype = $this->getMimeType(true); if (in_array($this->type, $mimetype)) { return $this->createError($file, self::FALSE_TYPE); } $types = explode('/', $this->type); $types = array_merge($types, explode('-', $this->type)); $types = array_merge($types, explode(';', $this->type)); foreach ($mimetype as $mime) { if (in_array($mime, $types)) { return $this->createError($file, self::FALSE_TYPE); } } return true; }
/** * Sets a new barcode adapter * * @param string|\Zend\Validator\Barcode\Adapter $adapter Barcode adapter to use * @param array $options Options for this adapter * @return Zend\Validator\Barcode * @throws \Zend\Validator\Exception */ public function setAdapter($adapter, $options = null) { if (is_string($adapter)) { $adapter = ucfirst(strtolower($adapter)); $adapter = 'Zend\\Validator\\Barcode\\' . $adapter; if (\Zend\Loader::isReadable('Zend/Validator/Barcode/' . $adapter . '.php')) { $adapter = 'Zend\\Validator\\Barcode\\' . $adapter; } if (!class_exists($adapter)) { throw new Exception\InvalidArgumentException('Barcode adapter matching "' . $adapter . '" not found'); } $this->options['adapter'] = new $adapter($options); } if (!$this->options['adapter'] instanceof Barcode\AdapterInterface) { throw new Exception\InvalidArgumentException("Adapter " . $adapter . " does not implement Zend\\Validate\\Barcode\\AdapterInterface"); } return $this; }
/** * Returns true if and only if the counted words are at least min and * not bigger than max (when max is not null). * * @param string $value Filename to check for word count * @param array $file File data from \Zend\File\Transfer\Transfer * @return boolean */ public function isValid($value, $file = null) { if ($file === null) { $file = array('name' => basename($value)); } // Is file readable ? if (!Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } $content = file_get_contents($value); $this->_count = str_word_count($content); if ($this->getMax() !== null && $this->_count > $this->getMax()) { return $this->_throw($file, self::TOO_MUCH); } if ($this->getMin() !== null && $this->_count < $this->getMin()) { return $this->_throw($file, self::TOO_LESS); } return true; }
/** * Create XML definition on an AMF service class * * @param string $serviceClass Service class name * @param array $options invocation options * @return string XML with service class introspection */ public function introspect($serviceClass, $options = array()) { $this->_options = $options; if (strpbrk($serviceClass, '\\/<>')) { return $this->_returnError('Invalid service name'); } // Transform com.foo.Bar into com\foo\Bar $serviceClass = str_replace('.', '\\', $serviceClass); // Introspect! if (!class_exists($serviceClass)) { \Zend\Loader::loadClass($serviceClass, $this->_getServicePath()); } $serv = $this->_xml->createElement('service-description'); $serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008'); $this->_types = $this->_xml->createElement('types'); $this->_ops = $this->_xml->createElement('operations'); $r = \Zend\Server\Reflection::reflectClass($serviceClass); $this->_addService($r, $this->_ops); $serv->appendChild($this->_types); $serv->appendChild($this->_ops); $this->_xml->appendChild($serv); return $this->_xml->saveXML(); }
/** * Returns the current adapter, instantiating it if necessary * * @return string */ public function getAdapter() { if ($this->_adapter instanceof Compress\CompressionAlgorithm) { return $this->_adapter; } $adapter = $this->_adapter; $options = $this->getAdapterOptions(); if (!class_exists($adapter)) { if (\Zend\Loader::isReadable('Zend/Filter/Compress/' . ucfirst($adapter) . '.php')) { $adapter = 'Zend\\Filter\\Compress\\' . ucfirst($adapter); } \Zend\Loader::loadClass($adapter); } $this->_adapter = new $adapter($options); if (!$this->_adapter instanceof Compress\CompressionAlgorithm) { throw new Exception\InvalidArgumentException("Compression adapter '" . $adapter . "' does not implement Zend\\Filter\\Compress\\CompressionAlgorithm"); } return $this->_adapter; }
/** * Returns an SQL statement for preparation. * * @param string $sql The SQL statement with placeholders. * @return \Zend\DB\Statement\Oracle\Oracle */ public function prepare($sql) { $this->_connect(); $stmtClass = $this->_defaultStmtClass; if (!class_exists($stmtClass)) { \Zend\Loader::loadClass($stmtClass); } $stmt = new $stmtClass($this, $sql); if ($stmt instanceof DB\Statement\Oracle\Oracle) { $stmt->setLobAsString($this->getLobAsString()); } $stmt->setFetchMode($this->_fetchMode); return $stmt; }
/** * Returns true if and only if the filesize of $value is at least min and * not bigger than max (when max is not null). * * @param string $value Real file to check for size * @param array $file File data from \Zend\File\Transfer\Transfer * @return boolean */ public function isValid($value, $file = null) { // Is file readable ? if (!\Zend\Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } // limited to 4GB files $size = sprintf("%u", @filesize($value)); $this->_size = $size; // Check to see if it's smaller than min size $min = $this->getMin(true); $max = $this->getMax(true); if (($min !== null) && ($size < $min)) { if ($this->useByteString()) { $this->_min = $this->_toByteString($min); $this->_size = $this->_toByteString($size); $this->_throw($file, self::TOO_SMALL); $this->_min = $min; $this->_size = $size; } else { $this->_throw($file, self::TOO_SMALL); } } // Check to see if it's larger than max size if (($max !== null) && ($max < $size)) { if ($this->useByteString()) { $this->_max = $this->_toByteString($max); $this->_size = $this->_toByteString($size); $this->_throw($file, self::TOO_BIG); $this->_max = $max; $this->_size = $size; } else { $this->_throw($file, self::TOO_BIG); } } if (count($this->_messages) > 0) { return false; } return true; }
/** * 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|\Zend\Config\Config $options * @return \Zend\Form\Form * @throws \Zend\Form\Exception\InvalidArgumentException if no valid elements provided */ public function addDisplayGroup(array $elements, $name, $options = null) { $group = array(); foreach ($elements as $element) { if (isset($this->_elements[$element])) { $add = $this->getElement($element); if (null !== $add) { unset($this->_order[$element]); $group[] = $add; } } } if (empty($group)) { throw new Exception\InvalidArgumentException('No valid elements specified for display group'); } $name = (string) $name; if (is_array($options)) { $options['elements'] = $group; } elseif ($options instanceof Config) { $options = $options->toArray(); $options['elements'] = $group; } else { $options = array('elements' => $group); } if (isset($options['displayGroupClass'])) { $class = $options['displayGroupClass']; unset($options['displayGroupClass']); } else { $class = $this->getDefaultDisplayGroupClass(); } if (!class_exists($class)) { 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; }
/** * Construct a filter or writer from config * * @param string $type 'writer' of 'filter' * @param mixed $config Config or Array * @param string $namespace * @throws Exception\InvalidArgumentException * @return object */ protected function _constructFromConfig($type, $config, $namespace) { if ($config instanceof Config) { $config = $config->toArray(); } if (!is_array($config) || empty($config)) { throw new Exception\InvalidArgumentException('Configuration must be an array or instance of Zend\\Config\\Config'); } $params = isset($config[$type . 'Params']) ? $config[$type . 'Params'] : array(); $className = $this->getClassName($config, $type, $namespace); if (!class_exists($className)) { \Zend\Loader::loadClass($className); } $reflection = new ReflectionClass($className); if (!$reflection->implementsInterface('Zend\\Log\\Factory')) { throw new Exception\InvalidArgumentException($className . ' does not implement Zend\\Log\\Factory and can not be constructed from config.'); } return $className::factory($params); }
/** * Initialize front controller plugin * * @return void */ protected function _initPlugin() { $pluginClass = $this->getPluginClass(); $front = Controller\Front::getInstance(); if (!$front->hasPlugin($pluginClass)) { if (!class_exists($pluginClass)) { \Zend\Loader::loadClass($pluginClass); } $front->registerPlugin(new $pluginClass($this), 99); } }
/** * Load a plugin via the name provided * * @param string $name * @param bool $throwExceptions Whether or not to throw exceptions if the * class is not resolved * @return string|false Class name of loaded class; false if $throwExceptions * if false and no class found * @throws \Zend\Loader\Exception if class not found */ public function load($name, $throwExceptions = true) { $name = $this->_formatName($name); if ($this->isLoaded($name)) { return $this->getClassName($name); } if ($this->_useStaticRegistry) { $registry = self::$_staticPrefixToPaths[$this->_useStaticRegistry]; } else { $registry = $this->_prefixToPaths; } $registry = array_reverse($registry, true); $found = false; $classFile = str_replace('\\', DIRECTORY_SEPARATOR, $name) . '.php'; $incFile = self::getIncludeFileCache(); foreach ($registry as $prefix => $paths) { $className = $prefix . $name; if (class_exists($className, true)) { $found = true; break; } $paths = array_reverse($paths, true); foreach ($paths as $path) { $loadFile = $path . $classFile; if (\Zend\Loader::isReadable($loadFile)) { include_once $loadFile; if (class_exists($className, false)) { if (null !== $incFile) { self::_appendIncFile($loadFile); } $found = true; break 2; } } } } if (!$found) { if (!$throwExceptions) { return false; } $message = "Plugin by name '{$name}' was not found in the registry; used paths:"; foreach ($registry as $prefix => $paths) { $message .= "\n{$prefix}: " . implode(PATH_SEPARATOR, $paths); } throw new Exception($message); } if ($this->_useStaticRegistry) { self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name] = $className; } else { $this->_loadedPlugins[$name] = $className; } return $className; }
/** * Defined by Zend_Validate_Interface * * Returns true if and only if the given file confirms the set hash * * @param string $value Filename to check for hash * @param array $file File data from \Zend\File\Transfer\Transfer * @return boolean */ public function isValid($value, $file = null) { // Is file readable ? if (!\Zend\Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } $hashes = array_unique(array_keys($this->_hash)); $filehash = hash_file('crc32', $value); if ($filehash === false) { return $this->_throw($file, self::NOT_DETECTED); } foreach ($hashes as $hash) { if ($filehash === $hash) { return true; } } return $this->_throw($file, self::DOES_NOT_MATCH); }
/** * Returns true if and only if the imagesize of $value is at least min and * not bigger than max * * @param string $value Real file to check for image size * @param array $file File data from \Zend\File\Transfer\Transfer * @return boolean */ public function isValid($value, $file = null) { if ($file === null) { $file = array('name' => basename($value)); } // Is file readable ? if (!Loader::isReadable($value)) { return $this->_throw($file, self::NOT_READABLE); } $size = @getimagesize($value); $this->setValue($file); if (empty($size) or $size[0] === 0 or $size[1] === 0) { return $this->_throw($file, self::NOT_DETECTED); } $this->_width = $size[0]; $this->_height = $size[1]; if ($this->_width < $this->getMinWidth()) { $this->_throw($file, self::WIDTH_TOO_SMALL); } if ($this->getMaxWidth() !== null and $this->getMaxWidth() < $this->_width) { $this->_throw($file, self::WIDTH_TOO_BIG); } if ($this->_height < $this->getMinHeight()) { $this->_throw($file, self::HEIGHT_TOO_SMALL); } if ($this->getMaxHeight() !== null and $this->getMaxHeight() < $this->_height) { $this->_throw($file, self::HEIGHT_TOO_BIG); } if (count($this->getMessages()) > 0) { return false; } return true; }
/** * Set the container class to use * * @param string $name * @return \Zend\View\Helper\Placeholder\Registry */ public function setContainerClass($name) { if (!class_exists($name)) { \Zend\Loader::loadClass($name); } if (!in_array('Zend\View\Helper\Placeholder\Container\AbstractContainer', class_parents($name))) { $e = new Container\Exception('Invalid Container class specified'); throw $e; } $this->_containerClass = $name; return $this; }
/** * Prepare a statement and return a PdoStatement-like object. * * @param string $sql SQL query * @return \Zend\Db\Statement\Mysqli */ public function prepare($sql) { $this->_connect(); if ($this->_stmt) { $this->_stmt->close(); } $stmtClass = $this->_defaultStmtClass; if (!class_exists($stmtClass)) { \Zend\Loader::loadClass($stmtClass); } $stmt = new $stmtClass($this, $sql); if ($stmt === \false) { return false; } $stmt->setFetchMode($this->_fetchMode); $this->_stmt = $stmt; return $stmt; }
/** * Returns true if and only if the given file confirms the set hash * * @param string $value Filename to check for hash * @param array $file File data from \Zend\File\Transfer\Transfer * @return boolean */ public function isValid($value, $file = null) { if ($file === null) { $file = array('name' => basename($value)); } // Is file readable ? if (!Loader::isReadable($value)) { return $this->_throw($file, self::NOT_FOUND); } $algos = array_unique(array_values($this->getHash())); $hashes = array_unique(array_keys($this->getHash())); foreach ($algos as $algorithm) { $filehash = hash_file($algorithm, $value); if ($filehash === false) { return $this->_throw($file, self::NOT_DETECTED); } foreach ($hashes as $hash) { if ($filehash === $hash) { return true; } } } return $this->_throw($file, self::DOES_NOT_MATCH); }
/** * Provides a magic factory method to instantiate new objects with * shorter syntax than would otherwise be required by the Zend Framework * naming conventions. For more information, see Zend_Gdata_App::__call(). * * This overrides the default behavior of __call() so that query classes * do not need to have their domain manually set when created with * a magic factory method. * * @see Zend_Gdata_App::__call() * @param string $method The method name being called * @param array $args The arguments passed to the call * @throws \Zend\GData\App\Exception */ public function __call($method, $args) { if (preg_match('/^new(\\w+Query)/', $method, $matches)) { $class = $matches[1]; $foundClassName = null; foreach ($this->_registeredPackages as $name) { try { // Autoloading disabled on next line for compatibility // with magic factories. See ZF-6660. if (!class_exists($name . '\\' . $class, false)) { @\Zend\Loader::loadClass($name . '\\' . $class); } $foundClassName = $name . '\\' . $class; break; } catch (\Zend\Exception $e) { // package wasn't here- continue searching } } if ($foundClassName != null) { $reflectionObj = new \ReflectionClass($foundClassName); // Prepend the domain to the query $args = array_merge(array($this->getDomain()), $args); return $reflectionObj->newInstanceArgs($args); } else { throw new App\Exception("Unable to find '{$class}' in registered packages"); } } else { return parent::__call($method, $args); } }