A tumblelog CMS built on AJAX, PHP and MySQL.

plugin.class.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. if(!defined('entry') || !entry) die('Not a valid page');
  3. /* ===========================
  4. gelato CMS - A PHP based tumblelog CMS
  5. development version
  6. http://www.gelatocms.com/
  7. gelato CMS is a free software licensed under the GPL 2.0
  8. Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
  9. =========================== */
  10. ?>
  11. <?php
  12. class plugin {
  13. var $actions = array();
  14. var $exists = array();
  15. function call($name) {
  16. if (!$this->exists($name)) {
  17. return false;
  18. }
  19. /*echo "<br />==========<br />";
  20. echo $name;
  21. echo "<br />";*/
  22. $index = 0;
  23. foreach (plugins::$instances as $plugin) {
  24. $action = $this->actions[$name][$index][1];
  25. if (is_callable(array($plugin, $action))) {
  26. $plugin->$action();
  27. }
  28. $index++;
  29. }
  30. }
  31. function exists($name) {
  32. if (isset($this->exists[$name])) {
  33. return $this->exists[$name];
  34. }
  35. foreach (plugins::$instances as $plugin) {
  36. /*print_r(plugins::$instances);
  37. echo "<br />";
  38. print_r($plugin);
  39. echo "<br />";
  40. print_r($this->actions[$name]);
  41. echo "<br />";
  42. echo $this->actions[$name][0][1];
  43. echo "<br />";*/
  44. if (is_callable(array($plugin, $this->actions[$name][0][1]))) {
  45. return $this->exists[$name] = true;
  46. }
  47. }
  48. return $this->exists[$name] = false;
  49. }
  50. function & instance()
  51. {
  52. static $instance;
  53. if( !isset($instance) ) {
  54. $instance = new self();
  55. }
  56. return $instance;
  57. }
  58. }
  59. ?>