v1.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace zin;
  3. require_once dirname(__DIR__) . DS . 'entitylist' . DS . 'v1.php';
  4. class storyList extends entitylist
  5. {
  6. /**
  7. * @var mixed[]
  8. */
  9. protected static $defaultProps = array
  10. (
  11. 'type' => 'story'
  12. );
  13. /**
  14. * @param object $entity
  15. */
  16. protected function getItem($entity)
  17. {
  18. $item = array
  19. (
  20. 'innerClass' => 'px-0 relative group',
  21. 'leading' => array(),
  22. 'innerTag' => 'div',
  23. 'titleClass' => 'flex gap-2 items-center flex-auto min-w-0',
  24. 'textClass' => 'flex-none',
  25. 'actionsClass' => $this->compact ? 'absolute top-0.5 right-0' : null,
  26. 'hint' => $entity->title,
  27. 'title' => span(setClass('text-clip'), $entity->title),
  28. 'leading' => idLabel::create($entity->id)
  29. );
  30. if(hasPriv($entity->type, 'view'))
  31. {
  32. $item['titleAttrs'] = array('data-toggle' => 'modal', 'data-size' => 'lg');
  33. $item['url'] = createLink($entity->type, 'view', "id=$entity->id");
  34. }
  35. return $item;
  36. }
  37. protected function getItems()
  38. {
  39. global $lang;
  40. $items = $this->prop('items', array());
  41. $list = array();
  42. foreach($items as $key => $entity)
  43. {
  44. if(is_object($entity))
  45. {
  46. $list[] = $this->getItem($entity);
  47. }
  48. elseif(is_array($entity))
  49. {
  50. $list[] = array('id' => $key, 'title' => $lang->story->typeList[$key]);
  51. foreach($entity as $subEntity)
  52. {
  53. $list[] = $this->getItem($subEntity);
  54. }
  55. }
  56. }
  57. return $list;
  58. }
  59. }