API16

API16:JArchive/getAdapter

From Joomla! Documentation

Revision as of 22:47, 22 March 2010 by Doxiki (talk | contribs) (New page: <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{Description:JArchive/getAdapter}...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

[Edit Descripton]

Template:Description:JArchive/getAdapter

Syntax

getAdapter($type)
Parameter Name Default Value Description
$type

Defined in

libraries/joomla/filesystem/archive.php

Importing

jimport( 'joomla.filesystem.archive' );

Source Body

function getAdapter($type)
{
        static $adapters;

        if (!isset($adapters)) {
                $adapters = array();
        }

        if (!isset($adapters[$type]))
        {
                // Try to load the adapter object
                $class = 'JArchive'.ucfirst($type);

                if (!class_exists($class))
                {
                        $path = dirname(__FILE__).DS.'archive'.DS.strtolower($type).'.php';
                        if (file_exists($path)) {
                                require_once $path;
                        } else {
                                JError::raiseError(500,JText::_('Unable to load archive'));
                        }
                }

                $adapters[$type] = new $class();
        }
        return $adapters[$type];
}

[Edit See Also] Template:SeeAlso:JArchive/getAdapter

Examples

<CodeExamplesForm />