A tumblelog CMS built on AJAX, PHP and MySQL.

plugin.class.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. if(array_key_exists($index,$this->actions[$name])){
  25. $action = $this->actions[$name][$index][1];
  26. if (is_callable(array($plugin, $action))) {
  27. //echo "ejecutar: ".$action."()<br/>";
  28. $plugin->$action();
  29. $index++;
  30. }
  31. }
  32. }
  33. }
  34. function exists($name) {
  35. if (isset($this->exists[$name])) {
  36. return $this->exists[$name];
  37. }
  38. foreach (plugins::$instances as $plugin) {
  39. /*print_r(plugins::$instances);
  40. echo "<br />";
  41. print_r($plugin);
  42. echo "<br />";
  43. print_r($this->actions[$name]);
  44. echo "<br />";
  45. echo $this->actions[$name][0][1];
  46. echo "<br />";*/
  47. if(array_key_exists($name,$this->actions)){
  48. if (is_callable(array($plugin, $this->actions[$name][0][1]))) {
  49. return $this->exists[$name] = true;
  50. }
  51. }
  52. }
  53. return $this->exists[$name] = false;
  54. }
  55. function & instance(){
  56. static $instance;
  57. if( !isset($instance) ) {
  58. $instance = new self();
  59. }
  60. return $instance;
  61. }
  62. }
  63. ?>