Changeset 25678


Ignore:
Timestamp:
Nov 24, 2013, 6:09:57 PM (7 years ago)
Author:
mistic100
Message:

very big update for Piwigo 2.6

Location:
extensions/UserCollections
Files:
10 added
3 deleted
34 edited
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/admin.php

    r23551 r25678  
    88include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    99$page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'sets';
    10  
     10
    1111$tabsheet = new tabsheet();
    1212$tabsheet->add('sets', l10n('Collections'), USER_COLLEC_ADMIN . '-sets');
     
    3434  'USER_COLLEC_ADMIN' => USER_COLLEC_ADMIN,
    3535  ));
    36  
     36
    3737$template->assign_var_from_handle('ADMIN_CONTENT', 'user_collections');
    38 
    39 ?>
  • extensions/UserCollections/admin/config.php

    r24421 r25678  
    88    'allow_mails'     => isset($_POST['allow_mails']) && isset($_POST['allow_public']),
    99    );
    10  
     10
    1111  conf_update_param('user_collections', serialize($conf['user_collections']));
    1212}
     
    1818
    1919$template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/config.tpl'));
    20 
    21 ?>
  • extensions/UserCollections/admin/export.php

    r24421 r25678  
    44try {
    55  $collection = new UserCollection($_GET['col_id']);
    6  
     6
    77  $template->assign('COL_ID', $_GET['col_id']);
    88}
     
    1919  pwg_set_session_var('uc_export_active_fields', $_POST['active']);
    2020  pwg_set_session_var('uc_export_inactive_fields', $_POST['inactive']);
    21  
     21
    2222  $content = $collection->serialize($_POST['active']);
    2323  $filename = 'collection_'.$_GET['col_id'].'_'.date('Ymd-Hi').'.csv';
    24  
     24
    2525  header('Content-Type: application/force-download; name="'.$filename.'"');
    2626  header('Content-Disposition: attachment; filename="'.$filename.'"');
     
    3232  header('Pragma: no-cache');
    3333  header('Expires: 0');
    34  
     34
    3535  echo $content;
    3636  exit;
     
    5555$template->assign('inactive_fields', pwg_get_session_var('uc_export_inactive_fields', $default_inactive_fields));
    5656
     57
    5758$template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/export.tpl'));
    58 
    59 ?>
  • extensions/UserCollections/admin/index.php

    r20090 r25678  
    11<?php
    2 // +-----------------------------------------------------------------------+
    3 // | Piwigo - a PHP based photo gallery                                    |
    4 // +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
    6 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    7 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
    8 // +-----------------------------------------------------------------------+
    9 // | This program is free software; you can redistribute it and/or modify  |
    10 // | it under the terms of the GNU General Public License as published by  |
    11 // | the Free Software Foundation                                          |
    12 // |                                                                       |
    13 // | This program is distributed in the hope that it will be useful, but   |
    14 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    16 // | General Public License for more details.                              |
    17 // |                                                                       |
    18 // | You should have received a copy of the GNU General Public License     |
    19 // | along with this program; if not, write to the Free Software           |
    20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    21 // | USA.                                                                  |
    22 // +-----------------------------------------------------------------------+
    23 
    24 // Recursive call
    252$url = '../';
    263header( 'Request-URI: '.$url );
     
    285header( 'Location: '.$url );
    296exit();
    30 ?>
  • extensions/UserCollections/admin/sets.php

    r24421 r25678  
    1919    array_push($where_clauses, 'username LIKE "%'.$_POST['username'].'%"');
    2020  }
    21  
     21
    2222  if (!empty($_POST['name']))
    2323  {
    2424    array_push($where_clauses, 'name LIKE "%'.$_POST['name'].'%"');
    2525  }
    26  
     26
    2727  $order_by = $_POST['order_by'].' '.$_POST['direction'];
    2828}
     
    3131// get sets
    3232$query = '
    33 SELECT 
     33SELECT
    3434    c.*,
    3535    u.'.$conf['user_fields']['username'].' AS username
     
    4646{
    4747  $template->append('sets', array(
    48     'NAME' => trigger_event('render_category_name', $row['name']),
     48    'NAME' => trigger_change('render_category_name', $row['name']),
    4949    'NB_IMAGES' => $row['nb_images'],
    5050    'DATE_CREATION' => format_date($row['date_creation'], true),
     
    7474  'direction_options' => $page['direction_items'],
    7575  'direction_selected' => isset($_POST['direction']) ? $_POST['direction'] : '',
    76  
     76
    7777  'F_USERNAME' => @htmlentities($_POST['username'], ENT_COMPAT, 'UTF-8'),
    7878  'F_NAME' => @htmlentities($_POST['name'], ENT_COMPAT, 'UTF-8'),
     
    8282
    8383$template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/sets.tpl'));
    84 
    85 ?>
  • extensions/UserCollections/admin/template/config.tpl

    r24421 r25678  
    1 {combine_css path=$USER_COLLEC_PATH|@cat:"admin/template/style.css"}
     1{combine_css path=$USER_COLLEC_PATH|cat:'admin/template/style.css'}
    22
    3 {footer_script}{literal}
    4 $("input[name='allow_public']").on("change", function() {
    5     $("#allow_mails").toggle($(this).is(":checked"));
     3{footer_script}
     4$('input[name="allow_public"]').on('change', function() {
     5    $('#allow_mails').toggle($(this).is(':checked'));
    66});
    7 {/literal}{/footer_script}
     7{/footer_script}
    88
    99<div class="titrePage">
     
    1717      <label>
    1818        <input type="checkbox" name="allow_public" {if $user_collections.allow_public}checked="checked"{/if}>
    19         <b>{'Allow users to set their collections as public'|@translate}</b>
     19        <b>{'Allow users to set their collections as public'|translate}</b>
    2020      </label>
    2121    </li>
     
    2323      <label>
    2424        <input type="checkbox" name="allow_mails" {if $user_collections.allow_mails}checked="checked"{/if}>
    25         <b>{'Allow users to send their public collections by mail'|@translate}</b>
     25        <b>{'Allow users to send their public collections by mail'|translate}</b>
    2626      </label>
    2727    </li>
     
    2929</fieldset>
    3030
    31   <p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'|@translate}"></p>   
     31  <p class="formButtons"><input type="submit" name="save_config" value="{'Save Settings'|translate}"></p>
    3232</form>
  • extensions/UserCollections/admin/template/export.tpl

    r20099 r25678  
    1 {combine_css path=$USER_COLLEC_PATH|@cat:"admin/template/style.css"}
     1{combine_css path=$USER_COLLEC_PATH|cat:'admin/template/style.css'}
    22
    3 {footer_script require='jquery.ui.sortable'}{literal}
    4 $( "#fields_active, #fields_inactive" ).sortable({
    5   connectWith: ".connectedSortable",
    6   items: "> li",
    7   placeholder: "sortable-moving"
     3{footer_script require='jquery.ui.sortable'}
     4$('#fields_active, #fields_inactive').sortable({
     5  connectWith: '.connectedSortable',
     6  items: '> li',
     7  placeholder: 'sortable-moving'
    88}).disableSelection();
    99
    10 $("input[name='generate']").click(function() {
    11   query = "ws.php?format=rest&method=pwg.collections.getSerialized&col_id={/literal}{$COL_ID}{literal}";
    12   $("#fields_active li").each(function() {
     10$('input[name="generate"]').click(function() {
     11  query = 'ws.php?format=rest&method=pwg.collections.getSerialized&col_id={$COL_ID}';
     12  $('#fields_active li').each(function() {
    1313    query+= '&content[]='+ $(this).data('name');
    1414  });
    15  
    16   $("#iframeWrapper").show();
    17   $("#invokeFrame").attr('src', query);
    18  
     15
     16  $('#iframeWrapper').show();
     17  $('#invokeFrame').attr('src', query);
     18
    1919  return false;
    2020});
    2121
    22 $("#invokeFrame").load(function() {
     22$('#invokeFrame').load(function() {
    2323  $(this).css('height', $(this).contents().find('body').outerHeight(true)+10);
    2424});
    2525
    26 $("input[name='download']").click(function() {
    27   $("#fields_active li").each(function() {
    28     $("#export_form").append('<input type="hidden" name="active[]" value="'+ $(this).data('name') +'"/>');
     26$('input[name="download"]').click(function() {
     27  $('#fields_active li').each(function() {
     28    $('#export_form').append('<input type="hidden" name="active[]" value="'+ $(this).data('name') +'"/>');
    2929  });
    30   $("#fields_inactive li").each(function() {
    31     $("#export_form").append('<input type="hidden" name="inactive[]" value="'+ $(this).data('name') +'"/>');
     30  $('#fields_inactive li').each(function() {
     31    $('#export_form').append('<input type="hidden" name="inactive[]" value="'+ $(this).data('name') +'"/>');
    3232  });
    3333});
    34 {/literal}{/footer_script}
     34{/footer_script}
    3535
    3636<div class="titrePage">
     
    4141<form method="post" action="" class="properties" id="export_form">
    4242<fieldset>
    43   <legend>{'Fields'|@translate}</legend>
     43  <legend>{'Fields'|translate}</legend>
    4444  <ul id="fields_active" class="connectedSortable">
    45     <h4>{'Active'|@translate}</h4>
     45    <h4>{'Active'|translate}</h4>
    4646  {foreach from=$active_fields item=field}
    4747    <li data-name="{$field}"><img src="{$themeconf.admin_icon_dir}/cat_move.png"> {$field}</li>
     
    4949  </ul>
    5050  <ul id="fields_inactive" class="connectedSortable">
    51     <h4>{'Inactive'|@translate}</h4>
     51    <h4>{'Inactive'|translate}</h4>
    5252  {foreach from=$inactive_fields item=field}
    5353    <li data-name="{$field}"><img src="{$themeconf.admin_icon_dir}/cat_move.png"> {$field}</li>
    5454  {/foreach}
    5555  </ul>
    56  
     56
    5757  <p class="formButtons">
    58     <input type="submit" name="generate" value="{'Preview'|@translate}">
    59     <input type="submit" name="download" value="{'Download CSV file'|@translate}">
    60   </p>   
     58    <input type="submit" name="generate" value="{'Preview'|translate}">
     59    <input type="submit" name="download" value="{'Download CSV file'|translate}">
     60  </p>
    6161</fieldset>
    6262
    6363<fieldset id="iframeWrapper" style="display:none;">
    64   <legend>{'Preview'|@translate}</legend>
     64  <legend>{'Preview'|translate}</legend>
    6565  <iframe src="" id="invokeFrame" name="invokeFrame"></iframe>
    6666</fieldset>
  • extensions/UserCollections/admin/template/index.php

    r20090 r25678  
    11<?php
    2 // +-----------------------------------------------------------------------+
    3 // | Piwigo - a PHP based photo gallery                                    |
    4 // +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
    6 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    7 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
    8 // +-----------------------------------------------------------------------+
    9 // | This program is free software; you can redistribute it and/or modify  |
    10 // | it under the terms of the GNU General Public License as published by  |
    11 // | the Free Software Foundation                                          |
    12 // |                                                                       |
    13 // | This program is distributed in the hope that it will be useful, but   |
    14 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    16 // | General Public License for more details.                              |
    17 // |                                                                       |
    18 // | You should have received a copy of the GNU General Public License     |
    19 // | along with this program; if not, write to the Free Software           |
    20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    21 // | USA.                                                                  |
    22 // +-----------------------------------------------------------------------+
    23 
    24 // Recursive call
    252$url = '../';
    263header( 'Request-URI: '.$url );
     
    285header( 'Location: '.$url );
    296exit();
    30 ?>
  • extensions/UserCollections/admin/template/sets.tpl

    r24421 r25678  
    1 {combine_css path=$USER_COLLEC_PATH|@cat:"admin/template/style.css"}
     1{combine_css path=$USER_COLLEC_PATH|cat:'admin/template/style.css'}
    22
    33<div class="titrePage">
     
    77<form class="filter" method="post" name="filter" action="{$F_FILTER_ACTION}">
    88<fieldset>
    9   <legend>{'Filter'|@translate}</legend>
     9  <legend>{'Filter'|translate}</legend>
    1010  <input type="hidden" name="page" value="user_list">
    1111
    12   <label>{'Name'|@translate} <input type="text" name="name" value="{$F_NAME}"></label>
    13  
    14   <label>{'Username'|@translate} <input type="text" name="username" value="{$F_USERNAME}"></label>
     12  <label>{'Name'|translate} <input type="text" name="name" value="{$F_NAME}"></label>
     13
     14  <label>{'Username'|translate} <input type="text" name="username" value="{$F_USERNAME}"></label>
    1515
    1616  <label>
    17   {'Sort by'|@translate}
     17  {'Sort by'|translate}
    1818  {html_options name=order_by options=$order_options selected=$order_selected}
    1919  </label>
    2020
    2121  <label>
    22   {'Sort order'|@translate}
     22  {'Sort order'|translate}
    2323  {html_options name=direction options=$direction_options selected=$direction_selected}
    2424  </label>
     
    2626  <label>
    2727  &nbsp;
    28   <span><input class="submit" type="submit" name="filter" value="{'Submit'|@translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|@translate}</a></span>
     28  <span><input class="submit" type="submit" name="filter" value="{'Submit'|translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|translate}</a></span>
    2929  </label>
    3030
     
    3636  <thead>
    3737    <tr class="throw">
    38       <td class="name">{'Name'|@translate}</td>
    39       <td class="user">{'Username'|@translate}</td>
    40       <td class="date">{'Creation date'|@translate}</td>
    41       <td class="images">{'Number of images'|@translate}</td>
    42       <td class="action">{'Actions'|@translate}</td>
     38      <td class="name">{'Name'|translate}</td>
     39      <td class="user">{'Username'|translate}</td>
     40      <td class="date">{'Creation date'|translate}</td>
     41      <td class="images">{'Number of images'|translate}</td>
     42      <td class="action">{'Actions'|translate}</td>
    4343    </tr>
    4444  </thead>
     
    5353    <td>{$set.NB_IMAGES}</td>
    5454    <td style="padding-left:25px;">
    55       <a href="{$set.U_EDIT}" title="{'Edit this collection'|@translate}"><img src="{$themeconf.admin_icon_dir}/edit_s.png"></a>
    56       <a href="{$set.U_EXPORT}" title="{'Export image list'|@translate}"><img src="{$themeconf.admin_icon_dir}/plug_install.png"><span class="icon-upload"></span></a> <!-- temp 2.5/2.6 -->
    57       <a href="{$set.U_DELETE}" title="{'Delete this collection'|@translate}" onClick="return confirm('{'Are you sure?'|@translate}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a>
     55      <a href="{$set.U_EDIT}" title="{'Edit this collection'|translate}"><img src="{$themeconf.admin_icon_dir}/edit_s.png"></a>
     56      <a href="{$set.U_EXPORT}" title="{'Export image list'|translate}"><img src="{$themeconf.admin_icon_dir}/plug_install.png"><span class="icon-upload"></span></a> <!-- temp 2.5/2.6 -->
     57      <a href="{$set.U_DELETE}" title="{'Delete this collection'|translate}" onClick="return confirm('{'Are you sure?'|translate}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a>
    5858    </td>
    5959  </tr>
    6060  {/foreach}
    61  
     61
    6262  {if not $sets}
    6363  <tr class="row2">
    64     <td colspan="8" style="text-align:center;font-style:italic;">{'No results'|@translate}</td>
     64    <td colspan="8" style="text-align:center;font-style:italic;">{'No results'|translate}</td>
    6565  </tr>
    6666  {/if}
  • extensions/UserCollections/admin/template/style.css

    r20099 r25678  
    9393    opacity:0.5;
    9494  }
    95  
     95
    9696#invokeFrame {
    9797  width:100%;
  • extensions/UserCollections/include/UserCollection.class.php

    r25676 r25678  
    66  private $data;
    77  private $images;
    8  
     8
    99  /**
    1010   * __construct
    11    * @param: mixed col id (##|'new')
    12    * @param: array images
     11   * @throws Exception
     12   *
     13   * @param int|string $col_id or 'new'
     14   * @param string $name
     15   * @param string $comment
     16   * @param int $user_id
    1317   */
    1418  function __construct($col_id, $name=null, $comment=null, $user_id=null)
    1519  {
    1620    global $user;
    17    
     21
    1822    if (empty($user_id))
    1923    {
    2024      $user_id = $user['id'];
    2125    }
    22    
     26
    2327    $this->data = array(
    2428      'id' => 0,
     
    3034      );
    3135    $this->images = array();
    32    
     36
    3337    // load specific collection
    3438    if (preg_match('#^[0-9]+$#', $col_id))
     
    4044;';
    4145      $result = pwg_query($query);
    42      
     46
    4347      if (pwg_db_num_rows($result))
    4448      {
     
    4751          pwg_db_fetch_assoc($result)
    4852          );
    49        
     53
    5054        // make sure all pictures of the collection exist
    5155        $query = '
     
    5660;';
    5761        pwg_query($query);
    58      
     62
    5963        // select images of the collection
    6064        $query = '
     
    6468;';
    6569        $this->images = array_from_query($query, 'image_id');
    66        
     70
    6771        $this->updateParam('nb_images', count($this->images));
    6872      }
     
    7781      $this->data['name'] = $name;
    7882      $this->data['comment'] = $comment;
    79      
     83
    8084      $query = '
    8185INSERT INTO '.COLLECTIONS_TABLE.'(
     
    8488    date_creation,
    8589    comment
    86   ) 
     90  )
    8791  VALUES(
    8892    '.$this->data['user_id'].',
     
    9498      pwg_query($query);
    9599      $this->data['id'] = pwg_db_insert_id();
    96      
     100
    97101      $date = pwg_query('SELECT NOW();');
    98102      list($this->data['date_creation']) = pwg_db_fetch_row($date);
     
    103107    }
    104108  }
    105  
    106   /**
    107    * check if current user is owner of the collection or admin
     109
     110  /**
     111   * Check if current user is owner of the collection or admin
     112   * @throws Exception
    108113   */
    109114  function checkUser()
    110115  {
    111116    global $user;
    112    
     117
    113118    if (!is_admin() && $user['id'] != $this->data['user_id'])
    114119    {
     
    116121    }
    117122  }
    118  
     123
    119124  /**
    120125   * updateParam
    121    * @param: string param name
    122    * @param: mixed param value
     126   *
     127   * @param string $name
     128   * @param mixed $value
    123129   */
    124130  function updateParam($name, $value)
     
    130136    }
    131137  }
    132  
     138
    133139  /**
    134140   * getParam
    135    * @param: string param name
    136    * @return: mixed param value
     141   *
     142   * @param string $name
     143   * @return mixed
    137144   */
    138145  function getParam($name)
     
    140147    return $this->data[$name];
    141148  }
    142  
     149
    143150  /**
    144151   * getImages
    145    * @return: array
     152   *
     153   * @return int[]
    146154   */
    147155  function getImages()
     
    149157    return $this->images;
    150158  }
    151  
    152   /**
    153    * isInSet
    154    * @param: int image id
    155    * @return: bool
     159
     160  /**
     161   * Check if an image is in the collection.
     162   *
     163   * @param int $image_id
     164   * @return bool
    156165   */
    157166  function isInSet($image_id)
     
    159168    return in_array($image_id, $this->images);
    160169  }
    161  
     170
    162171  /**
    163172   * removeImages
    164    * @param: array image ids
     173   *
     174   * @param int|int[] $image_ids
    165175   */
    166176  function removeImages($image_ids)
    167177  {
    168     if (empty($image_ids) or !is_array($image_ids)) return;
    169    
     178    if (empty($image_ids)) return;
     179    if (!is_array($image_ids)) $image_ids = array($image_ids);
     180
    170181    $this->images = array_diff($this->images, $image_ids);
    171    
     182
    172183    $query = '
    173184DELETE FROM '.COLLECTION_IMAGES_TABLE.'
    174   WHERE 
     185  WHERE
    175186    col_id = '.$this->data['id'].'
    176187    AND image_id IN('.implode(',', $image_ids).')
    177188;';
    178189    pwg_query($query);
    179    
     190
    180191    $this->updateParam('nb_images', count($this->images));
    181192  }
    182  
     193
    183194  /**
    184195   * addImages
    185    * @param: array image ids
     196   *
     197   * @param int|int[] $image_ids
    186198   */
    187199  function addImages($image_ids)
    188200  {
    189     if (empty($image_ids) or !is_array($image_ids)) return;
    190    
     201    if (empty($image_ids)) return;
     202    if (!is_array($image_ids)) $image_ids = array($image_ids);
     203
    191204    $image_ids = array_unique($image_ids);
    192205    $inserts = array();
    193    
     206
    194207    foreach ($image_ids as $image_id)
    195208    {
    196209      if ($this->isInSet($image_id)) continue;
    197      
     210
    198211      $this->images[] = $image_id;
    199212      $inserts[] = array(
     
    202215        );
    203216    }
    204    
     217
    205218    mass_inserts(
    206219      COLLECTION_IMAGES_TABLE,
     
    208221      $inserts
    209222      );
    210      
     223
    211224    $query = '
    212225UPDATE '.COLLECTION_IMAGES_TABLE.'
     
    218231';
    219232    pwg_query($query);
    220      
     233
    221234    $this->updateParam('nb_images', count($this->images));
    222235  }
    223  
     236
    224237  /**
    225238   * toggleImage
    226    * @param: int image id
     239   *
     240   * @param int $image_id
    227241   */
    228242  function toggleImage($image_id)
     
    237251    }
    238252  }
    239  
     253
    240254  /**
    241255   * clearImages
     
    245259    $this->images = array();
    246260    $this->updateParam('nb_images', 0);
    247    
     261
    248262    $query = '
    249263DELETE FROM '.COLLECTION_IMAGES_TABLE.'
     
    252266    pwg_query($query);
    253267  }
    254  
     268
    255269  /**
    256270   * getCollectionInfo
    257    * @return: array
     271   *
     272   * @return array
    258273   */
    259274  function getCollectionInfo()
     
    266281      'DATE_CREATION' => $this->data['date_creation'],
    267282      );
    268    
     283
    269284    return $set;
    270285  }
    271  
    272   /**
    273    * get share links
     286
     287  /**
     288   * Returns share links
     289   *
     290   * @return array
    274291   */
    275292  function getShares()
     
    281298;';
    282299    $result = pwg_query($query);
    283    
     300
    284301    $shares = array();
    285302    while ($row = pwg_db_fetch_assoc($result))
    286303    {
    287304      $row['expired'] = false;
    288      
     305
    289306      $row['params'] = unserialize($row['params']);
    290307      if (!empty($row['params']['deadline']))
     
    293310        $row['params']['deadline_readable'] = format_date($row['params']['deadline'], true, false);
    294311      }
    295      
     312
    296313      $row['url'] = USER_COLLEC_PUBLIC . 'view/' . $row['share_key'];
    297314      $row['u_delete'] = USER_COLLEC_PUBLIC . 'edit/' . $this->data['id'] . '&amp;delete_share=' . $row['id'];
    298315      $row['add_date_readable'] = format_date($row['add_date'], true, false);
    299      
     316
    300317      $shares[] = $row;
    301318    }
    302    
     319
    303320    return $shares;
    304321  }
    305  
    306   /**
    307    * delete a share
     322
     323  /**
     324   * Delete a share
     325   *
     326   * @param int $id
     327   * @return bool
    308328   */
    309329  function deleteShare($id)
     
    315335;';
    316336    pwg_query($query);
    317    
     337
    318338    return pwg_db_changes() != 0;
    319339  }
    320  
    321   /**
    322    * Add a share URL
    323    * @param: array
    324    *          - share_key
    325    *          - password
    326    *          - deadline
    327    * @return: array errors
     340
     341  /**
     342   * Add a share link
     343   *
     344   * @param array &$share
     345   *          - share_key (will be slugified)
     346   *          - password (optional)
     347   *          - deadline (optional)
     348   * @param bool $abord_on_duplicate
     349   * @return array|string errors or full share link
    328350   */
    329351  function addShare(&$share, $abord_on_duplicate=true)
    330352  {
    331353    global $conf, $page;
    332    
     354
    333355    $errors = array();
    334    
     356
    335357    $share = array_map('stripslashes', $share);
    336    
     358
    337359    // check key
    338360    if (empty($share['share_key']) || strlen($share['share_key']) < 8)
     
    344366      $share['share_key'] = str2url($share['share_key']);
    345367      $share_key = $this->data['id'].'-'.$share['share_key'];
    346      
     368
    347369      $query = '
    348370SELECT id FROM '.COLLECTION_SHARES_TABLE.'
     
    363385      }
    364386    }
    365    
     387
    366388    // filter date
    367389    if (!empty($share['deadline']))
    368390    {
    369       $date = DateTime::createFromFormat('Y-m-d H:i', $share['deadline']);
    370       $share['deadline'] = $date->format('Y-m-d H:i');
    371     }
    372    
     391      $share['deadline'] = transform_date($share['deadline'], 'Y-m-d H:i', 'Y-m-d H:i');
     392    }
     393
    373394    // hash password
    374395    if (!empty($share['password']))
     
    376397      $share['password'] = sha1($conf['secret_key'].$share['password'].$share_key);
    377398    }
    378    
     399
    379400    if (empty($errors))
    380401    {
     
    383404        'deadline' => @$share['deadline'],
    384405        ));
    385      
     406
    386407      $query = '
    387408INSERT INTO '.COLLECTION_SHARES_TABLE.'(
     
    399420;';
    400421      pwg_query($query);
    401      
     422
    402423      return USER_COLLEC_PUBLIC . 'view/' . $share_key;
    403424    }
    404    
     425
    405426    return $errors;
    406427  }
    407  
     428
    408429  /**
    409430   * Send the collection by email
    410    * @param: array
     431   *
     432   * @param array $comm
    411433   *          - sender_name
    412434   *          - sender_email
     
    415437   *          - nb_images
    416438   *          - message
    417    * @return: array errors
     439   * @return array|true array errors or true
    418440   */
    419441  function sendEmail($comm)
    420442  {
    421     global $conf;
    422    
     443    global $conf, $user;
     444
    423445    $errors = array();
    424    
     446
    425447    $comm = array_map('stripslashes', $comm);
    426448
    427     $comment_action='validate';
     449    $comment_action = 'validate';
    428450
    429451    // check author
    430452    if (empty($comm['sender_name']))
    431453    {
    432       array_push($errors, l10n('Please enter your name'));
    433       $comment_action='reject';
    434     }     
     454      $errors[] = l10n('Please enter your name');
     455      $comment_action = 'reject';
     456    }
    435457    if (empty($comm['recipient_name']))
    436458    {
    437       array_push($errors, l10n('Please enter the recipient name'));
    438       $comment_action='reject';
    439     }
    440    
     459      $errors[] = l10n('Please enter the recipient name');
     460      $comment_action = 'reject';
     461    }
     462
    441463    // check email
    442464    if (empty($comm['sender_email']))
    443465    {
    444       array_push($errors, l10n('Please enter your e-mail'));
    445       $comment_action='reject';
    446     }
    447     else if ( !empty($comm['sender_email']) and !uc_check_email_validity($comm['sender_email']) )
    448     {
    449       array_push($errors, l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));
    450       $comment_action='reject';
     466      $errors[] = l10n('Please enter your e-mail');
     467      $comment_action = 'reject';
     468    }
     469    else if (!empty($comm['sender_email']) and !email_check_format($comm['sender_email']))
     470    {
     471      $errors[] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)');
     472      $comment_action = 'reject';
    451473    }
    452474    if (empty($comm['recipient_email']))
    453475    {
    454       array_push($errors, l10n('Please enter the recipient e-mail'));
    455       $comment_action='reject';
    456     }
    457     else if ( !empty($comm['recipient_email']) and !uc_check_email_validity($comm['recipient_email']) )
    458     {
    459       array_push($errors, l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'));
    460       $comment_action='reject';
    461     }
    462      
     476      $errors[] = l10n('Please enter the recipient e-mail');
     477      $comment_action = 'reject';
     478    }
     479    else if (!empty($comm['recipient_email']) and !email_check_format($comm['recipient_email']))
     480    {
     481      $errors[] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)');
     482      $comment_action = 'reject';
     483    }
     484
    463485    // check content
    464486    if (!empty($comm['message']))
     
    466488      $comm['message'] = nl2br($comm['message']);
    467489    }
    468    
     490
    469491    include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    470    
     492
    471493    if ($comment_action == 'validate')
    472494    {
    473       // format subject
    474       $subject = '['.$conf['gallery_title'].'] '.sprintf(l10n('A photo collection by %s'), $comm['sender_name']);
    475       $subject = encode_mime_header($subject);
    476            
    477       // format expeditor
    478       $args['from'] = format_email($comm['sender_name'], $comm['sender_email']);
    479       $args['to'] = format_email($comm['recipient_name'], $comm['recipient_email']);
    480      
    481       // hearders
    482       $headers = 'From: '.$args['from']."\n"; 
    483       $headers.= 'MIME-Version: 1.0'."\n";
    484       $headers.= 'X-Mailer: Piwigo Mailer'."\n";
    485       $headers.= 'Content-Transfer-Encoding: 8bit'."\n";
    486       $headers.= 'Content-Type: text/html; charset="'.get_pwg_charset().'";'."\n";
    487            
    488       // mail content
    489       $content = $this->getMailContent($comm);
    490       $content = wordwrap($content, 70, "\n", true);
    491      
    492       // send mail
    493       $result =
    494         trigger_event('send_mail',
    495           false, /* Result */
    496           trigger_event('send_mail_to', $args['to']),
    497           trigger_event('send_mail_subject', $subject),
    498           trigger_event('send_mail_content', $content),
    499           trigger_event('send_mail_headers', $headers),
    500           $args
    501         );
    502      
    503       if ($result == false)
    504       {
    505         array_push($errors, l10n('Error while sending e-mail'));
    506       }
    507       else
    508       {
    509         return true;
    510       }
    511     }
    512    
    513     return $errors;
    514   }
    515  
    516   /**
    517    * get mail content for sendMail()
    518    */
    519   function getMailContent($params)
    520   {
    521     global $user, $conf, $template;
    522    
    523     // switch to guest user
    524     $user_save = $user;
    525     $user = build_user($conf['guest_id'], true);
    526    
    527     // get pictures
    528     $query = '
     495      // switch to guest user for get_sql_condition_FandF
     496      $user_save = $user;
     497      $user = build_user($conf['guest_id'], true);
     498
     499      // get pictures
     500      $query = '
    529501SELECT
    530     id,
    531     file,
    532     name,
    533     path
     502    id, file, name, path
    534503  FROM '.IMAGES_TABLE.' AS i
    535504    JOIN '.IMAGE_CATEGORY_TABLE.' AS ci ON ci.image_id = i.id
    536   WHERE id IN ('.implode(',', $this->images).')
    537     '.get_sql_condition_FandF(array(
    538                 'forbidden_categories' => 'category_id',
    539                 'forbidden_images' => 'id'
    540                 ),
    541               'AND'
    542               ).'
     505  WHERE id IN ('. implode(',', $this->images) .')
     506    '.get_sql_condition_FandF(
     507        array(
     508          'forbidden_categories' => 'category_id',
     509          'forbidden_images' => 'id'
     510          ),
     511        'AND'
     512        ).'
    543513  GROUP BY i.id
    544   ORDER BY '.DB_RANDOM_FUNCTION.'()
    545   LIMIT '.$params['nb_images'].'
    546 ;';
    547     $pictures = hash_from_query($query, 'id');
    548    
    549     // switch back to current user
    550     $user = $user_save;
    551     unset($user_save);
    552  
    553     // picture sinfos
    554     set_make_full_url();
    555     $tpl_vars = array();
    556     foreach ($pictures as $row)
    557     {
    558       $name = render_element_name($row);
    559      
    560       $tpl_vars[] = array(
    561         'TN_ALT' => htmlspecialchars(strip_tags($name)),
    562         'NAME' => $name,
    563         'URL' => make_picture_url(array('image_id' => $row['id'])),
    564         'THUMB' => DerivativeImage::url(IMG_SQUARE, $row),
     514  ORDER BY '. DB_RANDOM_FUNCTION .'()
     515  LIMIT '. $comm['nb_images'] .'
     516;';
     517      $pictures = hash_from_query($query, 'id');
     518
     519      // switch back to current user
     520      $user = $user_save;
     521      unset($user_save);
     522
     523      $share_key = array('share_key'=>'mail-' . substr(sha1($this->data['id'].$conf['secret_key']), 0, 11));
     524
     525      $tpl_vars = array(
     526        'COL_URL' => $this->addShare($share_key, false),
     527        'PARAMS' => $comm,
     528        'derivative_params' => ImageStdParams::get_by_type(IMG_SQUARE),
    565529        );
    566     }
    567    
    568     // template
    569     $mail_css = file_get_contents(dirname(__FILE__).'/../template/mail.css');
    570    
    571     $share_key = array('share_key'=>'mail-' . substr(sha1($this->data['id'].$conf['secret_key']), 0, 11));
    572    
    573     $template->assign(array(
    574       'GALLERY_URL' => get_gallery_home_url(),
    575       'PHPWG_URL' => PHPWG_URL,
    576       'UC_MAIL_CSS' => str_replace("\n", null, $mail_css),
    577       'MAIL_TITLE' => $this->getParam('name').' ('.sprintf(l10n('by %s'), $params['sender_name']).')',
    578       'COL_URL' => $this->addShare($share_key, false),
    579       'PARAMS' => $params,
    580       'derivative_params' => ImageStdParams::get_by_type(IMG_SQUARE),
    581       'thumbnails' => $tpl_vars,
    582       ));
    583      
    584     $template->set_filename('uc_mail', dirname(__FILE__).'/../template/mail.tpl');
    585     $content = $template->parse('uc_mail', true);
    586  
    587     unset_make_full_url();
    588    
    589     return $content;
    590   }
    591 
    592   /**
    593    * generate a listing of the collection
     530
     531      // pictures infos
     532      set_make_full_url();
     533
     534      foreach ($pictures as $row)
     535      {
     536        $name = render_element_name($row);
     537
     538        $tpl_vars['THUMBNAILS'][] = array(
     539          'TN_ALT' => htmlspecialchars(strip_tags($name)),
     540          'NAME' =>   $name,
     541          'URL' =>    make_picture_url(array('image_id' => $row['id'])),
     542          'THUMB' =>  DerivativeImage::url(IMG_SQUARE, $row),
     543          );
     544      }
     545
     546      unset_make_full_url();
     547
     548      $result = pwg_mail(
     549        array(
     550          'name' => $comm['recipient_name'],
     551          'email' => $comm['recipient_email'],
     552          ),
     553        array(
     554          'subject' => '['.$conf['gallery_title'].'] '.l10n('A photo collection by %s', $comm['sender_name']),
     555          'mail_title' => $this->getParam('name'),
     556          'mail_subtitle' => l10n('by %s', $comm['sender_name']),
     557          'content_format' => 'text/html',
     558          'from' => array(
     559            'name' => $comm['sender_name'],
     560            'email' => $comm['sender_email'],
     561            )
     562          ),
     563        array(
     564          'filename' => 'mail',
     565          'dirname' => realpath(USER_COLLEC_PATH . 'template'),
     566          'assign' => $tpl_vars,
     567          )
     568        );
     569
     570      if ($result == false)
     571      {
     572        $errors[] = l10n('Error while sending e-mail');
     573      }
     574      else
     575      {
     576        return true;
     577      }
     578    }
     579
     580    return $errors;
     581  }
     582
     583  /**
     584   * Generate a listing of the collection
     585   *
     586   * @param string[] $fields
     587   * @return string
    594588   */
    595589  function serialize($params)
    596590  {
    597     $params = array_intersect($params, array('id','file','name','url','path','date_creation','collection_add_date','filesize','width','height'));
    598    
     591    $fields = array_intersect($fields, array('id','file','name','url','path','date_creation','collection_add_date','filesize','width','height'));
     592
    599593    $content = null;
    600      
     594
    601595    // get images infos
    602596    $query = '
     
    617611;';
    618612    $pictures = hash_from_query($query, 'id');
    619    
     613
    620614    if (count($pictures))
    621615    {
     
    623617      set_make_full_url();
    624618      $root_url = get_root_url();
    625      
     619
    626620      $fp = fopen('php://temp', 'r+');
    627       fputcsv($fp, $params);
    628        
     621      fputcsv($fp, $fields);
     622
    629623      foreach ($pictures as $row)
    630624      {
    631625        $element = array();
    632         foreach ($params as $field)
     626        foreach ($fields as $field)
    633627        {
    634628          switch ($field)
     
    653647        }
    654648      }
    655      
     649
    656650      rewind($fp);
    657651      $content = stream_get_contents($fp);
    658652      fclose($fp);
    659      
     653
    660654      unset_make_full_url();
    661655    }
    662    
     656
    663657    return $content;
    664658  }
    665  
    666   /**
    667    * delete
     659
     660  /**
     661   * Delete the collection
    668662   */
    669663  function delete()
     
    673667  }
    674668}
    675 
    676 ?>
  • extensions/UserCollections/include/collections.inc.php

    r25674 r25678  
    2121    access_denied();
    2222  }
    23  
    24   $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collections_list.tpl'));
    25  
     23
     24  $template->set_filename('uc_page', realpath(USER_COLLEC_PATH.'template/collections_list.tpl'));
     25
    2626  // actions
    27   if ( isset($_GET['action']) and preg_match('#^([0-9]+)$#', $_GET['col_id']) )
     27  if (isset($_GET['action']) and preg_match('#^([0-9]+)$#', $_GET['col_id']))
    2828  {
    2929    switch ($_GET['action'])
     
    3939        {
    4040          $collection = new UserCollection('new', $_GET['name']);
    41          
     41
    4242          if (isset($_GET['redirect']))
    4343          {
     
    5252        break;
    5353      }
    54        
     54
    5555      ## delete collection ##
    5656      case 'delete':
     
    6969    }
    7070  }
    71  
     71
    7272  $template->assign('U_CREATE',
    7373    add_url_params(USER_COLLEC_PUBLIC, array('action'=>'new','col_id'=>'0'))
    7474    );
    75  
     75
    7676  $template->set_prefilter('index_category_thumbnails', 'user_collections_categories_list');
    77  
     77
    7878  include(USER_COLLEC_PATH . '/include/display_collections.inc.php');
    79  
     79
    8080  break;
    8181}
     
    9292    redirect(USER_COLLEC_PUBLIC);
    9393  }
    94  
    95   $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collection_edit.tpl'));
    96  
     94
     95  $template->set_filename('uc_page', realpath(USER_COLLEC_PATH.'template/collection_edit.tpl'));
     96
    9797  $self_url = USER_COLLEC_PUBLIC . 'edit/' . $page['col_id'];
    98  
     98
    9999  $template->assign(array(
    100100    'F_ACTION' => $self_url,
     
    102102    'UC_IN_EDIT' => true,
    103103    ));
    104  
     104
    105105  try {
    106106    $collection = new UserCollection($page['col_id']);
    107107    $collection->checkUser();
    108    
     108
    109109    // save properties
    110110    if (isset($_POST['save_col']))
     
    118118        $collection->updateParam('name', stripslashes($_POST['name']));
    119119      }
    120       $collection->updateParam('comment', stripslashes($_POST['comment']));
    121     }
    122    
     120      $collection->updateParam('comment', stripslashes(@$_POST['comment']));
     121    }
     122
    123123    // add key
    124124    if ($conf['user_collections']['allow_public'])
     
    127127      {
    128128        $share = array(
    129           'share_key' =>  trim($_POST['share_key']),
    130           'password' =>   isset($_POST['use_share_password']) ? trim($_POST['share_password']) : '',
    131           'deadline' =>   isset($_POST['use_share_deadline']) ? trim($_POST['share_deadline']) : '',
     129          'share_key' => trim($_POST['share_key']),
     130          'password' =>  isset($_POST['use_share_password']) ? trim($_POST['share_password']) : '',
     131          'deadline' =>  isset($_POST['use_share_deadline']) ? trim($_POST['share_deadline']) : '',
    132132          );
    133          
     133
    134134        if (!verify_ephemeral_key(@$_POST['key']))
    135135        {
     
    147147        {
    148148          $share = array();
    149           $share['infos'][] = sprintf(l10n('New share added: <a href="%s">%s</a>'), $result, $result);
     149          $share['infos'][] = l10n('New share added: <a href="%s">%s</a>', $result, $result);
    150150        }
    151151        $share['open'] = true;
     
    163163      {
    164164        $share['share_key'] = get_random_key(16);
    165         $share['password'] = null;
    166         $share['deadline'] = null;
     165        $share['password'] =  null;
     166        $share['deadline'] =  null;
    167167      }
    168168
    169169      $template->assign('share', $share);
    170170    }
    171    
     171
    172172    // send mail
    173     if ( $conf['user_collections']['allow_mails'] && $conf['user_collections']['allow_public'] )
    174     {
    175       $contact = array(
    176         'sender_name' =>      $user['username'],
    177         'sender_email' =>     $user['email'],
    178         'recipient_name' =>   null,
    179         'recipient_email' =>  null,
    180         'nb_images' =>        4,
    181         'message' =>          null,
    182         );
    183          
     173    if ($conf['user_collections']['allow_mails'] && $conf['user_collections']['allow_public'])
     174    {
    184175      if (isset($_POST['send_mail']))
    185176      {
     
    192183          'message' =>          $_POST['message'],
    193184          );
    194        
     185
    195186        if (!verify_ephemeral_key(@$_POST['key']))
    196187        {
     
    212203        }
    213204      }
    214      
     205
     206      if (!isset($contact['sender_email']))
     207      {
     208        $contact['sender_name'] =     $user['username'];
     209        $contact['sender_email'] =    $user['email'];
     210        $contact['recipient_name'] =  null;
     211        $contact['recipient_email'] = null;
     212        $contact['nb_images'] =       4;
     213        $contact['message'] =         null;
     214      }
     215
    215216      $template->assign('contact', $contact);
    216217    }
    217    
     218
    218219    // clear
    219     if ( isset($_GET['action']) and $_GET['action'] == 'clear' )
     220    if (isset($_GET['action']) && $_GET['action'] == 'clear')
    220221    {
    221222      $collection->clearImages();
    222223    }
    223    
    224    
     224
     225
    225226    // add remove item links
    226227    $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button');
    227228    $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox');
    228    
     229
    229230    // thumbnails
    230231    include(USER_COLLEC_PATH . '/include/display_thumbnails.inc.php');
    231    
    232    
     232
     233
    233234    // collection properties
    234235    $infos = $collection->getCollectionInfo();
    235236    $infos['DATE_CREATION'] = format_date($infos['DATE_CREATION'], true);
    236237    $infos['SHARES'] = $collection->getShares();
    237     $template->assign('collection', $infos);
    238    
     238    $template->assign('collection', $infos);
     239
     240
    239241    // toolbar buttons
    240242    if (!empty($page['items']))
    241243    {
    242       $template->assign('U_CLEAR',
     244      if ($conf['user_collections']['allow_public'])
     245      {
     246        user_collections_add_button('share', 'U_SHARE',
     247          USER_COLLEC_PUBLIC . 'view/' . $page['col_id'] .'-'
     248          );
     249
     250        if ($conf['user_collections']['allow_mails'])
     251        {
     252          user_collections_add_button('mail', 'U_MAIL', true);
     253        }
     254      }
     255
     256      user_collections_add_button('clear', 'U_CLEAR',
    243257        add_url_params($self_url, array('action'=>'clear'))
    244258        );
    245259    }
    246     $template->assign('U_DELETE',
     260
     261    user_collections_add_button('delete', 'U_DELETE',
    247262      add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$page['col_id']))
    248263      );
    249      
    250     if ( $conf['user_collections']['allow_public'] && !empty($page['items']) )
    251     {
    252       $template->assign('U_SHARE', USER_COLLEC_PUBLIC . 'view/' . $page['col_id'] .'-');
    253     }
    254     if ( $conf['user_collections']['allow_mails'] && $conf['user_collections']['allow_public'] && !empty($page['items']) )
    255     {
    256       $template->assign('U_MAIL', true);
    257     }
     264
    258265    $template->assign('UC_TKEY', get_ephemeral_key(3));
    259    
     266
    260267    // modify page title
    261     $template->concat('TITLE', 
    262       $conf['level_separator'] . trigger_event('render_category_name', $infos['NAME'])
     268    $template->concat('TITLE',
     269      $conf['level_separator'] . trigger_change('render_category_name', $infos['NAME'])
    263270      );
    264    
     271
    265272    // render description
    266273    $template->assign('CONTENT_DESCRIPTION',
    267       trigger_event('render_category_description', nl2br($infos['COMMENT']))
     274      trigger_change('render_category_description', nl2br($infos['COMMENT']))
    268275      );
    269276  }
     
    272279    $page['errors'][] = $e->getMessage();
    273280  }
    274  
     281
    275282  break;
    276283}
     
    282289{
    283290  $page['col_key'] = $page['col_id'];
    284  
     291
    285292  if (!$conf['user_collections']['allow_public'])
    286293  {
     
    291298    bad_request('');
    292299  }
    293  
     300
    294301  $query = '
    295302SELECT col_id, params
     
    298305;';
    299306  $result = pwg_query($query);
     307
    300308  if (!pwg_db_num_rows($result))
    301309  {
    302310    page_not_found(l10n('Collection not found'));
    303311  }
    304  
     312
    305313  list($page['col_id'], $share_params) = pwg_db_fetch_row($result);
    306314  $share_params = unserialize($share_params);
    307  
     315
    308316  // deadline check
    309   if ( !empty($share_params['deadline']) && strtotime($share_params['deadline'])<time() )
     317  if (!empty($share_params['deadline']) && strtotime($share_params['deadline'])<time())
    310318  {
    311319    page_not_found(l10n('This link expired'));
    312320  }
    313  
     321
    314322  $self_url = USER_COLLEC_PUBLIC . 'view/' . $page['col_key'];
    315  
    316   $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collection_view.tpl'));
    317  
     323
     324  $template->set_filename('uc_page', realpath(USER_COLLEC_PATH.'template/collection_view.tpl'));
     325
    318326  try {
    319327    $collection = new UserCollection($page['col_id']);
    320328    $col = $collection->getCollectionInfo();
    321    
     329
    322330    $mode = 'view';
    323    
     331
    324332    // password check
    325333    if (!empty($share_params['password']))
     
    351359      }
    352360    }
    353    
     361
    354362    if ($mode == 'view')
    355363    {
    356364      $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox');
    357      
     365
    358366      // thumbnails
    359367      include(USER_COLLEC_PATH . '/include/display_thumbnails.inc.php');
    360      
     368
    361369      // render description
    362370      $template->assign('CONTENT_DESCRIPTION',
    363         trigger_event('render_category_description', nl2br($col['COMMENT']))
     371        trigger_change('render_category_description', nl2br($col['COMMENT']))
    364372        );
    365373    }
    366    
     374
    367375    // add username in title
    368376    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    369     $template->concat('TITLE',
    370       $conf['level_separator'] . trigger_event('render_category_name', $col['NAME']) .
    371       ' (' . sprintf(l10n('by %s'), get_username($collection->getParam('user_id'))) . ')'
     377
     378    $template->concat('TITLE',
     379      $conf['level_separator'] . trigger_change('render_category_name', $col['NAME']) .
     380      ' (' . l10n('by %s', get_username($collection->getParam('user_id'))) . ')'
    372381      );
    373      
     382
    374383    $template->assign('UC_MODE', $mode);
    375384  }
     
    378387    access_denied();
    379388  }
    380  
     389
    381390  break;
    382391}
    383392}
     393
     394$template->assign_var_from_handle('CONTENT', 'uc_page');
    384395
    385396
     
    393404    | <a href="{$cat.U_DELETE}" onClick="return confirm(\'{"Are you sure?"|@translate}\');" rel="nofollow">{"Delete"|@translate}</a>
    394405  </div>';
    395  
     406
    396407  return str_replace($search, $replace, $content);
    397408}
     
    402413  $search = '<a href="{$thumbnail.URL}"';
    403414  $replace = $search.' class="preview-box" data-src="{$thumbnail.FILE_SRC}" data-id="{$thumbnail.id}"';
    404  
     415
    405416  return str_replace($search, $replace, $content);
    406417}
    407418
    408 ?>
     419// add special buttons
     420function user_collections_add_button($tpl_file, $tpl_var, $value)
     421{
     422  global $template;
     423
     424  $template->assign($tpl_var, $value);
     425  $template->set_filename('uc_button_'.$tpl_file, realpath(USER_COLLEC_PATH.'template/buttons/'. $tpl_file .'.tpl'));
     426  $template->add_index_button($template->parse('uc_button_'.$tpl_file, true));
     427}
  • extensions/UserCollections/include/display_collections.inc.php

    r23551 r25678  
    11<?php
    22defined('USER_COLLEC_PATH') or die('Hacking attempt!');
    3 
    43
    54// collections orders
     
    2019$orders = get_collections_preferred_orders();
    2120
     21
    2222// get sorted collections
    2323$query = '
    24 SELECT * 
     24SELECT *
    2525  FROM '.COLLECTIONS_TABLE.'
    2626  WHERE user_id = '.$user['id'].'
     
    3131$template->assign('COLLECTIONS_COUNT', count($categories));
    3232
     33
    3334// order menu
    3435if (count($categories))
    3536{
    3637  $url = add_url_params(USER_COLLEC_PUBLIC, array('uc_collection_order' => ''));
    37  
     38
    3839  foreach ($orders as $order_id => $order)
    3940  {
     
    5354
    5455
     56// collections details
    5557if (count($categories))
    5658{
     
    6971;';
    7072  $thumbnails = hash_from_query($query, 'col_id');
    71  
     73
    7274  $thumbnails[0] = array(
    7375    'id' => 0,
     
    7880    'rotation' => 0,
    7981    );
    80  
     82
    8183  foreach ($thumbnails as &$info)
    8284  {
     
    8486  }
    8587  unset($info);
    86  
     88
    8789  $tpl_thumbnails_var = array();
    8890
     
    9193    $thumb = empty($thumbnails[ $category['id'] ]) ? $thumbnails[0] : $thumbnails[ $category['id'] ];
    9294    $counter = get_display_images_count($category['nb_images'], $category['nb_images'], 0);
    93    
    94     $tpl_var = array_merge( $category, array(
    95       'representative'   => $thumb,
    96       'TN_ALT'   => strip_tags($category['name']),
    97       'URL'   => USER_COLLEC_PUBLIC.'edit/'.$category['id'],
    98       'CAPTION_NB_IMAGES' => empty($counter) ? sprintf(l10n('%d photo'), 0) : $counter,
    99       'NAME'  => trigger_event('render_category_name', $category['name']),
    100       'DESCRIPTION'  => trigger_event('render_category_description', $category['comment'], 'subcatify_category_description'),
    101       'INFO_DATES' => format_date($category['date_creation'], true),
    102       'U_DELETE' => add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$category['id'])),
     95
     96    $tpl_var = array_merge($category, array(
     97      'representative' =>    $thumb,
     98      'TN_ALT' =>            strip_tags($category['name']),
     99      'URL' =>                USER_COLLEC_PUBLIC.'edit/'.$category['id'],
     100      'CAPTION_NB_IMAGES' =>  empty($counter) ? l10n('%d photo', 0) : $counter,
     101      'NAME' =>               trigger_change('render_category_name', $category['name']),
     102      'DESCRIPTION' =>        trigger_change('render_category_description', $category['comment'], 'subcatify_category_description'),
     103      'INFO_DATES' =>         format_date($category['date_creation'], true),
     104      'U_DELETE' =>           add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$category['id'])),
    103105      ));
    104106
    105107    $tpl_thumbnails_var[] = $tpl_var;
    106108  }
    107  
    108   $derivative_params = trigger_event('get_index_album_derivative_params', ImageStdParams::get_by_type(IMG_THUMB) );
     109
     110  $derivative_params = trigger_change('get_index_album_derivative_params', ImageStdParams::get_by_type(IMG_THUMB) );
    109111  $template->assign(array(
    110     'maxRequests' =>$conf['max_requests'],
     112    'maxRequests' => $conf['max_requests'],
    111113    'category_thumbnails' => $tpl_thumbnails_var,
    112114    'derivative_params' => $derivative_params,
    113115    ));
    114  
     116
    115117  $template->set_filename('index_category_thumbnails', 'mainpage_categories.tpl');
    116118  $template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails');
    117119}
    118 
    119 ?>
  • extensions/UserCollections/include/display_thumbnails.inc.php

    r23551 r25678  
    11<?php
    22defined('USER_COLLEC_PATH') or die('Hacking attempt!');
    3 
    43
    54// image order
     
    1716}
    1817
    19 // get sorted elements
    2018$image_order_id = pwg_get_session_var('uc_image_order', 0);
    2119$orders = get_collection_preferred_image_orders();
    2220
     21
     22// get sorted elements
    2323$query = '
    2424SELECT i.id
     
    3131$page['items'] = array_from_query($query, 'id');
    3232
     33
    3334// caddie
    3435if (isset($_GET['uc_caddie']))
     
    3839}
    3940
     41
    4042// image order menu
    4143if ( $conf['index_sort_order_input']
     
    4345{
    4446  $url = add_url_params($self_url, array('uc_image_order' => ''));
    45  
     47
    4648  foreach ($orders as $order_id => $order)
    4749  {
     
    7577}
    7678
     79
    7780// add links for colorbox
    7881add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_in_collection', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    7982
     83// photos details
    8084global $selection, $pictures;
    8185include(PHPWG_ROOT_PATH . 'include/category_default.inc.php');
     
    8387
    8488// multisize menu
    85 if ( !empty($page['items']) )
     89if (!empty($page['items']))
    8690{
    8791  $url = add_url_params($self_url, array('display' => ''));
    88    
     92
    8993  $selected_type = $template->get_template_vars('derivative_params')->type;
    90   $template->clear_assign( 'derivative_params' );
     94  $template->clear_assign('derivative_params');
    9195  $type_map = ImageStdParams::get_defined_type_map();
    9296  unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]);
     
    118122{
    119123  global $template, $page;
    120  
     124
    121125  $url = USER_COLLEC_PUBLIC . 'edit/'.$page['col_id'];
    122  
     126
    123127  foreach ($tpl_thumbnails_var as &$thumbnail)
    124128  {
    125129    $src_image = new SrcImage($thumbnail);
    126    
     130
    127131    $thumbnail['FILE_SRC'] = DerivativeImage::url(IMG_LARGE, $src_image);
    128132    $thumbnail['URL'] = duplicate_picture_url(
     
    135139      );
    136140  }
    137  
     141
    138142  return $tpl_thumbnails_var;
    139143}
    140  
    141 ?>
  • extensions/UserCollections/include/events.inc.php

    r24421 r25678  
    1212  if ($tokens[0] == 'collections')
    1313  {
    14     add_event_handler('loc_begin_page_header', 'user_collections_page_header');
    15    
    1614    $page['section'] = 'collections';
    1715    $page['title'] = l10n('Collections');
    18    
     16    $page['body_id'] = 'theCollectionPage';
     17    $page['is_external'] = true;
     18    $page['is_homepage'] = false;
     19
    1920    $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'];
    20     if (is_a_guest()) $page['section_title'].= l10n('Collections');
    21     else $page['section_title'].= '<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>';
    22    
     21    if (is_a_guest())
     22    {
     23      $page['section_title'].= l10n('Collections');
     24    }
     25    else
     26    {
     27      $page['section_title'].= '<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>';
     28    }
     29
     30    $page['sub_section'] = 'list';
    2331    if (in_array(@$tokens[1], array('edit','view','list')))
    2432    {
    2533      $page['sub_section'] = $tokens[1];
    26       if ($tokens[1]=='edit' && isset($conf['GThumb']) && is_array($conf['GThumb']))
    27       {
    28         $conf['GThumb']['big_thumb'] = false; // big thumb is buggy with removes
    29       }
    30     }
    31     else
    32     {
    33       $page['sub_section'] = 'list';
    34     }
    35    
     34    }
     35
     36    if ($page['sub_section']=='edit' && isset($conf['GThumb']) && is_array($conf['GThumb']))
     37    {
     38      $conf['GThumb']['big_thumb'] = false; // big thumb is buggy with removes
     39    }
     40
    3641    if (!empty($tokens[2]))
    3742    {
     
    3944    }
    4045  }
    41 }
    42 
    43 function user_collections_page_header()
    44 {
    45   global $page;
    46   $page['body_id'] = 'theCollectionPage';
    47 }
    48 
    49 function uc_anti_lightbox($tpl_thumbnails_var)
    50 {
    51   global $template, $page;
    52  
    53   if ($page['section'] == 'collections' && !empty($template->css_by_priority[0]))
    54   {
    55     foreach ($template->css_by_priority[0] as $file)
    56     {
    57       if (strpos($file[0], 'colorbox.css') !== false)
    58       {
    59         $template->assign('UC_NO_LIGHTBOX', true);
    60         break;
    61       }
    62     }
    63   }
    64  
    65   return $tpl_thumbnails_var;
    6646}
    6747
     
    7353  if (isset($page['section']) and $page['section'] == 'collections')
    7454  {
    75     include(USER_COLLEC_PATH . '/include/collections.inc.php');
    76   }
    77  
     55    include(USER_COLLEC_PATH . 'include/collections.inc.php');
     56  }
     57
    7858  if (!is_a_guest() && count($page['items']))
    7959  {
     
    9171{
    9272  if (is_a_guest()) return $tpl_thumbnails_var;
    93  
     73
    9474  global $page, $template, $user;
    95  
     75
    9676  // the content is different on collection edition page and no button on batch downloader set edition page
    97   if ( empty($pictures) or (@$page['section'] == 'collections' and @$page['sub_section']=='edit') or @$page['section'] == 'download')
     77  if (empty($pictures) or (@$page['section'] == 'collections' and @$page['sub_section']=='edit') or @$page['section'] == 'download')
    9878  {
    9979    return $tpl_thumbnails_var;
    10080  }
    101  
     81
    10282  $image_ids = array_map(create_function('$i', 'return $i["id"];'), $pictures);
    103  
     83
    10484  // get collections for each picture
    10585  $query = '
     
    11797;';
    11898  $image_collections = simple_hash_from_query($query, 'image_id', 'col_ids');
    119  
     99
    120100  foreach ($tpl_thumbnails_var as &$thumbnail)
    121101  {
     
    123103  }
    124104  unset($thumbnail);
    125  
     105
    126106  // get all collections
    127107  $query = '
     
    132112;';
    133113  $collections = hash_from_query($query, 'id');
    134  
     114
    135115  foreach ($collections as &$col)
    136116  {
    137     $col["name"] = trigger_event("render_category_name", $col["name"]);
     117    $col["name"] = trigger_change('render_category_name', $col["name"]);
    138118  }
    139119  unset($col);
    140  
     120
    141121  $template->assign(array(
    142122    'COLLECTIONS' => $collections,
    143123    'USER_COLLEC_PATH' => USER_COLLEC_PATH,
    144124    ));
    145  
     125
    146126  // thumbnails buttons
    147127  $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button');
    148  
     128
    149129  return $tpl_thumbnails_var;
    150130}
     
    162142{/if}
    163143</a>{/strip}';
    164  
     144
    165145  return preg_replace($search, $replace, $content);
    166146}
     
    173153function user_collections_picture_page()
    174154{
    175   if (is_a_guest()) return;
    176  
     155  if (is_a_guest())
     156  {
     157    return;
     158  }
     159
    177160  global $template, $picture, $user;
    178  
     161
    179162  // get collections for this picture
    180163  $query = '
     
    190173;';
    191174  list($image_collections) = pwg_db_fetch_row(pwg_query($query));
    192  
     175
    193176  // get all collections
    194177  $query = '
     
    199182;';
    200183  $collections = hash_from_query($query, 'id');
    201  
     184
    202185  foreach ($collections as &$col)
    203186  {
    204     $col["name"] = trigger_event("render_category_name", $col["name"]);
     187    $col["name"] = trigger_change('render_category_name', $col["name"]);
    205188  }
    206189  unset($col);
    207  
     190
    208191  $template->assign(array(
    209192    'CURRENT_COLLECTIONS' => $image_collections,
     
    213196    'IN_PICTURE' => true,
    214197    ));
    215  
     198
    216199  // toolbar button
    217200  $template->set_filename('usercol_button', realpath(USER_COLLEC_PATH.'template/picture_button.tpl'));
     
    227210function user_collections_add_menublock($menu_ref_arr)
    228211{
    229   if (is_a_guest()) return;
    230  
    231212  $menu = &$menu_ref_arr[0];
    232   if ($menu->get_id() != 'menubar') return;
    233    
     213  if (is_a_guest() || $menu->get_id() != 'menubar')
     214  {
     215    return;
     216  }
     217
    234218  $menu->register_block(new RegisteredBlock('mbUserCollection', l10n('Collections'), 'UserCollection'));
    235219}
     
    239223{
    240224  $max = 6;
    241  
     225
    242226  global $template, $page, $conf, $user;
    243227  $menu = &$menu_ref_arr[0];
    244  
     228
    245229  if (($block = $menu->get_block('mbUserCollection')) != null)
    246230  {
     
    252236;';
    253237    $collections = array_values(hash_from_query($query, 'id'));
    254    
     238
    255239    $data['collections'] = array();
    256240    for ($i=0; $i<$max && $i<count($collections); $i++)
    257241    {
    258       $collections[$i]['name'] = trigger_event('render_category_name', $collections[$i]['name']);
     242      $collections[$i]['name'] = trigger_change('render_category_name', $collections[$i]['name']);
    259243      $collections[$i]['u_edit'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id'];
    260244      $data['collections'][] = $collections[$i];
    261245    }
    262    
     246
    263247    $data['NB_COL'] = count($collections);
    264248    if ($data['NB_COL'] > $max)
     
    266250      $data['MORE'] = count($collections)-$max;
    267251    }
    268    
     252
    269253    $data['U_LIST'] = USER_COLLEC_PUBLIC;
    270    
     254
    271255    $block->set_title('<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>');
    272256    $block->template = realpath(USER_COLLEC_PATH . 'template/menublock.tpl');
     
    274258  }
    275259}
    276 
    277 ?>
  • extensions/UserCollections/include/functions.inc.php

    r24421 r25678  
    11<?php
    22defined('USER_COLLEC_PATH') or die('Hacking attempt!');
    3 
    4 function uc_check_email_validity($mail_address)
    5 {
    6   if (function_exists('email_check_format'))
    7   {
    8     return email_check_format($mail_address); // Piwigo 2.5
    9   }
    10   else if (version_compare(PHP_VERSION, '5.2.0') >= 0)
    11   {
    12     return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;
    13   }
    14   else
    15   {
    16     $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
    17     $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
    18     $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
    19 
    20     return (bool)preg_match($regex, $mail_address);
    21   }
    22 }
    233
    244function get_random_key($length=32)
     
    3515{
    3616  global $conf;
    37    
    38   return trigger_event('get_category_preferred_image_orders', array(
     17
     18  return trigger_change('get_category_preferred_image_orders', array(
    3919    array(l10n('Date added to collection, new &rarr; old'), 'add_date DESC', true),
    4020    array(l10n('Date added to collection, old &rarr; new'), 'add_date ASC',  true),
     
    4222    array(l10n('Photo title, Z &rarr; A'),        'name DESC',            true),
    4323    array(l10n('Date created, new &rarr; old'),   'date_creation DESC',   true),
    44     array(l10n('Date created, old &rarr; new'),   'date_creation ASC',    true), 
     24    array(l10n('Date created, old &rarr; new'),   'date_creation ASC',    true),
    4525    array(l10n('Date posted, new &rarr; old'),    'date_available DESC',  true),
    4626    array(l10n('Date posted, old &rarr; new'),    'date_available ASC',   true),
     
    5838    array(l10n('Name, Z &rarr; A'),               'name DESC',          true),
    5939    array(l10n('Date created, new &rarr; old'),   'date_creation DESC', true),
    60     array(l10n('Date created, old &rarr; new'),   'date_creation ASC',  true), 
     40    array(l10n('Date created, old &rarr; new'),   'date_creation ASC',  true),
    6141    array(l10n('Photos number, high &rarr; low'), 'nb_images DESC',     true),
    6242    array(l10n('Photos number, low &rarr; high'), 'nb_images ASC',      true),
    6343    );
    6444}
    65 
    66 ?>
  • extensions/UserCollections/include/index.php

    r16591 r25678  
    11<?php
    2 // +-----------------------------------------------------------------------+
    3 // | Piwigo - a PHP based photo gallery                                    |
    4 // +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
    6 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    7 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
    8 // +-----------------------------------------------------------------------+
    9 // | This program is free software; you can redistribute it and/or modify  |
    10 // | it under the terms of the GNU General Public License as published by  |
    11 // | the Free Software Foundation                                          |
    12 // |                                                                       |
    13 // | This program is distributed in the hope that it will be useful, but   |
    14 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    16 // | General Public License for more details.                              |
    17 // |                                                                       |
    18 // | You should have received a copy of the GNU General Public License     |
    19 // | along with this program; if not, write to the Free Software           |
    20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    21 // | USA.                                                                  |
    22 // +-----------------------------------------------------------------------+
    23 
    24 // Recursive call
    252$url = '../';
    263header( 'Request-URI: '.$url );
     
    285header( 'Location: '.$url );
    296exit();
    30 ?>
  • extensions/UserCollections/include/plain_encoder.php

    r20090 r25678  
    4040  }
    4141}
    42 
    43 ?>
  • extensions/UserCollections/include/ws_functions.inc.php

    r24421 r25678  
    66  $service = &$arr[0];
    77  global $conf;
    8  
     8
    99  $service->addMethod(
    1010    'pwg.collections.create',
     
    1717    'Create a new User Collection.'
    1818    );
    19    
     19
    2020  $service->addMethod(
    2121    'pwg.collections.delete',
     
    2626    'Delete a User Collection.'
    2727    );
    28    
     28
    2929  $service->addMethod(
    3030    'pwg.collections.getList',
     
    4242    'Returns a list of collections.'
    4343    );
    44    
     44
    4545  $service->addMethod(
    4646    'pwg.collections.addImages',
     
    5252    'Add images to a collection.'
    5353    );
    54    
     54
    5555  $service->addMethod(
    5656    'pwg.collections.removeImages',
     
    6262    'Remove images from a collection.'
    6363    );
    64    
     64
    6565  $service->addMethod(
    6666    'pwg.collections.getImages',
     
    7474    'Returns elements for the corresponding  collection.'
    7575    );
    76    
     76
    7777  $service->addMethod(
    7878    'pwg.collections.getSerialized',
     
    8888    'Returns a serialized version of the collection in CSV.<br>The return type is plain/text whatever you select as response format.'
    8989    );
    90    
     90
    9191  $service->addMethod(
    9292    'pwg.collections.getInfo',
     
    105105{
    106106  global $conf, $user;
    107  
    108   // check status
    109   if (is_a_guest())
    110   {
    111     return new PwgError(403, 'Forbidden');
    112   }
    113  
     107
     108  // check status
     109  if (is_a_guest())
     110  {
     111    return new PwgError(403, 'Forbidden');
     112  }
     113
    114114  // check name
    115115  if (empty($params['name']))
     
    117117    return new PwgError(WS_ERR_MISSING_PARAM, 'Empty collection name');
    118118  }
    119  
     119
    120120  // check user id
    121121  if (!empty($params['user_id']))
     
    135135    $params['user_id'] = $user['id'];
    136136  }
    137  
     137
    138138  $collection = new UserCollection('new', $params['name'], $params['comment'], $params['user_id']);
    139  
     139
    140140  return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER);
    141141}
     
    147147{
    148148  global $user;
    149  
    150   // check status
    151   if (is_a_guest())
    152   {
    153     return new PwgError(403, 'Forbidden');
    154   }
    155  
    156   try {
    157     $collection = new UserCollection($params['col_id']);
    158     $collection->checkUser();
    159    
     149
     150  // check status
     151  if (is_a_guest())
     152  {
     153    return new PwgError(403, 'Forbidden');
     154  }
     155
     156  try {
     157    $collection = new UserCollection($params['col_id']);
     158    $collection->checkUser();
     159
    160160    $collection->delete();
    161161  }
     
    172172{
    173173  global $user, $conf;
    174  
    175   // check status
    176   if (is_a_guest())
    177   {
    178     return new PwgError(403, 'Forbidden');
    179   }
    180  
     174
     175  // check status
     176  if (is_a_guest())
     177  {
     178    return new PwgError(403, 'Forbidden');
     179  }
     180
    181181  // check user_id
    182182  if (!empty($params['user_id']))
     
    196196    $params['user_id'] = $user['id'];
    197197  }
    198  
     198
    199199  // search
    200200  $where_clauses = array('1=1');
     
    207207    $where_clauses[] = 'name LIKE("%'.pwg_db_real_escape_string($params['name']).'%")';
    208208  }
    209  
     209
    210210  $order_by = !empty($params['order']) ? $params['order'] : 'username ASC, name ASC';
    211  
     211
    212212  $query = '
    213 SELECT 
     213SELECT
    214214    c.*,
    215215    u.'.$conf['user_fields']['username'].' AS username
     
    223223;';
    224224  $sets = hash_from_query($query, 'id');
    225  
     225
    226226  $data = array();
    227227  foreach ($sets as $row)
     
    238238      );
    239239  }
    240  
     240
    241241  return array(
    242242    'paging' => new PwgNamedStruct(array(
     
    250250      )
    251251    );
    252  
     252
    253253  return $ret;
    254254}
     
    260260{
    261261  global $conf, $user;
    262  
    263   // check status
    264   if (is_a_guest())
    265   {
    266     return new PwgError(403, 'Forbidden');
    267   }
    268 
    269   try {
    270     $collection = new UserCollection($params['col_id']);
    271     $collection->checkUser();
    272    
     262
     263  // check status
     264  if (is_a_guest())
     265  {
     266    return new PwgError(403, 'Forbidden');
     267  }
     268
     269  try {
     270    $collection = new UserCollection($params['col_id']);
     271    $collection->checkUser();
     272
    273273    $collection->addImages($params['image_ids']);
    274    
     274
    275275    return array('nb_images' => $collection->getParam('nb_images'));
    276276  }
     
    287287{
    288288  global $conf, $user;
    289  
    290   // check status
    291   if (is_a_guest())
    292   {
    293     return new PwgError(403, 'Forbidden');
    294   }
    295  
    296   try {
    297     $collection = new UserCollection($params['col_id']);
    298     $collection->checkUser();
    299    
     289
     290  // check status
     291  if (is_a_guest())
     292  {
     293    return new PwgError(403, 'Forbidden');
     294  }
     295
     296  try {
     297    $collection = new UserCollection($params['col_id']);
     298    $collection->checkUser();
     299
    300300    $collection->removeImages($params['image_ids']);
    301    
     301
    302302    return array('nb_images' => $collection->getParam('nb_images'));
    303303  }
     
    314314{
    315315  global $conf, $user;
    316  
    317   // check status
    318   if (is_a_guest())
    319   {
    320     return new PwgError(403, 'Forbidden');
    321   }
    322 
    323   try {
    324     $collection = new UserCollection($params['col_id']);
    325     $collection->checkUser();
    326    
     316
     317  // check status
     318  if (is_a_guest())
     319  {
     320    return new PwgError(403, 'Forbidden');
     321  }
     322
     323  try {
     324    $collection = new UserCollection($params['col_id']);
     325    $collection->checkUser();
     326
    327327    $image_ids = $collection->getImages();
    328328    $images = array();
    329    
     329
    330330    if (!empty($image_ids))
    331331    {
     
    343343SELECT i.*
    344344  FROM '.IMAGES_TABLE.' i
    345   WHERE 
     345  WHERE
    346346    '. implode("\n AND ", $where_clauses).'
    347347  GROUP BY i.id
     
    366366        }
    367367        $image = array_merge($image, ws_std_get_urls($row));
    368        
     368
    369369        array_push($images, $image);
    370370      }
    371371    }
    372    
     372
    373373    return array(
    374374      'paging' => new PwgNamedStruct(array(
     
    396396{
    397397  global $conf, $user;
    398  
    399   // check status
    400   if (is_a_guest())
    401   {
    402     return new PwgError(403, 'Forbidden');
    403   }
    404 
    405   try {
    406     $collection = new UserCollection($params['col_id']);
    407     $collection->checkUser();
    408    
     398
     399  // check status
     400  if (is_a_guest())
     401  {
     402    return new PwgError(403, 'Forbidden');
     403  }
     404
     405  try {
     406    $collection = new UserCollection($params['col_id']);
     407    $collection->checkUser();
     408
    409409    // change encoder to plain text
    410410    include_once(USER_COLLEC_PATH.'include/plain_encoder.php');
    411411    $encoder = new PwgPlainEncoder();
    412412    $service->setEncoder('plain', $encoder);
    413  
     413
    414414    return $collection->serialize($params['content']);
    415415  }
     
    426426{
    427427  global $conf, $user;
    428  
    429   // check status
    430   if (is_a_guest())
    431   {
    432     return new PwgError(403, 'Forbidden');
    433   }
    434 
    435   try {
    436     $collection = new UserCollection($params['col_id']);
    437     $collection->checkUser();
    438  
     428
     429  // check status
     430  if (is_a_guest())
     431  {
     432    return new PwgError(403, 'Forbidden');
     433  }
     434
     435  try {
     436    $collection = new UserCollection($params['col_id']);
     437    $collection->checkUser();
     438
    439439    return array_change_key_case($collection->getCollectionInfo(), CASE_LOWER);
    440440  }
     
    444444  }
    445445}
    446 
    447 ?>
  • extensions/UserCollections/index.php

    r16591 r25678  
    11<?php
    2 // +-----------------------------------------------------------------------+
    3 // | Piwigo - a PHP based photo gallery                                    |
    4 // +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
    6 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    7 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
    8 // +-----------------------------------------------------------------------+
    9 // | This program is free software; you can redistribute it and/or modify  |
    10 // | it under the terms of the GNU General Public License as published by  |
    11 // | the Free Software Foundation                                          |
    12 // |                                                                       |
    13 // | This program is distributed in the hope that it will be useful, but   |
    14 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    16 // | General Public License for more details.                              |
    17 // |                                                                       |
    18 // | You should have received a copy of the GNU General Public License     |
    19 // | along with this program; if not, write to the Free Software           |
    20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    21 // | USA.                                                                  |
    22 // +-----------------------------------------------------------------------+
    23 
    24 // Recursive call
    252$url = '../';
    263header( 'Request-URI: '.$url );
     
    285header( 'Location: '.$url );
    296exit();
    30 ?>
  • extensions/UserCollections/language/en_UK/plugin.lang.php

    r24421 r25678  
    5555$lang['Message (optional)'] = 'Message (optional)';
    5656$lang['Hello <b>%s</b>, %s sent you a photos collection from <a href="%s">%s</a>'] = 'Hello <b>%s</b>, %s sent you a photo collection from <a href="%s">%s</a>';
     57$lang['Hello %s, %s sent you a photos collection from "%s"'] = 'Hello %s, %s sent you a photos collection from "%s"';
    5758$lang['Click here to view the complete collection'] = 'Click here to view the complete collection';
    5859$lang['Date added to collection, new &rarr; old'] = 'Date added to collection, new &rarr; old';
     
    6263$lang['Photos number, high &rarr; low'] = 'Photos number, high &rarr; low';
    6364$lang['Photos number, low &rarr; high'] = 'Photos number, low &rarr; high';
     65$lang['Add'] = 'Add';
     66$lang['Cancel'] = 'Cancel';
     67$lang['Description'] = 'Description';
     68$lang['jump to photo'] = 'jump to photo';
     69$lang['Name'] = 'Name';
     70$lang['Send'] = 'Send';
    6471
    6572?>
  • extensions/UserCollections/language/fr_FR/plugin.lang.php

    r24421 r25678  
    5555$lang['Message (optional)'] = 'Message (optionel)';
    5656$lang['Hello <b>%s</b>, %s sent you a photos collection from <a href="%s">%s</a>'] = 'Bonjour <b>%s</b>, %s vous a envoyé une collection de photos depuis <a href="%s">%s</a>';
     57$lang['Hello %s, %s sent you a photos collection from "%s"'] = 'Bonjour %s, %s vous a envoyé une collection de photos depuis "%s"';
    5758$lang['Click here to view the complete collection'] = 'Cliquez ici pour voir la collection complète';
    5859$lang['Date added to collection, new &rarr; old'] = 'Date d\'ajout à la collection, récent &rarr; ancien';
     
    6263$lang['Photos number, high &rarr; low'] = 'Nombre de photos, élévé &rarr; faible';
    6364$lang['Photos number, low &rarr; high'] = 'Nombre de photos, faible &rarr; élévé';
     65$lang['Add'] = 'Ajouter';
     66$lang['Cancel'] = 'Annuler';
     67$lang['Description'] = 'Description';
     68$lang['jump to photo'] = 'Voir la photo';
     69$lang['Name'] = 'Nom';
     70$lang['Send'] = 'Envoyer';
    6471
    6572?>
  • extensions/UserCollections/main.inc.php

    r24421 r25678  
    1 <?php 
     1<?php
    22/*
    33Plugin Name: User Collections
     
    1818global $conf, $prefixeTable;
    1919
    20 defined('USER_COLLEC_ID') or define('USER_COLLEC_ID', basename(dirname(__FILE__)));
     20define('USER_COLLEC_ID',          basename(dirname(__FILE__)));
    2121define('USER_COLLEC_PATH',        PHPWG_PLUGINS_PATH . USER_COLLEC_ID . '/');
    2222define('COLLECTIONS_TABLE',       $prefixeTable.'collections');
     
    4343  // thumbnails actions
    4444  add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_list', EVENT_HANDLER_PRIORITY_NEUTRAL-10, 2);
    45   add_event_handler('loc_end_index_thumbnails', 'uc_anti_lightbox', 41);
    4645
    4746  // picture action
     
    6463function user_collections_init()
    6564{
    66   global $pwg_loaded_plugins, $conf;
    67  
    68   if (
    69     USER_COLLEC_VERSION == 'auto' or
    70     $pwg_loaded_plugins[USER_COLLEC_ID]['version'] == 'auto' or
    71     version_compare($pwg_loaded_plugins[USER_COLLEC_ID]['version'], USER_COLLEC_VERSION, '<')
    72   )
    73   {
    74     include_once(USER_COLLEC_PATH . 'include/install.inc.php');
    75     user_collections_install();
    76    
    77     if ( $pwg_loaded_plugins[USER_COLLEC_ID]['version'] != 'auto' and USER_COLLEC_VERSION != 'auto' )
    78     {
    79       $query = '
    80 UPDATE '. PLUGINS_TABLE .'
    81 SET version = "'. USER_COLLEC_VERSION .'"
    82 WHERE id = "'. USER_COLLEC_ID .'"';
    83       pwg_query($query);
    84      
    85       $pwg_loaded_plugins[USER_COLLEC_ID]['version'] = USER_COLLEC_VERSION;
    86      
    87       if (defined('IN_ADMIN'))
    88       {
    89         $_SESSION['page_infos'][] = 'UserCollections updated to version '. USER_COLLEC_VERSION;
    90       }
    91     }
    92   }
    93  
     65  global $conf;
     66
     67  include_once(USER_COLLEC_PATH . 'maintain.inc.php');
     68  $maintain = new UserCollections_maintain(USER_COLLEC_ID);
     69  $maintain->autoUpdate(USER_COLLEC_VERSION, 'install');
     70
    9471  load_language('plugin.lang', USER_COLLEC_PATH);
    95  
     72
    9673  $conf['user_collections'] = unserialize($conf['user_collections']);
    9774}
     
    10077 * admin plugins menu
    10178 */
    102 function user_collections_admin_menu($menu) 
     79function user_collections_admin_menu($menu)
    10380{
    104   array_push($menu, array(
     81  $menu[] = array(
    10582    'NAME' => 'User Collections',
    10683    'URL' => USER_COLLEC_ADMIN,
    107   ));
     84    );
     85
    10886  return $menu;
    10987}
    110 
    111 ?>
  • extensions/UserCollections/maintain.inc.php

    r24421 r25678  
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33
    4 defined('USER_COLLEC_ID') or define('USER_COLLEC_ID', basename(dirname(__FILE__)));
    5 include_once(PHPWG_PLUGINS_PATH . USER_COLLEC_ID . '/include/install.inc.php');
     4class UserCollections_maintain extends PluginMaintain
     5{
     6  private $installed = false;
    67
    7 function plugin_install()
    8 {
    9   user_collections_install();
    10  
    11   define('user_collections_installed', true);
    12 }
     8  function install($plugin_version, &$errors=array())
     9  {
     10    global $conf, $prefixeTable;
    1311
    14 function plugin_activate()
    15 {
    16   if (!defined('user_collections_intalled'))
     12    if (empty($conf['user_collections']))
     13    {
     14      $conf['user_collections'] = serialize(array(
     15        'allow_mails' => true,
     16        'allow_public' => true,
     17        ));
     18
     19      conf_update_param('user_collections', $conf['user_collections']);
     20    }
     21
     22    // create tables
     23    $query = '
     24CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collections` (
     25  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
     26  `user_id` smallint(5) DEFAULT NULL,
     27  `name` varchar(255) NOT NULL,
     28  `date_creation` datetime NOT NULL,
     29  `comment` text NULL,
     30  `nb_images` mediumint(8) NOT NULL DEFAULT 0,
     31  PRIMARY KEY (`id`)
     32) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
     33;';
     34    pwg_query($query);
     35
     36    $query = '
     37CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collection_images` (
     38  `col_id` mediumint(8) NOT NULL,
     39  `image_id` mediumint(8) NOT NULL,
     40  `add_date` datetime NULL,
     41  UNIQUE KEY `UNIQUE` (`col_id`,`image_id`)
     42) ENGINE=MyISAM DEFAULT CHARSET=utf8
     43;';
     44    pwg_query($query);
     45
     46    $query = '
     47CREATE TABLE IF NOT EXISTS `'.$prefixeTable.'collection_shares` (
     48  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
     49  `col_id` mediumint(8) NOT NULL,
     50  `share_key` varchar(64) NOT NULL,
     51  `params` text NULL,
     52  `add_date` datetime NOT NULL,
     53  PRIMARY KEY (`id`),
     54  UNIQUE KEY `share_key` (`share_key`)
     55) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
     56;';
     57    pwg_query($query);
     58
     59
     60    // version 2.0.0
     61    $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collection_images` LIKE "add_date";');
     62    if (!pwg_db_num_rows($result))
     63    {
     64      pwg_query('ALTER TABLE `'.$prefixeTable.'collection_images` ADD `add_date` datetime NULL;');
     65    }
     66
     67    $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collections` LIKE "comment";');
     68    if (!pwg_db_num_rows($result))
     69    {
     70      pwg_query('ALTER TABLE `'.$prefixeTable.'collections` ADD `comment` text NULL;');
     71      pwg_query('ALTER TABLE `'.$prefixeTable.'collections` DROP `active`;');
     72    }
     73
     74    // version 2.1.0
     75    $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collections` LIKE "public";');
     76    if (pwg_db_num_rows($result))
     77    {
     78      $now = date('Y-m-d H:i:s');
     79
     80      $query = '
     81SELECT id, public_id
     82  FROM `'.$prefixeTable.'collections`
     83  WHERE public = 1
     84;';
     85      $result = pwg_query($query);
     86
     87      $inserts = array();
     88      while ($row = pwg_db_fetch_assoc($result))
     89      {
     90        $inserts[] = array(
     91          'col_id' => $row['id'],
     92          'share_key' => $row['public_id'],
     93          'params' => serialize(array('password'=>'','deadline'=>'')),
     94          'add_date' => $now,
     95          );
     96      }
     97
     98      mass_inserts($prefixeTable.'collection_shares',
     99        array('col_id','share_key','params','add_date'),
     100        $inserts
     101        );
     102
     103      pwg_query('ALTER TABLE `'.$prefixeTable.'collections` DROP `public`, DROP `public_id`;');
     104    }
     105  }
     106
     107  function activate($plugin_version, &$errors=array())
    17108  {
    18     user_collections_install();
     109    if (!$this->installed)
     110    {
     111      $this->install($plugin_version, $errors);
     112    }
     113  }
     114
     115  function deactivate(){}
     116
     117  function uninstall()
     118  {
     119    global $prefixeTable;
     120
     121    conf_delete_param('user_collections');
     122
     123    pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collections`;');
     124    pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_images`;');
     125    pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_shares`;');
    19126  }
    20127}
    21 
    22 function plugin_uninstall()
    23 {
    24   global $prefixeTable, $conf;
    25  
    26   pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "user_collections";');
    27   pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collections`;');
    28   pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_images`;');
    29   pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_shares`;');
    30  
    31   unset($conf['user_collections']);
    32 }
    33 
    34 ?>
  • extensions/UserCollections/template/collection_edit.tpl

    r25674 r25678  
     1{strip}
    12{combine_css path=$USER_COLLEC_PATH|cat:'template/style_collections.css'}
    23
     
    45
    56{*<!-- datepicker and timepicker -->*}
    6 {include file='include/datepicker.inc.tpl'}
    7 {combine_script id='jquery.ui.timepicker' load='footer' require='jquery.ui.datepicker,jquery.ui.slider' path=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/jquery-ui-timepicker-addon.js'}
    8 
    9 {assign var="timepicker_language" value=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/i18n/jquery-ui-timepicker-'|cat:$lang_info.code|cat:'.js'}
    10 {if "PHPWG_ROOT_PATH"|@constant|@cat:$timepicker_language|@file_exists}
    11 {combine_script id="jquery.ui.timepicker-$lang_info.code" load='footer' require='jquery.ui.timepicker' path=$timepicker_language}
     7{combine_script id='jquery.ui.datepicker' load='footer' path='themes/default/js/ui/jquery.ui.datepicker.js'}
     8{combine_script id='jquery.ui.timepicker' load='footer' require='jquery.ui.slider' path=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/jquery-ui-timepicker-addon.js'}
     9
     10{assign var=datepicker_language value='themes/default/js/ui/i18n/jquery.ui.datepicker-'|cat:$lang_info.code|cat:'.js'}
     11{if 'PHPWG_ROOT_PATH'|constant|cat:$datepicker_language|file_exists}
     12{combine_script id='jquery.ui.datepicker-'|cat:$lang_info.code load='footer' require='jquery.ui.datepicker' path=$datepicker_language}
     13{/if}
     14
     15{assign var=timepicker_language value=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/i18n/jquery-ui-timepicker-'|cat:$lang_info.code|cat:'.js'}
     16{if 'PHPWG_ROOT_PATH'|constant|cat:$timepicker_language|file_exists}
     17{combine_script id='jquery.ui.timepicker-'|cat:$lang_info.code load='footer' require='jquery.ui.timepicker' path=$timepicker_language}
    1218{/if}
    1319
    1420{combine_css path='themes/default/js/ui/theme/jquery.ui.core.css'}
    1521{combine_css path='themes/default/js/ui/theme/jquery.ui.theme.css'}
     22{combine_css path='themes/default/js/ui/theme/jquery.ui.datepicker.css'}
    1623{combine_css path='themes/default/js/ui/theme/jquery.ui.slider.css'}
    1724{combine_css path=$USER_COLLEC_PATH|cat:'template/resources/jquery-timepicker/jquery-ui-timepicker-addon.css'}
    18 
    19 
    20 {footer_script require='jquery,jquery.ui.timepicker'}
    21 var bg_color = $('#the_page #content').css('background-color');
    22 if (!bg_color || bg_color=='transparent') {ldelim}
    23   bg_color = $('body').css('background-color');
     25{/strip}
     26
     27{footer_script require='jquery'}
     28var bg_color = jQuery('#the_page #content').css('background-color');
     29if (!bg_color || bg_color=='transparent') {
     30  bg_color = jQuery('body').css('background-color');
    2431}
    2532
    2633{if isset($U_SHARE)}
    27 {literal}
    2834  var $share_form = jQuery('#share_form');
    29  
     35
    3036  // functions
    3137  jQuery.fn.extend({
    3238      hideVis: function() {
    33           $(this).css('visibility', 'hidden');
     39          jQuery(this).css('visibility', 'hidden');
    3440          return this;
    3541      },
    3642      showVis: function() {
    37           $(this).css('visibility', 'visible');
     43          jQuery(this).css('visibility', 'visible');
    3844          return this;
    3945      },
    4046      toggleVis: function(toggle) {
    41           if ($(this).css('visibility')=='hidden' || toggle === true){
    42               return $(this).showVis();
     47          if (jQuery(this).css('visibility')=='hidden' || toggle === true){
     48              return jQuery(this).showVis();
    4349          } else {
    44               return $(this).hideVis();
     50              return jQuery(this).hideVis();
    4551          }
    4652      }
    4753  });
    48  
     54
    4955  function enterShareKeyEdit() {
    5056      $share_form.find('.url-edit').show();
    5157      $share_form.find('.url-normal').hide();
    52       jQuery(".share_colorbox_open").colorbox.resize({speed:0});
     58      jQuery('.share_colorbox_open').colorbox.resize({ldelim}speed:0});
    5359  }
    5460  function exitShareKeyEdit() {
    5561      $share_form.find('.url-edit').hide();
    5662      $share_form.find('.url-normal').show();
    57       jQuery(".share_colorbox_open").colorbox.resize({speed:0});
     63      jQuery('.share_colorbox_open').colorbox.resize({ldelim}speed:0});
    5864  }
    59  
     65
    6066  // hide some inputs
    6167  exitShareKeyEdit();
    62  
     68
    6369  // display key
    6470  $share_form.find('.url-more').text($share_form.find('input[name="share_key"]').val());
    65  
     71
    6672  // url edition
    67   $share_form.find('.edit_share_key').on('click', function() {
     73  $share_form.find('.edit_share_key').on('click', function(e) {
    6874      enterShareKeyEdit();
    69       return false;
    70   });
    71   $share_form.find('.set_share_key').on('click', function() {
     75      e.preventDefault();
     76  });
     77  $share_form.find('.set_share_key').on('click', function(e) {
    7278      if ($share_form.find('input[name="share_key"]').val().length < 8) {
    73           alert("{/literal}{'The key must be at least 8 characters long'|@translate|escape:javascript}{literal}");
     79          alert('{'The key must be at least 8 characters long'|translate|escape:javascript}');
    7480      }
    7581      else {
     
    7783          exitShareKeyEdit();
    7884      }
    79       return false;
    80   });
    81   $share_form.find('.cancel_share_key').on('click', function() {
     85      e.preventDefault();
     86  });
     87  $share_form.find('.cancel_share_key').on('click', function(e) {
    8288      $share_form.find('input[name="share_key"]').val($share_form.find('.url-more').text());
    8389      exitShareKeyEdit();
    84       return false;
     90      e.preventDefault();
    8591  });
    8692  $share_form.find('.url-more').on('dblclick', function() {
    8793      enterShareKeyEdit();
    8894  });
    89  
     95
    9096  // optional inputs
    9197  $share_form.find('.share-option').each(function() {
    92       $share_form.find('input[name="'+ $(this).data('for') +'"]').hideVis();
     98      $share_form.find('input[name="'+ jQuery(this).data('for') +'"]').hideVis();
    9399  }).on('change', function() {
    94       $share_form.find('input[name="'+ $(this).data('for') +'"]').toggleVis($(this).is(':checked'));
    95   });
    96  
     100      $share_form.find('input[name="'+ jQuery(this).data('for') +'"]').toggleVis($(this).is(':checked'));
     101  });
     102
    97103  // datetime picker
    98104  $share_form.find('input[name="share_deadline"]').datetimepicker({
     
    100106      minDate: new Date()
    101107  });
    102  
    103  
     108
     109
    104110  // popup
    105   jQuery(".share_colorbox_open").colorbox({
    106     {/literal}{if isset($share.open)}open: true, transition:"none",{/if}{literal}
     111  jQuery('.share_colorbox_open').colorbox({
     112    {if isset($share.open)}open: true, transition:"none",{/if}
    107113    inline:true
    108114  });
    109   jQuery(".share_colorbox_close").click(function() {
    110     jQuery(".share_colorbox_open").colorbox.close();
    111     return false;
    112   });
    113   jQuery("#share_form").css('background-color', bg_color);
    114 {/literal}
     115  jQuery('.share_colorbox_close').click(function(e) {
     116    jQuery('.share_colorbox_open').colorbox.close();
     117    e.preventDefault();
     118  });
     119  jQuery('#share_form').css('background-color', bg_color);
    115120{/if}
    116121
    117122{if isset($U_MAIL)}
    118 {literal}
    119   jQuery(".mail_colorbox_open").colorbox({
    120     {/literal}{if isset($contact.open)}open: true, transition:"none",{/if}{literal}
     123  jQuery('.mail_colorbox_open').colorbox({
     124    {if isset($contact.open)}open: true, transition:"none",{/if}
    121125    inline:true
    122126  });
    123   jQuery(".mail_colorbox_close").click(function() {
    124     jQuery(".mail_colorbox_open").colorbox.close();
    125     return false;
    126   });
    127  
    128  
    129   jQuery("#mail_form").css('background-color', bg_color);
    130 {/literal}
    131 {/if}
    132 
    133 {literal}
    134 jQuery("#edit_form_show").click(function() {
    135   jQuery("#edit_form_show").hide();
    136   jQuery(".additional_info").hide();
    137   jQuery("#edit_form").show();
     127  jQuery('.mail_colorbox_close').click(function(e) {
     128    jQuery('.mail_colorbox_open').colorbox.close();
     129    e.preventDefault();
     130  });
     131
     132
     133  jQuery('#mail_form').css('background-color', bg_color);
     134{/if}
     135
     136jQuery('#edit_form_show').click(function() {
     137  jQuery('#edit_form_show').hide();
     138  jQuery('.additional_info').hide();
     139  jQuery('#edit_form').show();
    138140});
    139 jQuery("#edit_form_hide").click(function() {
    140   jQuery("#edit_form_show").show();
    141   jQuery(".additional_info").show();
    142   jQuery("#edit_form").hide();
     141jQuery('#edit_form_hide').click(function() {
     142  jQuery('#edit_form_show').show();
     143  jQuery('.additional_info').show();
     144  jQuery('#edit_form').hide();
    143145});
    144 {/literal}
    145146{/footer_script}
    146147
    147148
    148 {* <!-- Menubar & titrePage --> *}
    149 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}
    150   {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/stripped.tpl'}
    151   {assign var="clear" value="true"}
    152 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}
    153   {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/simple.tpl'}
    154   {assign var="clear" value="true"}
    155 {else}
    156   {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/default.tpl'}
    157 {/if}
    158 
    159 {if isset($errors) or not empty($infos)}
    160 {include file='infos_errors.tpl'}
    161 {/if}
    162 
    163 
    164149{if isset($collection)}
    165150
    166 {if !empty($CONTENT_DESCRIPTION)}
    167 <div class="additional_info">
    168         {$CONTENT_DESCRIPTION}
    169 </div>
    170 {/if}
    171 
    172 <p style="text-align:center;"><input type="submit" id="edit_form_show" value="{'Edit'|@translate}"></p>
     151<p style="text-align:center;"><input type="submit" id="edit_form_show" value="{'Edit'|translate}"></p>
    173152
    174153{* <!-- edit collection -->*}
    175154<form action="{$F_ACTION}" method="post" id="edit_form" style="display:none;">
    176155<fieldset id="colProperties">
    177   <legend>{'Properties'|@translate}</legend>
    178  
    179   <p class="title"><label for="name">{'Name'|@translate}</label></p>
     156  <legend>{'Edit'|translate}</legend>
     157
     158  <p class="title"><label for="name">{'Name'|translate}</label></p>
    180159  <p><input type="text" name="name" id="name" value="{$collection.NAME|escape:html}" size="60"></p>
    181  
    182   <p class="title"><label for="comment">{'Description'|@translate}</label></p>
     160
     161  <p class="title"><label for="comment">{'Description'|translate}</label></p>
    183162  <p><textarea name="comment" id="comment" style="width:400px;height:100px;">{$collection.COMMENT}</textarea></p>
    184163
    185164  <p>
    186     <input type="submit" name="save_col" value="{'Save'|@translate}">
    187     <a id="edit_form_hide">{'Cancel'|@translate}</a>
     165    <input type="submit" name="save_col" value="{'Save'|translate}">
     166    <a id="edit_form_hide">{'Cancel'|translate}</a>
    188167  </p>
    189168</fieldset>
     
    195174  <form id="share_form" class="uc_form" action="{$F_ACTION}" method="post">
    196175    {include file='infos_errors.tpl' errors=$share.errors infos=$share.infos}
    197    
     176
    198177    <table>
    199178      <tr>
     
    201180          <span class="url-base">{$U_SHARE}</span><span class="url-more url-normal"></span>
    202181          <input type="text" name="share_key" class="url-edit" size="20" value="{$share.share_key}">
    203           <button class="url-normal edit_share_key">{'Edit'|@translate}</button>
    204           <button class="url-edit set_share_key">{'OK'|@translate}</button>
    205           <a href="#" class="url-edit cancel_share_key">{'Cancel'|@translate}</button>
     182          <button class="url-normal edit_share_key">{'Edit'|translate}</button>
     183          <button class="url-edit set_share_key">{'OK'|translate}</button>
     184          <a href="#" class="url-edit cancel_share_key">{'Cancel'|translate}</button>
    206185        </td>
    207186      </tr>
    208187      <tr>
    209188        <td class="title"><label>
    210           {'Password'|@translate}
     189          {'Password'|translate}
    211190          <input type="checkbox" name="use_share_password" data-for="share_password" class="share-option">
    212191        </label></td>
    213192        <td>
    214           <input type="text" name="share_password" size="25" maxlength="25" value="{$share.password}" placeholder="{'Password'|@translate}">
     193          <input type="text" name="share_password" size="25" maxlength="25" value="{$share.password}" placeholder="{'Password'|translate}">
    215194        </td>
    216195      </tr>
    217196      <tr>
    218197        <td class="title"><label>
    219           {'Expiration date'|@translate}
     198          {'Expiration date'|translate}
    220199          <input type="checkbox" name="use_share_deadline" data-for="share_deadline" class="share-option">
    221200        </label></td>
    222201        <td>
    223           <input type="text" name="share_deadline" size="25" value="{$share.deadline}" placeholder="{'Date'|@translate}">
     202          <input type="text" name="share_deadline" size="25" value="{$share.deadline}" placeholder="{'Date'|translate}">
    224203        </td>
    225204      </tr>
     
    227206        <td class="title">&nbsp;</td>
    228207        <td>
    229           <input class="submit" type="submit" name="add_share" value="{'Add'|@translate}">
    230           <a class="share_colorbox_close" href="#">{'Cancel'|@translate}</a>
     208          <input class="submit" type="submit" name="add_share" value="{'Add'|translate}">
     209          <a class="share_colorbox_close" href="#">{'Cancel'|translate}</a>
    231210          <input type="hidden" name="key" value="{$UC_TKEY}">
    232211        </td>
    233212      </tr>
    234213    </table>
    235    
     214
    236215  {if not empty($collection.SHARES)}
    237216    <table class="shares_list">
    238217      <tr class="header">
    239         <th>{'Share key'|@translate}</th>
    240         <th>{'Creation date'|@translate}</th>
    241         <th>{'Password'|@translate}</th>
    242         <th>{'Expiration date'|@translate}</th>
     218        <th>{'Share key'|translate}</th>
     219        <th>{'Creation date'|translate}</th>
     220        <th>{'Password'|translate}</th>
     221        <th>{'Expiration date'|translate}</th>
    243222        <th></th>
    244223      </tr>
     
    247226        <td><a href="{$share.url}">{$share.share_key}</a></td>
    248227        <td>{$share.add_date_readable}</td>
    249         <td>{if $share.params.password}{'Yes'|@translate}{else}{'No'|@translate}{/if}</td>
    250         <td>{if $share.params.deadline}{$share.params.deadline_readable}{else}{'No'|@translate}{/if}</td>
    251         <td><a href="{$share.u_delete}" onClick="return confirm('{'Are you sure?'|@translate}');">
     228        <td>{if $share.params.password}{'Yes'|translate}{else}{'No'|translate}{/if}</td>
     229        <td>{if $share.params.deadline}{$share.params.deadline_readable}{else}{'No'|translate}{/if}</td>
     230        <td><a href="{$share.u_delete}" onClick="return confirm('{'Are you sure?'|translate}');">
    252231          <img src="{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/delete.png" width=16 height=16></a>
    253232        </td>
     
    268247    <table>
    269248      <tr>
    270         <td class="title"><label for="sender_name">{'Your name'|@translate}</label></td>
     249        <td class="title"><label for="sender_name">{'Your name'|translate}</label></td>
    271250        <td>
    272251          <input type="text" name="sender_name" id="sender_name" size="40" value="{$contact.sender_name}">
     
    274253      </tr>
    275254      <tr>
    276         <td class="title"><label for="sender_email">{'Your e-mail'|@translate}</label></td>
     255        <td class="title"><label for="sender_email">{'Your e-mail'|translate}</label></td>
    277256        <td>
    278257          <input type="text" name="sender_email" id="sender_email" size="40" value="{$contact.sender_email}">
     
    280259      </tr>
    281260      <tr>
    282         <td class="title"><label for="recipient_name">{'Recipient name'|@translate}</label></td>
     261        <td class="title"><label for="recipient_name">{'Recipient name'|translate}</label></td>
    283262        <td>
    284263          <input type="text" name="recipient_name" id="recipient_name" size="40" value="{$contact.recipient_name}">
     
    286265      </tr>
    287266      <tr>
    288         <td class="title"><label for="recipient_email">{'Recipient e-mail'|@translate}</label></td>
     267        <td class="title"><label for="recipient_email">{'Recipient e-mail'|translate}</label></td>
    289268        <td>
    290269          <input type="text" name="recipient_email" id="recipient_email" size="40" value="{$contact.recipient_email}">
     
    292271      </tr>
    293272      <tr>
    294         <td class="title"><label for="nb_images">{'Number of images'|@translate}</label></td>
     273        <td class="title"><label for="nb_images">{'Number of images'|translate}</label></td>
    295274        <td>
    296275          <select name="nb_images">
     
    302281      </tr>
    303282      <tr>
    304         <td class="title"><label for="message">{'Message (optional)'|@translate}</label></td>
     283        <td class="title"><label for="message">{'Message (optional)'|translate}</label></td>
    305284        <td><textarea name="message" id="message" rows="6" style="width:350px;">{$contact.message}</textarea></td>
    306285      </tr>
     
    308287        <td class="title">&nbsp;</td>
    309288        <td>
    310           <input class="submit" type="submit" name="send_mail" value="{'Send'|@translate}">
    311           <a class="mail_colorbox_close" href="#">{'Cancel'|@translate}</a>
     289          <input class="submit" type="submit" name="send_mail" value="{'Send'|translate}">
     290          <a class="mail_colorbox_close" href="#">{'Cancel'|translate}</a>
    312291          <input type="hidden" name="key" value="{$UC_TKEY}">
    313292        </td>
     
    318297{/if}
    319298
    320 
    321 {* <!-- collection content -->*}
    322 {if $collection.NB_IMAGES > 0}
    323 <ul class="thumbnails" id="thumbnails">
    324 {$THUMBNAILS}
    325 </ul>
    326 {else}
    327 <p><i>{'This collection is empty'|@translate}</i></p>
    328 {/if}
    329 
    330 {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
    331 
    332 {/if}
    333 
    334 {if isset($clear)}<div style="clear: both;"></div>
    335 </div>{/if}
    336 </div>{* <!-- content --> *}
     299{if empty($THUMBNAILS)}
     300<p><i>{'This collection is empty'|translate}</i></p>
     301{/if}
     302
     303{/if}
  • extensions/UserCollections/template/collection_view.tpl

    r24421 r25678  
    11{combine_css path=$USER_COLLEC_PATH|cat:'template/style_collections.css'}
    22{include file=$USER_COLLEC_ABS_PATH|cat:'template/thumbnails_colorbox.tpl'}
    3 
    4 
    5 {* <!-- Menubar & titrePage --> *}
    6 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}
    7   {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/stripped.tpl'}
    8   {assign var="clear" value="true"}
    9 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}
    10   {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/simple.tpl'}
    11   {assign var="clear" value="true"}
    12 {else}
    13   {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/default.tpl'}
    14 {/if}
    15 
    16 {if isset($errors) or not empty($infos)}
    17 {include file='infos_errors.tpl'}
    18 {/if}
    193
    204{if $UC_MODE == 'password'}
    215<form action="{$F_LOGIN_ACTION}" method="post" name="login_form" class="properties">
    226  <fieldset>
    23     <legend>{'Restricted access'|@translate}</legend>
     7    <legend>{'Restricted access'|translate}</legend>
    248
    259    <ul>
    2610      <li>
    2711        <span class="property">
    28           <label for="uc_password">{'Password'|@translate}</label>
     12          <label for="uc_password">{'Password'|translate}</label>
    2913        </span>
    3014        <input tabindex="1" class="login" type="password" name="uc_password" id="uc_password" size="25" maxlength="25">
     
    3418
    3519  <p>
    36     <input tabindex="2" type="submit" value="{'Submit'|@translate}">
     20    <input tabindex="2" type="submit" value="{'Submit'|translate}">
    3721  </p>
    3822</form>
    3923
    40 <script type="text/javascript"><!--
    41 document.login_form.username.focus();
    42 //--></script>
    43 
    44 {else}
    45 {if !empty($CONTENT_DESCRIPTION)}
    46 <div class="additional_info">
    47         {$CONTENT_DESCRIPTION}
    48 </div>
     24<script>document.login_form.username.focus();</script>
    4925{/if}
    50 
    51 {if !empty($THUMBNAILS)}
    52 <ul class="thumbnails" id="thumbnails">
    53 {$THUMBNAILS}
    54 </ul>
    55 {/if}
    56 
    57 {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
    58 {/if}
    59 
    60 {if isset($clear)}<div style="clear: both;"></div>
    61 </div>{/if}
    62 </div>{* <!-- content --> *}
  • extensions/UserCollections/template/collections_list.tpl

    r23551 r25678  
    22
    33{footer_script require='jquery'}
    4 jQuery(".new_col").click(function() {ldelim}
    5   var name = prompt("{'Collection name:'|@translate}");
    6   if (name != null) {ldelim}
    7     $(this).attr("href",  $(this).attr("href") +"&name="+ name);
     4jQuery('.new_col').click(function() {
     5  var name = prompt('{'Collection name:'|translate|escape:javascript}');
     6  if (name != null) {
     7    jQuery(this).attr('href',  jQuery(this).attr('href') +'&name='+ name);
    88    return true;
    9   } else {ldelim}
     9  }
     10  else {
    1011    return false;
    1112  }
    1213});
    1314
    14 jQuery(".titrePage h2").append(" [{$COLLECTIONS_COUNT}]");
     15jQuery('.titrePage h2').append(' [{$COLLECTIONS_COUNT}]');
    1516{/footer_script}
    1617
    17 {* <!-- Menubar & titrePage --> *}
    18 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"}
    19   {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/stripped.tpl'}
    20   {assign var="clear" value="true"}
    21 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"}
    22   {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/simple.tpl'}
    23   {assign var="clear" value="true"}
    24 {else}
    25   {include file=$USER_COLLEC_ABS_PATH|@cat:'template/themes/default.tpl'}
     18
     19<p style="text-align:left;font-weight:bold;margin:20px;"><a href="{$U_CREATE}" class="new_col">{'Create a new collection'|translate}</a></p>
     20
     21{if empty($CATEGORIES)}
     22{'You have no collection'|translate}
    2623{/if}
    27 
    28 {if isset($errors) or not empty($infos)}
    29 {include file='infos_errors.tpl'}
    30 {/if}
    31 
    32 
    33 <p style="text-align:left;font-weight:bold;margin:20px;"><a href="{$U_CREATE}" class="new_col">{'Create a new collection'|@translate}</a></p>
    34 
    35 {if !empty($CATEGORIES)}
    36 {$CATEGORIES}
    37 {else}
    38 {'You have no collection'|@translate}
    39 {/if}
    40 
    41 {if isset($clear)}<div style="clear: both;"></div>
    42 </div>{/if}
    43 </div>{* <!-- content --> *}
  • extensions/UserCollections/template/index.php

    r20090 r25678  
    11<?php
    2 // +-----------------------------------------------------------------------+
    3 // | Piwigo - a PHP based photo gallery                                    |
    4 // +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
    6 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    7 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
    8 // +-----------------------------------------------------------------------+
    9 // | This program is free software; you can redistribute it and/or modify  |
    10 // | it under the terms of the GNU General Public License as published by  |
    11 // | the Free Software Foundation                                          |
    12 // |                                                                       |
    13 // | This program is distributed in the hope that it will be useful, but   |
    14 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    16 // | General Public License for more details.                              |
    17 // |                                                                       |
    18 // | You should have received a copy of the GNU General Public License     |
    19 // | along with this program; if not, write to the Free Software           |
    20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    21 // | USA.                                                                  |
    22 // +-----------------------------------------------------------------------+
    23 
    24 // Recursive call
    252$url = '../';
    263header( 'Request-URI: '.$url );
     
    285header( 'Location: '.$url );
    296exit();
    30 ?>
  • extensions/UserCollections/template/menublock.tpl

    r23719 r25678  
    33  <p>{strip}
    44    {if $block->data.NB_COL == 0}
    5       {'You have no collection'|@translate}
     5      {'You have no collection'|translate}
    66    {else}
    77      <a href="{$block->data.U_LIST}">{$pwg->l10n_dec('You have %d collection', 'You have %d collections', $block->data.NB_COL)}</a>
     
    1212                {foreach from=$block->data.collections item=col}{strip}
    1313                <li>
    14       <a href="{$col.u_edit}">{$col.name}</a>&nbsp; 
     14      <a href="{$col.u_edit}">{$col.name}</a>&nbsp;
    1515      <span class="menuInfoCat">[<span class="nbImagesCollec-{$col.id}">{$col.nb_images}</span>]</span>
    1616    </li>
    1717                {/strip}{/foreach}
    18     {if isset($block->data.MORE)}<li class="menuInfoCat"><a href="{$block->data.U_LIST}">{'%d more...'|@translate|sprintf:$block->data.MORE}</a></li>{/if}
     18    {if isset($block->data.MORE)}<li class="menuInfoCat"><a href="{$block->data.U_LIST}">{'%d more...'|translate:$block->data.MORE}</a></li>{/if}
    1919        </ul>
    2020  {/if}
  • extensions/UserCollections/template/picture_button.tpl

    r23361 r25678  
    11{include file=$USER_COLLEC_ABS_PATH|cat:'template/thumbnails_css_js.tpl'}
    22
    3 {footer_script require='jquery'}{literal}
    4 jQuery().ready(function() {
     3{footer_script require='jquery'}
     4jQuery(function() {
    55  jQuery("#collectionsLink").click(function() {
    66          var elt = jQuery("#collectionsDropdown");
     
    1717  });
    1818});
    19 {/literal}{/footer_script}
     19{/footer_script}
    2020
    21 <a id="collectionsLink" title="{'Add to collection'|@translate}" class="pwg-state-default pwg-button addCollection" rel="nofollow" data-id="{$current.id}" data-cols="[{$CURRENT_COLLECTIONS}]">
     21<a id="collectionsLink" title="{'Add to collection'|translate}" class="pwg-state-default pwg-button addCollection" rel="nofollow" data-id="{$current.id}" data-cols="[{$CURRENT_COLLECTIONS}]">
    2222  <span class="pwg-icon" style="background:url('{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/image_add.png') center center no-repeat;"></span>
    23   <span class="pwg-button-text">{'Add to collection'|@translate}</span>
     23  <span class="pwg-button-text">{'Add to collection'|translate}</span>
    2424</a>
  • extensions/UserCollections/template/resources/index.php

    r20090 r25678  
    11<?php
    2 // +-----------------------------------------------------------------------+
    3 // | Piwigo - a PHP based photo gallery                                    |
    4 // +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
    6 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    7 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
    8 // +-----------------------------------------------------------------------+
    9 // | This program is free software; you can redistribute it and/or modify  |
    10 // | it under the terms of the GNU General Public License as published by  |
    11 // | the Free Software Foundation                                          |
    12 // |                                                                       |
    13 // | This program is distributed in the hope that it will be useful, but   |
    14 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    16 // | General Public License for more details.                              |
    17 // |                                                                       |
    18 // | You should have received a copy of the GNU General Public License     |
    19 // | along with this program; if not, write to the Free Software           |
    20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    21 // | USA.                                                                  |
    22 // +-----------------------------------------------------------------------+
    23 
    24 // Recursive call
    252$url = '../';
    263header( 'Request-URI: '.$url );
     
    285header( 'Location: '.$url );
    296exit();
    30 ?>
  • extensions/UserCollections/template/style_collections.css

    r24421 r25678  
    1010    margin-bottom:10px;
    1111  }
    12  
     12
    1313#publicURL {
    1414  display:inline-block;
     
    7777    padding:3px;
    7878  }
    79  
     79
    8080#share_form .url-base {
    8181  font-size:0.9em;
     
    104104  border-bottom:1px solid #111;
    105105}
    106  
     106
    107107.shares_list tr.row2 td { background-color:#222; }
    108108.shares_list tr.row1 td { background-color:#333; }
  • extensions/UserCollections/template/text/html/mail.tpl

    r25674 r25678  
    1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    2 <html>
    3 <head>
    4   <title>Piwigo Mail</title>
    5   <meta http-equiv="Content-Type" content="text/html; charset={$CONTENT_ENCODING}">
    6  
    7   {math assign=tn_width equation="min(x,150)"  x=$derivative_params->max_width()}
    8   <style type="text/css">{strip}<!--
    9   {$UC_MAIL_CSS}
    10   #the_image a {ldelim}
     1{math assign=tn_width equation="min(x,150)"  x=$derivative_params->max_width()}
     2<style type="text/css">{strip}
     3#contentTable {
     4  width:{math equation="x*4+200" x=$tn_width}px;
     5}
     6
     7#the_image {
     8  text-align:center;
     9  margin:1em 0;
     10}
     11  #the_image a {
     12    border:none;
     13  }
     14  #the_image img {
    1115    width:{$tn_width}px;
    1216    height:{$tn_width}px;
    1317  }
    14   #the_page {ldelim}
    15     width:{math equation="x*4+120" x=$tn_width}px;
    16   }
    17   -->{/strip}</style>
    18 </head>
    1918
    20 <body>
    21 <div id="the_page">
     19#button {
     20  margin-top:2em;
     21  text-align:center;
     22}
    2223
    23 <div id="the_header">
    24 <b>{$MAIL_TITLE}</b>
    25 </div>
    26 
    27 <div id="the_content">
     24#button  a {
     25  padding:8px 15px;
     26  background:#A80D24;
     27  color:#fff;
     28  border:1px solid #CE2E5A;
     29  text-decoration:none;
     30  font-size:14px;
     31  font-weight:bold;
     32}
     33{/strip}</style>
    2834
    2935<p>
    30   {'Hello <b>%s</b>, %s sent you a photos collection from <a href="%s">%s</a>'|@translate|sprintf:$PARAMS.recipient_name:$PARAMS.sender_name:$GALLERY_URL:$GALLERY_TITLE}
     36  {'Hello <b>%s</b>, %s sent you a photos collection from <a href="%s">%s</a>'|translate:$PARAMS.recipient_name:$PARAMS.sender_name:$GALLERY_URL:$GALLERY_TITLE}
    3137</p>
    3238
     39{if isset($THUMBNAILS)}
    3340<p id="the_image">
    34 {foreach from=$thumbnails item=element}
    35   <a href="{$element.URL}">
    36     <span>{$element.NAME|truncate:25:"..."}</span>
    37     <img src="{$element.THUMB}" alt="{$element.TN_ALT}">
     41{foreach from=$THUMBNAILS item=element}
     42  <a href="{$element.URL}" title="{$element.NAME|escape:html}">
     43    <img src="{$element.THUMB}" alt="{$element.TN_ALT|escape:html}" class="photo">
    3844  </a>
    3945{/foreach}
    4046</p>
     47{/if}
    4148
    4249{if $PARAMS.message}
    43 <p>
    44   <blockquote>{$PARAMS.message}</blockquote>
    45 </p>
     50<blockquote>{$PARAMS.message}</blockquote>
    4651{/if}
    4752
    48 <p class="button">
    49   <a href="{$COL_URL}">{'Click here to view the complete collection'|@translate}</a>
     53<p id="button">
     54  <a href="{$COL_URL}">{'Click here to view the complete collection'|translate}</a>
    5055</p>
    51 
    52 </div>
    53 
    54 <div id="the_footer">
    55   {'Sent by'|@translate} <a href="{$GALLERY_URL}">{$GALLERY_TITLE}</a>
    56   - {'Powered by'|@translate} <a href="{$PHPWG_URL}" class="Piwigo">Piwigo</a> {$VERSION}
    57   - User Collections
    58 </div>
    59 
    60 </div>
    61 </body>
    62 </html>
  • extensions/UserCollections/template/thumbnails_colorbox.tpl

    r25674 r25678  
    1 {if not isset($UC_NO_LIGHTBOX)}
    21{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
    3 {combine_css path='themes/default/js/plugins/colorbox/style2/colorbox.css'}
    4 {/if}
     2{combine_css id='colorbox' path='themes/default/js/plugins/colorbox/style2/colorbox.css'}
    53
    6 {footer_script}
    7 jQuery("a.preview-box").colorbox({ldelim}
    8   rel: ".preview-box",
    9   href: function() {ldelim} return $(this).data('src'); },
    10   title: function() {ldelim}
    11     var title = $(this).children("img.thumbnail").attr("alt");
    12     {if $F_ACTION} title+= ' · <a class="addCollection" data-id="'+ $(this).data('id') +'" rel="nofollow">{'Remove from collection'|@translate|escape:javascript}</a>';{/if}
    13     title+= ' · <a href="'+ $(this).attr('href') +'" target="_blank">{'jump to photo'|@translate|escape:javascript} →</a>';
     4{footer_script require='jquery'}
     5jQuery('a.preview-box').colorbox({
     6  rel: '.preview-box',
     7  href: function() {
     8    return jQuery(this).data('src');
     9  },
     10  title: function() {
     11    var title = jQuery(this).children('img.thumbnail').attr("alt");
     12    {if $F_ACTION} title+= ' · <a class="addCollection" data-id="'+ jQuery(this).data('id') +'" rel="nofollow">{'Remove from collection'|translate|escape:javascript}</a>';{/if}
     13    title+= ' · <a href="'+ jQuery(this).attr('href') +'" target="_blank">{'jump to photo'|translate|escape:javascript} →</a>';
    1414    return  title;
    1515  }
    1616});
    17 jQuery(document).on("click", "#cboxTitle .addCollection", function() {ldelim}
     17jQuery(document).on('click', '#cboxTitle .addCollection', function() {
    1818  jQuery.colorbox.close();
    19   jQuery("#thumbnails a.addCollection[data-id='"+ $(this).data('id')+"']").trigger("click");
     19  jQuery('#thumbnails a.addCollection[data-id="'+ jQuery(this).data('id') +'"]').trigger('click');
    2020  return false;
    2121});
  • extensions/UserCollections/template/thumbnails_css_js.tpl

    r25674 r25678  
    44{if not $UC_IN_EDIT}
    55{footer_script require='jquery'}
    6 var $cdm = jQuery("#collectionsDropdown");
     6var $cdm = jQuery('#collectionsDropdown');
    77
    88{if not $IN_PICTURE}
    9 $cdm.on("mouseleave", function() {ldelim}
     9$cdm.on('mouseleave', function() {
    1010  $cdm.hide();
    1111});
     
    1313
    1414// click on "create collection" button
    15 $cdm.find("a.new").on("click", function(event) {ldelim}
     15$cdm.find('a.new').on('click', function(e) {
    1616  jQuery(this).hide().next().show().focus();
    17   event.stopPropagation();
    18   return false;
     17  e.stopPropagation();
     18  e.preventDefault();
    1919});
    2020
    2121// events on "new collection" input
    22 $cdm.find("input.new").on({ldelim}
     22$cdm.find('input.new').on({
    2323  // ENTER or ESC pressed
    24   "keyup": function(event) {ldelim}
    25     if (event.which == 27) {ldelim}
     24  keyup: function(e) {
     25    if (e.which == 27) {
    2626      jQuery(this).val('').hide().prev().show();
    2727      return;
    2828    }
    29    
    30     if (event.which != 13) return;
    31    
     29
     30    if (e.which != 13) {
     31      return;
     32    }
     33
    3234    jQuery(this).hide().prev().show();
    3335    var name = jQuery(this).val();
    3436    jQuery(this).val('');
    35    
    36     if (name == "" || name == null) return;
    37    
    38     jQuery.ajax({ldelim}
    39       type: "GET",
    40       dataType: "json",
    41       url: "{$ROOT_URL}ws.php",
    42       data: {ldelim}
    43         format: "json",
    44         method: "pwg.collections.create",
     37
     38    if (name == '' || name == null) {
     39      return;
     40    }
     41
     42    jQuery.ajax({
     43      type: 'GET',
     44      dataType: 'json',
     45      url: '{$ROOT_URL}ws.php',
     46      data: {
     47        format: 'json',
     48        method: 'pwg.collections.create',
    4549        name: name,
    4650      },
    47       success: function(data) {ldelim}
    48         if (data.stat == 'ok') {ldelim}
     51      success: function(data) {
     52        if (data.stat == 'ok') {
    4953          var col = data.result;
    5054          var html = '<span>&#9733;</span> <a class="add" data-id="'+ col.id +'">'+ col.name +'</a> '
    5155            +'<span class="menuInfoCat">[<span class="nbImagesCollec-'+ col.id +'">'+ col.nb_images +'</span>]</span> '
    52             +'<a class="remove" data-id="'+ col.id +'">{'(remove)'|@translate}</a>'
     56            +'<a class="remove" data-id="'+ col.id +'">{'(remove)'|translate|escape:javscript}</a>'
    5357            +'<br>';
    54          
    55           $cdm.children(".switchBoxFooter").before(html);
    56           $cdm.children(".noCollecMsg").remove();
    57         }
    58         else {ldelim}
     58
     59          $cdm.children('.switchBoxFooter').before(html);
     60          $cdm.children('.noCollecMsg').remove();
     61        }
     62        else {
    5963          alert(data.message);
    6064        }
    6165      },
    62       error: function() {ldelim}
    63         alert("{'An unknown error occured'|@translate}");
     66      error: function() {
     67        alert('{'An unknown error occured'|translate|escape:javascript}');
    6468      }
    6569    });
    66    
    67     return false;
    6870  },
    6971  // prevent click propagation
    70   "click": function(event) {ldelim}
    71     event.stopPropagation();
     72  click: function(e) {
     73    e.stopPropagation();
    7274  }
    7375});
    7476
    7577// add and remove links (delegate for new collections)
    76 $cdm.on("click", ".add, .remove", function() {ldelim}
    77   var img_id = $cdm.data("img_id");
    78   var col_id = jQuery(this).data("id");
    79   var method = jQuery(this).hasClass("add") ? "pwg.collections.addImages" : "pwg.collections.removeImages";
    80  
    81   jQuery.ajax({ldelim}
    82     type: "GET",
    83     dataType: "json",
    84     url: "{$ROOT_URL}ws.php",
    85     data: {ldelim}
    86       format: "json",
     78$cdm.on('click', '.add, .remove', function(e) {
     79  var img_id = $cdm.data('img_id');
     80  var col_id = jQuery(this).data('id');
     81  var method = jQuery(this).hasClass('add') ? 'pwg.collections.addImages' : 'pwg.collections.removeImages';
     82
     83  jQuery.ajax({
     84    type: 'GET',
     85    dataType: 'json',
     86    url: '{$ROOT_URL}ws.php',
     87    data: {
     88      format: 'json',
    8789      method: method,
    8890      col_id: col_id,
    8991      image_ids: img_id
    9092    },
    91     success: function(data) {ldelim}
    92       if (data.stat == 'ok') {ldelim}
     93    success: function(data) {
     94      if (data.stat == 'ok') {
    9395        // update col counters
    94         jQuery(".nbImagesCollec-"+col_id).html(data.result.nb_images);
    95        
     96        jQuery('.nbImagesCollec-'+ col_id).html(data.result.nb_images);
     97
    9698        // update item datas
    97         var $target = jQuery(".addCollection[data-id='"+ img_id +"']");
    98         var col_ids = $target.data("cols");
    99         if (method == "pwg.collections.addImages" && col_ids.indexOf(col_id) == -1)
     99        var $target = jQuery('.addCollection[data-id="'+ img_id +'"]');
     100        var col_ids = $target.data('cols');
     101        if (method == 'pwg.collections.addImages' && col_ids.indexOf(col_id) == -1) {
    100102          col_ids[ col_ids.length ] = col_id;
    101         else if (method == "pwg.collections.removeImages")
     103        }
     104        else if (method == 'pwg.collections.removeImages') {
    102105          col_ids.splice(col_ids.indexOf(col_id), 1);
    103         $target.data("col", col_ids);
    104       }
    105       else {ldelim}
     106        }
     107        $target.data('col', col_ids);
     108      }
     109      else {
    106110        alert(data.message);
    107111      }
    108112    },
    109     error: function() {ldelim}
    110       alert("{'An unknown error occured'|@translate}");
    111     }
    112   });
    113  
     113    error: function() {
     114      alert('{'An unknown error occured'|translate|escape:javascript}');
     115    }
     116  });
     117
    114118  $cdm.hide();
    115   return false;
     119  e.preventDefault();
    116120});
    117121
    118122// main button, open the menu
    119 jQuery(".addCollection").on("click", function(event) {ldelim}
    120   var img_id = jQuery(this).data("id");
    121   var col_ids = jQuery(this).data("cols");
    122  
    123   $cdm.data("img_id", img_id);
    124  
    125   $cdm.children(".add").each(function() {ldelim}   
    126     if (col_ids.indexOf($(this).data("id")) != -1) {ldelim}
    127       $(this).css("font-weight", "bold").next().next().show();
    128     }
    129     else {ldelim}
    130       $(this).css("font-weight", "normal").next().next().hide();
    131     }
    132   });
    133  
     123jQuery('.addCollection').on('click', function(e) {
     124  var img_id = jQuery(this).data('id');
     125  var col_ids = jQuery(this).data('cols');
     126
     127  $cdm.data('img_id', img_id);
     128
     129  $cdm.children('.add').each(function() {
     130    if (col_ids.indexOf($(this).data('id')) != -1) {
     131      $(this).css('font-weight', 'bold').next().next().show();
     132    }
     133    else {
     134      $(this).css('font-weight', 'normal').next().next().hide();
     135    }
     136  });
     137
    134138  {if not $IN_PICTURE}
    135   $cdm.css({ldelim}
    136     "top": event.pageY-5-$(window).scrollTop(),
    137     "left": Math.min(event.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5)
     139  $cdm.css({
     140    'top': e.pageY-5-$(window).scrollTop(),
     141    'left': Math.min(e.pageX-jQuery(window).scrollLeft()-20, jQuery(window).width()-$cdm.outerWidth(true)-5)
    138142  });
    139143  $cdm.show();
    140144  {/if}
    141  
    142   return false;
     145
     146  e.preventDefault();
    143147});
    144148
    145149// try to respect theme colors
    146 $cdm.children(".switchBoxFooter").css("border-top-color", $cdm.children(".switchBoxTitle").css("border-bottom-color"));
     150$cdm.children('.switchBoxFooter').css('border-top-color', $cdm.children('.switchBoxTitle').css('border-bottom-color'));
    147151{/footer_script}
    148152
    149153<div id="collectionsDropdown" class="switchBox">
    150   <div class="switchBoxTitle">{'Collections'|@translate}</div>
    151  
     154  <div class="switchBoxTitle">{'Collections'|translate}</div>
     155
    152156  {foreach from=$COLLECTIONS item=col}
    153157    <span>&#9733;</span> <a class="add" data-id="{$col.id}">{$col.name}</a>
    154158    <span class="menuInfoCat">[<span class="nbImagesCollec-{$col.id}">{$col.nb_images}</span>]</span>
    155     <a class="remove" data-id="{$col.id}">{'(remove)'|@translate}</a>
     159    <a class="remove" data-id="{$col.id}">{'(remove)'|translate}</a>
    156160    <br>
    157161  {foreachelse}
    158     <span class="noCollecMsg">{'You have no collection'|@translate}</span>
     162    <span class="noCollecMsg">{'You have no collection'|translate}</span>
    159163  {/foreach}
    160  
     164
    161165  <div class="switchBoxFooter">
    162   <span>&#10010;</span> <a class="new">{'Create a new collection'|@translate}</a>
    163   <input type="text" class="new" placeholder="{'Name'|@translate}" size="25"/>
     166  <span>&#10010;</span> <a class="new">{'Create a new collection'|translate}</a>
     167  <input type="text" class="new" placeholder="{'Name'|translate}" size="25"/>
    164168  </div>
    165169</div>
     
    168172{else}
    169173{footer_script require='jquery'}
    170 jQuery(".addCollection").on("click", function(event) {ldelim}
     174jQuery('.addCollection').on('click', function(e) {
    171175  var $trigger = jQuery(this);
    172   var img_id = jQuery(this).data("id");
     176  var img_id = jQuery(this).data('id');
    173177  var col_id = {$collection.ID};
    174  
    175   jQuery.ajax({ldelim}
    176     type: "GET",
    177     dataType: "json",
    178     url: "{$ROOT_URL}ws.php",
    179     data: {ldelim}
    180       format: "json",
    181       method: "pwg.collections.removeImages",
     178
     179  jQuery.ajax({
     180    type: 'GET',
     181    dataType: 'json',
     182    url: '{$ROOT_URL}ws.php',
     183    data: {
     184      format: 'json',
     185      method: 'pwg.collections.removeImages',
    182186      col_id: col_id,
    183187      image_ids: img_id
    184188    },
    185     success: function(data) {ldelim}
    186       if (data.stat == 'ok') {ldelim}
    187         $trigger.parent("li").hide("fast", function() {ldelim}
     189    success: function(data) {
     190      if (data.stat == 'ok') {
     191        $trigger.parent('li').hide('fast', function() {
    188192          jQuery(this).remove();
    189           if (typeof GThumb != "undefined") GThumb.build();
     193          if (typeof GThumb != 'undefined') {
     194            GThumb.build();
     195          }
    190196        });
    191        
    192         jQuery(".nbImagesCollec-"+col_id).html(data.result.nb_images);
    193         if (typeof batchdown_count != 'undefined') batchdown_count = data.result.nb_images;
    194       }
    195       else {ldelim}
     197
     198        jQuery('.nbImagesCollec-'+ col_id).html(data.result.nb_images);
     199        if (typeof batchdown_count != 'undefined') {
     200          batchdown_count = data.result.nb_images;
     201        }
     202      }
     203      else {
    196204        alert(data.message);
    197205      }
    198206    },
    199     error: function() {ldelim}
    200       alert("{'An unknown error occured'|@translate}");
    201     }
    202   });
    203  
    204   event.stopPropagation();
    205   event.preventDefault();
    206   return false;
     207    error: function() {
     208      alert('{'An unknown error occured'|translate|escape:javascript}');
     209    }
     210  });
     211
     212  e.stopPropagation();
     213  e.preventDefault();
    207214});
    208215{/footer_script}
Note: See TracChangeset for help on using the changeset viewer.