DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

EXT:package_manager

Author:Peter Russ
Created:2007-03-06T16:20:18
Changed by:Peter Russ
Changed:2007-03-15T17:44:36
Author:Peter Russ
Email:peter.russ@4many.net
Info 3:4Many Servcies
Info 4:

EXT:package_manager

Extension Key: package_manager

Copyright 2007, 4Many Services , Peter Russ, <peter.russ@4many.net>

This document is published under the Open Content License

available from http://www.opencontent.org/opl.shtml

Version: 0.6.0

PDF-Version available at

http://www.4many.net/manual/package_manager/manual.pdf

The content of this document is related to TYPO3

- a GNU/GPL CMS/Framework available from www.typo3.com

Table of Contents

EXT:fdfx_be_image 1

Introduction 1

What does it do? 1

Sponsoring 1

Acknowledgment 1

Screenshots 1

Users manual 3

Administration 3

Installation 3

Setup 3

Configuration 4

To-Do list 4

Changelog 4

Introduction

What does it do?

There are a lot of useful PHP program packages, libraries or code fragments (herein call package) available in the internet. But often the license of the individual package is not compatible with the GPL. So the extension will never make it into TER.

Some extensions uses GPL packages. But due to the fact that these packages might be available form a different source it's sometime a hassle to keep them up to date. Either you do it by your own or wait until the author of the extension publishes an upgraded version.

This extension package_manager offers a solution for both. It could be the central point to keep external packages - i.e. packages beyond TER - up to date in your installation.

To whom it may concern

This extension and it's manual is for admins and programmers. An regular BE-user will never get in touch with this extension.

Screenshots

After the installation you will find a new entry in Tool menu. Clicking on that will give you the module screen

img-1

As you can see there are three packages managed by package_manager.

The extension itself (package_manager) contains two packages from PHP PEAR. As these are included they are already there and could be updated.

This package is depending on your installation! The extension fdfx_yaml requires the YAML package. As this is published under a GPL incompatible license you have to download this package by yourself. If you click the download button the source will be downloaded and expanded to the target.REMEMBER: you will only see this package if the extension fdfx_yaml is installed ;-)

img-2

PDF

The actual version of this manual can be downloaded in PDF format at http://www.4many.net/manual/package_manager/manual.pdf

Programmers Guide

ext_localconf.php

To integrate the download and update capabilities of package_manger in your extension you have to include the setup in ext_localconf.php of the extension.

<?
if (!defined ("TYPO3_MODE"))         die ('Access denied.');
if ((TYPO3_MODE == 'BE'))
{
 $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['externalPackageName']=array(
            'url'           =>   '',     # required:     source url of  the package
          'path'          =>   '',     # required:     target path to extract
                                                      #       root is ALLWAYS the extension path EXT:$_EXTKEY!
            'files'         =>   '',     # optional:     if empty package will be extracted completely
                                                       #       array or blank separated list of files
              'pathToRemove' => '',        # optional:     if set this path will be removed
            'initialize' => array(),     # optional:     array of source => target files
                                                       #       array('source file' => 'target file'),
                                                       #       if defined source files will be copied to target
                                                       #       Copied ONLY if package is downloaded, i.e. initial
                                                       #       installation. Might be changed in the future!
 );
}
?>

'externalPackageName' has to be changed to your needs and should be unique within your extension.

Example:

ext_localconf.php for package_manager might looks like this:

<?
if (!defined ("TYPO3_MODE"))         die ('Access denied.');
if ((TYPO3_MODE == 'BE'))
{
 $TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]=array('packages'=>null);
 $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['pear']=array(
       'url' =>'http://download.pear.php.net/package/PEAR-1.5.0.tgz',
       'path' => 'PEAR',
       'files' => 'PEAR-1.5.0/PEAR.php',
       'pathToRemove' => 'PEAR-1.5.0'
 );
 $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['pear-tar']=array(
       'url' =>'http://download.pear.php.net/package/Archive_Tar-1.3.2.tgz',
       'path' => 'PEAR',
       'files' => array('Archive_Tar-1.3.2/Archive/Tar.php'),
       'pathToRemove' => 'Archive_Tar-1.3.2/Archive'
 );
}
?>

