Пример #1
0
 /**
  * Include preview URLs in the resultset
  *
  * @param array $args
  * @return void
  */
 public function afterFetch(&$args)
 {
     $results =& $args[1];
     $scaler = new Garp_Image_Scaler();
     $templateUrl = (string) $scaler->getScaledUrl('%d', '%s');
     $templates = array_keys(Zend_Registry::get('config')->image->template->toArray());
     $iterator = new Garp_Db_Table_Rowset_Iterator($results, function ($result) use($templates, $templateUrl) {
         if (!isset($result->id)) {
             return;
         }
         $result->setVirtual('urls', array_reduce($templates, function ($acc, $cur) use($templateUrl, $result) {
             $acc[$cur] = sprintf($templateUrl, $cur, $result->id);
             return $acc;
         }, array()));
     });
     $iterator->walk();
 }
Пример #2
0
 protected function _loadIniDefaults()
 {
     if (!self::$_config) {
         $ini = Zend_Registry::get('config');
         self::$_config = $ini->image;
     }
     $this->params['bgcolor'] = self::$_config->bgcolor;
 }
Пример #3
0
 protected function _scaleDatabaseImage(Garp_Db_Table_Row $record, Garp_Image_File $file, Garp_Image_Scaler $scaler, $template, $overwrite)
 {
     $id = $record->id;
     $filename = $record->filename;
     if (!$file->exists($filename)) {
         Garp_Cli::errorOut('Warning: ' . $filename . ' is in the database, but not on disk!');
         return;
     }
     if ($file->exists($scaler->getScaledPath($id, $template, true)) && !$overwrite) {
         Garp_Cli::lineOut($template . '/' . $id . ' already exists, skipping');
         return;
     }
     try {
         $scaler->scaleAndStore($filename, $id, $template, $overwrite);
         Garp_Cli::lineOut('Scaled image #' . $id . ': ' . $filename);
         return true;
     } catch (Exception $e) {
         Garp_Cli::errorOut("Error scaling " . $filename . " (#" . $id . "): " . $e->getMessage());
     }
 }