public function view() { $view = $this->getView(); $factory = new ModelFactory('GalleryImageModel'); if ($this->getSetting('order') == 'random') { $factory->order('RAND()'); } else { $factory->order($this->getSetting('order')); } if ($this->getSetting('album')) { $factory->where('albumid = ' . $this->getSetting('album')); $album = GalleryAlbumModel::Construct($this->getSetting('album')); $link = $album->get('baseurl'); } else { $link = null; } $factory->limit($this->getSetting('count')); $images = $factory->get(); $view->assign('images', $images); $view->assign('dimensions', $this->getSetting('dimensions')); $view->assign('link', $link); $view->assign('uselightbox', $this->getSetting('uselightbox') && Core::IsComponentAvailable('jquery-lightbox')); }
/** * View to rearrange the images in this gallery. * */ public function order() { $view = $this->getView(); $request = $this->getPageRequest(); $albumid = $request->getParameter(0); $album = GalleryAlbumModel::Construct($albumid); $images = $album->getLink('GalleryImage', 'weight'); $manager = \Core\user()->checkAccess('p:/gallery/manage_all'); $editor = \Core\user()->checkAccess($album->get('editpermissions')) || $manager; $uploader = \Core\user()->checkAccess($album->get('uploadpermissions')) || $editor; // Uploading permission is required at least. if (!$uploader) { return View::ERROR_ACCESSDENIED; } // The album must exist first! if (!$album->exists()) { return View::ERROR_NOTFOUND; } if ($request->isPost()) { // For sanity reasons, make an array of the current images in this album. $imgs = array(); foreach ($images as $i) { $imgs[] = $i->get('id'); } $weight = 0; foreach ($_POST['images'] as $i) { if (!in_array($i, $imgs)) { continue; } $image = GalleryImageModel::Construct($i); $image->set('weight', ++$weight); $image->save(); } \core\redirect($album->get('rewriteurl')); } $view->addBreadcrumb($album->get('title'), $album->get('rewriteurl')); $view->title = 'Image Order'; $view->assign('album', $album); $view->assign('images', $images); $view->assign('editor', $editor); $view->assign('manager', $manager); $view->assign('uploader', $uploader); }