本文整理汇总了PHP中JInstaller类的典型用法代码示例。如果您正苦于以下问题:PHP JInstaller类的具体用法?PHP JInstaller怎么用?PHP JInstaller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JInstaller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
function update($parent)
{
$manifest = $parent->get("manifest");
$parent = $parent->getParent();
$source = $parent->getPath("source");
foreach ($manifest->plugins->plugin as $plugin) {
$installer = new JInstaller();
$attributes = $plugin->attributes();
$plg = $source . "/" . $attributes['folder'] . "/" . $attributes['plugin'];
$installer->install($plg);
}
$db = JFactory::getDBO();
// Fixes a Joomla bug, wich adds a second repository rather than overwrite the first one if they are different
$query = "DELETE FROM `#__update_sites` WHERE `name` = '" . $this->extension_name . " update site';";
$db->setQuery($query);
$db->query();
$query = "DELETE FROM `#__update_sites` WHERE `name` = 'Ozio Gallery3 update site';";
$db->setQuery($query);
$db->query();
// Clear updates cache related to this extension
$query = "DELETE FROM `#__updates` WHERE `name` = '" . $this->extension_name . "';";
$db->setQuery($query);
$db->query();
// Shows the installation/upgrade message
$this->message();
}
示例2: installExtensions
function installExtensions($extPath = null)
{
//if no path defined, use default path
if ($extPath == null) {
$extPath = dirname(__FILE__) . DS . 'extensions';
}
if (!JFolder::exists($extPath)) {
return false;
}
$extensions = JFolder::folders($extPath);
//no apps there to install
if (empty($extensions)) {
return true;
}
//get instance of installer
$installer = new JInstaller();
$installer->setOverwrite(true);
//install all apps
foreach ($extensions as $ext) {
$msg = "Supportive Plugin/Module {$ext} Installed Successfully";
// Install the packages
if ($installer->install($extPath . DS . $ext) == false) {
$msg = "Supportive Plugin/Module {$ext} Installation Failed";
}
//enque the message
JFactory::getApplication()->enqueueMessage($msg);
}
return true;
}
示例3: postflight
function postflight($type, $parent)
{
$db = JFactory::getDBO();
$status = new stdClass();
$status->plugins = array();
$src = $parent->getParent()->getPath('source');
$manifest = $parent->getParent()->manifest;
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $key => $plugin) {
$name = (string) $plugin->attributes()->plugin;
$group = (string) $plugin->attributes()->group;
$path = $src . '/plugins/' . $group;
if (JFolder::exists($src . '/plugins/' . $group . '/' . $name)) {
$path = $src . '/plugins/' . $group . '/' . $name;
}
$installer = new JInstaller();
$result = $installer->install($path);
if ($result) {
$query = "UPDATE #__extensions SET enabled=1 WHERE type='plugin' AND element=" . $db->Quote($name) . " AND folder=" . $db->Quote($group);
$db->setQuery($query);
$db->query();
}
}
$template_path = $src . '/template';
if (JFolder::exists($template_path)) {
$installer = new JInstaller();
$installer->install($template_path);
}
$conf = JFactory::getConfig();
$conf->set('debug', false);
$parent->getParent()->abort();
}
示例4: postflight
function postflight($type, $parent)
{
$db = JFactory::getDBO();
$mod_sp_poll = $parent->getParent()->getPath('source') . '/mod_sp_poll';
$installer = new JInstaller();
$installer->install($mod_sp_poll);
}
示例5: install
public function install($adapter)
{
/** @var $plugin JTableExtension */
$plugin = JTable::getInstance('extension');
if (!$plugin->load(array('type' => 'plugin', 'folder' => 'system', 'element' => 'communitybuilder'))) {
return false;
}
/** @var $legacy JTableExtension */
$legacy = JTable::getInstance('extension');
if ($legacy->load(array('type' => 'plugin', 'folder' => 'system', 'element' => 'cbcoreredirect'))) {
$pluginParams = new JRegistry();
$pluginParams->loadString($plugin->get('params'));
$legacyParams = new JRegistry();
$legacyParams->loadString($legacy->get('params'));
$pluginParams->set('rewrite_urls', $legacyParams->get('rewrite_urls', 1));
$pluginParams->set('itemids', $legacyParams->get('itemids', 1));
$plugin->set('params', $pluginParams->toString());
$installer = new JInstaller();
try {
$installer->uninstall('plugin', $legacy->get('extension_id'));
} catch (RuntimeException $e) {
}
}
$plugin->set('enabled', 1);
return $plugin->store();
}
示例6: uninstall
function uninstall($parent)
{
$db = JFactory::getDBO();
$manifest = $parent->getParent()->manifest;
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $plugin) {
$name = (string) $plugin->attributes()->plugin;
$group = (string) $plugin->attributes()->group;
$query = $db->getQuery(true);
$query->select($db->quoteName('extension_id'));
$query->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('type') . ' = ' . $db->Quote('plugin'));
$query->where($db->quoteName('element') . ' = ' . $db->Quote($name));
$query->where($db->quoteName('folder') . ' = ' . $db->Quote($group));
$db->setQuery($query);
$extensions = $db->loadColumn();
if (count($extensions)) {
foreach ($extensions as $id) {
$installer = new JInstaller();
$installer->uninstall('plugin', $id);
}
}
}
self::displayDonation();
}
示例7: uninstall
/**
* method to uninstall the component
*
* @return void
*/
function uninstall($parent)
{
return;
//XXX not working, need to install all plugins/modules separately
// $parent is the class calling this method
echo '<p>' . JText::_('COM_HELLOWORLD_UNINSTALL_TEXT') . '</p>';
$manifest = $parent->get("manifest");
$parent = $parent->getParent();
$source = $parent->getPath("source");
$installer = new JInstaller();
$db = JFactory::getDBO();
// Install plugins
foreach ($manifest->plugins->plugin as $plugin) {
$attributes = $plugin->attributes();
$plg = $source . '/' . $attributes['folder'] . '/' . $attributes['plugin'];
$plg = $source . '/' . $attributes['folder'];
$name = $attributes['plugin'];
/* print_r ($attributes);
echo "X";
$type = 'user';
$data = JPluginHelper::getPlugin ($type, 'joomdlehooks');
print_r ($data);
*/
$query = 'SELECT extension_id ' . ' FROM #__extensions' . " WHERE name = '{$name}'";
$db->setQuery($query);
$extension_id = $db->loadResult();
$installer->uninstall('plugin', $extension_id);
}
}
示例8: uninstall
/**
* method to uninstall the component
*
* @return void
*/
function uninstall($parent)
{
// $parent is the class calling this method
//echo '<p>' . JText::_('COM_HELLOWORLD_UNINSTALL_TEXT') . '</p>';
$db =& JFactory::getDBO();
// uninstalling jumi module
$db->setQuery("select extension_id from #__extensions where name = 'Jumi' and type = 'module' and element = 'mod_jumi'");
$jumi_module = $db->loadObject();
$module_uninstaller = new JInstaller();
if (@$module_uninstaller->uninstall('module', $jumi_module->extension_id)) {
echo 'Module uninstall success', '<br />';
} else {
echo 'Module uninstall failed', '<br />';
}
// uninstalling jumi plugin
$db->setQuery("select extension_id from #__extensions where name = 'System - Jumi' and type = 'plugin' and element = 'jumi'");
$jumi_plugin = $db->loadObject();
$plugin_uninstaller = new JInstaller();
if ($plugin_uninstaller->uninstall('plugin', $jumi_plugin->extension_id)) {
echo 'Plugin uninstall success', '<br />';
} else {
echo 'Plugin uninstall failed', '<br />';
}
// uninstalling jumi router
$db->setQuery("select extension_id from #__extensions where name = 'System - Jumi Router' and type = 'plugin' and element = 'jumirouter'");
$jumi_router = $db->loadObject();
$plugin_uninstaller = new JInstaller();
if ($plugin_uninstaller->uninstall('plugin', $jumi_router->extension_id)) {
echo 'Router uninstall success', '<br />';
} else {
echo 'Router uninstall failed', '<br />';
}
}
示例9: installGiantExtensionsPlugin
private function installGiantExtensionsPlugin()
{
$pluginPath = dirname(__FILE__) . '/plg_content_giantcontent.zip';
$installResult = JInstallerHelper::unpack($pluginPath);
if (empty($installResult)) {
$app = JFactory::getApplication();
$app->enqueueMessage('Giant Content can not install "Content - Giant Content" plugin. Please install plugin manually inside package.', 'error');
return false;
}
$installer = new JInstaller();
$installer->setOverwrite(true);
if (!$installer->install($installResult['extractdir'])) {
$app = JFactory::getApplication();
$app->enqueueMessage('Giant Content can not install "Content - Giant Content" plugin. Please install plugin manually inside package.', 'error');
return false;
}
$db = JFactory::getDBO();
$db->setQuery('UPDATE #__extensions SET enabled = 1 WHERE type = "plugin" AND folder = "content" AND element = "giantcontent"');
$db->query();
if ($db->getErrorNum()) {
$app = JFactory::getApplication();
$app->enqueueMessage('Giant Content can not enable "Content - Giant Content" plugin. Please enable plugin manually in the plugin manager.', 'warning');
}
return true;
}
示例10: install
function install()
{
$pkg_path = JPATH_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . $this->com . DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR;
if (JFolder::exists($pkg_path . 'nextend')) {
$librariesPath = defined('JPATH_LIBRARIES') ? JPATH_LIBRARIES : JPATH_PLATFORM;
JFolder::copy($pkg_path . 'nextend', $librariesPath . DIRECTORY_SEPARATOR . 'nextend', '', true);
JFolder::delete($pkg_path . 'nextend');
}
$extensions = array_merge(JFolder::folders($pkg_path, '^(?!com_)\\w+$'), JFolder::folders($pkg_path, '^com_\\w+$'));
if (version_compare(JVERSION, '3.0.0', 'ge')) {
foreach ($extensions as $pkg) {
$f = $pkg_path . DIRECTORY_SEPARATOR . $pkg;
$xmlfiles = JFolder::files($f, '.xml$', 1, true);
foreach ($xmlfiles as $xmlf) {
$file = file_get_contents($xmlf);
file_put_contents($xmlf, preg_replace("/<\\/install/", "</extension", preg_replace("/<install/", "<extension", $file)));
}
}
}
foreach ($extensions as $pkg) {
$installer = new JInstaller();
$installer->setOverwrite(true);
if ($success = $installer->install($pkg_path . DIRECTORY_SEPARATOR . $pkg)) {
$msgcolor = "#E0FFE0";
$name = version_compare(JVERSION, '1.6.0', 'l') ? $installer->getManifest()->document->name[0]->data() : $installer->getManifest()->name;
$msgtext = $name . " successfully installed.";
} else {
$msgcolor = "#FFD0D0";
$msgtext = "ERROR: Could not install the {$pkg}. Please contact us on our support page: http://www.nextendweb.com/help/support";
}
?>
<table bgcolor="<?php
echo $msgcolor;
?>
" width ="100%">
<tr style="height:30px">
<td><font size="2"><b><?php
echo $msgtext;
?>
</b></font></td>
</tr>
</table><?php
if ($success && file_exists("{$pkg_path}/{$pkg}/install.php")) {
require_once "{$pkg_path}/{$pkg}/install.php";
$com = new $pkg();
$com->install();
}
}
$db = JFactory::getDBO();
if (version_compare(JVERSION, '1.6.0', 'lt')) {
$db->setQuery("UPDATE #__plugins SET published=1 WHERE name LIKE '%nextend%'");
} else {
$db->setQuery("UPDATE #__extensions SET enabled=1 WHERE name LIKE '%nextend%' AND type='plugin'");
}
$db->query();
if (JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR)) {
JFolder::delete(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
JFolder::create(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'dojo' . DIRECTORY_SEPARATOR);
}
}
示例11: installHotelPackages
function installHotelPackages()
{
jimport('joomla.installer.installer');
// Install Package Manager
$basedir = dirname(__FILE__);
$packageDir = JPATH_ADMINISTRATOR . '/components/com_jhotelreservation/extensions';
if (!is_dir($packageDir)) {
$packageDir = $basedir . '/admin/extensions';
}
$extensionsDirs = JFolder::folders($packageDir);
foreach ($extensionsDirs as $extensionDir) {
$tmpInstaller = new JInstaller();
if (!$tmpInstaller->update($packageDir . '/' . $extensionDir)) {
JError::raiseWarning(100, "Extension :" . $extensionDir);
}
}
$db = JFactory::getDBO();
$db->setQuery(" UPDATE #__extensions SET enabled=1 WHERE name='Hotel Url Translator' ");
$db->query();
$db = JFactory::getDBO();
$db->setQuery(" UPDATE #__extensions SET enabled=1 WHERE name='Hotel Gallery' ");
$db->query();
$path = JPATH_ADMINISTRATOR . '/components/com_jhotelreservation/help/readme.html';
?>
<div style="text-align: left; float: left;">
<?php
include $path;
?>
</div>
<?php
}
示例12: com_install
/**
* Main installer
*/
function com_install()
{
$errors = FALSE;
//-- common images
$img_OK = '<img src="images/publish_g.png" />';
$img_WARN = '<img src="images/publish_y.png" />';
$img_ERROR = '<img src="images/publish_r.png" />';
$BR = '<br />';
//--install...
$db =& JFactory::getDBO();
$query = "CREATE TABLE IF NOT EXISTS `#__friendmanager` ( " . "`id` int(11) NOT NULL auto_increment, " . "`backupdate` datetime NOT NULL, " . "`msg` varchar(50) NOT NULL default '', " . "PRIMARY KEY (`id`) " . ")";
$db->setQuery($query);
if (!$db->query()) {
echo $img_ERROR . JText::_('Unable to create table') . $BR;
echo $db->getErrorMsg();
return FALSE;
}
// Install plg_geocode
$plugin_installer = new JInstaller();
if ($plugin_installer->install(dirname(__FILE__) . DS . 'plg_firstfriend')) {
echo "<br/><hr><h1>First Friend Plugin Installed and Published " . $img_OK . "</h1><hr><br />";
} else {
echo "<br/><hr><h1>First Friend Plugin Not Installed " . $img_ERROR . "</h1><hr><br />";
}
// Enable plg_geocode
$db->setQuery("UPDATE #__plugins SET published = 1 WHERE " . "name = 'FirstFriend' ");
$db->query();
return TRUE;
}
示例13: postflight
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
function postflight($type, $parent)
{
$manifest = $parent->getParent()->getManifest();
if ($type != 'uninstall' && !$this->_installAllowed($manifest)) {
return false;
}
// Remove AjaxHelpAry
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('extension_id', 'name', 'params', 'element'));
$query->from('#__extensions');
$query->where($db->quoteName('element') . ' = ' . $db->quote('ajaxhelpary'));
$query->where($db->quoteName('folder') . ' = ' . $db->quote('ajax'));
$db->setQuery($query);
$row = $db->loadAssoc();
if (!empty($row)) {
$installer = new JInstaller();
$res = $installer->uninstall('plugin', $row['extension_id']);
if ($res) {
$msg = '<b style="color:green">' . JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $row['name']) . '</b>';
} else {
$msg = '<b style="color:red">' . JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $row['name']) . '</b>';
}
$this->messages[] = $msg;
}
parent::postflight($type, $parent, $publishPlugin = true);
}
示例14: onExtensionAfterUpdate
/**
* After update of an extension.
*
* @param JInstaller $installer Installer object
* @param integer $eid Extension identifier
*/
public function onExtensionAfterUpdate($installer, $eid)
{
$msg = '';
$msg .= $eid === false ? 'Failed extension update: ' . $installer->getError() : 'Extension update successful';
$msg .= $eid ? ' with updated extension ID ' . $eid : ' with no extension ID detected or multiple extension IDs assigned';
JLog::add($msg, JLog::INFO, __METHOD__);
}
示例15: uninstall
/**
* method to uninstall the component
*
* @return void
*/
function uninstall($parent)
{
$installer = new JInstaller();
$db = JFactory::getDbo();
$tableExtensions = "#__extensions";
//$db->quote("#__extensions");
$columnElement = "element";
//$db->quote("element");
$columnType = "type";
//$db->quote("type");
$columnFolder = "folder";
//$db->quote("folder");
// Find AdmirorGallery plugin ID
$db->setQuery("SELECT extension_id\n\t\t\t\tFROM \n\t\t\t\t\t{$tableExtensions}\n\t\t\t\tWHERE\n\t\t\t\t\t{$columnElement}='admirorgallery'\n\t\t\t\tAND\n\t\t\t\t\t{$columnType}='plugin'\n\t\t\t\tAND\n\t\t\t\t\t{$columnFolder}='content'");
$admirorgallery_id = $db->loadResult();
$this->gallery_uninstall_result = $installer->uninstall('plugin', $admirorgallery_id);
// Find AdmirorButton ID
$db->setQuery("SELECT extension_id\n\t\t\t\tFROM \n\t\t\t\t\t{$tableExtensions}\n\t\t\t\tWHERE\n\t\t\t\t\t{$columnElement}='admirorbutton'\n\t\t\t\tAND\n\t\t\t\t\t{$columnType}='plugin'\n\t\t\t\tAND\n\t\t\t\t\t{$columnFolder}='editors-xtd'");
$admirorbutton_id = $db->loadResult();
$this->button_uninstall_result = $installer->uninstall('plugin', $admirorbutton_id);
$gallery_status = $this->gallery_uninstall_result ? JText::_('Removed') : JText::_('Error');
$button_status = $this->button_uninstall_result ? JText::_('Removed') : JText::_('Error');
$html = '<h2>Admiror Gallery ' . JText::_('Uninstall') . '</h2>
<table class="adminlist">
<thead>
<tr>
<th class="title" colspan="2">' . JText::_('Extension') . '</th>
<th width="30%">' . JText::_('Status') . '</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3"></td>
</tr>
</tfoot>
<tbody>
<tr class="row0">
<td class="key" colspan="2">Admiror Gallery ' . JText::_('Component') . '</td>
<td><strong>' . JText::_('Removed') . '</strong></td>
</tr>
<tr class="row1">
<th>' . JText::_('Plugin') . '</th>
<th>' . JText::_('Group') . '</th>
<th></th>
</tr>
<tr class="row0">
<td class="key">' . ucfirst('Admiror Gallery Plugin') . '</td>
<td class="key">' . ucfirst('content') . '</td>
<td><strong>' . $gallery_status . '</strong></td>
</tr>
<tr class="row0">
<td class="key">' . ucfirst('Admiror Button') . '</td>
<td class="key">' . ucfirst('editors-xtd') . '</td>
<td><strong>' . $button_status . '</strong></td>
</tr>
</tbody>
</table>';
echo $html;
}