/**
  *
  * @param array $params
  * @param string $posts
  */
 public function processRequest(array $params = null, $posts = null)
 {
     try {
         if (isset($posts['data']['current'])) {
             $this->setPath(self::ASSET_PATH . DS . str_replace('_', DS, $posts['data']['current']));
         }
         $filter = new Prepare();
         if ('php' !== Extension::get($posts['data']['filename'])) {
             $filename = $posts['data']['filename'] . '.php';
         } else {
             $filename = $posts['data']['filename'];
         }
         $this->setDestination($this->getPath() . DS . $filename);
         if (!is_file($this->getStorage()->getDocumentRoot() . DS . $this->getDestination())) {
             if (is_writable($this->getStorage()->getDocumentRoot() . DS . $this->getPath())) {
                 $this->setDestination($this->getStorage()->getDocumentRoot() . $this->getDestination());
                 $this->setFile($posts['data']['ident']);
                 $this->copy();
                 return array('success' => true);
             } else {
                 return array('error' => 'no_write_permissions');
             }
         } else {
             return array('warn' => 'file_exist');
         }
     } catch (\Exception $e) {
         return array('error' => $e->getMessage());
     }
 }
 /**
  * Prepare datas before save
  *
  * @see \ContentinumComponents\Mapper\Process::save()
  */
 public function save($datas, $entity = null, $stage = '', $id = null)
 {
     $filter = new Prepare();
     //
     $filename = $this->getStorage($this->getSl()->get('contentinum_files_storage_manager'))->getDocumentRoot() . DS . $this->entity->getCurrentPath();
     $filename .= DS . $filter->filter(Name::get($datas['name'])) . '.' . Extension::get($datas['name']);
     file_put_contents($filename, $datas['content']);
 }
 /**
  *
  * @param array $params
  * @param string $posts
  */
 public function processRequest(array $params = null, $posts = null)
 {
     try {
         if (isset($posts['current'])) {
             $medias = $this->getSl()->get('mcwork_media');
             $files = array();
             $dir = str_replace('_', DS, $posts['current']);
             foreach (scandir(CON_ROOT_PATH . '/public/medias/' . $dir) as $file) {
                 if ('.' != $file && '..' != $file && in_array(Extension::get($file), $this->imageExtensions)) {
                     if (isset($medias['/public/medias/' . $dir . '/' . $file])) {
                         $files['/medias/' . $dir . '/' . $file] = $medias['/public/medias/' . $dir . '/' . $file];
                     }
                 }
             }
             if (empty($files)) {
                 return array('error' => 'Keine Bilder in diesem Verzeichnis gefunden');
             } else {
                 return $files;
             }
         }
     } catch (\Exception $e) {
         return array('error' => $e->getMessage());
     }
 }
 /**
  *
  * @param string $newName
  * @param string $type
  */
 public function setNewName($newName, $type = 'file')
 {
     $this->newName = $newName;
     if ('file' == $type) {
         $this->ext = '.' . Extension::get($newName);
         $newName = Name::get($newName);
     }
     $this->validNewName = $this->filterFsNames($newName);
 }
 /**
  * Warpper for ContentinumComponents\File\Extension
  *
  * @param string $file
  * @return string
  */
 public function fileExtension($filename)
 {
     return \ContentinumComponents\File\Extension::get($filename);
 }