本文整理汇总了PHP中JInstaller::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP JInstaller::getPath方法的具体用法?PHP JInstaller::getPath怎么用?PHP JInstaller::getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JInstaller
的用法示例。
在下文中一共展示了JInstaller::getPath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetPath
/**
* @todo Implement testGetPath().
*/
public function testGetPath()
{
$this->saveFactoryState();
$newDbo = $this->getMock('test');
JFactory::$database = &$newDbo;
$this->object = JInstaller::getInstance();
$this->assertThat(
$this->object->getPath('path1_getpath', 'default_value'),
$this->equalTo('default_value'),
'getPath did not return the default value for an undefined path'
);
$this->object->setPath('path2_getpath', JPATH_BASE.'/required_path');
$this->assertThat(
$this->object->getPath('path2_getpath', 'default_value'),
$this->equalTo(JPATH_BASE.'/required_path'),
'getPath did not return the previously set value for the path'
);
$this->restoreFactoryState();
}
示例2: testGetPath
/**
* Test...
*
* @covers JInstaller::getPath
*
* @return void
*/
public function testGetPath()
{
$this->assertThat(
$this->object->getPath('path1_getpath', 'default_value'),
$this->equalTo('default_value'),
'getPath did not return the default value for an undefined path'
);
$this->object->setPath('path2_getpath', JPATH_BASE . '/required_path');
$this->assertThat(
$this->object->getPath('path2_getpath', 'default_value'),
$this->equalTo(JPATH_BASE . '/required_path'),
'getPath did not return the previously set value for the path'
);
}
示例3: setupScriptfile
/**
* Setup the manifest script file for those adapters that use it.
*
* @return void
*
* @since 3.4
*/
protected function setupScriptfile()
{
// If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
$manifestScript = (string) $this->getManifest()->scriptfile;
if ($manifestScript) {
$manifestScriptFile = $this->parent->getPath('source') . '/' . $manifestScript;
if (is_file($manifestScriptFile)) {
// Load the file
include_once $manifestScriptFile;
}
$classname = $this->getScriptClassName();
if (class_exists($classname)) {
// Create a new instance
$this->parent->manifestClass = new $classname($this);
// And set this so we can copy it later
$this->manifest_script = $manifestScript;
}
}
}
示例4: _uninstallSubextensions
/**
* Uninstalls subextensions (modules, plugins) bundled with the main extension
*
* @param JInstaller $parent
* @return JObject The subextension uninstallation status
*/
private function _uninstallSubextensions($parent)
{
jimport('joomla.installer.installer');
$db = JFactory::getDBO();
$status = new JObject();
$status->modules = array();
$status->plugins = array();
if (version_compare(JVERSION, '1.6.0', 'ge')) {
$src = $parent->getParent()->getPath('source');
} else {
$src = $parent->getPath('source');
}
// Modules uninstallation
if (count($this->installation_queue['modules'])) {
foreach ($this->installation_queue['modules'] as $folder => $modules) {
if (count($modules)) {
foreach ($modules as $module => $modulePreferences) {
// Find the module ID
$sql = $db->getQuery(true)->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('element') . ' = ' . $db->q('mod_' . $module))->where($db->qn('type') . ' = ' . $db->q('module'));
$db->setQuery($sql);
$id = $db->loadResult();
// Uninstall the module
if ($id) {
$installer = new JInstaller();
$result = $installer->uninstall('module', $id, 1);
$status->modules[] = array('name' => 'mod_' . $module, 'client' => $folder, 'result' => $result);
}
}
}
}
}
// Plugins uninstallation
if (count($this->installation_queue['plugins'])) {
foreach ($this->installation_queue['plugins'] as $folder => $plugins) {
if (count($plugins)) {
foreach ($plugins as $plugin => $published) {
$sql = $db->getQuery(true)->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('plugin'))->where($db->qn('element') . ' = ' . $db->q($plugin))->where($db->qn('folder') . ' = ' . $db->q($folder));
$db->setQuery($sql);
$id = $db->loadResult();
if ($id) {
$installer = new JInstaller();
$result = $installer->uninstall('plugin', $id, 1);
$status->plugins[] = array('name' => 'plg_' . $plugin, 'group' => $folder, 'result' => $result);
}
}
}
}
}
return $status;
}
示例5: rebuild
/**
* Rebuild update sites tables.
*
* @return void
*
* @since 3.6
*
* @throws Exception on ACL error
*/
public function rebuild()
{
if (!JFactory::getUser()->authorise('core.admin', 'com_installer')) {
throw new Exception(JText::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_NOT_PERMITTED'), 403);
}
$db = JFactory::getDbo();
$app = JFactory::getApplication();
// Check if Joomla Extension plugin is enabled.
if (!JPluginHelper::isEnabled('extension', 'joomla')) {
$query = $db->getQuery(true)->select($db->quoteName('extension_id'))->from($db->quoteName('#__extensions'))->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))->where($db->quoteName('element') . ' = ' . $db->quote('joomla'))->where($db->quoteName('folder') . ' = ' . $db->quote('extension'));
$db->setQuery($query);
$pluginId = (int) $db->loadResult();
$link = JRoute::_('index.php?option=com_plugins&task=plugin.edit&extension_id=' . $pluginId);
$app->enqueueMessage(JText::sprintf('COM_INSTALLER_MSG_UPDATESITES_REBUILD_EXTENSION_PLUGIN_NOT_ENABLED', $link), 'error');
return;
}
$clients = array(JPATH_SITE, JPATH_ADMINISTRATOR);
$extensionGroupFolders = array('components', 'modules', 'plugins', 'templates', 'language', 'manifests');
$pathsToSearch = array();
// Identifies which folders to search for manifest files.
foreach ($clients as $clientPath) {
foreach ($extensionGroupFolders as $extensionGroupFolderName) {
// Components, modules, plugins, templates, languages and manifest (files, libraries, etc)
if ($extensionGroupFolderName != 'plugins') {
foreach (glob($clientPath . '/' . $extensionGroupFolderName . '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $extensionFolderPath) {
array_push($pathsToSearch, $extensionFolderPath);
}
} else {
foreach (glob($clientPath . '/' . $extensionGroupFolderName . '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $pluginGroupFolderPath) {
foreach (glob($pluginGroupFolderPath . '/*', GLOB_NOSORT | GLOB_ONLYDIR) as $extensionFolderPath) {
array_push($pathsToSearch, $extensionFolderPath);
}
}
}
}
}
// Gets Joomla core update sites Ids.
$joomlaUpdateSitesIds = implode(', ', $this->getJoomlaUpdateSitesIds(0));
// Delete from all tables (except joomla core update sites).
$query = $db->getQuery(true)->delete($db->quoteName('#__update_sites'))->where($db->quoteName('update_site_id') . ' NOT IN (' . $joomlaUpdateSitesIds . ')');
$db->setQuery($query);
$db->execute();
$query = $db->getQuery(true)->delete($db->quoteName('#__update_sites_extensions'))->where($db->quoteName('update_site_id') . ' NOT IN (' . $joomlaUpdateSitesIds . ')');
$db->setQuery($query);
$db->execute();
$query = $db->getQuery(true)->delete($db->quoteName('#__updates'))->where($db->quoteName('update_site_id') . ' NOT IN (' . $joomlaUpdateSitesIds . ')');
$db->setQuery($query);
$db->execute();
$count = 0;
// Gets Joomla core extension Ids.
$joomlaCoreExtensionIds = implode(', ', $this->getJoomlaUpdateSitesIds(1));
// Search for updateservers in manifest files inside the folders to search.
foreach ($pathsToSearch as $extensionFolderPath) {
$tmpInstaller = new JInstaller();
$tmpInstaller->setPath('source', $extensionFolderPath);
// Main folder manifests (higher priority)
$parentXmlfiles = JFolder::files($tmpInstaller->getPath('source'), '.xml$', false, true);
// Search for children manifests (lower priority)
$allXmlFiles = JFolder::files($tmpInstaller->getPath('source'), '.xml$', 1, true);
// Create an unique array of files ordered by priority
$xmlfiles = array_unique(array_merge($parentXmlfiles, $allXmlFiles));
if (!empty($xmlfiles)) {
foreach ($xmlfiles as $file) {
// Is it a valid Joomla installation manifest file?
$manifest = $tmpInstaller->isManifest($file);
if (!is_null($manifest)) {
// Search if the extension exists in the extensions table. Excluding joomla core extensions (id < 10000) and discovered extensions.
$query = $db->getQuery(true)->select($db->quoteName('extension_id'))->from($db->quoteName('#__extensions'))->where($db->quoteName('name') . ' = ' . $db->quote($manifest->name))->where($db->quoteName('type') . ' = ' . $db->quote($manifest['type']))->where($db->quoteName('extension_id') . ' NOT IN (' . $joomlaCoreExtensionIds . ')')->where($db->quoteName('state') . ' != -1');
$db->setQuery($query);
$eid = (int) $db->loadResult();
if ($eid && $manifest->updateservers) {
// Set the manifest object and path
$tmpInstaller->manifest = $manifest;
$tmpInstaller->setPath('manifest', $file);
// Load the extension plugin (if not loaded yet).
JPluginHelper::importPlugin('extension', 'joomla');
// Fire the onExtensionAfterUpdate
JFactory::getApplication()->triggerEvent('onExtensionAfterUpdate', array('installer' => $tmpInstaller, 'eid' => $eid));
$count++;
}
}
}
}
}
if ($count > 0) {
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_SUCCESS'), 'message');
} else {
$app->enqueueMessage(JText::_('COM_INSTALLER_MSG_UPDATESITES_REBUILD_MESSAGE'), 'message');
}
}
示例6: preflight
public function preflight($type, $parent)
{
// Bugfix for "Can not build admin menus"
if (in_array($type, array('install', 'discover_install'))) {
$this->bugfixDBFunctionReturnedNoError();
} else {
$this->bugfixCantBuildAdminMenus();
}
$manifest = $parent->getParent()->getManifest();
// Prevent installation if requirements are not met.
if (!$this->checkRequirements($manifest->version)) {
return false;
}
// TODO: If we do not need to display the warning (but only after dropping J1.5 support)
// if (version_compare($manifest->version, '2.0', '>')) return true;
$adminpath = $parent->getParent()->getPath('extension_administrator');
$sitepath = $parent->getParent()->getPath('extension_site');
// If Kunena wasn't installed, there's nothing to do.
if (!file_exists($adminpath)) {
return true;
}
// Find the old manifest file.
$tmpInstaller = new JInstaller();
$tmpInstaller->setPath('source', $adminpath);
$obj_manifest = $tmpInstaller->findManifest() ? $tmpInstaller->getManifest() : null;
$old_manifest = basename($tmpInstaller->getPath('manifest'));
if ($obj_manifest) {
$this->oldAdminFiles = $this->findFilesFromManifest($obj_manifest->administration->files) + array($old_manifest => $old_manifest);
$this->oldAdminFiles += $this->findFilesFromManifest($manifest->administration->files);
$this->oldFiles = $this->findFilesFromManifest($obj_manifest->files);
$this->oldFiles += $this->findFilesFromManifest($manifest->files);
}
// Detect existing installation.
if ($old_manifest && JFile::exists("{$adminpath}/admin.kunena.php")) {
$contents = file_get_contents("{$adminpath}/admin.kunena.php");
if (!strstr($contents, '/* KUNENA FORUM INSTALLER */')) {
// If we don't find Kunena 2.0 installer, backup existing files...
$backuppath = "{$adminpath}/bak";
if (JFolder::exists($backuppath)) {
JFolder::delete($backuppath);
}
$this->backup($adminpath, $backuppath, $this->oldAdminFiles);
$backuppath = "{$sitepath}/bak";
if (JFolder::exists($backuppath)) {
JFolder::delete($backuppath);
}
$this->backup($sitepath, $backuppath, $this->oldFiles);
}
}
// Remove old manifest files, excluding the current one.
$manifests = array('manifest.xml', 'kunena.j16.xml', 'kunena.j25.xml', 'kunena.xml');
foreach ($manifests as $filename) {
if ($filename == $old_manifest) {
continue;
}
if (JFile::exists("{$adminpath}/{$filename}")) {
JFile::delete("{$adminpath}/{$filename}");
}
}
clearstatcache();
return true;
}
示例7: com_install
/**
* 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
if ($updater->installPlugins(true)) {
// Install Groups data
$updater->installGroups(true);
}
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+?(_patch)?\\.zip', false, true);
}
$language =& JFactory::getLanguage();
$language->load('com_jce', JPATH_ADMINISTRATOR);
$component = JComponentHelper::getComponent('com_jce');
$params = explode("\n", $component->params);
// get the component installer
$componentInstaller =& JInstaller::getInstance();
$componentXML = JApplicationHelper::parseXMLInstallFile($componentInstaller->getPath('manifest'));
$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%"> </th></tr>';
$out .= '<tr><td>' . JText::_('JCE ADMIN TITLE') . '</td><td>' . $componentXML['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>';
$editor_img = 'delete.png';
$editor_result = JText::_('Error');
if (!empty($editor)) {
if (is_file($editor[0])) {
if ($data = JInstallerHelper::unpack($editor[0])) {
// Add JTable include path
JTable::addIncludePath(JPATH_LIBRARIES . DS . 'joomla' . DS . 'database' . DS . 'table');
$editorInstaller = new JInstaller();
// install editor
if ($editorInstaller->install($data['extractdir'])) {
$editorXML = JApplicationHelper::parseXMLInstallFile($editorInstaller->getPath('manifest'));
// update plugin name
$query = 'UPDATE #__plugins' . ' SET name = ' . $db->Quote($editorXML['name']) . ' WHERE folder = ' . $db->Quote('editors') . ' AND element = ' . $db->Quote('jce');
$db->setQuery($query);
$db->query();
$editor_img = 'tick.png';
$editor_result = JText::_('Success');
$params[] = 'package=1';
} else {
$editor_img = 'delete.png';
$editor_result = JText::_('Error');
$params[] = 'package=0';
}
// cleanup
JInstallerHelper::cleanupInstall($data['packagefile'], $data['extractdir']);
}
$out .= '<tr><td>' . JText::_('JCE EDITOR TITLE') . '</td><td>' . $editorXML['version'] . '</td><td class="title" style="text-align:center;">' . JHTML::image($img_path . $editor_img, $editor_result) . '</td></tr>';
$out .= '<tr><td colspan="3">' . JText::_($editorInstaller->message) . '</td></tr>';
}
}
$out .= '</table>';
$installer->set('message', JText::_('JCE INSTALL SUMMARY'));
$installer->set('extension.message', $out);
// Add JTable include path
JTable::addIncludePath(JPATH_LIBRARIES . DS . 'joomla' . DS . 'database' . DS . 'table');
// store component params
$row =& JTable::getInstance('component');
$row->loadByOption('com_jce');
$row->params = implode("\n", $params);
$row->store();
if (is_dir($packages)) {
// Delete packages folder
@JFolder::delete($packages);
}
}