ResourceType.class.php 942 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. class ResourceType{
  3. public $user,$type;
  4. protected $fields =
  5. array(
  6. 'id' => 'key',
  7. 'user' => 'string',
  8. 'type' => 'string'
  9. );
  10. public static function all($target=null){
  11. $rawtypes = array();
  12. Plugin::callHook('resource_type',array(&$rawtypes));
  13. $types = array();
  14. foreach($rawtypes as $uid=>$file){
  15. if(isset($target) && $uid!=$target) continue;
  16. $class = str_replace('.class.php','',basename($file));
  17. require_once($file);
  18. if(!method_exists ( $class , 'toHtml' )) continue;
  19. if(!method_exists ( $class , 'toJson' )) continue;
  20. if(!method_exists ( $class , 'toFile' )) continue;
  21. if(!method_exists ( $class , 'fromJson' )) continue;
  22. if(!method_exists ( $class , 'fromFile' )) continue;
  23. $types[$uid] = $class::manifest();
  24. $types[$uid]['file'] =$file;
  25. $types[$uid]['class'] = $class;
  26. }
  27. return isset($target) ? $types[$target] : $types;
  28. }
  29. }
  30. ?>