Part.class.php 917 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Define a part.
  4. * @author Idleman
  5. * @category Plugin
  6. * @license copyright
  7. */
  8. class Part extends Entity{
  9. public $id,$label,$price,$link,$brand,$state;
  10. protected $TABLE_NAME = 'hackpoint_part';
  11. public $fields =
  12. array(
  13. 'id' => 'key',
  14. 'label' => 'string',
  15. 'price' => 'float',
  16. 'link' => 'longstring',
  17. 'state' => 'string',
  18. 'brand' => 'string'
  19. );
  20. public $links = array(
  21. );
  22. public function picture($toStream = false){
  23. $folder = File::dir().'hackpoint'.SLASH.'part'.SLASH.$this->id;
  24. if(!file_exists($folder)) mkdir($folder,0755,true);
  25. $picture = $folder.SLASH.'cover.jpg';
  26. if(!file_exists($picture)){
  27. copy(__DIR__.SLASH.'img'.SLASH.'default-part.png',$picture);
  28. }
  29. if($toStream) return 'image/jpeg;base64,'.base64_encode(file_get_contents($picture));
  30. return 'action.php?action=hackpoint_download_file&file='.base64_encode('part'.SLASH.$this->id.SLASH.'cover.jpg');
  31. }
  32. }
  33. ?>