Part.class.php 812 B

12345678910111213141516171819202122232425262728293031323334
  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(){
  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. return 'action.php?action=hackpoint_download_file&file='.base64_encode('part'.SLASH.$this->id.SLASH.'cover.jpg');
  30. }
  31. }
  32. ?>