diff --git a/images/logo_ugc.png b/images/logo_ugc.png new file mode 100755 index 0000000..2eda1ae Binary files /dev/null and b/images/logo_ugc.png differ diff --git a/inc/functions.php b/inc/functions.php index f9806d5..28e6160 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -25,7 +25,86 @@ function getPage($sPath, $asVars, $bSavePage=false) function setPageMime($sType='html') { - if($sType!='html') header('Content-type: application/'.$sType); + $asMainTypes = array('json'=>'application', 'jpeg'=>'image', 'png'=>'image', 'gif'=>'image'); + if($sType!='html' && array_key_exists($sType, $asMainTypes)) header('Content-type: '.$asMainTypes[$sType].'/'.$sType); +} + +function getTrimImage($iFilmId, $sinPath, $sImageExt) +{ + $sOutPath = 'images/'.$iFilmId.'.'.$sImageExt; + if(!file_exists($sOutPath)) + { + $oImage = call_user_func('imagecreatefrom'.$sImageExt, $sinPath); + $iImageX = imagesx($oImage); + $iImageY = imagesy($oImage); + $iTop = 0; + $iBottom = 0; + $iLeft = 0; + $iRight = 0; + $iWhiteLimit = 220; + + //Top height to crop: + for(; $iTop < $iImageY; ++$iTop) + { + for($x = 0; $x < $iImageX; ++$x) + { + $hColor = imagecolorat($oImage, $x, $iTop); + $iRed = ($hColor >> 16) & 0xFF; + $iGreen = ($hColor >> 8) & 0xFF; + $iBlue = $hColor & 0xFF; + if($iRed<$iWhiteLimit || $iGreen<$iWhiteLimit || $iBlue<$iWhiteLimit) break 2; //out of the 'top' loop + } + } + + //Bottom height to crop + for(; $iBottom < $iImageY; ++$iBottom) + { + for($x = 0; $x < $iImageX; ++$x) + { + $hColor = imagecolorat($oImage, $x, $iImageY - $iBottom - 1); + $iRed = ($hColor >> 16) & 0xFF; + $iGreen = ($hColor >> 8) & 0xFF; + $iBlue = $hColor & 0xFF; + if($iRed<$iWhiteLimit || $iGreen<$iWhiteLimit || $iBlue<$iWhiteLimit) break 2; //out of the 'bottom' loop + } + } + + //Left width to crop + for(; $iLeft < $iImageX; ++$iLeft) + { + for($y = 0; $y < $iImageY; ++$y) + { + $hColor = imagecolorat($oImage, $iLeft, $y); + $iRed = ($hColor >> 16) & 0xFF; + $iGreen = ($hColor >> 8) & 0xFF; + $iBlue = $hColor & 0xFF; + if($iRed<$iWhiteLimit || $iGreen<$iWhiteLimit || $iBlue<$iWhiteLimit) break 2; //out of the 'left' loop + } + } + + //Right width to crop + for(; $iRight < $iImageX; ++$iRight) + { + for($y = 0; $y < $iImageY; ++$y) + { + $hColor = imagecolorat($oImage, $iImageX - $iRight-1, $y); + $iRed = ($hColor >> 16) & 0xFF; + $iGreen = ($hColor >> 8) & 0xFF; + $iBlue = $hColor & 0xFF; + if($iRed<$iWhiteLimit || $iGreen<$iWhiteLimit || $iBlue<$iWhiteLimit) break 2; //out of the 'right' loop + } + } + + //Creating a image with the new height + $oCropImage = imagecreatetruecolor($iImageX-($iLeft+$iRight), $iImageY-($iTop+$iBottom)); + + //Copy the content, excluding the border + imagecopy($oCropImage, $oImage, 0, 0, $iLeft, $iTop, imagesx($oCropImage), imagesy($oCropImage)); + + call_user_func_array('image'.$sImageExt, array($oCropImage, $sOutPath)); + } + + return file_get_contents($sOutPath); } ?> \ No newline at end of file diff --git a/index.php b/index.php index c283a92..72f3ff1 100755 --- a/index.php +++ b/index.php @@ -1,5 +1,8 @@ - @@ -15,7 +14,7 @@ -
+
-
+
+

Filtered films

+
+
\ No newline at end of file diff --git a/script/film.js b/script/film.js index 5cfc38e..fb0b2bc 100755 --- a/script/film.js +++ b/script/film.js @@ -1,7 +1,7 @@ function Film() { var self = this; - this.consts = {'ugc_url':'http://www.ugc.fr/'}; + this.consts = {'ugc_url':'http://www.ugc.fr/', 'process_url':'index.php'}; this._attr = {}; this._anchor = {}; this._ban = {status:false, reason:''}; @@ -36,6 +36,12 @@ function Film() this.poster = function(sPoster) { + if(sPoster) //Set + { + var sExt = sPoster.substr(sPoster.lastIndexOf('.')+1).toLowerCase(); + if(sExt=='jpg') sExt = 'jpeg'; + var sPoster = this.consts.process_url+'?a=get_poster&type='+sExt+'&data[id]='+this.id()+'&data[url]='+encodeURIComponent(sPoster); + } return this.attr('poster', sPoster); }; @@ -68,16 +74,17 @@ function Film() { //Init page this.onPageReady(); - + //Add film to DOM this._anchor = $('
', {'class':'film', 'id':'film_'+this.id()}) + //.append($('', {'class':'bg', 'src':this.poster()})) .append($('', {'class':'poster', 'src':this.poster()})) .append($('
', {'class':'info'}) .append($('

', {'class':'title'}) .append($('', {'class':'name', 'target':'_blank', 'href':this.consts.ugc_url+'film.html?id='+this.id()}) .append($('', {'class':'fa fa-fw fa-icon fa-film'})) .append(this.name())) - .append($('', {'class':'edito'}).text(this.edito()?' ['+this.edito()+']':''))) + .append($('', {'class':'edito'+(this.edito()?' fa fa-edito':'')}).text(this.edito()?' '+this.edito():''))) .append($('

', {'class':'trailer'}) .append($('', {'target':'_blank', 'href':this.trailer()}) .append($('', {'class':'fa fa-fw fa-icon fa-trailer'})) @@ -108,20 +115,24 @@ function Film() this.renderTimetable = function(iCinemaId, asLang) { + var sCinema = asCinemas[iCinemaId]; $.each(asLang, function(iKey, sLang) { - if(sLang=='VF' && ('VOSTF' in self.timetable(iCinemaId))) self.error('Hiding VF version of "'+self.name()+'" (VOSTF available)'); + if(sLang=='VF' && ('VOSTF' in self.timetable(iCinemaId))) self.error('Hiding VF version of "'+self.name()+'" @'+sCinema+' (VOSTF available)'); + else if(sLang=='VFSTF') self.error('Hiding hearing-impaired version ('+sLang+') of "'+self.name()+'" @'+sCinema) else { var $Timetable = $('

') .append($('', {'class':'cinema', 'target':'_blank', 'href':self.consts.ugc_url+'cinemaAction!execute.action?page=7&id='+iCinemaId}) - .append($('', {'class':'fa fa-fw fa-icon fa-cinema'})) - .append(asCinemas[iCinemaId]+' '+sLang)) - .append(' : ') + .append($('', {'class':'fa fa-fw fa-icon fa-cinema'})) + .append($('', {'class':'cinema_name'}).text(sCinema))) + .append($('', {'class':'lang'}).text(sLang)) .appendTo(self.anchor().find('.timetable')); $.each(self.timetable(iCinemaId, sLang).sort(self.timeCompare), function(iKey, oTime){ - $Timetable.append($('', {'class':'time', 'href':oTime.booking, 'target':'_blank'}).text(oTime.time+' ')); + $Timetable + .append($('', {'class':'time', 'href':oTime.booking, 'target':'_blank'}).text(oTime.time)) + .append(' '); //for line break }); } }); @@ -134,7 +145,8 @@ function Film() this.error = function(sMsg) { - $('#feedback').show().append($('

').text(sMsg)); + $('#feedback').show(); + $('#feed_content').append($('

').text(sMsg)); }; } @@ -271,12 +283,13 @@ function Affiche(oDate) this.error = function(sMsg) { - $('#feedback').show().append($('

').text(sMsg)); + $('#feedback').show(); + $('#feed_content').append($('

').text(sMsg)); }; } function getUgcPage(sPath, asData, fOnSuccess, sType) { var asParams = {'a':'get_page', 'type':sType, 'data':{'path':sPath, 'vars':asData}}; - $.get('index.php', asParams, fOnSuccess, sType); + $.get((new Film()).consts.process_url, asParams, fOnSuccess, sType); } \ No newline at end of file diff --git a/style/style.css b/style/style.css index c0ec5d5..f849be2 100755 --- a/style/style.css +++ b/style/style.css @@ -7,28 +7,22 @@ body { padding:1em; font-family: 'Open Sans', sans-serif; font-size: 1em; -} - -header { - margin:1em 0; - font-size: 2em; -} - -footer { - clear:both; - font-size: 0.8em; - margin: 1em 0px; - display: none; + color:#333; + background:#DDD; } a { text-decoration: none; - color:black; + color:#333; } a:hover { color:#08288B; } +h1 { + margin:0 0 1em 0; +} + /* Common Classes */ .fa-icon { @@ -47,7 +41,7 @@ a:hover { content: "\f110"; } .fa-cinema:before { - content: "\f145"; + content: "\f017"; } .fa-date:before { content: "\f133"; @@ -55,11 +49,31 @@ a:hover { .fa-power:before { content: "\f1b0"; } +.fa-edito:before { + content: "\f0e7"; +} +.fa-feedback:before { + content: "\f0b0"; +} /* Sections */ +/* Section - Header */ + +header { + padding:1em 0 1em calc(113px + 0.5em); + background:url(../images/logo_ugc.png) 0 50% no-repeat; + margin:0 0 0 0.5em; + font-size: 2em; + color:#08288B; +} + /* Section - Main */ +main { + margin-top:1em; +} + #buffer { font-size:2em; } @@ -67,19 +81,27 @@ a:hover { /* Section - Film */ .film { - clear:both; + position:relative; background:white; - float:left; margin-bottom:1em; - width:100%; } .film:nth-child(even) { } +.film .bg { + position:absolute; + width:1000%; + opacity:0.3; + z-index: -1; + display:none; +} + .film .info { - margin-left:152px; + position:absolute; + top:0; + left:152px; padding-left:1em; width: calc(100% - 1em - 152px); } @@ -94,11 +116,13 @@ a:hover { .film .title .edito { font-style: italic; + margin-left:1em; + color:#999; } .film img.poster { - vertical-align: middle; - float:left; + width:152px; + display: block; } .film .trailer { @@ -110,8 +134,33 @@ a:hover { font-size: 0.8em; } +.film .timetable p { + line-height: 2.0; + margin: 0; +} + +.film .timetable .cinema { + margin-right:0.5em; +} + +.film .timetable .cinema .fa { + font-size: 1.25em; + line-height: 0.7656249414em; + vertical-align: -14.06250352%; +} + +.film .timetable .lang { + margin-right:0.5em; +} + .film .timetable .time { - + background:#666; + color:white; + padding:0.1em 0.4em; + border-radius:3px; +} +.film .timetable .time:hover { + background:#08288B; } /* Section - Feeback */ @@ -119,11 +168,10 @@ a:hover { #feedback { background:#EEE; padding:1em; - float:left; - clear:both; font-size:0.6em; margin-bottom: 1em; display:none; + color:#999; } #feedback p:FIRST-CHILD { @@ -131,4 +179,13 @@ a:hover { } #feedback p:LAST-CHILD { margin-bottom:0; +} + +/* Section - Footer */ + +footer { + font-size: 0.8em; + margin: 1em 0px; + display: none; + color:#08288B; } \ No newline at end of file