The first construct includes the file with the path PEAR-1.5.0/PEAR.php of thePHP PEAR package PEAR-1.5.0.tgz from the url `http://download.pear.php.net/package/PEAR-1.5.0.tgz <http://download.pear.php.net/package/PEAR-1.5.0.tgz>`_ to the path EXT:package_manager/PEAR while removing the path PEAR-1.5.0 . This is the root of the zipped package.

The second expands the Tar.php class from the PHP PEAR package found at location http://download.pear.php.net/package/Archive_Tar-1.3.2.tgz to the some path EXT:package_manager/PEAR while removing the path Archive_Tar-1.3.2/Archive . This is the root of the zipped package.

The initialize-Array

This initialize array defines files that can be copied from the source location within the extension path EXT:$_EXTKEY to the target within the same path. The key of the array is the source file name, the value has to be the target name.

Example:

      $_EXTCONF = unserialize($_EXTCONF);    // unserializing the configuration so we can use it here:
  $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['yaml']=array(
       'url'=> $_EXTCONF['yaml_url']
          ,'path'=> 'YAML'
       ,'pathToRemove' => $_EXTCONF['yaml_version']
           ,'initialize' => array(
                array('YAML/layout_storage/layout_1-2-3.html' => 'templates/sub/h-123-f.html')
                 ,array('YAML/layout_storage/layout_1-2-3.html' => 'templates/sub/h-123_abb-f.html')
                    ,array('YAML/layout_storage/layout_3-2-1.html' => 'templates/sub/h-321-f.html')
                ,array('YAML/layout_storage/layout_1-3-2.html' => 'templates/sub/h-132-f.html')
                ,array('YAML/layout_storage/layout_1-3-2.html' => 'templates/sub/h-132_baa-f.html')
                    ,array('YAML/layout_storage/layout_2-3-1.html' => 'templates/sub/h-231-f.html')
                ,array('YAML/layout_storage/layout_2-3-1.html' => 'templates/sub/h-231_aab-f.html')
                    ,array('YAML/layout_storage/layout_3-1-2.html' => 'templates/sub/h-312-f.html')
                ,array('YAML/layout_storage/layout_2-1-3.html' => 'templates/sub/h-213-f.html')
                ,array('YAML/layout_storage/layout_1-3-2.html' => 'templates/sub/h-13-f.html')
                 ,array('YAML/layout_storage/layout_1-3-2.html' => 'templates/sub/h-32-f.html')
                 ,array('YAML/layout_storage/layout_1-2-3.html' => 'templates/sub/h-1-23-f.html')
       ),
);

Enabling User Specific Uploads

Due to the fact that some user uploads might be required to add user specific changes the package manager can also handle this.

Example:

     if ($_EXTCONF['user_upload'])
    {
        $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['yaml-user']=array(
                 'url'=> $_EXTCONF['user_upload']
              ,'path'=> 'templates'
                 ,'pathToRemove' => $_EXTCONF['user_upload_remove_path']
       );
       if ($_EXTCONF['user_upload_initialize'])
         {
                $tempFiles=explode(',',stripslashes($_EXTCONF['user_upload_initialize']));
               $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['yaml-user']['initialize']=array();
                 foreach ($tempFiles as $tempFile)
                {
                        list($tempSource,$tempTarget)=explode('::',$tempFile);
                           $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['yaml-user']['initialize'][$tempSource]=$tempTarget;
                }
                unset($tempFiles,$tempFile,$tempSource,$tempTarget);
             }
}

ext_conf_template.php

To enable the upgrade the admin has to change the url and if defined the pathToRemove. To avoid hacking the code a good strategy is to provide settings in ext_conf_template.php of the extemsion.

# cat=file; type=string; label=Source URL:set the url of the package file to download.
source_url=
# cat=file; type=string; label=Path to remove:set the path that should be removed if required
path_to_remove=

Example:

ext_conf_template.php of the package_manager looks like this:

# cat=file; type=string; label=PEAR Url:set the url of the PEAR framework file to download.
pear_url=http://download.pear.php.net/package/PEAR-1.5.0.tgz
# cat=file; type=string; label=Path to remove:set the path that should be removed
pear_path_to_remove=PEAR-1.5.0
# cat=file; type=string; label=PEAR Tar Url:set the url of the PEAR Tar framework file to download.
pear_tar_url=http://download.pear.php.net/package/Archive_Tar-1.3.2.tgz
# cat=file; type=string; label=Path to remove:set the path that should be removed
pear_tar_path_to_remove=Archive_Tar-1.3.2/Archive

