Ejemplo n.º 1
0
 public function delAction()
 {
     $mediaMapper = new MediaMapper();
     $mediaMapper->delMediaById($this->getRequest()->getParam('id'));
     $this->addMessage('deleteSuccess');
     $this->redirect(array('action' => 'index'));
 }
Ejemplo n.º 2
0
 public function treatAction()
 {
     $mediaMapper = new MediaMapper();
     $catId = (int) $this->getRequest()->getParam('id');
     if ($this->getRequest()->getPost('save') && $this->getRequest()->getPost('title_treat')) {
         $model = new \Modules\Media\Models\Media();
         $model->setCatId($catId);
         $model->setCatName($this->getRequest()->getPost('title_treat'));
         $mediaMapper->treatCat($model);
         $this->addMessage('Success');
         $this->redirect(array('action' => 'index'));
     }
     $this->getView()->set('cat', $mediaMapper->getCatById($catId));
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 public function multiAction()
 {
     $this->getLayout()->setFile('modules/admin/layouts/ajax');
     $mediaMapper = new MediaMapper();
     $pagination = new \Ilch\Pagination();
     $pagination->setPage($this->getRequest()->getParam('page'));
     $lastId = $this->getRequest()->getParam('lastid');
     $this->getView()->set('pagination', $pagination);
     if (empty($lastId)) {
         $this->getView()->set('medias', $mediaMapper->getMediaList($pagination));
     } else {
         $this->getView()->set('medias', $mediaMapper->getMediaListScroll($lastId));
     }
     $this->getView()->set('media_ext_img', $this->getConfig()->get('media_ext_img'));
     $this->getView()->set('media_ext_file', $this->getConfig()->get('media_ext_file'));
     $this->getView()->set('media_ext_video', $this->getConfig()->get('media_ext_video'));
 }
Ejemplo n.º 5
0
 public function multickeditorAction()
 {
     $this->getLayout()->setFile('modules/admin/layouts/iframe');
     $mediaMapper = new MediaMapper();
     $pagination = new \Ilch\Pagination();
     $pagination->setPage($this->getRequest()->getParam('page'));
     $this->getView()->set('pagination', $pagination);
     $this->getView()->set('medias', $mediaMapper->getMediaList($pagination));
     $this->getView()->set('media_ext_img', $this->getConfig()->get('media_ext_img'));
     $this->getView()->set('media_ext_file', $this->getConfig()->get('media_ext_file'));
     $this->getView()->set('media_ext_video', $this->getConfig()->get('media_ext_video'));
 }