/plugins/apostrophePlugin/lib/action/BaseaMediaComponents.class.php

https://github.com/malacon/pprl · PHP · 160 lines · 113 code · 8 blank · 39 comment · 11 complexity · d681bbe022c172834039b29205fe3287 MD5 · raw file

  1. <?php
  2. /**
  3. * @package apostrophePlugin
  4. * @subpackage action
  5. * @author P'unk Avenue <apostrophe@punkave.com>
  6. */
  7. class BaseaMediaComponents extends sfComponents
  8. {
  9. /**
  10. * DOCUMENT ME
  11. * @param mixed $request
  12. */
  13. public function executeBrowser($request)
  14. {
  15. // We don't use a single integrated form for this anymore. What we wanted was
  16. // individual-link behavior, and yet we overlaid a form on that,
  17. // which had some interesting aspects but was ultimately confusing
  18. // and a problem for search engine indexing etc
  19. // ... But we do now use a simple form for the search form
  20. $this->current = "aMedia/index";
  21. $params = array();
  22. $type = aMediaTools::getSearchParameter('type');
  23. if (strlen($type))
  24. {
  25. $this->type = $type;
  26. $params['type'] = $type;
  27. }
  28. $tag = aMediaTools::getSearchParameter('tag');
  29. if (strlen($tag))
  30. {
  31. $this->selectedTag = $tag;
  32. $params['tag'] = $tag;
  33. }
  34. $categorySlug = aMediaTools::getSearchParameter('category');
  35. if (strlen($categorySlug))
  36. {
  37. $this->selectedCategory = Doctrine::getTable('aCategory')->findOneBySlug($categorySlug);
  38. $params['category'] = $categorySlug;
  39. }
  40. $search = aMediaTools::getSearchParameter('search');
  41. if (strlen($search))
  42. {
  43. $this->search = $search;
  44. $params['search'] = $search;
  45. }
  46. $this->searchForm = new aMediaSearchForm();
  47. $this->searchForm->bind(array('search' => $request->getParameter('search')));
  48. $this->current .= "?" . http_build_query($params);
  49. $this->allTags = aMediaItemTable::getAllTagNameForUserWithCount();
  50. $tagsByPopularity = $this->allTags;
  51. arsort($tagsByPopularity);
  52. $this->popularTags = array();
  53. $n = 0;
  54. $max = aMediaTools::getOption('popular_tags');
  55. foreach ($tagsByPopularity as $tag => $count)
  56. {
  57. if ($n == $max)
  58. {
  59. break;
  60. }
  61. $this->popularTags[$tag] = $count;
  62. $n++;
  63. }
  64. }
  65. /**
  66. * DOCUMENT ME
  67. * @param mixed $request
  68. */
  69. public function executeBreadcrumb($request)
  70. {
  71. $this->type = aMediaTools::getSearchParameter('type');
  72. $this->tag = aMediaTools::getSearchParameter('tag');
  73. $this->search = aMediaTools::getSearchParameter('search');
  74. $this->categorySlug = aMediaTools::getSearchParameter('category');
  75. $this->crumbs = array();
  76. // I tried calling I18N here but that requires enabling
  77. // I18N for every project which the I18N helper does not...
  78. // I'm not internationalizing this site, so I give up.
  79. // If you're reading this, tell me how to localize these labels
  80. // without punishing noninternationalized sites. I really don't
  81. // want to push this much logic into a template. tom@punkave.com
  82. $this->crumbs[] = array(
  83. "label" => "Home",
  84. "link" => "@homepage",
  85. "first" => true);
  86. $this->crumbs[] = array(
  87. "label" => "Media",
  88. "link" => "aMedia/index");
  89. if ($this->type)
  90. {
  91. $this->crumbs[] = array(
  92. "label" => $this->type,
  93. "link" => aUrl::addParams("aMedia/index", array("type" => $this->type)));
  94. }
  95. if ($this->categorySlug)
  96. {
  97. $this->crumbs[] = array(
  98. "label" => $this->category,
  99. "link" => aUrl::addParams("aMedia/index", array('type' => $this->type, "category" => $this->categorySlug)));
  100. }
  101. if ($this->tag)
  102. {
  103. $this->crumbs[] = array(
  104. "label" => htmlspecialchars($this->tag),
  105. "link" => aUrl::addParams("aMedia/index", array("type" => $this->type, 'category' => $this->categorySlug, "tag" => $this->tag)));
  106. }
  107. if ($this->search)
  108. {
  109. $this->crumbs[] = array(
  110. "label" => htmlspecialchars($this->search),
  111. "link" => aUrl::addParams("aMedia/index", array("type" => $this->type, 'category' => $this->categorySlug, "tag" => $this->tag, "search" => $this->search)));
  112. }
  113. if (isset($this->item))
  114. {
  115. $this->crumbs[] = array(
  116. "label" => $this->item->getTitle(),
  117. "link" => aUrl::addParams("aMedia/show", array("slug" => $this->item->getSlug())));
  118. }
  119. $this->crumbs[count($this->crumbs) - 1]['last'] = true;
  120. }
  121. /**
  122. * DOCUMENT ME
  123. * @param mixed $request
  124. */
  125. public function executeSelectMultiple($request)
  126. {
  127. $this->items = aMediaTools::getSelectedItems();
  128. }
  129. /**
  130. * DOCUMENT ME
  131. * @param mixed $request
  132. */
  133. public function executeSelectSingle($request)
  134. {
  135. $this->items = aMediaTools::getSelectedItems();
  136. }
  137. /**
  138. * DOCUMENT ME
  139. * @param mixed $request
  140. */
  141. public function executeMultipleList($request)
  142. {
  143. $this->items = aMediaTools::getSelectedItems();
  144. }
  145. /**
  146. * DOCUMENT ME
  147. */
  148. public function executeMultiplePreview()
  149. {
  150. $this->items = aMediaTools::getSelectedItems();
  151. }
  152. }