Jump to content

Replacing an image with an image onclick


LBJerryH

Recommended Posts

I am using a multi quote hack  on my message board and it currently uses to images, one to add the quote and one to remove it. I want it to where there is only one button. You click to add and the image switches to the remove image and then if you want to remove it, you click it and it goes back to the add button. Is this possible??

 

Here is the hack that I added:

 

#
#-----[ OPEN ]------------------------------------------
#

viewtopic.php

#
#-----[ FIND ]------------------------------------------
# 
   $quote = '<a href="' . $temp_url . '">' . $lang['Reply_with_quote'] . '</a>'; 
#
#-----[ AFTER, ADD ]------------------------------------------
#
   // DEBUT MOD Multiquote 
   $post_list_in_cookie = $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_multiquote_' . $topic_id]; 
   if(($post_list_in_cookie != '') && (strstr($post_list_in_cookie, '|' . $postrow[$i]['post_id'] . '|') != FALSE)) 
   { 
      $quote_add_class = 'display_none'; 
      $quote_remove_class = 'display_inline'; 
   } 
   else 
   { 
      $quote_add_class = 'display_inline'; 
      $quote_remove_class = 'display_none'; 
   } 
   $quote_add_img = '<img id="quote_add_' . $postrow[$i]['post_id'] . '" src="' . $images['MuQu_icon_quote_add'] . '" alt="' . $lang['MuQu_Add_to_quote_list'] . '" title="' . $lang['MuQu_Add_to_quote_list'] . '" onclick="cookiePostAdd(' . $topic_id . ', ' . $postrow[$i]['post_id'] . ', \'' . $board_config['cookie_name'] . '\');" style="cursor: pointer;" class="' . $quote_add_class . '" />'; 
   $quote_remove_img = '<img id="quote_remove_' . $postrow[$i]['post_id'] . '" src="' . $images['MuQu_icon_quote_remove'] . '" alt="' . $lang['MuQu_Remove_from_quote_list'] . '" title="' . $lang['MuQu_Remove_from_quote_list'] . '" onclick="cookiePostRemove(' . $topic_id . ', ' . $postrow[$i]['post_id'] . ', \'' . $board_config['cookie_name'] . '\');" style="cursor: pointer;" class="' . $quote_remove_class . '" />'; 
   // FIN MOD Multiquote 
#
#-----[ FIND ]------------------------------------------
# 
      'QUOTE_IMG' => $quote_img, 
#
#-----[ AFTER, ADD ]------------------------------------------
#
      // DEBUT MOD Multiquote 
      'QUOTE_ADD_IMG' => $quote_add_img, 
      'QUOTE_REMOVE_IMG' => $quote_remove_img, 
      // FIN MOD Multiquote
#
#-----[ OPEN ]------------------------------------------
#

posting.php

