本文整理汇总了PHP中JInstaller::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JInstaller::getInstance方法的具体用法?PHP JInstaller::getInstance怎么用?PHP JInstaller::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JInstaller
的用法示例。
在下文中一共展示了JInstaller::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uninstall
function uninstall($parent)
{
// Post Install Log
self::_postInstallMessage('uninstall', $parent);
$db = JFactory::getDbo();
$db->setQuery('SELECT extension_id FROM #__extensions WHERE type = "package" AND element = "pkg_cck"');
$eid = $db->loadResult();
$db->setQuery('SELECT extension_id FROM #__extensions WHERE type = "plugin" AND element = "cck" AND folder="system"');
$cck = $db->loadResult();
// Uninstall FULL PACKAGE only if package exists && system plugin exists..
if ($eid && $cck) {
$manifest = JPATH_ADMINISTRATOR . '/manifests/packages/pkg_cck.xml';
if (JFile::exists($manifest)) {
$xml = JFactory::getXML($manifest);
// Keep it this way until platform 13.x
}
if (isset($xml->files)) {
unset($xml->files->file[3]);
$xml->asXML($manifest);
}
jimport('joomla.installer.installer');
$installer = JInstaller::getInstance();
$installer->uninstall('package', $eid);
}
}
示例2: preflight
/**
* method to run before an install/update/uninstall method
*
* @return void
*/
public function preflight($type, $parent)
{
// $parent is the class calling this method
//$parent->getParent()->setRedirectURL('index.php?option=com_ckeditor');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
jimport('joomla.installer.installer');
$installer = JInstaller::getInstance();
$source = $installer->getPath('source');
$packages = $source . DS . 'packages';
// Get editor package
if (is_dir($packages)) {
$editor = JFolder::files($packages, 'plg_ckeditor.zip', false, true);
}
if (!empty($editor) && is_file($editor[0])) {
$confObject = JFactory::getApplication();
$packagePath = dirname($editor[0]) . DS . 'ckeditor';
if (!JArchive::extract($editor[0], $packagePath)) {
$editor_result = JText::_('EDITOR EXTRACT ERROR');
} else {
$installer = JInstaller::getInstance();
$c_manifest = $installer->getManifest();
$c_root =& $c_manifest->document;
if (JFolder::copy($packagePath, dirname($installer->getPath('extension_site')) . DS . '..' . DS . 'plugins' . DS . 'editors', '', true)) {
$editor_result = JText::_('Success');
} else {
$editor_result = JText::_('Error');
}
}
} else {
$editor_result = JText::_('Error');
}
echo '<p>' . $editor_result . '</p>';
}
示例3: _actionDelete
/**
* Generic uninstall function
*
* @param KCommandContext A command context object
* @return KDatabaseRowset A rowset object containing the deleted rows
*/
protected function _actionDelete(KCommandContext $context)
{
$request = $this->getRequest();
$type = $this->getIdentifier()->name;
// Initialize variables
$failed = array();
// Get an installer object for the extension type
$installer = JInstaller::getInstance();
foreach ($request->id as $composite) {
$parts = explode('-', $composite);
$id = $parts[0];
$appid = isset($parts[1]) ? $parts[1] : 0;
$result = $installer->uninstall($type, $id, $appid);
// 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;
}
$controller = $this->getService('com://admin/installer.controller.install');
$controller->name($installer->get('name'));
$controller->message($installer->message);
$controller->extension_message($installer->get('extension.message'));
JFactory::getApplication()->enqueueMessage($msg);
return $controller->get();
}
示例4: installPlugin
/**
* Installation of plugins on the site
*
* @since 1.0
* @access public
*/
public function installPlugin($element, $group, $absolutePath)
{
if ($this->isDevelopment()) {
$this->setInfo('ok', true);
return $this->output();
}
// Get Joomla's installer instance
$installer = JInstaller::getInstance();
// Allow overwriting of existing plugins
$installer->setOverwrite(true);
// Install the plugin now
$state = $installer->install($absolutePath);
// Ensure that the plugins are published
if ($state) {
$group = strtolower($group);
$element = strtolower($element);
$options = array('folder' => $group, 'element' => $element);
$plugin = JTable::getInstance('Extension');
$plugin->load($options);
$plugin->state = true;
$plugin->enabled = $group == 'easyblog' && $element == 'autoarticle' ? false : true;
$plugin->store();
}
return $state;
}
示例5: install
/**
*
*/
function install()
{
$package = $this->_getPackageFromUpload();
$config =& JFactory::getConfig();
if (!$package) {
$userfile = JRequest::getVar('userfile', '', 'files', 'array');
$script = $config->getValue('config.tmp_path') . DS . $userfile['name'];
$installer =& JInstaller::getInstance();
$ar = explode(".", $script);
$ext = array_pop($ar);
switch (strtolower($ext)) {
case 'rtf':
$this->importRTF($script);
break;
case 'txt':
$this->importTxt($script);
break;
case 'fdr':
$this->importFdr($script);
break;
}
$adaptor = new JInstallerFabrikPlugin($installer);
} else {
//TODO: J1.5 deal with zipped packages
echo "a zip file - to do - deal with zipped pacakges";
}
}
示例6: getTemplates
public function getTemplates()
{
$items = array();
$tpl_path = COM_TZ_PORTFOLIO_PLUS_PATH_SITE . DIRECTORY_SEPARATOR . 'templates';
if (!JFolder::exists($tpl_path)) {
return false;
}
if ($folders = JFolder::folders($tpl_path)) {
if (count($folders)) {
foreach ($folders as $i => $folder) {
$xmlFile = $tpl_path . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . 'template.xml';
if (JFile::exists($xmlFile)) {
$installer = JInstaller::getInstance($tpl_path . DIRECTORY_SEPARATOR . $folder);
if ($manifest = $installer->isManifest($xmlFile)) {
$lang = JFactory::getLanguage();
$lang->load('tpl_' . (string) $manifest->name, $tpl_path . DIRECTORY_SEPARATOR . $folder);
$item = new stdClass();
$item->id = $i;
$item->name = (string) $manifest->name;
$item->type = (string) $manifest->type;
$item->version = (string) $manifest->version;
$item->creationDate = (string) $manifest->creationDate;
$item->author = (string) $manifest->author;
$item->authorEmail = (string) $manifest->authorEmail;
$item->description = JText::_((string) $manifest->description);
$items[] = $item;
}
}
}
}
}
return $items;
// var_dump(JFolder::folders($tpl_path)); die();
}
示例7: install
/**
* Download and install
*/
function install($id, $url)
{
if (!is_string($url)) {
return JText::_('NNEM_ERROR_NO_VALID_URL');
}
$url = 'http://' . str_replace('http://', '', $url);
if (!($target = JInstallerHelper::downloadPackage($url))) {
return JText::_('NNEM_ERROR_CANNOT_DOWNLOAD_FILE');
}
$target = JFactory::getConfig()->get('tmp_path') . '/' . $target;
NNFrameworkFunctions::loadLanguage('com_installer', JPATH_ADMINISTRATOR);
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
// Get an installer instance
$installer = JInstaller::getInstance();
// Unpack the package
$package = JInstallerHelper::unpack($target);
// Cleanup the install files
if (!is_file($package['packagefile'])) {
$config = JFactory::getConfig();
$package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile'];
}
JInstallerHelper::cleanupInstall($package['packagefile'], $package['packagefile']);
// Install the package
if (!$installer->install($package['dir'])) {
// There was an error installing the package
return JText::sprintf('COM_INSTALLER_INSTALL_ERROR', JText::_('COM_INSTALLER_TYPE_TYPE_' . strtoupper($package['type'])));
}
return true;
}
示例8: preflight
function preflight($type, $parent)
{
//check if php version is supported before proceed with installation.
$phpVersion = floatval(phpversion());
if ($phpVersion < 5) {
$mainframe = JFactory::getApplication();
$mainframe->enqueueMessage('Installation was unsuccessful because you are using an unsupported version of PHP. Komento supports only PHP5 and above. Please kindly upgrade your PHP version and try again.', 'error');
return false;
}
//get source path and version number from manifest file.
$installer = JInstaller::getInstance();
$manifest = $installer->getManifest();
$sourcePath = $installer->getPath('source');
$this->message = array();
$this->status = true;
$this->sourcePath = $sourcePath;
$file = $this->sourcePath . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'install.default.php';
if (JFile::exists($file)) {
require_once $file;
}
//this is needed as joomla failed to remove it themselve during uninstallation or failed attempt of installation
if (class_exists('KomentoMenuMaintenance')) {
KomentoMenuMaintenance::removeAdminMenu();
}
return true;
}
示例9: getPluginTemplate
public function getPluginTemplate($id)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('folder');
$query->from('#__judownload_plugins');
$query->where('id = ' . $id);
$query->where('type = ' . $db->quote('plugin'));
$db->setQuery($query);
$folder = $db->loadResult();
if ($folder) {
$pluginFolderPath = JPATH_SITE . '/components/com_judownload/plugins/' . $folder;
$installer = JInstaller::getInstance();
$installer->setPath("source", $pluginFolderPath);
$installer->findManifest();
$xml = $installer->getManifest();
$templateFolder = null;
if (isset($xml->templateFolder)) {
$templateFolder = $xml->templateFolder->__toString();
} else {
$templateFolder = 'tmpl';
}
if (JFolder::exists($pluginFolderPath . '/' . $templateFolder . '/')) {
$asset_file = $pluginFolderPath . '/load_assets.php';
if (JFILE::exists($asset_file)) {
include $asset_file;
}
return $pluginFolderPath . '/' . $templateFolder . '/';
} else {
return false;
}
}
return false;
}
示例10: getAutoInstance
/**
* Get a model instance.
*
* @param string $name Model name
* @param mixed $client Client. null = auto, 1 = admin, 0 = frontend
* @param array $config An optional array of configuration
* @param string $option Component name, use for call model from modules
*
* @return RModel The model
*
* @throws InvalidArgumentException
*/
public static function getAutoInstance($name, $client = null, array $config = array(), $option = 'auto')
{
if ($option === 'auto') {
$option = JFactory::getApplication()->input->getString('option', '');
// Add com_ to the element name if not exist
$option = (strpos($option, 'com_') === 0 ? '' : 'com_') . $option;
if ($option == 'com_installer') {
$installer = JInstaller::getInstance();
$option = $installer->manifestClass->getElement($installer);
}
}
$componentName = ucfirst(strtolower(substr($option, 4)));
$prefix = $componentName . 'Model';
if (is_null($client)) {
$client = (int) JFactory::getApplication()->isAdmin();
}
// Admin
if ($client === 1) {
self::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . $option . '/models');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/' . $option . '/tables');
} elseif ($client === 0) {
self::addIncludePath(JPATH_SITE . '/components/' . $option . '/models');
JTable::addIncludePath(JPATH_SITE . '/components/' . $option . '/tables');
} else {
throw new InvalidArgumentException(sprintf('Cannot instanciate the model %s in component %s. Invalid client %s.', $name, $option, $client));
}
$model = self::getInstance($name, $prefix, $config);
if (!$model instanceof JModel && !$model instanceof JModelLegacy) {
throw new InvalidArgumentException(sprintf('Cannot instanciate the model %s in component %s. Invalid client %s.', $name, $option, $client));
}
return $model;
}
示例11: install
public function install()
{
$session = JFactory::getSession();
$tempdir = $session->get('tempdir', '', 'liveupdate');
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
$installer = JInstaller::getInstance();
$packageType = JInstallerHelper::detectType($tempdir);
if (!$packageType) {
$msg = JText::_('LIVEUPDATE_INVALID_PACKAGE_TYPE');
$result = false;
} elseif (!$installer->install($tempdir)) {
// There was an error installing the package
$msg = JText::sprintf('LIVEUPDATE_INSTALLEXT', JText::_($packageType), JText::_('LIVEUPDATE_Error'));
$result = false;
} else {
// Package installed sucessfully
$msg = JText::sprintf('LIVEUPDATE_INSTALLEXT', JText::_($packageType), JText::_('LIVEUPDATE_Success'));
$result = true;
}
$app = JFactory::getApplication();
$app->enqueueMessage($msg);
$this->setState('result', $result);
$this->setState('packageType', $packageType);
if ($packageType) {
$this->setState('name', $installer->get('name'));
$this->setState('message', $installer->message);
if (version_compare(JVERSION, '1.6.0', 'ge')) {
$this->setState('extmessage', $installer->get('extension_message'));
} else {
$this->setState('extmessage', $installer->get('extension.message'));
}
}
return $result;
}
示例12: install
/**
* install plugin
*/
function install()
{
require_once dirname(__FILE__) . DS . "adapter" . DS . "fabrikplugin.php";
$package = $this->_getPackageFromUpload();
// Was the package unpacked?
if (!$package) {
$this->setState('message', JText::_('UNABLE TO INSTALL PACKAGE FILE'));
return false;
}
$installer =& JInstaller::getInstance();
$this->setState('action', 'install');
$adaptor = new JInstallerFabrikPlugin($installer);
//test fro php 4.x??? seems to work
$adaptor->parent->setPath('source', $package['dir']);
//end test
$installer->setAdapter("fabrikplugin", $adaptor);
// 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;
}
// 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;
}
示例13: com_uninstall
function com_uninstall()
{
// Initialize the Joomla! installer
jimport('joomla.installer.installer');
$installer = JInstaller::getInstance();
// Select all MageBridge modules and remove them
$db = JFactory::getDBO();
$query = "SELECT `id`,`client_id` FROM #__modules WHERE `module` LIKE 'mod_magebridge%'";
$db->setQuery($query);
$rows = $db->loadObjectList();
if (!empty($rows)) {
foreach ($rows as $row) {
$installer->uninstall('module', $row->id, $row->client_id);
}
}
// Select all MageBridge plugins and remove them
$db = JFactory::getDBO();
$query = "SELECT `id`,`client_id` FROM #__plugins WHERE `element` LIKE 'magebridge%' OR `folder` = 'magento'";
$db->setQuery($query);
$rows = $db->loadObjectList();
if (!empty($rows)) {
foreach ($rows as $row) {
$installer->uninstall('plugin', $row->id, $row->client_id);
}
}
// Done
return true;
}
示例14: postflight
public function postflight($type, $parent, $results)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$adm_path = str_replace(array('/administrator', '\\administrator'), '', JPATH_BASE);
$installer = JInstaller::getInstance();
$manifest = $installer->getManifest();
$sourcePath = $installer->getPath('source');
$db->setQuery("DELETE FROM `#__extensions` WHERE `element` = 'pkg_ukUA'");
$db->query();
$jun = $db->getQuery(true);
$jun = "UPDATE `#__modules` SET `position` = 'cpanel', `published` = 1, `showtitle` = 0, `ordering` = 99 WHERE `module` = 'mod_junews' AND `client_id` = 1";
$db->setQuery($jun);
$db->query();
$jun1 = $db->getQuery(true);
$jun1 = "INSERT INTO #__modules_menu (moduleid, menuid) SELECT #__modules.id, 0 FROM #__modules WHERE #__modules.module = 'mod_junews' AND #__modules.position = 'cpanel' AND NOT EXISTS (SELECT 1 FROM #__modules_menu WHERE moduleid = #__modules.id) ORDER BY id DESC LIMIT 1";
$db->setQuery($jun1);
$db->query();
$jum = $db->getQuery(true);
$jum = "UPDATE `#__modules` SET `position` = 'menu', `published` = 1, `showtitle` = 0, `ordering` = 99 WHERE `module` = 'mod_jumenu' AND `client_id` = 1";
$db->setQuery($jum);
$db->query();
$jum1 = $db->getQuery(true);
$jum1 = "INSERT INTO #__modules_menu (moduleid, menuid) SELECT #__modules.id, 0 FROM #__modules WHERE #__modules.module = 'mod_jumenu' AND #__modules.position = 'menu' AND NOT EXISTS (SELECT 1 FROM #__modules_menu WHERE moduleid = #__modules.id) ORDER BY id DESC LIMIT 1";
$db->setQuery($jum1);
$db->query();
$manifestua = $adm_path . '/administrator/manifests/packages/pkg_ukUA.xml';
if (file_exists($manifestua)) {
unlink($manifestua);
}
if (is_dir(JPATH_BASE . '/manifests/packages/ukUA')) {
Pkg_ukUAInstallerScript::unlinkRecursive(JPATH_BASE . '/manifests/packages/ukUA/', 0);
}
return true;
}
示例15: display
public function display($tpl = null)
{
$paths = new stdClass();
$paths->first = '';
$this->assignRef('paths', $paths);
$this->state = $this->get('State');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->form = $this->get('Form');
if ($this->getLayout() == 'distribution') {
jimport('joomla.installer.installer');
// Extract the list and return it
$installer = JInstaller::getInstance();
$installer->setPath('source', $this->state->get('install.directory'));
$manifest = $installer->getManifest();
$result = false;
if ($manifest) {
$result->extensions = isset($manifest->extensions) ? $manifest->extensions : false;
$result->sql = isset($manifest->install->sql->file) ? $installer->getPath('source') . '/' . $manifest->install->sql->file : false;
$result->script = isset($manifest->scriptfile) ? $installer->getPath('source') . '/' . $manifest->scriptfile : false;
if ($result->script) {
include $installer->getPath('source') . '/' . $manifest->scriptfile;
$class = JRequest::$manifest->name . 'InstallerScript';
$script = new $class();
$result->scriptclass = $class;
$result->preflight = method_exists($script, 'preflight') ? $installer->getPath('source') . '/' . $manifest->scriptfile : false;
$result->postflight = method_exists($script, 'postflight') ? $installer->getPath('source') . '/' . $manifest->scriptfile : false;
}
}
$this->source = base64_encode($installer->getPath('source'));
$this->result = $result;
}
parent::display($tpl);
}