Ejemplo n.º 1
0
 /**
  * Method to create the extension root path if necessary
  *
  * @return  void
  *
  * @since   3.4
  * @throws  RuntimeException
  */
 protected function createExtensionRoot()
 {
     // Run the common create code first
     parent::createExtensionRoot();
     // If we're updating at this point when there is always going to be an extension_root find the old XML files
     if ($this->route == 'update') {
         // Create a new installer because findManifest sets stuff; side effects!
         $tmpInstaller = new JInstaller();
         // Look in the extension root
         $tmpInstaller->setPath('source', $this->parent->getPath('extension_root'));
         if ($tmpInstaller->findManifest()) {
             $old_manifest = $tmpInstaller->getManifest();
             $this->oldFiles = $old_manifest->files;
         }
     }
 }
 /**
  * Get the filtered extension element from the manifest
  *
  * @param   string  $element  Optional element name to be converted
  *
  * @return  string  The filtered element
  *
  * @since   3.4
  */
 public function getElement($element = null)
 {
     $element = parent::getElement($element);
     if (substr($element, 0, 4) != 'com_') {
         $element = 'com_' . $element;
     }
     return $element;
 }
Ejemplo n.º 3
0
 /**
  * Shit happens. Patched function to bypass bug in package uninstaller
  *
  * @param   JInstallerAdapter  $parent  Parent object
  *
  * @return  void
  */
 protected function loadManifest($parent)
 {
     $element = strtolower(str_replace('InstallerScript', '', get_called_class()));
     $elementParts = explode('_', $element);
     // Type not properly detected or not a package
     if (count($elementParts) != 2 || strtolower($elementParts[0]) != 'pkg') {
         $this->manifest = $parent->get('manifest');
         return;
     }
     $rootPath = $parent->getParent()->getPath('extension_root');
     $manifestPath = dirname($rootPath);
     $manifestFile = $manifestPath . '/' . $element . '.xml';
     // Package manifest found
     if (file_exists($manifestFile)) {
         $this->manifest = JFactory::getXML($manifestFile);
         return;
     }
     $this->manifest = $parent->get('manifest');
 }
Ejemplo n.º 4
0
 /**
  * Function called before extension installation/update/removal procedure commences
  *
  * @param   string             $type    The type of change (install, update or discover_install, not uninstall)
  * @param   JInstallerAdapter  $parent  The class calling this method
  *
  * @return  boolean  True on success
  *
  * @since   3.6
  */
 public function preflight($type, $parent)
 {
     // Check for the minimum PHP version before continuing
     if (!empty($this->minimumPhp) && !version_compare(PHP_VERSION, $this->minimumPhp, '>')) {
         JLog::add(JText::sprintf('JLIB_INSTALLER_MINIMUM_PHP', $this->minimumPhp), JLog::WARNING, 'jerror');
     }
     // Check for the minimum Joomla version before continuing
     if (!empty($this->minimumJoomla) && !version_compare(JVERSION, $this->minimumJoomla, '>')) {
         JLog::add(JText::sprintf('JLIB_INSTALLER_MINIMUM_JOOMLA', $this->minimumJoomla), JLog::WARNING, 'jerror');
     }
     // Extension manifest file version
     $this->release = $parent->getManifest()->version;
     $extensionType = substr($this->extension, 0, 3);
     // Modules parameters are located in the module table - else in the extension table
     if ($extensionType === 'mod') {
         $this->paramTable = '#__modules';
     } else {
         $this->paramTable = '#__extensions';
     }
     // Abort if the extension being installed is not newer than the currently installed version
     if (strtolower($type) == 'update' && !$this->allowDowngrades) {
         $manifest = $this->getItemArray('manifest_cache', '#__extensions', 'element', JFactory::getDbo()->quote($this->extension));
         $oldRelease = $manifest['version'];
         if (version_compare($this->release, $oldRelease, '<')) {
             JFactory::getApplication()->enqueueMessage(JText::sprintf('JLIB_INSTALLER_INCORRECT_SEQUENCE', $oldRelease, $this->release), 'error');
             return false;
         }
     }
     return true;
 }
 /**
  * Install TCPDF
  *
  * @param   JInstallerAdapter  $parent  How this was tarted
  *
  * @return void
  *
  * @since 1.7.0
  */
 private function _installTCPDF($parent)
 {
     $src = $parent->getParent()->getPath('source');
     $needUpgrade = false;
     // Install the TCPDF libraries
     $source = $src . '/libraries/tcpdf';
     $component = $source . '/tcpdf.xml';
     if (file_exists($component)) {
         $this->srcxml = simplexml_load_file($component);
     }
     if (!defined('JPATH_LIBRARIES')) {
         $target = JPATH_ROOT . '/libraries/tcpdf';
     } else {
         $target = JPATH_LIBRARIES . '/tcpdf';
     }
     $haveToInstallTCPDF = false;
     if (!JFolder::exists($target)) {
         $component = $target . '/tcpdf.xml';
         if (file_exists($component)) {
             $this->xml = simplexml_load_file($component);
         }
         $this->tcpdf_version = $this->xml->version;
         $this->tcpdf_result = 'Installed';
         $haveToInstallTCPDF = true;
     } else {
         $component = $target . '/tcpdf.xml';
         if (file_exists($component)) {
             $this->xml = simplexml_load_file($component);
         }
         $needUpgrade = version_compare($this->srcxml->version, $this->xml->version, '>');
         if ($needUpgrade) {
             $this->tcpdf_result = 'Upgrade';
         } else {
             $this->tcpdf_result = 'No Change';
         }
     }
     if ($haveToInstallTCPDF || $needUpgrade) {
         $installer = new JInstaller();
         $installer->install($source);
     }
     $this->status->libraries[] = ['name' => 'TCPDF', 'Version' => $this->tcpdf_version, 'result' => $this->tcpdf_result];
     return;
 }