public function load($source) { if ($source instanceof AeType) { $source = $source->getValue(); } if (is_array($source)) { if (!isset($source['tmp_name']) || !isset($source['name'])) { throw new AeImageException('Source value invalid', 400); } if (!file_exists($source['tmp_name'])) { throw new AeImageException('Source file not found', 404); } $type = strtolower(substr(strrchr($source['name'], '.'), 1)); $this->setImage($this->_getImage($type, $source['tmp_name'])); } else { if (is_string($source)) { if (!file_exists($source)) { throw new AeImageException('Source file not found', 404); } $this->setFile(AeFile::absolutePath($source)); } else { throw new AeImageException('Source value invalid', 400); } } return $this; }
/** * Save settings * * Save settings using file path provided. A file path can be an absolute * path, relative path to AnEngine root directory (the one with index.php in * it) or relative path to include path. File path must contain the target * file name including extension. * * If the file path is not passed, current {@link AeSettings_Driver_Xml::_filename} * property value will be used. If the latter is not set either, the file * will be created in the AnEngine root dir, with {@link * AeSettings_Driver_Xml::_section} plus .xml extension as its filename. * * Any multi-dimensional arrays, set via advanced <var>$name</var> usage of * the {@link AeSettings_Driver_Xml::set()} method, will be written as a * multi-dimensional array: * <code> $params->set('section.foo.bar', 'baz'); * $params->save('section.xml');</code> * * The above code will produce something like this in the xml file: * <code> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> * <settings path="section.xml" date="Sun, 29 Nov 2009 05:48:11 +0200" generator="AeSettings_Driver_Xml"> * <section> * <foo> * <bar type="string">baz</bar> * </foo> * </section> * </settings></code> * * @param string $data setting file path * * @return bool true on success, false otherwise */ public function save($data = null) { if ($data === null) { $data = $this->_filename === null ? $this->_section : $this->_filename; } // *** Check extension and add if required if (strpos($data, '.') === false) { $data .= '.' . self::EXTENSION; } if ($data === null || file_exists($data) && !is_writable($data)) { return false; } $data = AeFile::absolutePath($data); $xml = AeXml::element('settings'); $xml->setAttributes(array('path' => $data, 'date' => date('r'), 'generator' => $this->getClass())); if (count($this->_properties) > 0) { foreach ($this->_properties as $section => $settings) { $this->_valueToString($section, $settings, $xml); } } $xml->save($data); return $this; }