mostly filebased Content Presentation System
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

cpublication.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace Modules;
  3. class CPublication extends ContentType {
  4. public $keys = array(
  5. 'TITLE' => 'title',
  6. 'ARTIST' => 'artist',
  7. 'DATE' => 'date',
  8. 'IMAGE' => 'img',
  9. 'CATALOGUE' => 'cat',
  10. 'PRICE' => 'price',
  11. 'LINK' => 'link'
  12. );
  13. public $values;
  14. protected $layout;
  15. protected $layouts = array(
  16. 'default' => 'view_in_toc',
  17. 'toc' => 'view_in_toc'
  18. );
  19. function __construct($keys,$config) {
  20. parent::__construct($keys,$config);
  21. }
  22. function simple() {
  23. return sprintf("sdsd");
  24. }
  25. function affiliate_link($href) {
  26. $classes = ['affiliate'];
  27. $name = $href;
  28. if (stripos($href, 'bandcamp.com') !== false) {
  29. $classes[] = 'bandcamp';
  30. $name = 'Bandcamp';
  31. }
  32. return sprintf('<a href="%s" class="%s">%s</a>',
  33. $href,
  34. implode(" ",$classes),
  35. $name
  36. );
  37. }
  38. function view_in_toc() {
  39. $f3 = \Base::instance();
  40. $v = (object) $this->values;
  41. $img = new CachedImage($this->config['path'].$v->img);
  42. $img_html = sprintf('<img src="%s" alt="cover art" />', $img->get_src(1000));
  43. $ED = new ElementDispatcher();
  44. $buy_button = $v->price
  45. ? $ED->content_element([
  46. 'buy',
  47. $v->cat .": ".$v->title,
  48. $v->price])
  49. : "";
  50. $affiliates = "";
  51. if (is_array($v->link)) {
  52. foreach ($v->link as $link) {
  53. $affiliates .= $this->affiliate_link($link);
  54. }
  55. } else {
  56. $affiliates .= $this->affiliate_link($v->link);
  57. }
  58. return sprintf(
  59. "<div class=\"contentTypeElement publication\">"
  60. ."<span class=\"catalogue\">%s</span>"
  61. ."<a href=\"/%s\">"
  62. ."%s"
  63. ."<div class=\"info\">"
  64. ."<h2>%s</h2><h3><span class=\"artist\">%s</span>%s</h3>"
  65. ."</div></a></div>%s %s",
  66. $v->cat,
  67. $this->href,
  68. $img_html,
  69. $v->title,
  70. $v->artist,
  71. $v->date ? '<span class="pubdate"> - '.$v->date.'</span>' : '' ,
  72. $buy_button,
  73. $affiliates
  74. );
  75. }
  76. }