[geeklog-cvs] geeklog: New XMLSitemap plugin, provided by mystral-kk

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Fri May 1 10:03:06 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/fc202669ac90
changeset: 7005:fc202669ac90
user:      Dirk Haun <dirk at haun-online.de>
date:      Fri May 01 11:23:44 2009 +0200
description:
New XMLSitemap plugin, provided by mystral-kk

diffstat:

11 files changed, 1682 insertions(+)
plugins/xmlsitemap/autoinstall.php             |  131 +++++
plugins/xmlsitemap/functions.inc               |  554 ++++++++++++++++++++++++
plugins/xmlsitemap/install_defaults.php        |  119 +++++
plugins/xmlsitemap/language/english.php        |   74 +++
plugins/xmlsitemap/language/english_utf-8.php  |   74 +++
plugins/xmlsitemap/language/japanese_utf-8.php |   74 +++
plugins/xmlsitemap/sql/mssql_install.php       |   49 ++
plugins/xmlsitemap/sql/mysql_install.php       |   49 ++
plugins/xmlsitemap/xmlsitemap.class.php        |  553 +++++++++++++++++++++++
public_html/docs/english/changes.html          |    3 
public_html/docs/history                       |    2 

diffs (truncated from 1738 to 300 lines):

diff -r 895386b8afcb -r fc202669ac90 plugins/xmlsitemap/autoinstall.php
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/xmlsitemap/autoinstall.php	Fri May 01 11:23:44 2009 +0200
@@ -0,0 +1,131 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | XMLSitemap Plugin 1.0                                                     |
+// +---------------------------------------------------------------------------+
+// | autoinstall.php                                                           |
+// |                                                                           |
+// | This file provides helper functions for the automatic plugin install.     |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2009 by the following authors:                              |
+// |                                                                           |
+// | Authors: Kenji ITO         - geeklog AT mystral-kk DOT net                |
+// |          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.           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+
+/**
+* Autoinstall API functions for the XMLSitemap plugin
+*
+* @package XMLSitemap
+*/
+
+/**
+* Plugin autoinstall function
+*
+* @param    string  $pi_name    Plugin name
+* @return   array               Plugin information
+*
+*/
+function plugin_autoinstall_xmlsitemap($pi_name)
+{
+    $pi_name         = 'xmlsitemap';
+    $pi_display_name = 'XMLSitemap';
+    $pi_admin        = $pi_display_name . ' Admin';
+    $feature         = 'xmlsitemap.edit';
+    
+    $info = array(
+        'pi_name'         => $pi_name,
+        'pi_display_name' => $pi_display_name,
+        'pi_version'      => '1.0.0',
+        'pi_gl_version'   => '1.6.0',
+        'pi_homepage'     => 'http://www.geeklog.net/',
+    );
+    
+    $groups = array(
+        $pi_admin => 'Users in this group can administer the ' . $pi_display_name . ' plugin'
+    );
+    $features = array(
+        $feature => 'Access to ' . $pi_admin,
+    );
+    $mappings = array(
+        $feature => array($pi_admin),
+    );
+    $tables = array();
+    
+    $inst_parms = array(
+        'info'      => $info,
+        'groups'    => $groups,
+        'features'  => $features,
+        'mappings'  => $mappings,
+        'tables'    => $tables,
+    );
+    
+    return $inst_parms;
+}
+
+/**
+* Load plugin configuration from database
+*
+* @param    string  $pi_name    Plugin name
+* @return   boolean             TRUE on success, otherwise FALSE
+* @see      plugin_initconfig_glsitemap
+*
+*/
+function plugin_load_configuration_xmlsitemap($pi_name)
+{
+    global $_CONF;
+    
+    $base_path = $_CONF['path'] . 'plugins/' . $pi_name . '/';
+    
+    require_once $_CONF['path_system'] . 'classes/config.class.php';
+    require_once $base_path . 'install_defaults.php';
+    
+    return plugin_initconfig_xmlsitemap();
+}
+
+/**
+* Check if the plugin is compatible with this Geeklog version
+*
+* @param    string  $pi_name    Plugin name
+* @return   boolean             TRUE: plugin compatible; FALSE: not compatible
+*
+*/
+function plugin_compatible_with_this_version_xmlsitemap($pi_name)
+{
+    return function_exists('PLG_itemDeleted');
+}
+
+/**
+* Perform post-install operations
+*
+* @param    string  $pi_name    Plugin name
+* @return   boolean             TRUE: plugin compatible; FALSE: not compatible
+*/
+function plugin_postinstall_xmlsitemap($pi_name)
+{
+    global $_CONF, $_XMLSMAP_CONF;
+    
+    require_once $_CONF['path'] . 'plugins/xmlsitemap/functions.inc';
+    
+    // Create an XML sitemap for the first time
+    return XMLSMAP_update();
+}
+
+?>
diff -r 895386b8afcb -r fc202669ac90 plugins/xmlsitemap/functions.inc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/xmlsitemap/functions.inc	Fri May 01 11:23:44 2009 +0200
@@ -0,0 +1,554 @@
+<?php
+
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | XMLSitemap Plugin 1.0                                                     |
+// +---------------------------------------------------------------------------+
+// | functions.inc                                                             |
+// |                                                                           |
+// | This file does two things: 1) it implements the necessary Geeklog Plugin  |
+// | API method and 2) implements all the common code needed by the Links      |
+// | Plugins' PHP files.                                                       |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2009 by the following authors:                              |
+// |                                                                           |
+// | Authors: Kenji ITO         - geeklog AT mystral-kk DOT net                |
+// |          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.           |
+// |                                                                           |
+// +---------------------------------------------------------------------------+
+
+/**
+* Implementation of the Plugin API for the XMLSitemap plugin
+*
+* @package XMLSitemap
+*/
+
+if (strpos(strtolower($_SERVER['PHP_SELF']), 'functions.inc') !== FALSE) {
+    die ('This file can not be used on its own.');
+}
+
+/**
+* Language file Include
+*/
+$langfile = $_CONF['path'] . 'plugins/xmlsitemap/language/' . $_CONF['language'] . '.php';
+clearstatcache();
+if (file_exists($langfile)) {
+    include_once $langfile;
+} else {
+    include_once $_CONF['path'] . 'plugins/xmlsitemap/language/english.php';
+}
+
+/**
+* Load the plugin configuration
+*/
+$_XMLSMAP_CONF = XMLSMAP_loadConfig();
+
+// +---------------------------------------------------------------------------+
+// | Geeklog Plugin API Implementations                                        |
+// +---------------------------------------------------------------------------+
+
+/**
+* Return the version for this plugin
+*
+* @return string VersionNo
+*/
+function plugin_chkVersion_xmlsitemap()
+{
+    global $_CONF;
+    
+    require_once $_CONF['path'] . 'plugins/xmlsitemap/autoinstall.php';
+    
+    $inst_parms = plugin_autoinstall_xmlsitemap('xmlsitemap');
+    
+    return $inst_parms['info']['pi_version'];
+}
+
+/**
+* Upgrade the plugin
+*
+* @return   boolean TRUE (= success)
+*/
+function plugin_upgrade_xmlsitemap()
+{
+    global $_CONF, $_TABLES;
+    
+    $installed_version = DB_getItem($_TABLES['plugins'], 'pi_version',
+                                    "pi_name = 'xmlsitemap'");
+    $code_version = plugin_chkVersion_xmlsitemap();
+    if ($installed_version == $code_version) {
+        // nothing to do
+        return TRUE;
+    }
+    
+    require_once $_CONF['path'] . 'plugins/xmlsitemap/autoinstall.php';
+    
+    if (! plugin_compatible_with_this_version_xmlsitemap('xmlsitemap')) {
+        return 3002;
+    }
+    
+    $inst_parms = plugin_autoinstall_xmlsitemap('xmlsitemap');
+    $pi_gl_version = $inst_parms['info']['pi_gl_version'];
+    
+    DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '$code_version', pi_gl_version = '$pi_gl_version' WHERE pi_name = 'xmlsitemap'");
+    
+    return TRUE;
+}
+
+/**
+* Automatic uninstall function for plugins
+*
+* @return   array
+*/
+function plugin_autouninstall_xmlsitemap()
+{
+    global $_XMLSMAP_CONF;
+    
+    $out = array (
+        /* give the name of the tables, without $_TABLES[] */
+        'tables' => array(),
+        /* give the full name of the group, as in the db */
+        'groups' => array('XMLSitemap Admin'),
+        /* give the full name of the feature, as in the db */
+        'features' => array('xmlsitemap.edit'),
+        /* give the full name of the block, including 'phpblock_', etc */
+        'php_blocks' => array(),
+        /* give all vars with their name */
+        'vars' => array('xmlsitemap_filename', 'xmlsitemap_mobile'),
+    );
+    return $out;
+}
+
+/**
+* Loads config infor with config.class.php
+*/
+function XMLSMAP_loadConfig()
+{
+    global $_CONF;
+    
+    require_once $_CONF['path_system'] . 'classes/config.class.php';
+    
+    $config = config::get_instance();
+    if ($config->group_exists('xmlsitemap')) {
+        return $config->get_config('xmlsitemap');
+    } else {
+        return FALSE;
+    }
+}
+
+/**
+* Return a string escaped for HTML output
+*/
+function XMLSMAP_esc($str)
+{
+    static $encoding = NULL;
+    
+    if ($encoding === NULL) {
+        $encoding = COM_getCharset();;



More information about the geeklog-cvs mailing list