Development

phpSitemapNG 1.6 aka “kiting” introduces a new architecture that allows creating custom plugins – for input from a database or cms, and also to export the data to other file formats as xml-based sitemaps or txt-based files. This page describes the information necessary to create a custom plugin.

Installation

Please follow these steps to install phpSitemapNG.

  1. Download the latest development release from the phpSitemapNG download section.
  2. Extract this zip archive and copy the phpSitemapNG directory to your website.
  3. Modify the attributes of the directory phpSitemapNG/tmp/ to 777 – all information of phpSitemapNG will be stored into this directory. Maybe this is not necessary – but this depends on your webhoster.

That’s it.

Setup and usage

  1. Browse to your phpSitemapNG installation, e.g. if you installed into the home directory of your website, invoke http://www.yourdomain.com/phpSitemapNG/ . You’ll now see the main screen of phpSitemapNG.
  2. Have a look at the settings page. Make shure that the temp directory is set correct.
  3. Now you can have a look at the plugins page: all available plugins will be listed above and if you’ve setup some plugins they’ll be listed as Instances. Instances are plugins that have been setup.
    That means you can have multiple plugins of the same “type” – e.g. 2 crawler or 5 filesystem plugins. Or different Google Sitemaps output plugins – each for your website you want to generate sitemaps for.
    There are three kinds of plugins: input that adds url to phpSitemapNG, compute that manipulates url entries stored in phpSitemapNG and output plugins that exports the entries of phpSitemapNG.

    1. Create instances of available plugins will set up new plugins that will be invoked when you invoke the apropriate actions (run, export – will be explained soon).
    2. Edit settings of plugin instances.
    3. Delete instances of plugins.
  4. Press the run button to invoke all import plugin instances – get all urls.
  5. Press the export button to export all imported urls with the output plugin instances.

There is still some functionality missing.

Plugins

Input: Crawler

Build-in plugin that crawls and indexes all pages of a domain

Input: Filesystem-Scanner

Build-in pluing that scans the filesystem for files to add

Input: Joomla! plugin for phpSitemapNG

The Joomla! input plugin is developed by Ulrich Bruns.

Changelog of Joomla! input plugin

  • 2006-02-28 version 0.15, integrated into phpSitemapNG 1.6.1b
    • add option for mod_rewrite / no mod_rewrite
    • Priority now can have up to 3 digits behind the seperator (before only 1)
    • Get creation date instead of modified date if content never modified (30.11.1999 issue)
    • add output of version number in setup page
  • 2006-02-02 first public release, integrated into phpSitemapNG 1.6.1a

Output: xml-based Sitemaps

Build-in plugin that supports Google Sitemap Index files and Google Sitemaps Stylesheet.

Architecture

The architecture of phpSitemapNG is designed for a heavy usage of plugins.
The main code is just dumb code that displays and runs plugins at a specified time. :)

At the moment there is a main class PhpSitemapNG that handles the user input and control flow in a kind of state modell (not really, just a very simple kind of), a class called Gui that deals with the output and does some of the logic functions.
The settings are handled by special class Settings that behaves like a registry ( get and set values with the functions getValue and setValue) – this information will be stored into a session and also in a file.
For storing of the urls there is at the moment only a session based storage class available (called StorageSession) but there is no way to store urls onto the filesystem or into a database. But there will be soon. :)

The plugins are setup and handled by the PluginHandler class – this searches for available plugins and returns instances of them.

Available plugins are the Crawler and the Filesystem classes that have been used in the stable version of phpSitemapNG as input plugins and a simple output plugin called GoogleSitemaps that creates Google Sitemaps files (but no Sitemaps index files yet) with the GsgXml class.

Data structure

All information of an url entry is stored in an array that has the follwing format:

phpSitemapNG 1.6 kiting datastructure of url informationOnly the value PSNG_URLINFO_URL is required, the rest of the keys are optional. But the more an input plugin provides, the better.

PSNG_URLINFO_ENABLED

  • type: int
  • value: 0/1
  • description: the page will be used by output plugins(value: 1) or not(value: 0)

PSNG_URLINFO_URL

  • type: string
  • description: the url of the page

PSNG_URLINFO_LASTMOD

  • type: int
  • value: timestamp
  • description: last modification time of page (content)

PSNG_URLINFO_CHANGEFREQ

  • type: string
  • value: specified by Google Sitemaps protocol
  • description: the changefreq string introduced by Google Sitemaps

PSNG_URLINFO_PRIORITY

  • type: float
  • value: 0.0 to 1.0
  • description: the priority value introduced by Google Sitemaps

PSNG_URLINFO_FILENAME

  • type: string
  • value: absolute path to existing file
  • description: contains a valid absolute filename pointing to the page

PSNG_URLINFO_TYPE

  • type: string
  • value: valid content type
  • description: content type of url entry (eg application/pdf, application/html, …)

PSNG_URLINFO_ADDED

  • type: int
  • value: timestamp
  • description: time when page has been added for the first time

PSNG_URLINFO_TITLE

  • type: string
  • description: the title of the website extraced from html content

PSNG_URLINFO_GROUP

  • type: string
  • description: represents a group that can be used by plugins to select groups of urls

PSNG_URLINFO_META_ROBOTS

  • type: string
  • description: contains the robots tag from html website

PSNG_URLINFO_PAGESIZE

  • type: int
  • description: contains pagesize in byte

PSNG_URLINFO_PAGEHASH

  • type: string
  • description: contains hash value of page content