public function update(array $data, $where) { $currentFileRow = $this->fetchRow($where); if (null !== $currentFileRow->proxy_model) { $oldProxyTableClass = $currentFileRow->proxy_model; } foreach ($currentFileRow->duplicates as $duplicate) { $duplicate->delete(); } foreach ($this->_dependentProxies as $key => $dependentProxy) { $proxyTable = Centurion_Db::getSingletonByClassName($dependentProxy); $mimes = array_keys($proxyTable->getMimeTypes()); if (!in_array($data['mime'], $mimes)) { continue; } if (in_array($data['mime'], $mimes)) { $newProxyTableClass = $dependentProxy; break; } } if (!isset($data['sha1'])) { $data['sha1'] = sha1_file(Centurion_Config_Manager::get('media.uploads_dir') . DIRECTORY_SEPARATOR . $data['local_filename']); } if (isset($oldProxyTableClass) && $oldProxyTableClass != $newProxyTableClass) { $currentProxyRow = Centurion_Db::getRow($oldProxyTableClass, $currentFileRow->proxy_pk); if (null !== $currentProxyRow) { $data = array_merge($data, array('proxy_model' => null, 'proxy_pk' => null)); $currentProxyRow->delete(); } } if (null !== $newProxyTableClass) { $newProxyTable = Centurion_Db::getSingletonByClassName($newProxyTableClass); if (isset($oldProxyTableClass) && $oldProxyTableClass == $newProxyTableClass) { $pk = $newProxyTable->update($data, $newProxyTable->getAdapter()->quoteInto('id = ?', $currentFileRow->proxy_pk)); } else { $pk = $newProxyTable->insert($data); $data['proxy_model'] = $newProxyTableClass; } $data['proxy_pk'] = $pk; } if (array_key_exists(self::BELONG_TO, $data)) { list($model, $pk) = $this->_setupProxyBelong($data[self::BELONG_TO]); $data = array_merge($data, array('belong_model' => $model, 'belong_pk' => $pk)); unset($data[self::BELONG_TO]); } return parent::update($data, $where); }