API16

JInstallerLibrary/update: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 51: Line 51:


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=update
  category=update
  category=JInstallerLibrary
  category=JInstallerLibrary
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*

Latest revision as of 01:50, 25 March 2017

Description

Custom update method public boolean True on success 1.5



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

Syntax

update()


Returns

boolean True on success

Defined in

libraries/joomla/installer/adapters/library.php

Importing

jimport( 'joomla.installer.adapters.library' );

Source Body

function update()
{
        // since this is just files, an update removes old files
        // Get the extension manifest object
        $this->manifest = $this->parent->getManifest();

        // Set the extensions name
        $name = (string)$this->manifest->name;
        $name = JFilterInput::getInstance()->clean($name, 'string');
        $element = str_replace('.xml','',basename($this->parent->getPath('manifest')));
        $this->set('name', $name);
        $this->set('element', $element);
        $installer = new JInstaller(); // we don't want to compromise this instance!
        $db = &$this->parent->getDbo();
        $db->setQuery('SELECT extension_id FROM #__extensions WHERE type="library" AND element = "'. $element .'"');
        $result = $db->loadResult();
        if ($result) {
                // already installed, which would make sense
                $installer->uninstall('library', $result);
        }
        // now create the new files
        return $this->install();
}


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

Examples

Code Examples