A tumblelog CMS built on AJAX, PHP and MySQL.

plugin.class.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. //$instance;
  59. if( !isset($GLOBALS['$instance']) ) {
  60. $GLOBALS['$instance'] = new plugin();
  61. }
  62. //print_r($GLOBALS['$instance']);
  63. //die();
  64. return $GLOBALS['$instance'];
  65. }
  66. }
  67. ?>