Changeset 20141


Ignore:
Timestamp:
Jan 14, 2013, 5:29:39 PM (8 years ago)
Author:
mistic100
Message:

replace toggle_image.php by webservices

Location:
extensions/UserCollections
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/include/collections.inc.php

    r20097 r20141  
    169169      'collection_toggle_url' => $self_url,
    170170      'U_LIST' => USER_COLLEC_PUBLIC,
    171       'COL_ID' => $page['col_id'],
     171      'AJAX_COL_ID' => $page['col_id'],
     172      'UC_IN_EDIT' => true,
    172173      ));
    173174   
     
    330331function user_collections_thumbnails_in_collection($tpl_thumbnails_var, $pictures)
    331332{
    332   global $template;
     333  global $template, $page;
     334 
     335  $url = USER_COLLEC_PUBLIC . 'edit/'.$page['col_id'];
    333336 
    334337  foreach ($tpl_thumbnails_var as &$thumbnail)
     
    345348        array('start')
    346349      );
     350     
     351    $thumbnail['COLLECTION_SELECTED'] = true;
     352    $thumbnail['COLLECTION_TOGGLE_URL'] = add_url_params($url, array('collection_toggle'=>$thumbnail['id']));
    347353  }
    348354 
  • extensions/UserCollections/include/events.inc.php

    r20099 r20141  
    9999    $template->assign('NO_AJAX', true);
    100100  }
     101  else
     102  {
     103    $template->assign('AJAX_COL_ID', $col_id );
     104  }
    101105 
    102106  // template vars
    103   $url = duplicate_index_url(array(), array('collection_toggle')); 
     107  $url = duplicate_index_url(array(), array('collection_toggle'));
    104108 
    105109  foreach ($tpl_thumbnails_var as &$thumbnail)
     
    109113      $thumbnail['COLLECTION_SELECTED'] = true;
    110114    }
     115    $thumbnail['COLLECTION_TOGGLE_URL'] = add_url_params($url, array('collection_toggle'=>$thumbnail['id']));
    111116  }
    112117  unset($thumbnail);
     
    114119  $template->assign(array(
    115120    'USER_COLLEC_PATH' => USER_COLLEC_PATH,
    116     'collection_toggle_url' =>  add_url_params($url, array('collection_toggle'=>'')),
    117121    ));
    118122 
     
    128132  $search = '#(<li>|<li class="gthumb">)#';
    129133  $replace = '$1
    130 {strip}<a class="addCollection" href="{$collection_toggle_url}{$thumbnail.id}" data-id="{$thumbnail.id}" rel="nofollow">
    131 <span class="uc_remove" {if not $COL_ID and not $thumbnail.COLLECTION_SELECTED}style="display:none;"{/if}>
     134{strip}<a class="addCollection" href="{$thumbnail.COLLECTION_TOGGLE_URL}" data-id="{$thumbnail.id}" data-stat="{if $thumbnail.COLLECTION_SELECTED}remove{else}add{/if}" rel="nofollow">
     135<span class="uc_remove" {if not $thumbnail.COLLECTION_SELECTED}style="display:none;"{/if}>
    132136{\'Remove from collection\'|@translate}&nbsp;<img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_delete.png" title="{\'Remove from collection\'|@translate}">
    133137</span>
    134 <span class="uc_add" {if $COL_ID or $thumbnail.COLLECTION_SELECTED}style="display:none;"{/if}>
     138<span class="uc_add" {if $thumbnail.COLLECTION_SELECTED}style="display:none;"{/if}>
    135139{\'Add to collection\'|@translate}&nbsp;<img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_add.png" title="{\'Add to collection\'|@translate}">
    136140</span>
  • extensions/UserCollections/template/thumbnails_css_js.tpl

    r20099 r20141  
    88{footer_script require='jquery'}
    99jQuery(".addCollection").click(function() {ldelim}
    10   var toggle_id = jQuery(this).data("id");
    1110  var $trigger = jQuery(this);
     11  var toggle_id = $trigger.data("id");
     12  var method = $trigger.data("stat");
     13 
     14  if (method != "add" && method != "remove") {ldelim}
     15    $trigger.html("{'Un unknown error occured'|@translate}");
     16    return false;
     17  }
    1218 
    1319  jQuery.ajax({ldelim}
    14     type: "POST",
    15     url: "{$ROOT_URL}{$USER_COLLEC_PATH}toggle_image.php",
    16     data: {ldelim} {if $COL_ID}"col_id": "{$COL_ID}", {/if}"toggle_id": toggle_id }
    17   }).done(function(msg) {ldelim}
    18     if (msg == "true") {ldelim}
    19       $trigger.children(".uc_remove").show();
    20       $trigger.children(".uc_add").hide();
    21       jQuery(".nbImagesCollec").html(parseInt(jQuery(".nbImagesCollec").html()) +1);
    22     } else if (msg == "false") {ldelim}
    23     {if $COL_ID}
    24       $trigger.parent(".wrap1, .gthumb").hide("fast", function() {ldelim} $trigger.remove() });
    25       if (typeof batchdown_count != 'undefined') batchdown_count-=1;
    26     {else}
    27       $trigger.children(".uc_remove").hide();
    28       $trigger.children(".uc_add").show();
    29     {/if}
    30     jQuery(".nbImagesCollec").html(parseInt(jQuery(".nbImagesCollec").html()) -1);
    31     } else {ldelim}
    32       $trigger.html('{'Un unknown error occured'|@translate}');
     20    type: "GET",
     21    dataType: "json",
     22    url: "{$ROOT_URL}ws.php",
     23    data: {ldelim} "format": "json", "method": "pwg.collections."+method+"Images", "col_id": {$AJAX_COL_ID}, "image_ids": toggle_id },
     24    success: function(data) {ldelim}
     25      if (data['stat'] == 'ok') {ldelim}
     26        if (method == "add") {ldelim}
     27          $trigger.children(".uc_remove").show();
     28          $trigger.children(".uc_add").hide();
     29          $trigger.data("stat", "remove");
     30        }
     31        else if (method == "remove") {ldelim}
     32        {if $UC_IN_EDIT}
     33          $trigger.parent(".wrap1, .gthumb").hide("fast", function() {ldelim} $(this).remove() });
     34          if (typeof batchdown_count != 'undefined') batchdown_count-=1;
     35        {else}
     36          $trigger.children(".uc_remove").hide();
     37          $trigger.children(".uc_add").show();
     38          $trigger.data("stat", "add");
     39        {/if}
     40        }
     41       
     42        jQuery(".nbImagesCollec").html(data['result']['nb_images']);
     43      }
     44      else {ldelim}
     45        $trigger.html("{'Un unknown error occured'|@translate}");
     46      }
     47    },
     48    error: function() {ldelim}
     49      $trigger.html("{'Un unknown error occured'|@translate}");
    3350    }
    3451  });
Note: See TracChangeset for help on using the changeset viewer.