PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/app/views/history/index.php

https://gitlab.com/Kille250/myimouto
PHP | 135 lines | 127 code | 8 blank | 0 comment | 26 complexity | 5bd93aed466aa7ec52539d1fa27c27ea MD5 | raw file
  1. <?php $this->provide('title', $this->t('.title')) ?>
  2. <div>
  3. <div style="margin-bottom: 1em;">
  4. <ul class="history-header">
  5. <?php if ($this->type == "all" || $this->type == "posts") : ?>
  6. <li>» <?= $this->linkTo($this->options['show_all_tags'] ? $this->t('.show.all') : $this->t('.show.changed'), array_merge(['#index'], array_merge($this->params()->get(), ['show_all_tags' => $this->options['show_all_tags'] ? 0:1]))) ?></li>
  7. <?php endif ?>
  8. <?php /* If we're searching for a specific object, omit the id/name' column and
  9. show it once at the top. */ ?>
  10. <?php if ($this->options['specific_object'] && $this->changes->any()) : ?>
  11. <li>
  12. » <?= $this->t('.for') ?> <?= $this->singularize($this->type) ?>:
  13. <?=
  14. $this->linkTo(
  15. $this->options['show_name'] ?
  16. $this->changes[0]->group_by_obj->pretty_name() :
  17. $this->changes[0]->group_by_id,
  18. ['controller' => strtolower($this->changes[0]->get_group_by_controller()), 'action' => "show", 'id' => $this->changes[0]->group_by_id]
  19. )
  20. ?>
  21. </li>
  22. <?php endif ?>
  23. </ul>
  24. </div>
  25. <div style="clear: left;">
  26. <?= $this->imageTag('images/blank.gif', ['id' => 'hover-thumb', 'alt' => '', 'style' => 'position: absolute; display: none; border: 2px solid #000; right: 10%']) ?>
  27. <table width="100%" class="highlightable" id="history">
  28. <thead>
  29. <tr>
  30. <?php if ($this->type == "all") : ?>
  31. <th><?= $this->t('.object_type') ?></th>
  32. <?php endif ?>
  33. <th></th>
  34. <?php if ($this->options['specific_object']) : ?>
  35. <?php elseif ($this->options['show_name']) : ?>
  36. <th><?= $this->capitalize($this->singularize($this->type)) ?></th>
  37. <?php else: ?>
  38. <th><?php
  39. if ($this->type == "all")
  40. echo $this->t('.id');
  41. else
  42. echo ucfirst($this->singularize($this->type));
  43. ?></th>
  44. <?php endif ?>
  45. <th><?= $this->t('.date') ?></th>
  46. <th><?= $this->t('.user') ?></th>
  47. <th><?= $this->t('.change') ?></th>
  48. </tr>
  49. </thead>
  50. <tbody>
  51. <?php foreach ($this->changes as $change) : ?>
  52. <?php $new_user = (time() - strtotime($change->user->created_at) < 60*60*24*3) ?>
  53. <tr class="<?= $this->cycle('even', 'odd') ?>" id="r<?= $change->id ?>">
  54. <?php if ($this->type == "all") : ?>
  55. <td><?= $this->humanize($this->singularize($change->group_by_table)) ?></td>
  56. <?php endif ?>
  57. <td style="background: <?= $this->id_to_color($change->group_by_id) ?>;"></td>
  58. <?php if (!$this->options['specific_object']) : ?>
  59. <?php
  60. $classes = ["id"];
  61. if (get_class($change->group_by_obj()) == "Post") {
  62. if ($change->group_by_obj()->status == "deleted")
  63. $classes[] = "deleted";
  64. if ($change->group_by_obj()->is_held)
  65. $classes[] = "held";
  66. }
  67. ?>
  68. <td class="<?= implode(" ", $classes) ?>"><?= $this->linkTo($this->options['show_name'] ? $change->group_by_obj()->pretty_name() : $change->group_by_id, [
  69. 'controller' => strtolower($change->get_group_by_controller()),
  70. 'action' => $change->get_group_by_action(),
  71. 'id' => $change->group_by_id]
  72. ) ?></td>
  73. <?php endif ?>
  74. <td><?= date("M d Y, H:i", strtotime($change->created_at)) ?></td>
  75. <td class="author"><?= $this->linkToIf($change->user_id, $change->author(),
  76. ['controller' => "user", 'action' => "show", 'id' => $change->user_id],
  77. ['class' => "user-" . $change->user_id . ($new_user ? " new-user":"")]
  78. ) ?></td>
  79. <td class="change"><?= $this->format_changes($change, $this->options) ?></td>
  80. </tr>
  81. <?php endforeach ?>
  82. </tbody>
  83. </table>
  84. </div>
  85. <div class="history-search-row">
  86. <div>
  87. <?= $this->formTag("#index", ['method' => 'get'], function(){ ?>
  88. <?= $this->textFieldTag("search", $this->params()->search, ['id' => "search", 'size' => 20]) ?> <?= $this->submitTag($this->t('.search')) ?>
  89. <?php }) ?>
  90. </div>
  91. </div>
  92. <div class="footer history-footer">
  93. <?= $this->linkToFunction($this->t('.undo'), "History.undo(false)", ['level' => 'member', 'id' => "undo"]) ?> |
  94. <?= $this->linkToFunction($this->t('.redo'), "History.undo(true)", ['level' => 'member', 'id' => "redo"]) ?>
  95. </div>
  96. <?php $this->contentFor('subnavbar', function(){ ?>
  97. <li><?= $this->linkTo($this->t('.type.all'), ['action' => "index"]) ?></li>
  98. <li><?= $this->linkTo($this->t('.type.posts'), ['action' => "index", 'search' => "type:posts"]) ?></li>
  99. <li><?= $this->linkTo($this->t('.type.pools'), ['action' => "index", 'search' => "type:pools"]) ?></li>
  100. <li><?= $this->linkTo($this->t('.type.tags'), ['action' => "index", 'search' => "type:tags"]) ?></li>
  101. <?php }) ?>
  102. </div>
  103. <?php $this->contentFor('post_cookie_javascripts', function() { ?>
  104. <script type="text/javascript">
  105. var thumb = $("hover-thumb");
  106. <?php foreach ($this->changes as $change) : ?>
  107. History.add_change(<?= $change->id ?>, "<?= $change->get_group_by_controller() ?>", <?= $change->group_by_id ?>, [ <?= implode(', ', $change->history_changes->getAttributes('id')) ?> ], '<?= $this->escapeJavascript($change->author()) ?>')
  108. <?php if ($change->group_by_table_class() == "Post" && CONFIG()->can_see_post(current_user(), $change->group_by_obj())) : ?>
  109. Post.register(<?= $this->jsonEscape($change->group_by_obj()->toJson()) ?>)
  110. var hover_row = $("r<?= $change->id ?>");
  111. var container = hover_row.up("TABLE");
  112. Post.init_hover_thumb(hover_row, <?= $change->group_by_id ?>, thumb, container);
  113. <?php endif ?>
  114. <?php endforeach ?>
  115. Post.init_blacklisted({replace: true});
  116. <?php foreach ($this->changes as $change) : ?>
  117. <?php if ($change->group_by_table_class() == "Post" && CONFIG()->can_see_post(current_user(), $change->group_by_obj())) : ?>
  118. if(!Post.is_blacklisted(<?= $change->group_by_obj()->id ?>))
  119. Preload.preload('<?= $this->escapeJavascript($change->group_by_obj()->preview_url()) ?>');
  120. <?php endif ?>
  121. <?php endforeach ?>
  122. History.init()
  123. </script>
  124. <?php }) ?>
  125. <div id="paginator">
  126. <?= $this->willPaginate($this->changes) ?>
  127. </div>