Changeset 121 for trunk/lib/ImageThumb.inc.php
- Timestamp:
- May 22, 2006 5:29:19 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/ImageThumb.inc.php
r120 r121 194 194 if (isset($index) && isset($this->image_specs[$index])) { 195 195 // Merge with previous. 196 $this->image_specs[$index] = array_merge($this->image_specs[$index], $spec); 196 $final_spec = array_merge($this->image_specs[$index], $spec); 197 $this->image_specs[$index] = $final_spec; 197 198 } else { 198 199 // Merge with defaults. 199 $this->image_specs[] = array_merge($this->default_image_specs, $spec); 200 } 200 $final_spec = array_merge($this->default_image_specs, $spec); 201 $this->image_specs[] = $final_spec; 202 } 203 204 return $final_spec; 201 205 } 202 206 … … 207 211 * @return bool true on success, false on failure. 208 212 */ 209 function processAll( )213 function processAll($runtime_specs=null) 210 214 { 211 215 // Ensure we have a source. … … 228 232 $return_val = 0; 229 233 foreach ($files as $file_name) { 230 $return_val += $this->processFile($file_name );234 $return_val += $this->processFile($file_name, $runtime_specs); 231 235 } 232 236 $this->_raiseMsg(sprintf(_("Resized %s images."), sizeof($files)), MSG_SUCCESS, __FILE__, __LINE__); … … 243 247 * @access public 244 248 * @param string $file_name Name of file with extention. 249 * @param array $runtime_specs Array of specifications that will override all configured specifications. 245 250 * @return bool true on success, false on failure. 246 251 */ 247 function processFile($file_name )252 function processFile($file_name, $runtime_specs=null) 248 253 { 249 254 // Source file determinted by provided file_name. … … 252 257 // Ensure we have a source. 253 258 if (sizeof($this->image_specs) < 1) { 254 App::logMsg(sprintf('Image specifications not set before processing.'), LOG_ERR, __FILE__, __LINE__); 255 return false; 259 if (is_array($runtime_specs)) { 260 $this->setSpec($runtime_specs, 0); 261 } else { 262 App::logMsg(sprintf('Image specifications not set before processing.'), LOG_ERR, __FILE__, __LINE__); 263 return false; 264 } 256 265 } 257 266 … … 265 274 if (!file_exists($source_file)) { 266 275 $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s was not found."), $file_name), MSG_ERR, __FILE__, __LINE__); 267 App::logMsg(sprintf('Source image not found: %s', $ file_name), LOG_ALERT, __FILE__, __LINE__);276 App::logMsg(sprintf('Source image not found: %s', $source_file), LOG_ALERT, __FILE__, __LINE__); 268 277 return false; 269 278 } … … 272 281 if (!is_readable($source_file)) { 273 282 $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s is not readable."), $file_name), MSG_ERR, __FILE__, __LINE__); 274 App::logMsg(sprintf('Source image not readable: %s', $ file_name), LOG_ALERT, __FILE__, __LINE__);283 App::logMsg(sprintf('Source image not readable: %s', $source_file), LOG_ALERT, __FILE__, __LINE__); 275 284 return false; 276 285 } … … 279 288 if (filesize($source_file) <= 0) { 280 289 $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s is zero bytes."), $file_name), MSG_ERR, __FILE__, __LINE__); 281 App::logMsg(sprintf('Source image is zero bytes: %s', $ file_name), LOG_ALERT, __FILE__, __LINE__);290 App::logMsg(sprintf('Source image is zero bytes: %s', $source_file), LOG_ALERT, __FILE__, __LINE__); 282 291 return false; 283 292 } … … 286 295 if (!$this->_validFileExtension($file_name)) { 287 296 $this->_raiseMsg(sprintf(_("Image resizing failed: source image %s not a valid type. It must have one of the following file name extensions: %s"), $file_name, join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__); 288 App::logMsg(sprintf('Image resizing failed: source image not of valid type: %s', $ file_name), LOG_ERR, __FILE__, __LINE__);297 App::logMsg(sprintf('Image resizing failed: source image not of valid type: %s', $source_file), LOG_ERR, __FILE__, __LINE__); 289 298 return false; 290 299 } … … 295 304 // To keep this script running even if user tries to stop browser. 296 305 ignore_user_abort(true); 297 if (!ini_get('safe_mode')) { 298 set_time_limit(300); 299 } 306 ini_set('max_execution_time', 300); 307 ini_set('max_input_time', 300); 300 308 301 309 // This remains zero until something goes wrong. 302 310 $return_val = 0; 303 311 304 foreach ($this->image_specs as $spec) { 312 foreach ($this->image_specs as $index => $spec) { 313 314 if (is_array($runtime_specs)) { 315 // Override with runtime specs. 316 $spec = $this->setSpec($runtime_specs, $index); 317 } 305 318 306 319 // Destination filename uses the extention defined by dest_file_extention. … … 558 571 } 559 572 } 560 $this->_raiseMsg(sprintf(_("The thumbnails for file <strong>%s</strong>have been deleted."), $file_name), MSG_SUCCESS, __FILE__, __LINE__);573 $this->_raiseMsg(sprintf(_("The thumbnails for file %s have been deleted."), $file_name), MSG_SUCCESS, __FILE__, __LINE__); 561 574 return 0 === $return_val; 562 575 } … … 582 595 return false; 583 596 } 584 $this->_raiseMsg(sprintf(_("The original file <strong>%s</strong>has been deleted."), $file_name), MSG_SUCCESS, __FILE__, __LINE__);597 $this->_raiseMsg(sprintf(_("The original file %s has been deleted."), $file_name), MSG_SUCCESS, __FILE__, __LINE__); 585 598 return true; 586 599 } … … 615 628 { 616 629 preg_match('/.*?\.(\w+)$/i', $file_name, $ext); 617 return in_array(strtolower($ext[1]), $this->getParam('valid_file_extensions'));630 return !empty($ext) && in_array(strtolower($ext[1]), $this->getParam('valid_file_extensions')); 618 631 } 619 632
Note: See TracChangeset
for help on using the changeset viewer.