Exemple #1
0
 /**
  * Gets the Media List Scroll.
  *
  * @param int $lastId
  * @return MediaModel[]|array
  */
 public function getMediaListScroll($lastId = NULL)
 {
     $sql = 'SELECT *
             FROM `[prefix]_users_media`
             WHERE id < ' . $lastId . '
             ORDER by id DESC
             LIMIT 40';
     $mediaArray = $this->db()->query($sql);
     if (empty($mediaArray)) {
         return null;
     }
     $media = array();
     foreach ($mediaArray as $medias) {
         $entryModel = new MediaModel();
         $entryModel->setId($medias['id']);
         $entryModel->setUrl($medias['url']);
         $entryModel->setUrlThumb($medias['url_thumb']);
         $entryModel->setName($medias['name']);
         $entryModel->setDatetime($medias['datetime']);
         $entryModel->setEnding($medias['ending']);
         $media[] = $entryModel;
     }
     return $media;
 }
Exemple #2
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);
     }
 }