Skip to content

Commit

Permalink
feature 264: gallery_url, rate and rate_anonymous from config file to…
Browse files Browse the repository at this point in the history
… database

git-svn-id: http://piwigo.org/svn/trunk@1044 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed Feb 16, 2006
1 parent 2a01c74 commit d22a07c
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 14 deletions.
12 changes: 11 additions & 1 deletion admin/configuration.php
Expand Up @@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
Expand Down Expand Up @@ -60,6 +60,10 @@
{
case 'general' :
{
if ( !url_is_remote($_POST['gallery_url']) )
{
array_push($page['errors'], $lang['conf_gallery_url_error']);
}
break;
}
case 'comments' :
Expand Down Expand Up @@ -156,6 +160,8 @@
{
case 'general' :
{
$html_check='checked="checked"';

$history_yes = ($conf['log']=='true')?'checked="checked"':'';
$history_no = ($conf['log']=='false')?'checked="checked"':'';
$lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':'';
Expand All @@ -168,8 +174,12 @@
'HISTORY_NO'=>$history_no,
'GALLERY_LOCKED_YES'=>$lock_yes,
'GALLERY_LOCKED_NO'=>$lock_no,
($conf['rate']=='true'?'RATE_YES':'RATE_NO')=>$html_check,
($conf['rate_anonymous']=='true'
? 'RATE_ANONYMOUS_YES' : 'RATE_ANONYMOUS_NO')=>$html_check,
'CONF_GALLERY_TITLE' => $conf['gallery_title'],
'CONF_GALLERY_DESCRIPTION' => $conf['gallery_description'],
'CONF_GALLERY_URL' => $conf['gallery_url'],
));
break;
}
Expand Down
10 changes: 0 additions & 10 deletions include/config_default.inc.php
Expand Up @@ -90,13 +90,6 @@
// catgory
$conf['calendar_datefield'] = 'date_creation';

// rate : enable feature for rating elements
$conf['rate'] = true;

// rate_anonymous : visitors are able to rate pictures (requires
// $conf['rate'] set to true)
$conf['rate_anonymous'] = true;

// newcat_default_commentable : at creation, must a category be commentable
// or not ?
$conf['newcat_default_commentable'] = 'true';
Expand Down Expand Up @@ -171,9 +164,6 @@
// category and element description.
$conf['allow_html_descriptions'] = true;

// galery_url : URL given in RSS feed
$conf['gallery_url'] = 'http://demo.phpwebgallery.net';

// prefix_thumbnail : string before filename. Thumbnail's prefix must only
// contain characters among : a to z (case insensitive), "-" or "_".
$conf['prefix_thumbnail'] = 'TN-';
Expand Down
3 changes: 3 additions & 0 deletions install/config.sql
Expand Up @@ -16,4 +16,7 @@ INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('show_nb_comments
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('gallery_locked','false','Lock your gallery temporary for non admin users');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('gallery_title','PhpWebGallery demonstration site','Title at top of each page and for RSS feed');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('gallery_description','My photos web site','Short description displayed with gallery title');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('gallery_url','http://demo.phpwebgallery.net','URL given in RSS feed');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('rate','true','Rating pictures feature is enabled');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('rate_anonymous','true','Rating pictures feature is also enabled for visitors');

88 changes: 88 additions & 0 deletions install/db/8-database.php
@@ -0,0 +1,88 @@
<?php
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
// | last update : $Date: 2005-09-21 00:04:57 +0200 (mer, 21 sep 2005) $
// | last modifier : $Author: plg $
// | revision : $Revision: 870 $
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License 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. |
// +-----------------------------------------------------------------------+

if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}

$upgrade_description = 'Move rate, rate_anonymous and gallery_url from config file to database';

$params = array(
'gallery_url' => array('http://demo.phpwebgallery.net','URL given in RSS feed'),
'rate' => array('true','Rating pictures feature is enabled') ,
'rate_anonymous' => array('true','Rating pictures feature is also enabled for visitors')
);



// +-Get real values from config file--------------------------------------+

