Exemplo n.º 1
0
	/**
	 * @param string $type
	 * @param JInstallerFile $parent
	 * @return bool
	 */
	public function preflight($type, $parent) {
		if (!in_array($type, array('install', 'update'))) return true;

		$app = JFactory::getApplication();

		// Do not install if Kunena doesn't exist.
		if (!class_exists('KunenaForum') || !KunenaForum::isCompatible('4.0')) {
			$app->enqueueMessage(sprintf ( 'Kunena %s has not been installed, aborting!', '4.0' ), 'notice');
			return false;
		}
		if (KunenaForum::isDev()) {
			$app->enqueueMessage(sprintf ( 'You have installed Kunena from GitHub, aborting!' ), 'notice');
			return false;
		}

		// Get list of languages to be installed.
		$source = $parent->getParent()->getPath('source').'/language';
		$languages = JFactory::getLanguage()->getKnownLanguages();
		/** @var SimpleXMLElement $files */
		$files = $parent->manifest->files;
		foreach ($languages as $language) {
			$name = "com_kunena_{$language['tag']}";
			$search = JFolder::files($source, $name);
			if (empty($search)) continue;
			// Generate <file type="file" client="site" id="fi-FI">com_kunena_fi-FI_v2.0.0-BETA2-DEV2.zip</file>
			$file = $files->addChild('file', array_pop($search));
			$file->addAttribute('type', 'file');
			$file->addAttribute('client', 'site');
			$file->addAttribute('id', $name);
			echo sprintf('Installing language %s - %s ...', $language['tag'], $language['name']) . '<br />';
		}
		if (empty($files)) {
			$app->enqueueMessage(sprintf ( 'Your site is English only. There\'s no need to install Kunena language pack.' ), 'notice');
			return false;
		}

		// Remove old K1.7 style language pack.
		$table = JTable::getInstance('extension');
		$id = $table->find(array('type'=>'file', 'element'=>"kunena_language_pack"));
		if ($id) {
			$installer = new JInstaller();
			$installer->uninstall ( 'file', $id );
		}

		return true;
	}
Exemplo n.º 2
0
 public function install()
 {
     $result = parent::install();
     if ($result !== false) {
         $this->postInstall($result);
     }
     return $result;
 }
Exemplo n.º 3
0
 public function update()
 {
     $this->installtype = 'update';
     return parent::update();
 }