本文整理汇总了PHP中JInstallerHelper类的典型用法代码示例。如果您正苦于以下问题:PHP JInstallerHelper类的具体用法?PHP JInstallerHelper怎么用?PHP JInstallerHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JInstallerHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
public function install(InputInterface $input, OutputInterface $output)
{
$app = Bootstrapper::getApplication($this->target_dir);
// Output buffer is used as a guard against Joomla including ._ files when searching for adapters
// See: http://kadin.sdf-us.org/weblog/technology/software/deleting-dot-underscore-files.html
ob_start();
$installer = $app->getInstaller();
foreach ($this->extension as $package) {
$remove = false;
if (is_file($package)) {
$result = \JInstallerHelper::unpack($package);
$directory = isset($result['dir']) ? $result['dir'] : false;
$remove = true;
} else {
$directory = $package;
}
if ($directory !== false) {
$path = realpath($directory);
if (!file_exists($path)) {
$output->writeln("<info>File not found: " . $directory . "</info>\n");
continue;
}
try {
$installer->install($path);
} catch (\Exception $e) {
$output->writeln("<info>Caught exception during install: " . $e->getMessage() . "</info>\n");
}
if ($remove) {
\JFolder::delete($path);
}
}
}
ob_end_clean();
}
示例2: getPackageFromUpload
function getPackageFromUpload()
{
$install_file = JRequest::getVar('package', null, 'files', 'array');
if (!(bool) ini_get('file_uploads')) {
$msg = 'File upload function is disabled, please enable it in file "php.ini"';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
if (!extension_loaded('zlib')) {
$msg = 'Zlib library is disabled, please enable it in file "php.ini"';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
if ($install_file['name'] == '') {
$msg = 'The package is not selected, please download and select it';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
if (JFile::getExt($install_file['name']) != 'zip') {
$msg = 'The package has incorrect format, please use exactly the file you downloaded';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
$tmp_dest = JPATH_ROOT . DS . 'tmp' . DS . $install_file['name'];
$tmp_src = $install_file['tmp_name'];
if (!JFile::upload($tmp_src, $tmp_dest)) {
$msg = 'Folder "tmp" is Unwritable, please set it to Writable (chmod 777). You can set the folder back to Unwritable after sample data installation';
JError::raiseWarning('SOME_ERROR_CODE', JText::_($msg));
return false;
}
$package = JInstallerHelper::unpack($tmp_dest);
return $package;
}
示例3: 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;
}
示例4: runSQL
protected function runSQL($source, $file)
{
$db = JFactory::getDbo();
$driver = strtolower($db->name);
if ($driver == 'mysqli') {
$driver = 'mysql';
} elseif ($driver == 'sqlsrv') {
$driver = 'sqlazure';
}
$sqlfile = $source . '/sql/' . $driver . '/' . $file;
if (file_exists($sqlfile)) {
$buffer = file_get_contents($sqlfile);
if ($buffer !== false) {
$queries = JInstallerHelper::splitSql($buffer);
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query[0] != '#') {
$db->setQuery($query);
if (!$db->execute()) {
JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)));
}
}
}
}
}
}
示例5: querySQL
function querySQL($buffer)
{
$db =& JFactory::getDBO();
// Graceful exit and rollback if read not successful
if ($buffer === false) {
return false;
}
// Create an array of queries from the sql file
jimport('joomla.installer.helper');
$queries = JInstallerHelper::splitSql($buffer);
if (count($queries) == 0) {
// No queries to process
return 0;
}
// Process each query in the $queries array (split out of sql file).
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query[0] != '#') {
$db->setQuery($query);
if (!$db->query()) {
JError::raiseWarning(1, 'JInstaller::install: ' . JText::_('SQL Error') . " " . $db->stderr(true));
return false;
}
}
}
return true;
}
示例6: update
function update($parent)
{
$db = JFactory::getDBO();
if (method_exists($parent, 'extension_root')) {
$sqlfile = $parent->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql';
} else {
$sqlfile = $parent->getParent()->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql';
}
// Don't modify below this line
$buffer = file_get_contents($sqlfile);
if ($buffer !== false) {
jimport('joomla.installer.helper');
$queries = JInstallerHelper::splitSql($buffer);
if (count($queries) != 0) {
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query[0] != '#') {
$db->setQuery($query);
if (!$db->query()) {
CJFunctions::throw_error(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), 1);
return false;
}
}
}
}
}
echo '<p>' . JText::sprintf('COM_CJBLOG_UPDATE_TEXT', $parent->get('manifest')->version) . '</p>';
}
示例7: postflight
function postflight($type, $parent)
{
if ($type == 'update') {
$sqlfile = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_rsform' . DS . 'install.rsform.utf8.sql';
$buffer = file_get_contents($sqlfile);
if ($buffer === false) {
JError::raiseWarning(1, JText::_('JLIB_INSTALLER_ERROR_SQL_READBUFFER'));
return false;
}
jimport('joomla.installer.helper');
$queries = JInstallerHelper::splitSql($buffer);
if (count($queries) == 0) {
// No queries to process
return 0;
}
$db =& JFactory::getDBO();
// Process each query in the $queries array (split out of sql file).
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query[0] != '#') {
$db->setQuery($query);
if (!$db->query()) {
JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)));
return false;
}
}
}
}
}
示例8: 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;
}
示例9: installPluginTableByThemeName
function installPluginTableByThemeName($themeName)
{
jimport('joomla.filesystem.file');
$sqlFile = JPATH_PLUGINS . DS . $this->_pluginType . DS . $themeName . DS . $this->_installFile;
if (JFile::exists($sqlFile)) {
$objJNSUtils = JSNISFactory::getObj('classes.jsn_is_utils');
$buffer = $objJNSUtils->readFileToString($sqlFile);
if ($buffer === false) {
return false;
}
jimport('joomla.installer.helper');
$queries = JInstallerHelper::splitSql($buffer);
if (count($queries) == 0) {
JError::raiseWarning(100, $sqlFile . JText::_(' not exits'));
return 0;
}
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query[0] != '#') {
$this->_db->setQuery($query);
if (!$this->_db->query()) {
JError::raiseWarning(100, 'JInstaller::install: ' . JText::_('SQL Error') . " " . $this->_db->stderr(true));
return false;
}
}
}
return true;
} else {
JError::raiseWarning(100, $sqlFile . JText::_(' not exits'));
return false;
}
}
示例10: update
function update($parent)
{
$db = JFactory::getDBO();
if (method_exists($parent, 'extension_root')) {
$sqlfile = $parent->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql';
} else {
$sqlfile = $parent->getParent()->getPath('extension_root') . DS . 'sql' . DS . 'install.mysql.utf8.sql';
}
// Don't modify below this line
$buffer = file_get_contents($sqlfile);
if ($buffer !== false) {
jimport('joomla.installer.helper');
$queries = JInstallerHelper::splitSql($buffer);
if (count($queries) != 0) {
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query[0] != '#') {
$db->setQuery($query);
if (!$db->query()) {
JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)));
return false;
}
}
}
}
}
echo '<p>' . JText::_('COM_COMMUNITYSURVEYS_UPDATE_TEXT') . '</p>';
$parent->getParent()->setRedirectURL('index.php?option=com_communitysurveys&view=dashboard');
}
示例11: update
function update($parent)
{
$db = JFactory::getDBO();
if (method_exists($parent, 'extension_root')) {
$sqlfile = $parent->getPath('extension_root') . '/sql/install.mysql.sql';
} else {
$sqlfile = $parent->getParent()->getPath('extension_root') . '/sql/install.mysql.sql';
}
// Don't modify below this line
$buffer = file_get_contents($sqlfile);
if ($buffer !== false) {
jimport('joomla.installer.helper');
$queries = JInstallerHelper::splitSql($buffer);
if (count($queries) != 0) {
foreach ($queries as $query) {
$query = trim($query);
if ($query != '' && $query[0] != '#') {
$db->setQuery($query);
if (!$db->query()) {
JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)));
return false;
}
}
}
}
}
}
示例12: _installPackage
function _installPackage()
{
$installer = JSNISInstaller::getInstance();
if ($this->_packageExtract) {
$objJSNPlugins = JSNISFactory::getObj('classes.jsn_is_plugins');
$countSource = count($this->_listCurrentSources);
$currentSources = array();
if ($countSource) {
for ($i = 0; $i < $countSource; $i++) {
$item = $this->_listCurrentSources[$i];
$currentSources[$item->element] = $objJSNPlugins->getXmlFile($item);
}
}
if (!$installer->install($this->_packageExtract['dir'])) {
$this->_msgError = JText::_('INSTALLER_IMAGE_SOURCE_PACKAGE_UNSUCCESSFULLY_INSTALLED');
$this->_error = true;
return false;
}
$this->_upgradeSourceDB($currentSources, $installer);
if (!is_file($this->_packageExtract['packagefile'])) {
$config = JFactory::getConfig();
$package['packagefile'] = $config->getValue('config.tmp_path') . DS . $this->_packageExtract['packagefile'];
}
JInstallerHelper::cleanupInstall($this->_packageExtract['packagefile'], $this->_packageExtract['extractdir']);
}
}
示例13: postflight
function postflight($type, $parent)
{
if (version_compare(JVERSION, '3.0.0', '>')) {
$messages = array();
// Import required modules
jimport('joomla.installer.installer');
jimport('joomla.installer.helper');
jimport('joomla.filesystem.file');
//$db = JFactory::getDBO();
//$query = "ALTER TABLE #__k2_items ADD FULLTEXT(extra_fields)";
//$db->setQuery($query);
//$db->query();
// Get packages
$p_dir = JPath::clean(JPATH_SITE . DS . 'components' . DS . 'com_jak2filter' . DS . 'packages');
// Did you give us a valid directory?
if (!is_dir($p_dir)) {
$messages[] = JText::_('Package directory(Related modules, plugins) is missing');
} else {
$subpackages = JFolder::files($p_dir);
$result = true;
$installer = new JInstaller();
if ($subpackages) {
$app = JFactory::getApplication();
$templateDir = 'templates/' . $app->getTemplate();
foreach ($subpackages as $zpackage) {
if (JFile::getExt($p_dir . DS . $zpackage) != "zip") {
continue;
}
$subpackage = JInstallerHelper::unpack($p_dir . DS . $zpackage);
if ($subpackage) {
$type = JInstallerHelper::detectType($subpackage['dir']);
if (!$type) {
$messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::_($zpackage . " Not valid package") . '</span>';
$result = false;
}
if (!$installer->install($subpackage['dir'])) {
// There was an error installing the package
$messages[] = '<img src="' . $templateDir . '/images/admin/publish_x.png" alt="" width="16" height="16" /> <span style="color:#FF0000;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Error')) . '</span>';
} else {
$messages[] = '<img src="' . $templateDir . '/images/admin/tick.png" alt="" width="16" height="16" /> <span style="color:#00FF00;">' . JText::sprintf('Install %s: %s', $type . " " . JFile::getName($zpackage), JText::_('Success')) . '</span>';
}
if (!is_file($subpackage['packagefile'])) {
$subpackage['packagefile'] = $p_dir . DS . $subpackage['packagefile'];
}
if (is_dir($subpackage['extractdir'])) {
JFolder::delete($subpackage['extractdir']);
}
if (is_file($subpackage['packagefile'])) {
JFile::delete($subpackage['packagefile']);
}
}
}
}
JFolder::delete($p_dir);
}
}
}
示例14: update
public function update()
{
// Make sure there are updates available
$updates = $this->getModel('update')->getUpdates(false);
if (!$updates->update_available) {
$this->app->enqueueMessage(JText::_('JM_ERR_UPDATE_NOUPDATES'), 'error');
$this->app->redirect(JURI::base() . 'index.php?option=com_joomailermailchimpintegration');
}
// Download the package
$config = JFactory::getConfig();
$target = $config->get('tmp_path') . '/joomailermailchimpintegration_update.zip';
$result = $this->getModel('update')->downloadPackage($updates->packageUrl, $target);
if ($result === false) {
$this->app->enqueueMessage(JText::_('JM_ERR_UPDATE_CANTDOWNLOAD'), 'error');
$this->app->redirect(JURI::base() . 'index.php?option=com_joomailermailchimpintegration');
}
// Extract the package
jimport('joomla.installer.helper');
$result = JInstallerHelper::unpack($target);
if ($result === false) {
$this->app->enqueueMessage(JText::_('JM_ERR_UPDATE_CANTEXTRACT'), 'error');
$this->app->redirect(JURI::base() . 'index.php?option=com_joomailermailchimpintegration');
}
// Package extracted; run the installer
$tempdir = $result['dir'];
@ob_end_clean();
?>
<html>
<head></head>
<body>
<form action="<?php
echo JURI::base() . 'index.php?option=com_installer&view=install';
?>
" method="post" name="frm" id="frm">
<input type="hidden" name="task" value="install.install" />
<input type="hidden" name="installtype" value="folder" />
<input type="hidden" name="install_directory" value="<?php
echo htmlspecialchars($tempdir);
?>
" />
<input type="hidden" name="<?php
echo JSession::getFormToken();
?>
" value="1" />
</form>
<script type="text/javascript">
document.frm.submit();
</script>
</body>
<html><?php
exit;
}
示例15: install
/**
* method to install the component
*
* @return void
* <div id="system-message-container">
<div id="system-message">
<div class="alert alert-message"><a class="close" data-dismiss="alert">×</a>
<h4 class="alert-heading">Message</h4>
<div>
<p>Installing component was successful.</p>
</div>
</div>
</div>
</div>
*/
function install($parent)
{
// $parent is the class calling this method
echo '<div id="system-message-container">';
$msgtext = "";
echo '<div id="system-message">
<div style=" overflow:hidden; margin:8px 0 8px 0; padding:5px;" >
<div style=" font-size:12px; margin:0px 0 0px 0; padding:5px; position:relative; float:right;"><div>Powered by Percha.com</div></div>
<div style="float:left; margin:0 20px 20px 0;"><img src="http://www.fieldsattach.com/images/logo_fieldsattach_small.png" alt="fieldsattach.com" /></div>
<div style=" margin:30px 0 8px 0; padding:5px; font-size:23px; color:#4892AB;">Thanks for install the Fieldsattach component.</div>
</div>';
//INSTALL THE PLUGINS *******************************************************************************
$installer = new JInstaller();
//$installer->_overwrite = true;
$pkg_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_fieldsattach' . DS . 'extensions' . DS;
$pkgs = array('input.zip' => 'Plugin fieldsattachment <strong>Input</strong>', 'file.zip' => 'Plugin fieldsattachment <strong>File</strong>', 'image.zip' => 'Plugin fieldsattachment <strong>image</strong>', 'imagegallery.zip' => 'Plugin fieldsattachment <strong>imagegallery</strong>', 'select.zip' => 'Plugin fieldsattachment <strong>select</strong>', 'textarea.zip' => 'Plugin fieldsattachment <strong>textarea</strong>', 'content_fieldsattachment.zip' => 'Plugin Content FieldsAttachment', 'system_fieldsattachment.zip' => 'Plugin System FieldsAttachment', 'advancedsearch_fieldsattachment.zip' => 'Plugin Advanced Search FieldsAttachment', 'filterarticles.zip' => 'Plugin Advanced FILTER FieldsAttachment');
foreach ($pkgs as $pkg => $pkgname) {
$package = JInstallerHelper::unpack($pkg_path . $pkg);
if ($installer->install($package['dir'])) {
$msgtext .= '<div id="system-message-container"><div class="alert alert-message">' . $pkgname . ' successfully installed.</div></div>';
//ACTIVE IT
} else {
$msgtext .= '<div id="system-message-container"><div class="alert alert-message">ERROR: Could not install the $pkgname. Please install manually</div></div>';
}
//ACTIVE THE PLUGINS *******************************************************************************
$db = JFactory::getDBO();
$sql = "UPDATE #__extensions SET enabled = 1 WHERE element = 'fieldsattachment'";
$db->setQuery($sql);
$db->query();
$db = JFactory::getDBO();
$sql = "UPDATE #__extensions SET enabled = 1 WHERE element = 'fieldsattachmentadvanced'";
$db->setQuery($sql);
$db->query();
$db = JFactory::getDBO();
$sql = "UPDATE #__extensions SET enabled = 1 WHERE folder = 'fieldsattachment'";
$db->setQuery($sql);
$db->query();
//DESACTIVE OLD SEARCH
$db = JFactory::getDBO();
$sql = "UPDATE #__extensions SET enabled = 0 WHERE element = 'fieldsattachment' AND folder='search'";
$db->setQuery($sql);
$db->query();
JInstallerHelper::cleanupInstall($pkg_path . $pkg, $package['dir']);
}
//DELETE EXTENSIONS
$pkg_path = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_fieldsattach' . DS . 'extensions' . DS;
destroy_dir($pkg_path);
$msgtext .= '<div id="system-message-container"><div class="alert alert-message">Clean install directory: ' . $pkg_path . '</div></div>';
echo $msgtext;
echo '</div>';
//$parent->getParent()->setRedirectURL('index.php?option=com_helloworld');
}