public function deleteAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $json = new ZendT_Json_Result(); try { $filename = $this->getRequest()->getParam('filename'); $decode = $this->getRequest()->getParam('decode'); $files = explode(',', $filename); foreach ($files as $hashName) { if ($decode) { $file = base64_decode($hashName); if (file_exists($file)) { unlink($file); } } else { $file = ZendT_File::fromFilenameCrypt($hashName); $file->delete(); } } $id = $this->getRequest()->getParam('id'); if (!$id) { $id = 1; } $json->setResult(array('id' => $id)); } catch (Exception $Ex) { $json->setException($Ex); } echo $json->render(); }
/** * Retorna o valor no famato do banco de dados * * @return string */ public function getValueToDb() { if (strpos($this->_value, ZendT_File::ZENDT_FILE_PREFIX_FILENAME) !== false) { $file = ZendT_File::fromFilenameCrypt($this->_value); return $file->getContent(); } else { if (file_exists($this->_value)) { return file_get_contents($this->_value); } else { return $this->_value; } } }
/** * * @param type $value * @param type $options * @param type $locale */ public function set($value, $options = null, $locale = null) { if ($value && is_numeric($value)) { $this->_valueDb = $value; } else { if ($value instanceof ZendT_File) { $this->_value = $value; } else { if ($value !== null && $value) { $file = ZendT_File::fromFilenameCrypt($value); $this->_value = $file; } } } if (!is_array($this->_options)) { $this->_options = array(); } if (!is_array($options)) { $options = array(); } $this->_options = array_merge($this->_options, $options); $this->_locale = $locale; return $this; }