/modules/core/Collections/Controller/Collections.php
PHP | 59 lines | 37 code | 22 blank | 0 comment | 5 complexity | e1e3605d8a705e111b0a04091d3733c1 MD5 | raw file
Possible License(s): LGPL-2.1
- <?php
- namespace Collections\Controller;
- class Collections extends \Cockpit\Controller {
- public function index() {
- return $this->render("collections:views/index.php");
- }
- public function collection($id = null) {
- if(!$this->app->module("auth")->hasaccess("Collections", 'manage.collections')) {
- return false;
- }
- return $this->render("collections:views/collection.php", compact('id'));
- }
- public function entries($id) {
- $collection = $this->app->db->findOne("common/collections", ["_id" => $id]);
- if(!$collection) {
- return false;
- }
- $count = $this->app->module("collections")->collectionById($collection["_id"])->count();
- $collection["count"] = $count;
- return $this->render("collections:views/entries.php", compact('id', 'collection', 'count'));
- }
- public function entry($collectionId, $entryId=null) {
- $collection = $this->app->db->findOne("common/collections", ["_id" => $collectionId]);
- $entry = null;
- if(!$collection) {
- return false;
- }
- if($entryId) {
- $col = "collection".$collection["_id"];
- $entry = $this->app->db->findOne("collections/{$col}", ["_id" => $entryId]);
- if(!$entry) {
- return false;
- }
- }
- return $this->render("collections:views/entry.php", compact('collection', 'entry'));
- }
- }