[geeklog-cvs] Geeklog-1.x/plugins/staticpages functions.inc, 1.113, 1.114 install_defaults.php, 1.2, 1.3

Dirk Haun dhaun at qs1489.pair.com
Sat Feb 2 11:36:36 EST 2008


Update of /cvsroot/geeklog/Geeklog-1.x/plugins/staticpages
In directory qs1489.pair.com:/tmp/cvs-serv44585/plugins/staticpages

Modified Files:
	functions.inc install_defaults.php 
Log Message:
Have the config data for the Static Pages plugin in only one place


Index: functions.inc
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/plugins/staticpages/functions.inc,v
retrieving revision 1.113
retrieving revision 1.114
diff -C2 -d -r1.113 -r1.114
*** functions.inc	26 Jan 2008 13:14:46 -0000	1.113
--- functions.inc	2 Feb 2008 16:36:33 -0000	1.114
***************
*** 1021,1025 ****
  function plugin_upgrade_staticpages ()
  {
!     global $_CONF,$_TABLES, $_SP_CONF, $plugin_path;
  
      // the plugin needs this function so complain when it doesn't exist
--- 1021,1025 ----
  function plugin_upgrade_staticpages ()
  {
!     global $_CONF, $_TABLES, $_SP_CONF, $plugin_path;
  
      // the plugin needs this function so complain when it doesn't exist
***************
*** 1031,1068 ****
                               "pi_name = 'staticpages'");
  
!     if ($pi_version == '1.4.3') {  // Need to initialize the config table - GL 1.5+ feature
!         if (file_exists("{$plugin_path}config.php")) {
!             require_once $_CONF['path_system'] . 'classes/config.class.php';
!             $sp_config = config::get_instance();
!             $sp_config->initConfig();
!             if (! $sp_config->group_exists('staticpages')) {
!                 $sp_config->add('allow_php', $_SP_CONF['allow_php'], 'select', 0, 0, 0, 10, true, 'staticpages');
!                 $sp_config->add('sort_by', $_SP_CONF['sort_by'], 'select', 0, 0, 2, 20, true, 'staticpages');
!                 $sp_config->add('sort_menu_by', $_SP_CONF['sort_menu_by'], 'select', 0, 0, 3, 30, true, 'staticpages');
!                 $sp_config->add('delete_pages', $_SP_CONF['delete_pages'], 'select', 0, 0, 0, 40, true, 'staticpages');
!                 $sp_config->add('in_block', $_SP_CONF['in_block'], 'select', 0, 0, 0, 50, true, 'staticpages');
!                 $sp_config->add('show_hits', $_SP_CONF['show_hits'], 'select', 0, 0, 0, 60, true, 'staticpages');
!                 $sp_config->add('show_date', $_SP_CONF['show_date'], 'select', 0, 0, 0, 70, true, 'staticpages');
!                 $sp_config->add('filter_html', $_SP_CONF['filter_html'], 'select', 0, 0, 0, 80, true, 'staticpages');
!                 $sp_config->add('censor', $_SP_CONF['censor'], 'select', 0, 0, 0, 90, true, 'staticpages');
!                 $sp_config->add('aftersave', $_SP_CONF['aftersave'], 'select', 0, 0, 9, 100, true, 'staticpages');
!                 $sp_config->add('atom_max_items', $_SP_CONF['atom_max_items'], 'text', 0, 0, null, 110, true, 'staticpages');
!                 $sp_config->add('default_permissions', $_SP_CONF['default_permissions'], '@select', 0, 1, 12, 120, true, 'staticpages');
  
!                 // Rename the existing config.php as it's not needed now
!                 $ret = @rename ("{$plugin_path}config.php","{$plugin_path}config-pre1.4.3.php");
!                 if (!$ret) {
!                     COM_errorLog("Staticpages upgrade to 1.5 error - unable to rename plugins config.php to complete upgrade");
!                     return 3003;
!                 } elseif ($sp_config->group_exists('staticpages')) {
!                     DB_query ("UPDATE {$_TABLES['plugins']} SET pi_version = '1.5.0' WHERE pi_name = 'staticpages'");
!                 } else {
!                     COM_errorLog("Staticpages upgrade to 1.5 failed");
!                     return 3001;
!                 }
              }
          } else {
!             COM_errorLog("Staticpages upgrade to 1.5 failed - missing plugins config.php");
!             return 3004;
          }
  
--- 1031,1059 ----
                               "pi_name = 'staticpages'");
  
!     if ($pi_version == '1.4.3') { // Need to initialize the config table
  
!         require_once $_CONF['path_system'] . 'classes/config.class.php';
!         require_once $plugin_path . 'install_defaults.php';
! 
!         if (!plugin_initconfig_staticpages()) {
!             COM_errorLog("Staticpages upgrade to 1.5.0 failed");
!             return 3001;
!         }
! 
!         if (file_exists($plugin_path . 'config.php')) {
!             // Rename the existing config.php as it's not needed any more
!             $ren = @rename($plugin_path . 'config.php',
!                            $plugin_path . 'config-pre1.4.3.php');
!             if (!$ren) {
!                 COM_errorLog("Could not rename the Static Pages plugin's config.php file. Please remove if manually, as it is not needed any more.");
              }
+         }
+ 
+         $sp_config = config::get_instance();
+         if ($sp_config->group_exists('staticpages')) {
+             DB_query ("UPDATE {$_TABLES['plugins']} SET pi_version = '1.5.0', pi_gl_version = '1.5.0' WHERE pi_name = 'staticpages'");
          } else {
!             COM_errorLog("Staticpages upgrade to 1.5.0 failed");
!             return 3001;
          }
  

Index: install_defaults.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/plugins/staticpages/install_defaults.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** install_defaults.php	27 Jan 2008 19:53:00 -0000	1.2
--- install_defaults.php	2 Feb 2008 16:36:33 -0000	1.3
***************
*** 1,4 ****
--- 1,42 ----
  <?php
  
+ /* Reminder: always indent with 4 spaces (no tabs). */
+ // +---------------------------------------------------------------------------+
+ // | Static Pages Plugin 1.5                                                   |
+ // +---------------------------------------------------------------------------+
+ // | install_defaults.php                                                      |
+ // |                                                                           |
+ // | Initial Installation Defaults used when loading the online configuration  |
+ // | records. These settings are only used during the initial installation     |
+ // | and not referenced any more once the plugin is installed.                 |
+ // +---------------------------------------------------------------------------+
+ // | Copyright (C) 2008 by the following authors:                              |
+ // |                                                                           |
+ // | Authors: Blaine Lang      - blaine AT portalparts DOT com                 |
+ // |          Dirk Haun        - dirk AT haun-online DOT de                    |
+ // +---------------------------------------------------------------------------+
+ // |                                                                           |
+ // | 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; either version 2            |
+ // | of the License, or (at your option) any later version.                    |
+ // |                                                                           |
+ // | 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.           |
+ // |                                                                           |
+ // +---------------------------------------------------------------------------+
+ //
+ // $Id$
+ 
+ if (strpos($_SERVER['PHP_SELF'], 'install_defaults.php') !== false) {
+     die('This file can not be used on its own!');
+ }
+ 
  /*
   * Static Pages default settings
***************
*** 10,16 ****
   */
  
! if (strpos($_SERVER['PHP_SELF'], 'install_defaults.php') !== false) {
!     die('This file can not be used on its own!');
! }
  
  // If you don't plan on using PHP code in static pages, you should set this
--- 48,52 ----
   */
  
! global $_SP_DEFAULT;
  
  // If you don't plan on using PHP code in static pages, you should set this
***************
*** 69,72 ****
--- 105,160 ----
  // The maximum number of items displayed when an Atom feed is requested
  $_SP_DEFAULT['atom_max_items'] = 10;
+ 
+ 
+ /**
+ * Initialize Static Pages plugin configuration
+ *
+ * Creates the database entries for the configuation if they don't already
+ * exist. Initial values will be taken from $_SP_CONF if available (e.g. from
+ * an old config.php), uses $_SP_DEFAULT otherwise.
+ *
+ * @return   boolean     true: success; false: an error occurred
+ *
+ */
+ function plugin_initconfig_staticpages()
+ {
+     global $_SP_CONF, $_SP_DEFAULT;
+ 
+     if (is_array($_SP_CONF) && (count($_SP_CONF) > 1)) {
+         $_SP_DEFAULT = $_SP_CONF;
+     }
+ 
+     $c = config::get_instance();
+     if (!$c->group_exists('staticpages')) {
+ 
+         $c->add('allow_php', $_SP_DEFAULT['allow_php'], 'select',
+                 0, 0, 0, 10, true, 'staticpages');
+         $c->add('sort_by', $_SP_DEFAULT['sort_by'], 'select',
+                 0, 0, 2, 20, true, 'staticpages');
+         $c->add('sort_menu_by', $_SP_DEFAULT['sort_menu_by'], 'select',
+                 0, 0, 3, 30, true, 'staticpages');
+         $c->add('delete_pages', $_SP_DEFAULT['delete_pages'], 'select',
+                 0, 0, 0, 40, true, 'staticpages');
+         $c->add('in_block', $_SP_DEFAULT['in_block'], 'select',
+                 0, 0, 0, 50, true, 'staticpages');
+         $c->add('show_hits', $_SP_DEFAULT['show_hits'], 'select',
+                 0, 0, 0, 60, true, 'staticpages');
+         $c->add('show_date', $_SP_DEFAULT['show_date'], 'select',
+                 0, 0, 0, 70, true, 'staticpages');
+         $c->add('filter_html', $_SP_DEFAULT['filter_html'], 'select',
+                 0, 0, 0, 80, true, 'staticpages');
+         $c->add('censor', $_SP_DEFAULT['censor'], 'select',
+                 0, 0, 0, 90, true, 'staticpages');
+         $c->add('aftersave', $_SP_DEFAULT['aftersave'], 'select',
+                 0, 0, 9, 100, true, 'staticpages');
+         $c->add('atom_max_items', $_SP_DEFAULT['atom_max_items'], 'text',
+                 0, 0, null, 110, true, 'staticpages');
+         $c->add('default_permissions', $_SP_DEFAULT['default_permissions'],
+                 '@select', 0, 1, 12, 120, true, 'staticpages');
+ 
+     }
+ 
+     return true;
+ }
  
  ?>




More information about the geeklog-cvs mailing list