Beispiel #1
0
 public function indexAction()
 {
     $ilchdate = new IlchDate();
     $mediaMapper = new MediaMapper();
     $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('media'), array('controller' => 'index', 'action' => 'index'))->add($this->getTranslator()->trans('import'), array('action' => 'index'));
     $directory = $this->getConfig()->get('media_uploadpath');
     $filetypes = $this->getConfig()->get('media_ext_img');
     $globMediaArray = glob($directory . "*.*");
     if ($this->getRequest()->getPost('save') === 'save') {
         foreach ($this->getRequest()->getPost('check_medias') as $media) {
             $upload = new \Ilch\Upload();
             $upload->setFile($media);
             $upload->setTypes($filetypes);
             $upload->setPath($directory);
             $upload->save();
             $model = new \Modules\Media\Models\Media();
             $model->setUrl($upload->getUrl());
             $model->setUrlThumb($upload->getUrlThumb());
             $model->setEnding($upload->getEnding());
             $model->setName($upload->getName());
             $model->setDatetime($ilchdate->toDb());
             $mediaMapper->save($model);
         }
         $this->addMessage('Success');
         $this->redirect(array('action' => 'index'));
     }
     $mediaListAll = $mediaMapper->getMediaListAll();
     $existsMediaArray = array();
     if (!empty($mediaListAll)) {
         foreach ($mediaListAll as $existsMedia) {
             $existsMediaArray[] = $directory . $existsMedia->getName() . '.' . $existsMedia->getEnding();
         }
     }
     $newMediaArray = array();
     foreach ($globMediaArray as $globMedia) {
         $upload = new \Ilch\Upload();
         $upload->setFile($globMedia);
         $existsUrl = $mediaMapper->getByWhere(array('url' => $directory . $upload->getName() . '.' . $upload->getEnding()));
         $existsUrlThumb = $mediaMapper->getByWhere(array('url_thumb' => $directory . $upload->getName() . '.' . $upload->getEnding()));
         if (!$existsUrl && !$existsUrlThumb) {
             $newMediaArray[] = $directory . $upload->getName() . '.' . $upload->getEnding();
         }
     }
     $this->getView()->set('media', array_diff($newMediaArray, $existsMediaArray));
     $this->getView()->set('media_ext_img', $this->getConfig()->get('media_ext_img'));
     $this->getView()->set('path', $directory);
 }
Beispiel #2
0
 public function uploadAction()
 {
     $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('media'), array('action' => 'index'))->add($this->getTranslator()->trans('mediaUpload'), array('action' => 'upload'));
     if (!is_writable(APPLICATION_PATH . '/../' . $this->getConfig()->get('media_uploadpath'))) {
         $this->addMessage('writableMedia', 'danger');
     }
     $ilchdate = new IlchDate();
     $mediaMapper = new MediaMapper();
     if ($this->getRequest()->isPost()) {
         $upload = new \Ilch\Upload();
         $upload->setFile($_FILES['upl']['name']);
         $upload->setTypes($this->getConfig()->get('media_ext_img'));
         $upload->setPath($this->getConfig()->get('media_uploadpath'));
         $upload->upload();
         $model = new \Modules\Media\Models\Media();
         $model->setUrl($upload->getUrl());
         $model->setUrlThumb($upload->getUrlThumb());
         $model->setEnding($upload->getEnding());
         $model->setName($upload->getName());
         $model->setDatetime($ilchdate->toDb());
         $mediaMapper->save($model);
     }
 }
Beispiel #3
0
 public function uploadGalleryAction()
 {
     $ilchdate = new IlchDate();
     $mediaMapper = new MediaMapper();
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('media'), array('action' => 'index'))->add($this->getTranslator()->trans('mediaUpload'), array('action' => 'upload'));
     if (!is_writable(APPLICATION_PATH . '/../' . $this->getConfig()->get('usergallery_uploadpath'))) {
         $this->addMessage('writableMedia', 'danger');
     }
     if ($this->getRequest()->isPost()) {
         if (!is_dir(APPLICATION_PATH . '/../' . $this->getConfig()->get('usergallery_uploadpath') . $this->getUser()->getId())) {
             mkdir(APPLICATION_PATH . '/../' . $this->getConfig()->get('usergallery_uploadpath') . $this->getUser()->getId(), 0777);
         }
         $upload = new \Ilch\Upload();
         $upload->setFile($_FILES['upl']['name']);
         $upload->setTypes($this->getConfig()->get('usergallery_filetypes'));
         $upload->setPath($this->getConfig()->get('usergallery_uploadpath') . $this->getUser()->getId() . '/');
         $upload->upload();
         $model = new MediaModel();
         $model->setUserId($this->getUser()->getId());
         $model->setUrl($upload->getUrl());
         $model->setUrlThumb($upload->getUrlThumb());
         $model->setEnding($upload->getEnding());
         $model->setName($upload->getName());
         $model->setDatetime($ilchdate->toDb());
         $mediaMapper->save($model);
     }
 }
Beispiel #4
0
                        <th><?php 
    echo $this->getTrans('size');
    ?>
</th>
                        <th><?php 
    echo $this->getTrans('name');
    ?>
</th>
                    </tr>
                </thead>
                <tbody>
                    <?php 
    foreach ($this->get('media') as $media) {
        ?>
                        <?php 
        $upload = new \Ilch\Upload();
        $upload->setFile($media);
        ?>
                        <tr>
                            <td><input value="<?php 
        echo $media;
        ?>
" type="checkbox" name="check_medias[]" /></td>
                            <td><?php 
        echo $upload->getEnding();
        ?>
</td>
                            <td>
                                <?php 
        if (in_array($upload->getEnding(), explode(' ', $this->get('media_ext_img')))) {
            ?>