Author Topic: [Mod] Edit Keywords and Description from all Images from one Category  (Read 7924 times)

0 Members and 1 Guest are viewing this topic.

Rembrandt

  • Guest
Hi!

With this Modification you can edit Keywords and Description from all Images from one Category.

1.) search in admin/admin_functions.php:

function show_input_row($title$name$value ""$size "") {

insert above:

function show_multi_radio_row($title$name$value$note ""$checked 0$type "radio") {
  global 
$HTTP_POST_VARS$lang;
  if (isset(
$HTTP_POST_VARS[$name])) {
    
$value $HTTP_POST_VARS[$value];
  }
  echo 
"<tr class=\"".get_row_bg()."\">\n";
  echo 
"<td><p class=\"rowtitle\">".$title."</p></td>\n<td><p>";
  echo 
"<input type=\"$type\" name=\"$name\" value=\"$value\"";
 if (
$checked == 1) {
    echo 
" checked=\"checked\"";
  }
  echo 
"> ".$note."\n";
  echo 
"</p></td>\n</tr>";
}


2.) search in admin/categories.php

if ($action == "ordercat") {

insert above:

//##########Start Edit Keywords and Description from all Images from one Category. ############
function forward_to_edit($msg,$cat_id) {
  global 
$site_sess;
  
$site_sess->set_session_var('msg'$msg);
  
redirect("categories.php?action=editcat&cat_id=$cat_id");
}
//##########End Edit Keywords and Description from all Images from one Category. ##############

2.1) search in section " if ($action == "updatecat") ":

$cat_order 
= (isset($HTTP_POST_VARS['cat_order'])) ? intval($HTTP_POST_VARS['cat_order']) : 0;

insert below:

//#########Start Edit Keywords and Description from all Images from one Category. #############
  
if($HTTP_POST_VARS['selected_description'] == "save_description"){
    
$image_description un_htmlspecialchars(trim($HTTP_POST_VARS['image_description']));
  }
  if(
$HTTP_POST_VARS['selected_keywords'] == "save_keywords"){
    
$image_keywords un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords']));
    
$image_keywords preg_replace("/[\n\r]/is"","$image_keywords);
    
$image_keywords_arr explode(','$image_keywords);
    
array_walk($image_keywords_arr'trim_value');
    
$image_keywords implode(','array_unique(array_filter($image_keywords_arr)));
  }
//##########End Edit Keywords and Description from all Images from one Category. ##############

2.2) search in section " if ($action == "updatecat") ":

if ($result && $do_update_cat_order)

insert above:

//#########Start Edit Keywords and Description from all Images from one Category.#############    
    
if($HTTP_POST_VARS['selected_words'] == "add_words"){
      
$image_keywords = (isset($image_keywords)) ? "image_keywords = concat(image_keywords,',$image_keywords')" "";
      
$image_description = (isset($image_description)) ? "image_description = concat(image_description,' $image_description')" "";
    }
    if(
$HTTP_POST_VARS['selected_words'] == "replace_words"){    
      
$image_keywords = (isset($image_keywords)) ? "image_keywords = '".$image_keywords."'" "";
      
$image_description = (isset($image_description)) ? "image_description = '".$image_description."'" "";
      
$replace 1;
    }
    
    
$sql_set "";
    
$sql_set = (!empty($image_keywords) && !empty($image_description)) ? "$image_keywords$image_description"$image_keywords $image_description";

    if(
$sql_set){
      
$sql "UPDATE ".IMAGES_TABLE."
              SET 
$sql_set 
              WHERE cat_id = 
$cat_id";
      
$res $site_db->query($sql);
      
      if (
$res) {
        
$sql "SELECT cat_id,image_id
                FROM "
.IMAGES_TABLE."
                WHERE cat_id = 
$cat_id";
        
$res $site_db->query($sql);
        
$image_ids = array();
        
        while (
$row $site_db->fetch_array($res)) {
          
$image_ids[] = $row['image_id'];
        }
       
        
$search_words = array();
        foreach (
$search_match_fields as $image_column => $match_column) {
          if (isset(
$HTTP_POST_VARS[$image_column])) {
            
$search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column]);
          }
        }
        foreach(
$image_ids AS $image_id){
          if(
$replace){
            
remove_searchwords($image_id);
          }
          
add_searchwords($image_id$search_words);
        }
      }
// result 
    
}//$sql_set
//##########End Edit Keywords and Description from all Images from one Category. ##############

