upgrade lightbox + add thumbnails
This commit is contained in:
35
inc/spot.php
35
inc/spot.php
@@ -18,6 +18,10 @@ class Spot extends Main
|
||||
const SPOT_TABLE = 'spots';
|
||||
const POST_TABLE = 'posts';
|
||||
|
||||
//Picture folders
|
||||
const PIC_FOLDER = 'files/';
|
||||
const THUMB_FOLDER = self::PIC_FOLDER.'thumbs/';
|
||||
|
||||
const FORMAT_TIME = 'd/m/Y à H:i';
|
||||
|
||||
const FEED_CHUNK_SIZE = 15;
|
||||
@@ -150,15 +154,13 @@ class Spot extends Main
|
||||
|
||||
public function getMessages($sRefFeedId=self::FEED_ID)
|
||||
{
|
||||
//Adding another point to test
|
||||
/*
|
||||
/* Adding another point to test
|
||||
$test = $this->oDb->selectRow(self::MSG_TABLE, 1);
|
||||
unset($test['id_message']);
|
||||
$test['ref_msg_id'] = $test['ref_msg_id'] + 1;
|
||||
$test['latitude'] = '-41.4395';
|
||||
$test['longitude'] = '172.1936';
|
||||
$this->oDb->insertUpdateRow(self::MSG_TABLE, $test, array('ref_msg_id'));
|
||||
*/
|
||||
$this->oDb->insertUpdateRow(self::MSG_TABLE, $test, array('ref_msg_id')); */
|
||||
|
||||
//Check last message & update feed if necessary (max once a day)
|
||||
$sLastMsg = $this->oDb->selectValue(self::FEED_TABLE, 'led', array('ref_feed_id'=>$sRefFeedId));
|
||||
@@ -194,7 +196,7 @@ class Spot extends Main
|
||||
|
||||
private function getPictures()
|
||||
{
|
||||
$asPicPaths = glob('files/*.{jpg,JPG,jpeg,JPEG,png,PNG}', GLOB_BRACE);
|
||||
$asPicPaths = glob(self::PIC_FOLDER.'*.{jpg,JPG,jpeg,JPEG,png,PNG}', GLOB_BRACE);
|
||||
|
||||
$asPics = array();
|
||||
foreach($asPicPaths as $sPicPath)
|
||||
@@ -203,12 +205,16 @@ class Spot extends Main
|
||||
$asPicInfo = self::getPicInfo($sPicPath);
|
||||
$iPicTimeStamp = $asPicInfo['timestamp'];
|
||||
|
||||
//Preparing pictures sorting key and related info
|
||||
//Get/Create thumbnail
|
||||
$sThumbnailPath = self::getPicThumbnail($sPicPath);
|
||||
|
||||
//Filter on valid time interval (Histo mode only)
|
||||
if( Settings::MODE != self::MODE_HISTO ||
|
||||
($iPicTimeStamp >= strtotime(Settings::HISTO_SPAN['from']) && $iPicTimeStamp <= strtotime(Settings::HISTO_SPAN['to']))) {
|
||||
$iPicTimeStamp >= strtotime(Settings::HISTO_SPAN['from']) && $iPicTimeStamp <= strtotime(Settings::HISTO_SPAN['to'])) {
|
||||
|
||||
$asPics[] = array(
|
||||
'path' => $sPicPath,
|
||||
'thumb_path' => $sThumbnailPath,
|
||||
'rotate' => $asPicInfo['rotate'],
|
||||
'timestamp' => $iPicTimeStamp,
|
||||
'formatted_time'=> date(self::FORMAT_TIME, $iPicTimeStamp),
|
||||
@@ -331,11 +337,22 @@ class Spot extends Main
|
||||
|
||||
return array(
|
||||
'timestamp' => $iPicTimeStamp,
|
||||
'taken_ts' => $iPicTimeStamp,
|
||||
'file_ts' => $iPicTimeStamp,
|
||||
'taken_ts' => $iPicTakenTimeStamp,
|
||||
'file_ts' => $iPicFileTimeStamp,
|
||||
'rotate' => $sRotate
|
||||
);
|
||||
}
|
||||
|
||||
public static function getPicThumbnail($sPicPath)
|
||||
{
|
||||
$sPicName = pathinfo($sPicPath, PATHINFO_BASENAME);
|
||||
$sThumbPath = self::THUMB_FOLDER.$sPicName;
|
||||
|
||||
if(!file_exists($sThumbPath)) $asThumbInfo = ToolBox::createThumbnail($sPicPath, 400, 0, $sThumbPath/*, false, array('jpg', 'jpeg', 'gif', 'png'), true*/);
|
||||
else $asThumbInfo = array('error'=>'', 'out'=>$sThumbPath);
|
||||
|
||||
return ($asThumbInfo['error']=='')?$asThumbInfo['out']:$sPicPath;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user