Ignore:
Timestamp:
Jun 26, 2013, 12:09:21 AM (11 years ago)
Author:
mistic100
Message:

many corrections & optimizations + remove useless code + clean

Location:
extensions/UserCollections
Files:
21 edited
5 moved

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/admin.php

    r20090 r23551  
    1515  if (isset($_GET['col_id']))
    1616  {
    17     $tabsheet->add('export', l10n('Export'), USER_COLLEC_ADMIN . '-export&col_id='.$_GET['col_id']);
     17    $tabsheet->add('export', l10n('Export image list'), USER_COLLEC_ADMIN . '-export&col_id='.$_GET['col_id']);
    1818  }
    1919  else
  • extensions/UserCollections/admin/config.php

    r20090 r23551  
    1717
    1818
    19 $template->set_filename('user_collections', dirname(__FILE__) . '/template/config.tpl');
     19$template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/config.tpl'));
    2020
    2121?>
  • extensions/UserCollections/admin/export.php

    r20099 r23551  
    5555$template->assign('inactive_fields', pwg_get_session_var('uc_export_inactive_fields', $default_inactive_fields));
    5656
    57 $template->set_filename('user_collections', dirname(__FILE__) . '/template/export.tpl');
     57$template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/export.tpl'));
    5858
    5959?>
  • extensions/UserCollections/admin/sets.php

    r20090 r23551  
    4646{
    4747  $template->append('sets', array(
    48     'NAME' => $row['name'],
     48    'NAME' => trigger_event('render_category_name', $row['name']),
    4949    'NB_IMAGES' => $row['nb_images'],
    5050    'DATE_CREATION' => format_date($row['date_creation'], true),
     
    7070  );
    7171
    72 $template->assign('order_options', $page['order_by_items']);
    73 $template->assign('order_selected',
    74     isset($_POST['order_by']) ? $_POST['order_by'] : '');
    75 
    76 $template->assign('direction_options', $page['direction_items']);
    77 $template->assign('direction_selected',
    78     isset($_POST['direction']) ? $_POST['direction'] : '');
    79 
    8072
    8173$template->assign(array(
     74  'order_options' => $page['order_by_items'],
     75  'order_selected' => isset($_POST['order_by']) ? $_POST['order_by'] : '',
     76  'direction_options' => $page['direction_items'],
     77  'direction_selected' => isset($_POST['direction']) ? $_POST['direction'] : '',
     78 
    8279  'F_USERNAME' => @htmlentities($_POST['username'], ENT_COMPAT, 'UTF-8'),
    8380  'F_NAME' => @htmlentities($_POST['name'], ENT_COMPAT, 'UTF-8'),
     
    8683
    8784
    88 $template->set_filename('user_collections', dirname(__FILE__) . '/template/sets.tpl');
     85$template->set_filename('user_collections', realpath(USER_COLLEC_PATH . 'admin/template/sets.tpl'));
    8986
    9087?>
  • extensions/UserCollections/admin/template/sets.tpl

    r20090 r23551  
    5656    <td style="padding-left:25px;">
    5757      <a href="{$set.U_EDIT}" title="{'Edit this collection'|@translate}"><img src="{$themeconf.admin_icon_dir}/edit_s.png"></a>
    58       <a href="{$set.U_EXPORT}" title="{'Export image list'|@translate}"><img src="{$themeconf.admin_icon_dir}/plug_install.png"></a>
    59       <a href="{$set.U_DELETE}" title="{'Delete this collection'|@translate}" onClick="return confirm('{'Are your sure?'|@translate}');"><img src="{$themeconf.admin_icon_dir}/delete.png"></a>
     58      <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 -->
     59      <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>
    6060    </td>
    6161  </tr>
     
    6464  {if not $sets}
    6565  <tr class="row2">
    66     <td colspan="8" style="text-align:center;font-style:italic;">{'No result'|@translate}</td>
     66    <td colspan="8" style="text-align:center;font-style:italic;">{'No results'|@translate}</td>
    6767  </tr>
    6868  {/if}
  • extensions/UserCollections/include/UserCollection.class.php

    r23361 r23551  
    99  /**
    1010   * __construct
    11    * @param: mixed col id (##|'new'|'active')
     11   * @param: mixed col id (##|'new')
    1212   * @param: array images
    1313   */
    14   function __construct($col_id, $images=array(), $name=null, $active=false, $public=false, $user_id=null)
     14  function __construct($col_id, $name=null, $comment=null, $public=false, $user_id=null)
    1515  {
    1616    global $user;
     
    2525      'name' => null,
    2626      'date_creation' => '0000-00-00 00:00:00',
     27      'domment' => null,
    2728      'nb_images' => 0,
    28       'active' => 0,
    2929      'public' => 0,
    3030      'public_id' => null,
     
    7171          );
    7272       
    73         // make sur all pictures of the collection exist
     73        // make sure all pictures of the collection exist
    7474        $query = '
    7575DELETE FROM '.COLLECTION_IMAGES_TABLE.'
     
    9999    {
    100100      $this->data['name'] = $name;
    101       $this->data['active'] = (int)$active;
     101      $this->data['comment'] = $comment;
    102102      $this->data['public'] = (int)$public;
    103103      $this->data['public_id'] = 'uc'.hash('crc32', uniqid(serialize($this->data), true));
     
    108108    name,
    109109    date_creation,
    110     active,
     110    comment,
    111111    public,
    112112    public_id
     
    116116    "'.$this->data['name'].'",
    117117    NOW(),
    118     '.(int)$this->data['active'].',
     118    "'.$this->data['comment'].'",
    119119    '.(int)$this->data['public'].',
    120120    "'.$this->data['public_id'].'"
     
    126126      $date = pwg_query('SELECT NOW();');
    127127      list($this->data['date_creation']) = pwg_db_fetch_row($date);
    128      
    129       if (!empty($images))
    130       {
    131         $this->addImages($images);
    132       }
    133128    }
    134129    else
     
    283278      'ID' => $this->data['id'],
    284279      'NAME' => $this->data['name'],
     280      'COMMENT' => $this->data['comment'],
    285281      'NB_IMAGES' => $this->data['nb_images'],
    286       'ACTIVE' => (bool)$this->data['active'],
    287282      'PUBLIC' => (bool)$this->data['public'],
    288283      'DATE_CREATION' => $this->data['date_creation'],
     
    317312    if (!verify_ephemeral_key(@$key))
    318313    {
    319       array_push($errors, l10n('Invalid or expired security key'));
     314      array_push($errors, l10n('Invalid key'));
    320315      $comment_action='reject';
    321316    }
  • extensions/UserCollections/include/collections.inc.php

    r23361 r23551  
    1919    if (is_a_guest()) access_denied();
    2020   
    21     $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/list.tpl'));
     21    $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collections_list.tpl'));
    2222   
    2323    // actions
     
    3535          else
    3636          {
    37             $UserCollection = new UserCollection('new', array(), $_GET['name'], 1);
     37            $UserCollection = new UserCollection('new', $_GET['name']);
    3838           
    3939            if (isset($_GET['redirect']))
     
    6464          break;
    6565        }
    66        
    67         // set active
    68         case 'toggle_active':
    69         {
    70           $query = '
    71 UPDATE '.COLLECTIONS_TABLE.'
    72   SET active = IF(active=1, 0, 1)
    73   WHERE
    74     user_id = '.$user['id'].'
    75     AND id = '.$_GET['col_id'].'
    76 ;';
    77           pwg_query($query);
    78          
    79           redirect(USER_COLLEC_PUBLIC);
    80           break;
    81         }
    8266      }
    8367    }
     
    10286    }
    10387   
    104     $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/edit.tpl'));
     88    $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collection_edit.tpl'));
    10589   
    10690    $self_url = USER_COLLEC_PUBLIC . 'edit/'.$page['col_id'];
     
    10993      'user_collections' => $conf['user_collections'],
    11094      'F_ACTION' => $self_url,
    111       'collection_toggle_url' => $self_url,
    11295      'U_LIST' => USER_COLLEC_PUBLIC,
    11396      'UC_IN_EDIT' => true,
     
    133116        }
    134117        $UserCollection->updateParam('public', $_POST['public']);
     118        $UserCollection->updateParam('comment', stripslashes($_POST['comment']));
    135119      }
    136120     
     
    182166      // add remove item links
    183167      $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button');
    184       $template->set_prefilter('index', 'user_collections_thumbnails_list_cssjs');
    185168      $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox');
    186169     
     
    211194     
    212195      $template->concat('TITLE',
    213         $conf['level_separator'].$UserCollection->getParam('name')
     196        $conf['level_separator'].trigger_event('render_category_name', $col['NAME'])
    214197        );
     198       
     199      $template->assign('CONTENT_DESCRIPTION', trigger_event('render_category_description', nl2br($col['COMMENT'])));
    215200    }
    216201    catch (Exception $e)
     
    232217    }
    233218   
    234     $template->set_filename('index', dirname(__FILE__).'/../template/view.tpl');
     219    $template->set_filename('index', realpath(USER_COLLEC_PATH.'template/collection_view.tpl'));
    235220   
    236221    $self_url = USER_COLLEC_PUBLIC . 'view/'.$page['col_id'];
    237222   
    238223    try {
    239       $UserCollection = new UserCollection($page['col_id']);
    240       $page['col_id'] = $UserCollection->getParam('id');
     224      $UserCollection = new UserCollection($page['col_id']); // public id
     225      $page['col_id'] = $UserCollection->getParam('id'); // private id
     226      $col = $UserCollection->getCollectionInfo();
    241227     
    242228      $template->set_prefilter('index_thumbnails', 'user_collections_add_colorbox');
     
    248234      include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    249235      $template->concat('TITLE',
    250         $conf['level_separator'].$UserCollection->getParam('name').
    251         ' ('.sprintf(l10n('by %s'), get_username($UserCollection->getParam('user_id'))).')'
     236        $conf['level_separator'] . trigger_event('render_category_name', $col['NAME']) .
     237        ' (' . sprintf(l10n('by %s'), get_username($UserCollection->getParam('user_id'))) . ')'
    252238        );
     239       
     240      $template->assign('CONTENT_DESCRIPTION', trigger_event('render_category_description', nl2br($col['COMMENT'])));
    253241    }
    254242    catch (Exception $e)
     
    264252function user_collections_categories_list($content, &$samrty)
    265253{
    266   $search[0] = '<div class="thumbnailCategory">';
    267   $replace[0] = '<div class="thumbnailCategory {*if $cat.active}activeCollection{/if*}">
     254  $search = '<div class="thumbnailCategory">';
     255  $replace = '<div class="thumbnailCategory">
    268256  <div class="collectionActions">
    269257    <a href="{$cat.URL}" rel="nofollow">{"Edit"|@translate}</a>
    270258    | <a href="{$cat.U_DELETE}" onClick="return confirm(\'{"Are you sure?"|@translate}\');" rel="nofollow">{"Delete"|@translate}</a>
    271     {if $cat.U_ACTIVE}| <a href="{$cat.U_ACTIVE}" rel="nofollow">{if $cat.active}{"set inactive"|@translate}{else}{"set active"|@translate}{/if}</a>{/if}
    272259  </div>';
    273  
    274   // $search[1] = '<a href="{$cat.URL}">{$cat.NAME}</a>';
    275   // $replace[1] = '<a href="{$cat.URL}">{$cat.NAME}</a> {if $cat.active}<span class="collectionActive">({"active"|@translate})</span>{/if}';
    276260 
    277261  return str_replace($search, $replace, $content);
     
    281265function user_collections_add_colorbox($content)
    282266{
    283   // add datas
    284267  $search = '<a href="{$thumbnail.URL}"';
    285268  $replace = $search.' class="preview-box" data-src="{$thumbnail.FILE_SRC}" data-id="{$thumbnail.id}"';
    286269 
    287   // colorbox script
    288   $content.= file_get_contents(USER_COLLEC_PATH.'template/thumbnails_colorbox.tpl');
    289  
    290270  return str_replace($search, $replace, $content);
    291271}
  • extensions/UserCollections/include/display_collections.inc.php

    r23361 r23551  
    9797      'URL'   => USER_COLLEC_PUBLIC.'edit/'.$category['id'],
    9898      'CAPTION_NB_IMAGES' => empty($counter) ? sprintf(l10n('%d photo'), 0) : $counter,
    99       'NAME'  => $category['name'],
     99      'NAME'  => trigger_event('render_category_name', $category['name']),
     100      'DESCRIPTION'  => trigger_event('render_category_description', $category['comment'], 'subcatify_category_description'),
    100101      'INFO_DATES' => format_date($category['date_creation'], true),
    101      
    102       // 'U_ACTIVE' => add_url_params(USER_COLLEC_PUBLIC, array('action'=>'toggle_active','col_id'=>$category['id'])),
    103102      'U_DELETE' => add_url_params(USER_COLLEC_PUBLIC, array('action'=>'delete','col_id'=>$category['id'])),
    104103      ));
  • extensions/UserCollections/include/display_thumbnails.inc.php

    r23361 r23551  
    134134        array('start')
    135135      );
    136      
    137     $thumbnail['COLLECTION_SELECTED'] = true;
    138     $thumbnail['COLLECTION_TOGGLE_URL'] = add_url_params($url, array('collection_toggle'=>$thumbnail['id']));
    139136  }
    140137 
  • extensions/UserCollections/include/events.inc.php

    r23361 r23551  
    4747function user_collections_page()
    4848{
    49   global $page;
     49  global $page, $template;
    5050
    5151  if (isset($page['section']) and $page['section'] == 'collections')
    5252  {
    5353    include(USER_COLLEC_PATH . '/include/collections.inc.php');
     54  }
     55 
     56  if (!is_a_guest() && count($page['items']))
     57  {
     58    $template->set_filename('uc_tumbnails_cssjs', realpath(USER_COLLEC_PATH . 'template/thumbnails_css_js.tpl'));
     59    $template->parse('uc_tumbnails_cssjs');
    5460  }
    5561}
     
    98104  // get all collections
    99105  $query = '
    100 SELECT id, name, nb_images, active
     106SELECT id, name, nb_images
    101107  FROM '.COLLECTIONS_TABLE.'
    102108  WHERE user_id = '.$user['id'].'
     
    104110;';
    105111  $collections = hash_from_query($query, 'id');
     112 
     113  foreach ($collections as &$col)
     114  {
     115    $col["name"] = trigger_event("render_category_name", $col["name"]);
     116  }
     117  unset($col);
    106118 
    107119  $template->assign(array(
     
    112124  // thumbnails buttons
    113125  $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_button');
    114   $template->set_prefilter('index', 'user_collections_thumbnails_list_cssjs');
    115126 
    116127  return $tpl_thumbnails_var;
     
    133144}
    134145
    135 // add css & js and menu
    136 function user_collections_thumbnails_list_cssjs($content, &$smarty)
    137 {
    138   $content.= file_get_contents(USER_COLLEC_PATH.'template/thumbnails_css_js.tpl');
    139   return $content;
    140 }
    141 
    142146
    143147// +-----------------------------------------------------------------------+
     
    167171  // get all collections
    168172  $query = '
    169 SELECT id, name, nb_images, active
     173SELECT id, name, nb_images
    170174  FROM '.COLLECTIONS_TABLE.'
    171175  WHERE user_id = '.$user['id'].'
     
    173177;';
    174178  $collections = hash_from_query($query, 'id');
     179 
     180  foreach ($collections as &$col)
     181  {
     182    $col["name"] = trigger_event("render_category_name", $col["name"]);
     183  }
     184  unset($col);
    175185 
    176186  $template->assign(array(
     
    214224  {
    215225    $query = '
    216 SELECT *
     226SELECT id, name, nb_images
    217227  FROM '.COLLECTIONS_TABLE.'
    218228  WHERE user_id = '.$user['id'].'
    219   ORDER BY
    220     active DESC,
    221     date_creation DESC
     229  ORDER BY date_creation DESC
    222230;';
    223231    $collections = array_values(hash_from_query($query, 'id'));
     
    226234    for ($i=0; $i<$max && $i<count($collections); $i++)
    227235    {
    228       $collections[$i]['U_EDIT'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id'];
     236      $collections[$i]['name'] = trigger_event('render_category_name', $collections[$i]['name']);
     237      $collections[$i]['u_edit'] = USER_COLLEC_PUBLIC.'edit/'.$collections[$i]['id'];
    229238      $data['collections'][] = $collections[$i];
    230239    }
     
    239248    $data['U_CREATE'] = add_url_params(USER_COLLEC_PUBLIC, array('action'=>'new','col_id'=>'0','redirect'=>'true'));
    240249   
    241     $template->set_template_dir(USER_COLLEC_PATH . 'template/');
    242250    $block->set_title('<a href="'.USER_COLLEC_PUBLIC.'">'.l10n('Collections').'</a>');
    243     $block->template = 'menublock_user_collec.tpl';
     251    $block->template = realpath(USER_COLLEC_PATH . 'template/menublock.tpl');
    244252    $block->data = $data;
    245253  }
  • extensions/UserCollections/include/functions.inc.php

    r23361 r23551  
    11<?php
    22defined('USER_COLLEC_PATH') or die('Hacking attempt!');
    3 
    4 function get_current_collection_id($create=true)
    5 {
    6   global $user;
    7  
    8   // active in db
    9   $query = '
    10 SELECT id
    11   FROM '.COLLECTIONS_TABLE.'
    12   WHERE
    13     active = 1
    14     AND user_id = '.$user['id'].'
    15 ;';
    16   $result = pwg_query($query);
    17  
    18   if (pwg_db_num_rows($result))
    19   {
    20     list($col_id) = pwg_db_fetch_row($result);
    21     return $col_id;
    22   }
    23  
    24   // new one
    25   if ($create)
    26   {
    27     $UserCollection = new UserCollection('new', array(), 'temp', 1);
    28     return $UserCollection->getParam('id');
    29   }
    30  
    31   return false;
    32 }
    333
    344function uc_check_email_validity($mail_address)
  • extensions/UserCollections/include/install.inc.php

    r20090 r23551  
    2424  `name` varchar(255) NOT NULL,
    2525  `date_creation` datetime NOT NULL,
     26  `comment` text NULL,
    2627  `nb_images` mediumint(8) NOT NULL DEFAULT 0,
    27   `active` tinyint(1) DEFAULT 0,
    2828  `public` tinyint(1) DEFAULT 0,
    2929  `public_id` varchar(10) NULL,
     
    4848    pwg_query('ALTER TABLE `'.$prefixeTable.'collection_images` ADD `add_date` DATETIME NULL;');
    4949  }
     50 
     51  $result = pwg_query('SHOW COLUMNS FROM `'.$prefixeTable.'collections` LIKE "comment";');
     52  if (!pwg_db_num_rows($result))
     53  {
     54    pwg_query('ALTER TABLE `'.$prefixeTable.'collections` ADD `comment` TEXT NULL;');
     55    pwg_query('ALTER TABLE `'.$prefixeTable.'collections` DROP `active`;');
     56  }
    5057}
    5158
  • extensions/UserCollections/include/ws_functions.inc.php

    r23361 r23551  
    1212    array(
    1313      'name' => array(),
     14      'comment' => array('default' => null),
    1415      'user_id' => array('default' => null, 'info'=>'Admin parameter, default is current user'),
    15       'active' => array('default' => 0),
    1616      'public' => array('default' => 0),
    1717      ),
     
    3232    'ws_collections_getList',
    3333    array(
    34       'col_id' => array('default' => null),
    3534      'user_id' => array('default' => null, 'info'=>'Admin parameter, default is current user'),
    3635      'name' => array('default' => null),
    3736      'public' => array('default' => null),
    38       'active' => array('default' => null),
    39       ),
    40     'Retrive a list of collections.'
     37      'per_page' => array('default'=>100, 'maxValue'=>ceil($conf['ws_max_images_per_page']/10)),
     38      'page' => array('default'=>0),
     39      'order' => array('default'=>'username ASC, name ASC'),
     40      ),
     41    'Returns a list of collections.'
    4142    );
    4243   
     
    8182        'default'=>array('id','name','url','path'),
    8283        'flags'=>WS_PARAM_FORCE_ARRAY,
    83         'info'=>'Available options are: id, file, name, url, path'
     84        'info'=>'Available options are: id,file,name,url,path,date_creation,collection_add_date,filesize,width,height'
    8485        ),
    8586      ),
    8687    'Returns a serialized version of the collection in CSV.<br>The return type is plain/text whatever you select as response format.'
     88    );
     89   
     90  $service->addMethod(
     91    'pwg.collections.getInfo',
     92    'ws_collections_getInfo',
     93    array(
     94      'col_id' => array('info'=>'The current user must be admin or owner of the collection'),
     95      ),
     96    'Returns basic info about a collection.'
    8797    );
    8898}
     
    135145  }
    136146 
    137   // check active
    138   if ($params['active'] != 0 and $params['active'] != 1)
    139   {
    140     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid "active" value, 0 or 1.');
    141   }
    142  
    143   $UserCollection = new UserCollection('new', array(), $params['name'], $params['active'], $params['public'], $params['user_id']);
    144  
    145   $infos = array_change_key_case($UserCollection->getCollectionInfo(), CASE_LOWER);
    146  
    147   return $infos;
     147  $UserCollection = new UserCollection('new', $params['name'], $params['comment'], $params['public'], $params['user_id']);
     148 
     149  return array_change_key_case($UserCollection->getCollectionInfo(), CASE_LOWER);
    148150}
    149151
     
    233235  }
    234236 
    235   // check collection id
    236   if ( !empty($params['col_id']) and !preg_match('#^[0-9]+$#', $params['col_id']) )
    237   {
    238     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
    239   }
    240  
    241237  // check public
    242238  if ( !empty($params['public']) and $params['public'] != 0 and $params['public'] != 1 )
     
    245241  }
    246242 
    247   // check active
    248   if ( !empty($params['active']) and $params['active'] != 0 and $params['active'] != 1 )
    249   {
    250     return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid "active" value, 0 or 1.');
    251   }
    252  
    253243  // search
    254244  $where_clauses = array('1=1');
    255   if (!empty($params['col_id']))
    256   {
    257     $where_clauses[] = 'c.id = '.$params['col_id'];
    258   }
    259245  if (!empty($params['user_id']))
    260246  {
     
    265251    $where_clauses[] = 'public = '.$params['public'];
    266252  }
    267   if (!empty($params['active']))
    268   {
    269     $where_clauses[] = 'active = '.$params['active'];
    270   }
    271253  if (!empty($params['name']))
    272254  {
    273255    $where_clauses[] = 'name LIKE("%'.pwg_db_real_escape_string($params['name']).'%")';
    274256  }
     257 
     258  $order_by = !empty($params['order']) ? $params['order'] : 'username ASC, name ASC';
    275259 
    276260  $query = '
     
    283267  WHERE
    284268    '.implode("\n    AND ", $where_clauses).'
    285   ORDER BY username ASC, name ASC
     269  ORDER BY '.$order_by.'
     270  LIMIT '.(int)$params['per_page'].' OFFSET '.(int)($params['per_page']*$params['page']).'
    286271;';
    287272  $sets = hash_from_query($query, 'id');
    288273 
    289   $ret = array();
     274  $data = array();
    290275  foreach ($sets as $row)
    291276  {
    292     $ret[] = array(
     277    $data[] = array(
    293278      'id' => $row['id'],
    294279      'name' => $row['name'],
     280      'comment' => $row['comment'],
    295281      'nb_images' => $row['nb_images'],
    296       'active' => (bool)$row['active'],
    297282      'public' => (bool)$row['public'],
    298283      'date_creation' => $row['date_creation'],
     
    303288      );
    304289  }
     290 
     291  return array(
     292    'paging' => new PwgNamedStruct(array(
     293        'page' => $params['page'],
     294        'per_page' => $params['per_page'],
     295        'count' => count($data)
     296        )),
     297    'collections' => new PwgNamedArray(
     298      $data,
     299      'collection'
     300      )
     301    );
    305302 
    306303  return $ret;
     
    413410  WHERE
    414411    '. implode("\n AND ", $where_clauses).'
    415 GROUP BY i.id
    416 '.$order_by.'
    417 LIMIT '.(int)$params['per_page'].' OFFSET '.(int)($params['per_page']*$params['page']);
    418 
    419     $result = pwg_query($query);
    420     while ($row = pwg_db_fetch_assoc($result))
    421     {
    422       $image = array();
    423       foreach (array('id', 'width', 'height', 'hit') as $k)
     412  GROUP BY i.id
     413  '.$order_by.'
     414  LIMIT '.(int)$params['per_page'].' OFFSET '.(int)($params['per_page']*$params['page']).'
     415;';
     416
     417      $result = pwg_query($query);
     418      while ($row = pwg_db_fetch_assoc($result))
    424419      {
    425         if (isset($row[$k]))
     420        $image = array();
     421        foreach (array('id', 'width', 'height', 'hit') as $k)
    426422        {
    427           $image[$k] = (int)$row[$k];
     423          if (isset($row[$k]))
     424          {
     425            $image[$k] = (int)$row[$k];
     426          }
    428427        }
     428        foreach (array('file', 'name', 'comment', 'date_creation', 'date_available') as $k)
     429        {
     430          $image[$k] = $row[$k];
     431        }
     432        $image = array_merge($image, ws_std_get_urls($row));
     433       
     434        array_push($images, $image);
    429435      }
    430       foreach (array('file', 'name', 'comment', 'date_creation', 'date_available') as $k)
    431       {
    432         $image[$k] = $row[$k];
    433       }
    434       $image = array_merge($image, ws_std_get_urls($row));
    435      
    436       array_push($images, $image);
    437436    }
    438   }
    439 
    440   return array('images' => array(
    441     WS_XML_ATTRIBUTES => array(
    442       'page' => $params['page'],
    443       'per_page' => $params['per_page'],
    444       'count' => count($images)
    445       ),
    446     WS_XML_CONTENT => new PwgNamedArray(
    447       $images,
    448       'image',
    449       ws_std_get_image_xml_attributes()
    450       ),
    451     ));
     437   
     438    return array(
     439      'paging' => new PwgNamedStruct(array(
     440          'page' => $params['page'],
     441          'per_page' => $params['per_page'],
     442          'count' => count($images)
     443          )),
     444      'images' => new PwgNamedArray(
     445        $images,
     446        'image',
     447        ws_std_get_image_xml_attributes()
     448        )
     449      );
    452450  }
    453451  catch (Exception $e)
     
    491489  }
    492490}
     491
     492/**
     493 * get info about a collection
     494 */
     495function ws_collections_getInfo($params, &$service)
     496{
     497  global $conf, $user;
     498 
     499  // check status
     500  if (is_a_guest())
     501  {
     502    return new PwgError(403, 'Forbidden');
     503  }
     504 
     505  // check collection id
     506  if (!preg_match('#^[0-9]+$#', $params['col_id']))
     507  {
     508    return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
     509  }
     510
     511  try {
     512    $UserCollection = new UserCollection($params['col_id']);
     513 
     514    return array_change_key_case($UserCollection->getCollectionInfo(), CASE_LOWER);
     515  }
     516  catch (Exception $e)
     517  {
     518    return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid collection id');
     519  }
     520}
     521
    493522?>
  • extensions/UserCollections/language/en_UK/plugin.lang.php

    r23361 r23551  
    88$lang['Collection name:'] = 'Collection name:';
    99$lang['Create a new collection'] = 'Create a new collection';
    10 $lang['Unsaved collections'] = 'Unsaved collections';
    11 $lang['save'] = 'save';
    12 $lang['set active'] = 'set active';
    13 $lang['Saved collections'] = 'Saved collections';
    1410$lang['See all my collections'] = 'See all my collections';
    1511$lang['Please give a name'] = 'Please give a name';
     
    2420$lang['You have no collection'] = 'You have no collection';
    2521$lang['You have %d collections'] = 'You have %d collections';
    26 $lang['active'] = 'active';
    2722$lang['Save'] = 'Save';
    2823$lang['%d more...'] = '%d more...';
  • extensions/UserCollections/language/fr_FR/plugin.lang.php

    r23361 r23551  
    88$lang['Collection name:'] = 'Nom de la collection:';
    99$lang['Create a new collection'] = 'Créer une nouvelle collection';
    10 $lang['Unsaved collections'] = 'Collections temporaires';
    11 $lang['save'] = 'sauvegarder';
    12 $lang['set active'] = 'choisir comme collection active';
    13 $lang['Saved collections'] = 'Collections sauvegardées';
    1410$lang['See all my collections'] = 'Voir toutes mes collections';
    1511$lang['Please give a name'] = 'Veuillez donner un nom';
     
    2420$lang['You have no collection'] = 'Vous n\'avez aucune collection';
    2521$lang['You have %d collections'] = 'Vous avez %d collections';
    26 $lang['active'] = 'active';
    2722$lang['Save'] = 'Sauvegarder';
    2823$lang['%d more...'] = 'et %d autres...';
  • extensions/UserCollections/main.inc.php

    r23361 r23551  
    1919
    2020defined('USER_COLLEC_ID') or define('USER_COLLEC_ID', basename(dirname(__FILE__)));
    21 define('USER_COLLEC_PATH',       PHPWG_PLUGINS_PATH . USER_COLLEC_ID . '/');
    22 define('COLLECTIONS_TABLE',      $prefixeTable.'collections');
    23 define('COLLECTION_IMAGES_TABLE',$prefixeTable.'collection_images');
    24 define('USER_COLLEC_ADMIN',      get_root_url() . 'admin.php?page=plugin-' . USER_COLLEC_ID);
    25 define('USER_COLLEC_PUBLIC',     get_absolute_root_url() . make_index_url(array('section' => 'collections')) . '/');
     21define('USER_COLLEC_PATH',        PHPWG_PLUGINS_PATH . USER_COLLEC_ID . '/');
     22define('COLLECTIONS_TABLE',       $prefixeTable.'collections');
     23define('COLLECTION_IMAGES_TABLE', $prefixeTable.'collection_images');
     24define('USER_COLLEC_ADMIN',       get_root_url() . 'admin.php?page=plugin-' . USER_COLLEC_ID);
     25define('USER_COLLEC_PUBLIC',      get_absolute_root_url() . make_index_url(array('section' => 'collections')) . '/');
    2626define('USER_COLLEC_VERSION',    'auto');
    2727
  • extensions/UserCollections/maintain.inc.php

    r20090 r23551  
    2424  global $prefixeTable;
    2525 
     26  pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "user_collections" LIMIT 1;');
    2627  pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collections`;');
    2728  pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'collection_images`;');
  • extensions/UserCollections/template/collection_edit.tpl

    r23217 r23551  
    1 {combine_css path=$USER_COLLEC_PATH|@cat:"template/style.css"}
    2 {combine_script id='ZeroClipboard' path=$USER_COLLEC_PATH|@cat:"template/resources/ZeroClipboard.min.js"}
    3 
    4 {combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
    5 {combine_css path="themes/default/js/plugins/colorbox/style2/colorbox.css"}
     1{combine_css path=$USER_COLLEC_PATH|cat:'template/style_collections.css'}
     2{combine_script id='ZeroClipboard' path=$USER_COLLEC_PATH|cat:'template/resources/ZeroClipboard.min.js'}
     3{include file=$USER_COLLEC_ABS_PATH|cat:'template/thumbnails_colorbox.tpl'}
    64
    75{footer_script require='jquery'}
     
    97ZeroClipboard.setDefaults( {ldelim} moviePath: "{$ROOT_URL}{$USER_COLLEC_PATH}template/resources/ZeroClipboard.swf" } );
    108var clip = new ZeroClipboard();
     9
    1110clip.glue(jQuery("#publicURL .button").get());
    1211clip.addEventListener('onMouseOver', function() {ldelim}
     
    4241  jQuery("#mail_form").css('background-color', jQuery("#the_page #content").css('background-color'));
    4342{/if}
     43
     44jQuery("#edit_form_show").click(function() {ldelim}
     45  jQuery("#edit_form_show").hide();
     46  jQuery(".additional_info").hide();
     47  jQuery("#edit_form").show();
     48});
     49jQuery("#edit_form_hide").click(function() {ldelim}
     50  jQuery("#edit_form_show").show();
     51  jQuery(".additional_info").show();
     52  jQuery("#edit_form").hide();
     53});
    4454{/footer_script}
    4555
     
    6171
    6272
    63 {if $collection}
     73{if !empty($CONTENT_DESCRIPTION)}
     74<div class="additional_info">
     75        {$CONTENT_DESCRIPTION}
     76</div>
     77{/if}
     78
     79<p style="text-align:center;"><input type="submit" id="edit_form_show" value="{'Edit'|@translate}"></p>
     80
    6481{* <!-- edit collection -->*}
    65 <form action="{$F_ACTION}" method="post">
     82<form action="{$F_ACTION}" method="post" id="edit_form" style="display:none;">
    6683<fieldset id="colProperties">
    6784  <legend>{'Properties'|@translate}</legend>
     
    6986  <p class="title"><label for="name">{'Name'|@translate}</label></p>
    7087  <p><input type="text" name="name" id="name" value="{$collection.NAME|escape:html}" size="60"></p>
     88 
     89  <p class="title"><label for="comment">{'Description'|@translate}</label></p>
     90  <p><textarea name="comment" id="comment" style="width:400px;height:100px;">{$collection.COMMENT}</textarea></p>
     91 
    7192{if $user_collections.allow_public}
    7293  <p class="title">{'Public collection'|@translate}</p>
     
    80101  </p>
    81102{/if}
     103
    82104  <p>
    83105    <input type="submit" name="save_col" value="{'Save'|@translate}">
    84     <a href="{$U_LIST}" rel="nofollow">{'Return to collections list'|@translate}</a>
     106    <a id="edit_form_hide">{'Cancel'|@translate}</a>
    85107  </p>
    86108</fieldset>
    87109</form>
     110
    88111
    89112{* <!-- send collection by mail -->*}
     
    148171{/if}
    149172
     173
    150174{* <!-- collection content -->*}
    151175{if $collection.NB_IMAGES > 0}
     
    158182
    159183{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
    160 {/if}
    161184
    162 {if $clear}<div style="clear: both;"></div>
     185
     186{if isset($clear)}<div style="clear: both;"></div>
    163187</div>{/if}
    164188</div>{* <!-- content --> *}
  • extensions/UserCollections/template/collection_view.tpl

    r23217 r23551  
    1 {combine_css path=$USER_COLLEC_PATH|@cat:"template/style.css"}
     1{combine_css path=$USER_COLLEC_PATH|cat:'template/style_collections.css'}
     2{include file=$USER_COLLEC_ABS_PATH|cat:'template/thumbnails_colorbox.tpl'}
    23
    34
     
    1718{/if}
    1819
     20{if !empty($CONTENT_DESCRIPTION)}
     21<div class="additional_info">
     22        {$CONTENT_DESCRIPTION}
     23</div>
     24{/if}
    1925
    2026{if !empty($THUMBNAILS)}
     
    2632{if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
    2733
    28 {if $clear}<div style="clear: both;"></div>
     34{if isset($clear)}<div style="clear: both;"></div>
    2935</div>{/if}
    3036</div>{* <!-- content --> *}
  • extensions/UserCollections/template/collections_list.tpl

    r23361 r23551  
    1 {combine_css path=$USER_COLLEC_PATH|@cat:"template/style.css"}
     1{combine_css path=$USER_COLLEC_PATH|cat:'template/style_collections.css'}
    22
    33{footer_script require='jquery'}
     
    3939{/if}
    4040
    41 {if $clear}<div style="clear: both;"></div>
     41{if isset($clear)}<div style="clear: both;"></div>
    4242</div>{/if}
    4343</div>{* <!-- content --> *}
  • extensions/UserCollections/template/menublock.tpl

    r23361 r23551  
    1111                {foreach from=$block->data.collections item=col}
    1212                <li>
    13       <a href="{$col.U_EDIT}" {*if $col.active}style="font-weight:bold;"{/if*} rel="nofollow">{$col.name}</a>&nbsp;
    14       {*if $col.active}<i class="menuInfoCat">({'active'|@translate})</i>&nbsp;{/if*}
     13      <a href="{$col.u_edit}" rel="nofollow">{$col.name}</a>&nbsp;
    1514      <span class="menuInfoCat">[<span class="nbImagesCollec-{$col.id}">{$col.nb_images}</span>]</span>
    1615    </li>
    1716                {/foreach}
    18     {if $block->data.MORE}<li class="menuInfoCat"><a href="{$block->data.U_LIST}">{'%d more...'|@translate|sprintf:$block->data.MORE}</a></li>{/if}
     17    {if isset($block->data.MORE)}<li class="menuInfoCat"><a href="{$block->data.U_LIST}">{'%d more...'|@translate|sprintf:$block->data.MORE}</a></li>{/if}
    1918        {/strip}</ul>
    2019  {/if}
  • extensions/UserCollections/template/style_collections.css

    r23361 r23551  
    4343  }
    4444
    45 /* .thumbnailCategory.activeCollection {
    46   border:1px solid #999;
    47 } */
    4845.thumbnailCategory {
    4946  position:relative;
     
    5855  display:block;
    5956}
    60 /* .thumbnailCategory .collectionActive {
    61   font-weight:normal;
    62   font-style:italic;
    63 } */
    6457
    6558/* SEND BY MAIL */
     
    8376    padding:3px;
    8477  }
    85  
    86 /* TipTip CSS - Version 1.2 */
    87 #tiptip_holder {
    88         display: none;
    89         position: absolute;
    90         top: 0;
    91         left: 0;
    92         z-index: 99999;
    93 }
    94 #tiptip_holder.tip_top {
    95         padding-bottom: 5px;
    96 }
    97 #tiptip_holder.tip_bottom {
    98         padding-top: 5px;
    99 }
    100 #tiptip_holder.tip_right {
    101         padding-left: 5px;
    102 }
    103 #tiptip_holder.tip_left {
    104         padding-right: 5px;
    105 }
    106 #tiptip_content {
    107         font-size: 11px;
    108         color: #fff;
    109         text-shadow: 0 0 2px #000;
    110         padding: 4px 8px;
    111         border: 1px solid rgba(255,255,255,0.25);
    112         background-color: rgb(25,25,25);
    113         background-color: rgba(25,25,25,0.92);
    114         background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(transparent), to(#000));
    115         border-radius: 3px;
    116         -webkit-border-radius: 3px;
    117         -moz-border-radius: 3px;
    118         box-shadow: 0 0 3px #555;
    119         -webkit-box-shadow: 0 0 3px #555;
    120         -moz-box-shadow: 0 0 3px #555;
    121 }
    122 #tiptip_arrow, #tiptip_arrow_inner {
    123         position: absolute;
    124         border-color: transparent;
    125         border-style: solid;
    126         border-width: 6px;
    127         height: 0;
    128         width: 0;
    129 }
    130 #tiptip_holder.tip_top #tiptip_arrow {
    131         border-top-color: #fff;
    132         border-top-color: rgba(255,255,255,0.35);
    133 }
    134 #tiptip_holder.tip_bottom #tiptip_arrow {
    135         border-bottom-color: #fff;
    136         border-bottom-color: rgba(255,255,255,0.35);
    137 }
    138 #tiptip_holder.tip_right #tiptip_arrow {
    139         border-right-color: #fff;
    140         border-right-color: rgba(255,255,255,0.35);
    141 }
    142 #tiptip_holder.tip_left #tiptip_arrow {
    143         border-left-color: #fff;
    144         border-left-color: rgba(255,255,255,0.35);
    145 }
    146 #tiptip_holder.tip_top #tiptip_arrow_inner {
    147         margin-top: -7px;
    148         margin-left: -6px;
    149         border-top-color: rgb(25,25,25);
    150         border-top-color: rgba(25,25,25,0.92);
    151 }
    152 #tiptip_holder.tip_bottom #tiptip_arrow_inner {
    153         margin-top: -5px;
    154         margin-left: -6px;
    155         border-bottom-color: rgb(25,25,25);
    156         border-bottom-color: rgba(25,25,25,0.92);
    157 }
    158 #tiptip_holder.tip_right #tiptip_arrow_inner {
    159         margin-top: -6px;
    160         margin-left: -5px;
    161         border-right-color: rgb(25,25,25);
    162         border-right-color: rgba(25,25,25,0.92);
    163 }
    164 #tiptip_holder.tip_left #tiptip_arrow_inner {
    165         margin-top: -6px;
    166         margin-left: -7px;
    167         border-left-color: rgb(25,25,25);
    168         border-left-color: rgba(25,25,25,0.92);
    169 }
  • extensions/UserCollections/template/style_thumbnails.css

    r23361 r23551  
    2727  left:0;
    2828  box-shadow:2px 2px 10px #000;
     29  z-index:1000;
    2930}
    3031
  • extensions/UserCollections/template/themes/stripped.tpl

    r20093 r23551  
    88    <ul class="categoryActions group1">
    99    {if isset($U_CADDIE) }
    10       <li class="mainAction"><a href="{$U_CADDIE}" title="{'add to caddie'|@translate}">{'caddie'|@translate}</a></li>
     10      <li class="mainAction"><a href="{$U_CADDIE}" title="{'Add to caddie'|@translate}">{'Caddie'|@translate}</a></li>
    1111    {/if}
    1212       
  • extensions/UserCollections/template/thumbnails_colorbox.tpl

    r20097 r23551  
    11{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
    2 {combine_css path="themes/default/js/plugins/colorbox/style2/colorbox.css"}
     2{combine_css path='themes/default/js/plugins/colorbox/style2/colorbox.css'}
    33
    44{footer_script}
     
    88  title: function() {ldelim}
    99    var title = $(this).children("img.thumbnail").attr("alt");
    10     {if $F_ACTION} title+= ' · <a href="{$collection_toggle_url}&amp;collection_toggle='+ $(this).data('id') +'" class="addCollection" data-id="'+ $(this).data('id') +'">{'Remove from collection'|@translate}</a>';{/if}
     10    {if $F_ACTION} title+= ' · <a class="addCollection" data-id="'+ $(this).data('id') +'" rel="nofollow">{'Remove from collection'|@translate}</a>';{/if}
    1111    title+= ' · <a href="'+ $(this).attr('href') +'" target="_blank">{'jump to photo'|@translate} →</a>';
    1212    return  title;
  • extensions/UserCollections/template/thumbnails_css_js.tpl

    r23361 r23551  
    1 {combine_css path=$USER_COLLEC_PATH|@cat:"template/style_thumbnails.css"}
     1{combine_css path=$USER_COLLEC_PATH|cat:'template/style_thumbnails.css'}
    22
    33{* <!-- all pages but collection edit page --> *}
     
    2929    jQuery(this).val("{'Name'|@translate}");
    3030   
    31     if (name == "") return;
     31    if (name == "" || name == null) return;
    3232   
    3333    jQuery.ajax({ldelim}
     
    3939        method: "pwg.collections.create",
    4040        name: name,
    41         active: 1,
    4241      },
    4342      success: function(data) {ldelim}
     
    103102        if (method == "pwg.collections.addImages" && col_ids.indexOf(col_id) == -1)
    104103          col_ids[ col_ids.length ] = col_id;
    105         else
     104        else if (method == "pwg.collections.removeImages")
    106105          col_ids.splice(col_ids.indexOf(col_id), 1);
    107106        $target.data("col", col_ids);
     
    206205  });
    207206 
    208   // not working, the event is fired twice
    209207  event.stopPropagation();
    210208  event.preventDefault();
Note: See TracChangeset for help on using the changeset viewer.