Changeset 16625


Ignore:
Timestamp:
07/11/12 18:44:23 (7 years ago)
Author:
mistic100
Message:

-add download link if BatchDownloader is installed
-merge two prefilters
-better support of Stripped

Location:
extensions/UserCollections
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserCollections/include/UserCollection.class.php

    r16591 r16625  
    44class UserCollection 
    55{ 
    6   // private $conf; 
    76  private $data; 
    87  private $images; 
     
    1514  function __construct($col_id, $images=array(), $name=null, $active=false, $public=false) 
    1615  { 
    17     global $user, $conf; 
    18      
    19     // $this->conf = $conf['user_collections']; 
     16    global $user; 
     17     
    2018    $this->data = array( 
    2119      'col_id' => 0, 
  • extensions/UserCollections/include/collections.inc.php

    r16608 r16625  
    44# this file is called on basket public page # 
    55 
    6 global $page, $template, $conf, $user, $tokens; 
     6global $page, $template, $conf, $user, $tokens, $pwg_loaded_plugins; 
    77 
    88switch ($page['sub_section']) 
     
    132132      $col['U_DELETE'] = USER_COLLEC_PUBLIC.'&action=delete&col_id='.$col['id']; 
    133133       
     134      if (isset($pwg_loaded_plugins['BatchDownloader'])) 
     135      { 
     136        $col['U_DOWNLOAD'] = USER_COLLEC_PUBLIC.'view/'.$col['id'].'&action=advdown_set'; 
     137      } 
     138       
    134139      if ($col['name'] == 'temp') 
    135140      { 
     
    163168      'USER_COLLEC_PATH' => USER_COLLEC_PATH, 
    164169      'U_VIEW' => $self_url, 
     170      'collection_toggle_url' => $self_url, 
    165171      'U_LIST' => USER_COLLEC_PUBLIC, 
    166172      'COL_ID' => $page['col_id'], 
     
    183189       
    184190      // remove an element 
    185       if ( isset($_GET['remove']) and preg_match('#^[0-9]+$#', $_GET['remove']) ) 
    186       { 
    187         $UserCollection->removeImages(array($_GET['remove'])); 
     191      if ( isset($_GET['collection_toggle']) and preg_match('#^[0-9]+$#', $_GET['collection_toggle']) ) 
     192      { 
     193        $UserCollection->removeImages(array($_GET['collection_toggle'])); 
    188194      } 
    189195       
    190196      $template->assign('collection', $UserCollection->getCollectionInfo()); 
    191197       
    192       $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_special_prefilter'); 
     198      // add_event_handler('loc_end_index_thumbnails', 'user_collections_thumbnails_in_collection', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 
     199      $template->set_prefilter('index_thumbnails', 'user_collections_thumbnails_list_prefilter'); 
    193200       
    194201      $page['start'] = isset($_GET['start']) ? $_GET['start'] : 0; 
     
    282289 
    283290 
    284 function user_collections_thumbnails_list_special_prefilter($content, &$smarty) 
    285 { 
    286   // custom style 
    287   $search[0] = '{/html_style}'; 
    288   $replace[0] = '.thumbnails  .wrap1 {ldelim} position:relative; } 
    289 .addCollection {ldelim} width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:0.8em; } 
    290 .wrap1:hover .addCollection {ldelim} display:block; }' 
    291 .$search[0]; 
    292  
    293   // links 
    294   $search[1] = '<span class="wrap1">'; 
    295   $replace[1] = $search[1].' 
    296 {strip}<a class="addCollection" href="{$U_VIEW}&amp;remove={$thumbnail.id}" data-id="{$thumbnail.id}" rel="nofollow"> 
    297 {\'Remove from collection\'|@translate}&nbsp;<img src="{$USER_COLLEC_PATH}template/image_delete.png" title="{\'Remove from collection\'|@translate}"> 
    298 </a>{/strip}'; 
    299  
    300   // AJAX request 
    301   $search[2] = '{/html_style}'; 
    302   $replace[2] = $search[2].' 
    303 {footer_script require=\'jquery\'} 
    304 jQuery(".addCollection").click(function() {ldelim} 
    305   var toggle_id = jQuery(this).data("id"); 
    306   var $trigger = jQuery(this); 
     291// function user_collections_thumbnails_in_collection($tpl_thumbnails_var, $pictures) 
     292// { 
     293  // global $page; 
    307294   
    308   jQuery.ajax({ldelim} 
    309     type: "POST", 
    310     url: "{$USER_COLLEC_PATH}toggle_image.php", 
    311     data: {ldelim} "col_id": "{$COL_ID}", "toggle_id": toggle_id } 
    312   }).done(function(msg) {ldelim} 
    313     if (msg == "false") {ldelim} 
    314       $trigger.parent(".wrap1").hide("fast", function() {ldelim} $trigger.remove() }); 
    315     } else {ldelim} 
    316       $trigger.html(\'{\'Un unknown error occured\'|@translate}\'); 
    317     } 
    318   }); 
     295  // foreach ($tpl_thumbnails_var as &$thumbnail) 
     296  // { 
     297    // $thumbnail['URL'] = duplicate_picture_url( 
     298        // array( 
     299          // 'image_id' => $thumbnail['id'], 
     300          // 'image_file' => $thumbnail['file'], 
     301          // 'section' => 'collections', 
     302        // ), 
     303        // array('start') 
     304      // ).'/'.$page['col_id']; 
     305  // } 
    319306   
    320   return false; 
    321 }); 
    322 {/footer_script}'; 
    323  
    324   return str_replace($search, $replace, $content); 
    325 } 
     307  // return $tpl_thumbnails_var; 
     308// } 
    326309 
    327310?> 
  • extensions/UserCollections/include/events.inc.php

    r16608 r16625  
    3535    } 
    3636  } 
    37 } 
    38  
    39 /* collection section */ 
     37   
     38  // if ( script_basename() == 'picture' and @$tokens[1] == 'collections' and preg_match('#^[0-9]+$#', @$tokens[2]) ) 
     39  // { 
     40    // try 
     41    // { 
     42      // $UserCollection = new UserCollection($tokens[2]); 
     43      // $page['title'].= $conf['level_separator'].l10n('Collection').': <a href="'.USER_COLLEC_PUBLIC . 'view/'.$tokens[2].'">'.$UserCollection->getParam('name').'</a>'; 
     44      // $page['items'] = $UserCollection->getImages(); 
     45      // $page['col_id'] = $tokens[2]; 
     46    // } catch (Exception $e) {} 
     47  // } 
     48} 
     49 
     50/* collections section */ 
    4051function user_collections_page() 
    4152{ 
     
    116127function user_collections_thumbnails_list_prefilter($content, &$smarty) 
    117128{ 
    118   // custom style 
    119   $search[0] = '{/html_style}'; 
    120   $replace[0] = '.thumbnails  .wrap1 {ldelim} position:relative; } 
    121 .addCollection {ldelim} width:100%;height:16px;display:none;position:absolute;top:0;background:rgba(0,0,0,0.8);padding:2px;border-radius:2px;font-size:0.8em; } 
    122 .wrap1:hover .addCollection {ldelim} display:block; }' 
    123 .$search[0]; 
    124  
    125   // links 
    126   $search[1] = '<span class="wrap1">'; 
    127   $replace[1] = $search[1].' 
     129  // add links 
     130  $search = '<span class="wrap1">'; 
     131  $replace = $search.' 
    128132{strip}<a class="addCollection" href="{$collection_toggle_url}&amp;collection_toggle={$thumbnail.id}" data-id="{$thumbnail.id}" rel="nofollow"> 
    129 {if $thumbnail.COLLECTION_SELECTED} 
     133{if $COL_ID or $thumbnail.COLLECTION_SELECTED} 
    130134{\'Remove from collection\'|@translate}&nbsp;<img src="{$USER_COLLEC_PATH}template/image_delete.png" title="{\'Remove from collection\'|@translate}"> 
    131135{else} 
     
    134138</a>{/strip}'; 
    135139 
    136   // AJAX request 
    137   $search[2] = '{/html_style}'; 
    138   $replace[2] = $search[2].' 
    139 {footer_script require=\'jquery\'} 
    140 jQuery(".addCollection").click(function() {ldelim} 
    141   var toggle_id = jQuery(this).data("id"); 
    142   var $trigger = jQuery(this); 
    143    
    144   jQuery.ajax({ldelim} 
    145     type: "POST", 
    146     url: "{$USER_COLLEC_PATH}toggle_image.php", 
    147     data: {ldelim} "toggle_id": toggle_id } 
    148   }).done(function(msg) {ldelim} 
    149     if (msg == "true") {ldelim} 
    150       $trigger.html(\'{\'Remove from collection\'|@translate}&nbsp;<img src="{$USER_COLLEC_PATH}template/image_delete.png" title="{\'Remove from collection\'|@translate}">\'); 
    151     } else if (msg == "false") {ldelim} 
    152       $trigger.html(\'{\'Add to collection\'|@translate}&nbsp;<img src="{$USER_COLLEC_PATH}template/image_add.png" title="{\'Add to collection\'|@translate}">\'); 
    153     } else {ldelim} 
    154       $trigger.html(\'{\'Un unknown error occured\'|@translate}\'); 
    155     } 
    156   }); 
    157    
    158   return false; 
    159 }); 
    160 {/footer_script}'; 
     140  // custom CSS and AJAX request 
     141  $content.= file_get_contents(USER_COLLEC_PATH.'template/thumbnails_css_js.tpl'); 
    161142 
    162143  return str_replace($search, $replace, $content); 
  • extensions/UserCollections/template/edit.tpl

    r16608 r16625  
    2727{/footer_script} 
    2828 
    29 {$MENUBAR} 
     29{if $themeconf.name != "stripped" and $themeconf.parent != "stripped" and $themeconf.name != "simple-grey" and $themeconf.parent != "simple"} 
     30  {$MENUBAR} 
     31{else} 
     32  {assign var="intern_menu" value="true"} 
     33{/if} 
     34<div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> 
     35{if $intern_menu}{$MENUBAR}{/if} 
    3036 
    31 <div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> 
    3237<div class="titrePage"> 
    3338  <ul class="categoryActions"> 
  • extensions/UserCollections/template/list.tpl

    r16608 r16625  
    1313{/footer_script} 
    1414 
    15 {$MENUBAR} 
     15{if $themeconf.name != "stripped" and $themeconf.parent != "stripped" and $themeconf.name != "simple-grey" and $themeconf.parent != "simple"} 
     16  {$MENUBAR} 
     17{else} 
     18  {assign var="intern_menu" value="true"} 
     19{/if} 
     20<div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> 
     21{if $intern_menu}{$MENUBAR}{/if} 
    1622 
    17 <div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> 
    1823<div class="titrePage"> 
    1924  <ul class="categoryActions"></ul> 
     
    3944      </p> 
    4045      <p class="collecActions"> 
    41         <a href="{$col.U_EDIT}" rel="nofollow">{'Edit'|@translate}</a> | 
    42         <a href="{$col.U_SAVE}" class="save_col" rel="nofollow">{'save'|@translate}</a> | 
    43         <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{'delete'|@translate}</a> 
     46        <a href="{$col.U_EDIT}" rel="nofollow">{'Edit'|@translate}</a> 
     47        | <a href="{$col.U_SAVE}" class="save_col" rel="nofollow">{'save'|@translate}</a> 
     48        {if $col.U_DOWNLOAD}| <a href="{$col.U_DOWNLOAD}" rel="nofollow">{'download'|@translate}</a>{/if} 
     49        | <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{'delete'|@translate}</a> 
    4450        {if not $col.active}| <a href="{$col.U_ACTIVE}" rel="nofollow">{'set active'|@translate}</a>{/if} 
    4551      </p> 
     
    6571      </p> 
    6672      <p class="collecActions"> 
    67         <a href="{$col.U_EDIT}" rel="nofollow">{'Edit'|@translate}</a> | 
    68         <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{'delete'|@translate}</a> 
     73        <a href="{$col.U_EDIT}" rel="nofollow">{'Edit'|@translate}</a> 
     74        {if $col.U_DOWNLOAD}| <a href="{$col.U_DOWNLOAD}" rel="nofollow">{'download'|@translate}</a>{/if} 
     75        | <a href="{$col.U_DELETE}" onClick="return confirm('{'Are you sure?'|@translate}');" rel="nofollow">{'delete'|@translate}</a> 
    6976        {if not $col.active}| <a href="{$col.U_ACTIVE}" rel="nofollow">{'set active'|@translate}</a>{/if} 
    7077      </p> 
  • extensions/UserCollections/template/menublock_user_collec.tpl

    r16608 r16625  
    22<dd> 
    33{if $block->data.current} 
    4   {'Current collection:'|@translate} <b>{$block->data.current.NAME}</b>, {'%d photos'|@translate|@sprintf:$block->data.current.NB_IMAGES} 
     4  {assign var="nb_images" value='<span class="nbImagesCollec">'|@cat:$block->data.current.NB_IMAGES|@cat:'</span>'} 
     5  <p>{'Current collection:'|@translate} <b>{$block->data.current.NAME}</b>, {'%d photos'|@translate|replace:'%d':'%s'|sprintf:$nb_images}</p> 
    56        <ul>{strip} 
    67                {foreach from=$block->data.links item=link} 
     
    910        {/strip}</ul> 
    1011{/if} 
    11   <a href="{$block->data.U_LIST}" rel="nofollow">{'See all my collections'|@translate}</a> 
     12  <p><a href="{$block->data.U_LIST}" rel="nofollow">{'See all my collections'|@translate}</a></p> 
    1213</dd> 
  • extensions/UserCollections/template/view.tpl

    r16597 r16625  
    11{combine_css path=$USER_COLLEC_PATH|@cat:"template/style.css"} 
    22 
    3 {$MENUBAR} 
     3{if $themeconf.name != "stripped" and $themeconf.parent != "stripped" and $themeconf.name != "simple-grey" and $themeconf.parent != "simple"} 
     4  {$MENUBAR} 
     5{else} 
     6  {assign var="intern_menu" value="true"} 
     7{/if} 
     8<div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> 
     9{if $intern_menu}{$MENUBAR}{/if} 
    410 
    5 <div id="content" class="content{if isset($MENUBAR)} contentWithMenu{/if}"> 
    611<div class="titrePage"> 
    712  <ul class="categoryActions"> 
Note: See TracChangeset for help on using the changeset viewer.