Changeset 2566:9bf417837888 for inc/core/class.dc.media.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.media.php
r2098 r2566 26 26 protected $postmedia; 27 27 protected $file_sort = 'name-asc'; 28 28 29 29 protected $file_handler = array(); ///< <b>array</b> Array of callbacks 30 30 31 31 public $thumb_tp = '%s/.%s_%s.jpg'; ///< <b>string</b> Thumbnail file pattern 32 32 public $thumb_tp_alpha = '%s/.%s_%s.png'; ///< <b>string</b> Thumbnail file pattern (with alpha layer) 33 33 34 34 /** 35 35 <b>array</b> Tubmnail sizes: … … 39 39 - sq: square image 40 40 */ 41 public $thumb_sizes = array( 41 public $thumb_sizes = array( 42 42 'm' => array(448,'ratio','medium'), 43 43 's' => array(240,'ratio','small'), … … 45 45 'sq' => array(48,'crop','square') 46 46 ); 47 47 48 48 public $icon_img = 'images/media/%s.png'; ///< <b>string</b> Icon file pattern 49 49 50 50 /** 51 51 Object constructor. 52 52 53 53 @param core <b>dcCore</b> dcCore instance 54 54 @param type <b>string</b> Media type filter … … 59 59 $this->con =& $core->con; 60 60 $this->postmedia = new dcPostMedia($core); 61 61 62 62 if ($this->core->blog == null) { 63 63 throw new Exception(__('No blog defined.')); 64 64 } 65 65 66 66 $this->table = $this->core->prefix.'media'; 67 67 $root = $this->core->blog->public_path; 68 68 69 69 if (preg_match('#^http(s)?://#',$this->core->blog->settings->system->public_url)) { 70 70 $root_url = rawurldecode($this->core->blog->settings->system->public_url); … … 72 72 $root_url = rawurldecode($this->core->blog->host.path::clean($this->core->blog->settings->system->public_url)); 73 73 } 74 74 75 75 if (!is_dir($root)) { 76 76 # Check public directory … … 81 81 } 82 82 } 83 83 84 84 $this->type = $type; 85 85 86 86 parent::__construct($root,$root_url); 87 87 $this->chdir(''); 88 88 89 89 $this->path = $this->core->blog->settings->system->public_path; 90 90 91 91 $this->addExclusion(DC_RC_PATH); 92 92 $this->addExclusion(dirname(__FILE__).'/../'); 93 93 94 94 $this->exclude_pattern = $core->blog->settings->system->media_exclusion; 95 95 96 96 # Event handlers 97 97 $this->addFileHandler('image/jpeg','create',array($this,'imageThumbCreate')); 98 98 $this->addFileHandler('image/png','create',array($this,'imageThumbCreate')); 99 99 $this->addFileHandler('image/gif','create',array($this,'imageThumbCreate')); 100 100 101 101 $this->addFileHandler('image/png','update',array($this,'imageThumbUpdate')); 102 102 $this->addFileHandler('image/jpeg','update',array($this,'imageThumbUpdate')); 103 103 $this->addFileHandler('image/gif','update',array($this,'imageThumbUpdate')); 104 104 105 105 $this->addFileHandler('image/png','remove',array($this,'imageThumbRemove')); 106 106 $this->addFileHandler('image/jpeg','remove',array($this,'imageThumbRemove')); 107 107 $this->addFileHandler('image/gif','remove',array($this,'imageThumbRemove')); 108 108 109 109 $this->addFileHandler('image/jpeg','create',array($this,'imageMetaCreate')); 110 110 111 111 $this->addFileHandler('image/jpeg','recreate',array($this,'imageThumbCreate')); 112 112 $this->addFileHandler('image/png','recreate',array($this,'imageThumbCreate')); 113 113 $this->addFileHandler('image/gif','recreate',array($this,'imageThumbCreate')); 114 114 115 115 $this->addFileHandler('image/jpeg','recreate',array($this,'imageThumbCreate')); 116 116 $this->addFileHandler('image/png','recreate',array($this,'imageThumbCreate')); 117 117 $this->addFileHandler('image/gif','recreate',array($this,'imageThumbCreate')); 118 118 119 119 # Thumbnails sizes 120 120 $this->thumb_sizes['m'][0] = abs($core->blog->settings->system->media_img_m_size); 121 121 $this->thumb_sizes['s'][0] = abs($core->blog->settings->system->media_img_s_size); 122 122 $this->thumb_sizes['t'][0] = abs($core->blog->settings->system->media_img_t_size); 123 123 124 124 # Thumbnails sizes names 125 125 $this->thumb_sizes['m'][2] = __($this->thumb_sizes['m'][2]); … … 127 127 $this->thumb_sizes['t'][2] = __($this->thumb_sizes['t'][2]); 128 128 $this->thumb_sizes['sq'][2] = __($this->thumb_sizes['sq'][2]); 129 129 130 130 # --BEHAVIOR-- coreMediaConstruct 131 $this->core->callBehavior('coreMediaConstruct',$this); 132 } 133 131 $this->core->callBehavior('coreMediaConstruct',$this); 132 } 133 134 134 /** 135 135 Changes working directory. 136 136 137 137 @param dir <b>string</b> Directory name. 138 138 */ … … 142 142 $this->relpwd = preg_replace('/^'.preg_quote($this->root,'/').'\/?/','',$this->pwd); 143 143 } 144 144 145 145 /** 146 146 Adds a new file handler for a given media type and event. 147 147 148 148 Available events are: 149 149 - create: file creation 150 150 - update: file update 151 151 - remove: file deletion 152 152 153 153 @param type <b>string</b> Media type 154 154 @param event <b>string</b> Event … … 161 161 } 162 162 } 163 163 164 164 protected function callFileHandler($type,$event) 165 165 { … … 169 169 array_shift($args); 170 170 array_shift($args); 171 171 172 172 foreach ($this->file_handler[$type][$event] as $f) 173 173 { … … 176 176 } 177 177 } 178 178 179 179 /** 180 180 Returns HTML breadCrumb for media manager navigation. 181 181 182 182 @param href <b>string</b> URL pattern 183 183 @param last <b>string</b> Last item pattern … … 201 201 } 202 202 return $res; 203 204 } 205 203 204 } 205 206 206 protected function fileRecord($rs) 207 207 { 208 208 if ($rs->isEmpty()) { return null; } 209 209 210 210 if (!$this->isFileExclude($this->root.'/'.$rs->media_file) && is_file($this->root.'/'.$rs->media_file)) 211 211 { 212 212 $f = new fileItem($this->root.'/'.$rs->media_file,$this->root,$this->root_url); 213 213 214 214 if ($this->type && $f->type_prefix != $this->type) { 215 215 return null; 216 216 } 217 217 218 218 $meta = @simplexml_load_string($rs->media_meta); 219 219 220 220 $f->editable = true; 221 221 $f->media_id = $rs->media_id; … … 226 226 $f->media_dt = strtotime($rs->media_dt); 227 227 $f->media_dtstr = dt::str('%Y-%m-%d %H:%M',$f->media_dt); 228 228 229 229 $f->media_image = false; 230 230 231 231 if (!$this->core->auth->check('media_admin',$this->core->blog->id) 232 232 && $this->core->auth->userID() != $f->media_user) { … … 234 234 $f->editable = false; 235 235 } 236 236 237 237 $type_prefix = explode('/',$f->type); 238 238 $type_prefix = $type_prefix[0]; 239 239 240 240 switch ($type_prefix) { 241 241 case 'image': … … 297 297 break; 298 298 } 299 299 300 300 $f->media_type = $f->media_icon; 301 301 $f->media_icon = sprintf($this->icon_img,$f->media_icon); 302 302 303 303 # Thumbnails 304 304 $f->media_thumb = array(); … … 309 309 $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$this->root.'/'.$p['dirname'],$p['base'],'%s'); 310 310 $thumb_url = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$this->root_url.$p['dirname'],$p['base'],'%s'); 311 311 312 312 # Cleaner URLs 313 313 $thumb_url = preg_replace('#\./#','/',$thumb_url); … … 321 321 $thumb_url_alt = preg_replace('#(?<!:)/+#','/',$thumb_url_alt); 322 322 } 323 323 324 324 foreach ($this->thumb_sizes as $suffix => $s) { 325 325 if (file_exists(sprintf($thumb,$suffix))) { … … 329 329 } 330 330 } 331 331 332 332 if (isset($f->media_thumb['sq']) && $f->media_type == 'image') { 333 333 $f->media_icon = $f->media_thumb['sq']; 334 334 } 335 335 336 336 return $f; 337 337 } 338 338 339 339 return null; 340 340 } 341 342 341 342 343 343 public function setFileSort($type='name') 344 344 { … … 347 347 } 348 348 } 349 349 350 350 protected function sortFileHandler($a,$b) 351 351 { … … 368 368 return strcasecmp($a->basename,$b->basename); 369 369 } 370 370 371 371 } 372 372 … … 381 381 382 382 /** 383 Gets current working directory content. 384 383 Gets current working directory content. 384 385 385 @param type <b>string</b> Media type filter 386 386 */ … … 390 390 $this->type = $type; 391 391 } 392 392 393 393 $media_dir = $this->relpwd ? $this->relpwd : '.'; 394 394 395 395 $strReq = 396 396 'SELECT media_file, media_id, media_path, media_title, media_meta, media_dt, '. … … 399 399 "WHERE media_path = '".$this->path."' ". 400 400 "AND media_dir = '".$this->con->escape($media_dir)."' "; 401 401 402 402 if (!$this->core->auth->check('media_admin',$this->core->blog->id)) 403 403 { 404 404 $strReq .= 'AND (media_private <> 1 '; 405 405 406 406 if ($this->core->auth->userID()) { 407 407 $strReq .= "OR user_id = '".$this->con->escape($this->core->auth->userID())."'"; … … 409 409 $strReq .= ') '; 410 410 } 411 411 412 412 $rs = $this->con->select($strReq); 413 413 414 414 parent::getDir(); 415 415 416 416 $f_res = array(); 417 417 $p_dir = $this->dir; 418 418 419 419 # If type is set, remove items from p_dir 420 420 if ($this->type) … … 426 426 } 427 427 } 428 428 429 429 $f_reg = array(); 430 430 431 431 while ($rs->fetch()) 432 432 { … … 435 435 continue; 436 436 } 437 437 438 438 if ($this->inFiles($rs->media_file)) 439 439 { … … 442 442 if (isset($f_reg[$rs->media_file])) 443 443 { 444 # That media is duplicated in the database, 444 # That media is duplicated in the database, 445 445 # time to do a bit of house cleaning. 446 446 $this->con->execute( … … 468 468 } 469 469 } 470 470 471 471 $this->dir['files'] = $f_res; 472 472 foreach ($this->dir['dirs'] as $k => $v) { 473 473 $v->media_icon = sprintf($this->icon_img,($v->parent ? 'folder-up' : 'folder')); 474 474 } 475 475 476 476 # Check files that don't exist in database and create them 477 477 if ($this->core->auth->check('media,media_admin',$this->core->blog->id)) … … 488 488 usort($this->dir['files'],array($this,'sortFileHandler')); 489 489 } 490 490 491 491 /** 492 492 Gets file by its id. Returns a filteItem object. 493 493 494 494 @param id <b>integer</b> File ID 495 495 @return <b>fileItem</b> … … 504 504 "WHERE media_path = '".$this->path."' ". 505 505 'AND media_id = '.(integer) $id.' '; 506 506 507 507 if (!$this->core->auth->check('media_admin',$this->core->blog->id)) 508 508 { 509 509 $strReq .= 'AND (media_private <> 1 '; 510 510 511 511 if ($this->core->auth->userID()) { 512 512 $strReq .= "OR user_id = '".$this->con->escape($this->core->auth->userID())."'"; … … 514 514 $strReq .= ') '; 515 515 } 516 516 517 517 $rs = $this->con->select($strReq); 518 518 return $this->fileRecord($rs); 519 519 } 520 520 521 521 /** 522 522 Returns media items attached to a blog post. Result is an array containing 523 523 fileItems objects. 524 524 525 525 @param post_id <b>integer</b> Post ID 526 526 @param media_id <b>integer</b> Optionnal media ID … … 537 537 } 538 538 $rs = $this->postmedia->getPostMedia($params); 539 539 540 540 $res = array(); 541 541 542 542 while ($rs->fetch()) { 543 543 $f = $this->fileRecord($rs); … … 546 546 } 547 547 } 548 548 549 549 return $res; 550 550 } 551 551 552 552 /** 553 553 @deprecated since version 2.4 … … 558 558 $this->postmedia->addPostMedia($post_id,$media_id); 559 559 } 560 560 561 561 /** 562 562 @deprecated since version 2.4 … … 567 567 $this->postmedia->removePostMedia($post_id,$media_id,"attachment"); 568 568 } 569 569 570 570 /** 571 571 Rebuilds database items collection. Optional <var>$pwd</var> parameter is 572 572 the path where to start rebuild. 573 573 574 574 @param pwd <b>string</b> Directory to rebuild 575 575 */ … … 579 579 throw new Exception(__('You are not a super administrator.')); 580 580 } 581 581 582 582 $this->chdir($pwd); 583 583 parent::getDir(); 584 584 585 585 $dir = $this->dir; 586 586 587 587 foreach ($dir['dirs'] as $d) { 588 588 if (!$d->parent) { … … 590 590 } 591 591 } 592 592 593 593 foreach ($dir['files'] as $f) { 594 594 $this->chdir(dirname($f->relname)); 595 595 $this->createFile($f->basename); 596 596 } 597 597 598 598 $this->rebuildDB($pwd); 599 599 } 600 600 601 601 protected function rebuildDB($pwd) 602 602 { 603 603 $media_dir = $pwd ? $pwd : '.'; 604 604 605 605 $strReq = 606 606 'SELECT media_file, media_id '. … … 608 608 "WHERE media_path = '".$this->path."' ". 609 609 "AND media_dir = '".$this->con->escape($media_dir)."' "; 610 610 611 611 $rs = $this->con->select($strReq); 612 612 613 613 $delReq = 'DELETE FROM '.$this->table.' '. 614 614 'WHERE media_id IN (%s) '; 615 615 $del_ids = array(); 616 616 617 617 while ($rs->fetch()) 618 618 { … … 621 621 } 622 622 } 623 623 624 624 if (!empty($del_ids)) { 625 625 $this->con->execute(sprintf($delReq,implode(',',$del_ids))); 626 626 } 627 627 } 628 628 629 629 public function makeDir($d) 630 630 { … … 632 632 parent::makeDir($d); 633 633 } 634 634 635 635 /** 636 636 Creates or updates a file in database. Returns new media ID or false if 637 637 file does not exist. 638 638 639 639 @param name <b>string</b> File name (relative to working directory) 640 640 @param title <b>string</b> File title … … 648 648 throw new Exception(__('Permission denied.')); 649 649 } 650 650 651 651 $file = $this->pwd.'/'.$name; 652 652 if (!file_exists($file)) { 653 653 return false; 654 654 } 655 655 656 656 $media_file = $this->relpwd ? path::clean($this->relpwd.'/'.$name) : path::clean($name); 657 657 $media_type = files::getMimeType($name); 658 658 659 659 $cur = $this->con->openCursor($this->table); 660 660 661 661 $strReq = 'SELECT media_id '. 662 662 'FROM '.$this->table.' '. 663 663 "WHERE media_path = '".$this->con->escape($this->path)."' ". 664 664 "AND media_file = '".$this->con->escape($media_file)."' "; 665 665 666 666 $rs = $this->con->select($strReq); 667 667 668 668 if ($rs->isEmpty()) 669 669 { … … 673 673 $rs = $this->con->select('SELECT MAX(media_id) FROM '.$this->table); 674 674 $media_id = (integer) $rs->f(0) + 1; 675 675 676 676 $cur->media_id = $media_id; 677 677 $cur->user_id = (string) $this->core->auth->userID(); … … 681 681 $cur->media_creadt = date('Y-m-d H:i:s'); 682 682 $cur->media_upddt = date('Y-m-d H:i:s'); 683 683 684 684 $cur->media_title = !$title ? (string) $name : (string) $title; 685 685 $cur->media_private = (integer) (boolean) $private; 686 686 687 687 if ($dt) { 688 688 $cur->media_dt = (string) $dt; … … 690 690 $cur->media_dt = strftime('%Y-%m-%d %H:%M:%S',filemtime($file)); 691 691 } 692 692 693 693 try { 694 694 $cur->insert(); … … 708 708 { 709 709 $media_id = (integer) $rs->media_id; 710 710 711 711 $cur->media_upddt = date('Y-m-d H:i:s'); 712 712 713 713 $cur->update('WHERE media_id = '.$media_id); 714 714 } 715 715 716 716 $this->callFileHandler($media_type,'create',$cur,$name,$media_id,$force); 717 717 718 718 return $media_id; 719 719 } 720 720 721 721 /** 722 722 Updates a file in database. 723 723 724 724 @param file <b>fileItem</b> Current fileItem object 725 725 @param newFile <b>fileItem</b> New fileItem object … … 730 730 throw new Exception(__('Permission denied.')); 731 731 } 732 732 733 733 $id = (integer) $file->media_id; 734 734 735 735 if (!$id) { 736 736 throw new Exception('No file ID'); 737 737 } 738 738 739 739 if (!$this->core->auth->check('media_admin',$this->core->blog->id) 740 740 && $this->core->auth->userID() != $file->media_user) { 741 741 throw new Exception(__('You are not the file owner.')); 742 742 } 743 743 744 744 $cur = $this->con->openCursor($this->table); 745 745 746 746 # We need to tidy newFile basename. If dir isn't empty, concat to basename 747 747 $newFile->relname = files::tidyFileName($newFile->basename); … … 749 749 $newFile->relname = $newFile->dir.'/'.$newFile->relname; 750 750 } 751 751 752 752 if ($file->relname != $newFile->relname) { 753 753 $newFile->file = $this->root.'/'.$newFile->relname; 754 754 755 755 if ($this->isFileExclude($newFile->relname)) { 756 756 throw new Exception(__('This file is not allowed.')); 757 757 } 758 758 759 759 if (file_exists($newFile->file)) { 760 760 throw new Exception(__('New file already exists.')); 761 761 } 762 762 763 763 $this->moveFile($file->relname,$newFile->relname); 764 764 765 765 $cur->media_file = (string) $newFile->relname; 766 766 $cur->media_dir = (string) dirname($newFile->relname); 767 767 } 768 768 769 769 $cur->media_title = (string) $newFile->media_title; 770 770 $cur->media_dt = (string) $newFile->media_dtstr; 771 771 $cur->media_upddt = date('Y-m-d H:i:s'); 772 772 $cur->media_private = (integer) $newFile->media_priv; 773 773 774 774 $cur->update('WHERE media_id = '.$id); 775 775 776 776 $this->callFileHandler($file->type,'update',$file,$newFile); 777 777 } 778 778 779 779 /** 780 780 Uploads a file. 781 781 782 782 @param tmp <b>string</b> Full path of temporary uploaded file 783 783 @param name <b>string</b> File name (relative to working directory) … … 790 790 throw new Exception(__('Permission denied.')); 791 791 } 792 792 793 793 $name = files::tidyFileName($name); 794 794 795 795 parent::uploadFile($tmp,$name,$overwrite); 796 796 797 797 return $this->createFile($name,$title,$private); 798 798 } 799 799 800 800 /** 801 801 Creates a file from binary content. 802 802 803 803 @param name <b>string</b> File name (relative to working directory) 804 804 @param bits <b>string</b> Binary file content … … 809 809 throw new Exception(__('Permission denied.')); 810 810 } 811 811 812 812 $name = files::tidyFileName($name); 813 813 814 814 parent::uploadBits($name,$bits); 815 815 816 816 return $this->createFile($name,null,null); 817 817 } 818 818 819 819 /** 820 820 Removes a file. 821 821 822 822 @param f <b>fileItem</b> fileItem object 823 823 */ … … 827 827 throw new Exception(__('Permission denied.')); 828 828 } 829 829 830 830 $media_file = $this->relpwd ? path::clean($this->relpwd.'/'.$f) : path::clean($f); 831 831 832 832 $strReq = 'DELETE FROM '.$this->table.' '. 833 833 "WHERE media_path = '".$this->con->escape($this->path)."' ". 834 834 "AND media_file = '".$this->con->escape($media_file)."' "; 835 835 836 836 if (!$this->core->auth->check('media_admin',$this->core->blog->id)) 837 837 { 838 838 $strReq .= "AND user_id = '".$this->con->escape($this->core->auth->userID())."'"; 839 839 } 840 840 841 841 $this->con->execute($strReq); 842 842 843 843 if ($this->con->changes() == 0) { 844 844 throw new Exception(__('File does not exist in the database.')); 845 845 } 846 846 847 847 parent::removeFile($f); 848 848 849 849 $this->callFileHandler(files::getMimeType($media_file),'remove',$f); 850 850 } … … 861 861 { 862 862 $media_dir = $this->relpwd ? $this->relpwd : '.'; 863 863 864 864 $strReq = 865 865 'SELECT distinct media_dir '. … … 871 871 $dir[] = ($rs->media_dir == '.' ? '' : $rs->media_dir); 872 872 } 873 873 874 874 return $dir; 875 875 } 876 876 877 877 /** 878 878 Extract zip file in current location 879 879 880 880 @param f <b>fileRecord</b> fileRecord object 881 881 */ … … 885 885 $zip->setExcludePattern($this->exclude_pattern); 886 886 $zip->getList(false,'#(^|/)(__MACOSX|\.svn|\.DS_Store|\.directory|Thumbs\.db)(/|$)#'); 887 887 888 888 if ($create_dir) 889 889 { … … 896 896 $target = $f->dir.'/'.$destination; 897 897 } 898 898 899 899 if (is_dir($f->dir.'/'.$destination)) { 900 throw new Exception(sprintf(__('Extract destination directory %s already exists.'),dirname($f->relname).'/'.$destination)); 900 throw new Exception(sprintf(__('Extract destination directory %s already exists.'),dirname($f->relname).'/'.$destination)); 901 901 } 902 902 } … … 906 906 $destination = ''; 907 907 } 908 908 909 909 $zip->unzipAll($target); 910 910 $zip->close(); 911 911 return dirname($f->relname).'/'.$destination; 912 912 } 913 913 914 914 /** 915 915 Returns zip file content 916 916 917 917 @param f <b>fileRecord</b> fileRecord object 918 918 @return <b>array</b> … … 928 928 /** 929 929 Calls file handlers registered for recreate event 930 930 931 931 @param f <b>fileItem</b> fileItem object 932 932 */ … … 936 936 $this->callFileHandler($media_type,'recreate',null,$f->basename); // Args list to be completed as necessary (Franck) 937 937 } 938 938 939 939 /* Image handlers 940 940 ------------------------------------------------------- */ … … 942 942 { 943 943 $file = $this->pwd.'/'.$f; 944 944 945 945 if (!file_exists($file)) { 946 946 return false; 947 947 } 948 948 949 949 $p = path::info($file); 950 950 $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 951 951 $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$p['dirname'],$p['base'],'%s'); 952 952 953 953 try 954 954 { 955 955 $img = new imageTools(); 956 956 $img->loadImage($file); 957 957 958 958 $w = $img->getW(); 959 959 $h = $img->getH(); 960 960 961 961 if ($force) $this->imageThumbRemove($f); 962 962 963 963 foreach ($this->thumb_sizes as $suffix => $s) { 964 964 $thumb_file = sprintf($thumb,$suffix); … … 981 981 } 982 982 } 983 983 984 984 protected function imageThumbUpdate($file,$newFile) 985 985 { … … 989 989 $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 990 990 $thumb_old = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$p['dirname'],$p['base'],'%s'); 991 991 992 992 $p = path::info($newFile->relname); 993 993 $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 994 994 $thumb_new = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),$p['dirname'],$p['base'],'%s'); 995 995 996 996 foreach ($this->thumb_sizes as $suffix => $s) { 997 997 try { … … 1001 1001 } 1002 1002 } 1003 1003 1004 1004 protected function imageThumbRemove($f) 1005 1005 { … … 1007 1007 $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 1008 1008 $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp),'',$p['base'],'%s'); 1009 1009 1010 1010 foreach ($this->thumb_sizes as $suffix => $s) { 1011 1011 try { … … 1014 1014 } 1015 1015 } 1016 1016 1017 1017 protected function imageMetaCreate($cur,$f,$id) 1018 1018 { 1019 1019 $file = $this->pwd.'/'.$f; 1020 1020 1021 1021 if (!file_exists($file)) { 1022 1022 return false; 1023 1023 } 1024 1024 1025 1025 $xml = new xmlTag('meta'); 1026 1026 $meta = imageMeta::readMeta($file); 1027 1027 $xml->insertNode($meta); 1028 1028 1029 1029 $c = $this->core->con->openCursor($this->table); 1030 1030 $c->media_meta = $xml->toXML(); 1031 1031 1032 1032 if ($cur->media_title !== null && $cur->media_title == basename($cur->media_file)) 1033 1033 { … … 1036 1036 } 1037 1037 } 1038 1038 1039 1039 if ($meta['DateTimeOriginal'] && $cur->media_dt === '') 1040 1040 { … … 1046 1046 } 1047 1047 } 1048 1048 1049 1049 $c->update('WHERE media_id = '.$id); 1050 1050 } 1051 1051 1052 1052 /** 1053 1053 Returns HTML code for MP3 player 1054 1054 1055 1055 @param url <b>string</b> MP3 URL to play 1056 1056 @param player <b>string</b> Player URL … … 1063 1063 $player = 'player_mp3.swf'; 1064 1064 } 1065 1065 1066 1066 if (!is_array($args)) 1067 1067 { … … 1078 1078 ); 1079 1079 } 1080 1080 1081 1081 $args['mp3'] = $url; 1082 1082 1083 1083 if (empty($args['width'])) { 1084 1084 $args['width'] = 200; … … 1087 1087 $args['height'] = 20; 1088 1088 } 1089 1089 1090 1090 $vars = array(); 1091 1091 foreach ($args as $k => $v) { 1092 1092 $vars[] = $k.'='.$v; 1093 1093 } 1094 1094 1095 1095 return 1096 1096 '<object type="application/x-shockwave-flash" '. … … 1103 1103 '</object>'; 1104 1104 } 1105 1105 1106 1106 public static function flvplayer($url,$player=null,$args=null) 1107 1107 { … … 1109 1109 $player = 'player_flv.swf'; 1110 1110 } 1111 1111 1112 1112 if (!is_array($args)) 1113 1113 { … … 1123 1123 ); 1124 1124 } 1125 1125 1126 1126 $args['flv'] = $url; 1127 1127 1128 1128 if (empty($args['width'])) { 1129 1129 $args['width'] = 400; … … 1132 1132 $args['height'] = 300; 1133 1133 } 1134 1134 1135 1135 $vars = array(); 1136 1136 foreach ($args as $k => $v) { 1137 1137 $vars[] = $k.'='.$v; 1138 1138 } 1139 1139 1140 1140 return 1141 1141 '<object type="application/x-shockwave-flash" '. … … 1150 1150 } 1151 1151 } 1152 ?>
Note: See TracChangeset
for help on using the changeset viewer.