本文整理汇总了PHP中JInstaller::getManifest方法的典型用法代码示例。如果您正苦于以下问题:PHP JInstaller::getManifest方法的具体用法?PHP JInstaller::getManifest怎么用?PHP JInstaller::getManifest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JInstaller
的用法示例。
在下文中一共展示了JInstaller::getManifest方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: install
/**
* Custom install method
*
* @access public
* @return boolean True on success
* @since 1.5
*/
public function install()
{
// Get a database connector object
$db = $this->parent->getDbo();
// Get the extension manifest object
$this->manifest = $this->parent->getManifest();
$xml = $this->manifest;
/**
* ---------------------------------------------------------------------------------------------
* Manifest Document Setup Section
* ---------------------------------------------------------------------------------------------
*/
// Set the extensions name
$name = (string) $xml->name;
$name = JFilterInput::getInstance()->clean($name, 'string');
$this->set('name', $name);
// Get the component description
$description = (string) $xml->description;
if ($description) {
$this->parent->set('message', JText::_($description));
} else {
$this->parent->set('message', '');
}
/*
* Backward Compatability
* @todo Deprecate in future version
*/
$type = (string) $xml->attributes()->type;
// Set the installation path
if (count($xml->files->children())) {
foreach ($xml->files->children() as $file) {
if ((string) $file->attributes()->{$type}) {
$element = (string) $file->attributes()->{$type};
break;
}
}
}
$group = (string) $xml->attributes()->group;
if (!empty($element) && !empty($group)) {
$this->parent->setPath('extension_root', JPATH_PLUGINS . DS . $group . DS . $element);
} else {
$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PLG_INSTALL_NO_FILE', JText::_('JLIB_INSTALLER_' . $this->route)));
return false;
}
/*
* Check if we should enable overwrite settings
*/
// Check to see if a plugin by the same name is already installed
$query = 'SELECT `extension_id`' . ' FROM `#__extensions`' . ' WHERE folder = ' . $db->Quote($group) . ' AND element = ' . $db->Quote($element);
$db->setQuery($query);
try {
$db->Query();
} catch (JException $e) {
// Install failed, roll back changes
$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PLG_INSTALL_ROLLBACK', JText::_('JLIB_INSTALLER_' . $this->route), $db->stderr(true)));
return false;
}
$id = $db->loadResult();
// if its on the fs...
if (file_exists($this->parent->getPath('extension_root')) && (!$this->parent->getOverwrite() || $this->parent->getUpgrade())) {
$updateElement = $xml->update;
// upgrade manually set
// update function available
// update tag detected
if ($this->parent->getUpgrade() || $this->parent->manifestClass && method_exists($this->parent->manifestClass, 'update') || is_a($updateElement, 'JXMLElement')) {
// force these one
$this->parent->setOverwrite(true);
$this->parent->setUpgrade(true);
if ($id) {
// if there is a matching extension mark this as an update; semantics really
$this->route = 'update';
}
} else {
if (!$this->parent->getOverwrite()) {
// overwrite is set
// we didn't have overwrite set, find an udpate function or find an update tag so lets call it safe
$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT_PLG_INSTALL_DIRECTORY', JText::_('JLIB_INSTALLER_' . $this->route), $this->parent->getPath('extension_root')));
return false;
}
}
}
/**
* ---------------------------------------------------------------------------------------------
* Installer Trigger Loading
* ---------------------------------------------------------------------------------------------
*/
// If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
if ((string) $xml->scriptfile) {
$manifestScript = (string) $xml->scriptfile;
$manifestScriptFile = $this->parent->getPath('source') . DS . $manifestScript;
if (is_file($manifestScriptFile)) {
// load the file
include_once $manifestScriptFile;
//.........这里部分代码省略.........
示例3: update
/**
* Custom update method for components
*
* @return boolean True on success
*
* @since 3.1
*/
public function update()
{
// Get a database connector object
$db = $this->parent->getDbo();
// Set the overwrite setting
$this->parent->setOverwrite(true);
// Get the extension manifest object
$this->manifest = $this->parent->getManifest();
/**
* ---------------------------------------------------------------------------------------------
* Manifest Document Setup Section
* ---------------------------------------------------------------------------------------------
*/
// Set the extension's name
$name = strtolower(JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd'));
if (substr($name, 0, 4) == 'com_') {
$element = $name;
} else {
$element = 'com_' . $name;
}
$this->set('name', $name);
$this->set('element', $element);
// Get the component description
$description = (string) $this->manifest->description;
if ($description) {
$this->parent->set('message', JText::_($description));
} else {
$this->parent->set('message', '');
}
// Set the installation target paths
$this->parent->setPath('extension_site', JPath::clean(JPATH_SITE . '/components/' . $this->get('element')));
$this->parent->setPath('extension_administrator', JPath::clean(JPATH_ADMINISTRATOR . '/components/' . $this->get('element')));
// Copy the admin path as it's used as a common base
$this->parent->setPath('extension_root', $this->parent->getPath('extension_administrator'));
// Hunt for the original XML file
$old_manifest = null;
// Create a new installer because findManifest sets stuff
// Look in the administrator first
$tmpInstaller = new JInstaller();
$tmpInstaller->setPath('source', $this->parent->getPath('extension_administrator'));
if (!$tmpInstaller->findManifest()) {
// Then the site
$tmpInstaller->setPath('source', $this->parent->getPath('extension_site'));
if ($tmpInstaller->findManifest()) {
$old_manifest = $tmpInstaller->getManifest();
}
} else {
$old_manifest = $tmpInstaller->getManifest();
}
// Should do this above perhaps?
if ($old_manifest) {
$this->oldAdminFiles = $old_manifest->administration->files;
$this->oldFiles = $old_manifest->files;
} else {
$this->oldAdminFiles = null;
$this->oldFiles = null;
}
/**
* ---------------------------------------------------------------------------------------------
* Basic Checks Section
* ---------------------------------------------------------------------------------------------
*/
// Make sure that we have an admin element
if (!$this->manifest->administration) {
JLog::add(JText::_('JLIB_INSTALLER_ABORT_COMP_UPDATE_ADMIN_ELEMENT'), JLog::WARNING, 'jerror');
return false;
}
/**
* ---------------------------------------------------------------------------------------------
* Installer Trigger Loading
* ---------------------------------------------------------------------------------------------
*/
// If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
$manifestScript = (string) $this->manifest->scriptfile;
if ($manifestScript) {
$manifestScriptFile = $this->parent->getPath('source') . '/' . $manifestScript;
if (is_file($manifestScriptFile)) {
// Load the file
include_once $manifestScriptFile;
}
// Set the class name
$classname = $element . 'InstallerScript';
if (class_exists($classname)) {
// Create a new instance
$this->parent->manifestClass = new $classname($this);
// And set this so we can copy it later
$this->set('manifest_script', $manifestScript);
}
}
// Run preflight if possible (since we know we're not an update)
ob_start();
ob_implicit_flush(false);
if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'preflight')) {
//.........这里部分代码省略.........
示例4: createExtensionRoot
/**
* Method to create the extension root path if necessary
*
* @return void
*
* @since 3.4
* @throws RuntimeException
*/
protected function createExtensionRoot()
{
// Run the common create code first
parent::createExtensionRoot();
// If we're updating at this point when there is always going to be an extension_root find the old XML files
if ($this->route == 'update') {
// Create a new installer because findManifest sets stuff; side effects!
$tmpInstaller = new JInstaller();
// Look in the extension root
$tmpInstaller->setPath('source', $this->parent->getPath('extension_root'));
if ($tmpInstaller->findManifest()) {
$old_manifest = $tmpInstaller->getManifest();
$this->oldFiles = $old_manifest->files;
}
}
}
示例5: setupUpdates
/**
* Method to setup the update routine for the adapter
*
* @return void
*
* @since 3.4
*/
protected function setupUpdates()
{
// Hunt for the original XML file
$old_manifest = null;
// Use a temporary instance due to side effects; start in the administrator first
$tmpInstaller = new JInstaller();
$tmpInstaller->setPath('source', $this->parent->getPath('extension_administrator'));
if (!$tmpInstaller->findManifest()) {
// Then the site
$tmpInstaller->setPath('source', $this->parent->getPath('extension_site'));
if ($tmpInstaller->findManifest()) {
$old_manifest = $tmpInstaller->getManifest();
}
} else {
$old_manifest = $tmpInstaller->getManifest();
}
if ($old_manifest) {
$this->oldAdminFiles = $old_manifest->administration->files;
$this->oldFiles = $old_manifest->files;
}
}
示例6: _installExtensions
private function _installExtensions($parent)
{
jimport('joomla.filesystem.folder');
jimport('joomla.installer.installer');
JLoader::register('LanguagesModelInstalled', JPATH_ADMINISTRATOR . '/components/com_languages/models/installed.php');
$lang = new LanguagesModelInstalled();
$current_languages = $lang->getData();
$locales = array();
foreach ($current_languages as $lang) {
$locales[] = $lang->language;
}
$extpath = dirname(__FILE__) . '/extensions';
if (!is_dir($extpath)) {
return;
}
$folders = JFolder::folders($extpath);
foreach ($folders as $folder) {
$folder_temp = explode('_', $folder, 2);
if (isset($folder_temp[0])) {
$check_if_language = $folder_temp[0];
if (preg_match('~[a-z]{2}-[A-Z]{2}~', $check_if_language)) {
if (!in_array($folder_temp[0], $locales)) {
continue;
}
}
}
$installer = new JInstaller();
if ($installer->install($extpath . '/' . $folder)) {
$manifest = $installer->getManifest();
$this->messages[] = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', '<b style="color:#0055BB;">[' . $manifest->name . ']<span style="color:green;">') . '</span></b>';
} else {
$this->messages[] = '<span style="color:red;">' . $folder . ' ' . JText::_('JERROR_AN_ERROR_HAS_OCCURRED') . '</span>';
}
}
}
示例7: update
/**
* Custom update method for components
*
* @access public
* @return boolean True on success
* @since 1.5
*/
function update()
{
// Get a database connector object
$db =& $this->parent->getDbo();
// set the overwrite setting
$this->parent->setOverwrite(true);
// Get the extension manifest object
$this->manifest = $this->parent->getManifest();
/**
* ---------------------------------------------------------------------------------------------
* Manifest Document Setup Section
* ---------------------------------------------------------------------------------------------
*/
// Set the extensions name
$name = JFilterInput::getInstance()->clean((string) $this->manifest->name, 'cmd');
$element = strtolower('com_' . $name);
$this->set('name', $name);
$this->set('element', $element);
// Get the component description
$description = (string) $this->manifest->description;
if ($description) {
$this->parent->set('message', JText::_($description));
} else {
$this->parent->set('message', '');
}
// Set the installation target paths
$this->parent->setPath('extension_site', JPath::clean(JPATH_SITE . DS . "components" . DS . $this->get('element')));
$this->parent->setPath('extension_administrator', JPath::clean(JPATH_ADMINISTRATOR . DS . "components" . DS . $this->get('element')));
$this->parent->setPath('extension_root', $this->parent->getPath('extension_administrator'));
// copy this as its used as a common base
/**
* Hunt for the original XML file
*/
$oldmanifest = null;
$tmpInstaller = new JInstaller();
// create a new installer because findManifest sets stuff
// look in the administrator first
$tmpInstaller->setPath('source', $this->parent->getPath('extension_administrator'));
if (!$tmpInstaller->findManifest()) {
// then the site
$tmpInstaller->setPath('source', $this->parent->getPath('extension_site'));
if ($tmpInstaller->findManifest()) {
$old_manifest = $tmpInstaller->getManifest();
}
} else {
$old_manifest = $tmpInstaller->getManifest();
}
// should do this above perhaps?
if ($old_manifest) {
$this->oldAdminFiles = $old_manifest->administration->files;
$this->oldFiles = $old_manifest->files;
} else {
$this->oldAdminFiles = null;
$this->oldFiles = null;
}
/**
* ---------------------------------------------------------------------------------------------
* Basic Checks Section
* ---------------------------------------------------------------------------------------------
*/
// Make sure that we have an admin element
if (!$this->manifest->administration) {
JError::raiseWarning(1, JText::_('Component') . ' ' . JText::_('Update') . ': ' . JText::_('The XML file did not contain an administration element'));
return false;
}
/**
* ---------------------------------------------------------------------------------------------
* Installer Trigger Loading
* ---------------------------------------------------------------------------------------------
*/
// If there is an manifest class file, lets load it; we'll copy it later (don't have dest yet)
$manifestScript = (string) $this->manifest->scriptfile;
if ($manifestScript) {
$manifestScriptFile = $this->parent->getPath('source') . DS . $manifestScript;
if (is_file($manifestScriptFile)) {
// load the file
include_once $manifestScriptFile;
}
// Set the class name
$classname = $element . 'InstallerScript';
if (class_exists($classname)) {
// create a new instance
$this->parent->manifestClass = new $classname($this);
// and set this so we can copy it later
$this->set('manifest_script', $manifestScript);
// Note: if we don't find the class, don't bother to copy the file
}
}
// run preflight if possible (since we know we're not an update)
ob_start();
ob_implicit_flush(false);
if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, 'preflight')) {
$this->parent->manifestClass->preflight('update', $this);
//.........这里部分代码省略.........
示例8: preventCustomUninstall
/**
* Tricks joomla so as to not run the custom unistall script of a component during an uninstall
*
* @access public
* @param JInstaller $installer the intaller of the current component
*/
function preventCustomUninstall(&$installer)
{
//Get the extension manifest object
$manifest = $installer->getManifest();
$manifestFile = $manifest->document;
//Cleverly remove the XML containing custom uninstall information
$uninstaller = $manifestFile->getElementByPath('uninstall');
$manifestFile->removeChild($uninstaller);
}
示例9: getExtensionInfo
/**
* Get information about the installed extension
*
* @param \JInstaller $installer
*
* @return array A message array suitable for OutputInterface::write[ln]
*/
private function getExtensionInfo($installer)
{
$manifest = $installer->getManifest();
$data = $this->joomla->getExtensionInfo($manifest);
$message = array('Installed ' . $data['type'] . ' <info>' . $data['name'] . '</info> version <info>' . $data['version'] . '</info>', '', wordwrap($data['description'], 60), '');
return $message;
}
示例10: 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;
}
示例11: getManifestObject
function getManifestObject($path)
{
$installer = new JInstaller();
$installer->setPath('source', $path);
if (!$installer->setupInstall()) {
return null;
}
$manifest =& $installer->getManifest();
return $manifest;
}
示例12: installExtensions
private function installExtensions($parent)
{
jimport('joomla.filesystem.folder');
jimport('joomla.installer.installer');
$extpath = __DIR__ . '/extensions';
$folders = JFolder::folders($extpath);
foreach ($folders as $folder) {
$installer = new JInstaller();
if ($installer->install($extpath . '/' . $folder)) {
$manifest = $installer->getManifest();
$this->messages[] = JText::sprintf('COM_INSTALLER_INSTALL_SUCCESS', '<b style="color:#0055BB;">[' . $manifest->name . ']<span style="color:green;">') . '</span></b>';
} else {
$this->messages[] = '<span style="color:red;">' . $folder . ' ' . JText::_('JERROR_AN_ERROR_HAS_OCCURRED') . '</span>';
}
}
}
示例13: preflight
public function preflight($type, $adapter)
{
if ($type !== 'update') {
return true;
}
// "Fix" Joomla! bug
$row = JTable::getInstance('extension');
$eid = $row->find(array('element' => strtolower($adapter->get('element')), 'type' => 'component'));
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('version_id')->from('#__schemas')->where('extension_id = ' . $eid);
$db->setQuery($query);
if ($db->loadResult()) {
return true;
}
// Get the previous version
$old_manifest = null;
// Create a new installer because findManifest sets stuff
// Look in the administrator first
$tmpInstaller = new JInstaller();
$tmpInstaller->setPath('source', JPATH_ADMINISTRATOR . '/components/com_slicomments');
if (!$tmpInstaller->findManifest()) {
echo 'Could not find old manifest.';
return false;
}
$old_manifest = $tmpInstaller->getManifest();
$version = (string) $old_manifest->version;
// Store
$data = new stdClass();
$data->extension_id = $eid;
$data->version_id = $version;
$db->insertObject('#__schemas', $data);
return true;
}
示例14: getKSVersion
public function getKSVersion()
{
$kmdestination = JPATH_ROOT . '/administrator/components/' . $this->ext_name_com;
$tmpInstaller = new JInstaller();
$tmpInstaller->setPath('source', $kmdestination);
$manifest = $tmpInstaller->getManifest();
$info = new stdClass();
$info->name = JText::_($manifest->name);
$info->version = (string) $manifest->version;
JFactory::getApplication()->close(json_encode($info));
}