PPU web frontend and a simple skin

Overview

This example show how to customize easily your PPU web frontend with a simple Custom StyleSheet.

Screenshot

sample screenshot

sample screenshot

Dependencies

This example requires mandatory resources :

Explains step by step

The PEAR_PackageUpdate package is loaded at line 14, while on line 17 we instanciate a new web frontend for PPU.

Render of dialog boxes (main and preferences) is produces by stylesheet ppugreyskin.css that PPUweb should find in directory located by setStyleSheet() method. on line 27.

Source Code

  1. <?php
  2. /**
  3. * An example script that update PEAR::DB_DataObject
  4. * using PEAR_PackageUpdate with a Web front end.
  5. *
  6. * @author    Laurent Laville
  7. * @package   PEAR_PackageUpdate_Web
  8. * @version   $Id: ppuWebExample2.php,v 1.2 2006/07/17 18:50:08 farell Exp $
  9. * @license   http://www.php.net/license/3_01.txt  PHP License 3.01
  10. * @copyright 2006 Laurent Laville
  11. * @ignore
  12. */
  13.  
  14. require_once 'PEAR/PackageUpdate.php';
  15.  
  16. // Create a Web package updater for the DB_DataObject package on pear channel.
  17. $ppu = PEAR_PackageUpdate::factory('Web', 'DB_DataObject', 'pear');
  18.  
  19. // Make sure the updater was created properly.
  20. if ($ppu === false) {
  21.     echo "Could not create updater.\n";
  22.     echo "You might want to check for and install updates manually.\n";
  23.     die();
  24. }
  25.  
  26. // set your own styles, rather than use the default stylesheet
  27. $ppu->setStyleSheet(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ppugreyskin.css');
  28.  
  29. // Check to see if any updates are availble.
  30. if ($ppu->checkUpdate()) {
  31.     // If updates are available, present the user with the option to update.
  32.     if ($ppu->presentUpdate()) {
  33.         // Update the package.
  34.         $ppu->update();
  35.         $ppu->forceRestart();
  36.     }
  37. }
  38.  
  39. // Check for errors.
  40. if ($ppu->hasErrors()) {
  41.     $ppu->errorDialog(); // without context details
  42. }
  43.  
  44. print 'still alive';
  45. ?>