1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- /**
- * Define a part.
- * @author Idleman
- * @category Plugin
- * @license copyright
- */
- class Part extends Entity{
- public $id,$label,$price,$link,$brand,$state;
- protected $TABLE_NAME = 'hackpoint_part';
- public $fields =
- array(
- 'id' => 'key',
- 'label' => 'string',
- 'price' => 'float',
- 'link' => 'longstring',
- 'state' => 'string',
- 'brand' => 'string'
- );
- public $links = array(
- );
- public function picture($toStream = false){
- $folder = File::dir().'hackpoint'.SLASH.'part'.SLASH.$this->id;
- if(!file_exists($folder)) mkdir($folder,0755,true);
- $picture = $folder.SLASH.'cover.jpg';
- if(!file_exists($picture)){
- copy(__DIR__.SLASH.'img'.SLASH.'default-part.png',$picture);
- }
- if($toStream) return 'image/jpeg;base64,'.base64_encode(file_get_contents($picture));
- return 'action.php?action=hackpoint_download_file&file='.base64_encode('part'.SLASH.$this->id.SLASH.'cover.jpg');
- }
- }
- ?>
|