#
#-----[ FIND ]------------------------------------------
#
// 
// Signature toggle selection 
// 
#
#-----[ BEFORE, ADD ]------------------------------------------
# 
// DEBUT MOD Multiquote 
if($mode == 'reply' && !$preview) 
{ 
   // Récupération du cookie. 
   $post_list_in_cookie = $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_multiquote_' . $topic_id]; 
   if($post_list_in_cookie != '') 
   { 
      // Génération de la liste des id. 
      $post_list_in_cookie = str_replace('||', '|', $post_list_in_cookie); 
      $posts_to_quote = explode ('|', $post_list_in_cookie); 
      $sql_posts_list = ''; 
      foreach($posts_to_quote as $post_to_quote) 
      { 
         // Si on est en mode "quote", on a déjà cité le message courrant, on ne l'inèsre donc pas dans la liste. 
         if($post_to_quote != '' && ($post_to_quote != $post_id)) 
         { 
            $sql_posts_list .= ($sql_posts_list == '') ? $post_to_quote : ', ' . $post_to_quote; 
         } 
      } 
       
      // Si l'on a des posts à citer, on les ajoute en tête de message. 
      if($sql_posts_list != '') 
      { 
         $sql_quote = "SELECT p.post_id, p.poster_id, u.username AS post_username, t.post_text, t.bbcode_uid 
            FROM " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " t, " . USERS_TABLE . " u 
            WHERE p.post_id = t.post_id 
               AND p.poster_id = u.user_id 
               AND p.post_id IN ($sql_posts_list) 
               AND p.topic_id = $topic_id 
            ORDER BY p.post_id DESC"; 

         if (!($result_quote = $db->sql_query($sql_quote))) 
         { 
            message_die(GENERAL_ERROR, 'Could not obtain quotes', '', __LINE__, __FILE__, $sql_quote); 
         } 

         $orig_word = array(); 
         $replacement_word = array(); 
         obtain_word_list($orig_word, $replace_word); 
          
         // Ajout des posts cités un à un. 
         while($row_quote = $db->sql_fetchrow($result_quote)) 
         { 
            // Nettoyage du nom d'utilisateur. 
            $quote_username = trim($row_quote['post_username']); 
          
            $message_quote = $row_quote['post_text']; 
          
            // Nettoyage des bbcode uid. 
            if($row_quote['bbcode_uid'] != '') 
            { 
               $message_quote = preg_replace('/\([a-z0-9]?)' . $row_quote['bbcode_uid'] . '/s', '', $message_quote); 
            } 
             
            // Conversions... 
            $message_quote = str_replace('<', '<', $message_quote); 
            $message_quote = str_replace('>', '>', $message_quote); 
            $message_quote = str_replace('<br />', "\n", $message_quote); 
            $message_quote = '[quote="' . $quote_username . '"]' . $message_quote . "[/quote]\n\n"; 
             
            // Gestion de la censure. 
            if (!empty($orig_word)) 
            { 
               $message_quote = (!empty($message_quote)) ? preg_replace($orig_word, $replace_word, $message_quote) : ''; 
            } 
             
            // Ajout en tête de message. 
            $message = $message_quote . $message; 
         } 
      } 
   } 
} 
// FIN MOD Multiquote
#
#-----[ OPEN ]------------------------------------------
#

includes/functions_post.php

#
#-----[ FIND ]------------------------------------------
# 
   include($phpbb_root_path . 'includes/functions_search.'.$phpEx); 

   $current_time = time(); 
#
#-----[ AFTER, ADD ]------------------------------------------
# 
   // DEBUT MOD Multiquote 
   $cookiename = $board_config['cookie_name']; 
   $cookiepath = $board_config['cookie_path']; 
   $cookiedomain = $board_config['cookie_domain']; 
   $cookiesecure = $board_config['cookie_secure']; 
   setcookie($cookiename . '_multiquote_' . $topic_id, '', FALSE); 
   // FIN MOD Multiquote
#
#-----[ OPEN ]------------------------------------------
#  

language/lang_english/lang_main.php

#
#-----[ FIND ]------------------------------------------
# 
?> 
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// DEBUT MOD Multiquote 
$lang['MuQu_Add_to_quote_list'] = 'Ajouter à liste des messages à citer'; 
$lang['MuQu_Remove_from_quote_list'] = 'Retirer de la liste des messages à citer'; 
// FIN MOD Multiquote 
#
#-----[ OPEN ]------------------------------------------
#

templates/AdInfinitum/AdInfinitum.cfg 

#
#-----[ FIND ]------------------------------------------
# 
?> 
#
#-----[ BEFORE, ADD ]------------------------------------------
# 
// DEBUT MOD Multiquote 
$images['MuQu_icon_quote_add'] = "$current_template_images/{LANG}/icon_quote_add.gif"; 
$images['MuQu_icon_quote_remove'] = "$current_template_images/{LANG}/icon_quote_remove.gif"; 
#
#-----[ OPEN ]------------------------------------------
#

templates/AdInfinitum/viewtopic_body.tpl

#
#-----[ FIND ]------------------------------------------
# 
<table width="100%" cellspacing="2" cellpadding="2" border="0"> 
#
#-----[ BEFORE, ADD ]------------------------------------------
#  
<script type="text/javascript" src="templates/multiquote.js"></script> 
#
#-----[ IN-LINE, FIND ]------------------------------------------
# 
{postrow.QUOTE_IMG} 
#
#-----[ AFTER, ADD ]------------------------------------------
# 
{postrow.QUOTE_ADD_IMG}{postrow.QUOTE_REMOVE_IMG} 
# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM

 

Any help is a appreciated. Thanks!:D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.