Actions

API15

JInstallerHelper/detectType

From Joomla! Documentation

< API15:JInstallerHelper
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Method to detect the extension type from a package directory

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax

detectType($p_dir)
Parameter Name Default Value Description
$p_dir $p_dir Path to package directory

Returns

mixed Extension type string or boolean false on fail

Defined in

libraries/joomla/installer/helper.php

Importing

jimport( 'joomla.installer.helper' );

Source Body

function detectType($p_dir)
{
        // Search the install dir for an xml file
        $files = JFolder::files($p_dir, '\.xml$', 1, true);
 
        if (count($files) > 0)
        {
 
                foreach ($files as $file)
                {
                        $xmlDoc = & JFactory::getXMLParser();
                        $xmlDoc->resolveErrors(true);
 
                        if (!$xmlDoc->loadXML($file, false, true))
                        {
                                // Free up memory from DOMIT parser
                                unset ($xmlDoc);
                                continue;
                        }
                        $root = & $xmlDoc->documentElement;
                        if (!is_object($root) || ($root->getTagName() != "install" && $root->getTagName() != 'mosinstall'))
                        {
                                unset($xmlDoc);
                                continue;
                        }
 
                        $type = $root->getAttribute('type');
                        // Free up memory from DOMIT parser
                        unset ($xmlDoc);
                        return $type;
                }
 
                JError::raiseWarning(1, JText::_('ERRORNOTFINDJOOMLAXMLSETUPFILE'));
                // Free up memory from DOMIT parser
                unset ($xmlDoc);
                return false;
        } else
        {
                JError::raiseWarning(1, JText::_('ERRORNOTFINDXMLSETUPFILE'));
                return false;
        }
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

<CodeExamplesForm />