Changeset 1327 for bb-attachments

Show
Ignore:
Timestamp:
09/04/08 07:13:15 (3 months ago)
Author:
_ck_
Message:

0.1.11 now can auto-insert images into post after upload (default)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bb-attachments/trunk/bb-attachments.php

    r1318 r1327  
    66Author: _ck_ 
    77Author URI: http://bbShowcase.org 
    8 Version: 0.1.10 
     8Version: 0.1.11 
    99 
    1010License: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ 
     
    4545$bb_attachments['inline']['solution']="resize"; // resize|frame - images can be either resized or CSS framed to meet above requirement 
    4646                                                                        // only resize is supported at this time 
     47$bb_attachments['inline']['auto']=true;         // auto insert uploaded images into post 
     48 
    4749$bb_attachments['style']=".bb_attachments_link, .bb_attachments_link img {border:0; text-decoration:none; background:none;} #thread .post li {clear:none;}"; 
    4850 
     
    247249 
    248250$user_ip=$_SERVER["REMOTE_ADDR"];       // $GLOBALS["HTTP_SERVER_VARS"]["REMOTE_ADDR"]; 
    249 $time=time();                                          
     251$time=time();   $inject="";                                    
    250252 
    251253$bb_post=bb_get_post($post_id);  $topic_id=$bb_post->topic_id;  // fetch related topic 
     
    331333                        $error=""; if ($_FILES['bb_attachments']['error'][$key]>0) {$error=" (".$bb_attachments['errors'][$_FILES['bb_attachments']['error'][$key]].") ";} 
    332334                        $output.="<li><span style='color:red'><strong>$filename "." <span class='num'>(".round($size/1024,1)." KB)</span> ".__('error:')." ".$bb_attachments['status'][$status]."</strong>$error</span></li>"; 
    333                 } else {$output.="<li><span style='color:green'><strong>$filename "." <span class='num'>(".round($size/1024,1)." KB)</span> ".__('successful')."</strong></span></li>";} 
     335                } else {$output.="<li><span style='color:green'><strong>$filename "." <span class='num'>(".round($size/1024,1)." KB)</span> ".__('successful')."</strong></span></li>";                   
     336                        if ($bb_attachments['inline']['auto']) { 
     337                        if ($display) { 
     338                                $location = bb_attachments_location();   $can_inline=true; 
     339                                if (!($bb_attachments['role']['inline']=="read" || bb_current_user_can($bb_attachments['role']['inline']))) {$can_inline=false;} 
     340                                if ($location=="edit.php" && $can_inline) { 
     341                                        $output.='<scr'.'ipt type="text/javascript" defer="defer">                       
     342                                        bbat_field = document.getElementsByTagName("textarea")[0]; 
     343                                        bbat_value=" [attachment="+'.$post_id.'+","+'.$id.'+"] "; 
     344                                        bbat_field.value += bbat_value;</script>'; 
     345                                } // above auto-injects newly uploaded attachment if edit form present 
     346                        } else {        $inject.=" [attachment=$post_id,$id]";} 
     347                        } 
     348                } 
    334349        } // end !$empty 
    335350} // end while 
    336351$output.="</ol>"; 
    337 if ($display) {echo $output;} 
     352if ($display) {echo $output;}  
     353elseif (!empty($inject) && $bb_attachments['inline']['auto']) {$bb_post->post_text=apply_filters('edit_text', $bb_post->post_text.$inject); bb_insert_post($bb_post);} // auto-inject  
    338354bb_update_topicmeta( $topic_id, 'bb_attachments', $topic_attachments+$offset); 
    339355} 
  • bb-attachments/trunk/readme.txt

    r1206 r1327  
    5656* 0.1.8 workaround for lack of apache_request_headers, javascript insert bug 
    5757* 0.1.9 handle missing inline images a bit better with "x" icon 
     58* 0.1.11 now can auto-insert images into post after upload (default) 
    5859         
    5960== To Do ==