$conf_save = $conf;
unset($conf);
@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
if ( isset($conf['gallery_url']) )
{
$params['gallery_url'][0] = $conf['gallery_url'];
}
if ( isset($conf['rate']) and is_bool($conf['rate']) )
{
$params['rate'][0] = $conf['rate'] ? 'true' : 'false';
}
if ( isset($conf['rate_anonymous']) and is_bool($conf['rate_anonymous']) )
{
$params['rate_anonymous'][0] = $conf['rate_anonymous'] ? 'true' : 'false';
}
$conf = $conf_save;



// +-Do I already have them in DB ?----------------------------------------+
$query = 'SELECT param FROM '.PREFIX_TABLE.'config';
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
{
unset( $params[ $row['param'] ] );
}

// +-Perform the insert query----------------------------------------------+
foreach ($params as $param_key => $param_values)
{
$query = '
INSERT INTO '.PREFIX_TABLE.'config (param,value,comment) VALUES (' .
"'$param_key','$param_values[0]','$param_values[1]');";
pwg_query($query);
}


echo
"\n"
.'Table '.PREFIX_TABLE.'config upgraded'
."\n"
;
?>
6 changes: 4 additions & 2 deletions language/en_UK.iso-8859-1/admin.lang.php
Expand Up @@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
Expand Down Expand Up @@ -71,6 +71,7 @@
$lang['Environment'] = 'Environment';
$lang['Expand all categories'] = 'Expand all categories';
$lang['Form'] = 'Form';
$lang['Gallery URL'] = 'Gallery URL';
$lang['Gallery description'] = 'Gallery description';
$lang['Gallery title'] = 'Gallery title';
$lang['Grant selected groups'] = 'Grant selected groups';
Expand Down Expand Up @@ -120,6 +121,7 @@
$lang['Random picture'] = 'Random picture';
$lang['Rate date'] = 'Rate date';
$lang['Rating'] = 'Rating';
$lang['Rating by guests'] = 'Rating by guests';
$lang['Recent period'] = 'Recent period';
$lang['Registration date'] = 'Registration date';
$lang['Reject All'] = 'Reject All';
Expand Down Expand Up @@ -162,7 +164,6 @@
$lang['cat_add'] = 'Add a virtual category';
$lang['cat_comments_title'] = 'Authorize users to add comments on selected categories';
$lang['cat_error_name'] = 'The name of a category should not be empty';
$lang['cat_image_info'] = 'Images info';
$lang['cat_lock_title'] = 'Lock categories';
$lang['cat_private'] = 'Private category';
$lang['cat_public'] = 'Public category';
Expand All @@ -178,6 +179,7 @@
$lang['conf_confirmation'] = 'Information data registered in database';
$lang['conf_default'] = 'Default display';
$lang['conf_default_title'] = 'Default display';
$lang['conf_gallery_url_error'] = 'The gallery URL is not valid.';
$lang['conf_general_title'] = 'Main configuration';
$lang['conf_nb_comment_page_error'] = 'The number of comments a page must be between 5 and 50 included.';
$lang['config'] = 'Configuration';
Expand Down
7 changes: 7 additions & 0 deletions language/en_UK.iso-8859-1/help/configuration.html
Expand Up @@ -19,6 +19,8 @@ <h3>General</h3>
<li><strong>Gallery description</strong>: displayed under gallery
title.</li>

<li><strong>Gallery URL</strong>: used for the RSS feed.</li>

<li><strong>History</strong>: visits on pages <span
class="pwgScreen">category.php</span> and <span
class="pwgScreen">picture.php</span> will be registered in
Expand All @@ -29,6 +31,11 @@ <h3>General</h3>
maintenance. Only administrator users will be able to reach the
gallery.</li>

<li><strong>Rating</strong>: Picture rating feature is enabled.</li>

<li><strong>Rating by guests</strong>: Even non registered users can
rate images.</li>

</ul>


Expand Down
5 changes: 4 additions & 1 deletion language/fr_FR.iso-8859-1/admin.lang.php
Expand Up @@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
Expand Down Expand Up @@ -71,6 +71,7 @@
$lang['Environment'] = 'Environnement';
$lang['Expand all categories'] = 'Développer toutes les catégories';
$lang['Form'] = 'Formulaire';
$lang['Gallery URL'] = 'URL de la galerie';
$lang['Gallery description'] = 'Description de la galerie';
$lang['Gallery title'] = 'Titre de la galerie';
$lang['Grant selected groups'] = 'Donner l\'accès aux groupes sélectionnés';
Expand Down Expand Up @@ -120,6 +121,7 @@
$lang['Random picture'] = 'Au hasard';
$lang['Rate date'] = 'Date de notation';
$lang['Rating'] = 'Notation';
$lang['Rating by guests'] = 'Notation par les visiteurs';
$lang['Recent period'] = 'Période récente';
$lang['Registration date'] = 'Date d\'enregistrement';
$lang['Reject All'] = 'Tout rejeter';
Expand Down Expand Up @@ -177,6 +179,7 @@
$lang['conf_confirmation'] = 'Informations enregistrées dans la base de données';
$lang['conf_default'] = 'Affichage par défaut';
$lang['conf_default_title'] = 'Affichage par défaut';
$lang['conf_gallery_url_error'] = 'L\'adresse de la galerie n\'est pas valide.';
$lang['conf_general_title'] = 'Configuration principale';
$lang['conf_nb_comment_page_error'] = 'Le nombre de commentaires utilisateurs par page doit être compris entre 5 et 50.';
$lang['config'] = 'Configuration';
Expand Down
7 changes: 7 additions & 0 deletions language/fr_FR.iso-8859-1/help/configuration.html
Expand Up @@ -19,6 +19,8 @@ <h2>Configuration</h2>
<li><strong>Description de la galerie</strong>: affiché en dessous du
titre de la galerie.</li>

<li><strong>URL de la galerie</strong>: utilisé pour le flux RSS.</li>

<li><strong>Historique</strong>: visites des pages <span
class="pwgScreen">category.php</span> et <span
class="pwgScreen">picture.php</span> sont enregistrées dans la table
Expand All @@ -29,6 +31,11 @@ <h2>Configuration</h2>
galerie pour maintenance. Seul les administrateurs pourront accéder à la
galerie.</li>

<li><strong>Notation</strong>: La notation des photos est possible.</li>

<li><strong>Notation par les visiteurs</strong>: Même les utilisateurs
non enregistrés peuvent noter les images.</li>

</ul>


Expand Down
19 changes: 19 additions & 0 deletions template/yoga/admin/configuration.tpl
Expand Up @@ -23,6 +23,11 @@
<textarea cols="50" rows="5" name="gallery_description" id="gallery_description">{general.CONF_GALLERY_DESCRIPTION}</textarea>
</li>

<li>
<label for="gallery_title"><strong>{lang:Gallery URL}</strong></label>
<input type="text" maxlength="255" size="50" name="gallery_url" id="gallery_url" value="{general.CONF_GALLERY_URL}" />
</li>

<li>
<label><strong>{lang:History}</strong></label>
<input type="radio" class="radio" name="log" value="true" {general.HISTORY_YES} />{lang:Yes}
Expand All @@ -35,6 +40,20 @@
<input type="radio" class="radio" name="gallery_locked" value="false" {general.GALLERY_LOCKED_NO} />{lang:No}
</li>
</ul>

<ul>
<li>
<label><strong>{lang:Rating}</strong></label>
<input type="radio" class="radio" name="rate" value="true" {general.RATE_YES} />{lang:Yes}
<input type="radio" class="radio" name="rate" value="false" {general.RATE_NO} />{lang:No}
</li>

<li>
<label><strong>{lang:Rating by guests}</strong></label>
<input type="radio" class="radio" name="rate_anonymous" value="true" {general.RATE_ANONYMOUS_YES} />{lang:Yes}
<input type="radio" class="radio" name="rate_anonymous" value="false" {general.RATE_ANONYMOUS_NO} />{lang:No}
</li>
</ul>
<!-- END general -->

<!-- BEGIN comments -->
Expand Down

0 comments on commit d22a07c

Please sign in to comment.