function install()
 {
     global $mainframe;
     $this->setState('action', 'install');
     switch (JRequest::getWord('installtype')) {
         case 'folder':
             $package = $this->_getPackageFromFolder();
             break;
         case 'upload':
             $package = $this->_getPackageFromUpload();
             break;
         case 'url':
             $package = $this->_getPackageFromUrl();
             break;
         default:
             $this->setState('message', 'No Install Type Found');
             return false;
             break;
     }
     // Was the package unpacked?
     if (!$package) {
         $this->setState('message', 'Unable to find install package');
         return false;
     }
     // Get a database connector
     //$db = & JFactory::getDBO();
     // Get an installer instance
     require_once JPATH_COMPONENT . DS . 'installer' . DS . 'installer.php';
     $installer =& JCEInstaller::getInstance();
     // Install the package
     if (!$installer->install($package['dir'])) {
         // There was an error installing the package
         $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error'));
         $result = false;
     } else {
         // Package installed sucessfully
         $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success'));
         $result = true;
     }
     // Set some model state values
     $mainframe->enqueueMessage($msg);
     $this->setState('name', $installer->get('name'));
     $this->setState('result', $result);
     $this->setState('message', $installer->message);
     $this->setState('extension.message', $installer->get('extension.message'));
     // Cleanup the install files
     if (!is_file($package['packagefile'])) {
         $config =& JFactory::getConfig();
         $package['packagefile'] = $config->getValue('config.tmp_path') . DS . $package['packagefile'];
     }
     JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
     return $result;
 }
Exemple #2
0
 /**
  * Remove (uninstall) an extension
  *
  * @static
  * @return boolean True on success
  * @since 1.0
  */
 function remove($eid = array())
 {
     global $mainframe;
     $lang =& JFactory::getLanguage();
     $lang->load('com_jce');
     // Initialize variables
     $failed = array();
     /*
      * Ensure eid is an array of extension ids
      * TODO: If it isn't an array do we want to set an error and fail?
      */
     if (!is_array($eid)) {
         $eid = array($eid);
     }
     // construct the list of all language
     $this->_loadItems();
     // Get a database connector
     $db =& JFactory::getDBO();
     // Get an installer object for the extension type
     //jimport('joomla.installer.installer');
     require_once JPATH_COMPONENT . DS . 'installer' . DS . 'installer.php';
     $installer =& JCEInstaller::getInstance($db, $this->_type);
     // Uninstall the chosen extensions
     foreach ($eid as $id) {
         $item = $this->_items[$id];
         $result = $installer->uninstall('language', $item->language);
         // Build an array of extensions that failed to uninstall
         if ($result === false) {
             $failed[] = $id;
         }
     }
     if (count($failed)) {
         // There was an error in uninstalling the package
         $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Error'));
         $result = false;
     } else {
         // Package uninstalled sucessfully
         $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Success'));
         $result = true;
     }
     $mainframe->enqueueMessage($msg);
     $this->setState('action', 'remove');
     $this->setState('message', $installer->message);
     // re-construct the list of all language
     $this->_loadItems();
     return $result;
 }
Exemple #3
0
	/**
	 * Remove (uninstall) an extension
	 *
	 * @static
	 * @param	array	An array of identifiers
	 * @return	boolean	True on success
	 * @since 1.0
	 */
	function remove($eid=array())
	{
		global $mainframe;

		// Initialize variables
		$failed = array ();

		/*
		 * Ensure eid is an array of extension ids in the form id => client_id
		 * TODO: If it isn't an array do we want to set an error and fail?
		 */
		if (!is_array($eid)) {
			$eid = array($eid => 0);
		}

		// Get a database connector
		$db =& JFactory::getDBO();

		// Get an installer object for the extension type
		//jimport('joomla.installer.installer');
		require_once( JPATH_COMPONENT .DS. 'installer' .DS. 'installer.php' );
		$installer = & JCEInstaller::getInstance();

		// Uninstall the chosen extensions
		foreach ($eid as $id => $clientId)
		{
			$id		= trim( $id );
			$result	= $installer->uninstall($this->_type, $id, $clientId );

			// Build an array of extensions that failed to uninstall
			if ($result === false) {
				$failed[] = $id;
			}
		}

		if (count($failed)) {
			// There was an error in uninstalling the package
			$msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Error'));
			$result = false;
		} else {
			// Package uninstalled sucessfully
			$msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Success'));
			$result = true;
		}

		$mainframe->enqueueMessage($msg);
		$this->setState('action', 'remove');
		$this->setState('name', $installer->get('name'));
		$this->setState('message', $installer->message);
		$this->setState('extension.message', $installer->get('extension.message'));

		return $result;
	}
