Gestione immagine locandina negli eventi

This commit is contained in:
gine 2017-11-10 13:58:51 +01:00
parent 39d5e46bbf
commit 1920be90e4
4 changed files with 23 additions and 5 deletions

View file

@ -54,11 +54,12 @@ EVENTS.getDataAndLoad = function (type) {
var evDesc = ai1ec.event.getDescription(event);
var evUrl = ai1ec.event.getUrl(event);
var evGeo = ai1ec.event.getGeo(event);
var evImg = ai1ec.event.getImage(event);
var evInitDate = EVENTS.formatDate(ai1ec.event.getInitDate(event), EVENTS.storeDateFormat);
var evEndDate = EVENTS.formatDate(ai1ec.event.getEndDate(event), EVENTS.storeDateFormat);
FONTE.dbHandler.executeSql('INSERT INTO ' + table + ' VALUES (?,?,?,?,?,?,?)', [evId, evTitle, evDesc, evInitDate, evEndDate, evUrl, evGeo],
FONTE.dbHandler.executeSql('INSERT INTO ' + table + ' VALUES (?,?,?,?,?,?,?,?)', [evId, evTitle, evDesc, evInitDate, evEndDate, evUrl, evGeo, evImg],
//onSuccess
function (resultSet) {
n_evs_ins++;

View file

@ -56,10 +56,14 @@ var ai1ec = (function(){
return event.geo || "";
},
//Regole per gli evebti ripetitivi
//Regole per gli eventi ripetitivi
getRule : function(event) {
return event.rrule || "";
},
getImage : function(event){
return event['x-wp-images-url'] || "";
},
};
var getXmlData = function(url, catId, callback) {

View file

@ -300,11 +300,15 @@ function drawEvent(div_title, div_content, resultSet){
var id = val.id;
var title = val.title;
var url = val.url;
var content = val.description;
var content = entityToHtml(val.description);
var geo = val.geo;
var imgUrlThumb = getImageUrl(val.img, 'thumb');
$(div_title).html(title);
$(div_content).html("<small>" + evInitDate +"-" + evEndDate +"</small><p>" + content + "</p>");
var img = imgUrlThumb != "" ? "<a href='" + getImageUrl(val.img, 'large') + "'>" +
"<img src='" + imgUrlThumb + "'/>" +
"</a><br>" : "";
$(div_content).html(img + "<small>" + evInitDate +"-" + evEndDate +"</small><p>" + content + "</p>");
renderShareButton(div_content, title, url, evInitDate + " "+ evEndDate);
}
}
@ -375,7 +379,7 @@ function createDB() {
//FONTE.dbHandler.executeSql('CREATE TABLE IF NOT EXISTS xm24_tags (id INTEGER PRIMARY KEY, title, tag)');
//FONTE.dbHandler.executeSql('CREATE TABLE IF NOT EXISTS xm24_tags_to_posts (id, tagid)');
//FONTE.dbHandler.executeSql('CREATE TABLE IF NOT EXISTS xm24_pages (id INTEGER PRIMARY KEY, title, date, page)');
FONTE.dbHandler.executeSql('CREATE TABLE IF NOT EXISTS xm24_events_single (id INTEGER PRIMARY KEY, title, description, initDate, endDate, url, geo)');
FONTE.dbHandler.executeSql('CREATE TABLE IF NOT EXISTS xm24_events_single (id INTEGER PRIMARY KEY, title, description, initDate, endDate, url, geo, img)');
//FONTE.dbHandler.executeSql('CREATE TABLE IF NOT EXISTS xm24_tags_to_events (id, tagid)');
//FONTE.dbHandler.executeSql('CREATE TABLE IF NOT EXISTS xm24_events_repeat (id INTEGER PRIMARY KEY, title, description, initDate, endDate, url, geo)');
}, function () {

View file

@ -59,6 +59,15 @@ function entityToHtml(string) {
return string;
}
function getImageUrl(str, dim) {
var sstr = str.split(";");
for(var i = 0; i < sstr.length; i++) {
if(sstr[i].indexOf(dim) > -1){
return sstr[i +1];
}
}
}
var entity_table = {
// 34: "&quot;", // Quotation mark. Not required
38: "&amp;", // Ampersand. Applied before everything else in the application