mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-06 01:42:29 +02:00
fixes #426, count views on SmartPocket
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
return '<div class="ps-toolbar-close"><div class="ps-toolbar-content"></div></div><div class="ps-toolbar-play"><div class="ps-toolbar-content"></div></div><div id="more_link">'+var_trad+'</div><div class="ps-toolbar-previous"><div class="ps-toolbar-content"></div></div><div class="ps-toolbar-next"><div class="ps-toolbar-content"></div></div>';},
|
||||
getImageMetaData:function(el){
|
||||
return {
|
||||
picture_url: $(el).attr('data-picture-url')
|
||||
picture_url: $(el).attr('data-picture-url'),
|
||||
image_id: $(el).attr('data-image-id'),
|
||||
};}
|
||||
};
|
||||
var myPhotoSwipe = $(".thumbnails a").photoSwipe(options);
|
||||
@@ -27,7 +28,22 @@ return '<div class="ps-toolbar-close"><div class="ps-toolbar-content"></div></di
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myPhotoSwipe.addEventHandler(PhotoSwipe.EventTypes.onDisplayImage, function(e) {
|
||||
var currentImage = myPhotoSwipe.getCurrentImage();
|
||||
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: 'ws.php?format=json&method=smartpocket.images.logHistory',
|
||||
data: {
|
||||
image_id:currentImage.metaData.image_id,
|
||||
cat_id:jQuery("ul.thumbnails").data("cat_id"),
|
||||
section:jQuery("ul.thumbnails").data("section"),
|
||||
tags_string:jQuery("ul.thumbnails").data("tags_string"),
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var spThumbs = new SPThumbs(SPThumbsOpts);
|
||||
});
|
||||
}(window, window.jQuery, window.Code.PhotoSwipe));
|
||||
|
||||
|
||||
@@ -18,13 +18,19 @@ var SPThumbsOpts ={ hMargin:{$hmargin},rowHeight:{$row_height}};
|
||||
.thumbnails LI{ margin-left:{$hmargin}px; margin-bottom:{$vmargin}px}
|
||||
.thumbnails { margin:0 {$container_margin}px 0 {$container_margin-$hmargin}px}
|
||||
{/html_style}
|
||||
<ul class="thumbnails">
|
||||
{strip}
|
||||
<ul class="thumbnails"
|
||||
{if !empty($smartpocket_log_history.cat_id)}data-cat_id="{$smartpocket_log_history.cat_id}"{/if}
|
||||
{if !empty($smartpocket_log_history.section)}data-section="{$smartpocket_log_history.section}"{/if}
|
||||
{if !empty($smartpocket_log_history.tags_string)}data-tags_string="{$smartpocket_log_history.tags_string}"{/if}
|
||||
>
|
||||
{/strip}
|
||||
{foreach from=$thumbnails item=thumbnail}{strip}
|
||||
{$derivative=$thumb_picker->pick($thumbnail.src_image)}
|
||||
{if isset($page_selection[$thumbnail.id])}
|
||||
<li class="liVisible">
|
||||
{if !isset($thumbnail.representative_ext)}
|
||||
<a href="{$pwg->derivative_url($picture_derivative_params, $thumbnail.src_image)}" data-picture-url="{$thumbnail.URL}" rel="external">
|
||||
<a href="{$pwg->derivative_url($picture_derivative_params, $thumbnail.src_image)}" data-picture-url="{$thumbnail.URL}" data-image-id="{$thumbnail.id}" rel="external">
|
||||
{else}
|
||||
<a href="{$thumbnail.URL}" target="_blank" onClick="window.location='{$thumbnail.URL}'">
|
||||
{/if}
|
||||
@@ -37,3 +43,4 @@ var SPThumbsOpts ={ hMargin:{$hmargin},rowHeight:{$row_height}};
|
||||
{/strip}{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
{debug}
|
||||
|
||||
@@ -103,6 +103,60 @@ if (!empty($_COOKIE['screen_size']))
|
||||
$this->assign('picture_derivative_params', ImageStdParams::get_by_type($type));
|
||||
$this->assign('thumbnail_derivative_params', ImageStdParams::get_by_type(IMG_SQUARE));
|
||||
|
||||
add_event_handler('loc_end_section_init', 'sp_end_section_init');
|
||||
function sp_end_section_init()
|
||||
{
|
||||
global $page, $template;
|
||||
|
||||
// variables to log history
|
||||
$template->assign(
|
||||
'smartpocket_log_history',
|
||||
array(
|
||||
'cat_id' => @$page['category']['id'],
|
||||
'section' => @$page['section'],
|
||||
'tags_string' => @implode(',', @$page['tag_ids']),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_event_handler('ws_add_methods', 'sp_add_methods');
|
||||
function sp_add_methods($arr)
|
||||
{
|
||||
$service = &$arr[0];
|
||||
$service->addMethod(
|
||||
'smartpocket.images.logHistory',
|
||||
'ws_sp_log_history',
|
||||
array(
|
||||
'image_id' => array('type'=>WS_TYPE_ID),
|
||||
'cat_id' => array('type'=>WS_TYPE_ID, 'default'=>null),
|
||||
'section' => array('default'=>null),
|
||||
'tags_string' => array('default'=>null),
|
||||
),
|
||||
'Log visit in history'
|
||||
);
|
||||
}
|
||||
|
||||
function ws_sp_log_history($params, &$service)
|
||||
{
|
||||
global $logger, $page;
|
||||
|
||||
if (!empty($params['section']) and in_array($params['section'], get_enums(HISTORY_TABLE, 'section')))
|
||||
{
|
||||
$page['section'] = $params['section'];
|
||||
}
|
||||
|
||||
if (!empty($params['cat_id']))
|
||||
{
|
||||
$page['category'] = array('id' => $params['cat_id']);
|
||||
}
|
||||
|
||||
if (!empty($params['tags_string']) and preg_match('/^\d+(,\d+)*$/', $params['tags_string']))
|
||||
{
|
||||
$page['tag_ids'] = explode(',', $params['tags_string']);
|
||||
}
|
||||
|
||||
pwg_log($params['image_id'], 'picture');
|
||||
}
|
||||
//------------------------------------------------------------- mobile version & theme config
|
||||
add_event_handler('init', 'mobile_link');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user