示例#1
0
 function finish()
 {
     $link = 'index.php?option=com_imageshow';
     $objJSNInstMessage = new JSNISInstallerMessage();
     $objJSNInstMessage->installMessage();
     $this->setRedirect($link);
 }
示例#2
0
    /**
     * Implement postflight hook.
     *
     * @param   string  $type    Extension type.
     * @param   object  $parent  JInstaller object.
     *
     * @return  void
     */
    public function postflight($type, $parent)
    {
        /******************************* JSN IMAGESHOW ***************************************/
        $factoryFile = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_imageshow' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'jsn_is_factory.php';
        $upgradeDBUtilFile = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_imageshow' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'jsn_is_upgradedbutil.php';
        $installerMessageFile = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_imageshow' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'jsn_is_installermessage.php';
        $imageShowPostFlightFlag = false;
        if (is_file($factoryFile) && is_file($upgradeDBUtilFile) && is_file($installerMessageFile)) {
            include_once $factoryFile;
            include_once $upgradeDBUtilFile;
            include_once $installerMessageFile;
            $imageShowPostFlightFlag = true;
        }
        /******************************* JSN IMAGESHOW ***************************************/
        // Get original installer
        $installer = $parent->getParent();
        isset($this->parentInstaller) or $this->parentInstaller = $parent->getParent();
        // Update language file
        $this->updateLanguage();
        // Process dependency installation
        foreach ($this->dependencies as $extension) {
            // Remove installed extension if requested
            if (isset($extension->remove) and (int) $extension->remove > 0) {
                $this->removeExtension($extension);
                continue;
            }
            // Install only dependency that has local installation package
            if (isset($extension->source)) {
                // Install and update dependency status
                $this->installExtension($extension);
            } elseif (!isset($this->missingDependency)) {
                $this->missingDependency = true;
            }
        }
        // Create dependency declaration constant
        if (!defined('JSN_' . strtoupper($this->name) . '_DEPENDENCY')) {
            // Get Joomla config
            $config = JFactory::getConfig();
            // Unset some unnecessary properties
            foreach ($this->dependencies as &$dependency) {
                unset($dependency->source);
                unset($dependency->upToDate);
            }
            $this->dependencies = json_encode($this->dependencies);
            // Store dependency declaration
            file_exists($defines = $this->path . '/defines.php') or file_exists($defines = $this->path . "/{$this->name}.defines.php") or $defines = $this->path . "/{$this->name}.php";
            if ($config->get('ftp_enable') or is_writable($defines)) {
                $buffer = preg_replace('/(defined\\s*\\(\\s*._JEXEC.\\s*\\)[^\\n]+\\n)/', '\\1' . "\ndefine('JSN_" . strtoupper($this->name) . "_DEPENDENCY', '" . $this->dependencies . "');\n", JFile::read($defines));
                JFile::write($defines, $buffer);
            }
        }
        // Clean latest product version cache file
        $cache = JFactory::getConfig()->get('tmp_path') . '/JoomlaShineUpdates.json';
        if (file_exists($cache)) {
            jimport('joomla.filesystem.file');
            JFile::delete($cache);
        }
        // Register check update link for Joomla 3.1
        $JVersion = new JVersion();
        // Check if current joomla version is 2.5.x
        $isJoomla25 = (version_compare($JVersion->getShortVersion(), '2.5', '>=') and version_compare($JVersion->getShortVersion(), '3.0', '<'));
        //if (version_compare($JVersion->RELEASE, '3.1', '>='))
        //{
        // Get id for the extension just installed
        $ext = JTable::getInstance('Extension');
        $ext->load(array('name' => $this->name, 'element' => basename($this->path), 'type' => 'component'));
        if ($ext->extension_id) {
            // Get current check update data
            $db = JFactory::getDbo();
            $q = $db->getQuery(true);
            $q->select('update_site_id');
            $q->from('#__update_sites');
            $q->where('location LIKE ' . $q->quote('%index.php?option=' . $ext->element . '&task=checkUpdate%'));
            $db->setQuery($q);
            if ($uid = $db->loadResult()) {
                // Clean-up current check update data
                $q = $db->getQuery(true);
                $q->delete('#__update_sites');
                $q->where('update_site_id = ' . (int) $uid);
                $db->setQuery($q);
                if ($isJoomla25) {
                    $db->query();
                } else {
                    $db->execute();
                }
                $q = $db->getQuery(true);
                $q->delete('#__update_sites_extensions');
                $q->where('update_site_id = ' . (int) $uid);
                $db->setQuery($q);
                if ($isJoomla25) {
                    $db->query();
                } else {
                    $db->execute();
                }
            }
            // Register check update data
            $ln = JUri::root() . 'administrator/index.php?option=' . $ext->element . '&task=checkUpdate&file=update.xml';
            $q = $db->getQuery(true);
            $q->insert('#__update_sites');
            $q->columns('`name`, `type`, `location`, `enabled`');
            $q->values($q->quote($this->name) . ', ' . $q->quote('collection') . ', ' . $q->quote($ln) . ', 1');
            $db->setQuery($q);
            if ($isJoomla25) {
                $db->query();
            } else {
                $db->execute();
            }
            if ($uid = $db->insertid()) {
                $q = $db->getQuery(true);
                $q->insert('#__update_sites_extensions');
                $q->columns('`update_site_id`, `extension_id`');
                $q->values((int) $uid . ', ' . (int) $ext->extension_id);
                $db->setQuery($q);
                if ($isJoomla25) {
                    $db->query();
                } else {
                    $db->execute();
                }
            }
        }
        //}
        /******************************* JSN IMAGESHOW ***************************************/
        $extInfo = $this->getExtInfo();
        $session = JFactory::getSession();
        if (!is_null($extInfo)) {
            if ($session->get('preversion', null, 'jsnimageshow') != null) {
                if ($imageShowPostFlightFlag) {
                    $objUpgradeDBUtil = new JSNISUpgradeDBUtil($this->parentInstaller->getManifest());
                    $objUpgradeDBUtil->executeUpgradeDB();
                }
            }
        }
        $this->duplicateManifestFile();
        if ($imageShowPostFlightFlag) {
            $objJSNInstMessage = new JSNISInstallerMessage();
            $objJSNInstMessage->installMessage();
        }
        /******************************* JSN IMAGESHOW ***************************************/
        // Check if redirect should be disabled
        if ($this->app->input->getBool('tool_redirect', true)) {
            // Do we have any missing dependency
            if ($this->missingDependency) {
                if (strpos($_SERVER['HTTP_REFERER'], '/administrator/index.php?option=com_installer') !== false) {
                    // Set redirect to finalize dependency installation
                    $this->parentInstaller->setRedirectURL('index.php?option=com_' . $this->name . '&view=installer');
                } else {
                    // Let Ajax client redirect
                    echo '
<script type="text/javascript">
	if (window.parent)
		window.parent.location.href ="' . JUri::root() . 'administrator/index.php?option=com_' . $this->name . '&view=installer";
	else
		location.href ="' . JUri::root() . 'administrator/index.php?option=com_' . $this->name . '&view=installer";
</script>';
                    exit;
                }
            }
        }
    }
示例#3
0
 /**
  * Finish process of installation and creat a copy of imageshow.xml with new name is com_imageshow.xml
  * This action is to maintain for old versions.
  *
  * @return void
  */
 public function finish()
 {
     // clear install session
     $session = JFactory::getSession();
     $session->set('preversion', null, 'jsnimageshow');
     $session->set('jsn-list-required-install', array(), 'jsn-install-manual');
     $link = 'index.php?option=com_imageshow';
     $pathSrcManifestFile = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_imageshow' . DS . 'imageshow.xml';
     $pathDestManifestFile = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_imageshow' . DS . 'com_imageshow.xml';
     JFile::copy($pathSrcManifestFile, $pathDestManifestFile);
     $objJSNInstMessage = new JSNISInstallerMessage();
     $objJSNInstMessage->installMessage();
     $this->setRedirect($link);
 }