Changeset 2429


Ignore:
Timestamp:
Jul 12, 2008, 2:30:27 AM (16 years ago)
Author:
rvelices
Message:
  • add to caddie on picture page done through ajax
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r2413 r2429  
    281281}
    282282
     283function ws_caddie_add($params, &$service)
     284{
     285  if (!is_admin())
     286  {
     287    return new PwgError(401, 'Access denied');
     288  }
     289  if ( empty($params['image_id']) )
     290  {
     291    return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id");
     292  }
     293  global $user;
     294  $query = '
     295SELECT id
     296  FROM '.IMAGES_TABLE.' LEFT JOIN '.CADDIE_TABLE.' ON id=element_id AND user_id='.$user['id'].'
     297  WHERE id IN ('.implode(',',$params['image_id']).')
     298    AND element_id IS NULL';
     299  $datas = array();
     300  foreach ( array_from_query($query, 'id') as $id )
     301  {
     302    array_push($datas, array('element_id'=>$id, 'user_id'=>$user['id']) );
     303  }
     304  if (count($datas))
     305  {
     306    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     307    mass_inserts(CADDIE_TABLE, array('element_id','user_id'), $datas);
     308  }
     309  return count($datas);
     310}
    283311
    284312/**
  • trunk/template-common/scripts.js

    r2413 r2429  
    55for( i = 0; i < len; i++)
    66{
    7   if ( formulaire.elements[i].type=='checkbox'
    8            && formulaire.elements[i].name != 'copie')
    9   {
    10         formulaire.elements[i].checked = true;
    11   }
     7        if ( formulaire.elements[i].type=='checkbox'
     8                && formulaire.elements[i].name != 'copie')
     9        {
     10                formulaire.elements[i].checked = true;
     11        }
    1212}
    1313}
     
    1919for( i = 0; i < len; i++)
    2020{
    21   if ( formulaire.elements[i].type=='checkbox'
    22            && formulaire.elements[i].name != 'copie')
    23   {
     21        if ( formulaire.elements[i].type=='checkbox'
     22                && formulaire.elements[i].name != 'copie')
     23        {
    2424        formulaire.elements[i].checked = false;
    25   }
     25        }
    2626}
    2727}
     
    3333for( i=0; i<len; i++)
    3434{
    35   if ( formulaire.elements[i].type=='checkbox'
    36            && formulaire.elements[i].name != 'copie')
    37   {
     35        if ( formulaire.elements[i].type=='checkbox'
     36                && formulaire.elements[i].name != 'copie')
     37        {
    3838        formulaire.elements[i].checked = !formulaire.elements[i].checked;
    39   }
     39        }
    4040}
    4141}
     
    4343function phpWGOpenWindow(theURL,winName,features)
    4444{
    45   img = new Image();
    46   img.src = theURL;
    47   if (img.complete)
    48   {
    49     var width=img.width +40;
    50     var height=img.height +40;
    51   }
    52   else
    53   {
    54     var width=640;
    55     var height=480;
    56     img.onload = resizeWindowToFit;
    57   }
    58   newWin = window.open(theURL,winName,features+',left=2,top=1,width=' + width + ',height=' + height);
     45        img = new Image();
     46        img.src = theURL;
     47        if (img.complete)
     48        {
     49                var width=img.width +40;
     50                var height=img.height +40;
     51        }
     52        else
     53        {
     54                var width=640;
     55                var height=480;
     56                img.onload = resizeWindowToFit;
     57        }
     58        newWin = window.open(theURL,winName,features+',left=2,top=1,width=' + width + ',height=' + height);
    5959}
    6060
    6161function resizeWindowToFit()
    6262{
    63   newWin.resizeTo( img.width+50, img.height+100);
     63        newWin.resizeTo( img.width+50, img.height+100);
    6464}
    6565
    6666function popuphelp(url)
    6767{
    68   window.open(
    69     url,
    70     'dc_popup',
    71     'alwaysRaised=yes,dependent=yes,toolbar=no,height=420,width=500,menubar=no,resizable=yes,scrollbars=yes,status=no'
    72   );
     68        window.open( url, 'dc_popup',
     69                'alwaysRaised=yes,dependent=yes,toolbar=no,height=420,width=500,menubar=no,resizable=yes,scrollbars=yes,status=no'
     70        );
    7371}
    7472
     
    155153                        catch (e)
    156154                        {
    157                                 this.dispatchError( 200, e.message + '\n' + transport.responseText.substr(0,256).escapeHTML() );
     155                                this.dispatchError( 200, e.message + '\n' + transport.responseText.substr(0,512) );
    158156                        }
    159157                        if (resp!=null)
  • trunk/template/yoga/picture.tpl

    r2413 r2429  
    5555      <a href="{$U_ADMIN}" title="{'link_info_image'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/preferences.png" class="button" alt="{'edit'|@translate}"></a>
    5656    {/if}
    57     {if isset($U_CADDIE) }
    58       <a href="{$U_CADDIE}" title="{'add to caddie'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/caddie_add.png" class="button" alt="{'caddie'|@translate}"></a>
    59     {/if}
     57    {if isset($U_CADDIE) }{*caddie management BEGIN*}
     58<script type="text/javascript">
     59{literal}function addToCadie(aElement, rootUrl, id)
     60{
     61if (aElement.disabled) return;
     62aElement.disabled=true;
     63var y = new PwgWS(rootUrl);
     64
     65y.callService(
     66  "pwg.caddie.add", {image_id: id} ,
     67  {
     68    onFailure: function(num, text) { alert(num + " " + text); document.location=aElement.href; },
     69    onSuccess: function(result) { aElement.disabled = false; }
     70  }
     71  );
     72}{/literal}
     73</script>
     74      <a href="{$U_CADDIE}" onclick="addToCadie(this, '{$ROOT_URL|@escape:'javascript'}', {$current.id}); return false;" title="{'add to caddie'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/caddie_add.png" class="button" alt="{'caddie'|@translate}"></a>
     75    {/if}{*caddie management END*}
    6076  </div>
    6177  {include file=$FILE_PICTURE_NAV_BUTTONS}
  • trunk/ws.php

    r2413 r2429  
    4343  $service->addMethod('pwg.getVersion', 'ws_getVersion', null,
    4444      'retrieves the PWG version');
     45
     46  $service->addMethod('pwg.caddie.add', 'ws_caddie_add',
     47      array(
     48        'image_id'=> array( 'flags'=>WS_PARAM_FORCE_ARRAY ),
     49      ),
     50      'adds the elements to the caddie');
    4551
    4652  $service->addMethod('pwg.categories.getImages', 'ws_categories_getImages',
Note: See TracChangeset for help on using the changeset viewer.