Exemple #4
0
/**
 * Installer function
 * @return
 */
function com_install()
{
    global $mainframe;
    $db = & JFactory::getDBO();

    jimport('joomla.filesystem.folder');
    jimport('joomla.filesystem.file');

    $path = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_jce';

    // Remove legacy file
    if (file_exists($path.DS.'admin.jce.php')) {
        @JFile::delete($path.DS.'admin.jce.php');
    }
    // Load updater class
    require_once ($path.DS.'updater.php');

    $updater = & JCEUpdater::getInstance();
    // Install Plugins data
    $updater->installPlugins(true);
    // Install Groups data
    $updater->installGroups(true);
    // Install editor plugin

    jimport('joomla.installer.installer');
    $installer = & JInstaller::getInstance();

    $source 	= $installer->getPath('source');

    $packages 	= $source.DS.'packages';
    // Get editor and plugin packages
	if(is_dir($packages)) {
		$editor 	= JFolder::files($packages, 'plg_jce_15\d+?\.zip', false, true);
   	 	$plugins 	= JFolder::files($packages, 'jce_\w+_15\d+?\.zip', false, true);
	}

    $language = & JFactory::getLanguage();
    $language->load('com_jce', JPATH_ADMINISTRATOR);

    $img_path	 = JURI::root().'/administrator/components/com_jce/img/';
    $out 	 	 = '<table class="adminlist" style="width:50%;">';
    $out 		.= '<tr><th class="title" style="width:65%">'.JText::_('Extension').'</th><th class="title" style="width:30%">'.JText::_('Version').'</th><th class="title" style="width:5%">&nbsp;</th></tr>';

    $editor_img 	= 'delete.png';
    $editor_result 	= JText::_('Error');
    $plugin_out 	= '';

    if (! empty($editor)) {
        if (is_file($editor[0])) {
            $config = & JFactory::getConfig();
            $tmp = $config->getValue('config.tmp_path').DS.uniqid('install_').DS.basename($editor[0], '.zip');

            if (!JArchive::extract($editor[0], $tmp)) {
                $mainframe->enqueueMessage(JText::_('EDITOR EXTRACT ERROR'), 'error');
            } else {
                $query = 'SELECT id, params'
                .' FROM #__components'
                .' WHERE link = '.$db->Quote('option=com_jce')
                ;

                $db->setQuery($query);
                $component = $db->loadObject();

                $params = explode("\n", $component->params);

                $installer = & JInstaller::getInstance();
				
				$c_manifest 	= & $installer->getManifest();
				$c_root 		= & $c_manifest->document;
				$version 		= & $c_root->getElementByPath('version');
				
				$component_version = $version->data();

                // Store Component values
                $component_paths = array (
                	'source'=>$installer->getPath('source'),
                	'manifest'=>$installer->getPath('manifest'),
               		'extension_site'=>$installer->getPath('extension_site'),
                	'extension_administrator'=>$installer->getPath('extension_administrator')
                );

                $component_vars = array (
                	'name'=>$installer->get('name'),
                	'result'=>$installer->get('result'),
                	'message'=>$installer->message
                );
                $editor_version = preg_replace('/\D+/', '', basename($editor[0]));

                // Add JTable include path
                JTable::addIncludePath(JPATH_LIBRARIES.DS.'joomla'.DS.'database'.DS.'table');
                // Editor Plugin installed proceed with plugins
                if ($installer->install($tmp)) {
                    $manifest 	= & $installer->getManifest();
                    $root 		= & $manifest->document;
                    $name 		= & $root->getElementByPath('name');
					$version 	= & $root->getElementByPath('version');
					$editor_version = $version->data();

                    $language->load('plg_editors_jce', JPATH_ADMINISTRATOR);

                    $editor_img 	= 'tick.png';
                    $editor_result 	= JText::_('Success');
					
					$query = 'UPDATE #__plugins'
					. ' SET name = '.$db->Quote($name->data())
					. ' WHERE folder = '.$db->Quote('editors')
					. ' AND element = '.$db->Quote('jce')
					;
					$db->setQuery($query);
					$db->query();

                    $params[] = 'package=1';

                    // Include installer class
                    if (! empty($plugins)) {
                        require_once ($path.DS.'installer'.DS.'installer.php');
                        $jce_installer = & JCEInstaller::getInstance();

                        $plugin_out = '<tr><th class="title" style="width:65%">'.JText::_('Plugin').'</th><th class="title" style="width:30%">'.JText::_('Version').'</th><th class="title" style="width:5%">&nbsp;</th></tr>';

                        foreach ($plugins as $plugin) {
                            // Create unique tmp dir name
                            $tmp = $config->getValue('config.tmp_path').DS.uniqid('install_').DS.basename($plugin, '.zip');
                            // Extract to tmp dir
                            if (JArchive::extract($plugin, $tmp)) {
                                // Install plugin
                                if (!$jce_installer->install($tmp)) {
                                    $plugin_img 	= 'delete.png';
                                    $plugin_result 	= JText::_('Error');
                                    $plugin_name 	= basename($plugin);
                                } else {
                                    $manifest 	= & $jce_installer->getManifest();
                                    $root 		= & $manifest->document;
                                    $name 		= & $root->getElementByPath('name');

                                    $language->load('com_jce_'.trim($root->attributes('plugin')));

                                    $plugin_img 	= 'tick.png';
                                    $plugin_result 	= JText::_('Success');
                                    $plugin_name 	= $name->data();
                                }
                                $plugin_out .= '<tr><td>'.$plugin_name.'</td><td>'.preg_replace('/\D+/', '', basename($plugin)).'</td><td style="text-align:center;">'.JHTML::image($img_path.$plugin_img, $plugin_result).'</td></tr>';
                                if ($jce_installer->get('extension.message')) {
                                    $plugin_out .= '<tr><td colspan="3">'.JText::_($jce_installer->get('extension.message')).'</td></tr>';
                                }
                                // Cleanup
                                if (is_dir($tmp)) {
                                    @JFolder::delete($tmp);
                                }
                            }
                        }
                    }
                } else {
                    $editor_img = 'delete.png';
                    $editor_result = JText::_('Error');
                    $params[] = 'package=0';
                }
                $editor_message = JText::_($installer->message);
                // Return Component Paths
                foreach ($component_paths as $k=>$v) {
                    $installer->setPath($k, $v);
                }
                // Return Component Vars
                foreach ($component_vars as $k=>$v) {
                    $installer->set($k, $v);
                }
                if (is_dir($tmp)) {
                    @JFolder::delete($tmp);
                }

                $manifest 	= & $installer->getManifest();
                $root 		= & $manifest->document;
                $version 	= & $root->getElementByPath('version');

                $out .= '<tr><td>'.JText::_('JCE ADMIN TITLE').'</td><td>'.$component_version.'</td><td class="title" style="text-align:center;">'.JHTML::image($img_path.'tick.png', JText::_('Success')).'</td></tr>';
                $out .= '<tr><td colspan="3">'.JText::_($installer->message).'</td></tr>';
                $out .= '<tr><td>'.JText::_('JCE EDITOR TITLE').'</td><td>'.$editor_version.'</td><td class="title" style="text-align:center;">'.JHTML::image($img_path.$editor_img, $editor_result).'</td></tr>';
                $out .= '<tr><td colspan="3">'.$editor_message.'</td></tr>';
                $out .= $plugin_out;
                $out .= '</table>';

                $installer->set('message', JText::_('JCE INSTALL SUMMARY'));
                $installer->set('extension.message', $out);

                $row = & JTable::getInstance('component');
                $row->load($component->id);
                $row->params = implode("\n", $params);
                $row->store();
            }
        }
    }
	if (is_dir($packages)) {
    	// Delete packages folder
    	@JFolder::delete($packages);
	}
}