public function delAction() { $mediaMapper = new MediaMapper(); $mediaMapper->delMediaById($this->getRequest()->getParam('id')); $this->addMessage('deleteSuccess'); $this->redirect(array('action' => 'index')); }
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)); }
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); }
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')); }
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')); }