Announcement

  •  » Engine
  •  » turn the "local" directory into a configuration setting

#16 2011-01-17 18:04:59

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13182

Re: turn the "local" directory into a configuration setting

I have made changes and it seems to work fine for language files, database connection settings and configuration settings, but I still have problems with CSS files.

Here are the changes I made:

Code:

$ svn diff include/constants.php include/template.class.php 
Index: include/constants.php
===================================================================
--- include/constants.php       (revision 8719)
+++ include/constants.php       (working copy)
@@ -27,6 +27,7 @@
 define('PHPWG_DEFAULT_TEMPLATE', 'Sylvia');
 
 define('PHPWG_THEMES_PATH', $conf['themes_dir'].'/');
+define('PWG_COMBINED_DIR', PWG_LOCAL_DIR.'combined/');
 
 // Required versions
 define('REQUIRED_PHP_VERSION', '5.0.0');
Index: include/template.class.php
===================================================================
--- include/template.class.php  (revision 8719)
+++ include/template.class.php  (working copy)
@@ -797,13 +797,13 @@
     $css = array();
     foreach ($smarty->get_template_vars('themes') as $theme)
     {
-      $f = 'local/css/'.$theme['id'].'-rules.css';
+      $f = PWG_LOCAL_DIR.'css/'.$theme['id'].'-rules.css';
       if (file_exists(PHPWG_ROOT_PATH.$f))
       {
         array_push($css, "{combine_css path='$f' order=10}");
       }
     }
