本文整理汇总了PHP中JInstaller::parseXMLInstallFile方法的典型用法代码示例。如果您正苦于以下问题:PHP JInstaller::parseXMLInstallFile方法的具体用法?PHP JInstaller::parseXMLInstallFile怎么用?PHP JInstaller::parseXMLInstallFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JInstaller
的用法示例。
在下文中一共展示了JInstaller::parseXMLInstallFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchAdminLanguage
/**
* Task to switch the administrator language.
*
* @return void
*/
public function switchAdminLanguage()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$cid = $this->input->get('cid', '');
$model = $this->getModel('installed');
// Fetching the language name from the xx-XX.xml
$file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/' . $cid . '.xml';
$info = JInstaller::parseXMLInstallFile($file);
$languageName = $info['name'];
if ($model->switchAdminLanguage($cid)) {
// Switching to the new language for the message
$language = JFactory::getLanguage();
$newLang = JLanguage::getInstance($cid);
JFactory::$language = $newLang;
JFactory::getApplication()->loadLanguage($language = $newLang);
$newLang->load('com_languages', JPATH_ADMINISTRATOR);
$msg = JText::sprintf('COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS', $languageName);
$type = 'message';
} else {
$msg = $model->getError();
$type = 'error';
}
$this->setRedirect('index.php?option=com_languages&view=installed', $msg, $type);
}
示例2: getJoaktreeVersion
public function getJoaktreeVersion()
{
// get the folder and xml-files
$folder = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_joaktree';
if (JFolder::exists($folder)) {
$xmlFilesInDir = JFolder::files($folder, '.xml$');
} else {
$folder = JPATH_SITE . DS . 'components' . DS . 'com_joaktree';
if (JFolder::exists($folder)) {
$xmlFilesInDir = JFolder::files($folder, '.xml$');
} else {
$xmlFilesInDir = null;
}
}
// loop through the xml-files
$xml_items = '';
if (count($xmlFilesInDir)) {
foreach ($xmlFilesInDir as $xmlfile) {
if ($data = JInstaller::parseXMLInstallFile($folder . DS . $xmlfile)) {
foreach ($data as $key => $value) {
$xml_items[$key] = $value;
}
}
}
}
// return the found version
if (isset($xml_items['version']) && $xml_items['version'] != '') {
return $xml_items['version'];
} else {
return '';
}
}
示例3: onBeforeRender
public function onBeforeRender()
{
$app = JFactory::getApplication();
//get language and direction
$doc = JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;
// Get array Framework info
$temp = JFactory::getApplication()->getTemplate();
$f_filePath = JPath::clean(JPATH_ROOT . '/' . YT_PLUGIN_REL_URL . '/' . YT_PLUGIN . '.xml');
if ($app->isSite()) {
// include Bootstrap
if ($this->params->get('show_sjbootstrap', 0) == '1') {
$this->ytStyleSheet('plugins/system/ytshortcodes/assets/css/bootstrap/bootstrap.css');
}
if (is_file($f_filePath)) {
$t_xml = JInstaller::parseXMLInstallFile($f_filePath);
}
if ($this->params->get('show_sjawesome', 1) == 1) {
if ($t_xml['version'] < 3) {
$this->ytStyleSheet('plugins/system/ytshortcodes/assets/css/awesome/font-awesome.min.css');
}
$this->ytStyleSheet('plugins/system/ytshortcodes/assets/css/awesome/glyphicon.css');
}
$this->ytStyleSheet("plugins/system/ytshortcodes/assets/css/shortcodes.css");
} else {
if (!defined('FONT_AWESOME')) {
$this->document->addStyleSheet($this->baseurl . "plugins/system/ytshortcodes/assets/css/awesome/font-awesome.min.css");
define('FONT_AWESOME', 1);
}
$this->document->addStyleSheet($this->baseurl . "plugins/system/ytshortcodes/assets/css/shortcodes-backend.css");
}
if ($this->direction == 'rtl') {
if ($app->isSite()) {
$this->ytStyleSheet("plugins/system/ytshortcodes/assets/css/shortcodes-rtl.css");
}
}
// include Jquery Joomla25
$version = new JVersion();
if ($this->params->get('show_sjjquery', 0) == 1 && $version->RELEASE == '2.5') {
$this->document->addScript($this->baseurl . "plugins/system/ytshortcodes/assets/js/jquery.min.js");
$this->document->addScript($this->baseurl . "plugins/system/ytshortcodes/assets/js/jquery-noconflict.js");
}
// include Jquery
if ($this->params->get('show_sjbootstrap', 0) == 1 && $app->isSite()) {
$this->document->addScript($this->baseurl . "plugins/system/ytshortcodes/assets/js/bootstrap.min.js");
$this->document->addScript($this->baseurl . "plugins/system/ytshortcodes/assets/js/touchswipe.min.js");
}
if ($app->isSite()) {
$this->document->addScript($this->baseurl . "plugins/system/ytshortcodes/assets/js/jquery.prettyPhoto.js");
if ($this->params->get('show_sjprettify', 1) == 1) {
$this->document->addScript($this->baseurl . "plugins/system/ytshortcodes/assets/js/prettify.js");
}
$this->document->addScript($this->baseurl . "plugins/system/ytshortcodes/assets/js/shortcodes.js");
}
}
示例4: parseXMLTemplateFile
public static function parseXMLTemplateFile($templateBaseDir, $templateDir)
{
$data = new JObject();
// Check of the xml file exists
$filePath = JPath::clean($templateBaseDir . '/templates/' . $templateDir . '/templateDetails.xml');
if (is_file($filePath)) {
$xml = JInstaller::parseXMLInstallFile($filePath);
if ($xml['type'] != 'template') {
return false;
}
foreach ($xml as $key => $value) {
$data->set($key, $value);
}
}
return $data;
}
示例5: parseXMLModuleFile
function parseXMLModuleFile(&$rows)
{
foreach ($rows as $i => $row) {
if ($row->module == '') {
$rows[$i]->name = 'custom';
$rows[$i]->module = 'custom';
$rows[$i]->descrip = 'Custom created module, using Module Manager New function';
} else {
$data = JInstaller::parseXMLInstallFile($row->path . '/' . $row->file);
if ($data['type'] == 'module') {
$rows[$i]->name = $data['name'];
$rows[$i]->descrip = $data['description'];
}
}
}
}
示例6: storeExtension
protected function storeExtension()
{
// Discover installs are stored a little differently
if ($this->route == 'discover_install') {
$manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->extension->manifest_cache = json_encode($manifest_details);
$this->extension->state = 0;
$this->extension->name = $manifest_details['name'];
$this->extension->published = 1;
$this->extension->params = $this->parent->getParams();
if (!$this->extension->store()) {
// Install failed, roll back changes
throw new RuntimeException(JText::_('JLIB_INSTALLER_ERROR_TPL_DISCOVER_STORE_DETAILS'));
}
return;
}
// Was there a template already installed with the same name?
if ($this->currentExtensionId) {
if (!$this->parent->isOverwrite()) {
// Install failed, roll back changes
throw new RuntimeException(JText::_('JLIB_INSTALLER_ABORT_TPL_INSTALL_ALREADY_INSTALLED'));
}
// Load the entry and update the manifest_cache
$this->extension->load($this->currentExtensionId);
} else {
$this->extension->type = 'tz_portfolio_plus-template';
$this->extension->element = $this->element;
// There is no folder for templates
$this->extension->folder = '';
$this->extension->published = 1;
$this->extension->protected = 0;
$this->extension->access = 1;
$this->extension->params = $this->parent->getParams();
}
// Name might change in an update
$this->extension->name = $this->name;
$this->extension->manifest_cache = $this->parent->generateManifestCache();
unset($this->extension->extension_id);
if (!$this->extension->store()) {
// Install failed, roll back changes
throw new RuntimeException(JText::sprintf('JLIB_INSTALLER_ABORT_ROLLBACK', JText::_('JLIB_INSTALLER_' . strtoupper($this->route)), $this->extension->getError()));
}
// Set extension_id = id because table extension of joomla with key is "extension_id" so plus is "id"
$this->extension->extension_id = $this->extension->id;
}
示例7: refreshManifestCache
/**
* Refreshes the extension table cache
*
* @return boolean Result of operation, true if updated, false on failure
*
* @since 3.1
*/
public function refreshManifestCache()
{
// Need to find to find where the XML file is since we don't store this normally
$client = JApplicationHelper::getClientInfo($this->parent->extension->client_id);
$short_element = str_replace('com_', '', $this->parent->extension->element);
$manifestPath = $client->path . '/components/' . $this->parent->extension->element . '/' . $short_element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
$manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
try {
return $this->parent->extension->store();
} catch (RuntimeException $e) {
JLog::add(JText::_('JLIB_INSTALLER_ERROR_COMP_REFRESH_MANIFEST_CACHE'), JLog::WARNING, 'jerror');
return false;
}
}
示例8: parseXMLInstallFile
/**
* Parse a XML install manifest file.
*
* XML Root tag should be 'install' except for languages which use meta file.
*
* @param string $path Full path to XML file.
*
* @return array XML metadata.
*
* @since 1.5
* @deprecated 4.0 Use JInstaller::parseXMLInstallFile instead.
*/
public static function parseXMLInstallFile($path)
{
JLog::add('JApplicationHelper::parseXMLInstallFile is deprecated. Use JInstaller::parseXMLInstallFile instead.', JLog::WARNING, 'deprecated');
return JInstaller::parseXMLInstallFile($path);
}
示例9: getTemplateName
function getTemplateName()
{
$app = JFactory::getApplication();
$template = false;
if ($app->isSite()) {
$template = $app->getTemplate(null);
} else {
$option = $app->input->get('option', null, 'string');
$view = $app->input->get('view', null, 'string');
$task = $app->input->get('task', '', 'string');
$controller = current(explode('.', $task));
$id = $app->input->get('id', null, 'int');
if ($option == 'com_templates' && ($view == 'style' || $controller == 'style' || $task == 'apply' || $task == 'save' || $task == 'save2copy') && $id > 0) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('template');
$query->from('#__template_styles');
$query->where('id=' . $id);
$db->setQuery($query);
$template = $db->loadResult();
}
}
if ($template) {
jimport('joomla.filesystem.file');
$path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'templateDetails.xml';
if (JFile::exists($path)) {
$xml = JInstaller::parseXMLInstallFile($path);
if (array_key_exists('group', $xml)) {
if ($xml['group'] == 'jmf') {
return $template;
}
}
}
}
return false;
}
示例10: installModule
public function installModule($title, $module, $ordering, $params, $src, $client_id = 0, $position = 'position-4', $access = 1, $alreadyInstalled = true)
{
$table = JTable::getInstance('module');
$db = $table->getDBO();
$src .= DS . $module;
if (!$alreadyInstalled) {
$params = '';
$q = 'SELECT id FROM `#__modules` WHERE `module` = "' . $module . '" ';
$db->setQuery($q);
$id = $db->loadResult();
if (!empty($id)) {
return;
}
$table->load();
if (empty($table->title)) {
$table->title = $title;
}
if (empty($table->ordering)) {
$table->ordering = $ordering;
}
if (empty($table->published)) {
$table->published = 1;
}
if (empty($table->module)) {
$table->module = $module;
}
if (empty($table->params)) {
$table->params = $params;
}
// table is loaded with access=1
$table->access = $access;
if (empty($table->position)) {
$table->position = $position;
}
if (empty($table->client_id)) {
$table->client_id = $client_id;
}
$table->language = '*';
if (!$table->check()) {
$app = JFactory::getApplication();
$app->enqueueMessage('VMInstaller table->check throws error for ' . $title . ' ' . $module . ' ' . $params);
}
if (!$table->store()) {
$app = JFactory::getApplication();
$app->enqueueMessage('VMInstaller table->store throws error for for ' . $title . ' ' . $module . ' ' . $params);
}
$errors = $table->getErrors();
foreach ($errors as $error) {
$app = JFactory::getApplication();
$app->enqueueMessage(get_class($this) . '::store ' . $error);
}
// }
$lastUsedId = $table->id;
$q = 'SELECT moduleid FROM `#__modules_menu` WHERE `moduleid` = "' . $lastUsedId . '" ';
$db->setQuery($q);
$moduleid = $db->loadResult();
$action = '';
if (empty($moduleid)) {
$q = 'INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES( "' . $lastUsedId . '" , "0");';
} else {
//$q = 'UPDATE `#__modules_menu` SET `menuid`= "0" WHERE `moduleid`= "'.$moduleid.'" ';
}
$db->setQuery($q);
$db->query();
}
if (version_compare(JVERSION, '1.6.0', 'ge')) {
$q = 'SELECT extension_id FROM `#__extensions` WHERE `element` = "' . $module . '" ';
$db->setQuery($q);
$ext_id = $db->loadResult();
// $manifestCache = str_replace('"', '\'', $data["manifest_cache"]);
$action = '';
$manifest_cache = json_encode(JInstaller::parseXMLInstallFile($src . DS . $module . '.xml'));
if (empty($ext_id)) {
$q = 'INSERT INTO `#__extensions` (`name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `ordering`) VALUES
( "' . $module . '" , "module", "' . $module . '", "", "' . $client_id . '", "1","' . $access . '", "0", "' . $db->escape($manifest_cache) . '", "' . $db->escape($params) . '","' . $ordering . '");';
} else {
$q = 'UPDATE `#__extensions` SET `manifest_cache` ="' . $db->escape($manifest_cache) . '", state=0 WHERE extension_id=' . $ext_id . ';';
}
$db->setQuery($q);
if (!$db->query()) {
$app = JFactory::getApplication();
$app->enqueueMessage(get_class($this) . ':: ' . $db->getErrorMsg());
}
$installTask = empty($ext_id) ? 'installed' : 'updated';
echo '<tr><td>' . $title . '</td><td> ' . $installTask . '</td></tr>';
}
//$this->updateJoomlaUpdateServer( 'module', $module, $dst );
}
示例11: getTemplate
public function getTemplate($element, $override)
{
$templatesPath = COMMUNITY_BASE_PATH . '/templates';
if ($override) {
$templatesPath = JPATH_ROOT . '/templates/' . $element . '/html/com_community';
}
$obj = new stdClass();
$obj->element = $element;
$obj->override = $override;
if (JFile::exists($templatesPath . '/' . $element . '/' . COMMUNITY_TEMPLATE_XML)) {
$obj->info = JInstaller::parseXMLInstallFile($templatesPath . '/' . $element . '/' . COMMUNITY_TEMPLATE_XML);
} else {
$obj->info = false;
}
return $obj;
}
示例12: showconfig
function showconfig()
{
$isJoomla15 = substr(JVERSION, 0, 3) == '1.5';
/** @var array $MobileJoomla_Settings */
include JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/config.php';
include_once JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/classes/jhtmlmjconfig.php';
$app = JFactory::getApplication();
if (!JFile::exists(JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/config.php')) {
$app->enqueueMessage(JText::_('COM_MJ__CONFIG_MISSING'), 'error');
} elseif (!is_writable(JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/config.php')) {
$app->enqueueMessage(JText::_('COM_MJ__CONFIG_UNWRITEABLE'), 'warning');
}
$db = JFactory::getDBO();
$query = 'SELECT DISTINCT(position) FROM #__modules WHERE client_id = 0';
$db->setQuery($query);
if (version_compare(JVERSION, '3.0', '>=')) {
$positions = $db->loadColumn();
} else {
$positions = $db->loadResultArray();
}
$positions = is_array($positions) ? $positions : array();
$templateBaseDir = JPATH_SITE . '/templates/';
$templates = array();
$templates[] = array('value' => '');
jimport('joomla.installer.installer');
$templateDirs = JFolder::folders($templateBaseDir);
foreach ($templateDirs as $templateDir) {
$templateFile = $templateBaseDir . $templateDir . '/templateDetails.xml';
if (!JFile::exists($templateFile)) {
continue;
}
if (version_compare(JVERSION, '2.5.5', '<')) {
$xml = JApplicationHelper::parseXMLInstallFile($templateFile);
} else {
$xml = JInstaller::parseXMLInstallFile($templateFile);
}
if ($xml['type'] != 'template') {
continue;
}
$templates[] = array('value' => $templateDir);
$xml = simplexml_load_file($templateFile);
if (isset($xml->positions[0])) {
foreach ($xml->positions[0] as $position) {
$positions[] = (string) $position;
}
}
}
$positions[] = '';
$positions = array_unique($positions);
sort($positions);
$modulepositions = array();
foreach ($positions as $position) {
$modulepositions[] = array('value' => $position);
}
$lists = array();
JPluginHelper::importPlugin('mobile');
$mjver = HTML_mobilejoomla::getMJVersion();
if (stripos($mjver, 'pro') === false) {
include_once JPATH_ADMINISTRATOR . '/components/com_mobilejoomla/classes/mjprostub.php';
$dispatcher = JDispatcher::getInstance();
new plgMobileMJProStub($dispatcher);
}
$lists['dbsize'] = $app->triggerEvent('onGetDatabaseSize');
$img = array(JHtml::_('select.option', 0, JText::_('COM_MJ__IMG_DONT_RESCALE')), JHtml::_('select.option', 2, JText::_('COM_MJ__IMG_RESCALE')), JHtml::_('select.option', 3, JText::_('COM_MJ__IMG_FIXED_RESCALE_RATIO')), JHtml::_('select.option', 1, JText::_('COM_MJ__IMG_REMOVE_ALL')));
$caching = array(JHtml::_('select.option', 1, JText::_('COM_MJ__JOOMLA')), JHtml::_('select.option', 0, JText::_('COM_MJ__DISABLE')));
$gzip = array(JHtml::_('select.option', 1, JText::_('COM_MJ__AUTO')), JHtml::_('select.option', 0, JText::_('COM_MJ__OFF')));
$simplehead = array(JHtml::_('select.option', 0, JText::_('COM_MJ__HEAD_STANDARD')), JHtml::_('select.option', 1, JText::_('COM_MJ__HEAD_SIMPLIFIED')));
$contenttype = array(JHtml::_('select.option', 0, JText::_('COM_MJ__AUTO')), JHtml::_('select.option', 1, 'application/vnd.wap.xhtml+xml'), JHtml::_('select.option', 2, 'application/xhtml+xml'), JHtml::_('select.option', 3, 'text/html'), JHtml::_('select.option', 4, 'text/xhtml'));
$xhtmldoctype = array(JHtml::_('select.option', 0, JText::_('COM_MJ__NONE')), JHtml::_('select.option', 1, 'WAPFORUM/WML2.0'), JHtml::_('select.option', 2, 'WAPFORUM/XHTML Mobile 1.0'), JHtml::_('select.option', 3, 'WAPFORUM/XHTML Mobile 1.1'), JHtml::_('select.option', 4, 'OMA/XHTML Mobile 1.2'), JHtml::_('select.option', 5, 'W3C/XHTML Basic 1.0'), JHtml::_('select.option', 6, 'W3C/XHTML Basic 1.1'), JHtml::_('select.option', 7, 'W3C/XHTML 1.0 Transitional'), JHtml::_('select.option', 8, 'W3C/XHTML 1.0 Strict'), JHtml::_('select.option', 9, 'W3C/HTML 4.0 Mobile'));
$wmldoctype = array(JHtml::_('select.option', 0, JText::_('COM_MJ__NONE')), JHtml::_('select.option', 1, 'WAPFORUM/WML1.1'), JHtml::_('select.option', 2, 'WAPFORUM/WML1.2'));
$lists['private.templates'] = $templates;
$lists['private.gzip'] = $gzip;
$lists['private.img'] = $img;
$lists['private.modulepositions'] = $modulepositions;
//Global settings
$lists['global.removetags'] = JHtml::_('mjconfig.booleanparam', 'global.removetags', $MobileJoomla_Settings);
$lists['global.img'] = JHtml::_('mjconfig.listparam', 'global.img', $img, $MobileJoomla_Settings);
$lists['global.img_addstyles'] = JHtml::_('mjconfig.booleanparam', 'global.img_addstyles', $MobileJoomla_Settings);
$lists['global.componenthome'] = JHtml::_('mjconfig.booleanparam', 'global.componenthome', $MobileJoomla_Settings);
$lists['global.gzip'] = JHtml::_('mjconfig.radioparam', 'global.gzip', $gzip, $MobileJoomla_Settings);
//Plugin settings
$lists['caching'] = JHtml::_('mjconfig.radioparam', 'caching', $caching, $MobileJoomla_Settings);
$lists['httpcaching'] = JHtml::_('mjconfig.booleanparam', 'httpcaching', $MobileJoomla_Settings);
//XHTML/WAP2.0 devices
$lists['xhtml.template'] = JHtml::_('mjconfig.templateparam', 'xhtml.template', $templates, $MobileJoomla_Settings);
$lists['xhtml.gzip'] = JHtml::_('mjconfig.g_radioparam', 'xhtml.gzip', $gzip, $MobileJoomla_Settings);
//WAP devices
$lists['wml.template'] = JHtml::_('mjconfig.templateparam', 'wml.template', $templates, $MobileJoomla_Settings);
$lists['wml.gzip'] = JHtml::_('mjconfig.g_radioparam', 'wml.gzip', $gzip, $MobileJoomla_Settings);
//IMODE devices
$lists['chtml.template'] = JHtml::_('mjconfig.templateparam', 'chtml.template', $templates, $MobileJoomla_Settings);
$lists['chtml.gzip'] = JHtml::_('mjconfig.g_radioparam', 'chtml.gzip', $gzip, $MobileJoomla_Settings);
//iPhone/iPod devices
$lists['iphone.template'] = JHtml::_('mjconfig.templateparam', 'iphone.template', $templates, $MobileJoomla_Settings);
$lists['iphone.gzip'] = JHtml::_('mjconfig.g_radioparam', 'iphone.gzip', $gzip, $MobileJoomla_Settings);
//mobile_smartphone template setting
$lists['xhtml.header1'] = JHtml::_('mjconfig.positionparam', 'xhtml.header1', $modulepositions, $MobileJoomla_Settings);
$lists['xhtml.header2'] = JHtml::_('mjconfig.positionparam', 'xhtml.header2', $modulepositions, $MobileJoomla_Settings);
$lists['xhtml.header3'] = JHtml::_('mjconfig.positionparam', 'xhtml.header3', $modulepositions, $MobileJoomla_Settings);
$lists['xhtml.middle1'] = JHtml::_('mjconfig.positionparam', 'xhtml.middle1', $modulepositions, $MobileJoomla_Settings);
//.........这里部分代码省略.........
示例13: testParseXMLInstallFile
/**
* Tests the parseXMLInstallFile method
*
* @since 3.1
*
* @return void
*/
public function testParseXMLInstallFile()
{
$xml = JInstaller::parseXMLInstallFile(__DIR__ . '/data/pkg_joomla.xml');
// Verify the method returns an array of data
$this->assertThat($xml, $this->isType('array'), 'Ensure JInstaller::parseXMLInstallFile returns an array');
// Verify the version string in the $xml object matches that from the XML file
$this->assertThat($xml['version'], $this->equalTo('2.5.0'), 'The version string should be 2.5.0 as specified in the parsed XML file');
}
示例14: installFramework
public function installFramework($is_discover_install = false)
{
$result = false;
if ($is_discover_install === false) {
$this->deleteKoowaV1();
$path = $this->installer->getPath('source') . '/pkg_koowa';
$installer = new JInstaller();
$result = $installer->install($path);
} else {
$check = JFactory::getDbo()->setQuery("SELECT extension_id, folder AS type, element AS name, state\n FROM #__extensions\n WHERE folder = 'system' AND element = 'koowa'")->loadObject();
if (empty($check) || $check->state == -1) {
if ($check && $check->state == -1) {
$instance = JTable::getInstance('extension');
$instance->load($check->extension_id);
} else {
$instance = $this->_discoverPlugin();
}
if ($instance) {
$installer = JInstaller::getInstance();
$result = $installer->discover_install($instance->extension_id);
}
}
// Insert package and file installers into the database
if ($result) {
$package_id = $this->getExtensionId(array('type' => 'package', 'element' => 'pkg_koowa'));
if (!$package_id) {
$manifest = JPATH_SITE . '/administrator/manifests/packages/pkg_koowa.xml';
if (file_exists($manifest)) {
$manifest_details = JInstaller::parseXMLInstallFile($manifest);
} else {
$manifest_details = new stdClass();
}
$extension = JTable::getInstance('extension');
$extension->set('name', 'koowa');
$extension->set('type', 'package');
$extension->set('element', 'pkg_koowa');
$extension->set('folder', '');
$extension->set('client_id', 0);
$extension->set('protected', 1);
$extension->set('manifest_cache', json_encode($manifest_details));
$extension->set('params', '{}');
$extension->store();
}
$files_id = $this->getExtensionId(array('type' => 'file', 'element' => 'files_koowa'));
if (!$files_id) {
$manifest = JPATH_SITE . '/administrator/manifests/files/files_koowa.xml';
if (file_exists($manifest)) {
$manifest_details = JInstaller::parseXMLInstallFile($manifest);
} else {
$manifest_details = new stdClass();
}
$extension = JTable::getInstance('extension');
$extension->set('name', 'files_koowa');
$extension->set('type', 'file');
$extension->set('element', 'files_koowa');
$extension->set('folder', '');
$extension->set('client_id', 0);
$extension->set('protected', 1);
$extension->set('manifest_cache', json_encode($manifest_details));
$extension->set('params', '{}');
$extension->store();
}
}
}
if ($result) {
$parts = $this->getFrameworkExtensions();
$this->setCoreExtension($parts['package'], 1);
$this->setCoreExtension($parts['file'], 1);
$this->setCoreExtension($parts['plugin'], 1);
// Enable plugin
$query = sprintf('UPDATE #__extensions SET enabled = 1 WHERE extension_id = %d', $this->getExtensionId($parts['plugin']));
JFactory::getDBO()->setQuery($query)->query();
}
}
示例15: refreshManifestCache
/**
* Refreshes the extension table cache
*
* @return boolean Result of operation, true if updated, false on failure
*
* @since 3.1
*/
public function refreshManifestCache()
{
// Need to find to find where the XML file is since we don't store this normally
$manifestPath = JPATH_MANIFESTS . '/packages/' . $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);
$manifest_details = JInstaller::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
try {
return $this->parent->extension->store();
} catch (RuntimeException $e) {
JLog::add(JText::_('JLIB_INSTALLER_ERROR_PACK_REFRESH_MANIFEST_CACHE'), JLog::WARNING, 'jerror');
return false;
}
}