A tumblelog CMS built on AJAX, PHP and MySQL.

plugin.class.php 1.9KB

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