Changeset 14546


Ignore:
Timestamp:
04/30/12 01:58:44 (8 years ago)
Author:
plg
Message:

feature 2626: ability to upload a new watermark

Location:
trunk/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/configuration_watermark_process.inc.php

    r14513 r14546  
    2929$errors = array(); 
    3030$pwatermark = $_POST['w']; 
     31 
     32// step 0 - manage upload if any 
     33if (isset($_FILES['watermarkImage']) and !empty($_FILES['watermarkImage']['tmp_name'])) 
     34{ 
     35  list($width, $height, $type) = getimagesize($_FILES['watermarkImage']['tmp_name']); 
     36  if (IMAGETYPE_PNG != $type) 
     37  { 
     38    $errors['watermarkImage'] = 'PNG'; 
     39  } 
     40  else 
     41  { 
     42    $upload_dir = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'watermarks'; 
     43 
     44    include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 
     45    prepare_directory($upload_dir); 
     46 
     47    $new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png'; 
     48    $file_path = $upload_dir.'/'.$new_name;  
     49   
     50    move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path); 
     51     
     52    $pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH)); 
     53  } 
     54} 
    3155 
    3256// step 1 - sanitize HTML input 
  • trunk/admin/themes/default/template/configuration.tpl

    r14514 r14546  
    3434 
    3535{if !isset($default)} 
    36 <form method="post" action="{$F_ACTION}" class="properties"> 
     36<form method="post" action="{$F_ACTION}" class="properties"{if isset($watermark)} enctype="multipart/form-data"{/if}> 
    3737{/if} 
    3838<div id="configContent"> 
     
    480480    } 
    481481  }); 
     482 
     483  jQuery(".addWatermarkOpen").click(function(){ 
     484    jQuery("#addWatermark, #selectWatermark").toggle(); 
     485  }); 
    482486}); 
    483487{/literal}{/footer_script} 
    484  
    485488 
    486489<fieldset id="watermarkConf"> 
     
    488491  <ul> 
    489492    <li> 
    490       <label>{'Select a file'|@translate}</label> 
     493      <span id="selectWatermark"{if isset($ferrors.watermarkImage)} style="display:none"{/if}><label>{'Select a file'|@translate}</label> 
    491494      <select name="w[file]" id="wSelect"> 
    492495        {html_options options=$watermark_files selected=$watermark.file} 
    493496      </select> 
    494       <br>{'... or '|@translate}<a href="#" class="addWatermarkOpen" title="{'add a new watermark'|@translate}">{'add a new watermark'|@translate}</a> 
    495       <br><img id="wImg"></img> 
     497      {'... or '|@translate}<a href="#" class="addWatermarkOpen">{'add a new watermark'|@translate}</a> 
     498      <br><img id="wImg"></img></span>{* #selectWatermark *} 
     499      <span id="addWatermark"{if isset($ferrors.watermarkImage)} style="display:inline"{/if}> 
     500      <a href="#" class="addWatermarkOpen">{'add a new watermark'|@translate}</a> (png) 
     501      <br><input type="file" size="60" id="watermarkImage" name="watermarkImage"{if isset($ferrors.watermarkImage)} class="dError"{/if}> 
     502      {if isset($ferrors.watermarkImage)}<span class="dErrorDesc" title="{$ferrors.watermarkImage}">!</span>{/if} 
     503      </span>{* #addWatermark *} 
    496504    </li> 
    497505 
  • trunk/admin/themes/default/theme.css

    r14514 r14546  
    11131113.dErrorDesc {background-color:red; color:white; padding:0 5px;border-radius:10px; font-weight:bold;cursor:help;} 
    11141114 
    1115 #wImg {max-height:100px;border:2px solid #ccc;} 
     1115#wImg {max-height:100px;border:2px solid #ccc;margin-top:5px;} 
     1116#addWatermark {display:none;} 
Note: See TracChangeset for help on using the changeset viewer.