PageRenderTime 59ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/system/plugins/pi.randomizer.php

https://github.com/danboy/Croissierd
PHP | 106 lines | 45 code | 23 blank | 38 comment | 0 complexity | 9fdf42f93349f2d64bc18416dbec136b MD5 | raw file
  1. <?php
  2. /*
  3. =====================================================
  4. ExpressionEngine - by EllisLab
  5. -----------------------------------------------------
  6. http://expressionengine.com/
  7. -----------------------------------------------------
  8. Copyright (c) 2003 - 2010 EllisLab, Inc.
  9. =====================================================
  10. THIS IS COPYRIGHTED SOFTWARE
  11. PLEASE READ THE LICENSE AGREEMENT
  12. http://expressionengine.com/docs/license.html
  13. =====================================================
  14. File: pi.randomizer.php
  15. -----------------------------------------------------
  16. Purpose: Random generator. This class enables
  17. random items to appear on your page.
  18. =====================================================
  19. To add another sets of quotes, add another function:
  20. function set_two()
  21. {
  22. $quotes = array( FILL WITH QUOTES);
  23. return $quotes[array_rand($quotes)];
  24. }
  25. Then use this tag in your template:
  26. {exp:randomizer:set_two}
  27. */
  28. $plugin_info = array(
  29. 'pi_name' => 'Randomizer',
  30. 'pi_version' => '1.0',
  31. 'pi_author' => 'Rick Ellis',
  32. 'pi_author_url' => 'http://expressionengine.com/',
  33. 'pi_description' => 'Allows you to show random text, such as quotes, on your site.',
  34. 'pi_usage' => Randomizer::usage()
  35. );
  36. class Randomizer {
  37. function set_one()
  38. {
  39. $quotes = array(
  40. "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson",
  41. "Don't stay in bed, unless you can make money in bed. - George Burns",
  42. "We didn't lose the game; we just ran out of time. - Vince Lombardi",
  43. "If everything seems under control, you're not going fast enough. - Mario Andretti",
  44. "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein",
  45. "Adventure is worthwhile - Aesop",
  46. "No legacy is so rich as honesty - William Shakespeare",
  47. "You will never live if you are looking for the meaning of life - Albert Camus",
  48. "The price of anything is the amount of life you exchange for it - Henry David Thoreau",
  49. "Chance favors the prepared mind - Louis Pasteur",
  50. "Freedom of Press is limited to those who own one - H.L. Mencken",
  51. "I do not fear computers. I fear the lack of them - Isaac Asimov",
  52. "Never trust a computer you can't throw out a window - Steve Wozniak",
  53. "Do, or do not. There is no 'try'. - Yoda", // No comma after the last item
  54. );
  55. return $quotes[array_rand($quotes)];
  56. }
  57. // ----------------------------------------
  58. // Plugin Usage
  59. // ----------------------------------------
  60. // This function describes how the plugin is used.
  61. // Make sure and use output buffering
  62. function usage()
  63. {
  64. ob_start();
  65. ?>
  66. Open this file: /plugins/pi.randomizer.php
  67. Fill the array with as many quotes as you want.
  68. Then place the following tag in any of your templates:
  69. {exp:randomizer:set_one}
  70. <?php
  71. $buffer = ob_get_contents();
  72. ob_end_clean();
  73. return $buffer;
  74. }
  75. /* END */
  76. }
  77. ?>