Nice plugin! However it is really best to not place non Zenphoto files within the Zenphoto folders. A plugin can add itself to the Utilities buttons. Use the `admin_utilities_buttons` filter. See the rating, sitemap-extended, and static_html_cache plugins for examples.
Also it would be nice if the handling of the root index.php script could be automated. I don't have a suggestion at the moment on how, but it would be nice.
Maybe we could add a filter to the root index.php or on the theme side? Then it could be redirected to a "closed for maintainance" replacement page (probably a static html page or whatever).
My first idea is not touch at the zenphoto index.php. Because, by rewriting this script, it's possible to making many errors or dysfunctions. and "help me, my gallery is not function !".
And, i search to write file 'close' at the root ... but not permit ! (when script 'close_for_updating.php' is include to /utilities).
@sbillard, ok, i'm going to see the filter, and those examples.
and, if this plugin rename himself the zenphoto script index.php to index_gallery.php ? and put on root the new index.php ?! (when the button close is active...)
the better (perhaps?) is that script rewriting zenphoto index.php and add this instruction @ line 124 for including text or page html:
`
if( CLOSING == 1 ) echo "Gallery Closing for maintain-it" // or include('close_for_updating.html');
An Image would work probably as well but a html page gives more freedom to style the replacement page" (Sorry, haven't looked at the plugin itself yet.)
However I see indeed also no clear sitemap cache buttons as it should appear. Something must have gotten lost with the recent updates I guess. However I see still the clear ratings one.
if (__underconstruction__) { zp_register_filter('load_theme_script', 'under_construction_blocker'); } ` `__underconstruction__` is whatever test you use (Could be an option that the plugin sets.) and `__pluginname__/upgrading.php` is your script.
Here is a simple "under construction" plugin. It assumes an image and simple htm file to display it. These files are in the plugin's folder. ` <?php /* Places site "under construction" * * @package plugins */ $plugin_is_filter = 5; $plugin_description = gettext('Provides an overview button to place site "Under Construction" allowing for orderly upgrades to the site.'); $plugin_author = "Stephen Billard (sbillard)";
function under_construction_button($buttons) { if (isset($_GET['construction'])) { XSRFdefender('construction'); if ($_GET['construction']=='under') { setOption('under_construction_blocked',1); copy(dirname(__FILE__).'/under_construction/ug.png',SERVERPATH.'/ug.png'); copy(dirname(__FILE__).'/under_construction/upgrading.htm',SERVERPATH.'/index.htm'); } else { setOption('under_construction_blocked',0); @unlink(SERVERPATH.'/ug.png'); @unlink(SERVERPATH.'/index.htm'); } } if (getOption('under_construction_blocked')) { $buttons[] = array( 'enable'=>true, 'button_text'=>gettext('Under Construction'), 'formname'=>'under_construction_button', 'action'=>'?construction=done', 'icon'=>'images/lock_open.png', 'title'=>gettext('Set site to normal'), 'alt'=>'', 'hidden'=> '', 'rights'=> ADMIN_RIGHTS, 'XSRFTag' => 'construction'); } else { $buttons[] = array( 'enable'=>true, 'button_text'=>gettext('Under Construction'), 'formname'=>'under_construction_button', 'action'=>'?construction=under', 'icon'=>'images/lock_2.png', 'title'=>gettext('Set site to Under Construction'), 'alt'=>'', 'hidden'=> '', 'rights'=> ADMIN_RIGHTS, 'XSRFTag' => 'construction'); } return $buttons; }
That above code was quickly concocted. Here is a better version ` <?php /* Places site "under construction" * * @package plugins */ $plugin_is_filter = 5; $plugin_description = gettext('Provides an overview button to place site "Under Construction" allowing for orderly upgrades to the site.'); $plugin_author = "Stephen Billard (sbillard)";
function under_construction_button($buttons) { if (isset($_GET['construction'])) { XSRFdefender('construction'); if ($_GET['construction']=='under') { setOption('under_construction_blocked',1); } else { setOption('under_construction_blocked',0); } } if (getOption('under_construction_blocked')) { $buttons[] = array( 'enable'=>true, 'button_text'=>gettext('Under Construction'), 'formname'=>'under_construction_button', 'action'=>'?construction=done', 'icon'=>'images/lock_open.png', 'title'=>gettext('Set site to normal'), 'alt'=>'', 'hidden'=> '', 'rights'=> ADMIN_RIGHTS, 'XSRFTag' => 'construction' ); } else { $buttons[] = array( 'enable'=>true, 'button_text'=>gettext('Under Construction'), 'formname'=>'under_construction_button', 'action'=>'?construction=under', 'icon'=>'images/lock_2.png', 'title'=>gettext('Set site to Under Construction'), 'alt'=>'', 'hidden'=> '', 'rights'=> ADMIN_RIGHTS, 'XSRFTag' => 'construction' ); } return $buttons; }
Comments
Also it would be nice if the handling of the root index.php script could be automated. I don't have a suggestion at the moment on how, but it would be nice.
My first idea is not touch at the zenphoto index.php.
Because, by rewriting this script, it's possible to making many errors or dysfunctions. and "help me, my gallery is not function !".
And, i search to write file 'close' at the root ... but not permit ! (when script 'close_for_updating.php' is include to /utilities).
@sbillard, ok, i'm going to see the filter, and those examples.
[french] Rahhhh.
Merci de vos réactions, je les apprécie vraiment (j'avoue, j'avais un peu peur de vos possibles réactions négatives).
Ma première idée était de ne pas toucher au script 'index.php' de la galerie zenphoto. Parce que réécrire celui-ci, pour la plupart des utilisateurs, est une source d'erreurs et de dysfonctionnement. Et, ainsi, pour éviter les "au-secours, ma galerie ne fonctionne plus".
J'ai essayé d'écrire le fichier 'close' à la racine de la galerie ... mais dans le contexte, où le script 'close_for_updating.php' est dans le répertoire /utilities, cela n'est pas permis.
(when the button close is active...)
the better (perhaps?) is that script rewriting zenphoto index.php and add this instruction @ line 124 for including text or page html:
`
if( CLOSING == 1 ) echo "Gallery Closing for maintain-it" // or include('close_for_updating.html');
else include(internalToFilesystem($_zp_obj));
`
i question if my image, on the actual plugin, is good?
(you can viewing this on the dev page ... ;-) )
I active plugins sitemap_extend, rating ... but not have buttons on section 'utilities'?!
However I see indeed also no clear sitemap cache buttons as it should appear. Something must have gotten lost with the recent updates I guess. However I see still the clear ratings one.
Act as plugin (@sbillard: ;-) )
http://zenphoto.dev.stephane-huc.net/pages/closeforupdating-administration-plugin-en-
http://zenphoto.dev.stephane-huc.net/pages/closeforupdating-administration-plugin-fr-
This filter could intercept the page loading and if the gallery is closed, do the appropriate thing.
you have a mechanism to close gallery?!
For instance:
`
function under_construction_blocker() {
header("Location: " . FULLWEBPATH . "/" . USER_PLUGIN_FOLDER . "/__pluginname__/upgrading.php");
exit();
}
if (__underconstruction__) {
zp_register_filter('load_theme_script', 'under_construction_blocker');
}
`
`__underconstruction__` is whatever test you use (Could be an option that the plugin sets.) and `__pluginname__/upgrading.php` is your script.
Here is a simple "under construction" plugin. It assumes an image and simple htm file to display it. These files are in the plugin's folder.
`
<?php
/* Places site "under construction"
*
* @package plugins
*/
$plugin_is_filter = 5;
$plugin_description = gettext('Provides an overview button to place site "Under Construction" allowing for orderly upgrades to the site.');
$plugin_author = "Stephen Billard (sbillard)";
function under_construction_button($buttons) {
if (isset($_GET['construction'])) {
XSRFdefender('construction');
if ($_GET['construction']=='under') {
setOption('under_construction_blocked',1);
copy(dirname(__FILE__).'/under_construction/ug.png',SERVERPATH.'/ug.png');
copy(dirname(__FILE__).'/under_construction/upgrading.htm',SERVERPATH.'/index.htm');
} else {
setOption('under_construction_blocked',0);
@unlink(SERVERPATH.'/ug.png');
@unlink(SERVERPATH.'/index.htm');
}
}
if (getOption('under_construction_blocked')) {
$buttons[] = array( 'enable'=>true,
'button_text'=>gettext('Under Construction'),
'formname'=>'under_construction_button',
'action'=>'?construction=done',
'icon'=>'images/lock_open.png',
'title'=>gettext('Set site to normal'),
'alt'=>'',
'hidden'=> '',
'rights'=> ADMIN_RIGHTS,
'XSRFTag' => 'construction');
} else {
$buttons[] = array(
'enable'=>true,
'button_text'=>gettext('Under Construction'),
'formname'=>'under_construction_button',
'action'=>'?construction=under',
'icon'=>'images/lock_2.png',
'title'=>gettext('Set site to Under Construction'),
'alt'=>'',
'hidden'=> '',
'rights'=> ADMIN_RIGHTS,
'XSRFTag' => 'construction');
}
return $buttons;
}
function under_construction_blocker() {
header("Location: " . FULLWEBPATH . "/" . USER_PLUGIN_FOLDER . "/under_construction/upgrading.htm");
exit();
}
zp_register_filter('admin_utilities_buttons', 'under_construction_button');
if (!zp_loggedin(ADMIN_RIGHTS) && getOption('under_construction_blocked')) {
zp_register_filter('load_theme_script', 'under_construction_blocker');
}
?>
`
"j'apprécie
`
<?php
/* Places site "under construction"
*
* @package plugins
*/
$plugin_is_filter = 5;
$plugin_description = gettext('Provides an overview button to place site "Under Construction" allowing for orderly upgrades to the site.');
$plugin_author = "Stephen Billard (sbillard)";
function under_construction_button($buttons) {
if (isset($_GET['construction'])) {
XSRFdefender('construction');
if ($_GET['construction']=='under') {
setOption('under_construction_blocked',1);
} else {
setOption('under_construction_blocked',0);
}
}
if (getOption('under_construction_blocked')) {
$buttons[] = array(
'enable'=>true,
'button_text'=>gettext('Under Construction'),
'formname'=>'under_construction_button',
'action'=>'?construction=done',
'icon'=>'images/lock_open.png',
'title'=>gettext('Set site to normal'),
'alt'=>'',
'hidden'=> '',
'rights'=> ADMIN_RIGHTS,
'XSRFTag' => 'construction'
);
} else {
$buttons[] = array(
'enable'=>true,
'button_text'=>gettext('Under Construction'),
'formname'=>'under_construction_button',
'action'=>'?construction=under',
'icon'=>'images/lock_2.png',
'title'=>gettext('Set site to Under Construction'),
'alt'=>'',
'hidden'=> '',
'rights'=> ADMIN_RIGHTS,
'XSRFTag' => 'construction'
);
}
return $buttons;
}
function under_construction_blocker($file) {
if (!zp_loggedin(ADMIN_RIGHTS) && getOption('under_construction_blocked')) {
header("Location: " . FULLWEBPATH . "/" . USER_PLUGIN_FOLDER . "/under_construction/upgrading.htm");
exit();
}
return($file);
}
zp_register_filter('admin_utilities_buttons', 'under_construction_button');
zp_register_filter('load_theme_script', 'under_construction_blocker');
?>
`
new version out!! v0.3.
Please, deleting all oldiers files before updating ;-)
all explain :
http://zenphoto.dev.stephane-huc.net/pages/closeforupdating-administration-plugin-en-
http://zenphoto.dev.stephane-huc.net/pages/closeforupdating-administration-plugin-fr-
Thank you a lot for this plugin. I was my self thinking about something like that.
If you like, I could help you. I would be nice if the sentence on the maintenance page could be personnalized.
[French]
Merci beaucoup Hucste!
J'avais moi-même pensé à développé un plug-in qui ai cette fonctionnalité. Il semblerait que tu m'aie devancé.
Je n'ai pas encore essayé ton plug-in. Je le ferais lors de la prochaine mise à jour.
Si tu le souhaite je peux t'aider. Ce qui serait bien, c'est de pouvoir personnaliser le texte de la page de maintenance via une option.
[/French]
@afternoon
Add a capacity to set title and text on section [options] > [extension]...
http://zenphoto.dev.stephane-huc.net/pages/closeforupdating-administration-plugin-en-
http://zenphoto.dev.stephane-huc.net/pages/closeforupdating-administration-plugin-fr-
(i hope that's final cut!
No more access to the plugin ?
Laurent
Thank you
Laurent
i have installed this plugin on my website
unfortunatly, i have this error when i've checked "Set Under Construction" :
Fatal error: Call to undefined function XSRFdefender() in [website]/zenphotoNB/plugins/close_for_updating.php on line 56
what is the problem ?
i have this faal error with 1.3.0