PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/core/Collections/Controller/Collections.php

https://github.com/scogle/cockpit
PHP | 59 lines | 37 code | 22 blank | 0 comment | 5 complexity | e1e3605d8a705e111b0a04091d3733c1 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. namespace Collections\Controller;
  3. class Collections extends \Cockpit\Controller {
  4. public function index() {
  5. return $this->render("collections:views/index.php");
  6. }
  7. public function collection($id = null) {
  8. if(!$this->app->module("auth")->hasaccess("Collections", 'manage.collections')) {
  9. return false;
  10. }
  11. return $this->render("collections:views/collection.php", compact('id'));
  12. }
  13. public function entries($id) {
  14. $collection = $this->app->db->findOne("common/collections", ["_id" => $id]);
  15. if(!$collection) {
  16. return false;
  17. }
  18. $count = $this->app->module("collections")->collectionById($collection["_id"])->count();
  19. $collection["count"] = $count;
  20. return $this->render("collections:views/entries.php", compact('id', 'collection', 'count'));
  21. }
  22. public function entry($collectionId, $entryId=null) {
  23. $collection = $this->app->db->findOne("common/collections", ["_id" => $collectionId]);
  24. $entry = null;
  25. if(!$collection) {
  26. return false;
  27. }
  28. if($entryId) {
  29. $col = "collection".$collection["_id"];
  30. $entry = $this->app->db->findOne("collections/{$col}", ["_id" => $entryId]);
  31. if(!$entry) {
  32. return false;
  33. }
  34. }
  35. return $this->render("collections:views/entry.php", compact('collection', 'entry'));
  36. }
  37. }