Added image.php to permit fully dynamic image path
authorBenjamin Renard <bn8@zionetrix.net>
Wed, 19 Jun 2013 00:17:39 +0000 (02:17 +0200)
committerBenjamin Renard <bn8@zionetrix.net>
Wed, 19 Jun 2013 00:17:39 +0000 (02:17 +0200)
20 files changed:
public_html/image.php [new file with mode: 0644]
public_html/includes/class/class.LStemplate.php
public_html/includes/js/LSdefault.js
public_html/includes/js/LSformElement_boolean.js
public_html/includes/js/LSformElement_date_field.js
public_html/includes/js/LSformElement_field.js
public_html/includes/js/LSformElement_mail.js
public_html/includes/js/LSformElement_maildir_field.js
public_html/includes/js/LSformElement_password_field.js
public_html/includes/js/LSformElement_postaladdress.js
public_html/includes/js/LSformElement_rss.js
public_html/includes/js/LSformElement_select.js
public_html/includes/js/LSformElement_select_object_field.js
public_html/includes/js/LSformElement_text_field.js
public_html/includes/js/LSformElement_textarea.js
public_html/includes/js/LSformElement_url.js
public_html/includes/js/LSformElement_xmpp.js
public_html/includes/js/LSrelation.js
public_html/includes/js/LSsmoothbox.js
public_html/includes/js/LSview.js

