-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fecccdd
commit 109abe5
Showing
6 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2014 Laposa Ltd (http://laposa.co.uk) | ||
* Licensed under the New BSD License. See the file LICENSE.txt for details. | ||
*/ | ||
|
||
require_once 'lib/phpFlickr/phpFlickr.php'; | ||
|
||
class Onxshop_Controller_Component_Flickr extends Onxshop_Controller | ||
{ | ||
|
||
/** | ||
* main action | ||
*/ | ||
|
||
public function mainAction() | ||
{ | ||
return true; | ||
|
||
} | ||
|
||
public function init() | ||
{ | ||
$this->flickr = new phpFlickr(ONXSHOP_FLICKR_API_KEY); | ||
$this->flickr->enableCache("fs", ONXSHOP_PROJECT_DIR . "var/cache"); | ||
} | ||
|
||
public function getUserIdByUserName($username) | ||
{ | ||
$response = $this->flickr->people_findByUsername($username); | ||
if ($response === false) msg($this->flickr->getErrorMsg(), 'error', 1); | ||
return $response['id']; | ||
} | ||
|
||
public function getPhotoSizes($photo_id) | ||
{ | ||
$response = $this->flickr->photos_getSizes($photo_id); | ||
if ($response === false) msg($this->flickr->getErrorMsg(), 'error', 1); | ||
return $response['id']; | ||
} | ||
|
||
public function getGalleryList($user_id, $per_page = null, $page = null) | ||
{ | ||
$response = $this->flickr->galleries_getList($user_id, $per_page, $page); | ||
if ($response === false) msg($this->flickr->getErrorMsg(), 'error', 1); | ||
return $response; | ||
} | ||
|
||
public function getPhotosetList($user_id, $page = null, $per_page = null, $primary_photo_extras = null) | ||
{ | ||
$response = $this->flickr->photosets_getList($user_id, $page, $per_page, $primary_photo_extras); | ||
if ($response === false) msg($this->flickr->getErrorMsg(), 'error', 1); | ||
return $response; | ||
} | ||
|
||
public function getPhotoset($photoset_id, $extras = null, $privacy_filter = null, $per_page = null, $page = null, $media = 'photos') | ||
{ | ||
$response = $this->flickr->photosets_getPhotos($photoset_id, $extras, $privacy_filter, $per_page, $page, $media); | ||
if ($response === false) msg($this->flickr->getErrorMsg(), 'error', 1); | ||
return $response; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2014 Laposa Ltd (http://laposa.co.uk) | ||
* Licensed under the New BSD License. See the file LICENSE.txt for details. | ||
*/ | ||
|
||
require_once 'controllers/component/flickr.php'; | ||
|
||
class Onxshop_Controller_Component_Flickr_Photoset_Detail extends Onxshop_Controller_Component_Flickr | ||
{ | ||
|
||
/** | ||
* main action | ||
*/ | ||
|
||
public function mainAction() { | ||
|
||
$this->init(); | ||
|
||
$photoset_id = $this->GET['photoset_id']; | ||
|
||
$list = $this->getPhotoset($photoset_id); | ||
|
||
foreach ($list['photoset']['photo'] as $item) { | ||
$this->tpl->assign('ITEM', $item); | ||
$this->tpl->parse('content.item'); | ||
} | ||
|
||
return true; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* Copyright (c) 2014 Laposa Ltd (http://laposa.co.uk) | ||
* Licensed under the New BSD License. See the file LICENSE.txt for details. | ||
*/ | ||
|
||
require_once 'controllers/component/flickr.php'; | ||
|
||
class Onxshop_Controller_Component_Flickr_Photoset_List extends Onxshop_Controller_Component_Flickr | ||
{ | ||
|
||
/** | ||
* main action | ||
*/ | ||
|
||
public function mainAction() { | ||
|
||
$this->init(); | ||
|
||
$user_id = $this->getUserIdByUserName($this->GET['username']); | ||
|
||
if (is_numeric($this->GET['limit_per_page'])) $limit_per_page = $this->GET['limit_per_page']; | ||
else $limit_per_page = 9; | ||
|
||
if (is_numeric($this->GET['limit_from'])) $limit_from = floor($this->GET['limit_from'] / $limit_per_page) + 1; | ||
else $limit_from = 1; | ||
|
||
$list = $this->getPhotosetList($user_id, $limit_from, $limit_per_page); | ||
|
||
if (is_array($list)) { | ||
foreach ($list['photoset'] as $item) { | ||
$this->tpl->assign('ITEM', $item); | ||
$this->tpl->parse('content.item'); | ||
} | ||
if ($list['pages'] > $limit_from && $limit_per_page == 9) { | ||
$this->tpl->assign('NEXT_PAGE', $limit_from * $limit_per_page); | ||
$this->tpl->parse('content.more'); | ||
} | ||
} | ||
|
||
return true; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!-- BEGIN: content --> | ||
<div class="flick_gallery_detail" id="flick_gallery_list_{GET.id}"> | ||
|
||
<!-- BEGIN: item --> | ||
<div class="item"> | ||
<span class="image"><img src="https://farm{ITEM.farm}.staticflickr.com/{ITEM.server}/{ITEM.id}_{ITEM.secret}_c.jpg" alt="{ITEM.title._content}"/></span> | ||
<p>{ITEM.title._content}</p> | ||
</div> | ||
<!-- END: item --> | ||
|
||
</div> | ||
<!-- END: content --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<!-- BEGIN: head --> | ||
<script type="text/javascript" src="/share/js/jquery/plugins/jquery.cycle.all.min.js"></script> | ||
<!-- END: head --> | ||
<!-- BEGIN: content --> | ||
<div class="flick_gallery_list" id="flick_gallery_list_{GET.id}"> | ||
|
||
<!-- BEGIN: item --> | ||
<div class="item" data-photoset-id="{ITEM.id}"> | ||
<a href="#photoset_id_{ITEM.id}" class="image"><span class="imageWrap"><img src="https://farm{ITEM.farm}.staticflickr.com/{ITEM.server}/{ITEM.primary}_{ITEM.secret}_n.jpg" alt="{ITEM.title._content}"/></span></a> | ||
<div class="meta"> | ||
<div class="date">{ITEM.date_update|date("jS M, Y", %s)}</div> | ||
<h4>{ITEM.title._content}</h4> | ||
<p>{ITEM.description._content|character_limiter(%s, 100)}</p> | ||
</div> | ||
<div class="bottom"></div> | ||
<br/> | ||
</div> | ||
<!-- END: item --> | ||
|
||
<!-- BEGIN: more --> | ||
<div class="more"> | ||
<a href="?limit_from={NEXT_PAGE}" class="buttonLink"><span>Older Posts</span></a> | ||
</div> | ||
<!-- END: more --> | ||
|
||
<div class="bottom"></div> | ||
|
||
<script type="text/javascript"> | ||
|
||
function loadGallery(photoset_id, element) { | ||
|
||
$('#galleryWrapper').remove(); | ||
|
||
var shareButtons = '<div class="socialShareButtons"><a href="#" class="socialIcon facebook">Share On <span>Facebook</span></a>' + | ||
'<a href="#" class="socialIcon twitter">Share On <span>Twitter</span></a></div>'; | ||
|
||
$(document.body).append('<div id="galleryWrapper" style="dispay: none;">' + | ||
'<div id="galleryContent">' + | ||
'<a id="galleryClose" href="#">X</a>' + | ||
'<div id="galleryTitle">' + element.find(".meta").html() + '</div>' + | ||
'<div id="galleryImages"></div>' + | ||
shareButtons + | ||
'</div>' + | ||
'</div>'); | ||
|
||
$('#galleryImages').load('/request/component/flickr_photoset_detail?photoset_id=' + photoset_id, function() { | ||
$('#galleryWrapper').fadeIn(300); | ||
|
||
$('#galleryContent').append('<div class="buttons"><a href="#" class="prev"><</a><a href="#" class="next">></a></div>'); | ||
|
||
$('#galleryImages > .flick_gallery_detail').cycle({ | ||
fx: 'fade', | ||
fit: true, | ||
width: Math.min(670, window.innerWidth), | ||
height: Math.min(435, window.innerHeight), | ||
timeout: 0, | ||
next: '#galleryWrapper a.next', | ||
prev: '#galleryWrapper a.prev', | ||
log: false | ||
}); | ||
|
||
$('#galleryWrapper, #galleryClose').click(function(e) { | ||
if (e.target.id == 'galleryWrapper' || e.target.id == 'galleryClose') { | ||
$('#galleryWrapper').remove(); | ||
return false; | ||
} | ||
}); | ||
|
||
window.location.hash = '#photoset_id_' + photoset_id; | ||
|
||
$("#galleryWrapper div.socialShareButtons a.facebook").click(function() { | ||
nOpenWin('http://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(window.location.href), 400, 300); | ||
return false; | ||
}); | ||
|
||
$("#galleryWrapper div.socialShareButtons a.twitter").click(function() { | ||
nOpenWin('https://twitter.com/share?url=' + encodeURIComponent(window.location.href), 400, 300); | ||
return false; | ||
}); | ||
|
||
}); | ||
|
||
} | ||
|
||
$(function() { | ||
|
||
// load overlay gallery on click | ||
$('#flick_gallery_list_{GET.id} .item').click(function() { | ||
var photoset_id = $(this).attr("data-photoset-id"); | ||
loadGallery(photoset_id, $(this)); | ||
return false; | ||
}); | ||
|
||
// load overlay gallery from url | ||
if (window.location.hash.substr(0, 13) == '#photoset_id_') { | ||
var found = window.location.hash.match(/#photoset_id_(\d+)/); | ||
var item = $('#flick_gallery_list_{GET.id} .item a[href="' + window.location.hash + '"]').parent(); | ||
if (item.length == 1) loadGallery(found[1], item); | ||
} | ||
}); | ||
|
||
</script> | ||
</div> | ||
|
||
<!-- END: content --> |