BlankAdPlugin.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Plugin for testing ad layout
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Ads
  23. * @package StatusNet
  24. * @author Evan Prodromou <evan@status.net>
  25. * @copyright 2010 StatusNet Inc.
  26. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  27. * @link http://status.net/
  28. */
  29. if (!defined('STATUSNET')) {
  30. exit(1);
  31. }
  32. /**
  33. * Plugin for testing ad layout
  34. *
  35. * This plugin uses the UAPPlugin framework to output ad content. However,
  36. * its ad content is just images with one red pixel stretched to the
  37. * right size. It's mostly useful for debugging theme layout.
  38. *
  39. * To use this plugin, set the parameter for the ad size you want to use
  40. * to true (or anything non-null). For example, to make a leaderboard:
  41. *
  42. * addPlugin('BlankAd', array('leaderboard' => true));
  43. *
  44. * @category Plugin
  45. * @package StatusNet
  46. * @author Evan Prodromou <evan@status.net>
  47. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  48. * @link http://status.net/
  49. *
  50. * @seeAlso Location
  51. */
  52. class BlankAdPlugin extends UAPPlugin
  53. {
  54. const PLUGIN_VERSION = '2.0.0';
  55. /**
  56. * Show a medium rectangle 'ad'
  57. *
  58. * @param Action $action Action being shown
  59. *
  60. * @return void
  61. */
  62. protected function showMediumRectangle($action)
  63. {
  64. $action->element('img',
  65. array('width' => 300,
  66. 'height' => 250,
  67. 'src' => $this->path('redpixel.png')),
  68. '');
  69. }
  70. /**
  71. * Show a rectangle 'ad'
  72. *
  73. * @param Action $action Action being shown
  74. *
  75. * @return void
  76. */
  77. protected function showRectangle($action)
  78. {
  79. $action->element('img',
  80. array('width' => 180,
  81. 'height' => 150,
  82. 'src' => $this->path('redpixel.png')),
  83. '');
  84. }
  85. /**
  86. * Show a wide skyscraper ad
  87. *
  88. * @param Action $action Action being shown
  89. *
  90. * @return void
  91. */
  92. protected function showWideSkyscraper($action)
  93. {
  94. $action->element('img',
  95. array('width' => 160,
  96. 'height' => 600,
  97. 'src' => $this->path('redpixel.png')),
  98. '');
  99. }
  100. /**
  101. * Show a leaderboard ad
  102. *
  103. * @param Action $action Action being shown
  104. *
  105. * @return void
  106. */
  107. protected function showLeaderboard($action)
  108. {
  109. $action->element('img',
  110. array('width' => 728,
  111. 'height' => 90,
  112. 'src' => $this->path('redpixel.png')),
  113. '');
  114. }
  115. public function onPluginVersion(array &$versions): bool
  116. {
  117. $versions[] = array('name' => 'BlankAd',
  118. 'version' => self::PLUGIN_VERSION,
  119. 'author' => 'Evan Prodromou',
  120. 'homepage' => GNUSOCIAL_ENGINE_REPO_URL . 'tree/master/plugins/BlankAdPlugin',
  121. 'rawdescription' =>
  122. // TRANS: Plugin description.
  123. _m('Plugin for testing ad layout.'));
  124. return true;
  125. }
  126. }