PageRenderTime 31ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/app/tpl/Paste/default.php

https://github.com/marek-saji/nyopaste
PHP | 201 lines | 165 code | 30 blank | 6 comment | 9 complexity | 20af26997d44fd54ba9a43ac9d8662a2 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * Displaying a paste
  4. * @author m.augustynowicz
  5. *
  6. * @param array $row one row data
  7. */
  8. $title = $row['title'];
  9. $v->setTitle($title);
  10. $v->setMeta('og:type', 'article', 'property');
  11. $v->setMeta('og:url', $this->url2a('', array($row['url']), true), 'property');
  12. $v->setDescription($this->trans(
  13. 'a paste by %s',
  14. $row['Paster'] ? $row['Paster']['DisplayName'] : $row['paster']
  15. ));
  16. $v->addLess($this->file('default', 'less'));
  17. $v->addJs($this->file('default', 'js'));
  18. $meta_data_toggler = json_encode(array(
  19. 'showLabel' => $this->trans('more info'),
  20. 'hideLabel' => $this->trans('less info')
  21. ));
  22. ?>
  23. <section class="paste hentry" id="paste">
  24. <header>
  25. <hgroup>
  26. <h2 class="entry-title">
  27. <?=$title?>
  28. <span class="version">
  29. <?=$this->trans('v%s', $row['version'])?>
  30. </span>
  31. </h2>
  32. <h3>
  33. <?=$this->trans('pasted by %s', $this->inc('paster', $row))?>
  34. </h3>
  35. </hgroup>
  36. <dl <?=$f->xmlAttr(array('id' => 'meta', 'data-toggler' => $meta_data_toggler))?>>
  37. <dt><?=$this->trans('created')?></dt>
  38. <dd>
  39. <time class="published" datetime="<?=$row['creation']?>">
  40. <?=$f->formatDate($row['creation'], DATE_HUMAN_FORMAT|DATE_SHOW_ALL)?>
  41. </time>
  42. </dd>
  43. <dt><?=$this->trans('privacy')?></dt>
  44. <dd>
  45. <?=$this->trans($row['privacy'])?><?php
  46. if ($row['enc_passwd']) :
  47. ?>, <?=$this->trans('password protected')?>
  48. <?php endif; ?>
  49. </dd>
  50. <?php if ($row['source_url']) : ?>
  51. <dt><?=$t->trans('source URL')?></dt>
  52. <dd><a href="<?=$row['source_url']?>"><?=$row['source_url']?></a></dd>
  53. </p>
  54. <?php endif; ?>
  55. <?php if ($row['author']) : ?>
  56. <dt><?=$t->trans('original author')?></dt>
  57. <dd><?=$row['author']?></dd>
  58. <?php endif; ?>
  59. <?php if (!$f->anyToBool($row['publicly_versionable'])) : ?>
  60. <dt><?=$this->trans('creating new versions by other users denied')?></dt>
  61. <?php endif; ?>
  62. <?php
  63. $type->inc('meta');
  64. ?>
  65. <?php if ($row['Tags']) : ?>
  66. <dt><?=$t->trans('tags')?></dt>
  67. <dd>
  68. <?php
  69. $this->inc('tags', array('tags'=>&$row['Tags']));
  70. ?>
  71. </dd>
  72. <?php endif; ?>
  73. </dl>
  74. <div class="actions wrapper">
  75. <?php
  76. $t->inc('row_actions', array(
  77. 'actions' => & $row['Actions']
  78. ));
  79. ?>
  80. <?php
  81. $t->inc('row_actions', array(
  82. 'actions' => & $row['BasicActions'],
  83. 'class' => 'basic'
  84. ));
  85. ?>
  86. </div> <!-- .actions.wrapper -->
  87. </header>
  88. <?php if ($row['enc_passwd'] && null === $row['content']) : ?>
  89. <?php
  90. $form = g('Forms', array('enc_passwd', $this));
  91. ?>
  92. <article class="holoform" id="content">
  93. <?php
  94. $form->create();
  95. ?>
  96. <fieldset>
  97. <ul>
  98. <li class="field">
  99. <?php
  100. $form->label('enc_passwd', 'Password');
  101. ?>
  102. <?php
  103. $form->input('enc_passwd');
  104. ?>
  105. </li>
  106. </ul>
  107. </fieldset>
  108. <?php
  109. $this->inc(
  110. 'Forms/buttons',
  111. array(
  112. 'form' => $form,
  113. 'submit' => 'show the paste'
  114. )
  115. );
  116. ?>
  117. <?php
  118. $form->end();
  119. ?>
  120. </article>
  121. <?php else : ?>
  122. <article id="content" class="entry-content <?=$type->getType()?>">
  123. <?php
  124. $type->render();
  125. ?>
  126. </article>
  127. <?php endif; /* $enc_passwd_form */ ?>
  128. <div id="share" class="modaled">
  129. <div class="share-inside">
  130. <h3>
  131. <?=$this->trans('share this paste')?>
  132. </h3>
  133. <?php
  134. $permalink = g()->req->getBaseUri(true)
  135. . sprintf(
  136. g()->conf['paste']['permalink'],
  137. $this->getParam(0), $this->getParam('v')
  138. )
  139. ;
  140. $share_text = $this->trans('%s', $row['title']);
  141. $mail_subject = $this->trans('%s at %s', $row['title'], strip_tags(g()->conf['site_name']));
  142. $mail_body = $this->trans("Take a look at this:\n\n%2\$s", $row['title'], $permalink);
  143. $this->inc('share', array(
  144. 'link' => $permalink,
  145. 'title' => $share_text,
  146. 'mail_subject' => $mail_subject,
  147. 'mail_body' => $mail_body
  148. ));
  149. ?>
  150. </div>
  151. </div>
  152. <?php if (@$row['Tree'][$row['root_id']]['Children']) : ?>
  153. <section class="tree" id="tree">
  154. <h3><?=$this->trans('All versions of this paste:')?></h3>
  155. <?php
  156. $this->inc('tree', array(
  157. 'tree' => & $row['Tree'],
  158. 'current' => $row['id']
  159. ));
  160. ?>
  161. </section>
  162. <?php endif; ?>
  163. </section>
  164. <?php
  165. $url_json = json_encode($this->url2a('newVerCheck', array($row['url'], 'timestamp'=>$timestamp)));
  166. $msg_json = json_encode($this->trans('New version(s) of this paste available. You may want to refresh the page, to see them.'));
  167. $ver_check_timeout_json = (int) $ver_check_timeout;;
  168. $v->addOnLoad( <<< VER_CHECKER
  169. newVerChecker({$url_json}, {$ver_check_timeout_json}, {$msg_json});
  170. VER_CHECKER
  171. );