Changeset 12609


Ignore:
Timestamp:
11/12/11 12:03:29 (8 years ago)
Author:
mistic100
Message:

move subscriptions fieldset to the bottom of the page

Location:
extensions/Subscribe_to_comments
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/Subscribe_to_comments/include/functions.inc.php

    r12607 r12609  
    9898   
    9999  // check email 
    100   if ( is_a_guest() and empty($email) ) 
     100  if ( ( is_a_guest() or empty($user['email']) ) and empty($email) ) 
    101101  { 
    102102    return false; 
     
    175175   
    176176  // check email 
    177   if ( is_a_guest() and empty($email) ) 
     177  if ( ( is_a_guest() or empty($user['email']) ) and empty($email) ) 
    178178  { 
    179179    return false; 
  • extensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php

    r12607 r12609  
    130130  $infos = $array = array(); 
    131131   
    132   if (isset($_POST['stc_check_stdl'])) 
     132  if (isset($_POST['stc_submit'])) 
    133133  { 
    134134    $return = subscribe_to_comments($picture['current']['id'], @$_POST['stc_mail_stdl'], 'image'); 
     
    171171} 
    172172 
    173 function stc_on_picture_prefilter($template, &$smarty) 
     173function stc_on_picture_prefilter($content, &$smarty) 
    174174{ 
    175175  global $user, $picture; 
    176176   
    177   // if registered user we check if already subscribed 
     177  // if registered user with mail we check if already subscribed 
    178178  $subscribed = false; 
    179   if (!is_a_guest()) 
     179  if ( !is_a_guest() and !empty($user['email']) ) 
    180180  { 
    181181    $query = ' 
     
    194194   
    195195  ## subscribe at any moment ## 
    196   $search[1] = '{if isset($comment_add)}'; 
    197    
    198   $replace[1] = $search[1].' 
     196  $search = '#\<\/div\>(.{0,5})\{\/if\}(.{0,5})\{\*comments\*\}#is'; 
     197   
     198  $replace = ' 
    199199<form method="post" action="{$comment_add.F_ACTION}" class="filter" id="stc_standalone"> 
    200200  <fieldset>'; 
     
    202202  if ($subscribed) 
    203203  { 
    204     $replace[1].= ' 
     204    $replace.= ' 
    205205    {\'You are currently subscribed to comments of this picture.\'|@translate} 
    206206    <a href="'.add_url_params($picture['current']['url'], array('stc_unsubscribe'=>'1')).'">{\'Unsubscribe\'|@translate}'; 
     
    208208  else 
    209209  { 
    210     $replace[1].= ' 
    211     <label><a href="#" id="stc_check_stdl">{\'Subscribe to new comments\'|@translate}</a> <input type="checkbox" name="stc_check_stdl" value="1" style="display:none;"></label>'; 
    212      
    213     // form for guests 
    214     if (is_a_guest()) 
    215     { 
    216       $replace[1].= '  
    217       <label style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail_stdl"></label> 
    218       <label style="display:none;"><input type="submit" id="stc_submit" value="{\'Submit\'|@translate}"></label> 
     210    $replace.= ' 
     211    <legend>{\'Subscribe without commenting\'|@translate}</legend>'; 
     212    if ( is_a_guest() or empty($user['email']) ) // email input for guest or users without mail 
     213    { 
     214      $replace.= ' 
     215      <label>{\'Email address\'|@translate} <input type="text" name="stc_mail_stdl"></label> 
     216      <label><input type="submit" name="stc_submit" value="{\'Submit\'|@translate}"></label>'; 
     217    } 
     218    else 
     219    { 
     220      $replace.= ' 
     221      <label><input type="submit" name="stc_submit" value="{\'Subscribe\'|@translate}"></label>'; 
     222    } 
     223  } 
     224       
     225  $replace.= ' 
     226  </fieldset> 
     227</form> 
     228</div> 
     229{/if}{*comments*}'; 
     230 
     231  $content = preg_replace($search, $replace, $content); 
     232 
     233 
     234  ## subscribe while add a comment ## 
     235  $search = '<input type="submit" value="{\'Submit\'|@translate}">'; 
     236  $replace = null; 
     237   
     238  if (!$subscribed) 
     239  { 
     240    $replace.= ' 
     241    <label>{\'Notify me of followup comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 
     242  } 
     243  if ( is_a_guest() or empty($user['email']) ) 
     244  { 
     245    $replace.= '  
     246    <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 
    219247    {footer_script require="jquery"}{literal} 
    220248    jQuery(document).ready(function() { 
    221       $("a#stc_check_stdl").click(function() { 
    222         $("input[name=stc_check_stdl]").prop("checked", true); 
    223         $("#stc_standalone label").toggle(); 
    224         return false; 
     249      $("input[name=stc_check]").change(function() { 
     250        if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 
     251        else $("#stc_mail").css("display", "none"); 
    225252      }); 
    226253    }); 
    227254    {/literal}{/footer_script}'; 
    228     } 
    229     // simple link for registered users 
    230     else 
    231     { 
    232       $replace[1].= ' 
    233     {footer_script require="jquery"}{literal} 
    234     jQuery(document).ready(function() { 
    235       $("a#stc_check_stdl").click(function() { 
    236         $("input[name=stc_check_stdl]").prop("checked", true); 
    237         $(this).parents("form#stc_standalone").submit(); 
    238         return false; 
    239       }); 
    240     }); 
    241     {/literal}{/footer_script}'; 
    242     } 
    243   } 
    244        
    245   $replace[1].= ' 
    246   </fieldset> 
    247 </form>'; 
    248  
    249  
    250   ## subscribe while add a comment ## 
    251   $search[0] = '<input type="submit" value="{\'Submit\'|@translate}">'; 
    252   $replace[0] = null; 
    253    
    254   if (!$subscribed) 
    255   { 
    256     $replace[0].= ' 
    257 <label>{\'Subscribe to new comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 
    258   } 
    259   if (is_a_guest()) 
    260   { 
    261     $replace[0].= '  
    262 <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 
    263 {footer_script require="jquery"}{literal} 
    264 jQuery(document).ready(function() { 
    265   $("input[name=stc_check]").change(function() { 
    266     if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 
    267     else $("#stc_mail").css("display", "none"); 
    268   }); 
    269 }); 
    270 {/literal}{/footer_script}'; 
    271   } 
    272   $replace[0].= $search[0]; 
    273    
    274   return str_replace($search, $replace, $template); 
     255  } 
     256  $replace.= $search; 
     257   
     258  $content = str_replace($search, $replace, $content); 
     259   
     260  return $content; 
    275261} 
    276262 
     
    294280  } 
    295281   
    296   if (isset($_POST['stc_check_stdl'])) 
     282  if (isset($_POST['stc_submit'])) 
    297283  { 
    298284    $return = subscribe_to_comments($page['category']['id'], @$_POST['stc_mail_stdl'], 'category'); 
     
    337323} 
    338324 
    339 function stc_on_album_prefilter($template, &$smarty) 
     325function stc_on_album_prefilter($content, &$smarty) 
    340326{ 
    341327  global $user, $page; 
     
    343329  // if registered user we check if already subscribed 
    344330  $subscribed = false; 
    345   if (!is_a_guest()) 
     331  if ( !is_a_guest() and !empty($user['email']) ) 
    346332  { 
    347333    $query = ' 
     
    360346   
    361347  ## subscribe at any moment ## 
    362   $search[1] = '{if isset($comment_add)}'; 
    363    
    364   $replace[1] = $search[1].' 
     348  $search = '#\<\/div\>(.{0,5})\{\/if\}(.{0,5})\{\*comments\*\}#is'; 
     349   
     350  $replace = ' 
    365351<form method="post" action="{$comment_add.F_ACTION}" class="filter" id="stc_standalone"> 
    366352  <fieldset>'; 
    367353   
    368   // if registered user we check if already subscribed 
    369354  if ($subscribed) 
    370355  { 
     
    374359    $element_url = make_index_url($url_params); 
    375360   
    376     $replace[1].= ' 
     361    $replace.= ' 
    377362    {\'You are currently subscribed to comments of this album.\'|@translate} 
    378363    <a href="'.add_url_params($element_url, array('stc_unsubscribe'=>'1')).'">{\'Unsubscribe\'|@translate}'; 
     
    380365  else 
    381366  { 
    382     $replace[1].= ' 
    383     <label><a href="#" id="stc_check_stdl">{\'Subscribe to new comments\'|@translate}</a> <input type="checkbox" name="stc_check_stdl" value="1" style="display:none;"></label>'; 
    384      
    385     // form for guests 
    386     if (is_a_guest()) 
    387     { 
    388       $replace[1].= '  
    389       <label style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail_stdl"></label> 
    390       <label style="display:none;"><input type="submit" id="stc_submit" value="{\'Submit\'|@translate}"></label> 
     367    $replace.= ' 
     368    <legend>{\'Subscribe without commenting\'|@translate}</legend>'; 
     369    if ( is_a_guest() or empty($user['email']) ) // email input for guest or users without mail 
     370    { 
     371      $replace.= ' 
     372      <label>{\'Email address\'|@translate} <input type="text" name="stc_mail_stdl"></label> 
     373      <label><input type="submit" name="stc_submit" value="{\'Submit\'|@translate}"></label>'; 
     374    } 
     375    else 
     376    { 
     377      $replace.= ' 
     378      <label><input type="submit" name="stc_submit" value="{\'Subscribe\'|@translate}"></label>'; 
     379    } 
     380  } 
     381       
     382  $replace.= ' 
     383  </fieldset> 
     384</form> 
     385</div> 
     386{/if}{*comments*}'; 
     387 
     388  $content = preg_replace($search, $replace, $content); 
     389 
     390 
     391  ## subscribe while add a comment ## 
     392  $search = '<input type="submit" value="{\'Submit\'|@translate}">'; 
     393  $replace = null; 
     394   
     395  if (!$subscribed) 
     396  { 
     397    $replace.= ' 
     398    <label>{\'Notify me of followup comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 
     399  } 
     400  if ( is_a_guest() or empty($user['email']) ) 
     401  { 
     402    $replace.= '  
     403    <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 
    391404    {footer_script require="jquery"}{literal} 
    392405    jQuery(document).ready(function() { 
    393       $("a#stc_check_stdl").click(function() { 
    394         $("input[name=stc_check_stdl]").prop("checked", true); 
    395         $("#stc_standalone label").toggle(); 
    396         return false; 
     406      $("input[name=stc_check]").change(function() { 
     407        if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 
     408        else $("#stc_mail").css("display", "none"); 
    397409      }); 
    398410    }); 
    399411    {/literal}{/footer_script}'; 
    400     } 
    401     // simple link for registered users 
    402     else 
    403     { 
    404       $replace[1].= ' 
    405     {footer_script require="jquery"}{literal} 
    406     jQuery(document).ready(function() { 
    407       $("a#stc_check_stdl").click(function() { 
    408         $("input[name=stc_check_stdl]").prop("checked", true); 
    409         $(this).parents("form#stc_standalone").submit(); 
    410         return false; 
    411       }); 
    412     }); 
    413     {/literal}{/footer_script}'; 
    414     } 
    415   } 
    416        
    417   $replace[1].= ' 
    418   </fieldset> 
    419 </form>'; 
    420  
    421  
    422   ## subscribe while add a comment ## 
    423   $search[0] = '<input type="submit" value="{\'Submit\'|@translate}">'; 
    424   $replace[0] = null; 
    425    
    426   if (!$subscribed) 
    427   { 
    428     $replace[0].= ' 
    429 <label>{\'Subscribe to new comments\'|@translate} <input type="checkbox" name="stc_check" value="1"></label>'; 
    430   } 
    431   if (is_a_guest()) 
    432   { 
    433     $replace[0].= '  
    434 <label id="stc_mail" style="display:none;">{\'Email address\'|@translate} <input type="text" name="stc_mail"></label> 
    435 {footer_script require="jquery"}{literal} 
    436 jQuery(document).ready(function() { 
    437   $("input[name=stc_check]").change(function() { 
    438     if ($(this).is(":checked")) $("#stc_mail").css("display", ""); 
    439     else $("#stc_mail").css("display", "none"); 
    440   }); 
    441 }); 
    442 {/literal}{/footer_script}'; 
    443   } 
    444   $replace[0].= $search[0]; 
    445  
    446   return str_replace($search, $replace, $template); 
     412  } 
     413  $replace.= $search; 
     414 
     415  $content = str_replace($search, $replace, $content); 
     416   
     417  return $content; 
    447418} 
    448419 
     
    453424function stc_profile_link() 
    454425{ 
    455   global $template; 
    456    
    457   $template->set_prefilter('profile_content', 'stc_profile_link_prefilter');  
     426  global $template, $user; 
     427   
     428  if (!empty($user['email'])) 
     429  { 
     430    $template->set_prefilter('profile_content', 'stc_profile_link_prefilter'); 
     431  } 
    458432} 
    459433 
  • extensions/Subscribe_to_comments/language/en_UK/plugin.lang.php

    r12607 r12609  
    99$lang['You are currently subscribed to comments of this album.'] = 'You are currently subscribed to comments of this album.'; 
    1010$lang['Unsubscribe'] = 'Unsubscribe'; 
    11 $lang['Subscribe to new comments'] = 'Subscribe to new comments'; 
     11$lang['Subscribe'] = 'Subscribe'; 
     12$lang['Subscribe without commenting'] = 'Subscribe without commenting'; 
     13$lang['Notify me of followup comments'] = 'Notify me of followup comments'; 
    1214$lang['Invalid email adress.'] = 'Invalid email adress.'; 
    1315$lang['Your subscribtion has been validated, thanks you.'] = 'Your subscribtion has been validated, thanks you.'; 
  • extensions/Subscribe_to_comments/language/fr_FR/plugin.lang.php

    r12607 r12609  
    99$lang['You are currently subscribed to comments of this album.'] = 'Vous êtes actuellement inscrit aux commentaires de cet album.'; 
    1010$lang['Unsubscribe'] = 'Se désinscrire'; 
    11 $lang['Subscribe to new comments'] = 'S\'inscrire aux nouveaux commentaires'; 
     11$lang['Subscribe'] = 'S\'inscrire'; 
     12$lang['Subscribe without commenting'] = 'S\'inscrire sans commenter'; 
     13$lang['Notify me of followup comments'] = 'Me notifier des nouveaux commentaires'; 
    1214$lang['Invalid email adress.'] = 'Adress email invalide.'; 
    1315$lang['Your subscribtion has been validated, thanks you.'] = 'Votre inscription a été validée, merci.'; 
Note: See TracChangeset for help on using the changeset viewer.