diff --git a/public_html/image.php b/public_html/image.php
new file mode 100644 (file)
index 0000000..eaf01da
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/*******************************************************************************
+ * Copyright (C) 2007 Easter-eggs
+ * http://ldapsaisie.labs.libre-entreprise.org
+ *
+ * Author: See AUTHORS file in top-level directory.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+******************************************************************************/
+
+require_once 'core.php';
+if(LSsession :: startLSsession()) {
+  if (isset($_GET['i'])) {
+    $img_path=LStemplate :: getImagePath($_GET['i']);
+    if (is_file($img_path)) {
+      header('Content-type: '.mime_content_type($img_path));
+      header('Cache-Control: public');
+      header('Pragma: cache');
+      header('Expires: '. gmdate('D, d M Y H:i:s', time() + 60*60*24*30)); // one month
+      readfile($img_path); 
+      exit(); 
+    }
+  }
+  else {
+    die(_('Missing parameter'));
+  }
+}
+
index 2feeae6..2935426 100644 (file)
@@ -271,7 +271,7 @@ function LStemplate_smarty_tr($params) {
 
 function LStemplate_smarty_img($params) {
   extract($params);
-  echo LStemplate :: getImagePath($name);
+  echo "image.php?i=$name";
 }
 
 // Errors
index 8e8e61f..992ea08 100644 (file)
@@ -164,10 +164,10 @@ var LSdefault = new Class({
       this.loading_img_id++;
       this.loading_img[this.loading_img_id] = new Element('img');
       if (size=='big') {
-        var src = this.imagePath('loading.gif');
+        var src = this.imagePath('loading');
       }
       else {
-        var src = this.imagePath('ajax-loader.gif');
+        var src = this.imagePath('ajax-loader');
       }
       this.loading_img[this.loading_img_id].src=src;
       if (position=='inside') {
@@ -211,7 +211,7 @@ var LSdefault = new Class({
     },
     
     imagePath: function(image) {
-      return this.LSjsConfig['LS_IMAGES_DIR'] + '/' + image;
+      return 'image.php?i=' + image;
     },
     
     getParams: function(name) {
index be1d2d4..550a715 100644 (file)
@@ -7,7 +7,7 @@ var LSformElement_boolean = new Class({
       $$('li.LSformElement_boolean').each(function(el) {
         var btn = new Element('img');
         btn.setProperties({
-          src:    varLSdefault.imagePath('clear.png'),
+          src:    varLSdefault.imagePath('clear'),
           alt:    'Clear'
         });
         btn.addClass('btn');
index 99a5198..9250bef 100644 (file)
@@ -38,14 +38,14 @@ var LSformElement_date_field = new Class({
       );
 
       this.nowBtn = new Element('img');
-      this.nowBtn.src = varLSdefault.imagePath('now.png');
+      this.nowBtn.src = varLSdefault.imagePath('now');
       this.nowBtn.addClass('btn');
       this.nowBtn.addEvent('click',this.onNowBtnClick.bind(this));
       this.nowBtn.injectAfter(this.input);
       varLSdefault.addHelpInfo(this.nowBtn,'LSformElement_date','now');
 
       this.todayBtn = new Element('img');
-      this.todayBtn.src = varLSdefault.imagePath('calendar.png');
+      this.todayBtn.src = varLSdefault.imagePath('calendar');
       this.todayBtn.addClass('btn');
       this.todayBtn.addEvent('click',this.onTodayBtnClick.bind(this));
       this.todayBtn.injectAfter(this.nowBtn);
index 82f01df..100c939 100644 (file)
@@ -6,14 +6,14 @@ var LSformElement_field = new Class({
       
       if (this.LSformElement.multiple) {
         this.addFieldBtn = new Element('img');
-        this.addFieldBtn.src = varLSdefault.imagePath('add.png');
+        this.addFieldBtn.src = varLSdefault.imagePath('add');
         this.addFieldBtn.addClass('btn');
         this.addFieldBtn.addEvent('click',this.LSformElement.onAddFieldBtnClick.bind(this.LSformElement,this));
         this.addFieldBtn.injectInside(this.li);
         varLSdefault.addHelpInfo(this.addFieldBtn,'LSform','addFieldBtn');
         
         this.removeFieldBtn = new Element('img');
-        this.removeFieldBtn.src = varLSdefault.imagePath('remove.png');
+        this.removeFieldBtn.src = varLSdefault.imagePath('remove');
         this.removeFieldBtn.addClass('btn');
         this.removeFieldBtn.addEvent('click',this.LSformElement.onRemoveFieldBtnClick.bind(this.LSformElement,this));
         this.removeFieldBtn.injectInside(this.li);
index 6bc3cc5..35678dd 100644 (file)
@@ -26,7 +26,7 @@ var LSformElement_mail = new Class({
     addBtnAfter: function(el) {
       var btn = new Element('img');
       btn.setProperties({
-        src:    varLSdefault.imagePath('mail.png')
+        src:    varLSdefault.imagePath('mail')
       });
       btn.addClass('btn');
       btn.injectAfter(el);
index 45f14ba..d9bbd6a 100644 (file)
@@ -21,12 +21,12 @@ var LSformElement_maildir_field = new Class({
         });
         if (this.params.LSform[varLSform.idform]) {
           this.doInput.value = 1;
-          this.doBtn.src = varLSdefault.imagePath('maildir_do.png');
+          this.doBtn.src = varLSdefault.imagePath('maildir_do');
           varLSdefault.addHelpInfo(this.doBtn,'LSformElement_maildir','do');
         }  
         else {
           this.doInput.value = 0;
-          this.doBtn.src = varLSdefault.imagePath('maildir_nodo.png');
+          this.doBtn.src = varLSdefault.imagePath('maildir_nodo');
           varLSdefault.addHelpInfo(this.doBtn,'LSformElement_maildir','nodo');
         }
         this.doBtn.injectAfter(this.input);
@@ -37,12 +37,12 @@ var LSformElement_maildir_field = new Class({
     onDoBtnClick: function() {
       if (this.doInput.value==0) {
         this.doInput.value = 1;
-        this.doBtn.src = varLSdefault.imagePath('maildir_do.png');
+        this.doBtn.src = varLSdefault.imagePath('maildir_do');
         varLSdefault.setHelpInfo(this.doBtn,'LSformElement_maildir','do');
       }
       else {
         this.doInput.value = 0;
-        this.doBtn.src = varLSdefault.imagePath('maildir_nodo.png');
+        this.doBtn.src = varLSdefault.imagePath('maildir_nodo');
         varLSdefault.setHelpInfo(this.doBtn,'LSformElement_maildir','nodo');
       }
     }
index 59f46a5..6fbeeb6 100644 (file)
@@ -10,7 +10,7 @@ var LSformElement_password_field = new Class({
       // ViewHashBtn
       if (this.params['viewHash'] && varLSform.objectdn!= "") {
         this.viewHashBtn = new Element('img');
-        this.viewHashBtn.src = varLSdefault.imagePath('view_hash.png');
+        this.viewHashBtn.src = varLSdefault.imagePath('view_hash');
         this.viewHashBtn.addClass('btn');
         this.viewHashBtn.addEvent('click',this.onViewHashBtnClick.bind(this));
         this.viewHashBtn.injectAfter(this.input);
@@ -21,7 +21,7 @@ var LSformElement_password_field = new Class({
       if (this.params['mail']) {
         if ((this.params.mail['canEdit']==1)||(!$type(this.params.mail['canEdit']))) {
           this.editMailBtn = new Element('img');
-          this.editMailBtn.src = varLSdefault.imagePath('mail-edit.png');
+          this.editMailBtn.src = varLSdefault.imagePath('mail-edit');
           this.editMailBtn.addClass('btn');
           this.editMailBtn.addEvent('click',this.onEditMailBtnClick.bind(this));
           this.LSmail_open = 0;
@@ -39,12 +39,12 @@ var LSformElement_password_field = new Class({
           });
           if (this.params.mail['send']) {
             this.mailInput.value = 1;
-            this.mailBtn.src = varLSdefault.imagePath('mail.png');
+            this.mailBtn.src = varLSdefault.imagePath('mail');
             varLSdefault.addHelpInfo(this.mailBtn,'LSformElement_password','mail');
           }  
           else {
             this.mailInput.value = 0;
-            this.mailBtn.src = varLSdefault.imagePath('nomail.png');
+            this.mailBtn.src = varLSdefault.imagePath('nomail');
             varLSdefault.addHelpInfo(this.mailBtn,'LSformElement_password','nomail');
           }
           this.mailBtn.injectAfter(this.input);
@@ -54,7 +54,7 @@ var LSformElement_password_field = new Class({
       
       // ViewBtn
       this.viewBtn = new Element('img');
-      this.viewBtn.src = varLSdefault.imagePath('view.png');
+      this.viewBtn.src = varLSdefault.imagePath('view');
       this.viewBtn.addClass('btn');
       this.viewBtn.addEvent('click',this.changeInputType.bind(this));
       this.viewBtn.injectAfter(this.input);
@@ -65,7 +65,7 @@ var LSformElement_password_field = new Class({
         this.bgColor = this.input.getStyle('background-color');
         this.verifyFx = new Fx.Tween(this.input,{property: 'background-color',duration:600});
         this.verifyBtn = new Element('img');
-        this.verifyBtn.src = varLSdefault.imagePath('verify.png');
+        this.verifyBtn.src = varLSdefault.imagePath('verify');
         this.verifyBtn.addClass('btn');
         this.verifyBtn.addEvent('click',this.onVerifyBtnClick.bind(this));
         this.verifyBtn.injectAfter(this.input);
@@ -74,7 +74,7 @@ var LSformElement_password_field = new Class({
       
       if (this.params['generate']) {
         this.generateBtn = new Element('img');
-        this.generateBtn.src = varLSdefault.imagePath('generate.png');
+        this.generateBtn.src = varLSdefault.imagePath('generate');
         this.generateBtn.addClass('btn');
         this.generateBtn.addEvent('click',this.onGenerateBtnClick.bind(this));
         this.generateBtn.injectAfter(this.input);
@@ -94,12 +94,12 @@ var LSformElement_password_field = new Class({
     onMailBtnClick: function() {
       if (this.mailInput.value==0) {
         this.mailInput.value = 1;
-        this.mailBtn.src = varLSdefault.imagePath('mail.png');
+        this.mailBtn.src = varLSdefault.imagePath('mail');
         varLSdefault.setHelpInfo(this.mailBtn,'LSformElement_password','mail');
       }
       else {
         this.mailInput.value = 0;
-        this.mailBtn.src = varLSdefault.imagePath('nomail.png');
+        this.mailBtn.src = varLSdefault.imagePath('nomail');
         varLSdefault.setHelpInfo(this.mailBtn,'LSformElement_password','nomail');
       }
     },
@@ -179,12 +179,12 @@ var LSformElement_password_field = new Class({
       }
       if (this.input.type=='password') {
         var newType = 'text';
-        this.viewBtn.src=varLSdefault.imagePath('hide.png');
+        this.viewBtn.src=varLSdefault.imagePath('hide');
         varLSdefault.setHelpInfo(this.viewBtn,'LSformElement_password','hide');
       }
       else {
         var newType = 'password';
-        this.viewBtn.src=varLSdefault.imagePath('view.png');
+        this.viewBtn.src=varLSdefault.imagePath('view');
         varLSdefault.setHelpInfo(this.viewBtn,'LSformElement_password','view');
       }
       var newInput = new Element('input');
index a2c9f3b..b56cc1d 100644 (file)
@@ -44,7 +44,7 @@ var LSformElement_postaladdress = new Class({
       }
       var btn = new Element('img');
       btn.setProperties({
-        src:    varLSdefault.imagePath('map_go.png'),
+        src:    varLSdefault.imagePath('map_go'),
         alt:    'View on map'
       });
       btn.addClass('btn');
index 3aefe12..0c306b0 100644 (file)
@@ -21,7 +21,7 @@ var LSformElement_rss = new Class({
     addBtnAfter: function(el) {
       var btn = new Element('img');
       btn.setProperties({
-        src:    varLSdefault.imagePath('rss.png'),
+        src:    varLSdefault.imagePath('rss'),
         alt:    'File RSS'
       });
       btn.addClass('btn');
index 729c3fe..a42fc40 100644 (file)
@@ -7,7 +7,7 @@ var LSformElement_select = new Class({
       $$('select.LSformElement_select').each(function(el) {
         var btn = new Element('img');
         btn.setProperties({
-          src:    varLSdefault.imagePath('clear.png'),
+          src:    varLSdefault.imagePath('clear'),
           alt:    'Reset',
           title:  'Reset'
         });
index a4c3805..8b3508f 100644 (file)
@@ -54,7 +54,7 @@ var LSformElement_select_object_field = new Class({
       var btn = new Element('img');
       btn.addClass('btn');
       btn.setProperties({
-        src:    varLSdefault.imagePath('delete.png'),
+        src:    varLSdefault.imagePath('delete'),
         alt:    this.params.deleteBtns
       });
       btn.addEvent('click',this.onDeleteBtnClick.bind(this,btn));
@@ -64,7 +64,7 @@ var LSformElement_select_object_field = new Class({
     
     addSingleAddBtn: function(insideEl) {
       this.addBtn = new Element('img');
-      this.addBtn.setProperty('src',varLSdefault.imagePath('modify.png'));
+      this.addBtn.setProperty('src',varLSdefault.imagePath('modify'));
       this.addBtn.addClass('btn');
       this.addBtn.addEvent('click',this.onAddBtnClick.bindWithEvent(this));
       this.addBtn.injectInside(insideEl);
@@ -73,7 +73,7 @@ var LSformElement_select_object_field = new Class({
     
     addSearchAddBtn: function() {
       this.searchAddBtn = new Element('img');
-      this.searchAddBtn.setProperty('src',varLSdefault.imagePath('add.png'));
+      this.searchAddBtn.setProperty('src',varLSdefault.imagePath('add'));
       this.searchAddBtn.addClass('btn');
       this.searchAddBtn.addEvent('click',this.onSearchAddBtnClick.bindWithEvent(this));
       this.searchAddBtn.injectAfter(this.addBtn);
index 946bc83..2021ffc 100644 (file)
@@ -24,7 +24,7 @@ var LSformElement_text_field = new Class({
           // GenerateBtn
           this.generateBtn = new Element('img');
           this.generateBtn.addClass('btn');
-          this.generateBtn.src=varLSdefault.imagePath('generate.png');
+          this.generateBtn.src=varLSdefault.imagePath('generate');
           this.generateBtn.addEvent('click',this.refreshValue.bind(this,true));
           this.generateBtn.injectAfter(this.input);
           varLSdefault.addHelpInfo(this.generateBtn,'LSformElement_text','generate');
index 83a04d4..e3a7dd9 100644 (file)
@@ -13,7 +13,7 @@ var LSformElement_textarea = new Class({
       el.getElements('textarea.LSform').each(function(textarea) {
         var btn = new Element('img');
         btn.addClass('btn');
-        btn.src = varLSdefault.imagePath('clear.png');
+        btn.src = varLSdefault.imagePath('clear');
         btn.addEvent('click',this.onClearBtnClick.bind(this,btn));
         btn.injectAfter(textarea);
         varLSdefault.addHelpInfo(btn,'LSformElement_textarea','clear');
index 210ff86..614fac5 100644 (file)
@@ -21,7 +21,7 @@ var LSformElement_url = new Class({
     addBtnAfter: function(el) {
       var btn_go = new Element('img');
       btn_go.setProperties({
-        src:    varLSdefault.imagePath('url_go.png')
+        src:    varLSdefault.imagePath('url_go')
       });
       btn_go.addClass('btn');
       btn_go.injectAfter(el);
@@ -31,7 +31,7 @@ var LSformElement_url = new Class({
       if (this.isAddFavoriteSupportedBrowser()) {
         var btn_fav = new Element('img');
         btn_fav.setProperties({
-          src:    varLSdefault.imagePath('url_add.png')
+          src:    varLSdefault.imagePath('url_add')
         });
         btn_fav.addClass('btn');
         btn_fav.injectAfter(btn_go);
index 84b6da1..315925c 100644 (file)
@@ -21,7 +21,7 @@ var LSformElement_xmpp = new Class({
     addBtnAfter: function(el) {
       var btn = new Element('img');
       btn.setProperties({
-        src:    varLSdefault.imagePath('xmpp.png'),
+        src:    varLSdefault.imagePath('xmpp'),
         alt:    'Chat'
       });
       btn.addClass('btn');
index daefdb2..1e88275 100644 (file)
@@ -30,7 +30,7 @@ var LSrelation = new Class({
       this.deleteBtnId = 0;
       $$('a.LSrelation_editable').each(function(a) {
         this.deleteBtn[this.deleteBtnId] = new Element('img');
-        this.deleteBtn[this.deleteBtnId].src = varLSdefault.imagePath('delete.png');
+        this.deleteBtn[this.deleteBtnId].src = varLSdefault.imagePath('delete');
         this.deleteBtn[this.deleteBtnId].setStyle('cursor','pointer');
         this.deleteBtn[this.deleteBtnId].addClass('LSrelation-btn');
         this.deleteBtn[this.deleteBtnId].addEvent('click',this.onDeleteBtnClick.bind(this,this.deleteBtn[this.deleteBtnId]));
index 3c2a66d..e76c8ad 100644 (file)
@@ -320,7 +320,7 @@ var LSsmoothbox = new Class({
     load: function() {
       this.frame.empty();
       this.loadingImage = new Element('img');
-      this.loadingImage.setProperty('src',varLSdefault.imagePath('loading.gif'));
+      this.loadingImage.setProperty('src',varLSdefault.imagePath('loading'));
       this.loadingImage.setProperty('id','loadingImage-LSsmoothbox');
       this.openOptions.width = 120;
       this.openOptions.height = 120;
index bb7eb7e..38bd4b4 100644 (file)
@@ -53,7 +53,7 @@ var LSview = new Class({
 
     onTdLSobjectListNamesOver: function(td){
       td.imgEdit = new Element('img');
-      td.imgEdit.src = varLSdefault.imagePath('view.png');
+      td.imgEdit.src = varLSdefault.imagePath('view');
       td.imgEdit.injectInside(td);
     },