2.3) search in section " if ($action == "updatecat") ":

    $msg 
= ($result) ? $lang['cat_edit_success'] : $lang['cat_edit_error'];
    
//$action = "modifycats";
    
forward_to_modify($msg);

and replace:

    $msg 
= ($result) ? $lang['cat_edit_success'] : $lang['cat_edit_error'];
    
//$action = "modifycats";
    
forward_to_edit($msg,$cat_id);

2.4) search in section " if ($action == "editcat") ":

$cat_id 
= (isset($HTTP_POST_VARS['cat_id'])) ? intval($HTTP_POST_VARS['cat_id']) : intval($HTTP_GET_VARS['cat_id']);

insert below:

//#########Start Edit Keywords and Description from all Images from one Category. ##############
    
$sql "SELECT image_id,cat_id,image_description,image_keywords
          FROM "
.IMAGES_TABLE."
          WHERE cat_id = 
$cat_id";
  
$result $site_db->query($sql);
  
  while (
$image_row $site_db->fetch_array($result)){
    
$image_description .= (!empty($image_row['image_description'])) ? $image_row['image_description']."#"$image_row['image_description'];
    
$image_keywords .= (!empty($image_row['image_keywords'])) ? $image_row['image_keywords']."#"$image_row['image_keywords'];
  }
  
$image_description explode("#"$image_description);
  
$image_description implode(" "array_unique($image_description));
  
$image_keywords explode('#'$image_keywords);
  
$image_keywords implode(','array_unique($image_keywords));
//##########End Edit Keywords and Description from all Images from one Category. ##############

2.5) search in section " if ($action == "editcat") ":

show_input_row
($lang['field_hits'], "cat_hits"$cat_row['cat_hits'], 5);

insert below:

//#########Start Edit Keywords and Description from all Images from one Category. #############
  
show_table_separator($lang['nav_images_edit'], 2);
  
show_textarea_row($lang['field_description_ext'], "image_description"$image_description$textarea_size);
  
show_multi_radio_row($lang['save_changes']." ?""selected_description""save_description"$lang['save'], 0"checkbox");
  
show_textarea_row($lang['field_keywords_ext'], "image_keywords"$image_keywords$textarea_size);
  
show_multi_radio_row($lang['save_changes']." ?""selected_keywords""save_keywords"$lang['save'], 0"checkbox");
  
show_multi_radio_row($lang['append_desc'], "selected_words""add_words"$lang['append'], 1);
  
show_multi_radio_row($lang['replace_desc'], "selected_words""replace_words"$lang['replace']);
//##########End Edit Keywords and Description from all Images from one Category. ##############


3.) search in lang/your Lang/admin.php:

//--- Categories --------------------------------------
//-----------------------------------------------------

insert below:
(deutsch)

$lang
['replace'] = "Ersetzen";
$lang['replace_desc'] = "Ersetzen :<br><span class=\"smalltext\">Die Beschreibung und Schlüsselwörter, werden als neue Beschreibung und Schlüsselwörter der Bilder gespeichert.</span>";
$lang['append'] = "Hinzufügen";
$lang['append_desc'] = "Hinzufügen :<br><span class=\"smalltext\">Die Beschreibung und Schlüsselwörter, werden zu der schon vorhandenen Beschreibungen und Schlüsselwörter der Bilder hinzugefügt.</span>";
$lang['save'] = "Speichern";

(english)

$lang
['replace'] = "Replace";
$lang['replace_desc'] = "Replace :<br><span class=\"smalltext\">The description and keywords are stored as a new description and keywords of the images.</span>";
$lang['append'] = "Add";
$lang['append_desc'] = "Add :<br><span class=\"smalltext\">The description and keywords are added to the already existing descriptions and keywords of the images.</span>";
$lang['save'] = "Save";


Now in "ACP / Categories" you can edit the description and keywords from all images in the category.

mfg Andi
« Last Edit: June 03, 2012, 08:37:10 PM by Rembrandt »

Offline Nosferatu

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Project-Firepower
Ist ja total cool 1000 Danke ;)

warum entwickelst du nicht einfach ein 4images 2.0 :D ^^ mit den ganzen tollen mods die hast ^^ verwende 15 große mods bei mir, glaubt 11 davon sind alleine von dir :D

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.289
    • View Profile
    • Discover the New World of Kindersurprise
Klappt perfect, BIG Thanks :wink:
Danke Harald