Final ext_localconf.php

The final version of ext_localconf.php should look like this:

<?
if (!defined ("TYPO3_MODE"))         die ('Access denied.');
if ((TYPO3_MODE == 'BE'))
{
   $_EXTCONF = unserialize($_EXTCONF);    # unserializing the configuration so we can use it here

    $TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]=array('packages'=>null);
   $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['externalPackageName']=array(
          'url'           =>$_EXTCONF['url'],  # has to be adjusted to your needs
          'path'          =>   '',     # required: target path to extract
          'files'         =>   '',     # option: if empty package will be extracted completely
                                                     # array or blank separated list of strings
          'pathToRemove' => $_EXTCONF['path_to_remove']        # set this only IF required
 );
 }
?>

'externalPackageName' has to be changed to your needs and should be unique within your extension.$_EXTCONF['url'] and $_EXTCONF['path_to_remove'] depend on the definition you are using in ext_conf_template.php.

Example:

With the definition of the constants in ext_conf_template.php the ext_localconf.php of the package_manager extension will finally look like this:

<?
if (!defined ("TYPO3_MODE"))         die ('Access denied.');
if ((TYPO3_MODE == 'BE'))
{
 $_EXTCONF = unserialize($_EXTCONF);    // unserializing the configuration so we can use it here

 $TYPO3_CONF_VARS['EXTCONF'][$_EXTKEY]=array('packages'=>null);
 $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['pear']=array(
             'url' =>$_EXTCONF['pear_url'],
           'path' => 'PEAR',
                'files' => 'PEAR-1.5.0/PEAR.php',
                'pathToRemove' => $_EXTCONF['pear_path_to_remove']
 );
 $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'][$_EXTKEY]['pear-tar']=array(
            'url' =>$_EXTCONF['pear_tar_url'],
               'path' => 'PEAR',
                'files' => array('Archive_Tar-1.3.2/Archive/Tar.php'),
           'pathToRemove' => $_EXTCONF['pear_tar_path_to_remove']
 );
}
?>

What It Does

The package_manager will loop through all packages defined at $TYPO3_CONF_VARS['EXTCONF']['package_manager']['packages'] . If the found extension $extKey is installed it will loop through all packages that are defined for that extension and check whether the package should be downloaded for the first time or could be updated.

If download is activated the path will be created in the extension path, i.e. EXT:$extKey/path. The source gets downloaded from the url and expanded to the path. If files (i.e. one single file or a list of blank separated files or an array of files) is provided only these files will be expanded. If a pathToRemove is defined this will be removed.For compatibility (i.e. with Windows) a file '.mtime' will be created in EXT:$extKey/path.

If update is activated it works almost similar with the exception of creating the path and the file '.mtime'. As the path already exists there is no need to create. The file '.mtime' will be timestamped with the time of last update EXT:$extKey/path.

Administration

Installation

Just download the extension using the extension manager.

Setup

No need to setup anything at the moment.

What It Does

If you click on “Package Manger” at the Tools menu the package_manager will loop through all packages defined at $TYPO3_C ONF_VARS['EXTCONF']['package_manager']['packages'][$extKey] . If the found extension $extKey is installed it will loop through all packages that are defined for that extension and check whether the package should be downloaded for the first time or could be updated.

If download is activated the path will be created in the extension path, i.e. EXT:$extKey/path. The source gets downloaded from the url and expanded to the path. If files (i.e. one single file or a list of blank separated files or an array if files) is provided only these files will be expanded. If a pathToRemove is defined this will be removed.For compatibility (i.e. with Windows) a file '.mtime' will be created in EXT:$extKey/path.

If update is activated it works almost similar with the exception of creating the path and the file '.mtime'. As the path already exists there is no need to create. The file '.mtime' will be timestamped with the time of last update EXT:$extKey/path.

Adjustments

To change the source of a specific package and if defined the path to be removed refer to the extension by using the Extension Manager. At the moment there is no option included to change that directly. This might change in the future.

To-Do list

Option to change extension setting directly. T.B.D

Option to update selected or all packages on one shot.

Changelog

0.6.0 added initialize capabilityminor bugfixes

0.5.0 first public upload

img-3 EXT:package_manager - 9