-    $f = 'local/css/rules.css';
+    $f = PWG_LOCAL_DIR.'css/rules.css';
     if (file_exists(PHPWG_ROOT_PATH.$f))
     {
       array_push($css, "{combine_css path='$f' order=10}");
@@ -1133,7 +1133,7 @@
 /*Allows merging of javascript and css files into a single one.*/
 final class FileCombiner
 {
-  const OUT_SUB_DIR = 'local/combined/';
+  const OUT_SUB_DIR = PWG_COMBINED_DIR;
   private $type; // js or css
   private $files = array();
   private $versions = array();

but:

[pierrick@pierrick-desktop] ~/public_html/piwigo/dev/trunk
$ cat local/combined/uw2xo6.css | grep '^\/\*BEGIN'
/*BEGIN themes/default/theme.css */
/*BEGIN themes/default/print.css */
/*BEGIN themes/clear/theme.css */
/*BEGIN local2/css/clear-rules.css */
/*BEGIN local2/css/rules.css */

the local combined script uses the local2 CSS files :-/


Latest blog post (November 9th 2018) Why Flickr could not remain free for ever

Offline

 

#17 2011-01-17 18:34:50

grum
Piwigo Team
Nantes
2007-09-10
1371

Re: turn the "local" directory into a configuration setting

I'not sure to understand... what are the expected results ?


My pictures with Piwigo, of course !
[ www.grum.fr ] [ photos.grum.fr ]

Offline

 

#18 2011-01-17 18:57:23

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13182

Re: turn the "local" directory into a configuration setting

grum wrote:

I'not sure to understand... what are the expected results ?

[pierrick@pierrick-desktop] ~/public_html/piwigo/dev/trunk
$ cat local/combined/123abc.css | grep '^\/\*BEGIN'
/*BEGIN themes/default/theme.css */
/*BEGIN themes/default/print.css */
/*BEGIN themes/clear/theme.css */
/*BEGIN local/css/clear-rules.css */
/*BEGIN local/css/rules.css */

[pierrick@pierrick-desktop] ~/public_html/piwigo/dev/trunk
$ cat local2/combined/456def.css | grep '^\/\*BEGIN'
/*BEGIN themes/default/theme.css */
/*BEGIN themes/default/print.css */
/*BEGIN themes/clear/theme.css */
/*BEGIN local2/css/clear-rules.css */
/*BEGIN local2/css/rules.css */


Latest blog post (November 9th 2018) Why Flickr could not remain free for ever

Offline

 

#19 2011-01-17 19:06:01

grum
Piwigo Team
Nantes
2007-09-10
1371

Re: turn the "local" directory into a configuration setting

you have to keep the hard coded 'local' lines, something like :

Code:

@@ -797,13 +797,13 @@
     $css = array();
     foreach ($smarty->get_template_vars('themes') as $theme)
     {
      $flocal = 'local/css/'.$theme['id'].'-rules.css';
      $flocal_galery = PWG_LOCAL_DIR.'css/'.$theme['id'].'-rules.css';
       if (file_exists(PHPWG_ROOT_PATH.$flocal))
       {
         array_push($css, "{combine_css path='$flocal' order=10}");
       }

       if (file_exists(PHPWG_ROOT_PATH.$flocal_galery))
       {
         array_push($css, "{combine_css path='$flocal_galery' order=10}");
       }
     }
    $flocal = 'local/css/rules.css';
    $flocal_galery = PWG_LOCAL_DIR.'css/rules.css';

and you will have 2 files :
one in the local directory
another one in the LOCAL_DIR directory


the best way seems to implement a function with one paramete and called twice (with 'local' and LOCAL_DIR as parameter)


My pictures with Piwigo, of course !
[ www.grum.fr ] [ photos.grum.fr ]

Offline

 

#20 2011-01-17 19:17:15

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13182

Re: turn the "local" directory into a configuration setting

That seems to be the way for having a common local + site local, but this is not the problem. The problem is that the site with "local" as local dir should use the local/css/* files and not the local2/css/* files.


Latest blog post (November 9th 2018) Why Flickr could not remain free for ever

Offline

 

#21 2011-01-17 19:48:43

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13182

Re: turn the "local" directory into a configuration setting

I've commited my current code in [Subversion] r8722


Latest blog post (November 9th 2018) Why Flickr could not remain free for ever

Offline

 

#22 2011-01-17 21:38:04

rvelices
Piwigo Team
2005-12-29
1960

Re: turn the "local" directory into a configuration setting

it seems ok to me ...

Offline

 

#23 2011-01-18 01:22:40

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13182

Re: turn the "local" directory into a configuration setting

rvelices wrote:

it seems ok to me ...

You mean you made the test with a local/config/multisite.inc.php with the following code:

Code:

<?php
$conf['local_dir_site'] = 'local2/';
?>

and you didn't see any problem?

(and change again to local3 for example)


Latest blog post (November 9th 2018) Why Flickr could not remain free for ever

Offline

 

#24 2011-01-18 07:00:51

rvelices
Piwigo Team
2005-12-29
1960

Re: turn the "local" directory into a configuration setting

plg wrote:

rvelices wrote:

it seems ok to me ...

You mean you made the test with a local/config/multisite.inc.php with the following code:

Code:

<?php
$conf['local_dir_site'] = 'local2/';
?>

and you didn't see any problem?

(and change again to local3 for example)

no, i didn't make those tests. to be honest i don't get exactly what you are trying to do - it seems to me you are doing more than just replace 'local' with 'local2', otherwise i don't see why it should not work

Offline

 

#25 2011-01-18 11:26:23

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13182

Re: turn the "local" directory into a configuration setting

rvelices wrote:

no, i didn't make those tests. to be honest i don't get exactly what you are trying to do - it seems to me you are doing more than just replace 'local' with 'local2', otherwise i don't see why it should not work

After another investigation, I noticed that the list of CSS files was correct if I purge compiled templates each time I change the $conf['local_dir_site']. If I set $conf['template_force_compile'] = true then it's OK (but it's not a solution).

I suppose the list of CSS files is in the compiled template and that the template "key" is not related to the $conf['local_dir_site'] (of course).

This it not a big deal, since I consider each site should have a distinct _data directory, once you set a distinct $conf['local_data_dir'] for each site, the problem disappears. We will have to make it obvious in the documentation.


Latest blog post (November 9th 2018) Why Flickr could not remain free for ever

Offline

 

#26 2011-01-18 11:43:54

rvelices
Piwigo Team
2005-12-29
1960

Re: turn the "local" directory into a configuration setting

plg wrote:

After another investigation, I noticed that the list of CSS files was correct if I purge compiled templates each time I change the $conf['local_dir_site']. If I set $conf['template_force_compile'] = true then it's OK (but it's not a solution).

I suppose the list of CSS files is in the compiled template and that the template "key" is not related to the $conf['local_dir_site'] (of course).

This it not a big deal, since I consider each site should have a distinct _data directory, once you set a distinct $conf['local_data_dir'] for each site, the problem disappears. We will have to make it obvious in the documentation.

It is normal because the local css is a smarty prefilter. A smarty prefilter is called only when compiling the template. I have asked P@t to use a prefilter so that we don't look at every page hit weather the local css file is there

Offline

 

#27 2011-12-29 10:59:47

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13182

Re: turn the "local" directory into a configuration setting


Latest blog post (November 9th 2018) Why Flickr could not remain free for ever

Offline

 
  •  » Engine
  •  » turn the "local" directory into a configuration setting

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact