API16

JInstallerHelper/detectType: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Method to detect the extension type from a package directory <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JInstallerHelper/detec...
 
m preparing for archive only
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
Method to detect the extension type from a package directory
Method to detect the extension type from a package directory


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JInstallerHelper/detectType|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JInstallerHelper/detectType}}
 
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 69: Line 67:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JInstallerHelper/detectType|Edit See Also]]<nowiki>]</nowiki>
<! removed transcluded page call, red link never existed >
</span>
{{SeeAlso:JInstallerHelper/detectType}}


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=detectType
  category=detectType
  category=JInstallerHelper
  category=JInstallerHelper
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API16]]

Latest revision as of 01:49, 25 March 2017

Description

Method to detect the extension type from a package directory


<! 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))
        {
                JError::raiseWarning(1, JText::_('ERRORNOTFINDXMLSETUPFILE'));
                return false;
        }

        foreach ($files as $file)
        {
                if( ! $xml = JFactory::getXML($file))
                {
                        continue;
                }

                if($xml->getName() != 'install' && $xml->getName() != 'extension')
                {
                        unset($xml);
                        continue;
                }

                $type = (string)$xml->attributes()->type;
                // Free up memory
                unset ($xml);
                return $type;
        }

        JError::raiseWarning(1, JText::_('ERRORNOTFINDJOOMLAXMLSETUPFILE'));
        // Free up memory.
        unset ($xml);
        return false;
}


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

Examples

Code Examples