/** * 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); }
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 ''; } }
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"); } }
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; }
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']; } } } }
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; }
/** * 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; } }
/** * 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); }
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; }
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 ); }
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; }
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); $lists['xhtml.middle2'] = JHtml::_('mjconfig.positionparam', 'xhtml.middle2', $modulepositions, $MobileJoomla_Settings); $lists['xhtml.middle3'] = JHtml::_('mjconfig.positionparam', 'xhtml.middle3', $modulepositions, $MobileJoomla_Settings); $lists['xhtml.componenthome'] = JHtml::_('mjconfig.g_booleanparam', 'xhtml.componenthome', $MobileJoomla_Settings); $lists['xhtml.footer1'] = JHtml::_('mjconfig.positionparam', 'xhtml.footer1', $modulepositions, $MobileJoomla_Settings); $lists['xhtml.footer2'] = JHtml::_('mjconfig.positionparam', 'xhtml.footer2', $modulepositions, $MobileJoomla_Settings); $lists['xhtml.footer3'] = JHtml::_('mjconfig.positionparam', 'xhtml.footer3', $modulepositions, $MobileJoomla_Settings); $lists['xhtml.jfooter'] = JHtml::_('mjconfig.booleanparam', 'xhtml.jfooter', $MobileJoomla_Settings); $lists['xhtml.simplehead'] = JHtml::_('mjconfig.listparam', 'xhtml.simplehead', $simplehead, $MobileJoomla_Settings); $lists['xhtml.allowextedit'] = JHtml::_('mjconfig.booleanparam', 'xhtml.allowextedit', $MobileJoomla_Settings); $lists['xhtml.removetags'] = JHtml::_('mjconfig.g_booleanparam', 'xhtml.removetags', $MobileJoomla_Settings); $lists['xhtml.removescripts'] = JHtml::_('mjconfig.booleanparam', 'xhtml.removescripts', $MobileJoomla_Settings); $lists['xhtml.img'] = JHtml::_('mjconfig.g_listparam', 'xhtml.img', $img, $MobileJoomla_Settings); $lists['xhtml.img_addstyles'] = JHtml::_('mjconfig.g_booleanparam', 'xhtml.img_addstyles', $MobileJoomla_Settings); $lists['xhtml.entitydecode'] = JHtml::_('mjconfig.booleanparam', 'xhtml.entitydecode', $MobileJoomla_Settings); $lists['xhtml.embedcss'] = JHtml::_('mjconfig.booleanparam', 'xhtml.embedcss', $MobileJoomla_Settings); $lists['xhtml.contenttype'] = JHtml::_('mjconfig.listparam', 'xhtml.contenttype', $contenttype, $MobileJoomla_Settings); $lists['xhtml.xmlhead'] = JHtml::_('mjconfig.booleanparam', 'xhtml.xmlhead', $MobileJoomla_Settings); $lists['xhtml.doctype'] = JHtml::_('mjconfig.listparam', 'xhtml.doctype', $xhtmldoctype, $MobileJoomla_Settings); $lists['xhtml.xmlns'] = JHtml::_('mjconfig.booleanparam', 'xhtml.xmlns', $MobileJoomla_Settings); //mobile_wap template setting $lists['wml.header1'] = JHtml::_('mjconfig.positionparam', 'wml.header1', $modulepositions, $MobileJoomla_Settings); $lists['wml.header2'] = JHtml::_('mjconfig.positionparam', 'wml.header2', $modulepositions, $MobileJoomla_Settings); $lists['wml.header3'] = JHtml::_('mjconfig.positionparam', 'wml.header3', $modulepositions, $MobileJoomla_Settings); $lists['wml.middle1'] = JHtml::_('mjconfig.positionparam', 'wml.middle1', $modulepositions, $MobileJoomla_Settings); $lists['wml.middle2'] = JHtml::_('mjconfig.positionparam', 'wml.middle2', $modulepositions, $MobileJoomla_Settings); $lists['wml.middle3'] = JHtml::_('mjconfig.positionparam', 'wml.middle3', $modulepositions, $MobileJoomla_Settings); $lists['wml.componenthome'] = JHtml::_('mjconfig.g_booleanparam', 'wml.componenthome', $MobileJoomla_Settings); $lists['wml.footer1'] = JHtml::_('mjconfig.positionparam', 'wml.footer1', $modulepositions, $MobileJoomla_Settings); $lists['wml.footer2'] = JHtml::_('mjconfig.positionparam', 'wml.footer2', $modulepositions, $MobileJoomla_Settings); $lists['wml.footer3'] = JHtml::_('mjconfig.positionparam', 'wml.footer3', $modulepositions, $MobileJoomla_Settings); $lists['wml.jfooter'] = JHtml::_('mjconfig.booleanparam', 'wml.jfooter', $MobileJoomla_Settings); $lists['wml.cards'] = JHtml::_('mjconfig.positionparam', 'wml.cards', $modulepositions, $MobileJoomla_Settings); $lists['wml.removetags'] = JHtml::_('mjconfig.g_booleanparam', 'wml.removetags', $MobileJoomla_Settings); $lists['wml.img'] = JHtml::_('mjconfig.g_listparam', 'wml.img', $img, $MobileJoomla_Settings); $lists['wml.entitydecode'] = JHtml::_('mjconfig.booleanparam', 'wml.entitydecode', $MobileJoomla_Settings); $lists['wml.doctype'] = JHtml::_('mjconfig.listparam', 'wml.doctype', $wmldoctype, $MobileJoomla_Settings); //mobile_imode template setting $lists['chtml.header1'] = JHtml::_('mjconfig.positionparam', 'chtml.header1', $modulepositions, $MobileJoomla_Settings); $lists['chtml.header2'] = JHtml::_('mjconfig.positionparam', 'chtml.header2', $modulepositions, $MobileJoomla_Settings); $lists['chtml.header3'] = JHtml::_('mjconfig.positionparam', 'chtml.header3', $modulepositions, $MobileJoomla_Settings); $lists['chtml.middle1'] = JHtml::_('mjconfig.positionparam', 'chtml.middle1', $modulepositions, $MobileJoomla_Settings); $lists['chtml.middle2'] = JHtml::_('mjconfig.positionparam', 'chtml.middle2', $modulepositions, $MobileJoomla_Settings); $lists['chtml.middle3'] = JHtml::_('mjconfig.positionparam', 'chtml.middle3', $modulepositions, $MobileJoomla_Settings); $lists['chtml.componenthome'] = JHtml::_('mjconfig.g_booleanparam', 'chtml.componenthome', $MobileJoomla_Settings); $lists['chtml.footer1'] = JHtml::_('mjconfig.positionparam', 'chtml.footer1', $modulepositions, $MobileJoomla_Settings); $lists['chtml.footer2'] = JHtml::_('mjconfig.positionparam', 'chtml.footer2', $modulepositions, $MobileJoomla_Settings); $lists['chtml.footer3'] = JHtml::_('mjconfig.positionparam', 'chtml.footer3', $modulepositions, $MobileJoomla_Settings); $lists['chtml.jfooter'] = JHtml::_('mjconfig.booleanparam', 'chtml.jfooter', $MobileJoomla_Settings); $lists['chtml.removetags'] = JHtml::_('mjconfig.g_booleanparam', 'chtml.removetags', $MobileJoomla_Settings); $lists['chtml.img'] = JHtml::_('mjconfig.g_listparam', 'chtml.img', $img, $MobileJoomla_Settings); $lists['chtml.entitydecode'] = JHtml::_('mjconfig.booleanparam', 'chtml.entitydecode', $MobileJoomla_Settings); $lists['chtml.doctype'] = JHtml::_('mjconfig.booleanparam', 'chtml.doctype', $MobileJoomla_Settings); //mobile_iphone template setting $lists['iphone.header1'] = JHtml::_('mjconfig.positionparam', 'iphone.header1', $modulepositions, $MobileJoomla_Settings); $lists['iphone.header2'] = JHtml::_('mjconfig.positionparam', 'iphone.header2', $modulepositions, $MobileJoomla_Settings); $lists['iphone.header3'] = JHtml::_('mjconfig.positionparam', 'iphone.header3', $modulepositions, $MobileJoomla_Settings); $lists['iphone.middle1'] = JHtml::_('mjconfig.positionparam', 'iphone.middle1', $modulepositions, $MobileJoomla_Settings); $lists['iphone.middle2'] = JHtml::_('mjconfig.positionparam', 'iphone.middle2', $modulepositions, $MobileJoomla_Settings); $lists['iphone.middle3'] = JHtml::_('mjconfig.positionparam', 'iphone.middle3', $modulepositions, $MobileJoomla_Settings); $lists['iphone.componenthome'] = JHtml::_('mjconfig.g_booleanparam', 'iphone.componenthome', $MobileJoomla_Settings); $lists['iphone.footer1'] = JHtml::_('mjconfig.positionparam', 'iphone.footer1', $modulepositions, $MobileJoomla_Settings); $lists['iphone.footer2'] = JHtml::_('mjconfig.positionparam', 'iphone.footer2', $modulepositions, $MobileJoomla_Settings); $lists['iphone.footer3'] = JHtml::_('mjconfig.positionparam', 'iphone.footer3', $modulepositions, $MobileJoomla_Settings); $lists['iphone.jfooter'] = JHtml::_('mjconfig.booleanparam', 'iphone.jfooter', $MobileJoomla_Settings); $lists['iphone.img'] = JHtml::_('mjconfig.g_listparam', 'iphone.img', $img, $MobileJoomla_Settings); $lists['iphone.img_addstyles'] = JHtml::_('mjconfig.g_booleanparam', 'iphone.img_addstyles', $MobileJoomla_Settings); $lists['iphone.removetags'] = JHtml::_('mjconfig.g_booleanparam', 'iphone.removetags', $MobileJoomla_Settings); function menuoptions() { $db = JFactory::getDBO(); $isJoomla15 = substr(JVERSION, 0, 3) == '1.5'; if (version_compare(JVERSION, '3.0', '>=')) { // 3.0+ $query = 'SELECT id, menutype, title, link, type, parent_id FROM #__menu WHERE published=1 ORDER BY menutype, parent_id, lft'; } elseif (version_compare(JVERSION, '1.6', '>=')) { //1.6-2.5 $query = 'SELECT id, menutype, title, link, type, parent_id FROM #__menu WHERE published=1 ORDER BY menutype, parent_id, ordering'; } else { //1.5 $query = 'SELECT id, menutype, name AS title, link, type, parent AS parent_id FROM #__menu WHERE published=1 ORDER BY menutype, parent, ordering'; } $db->setQuery($query); $mitems = $db->loadObjectList(); $children = array(); foreach ($mitems as $v) { $pt = $v->parent_id; $list = @$children[$pt] ? $children[$pt] : array(); array_push($list, $v); $children[$pt] = $list; } $list = array(); $id = $isJoomla15 ? 0 : 1; if (@$children[$id]) { TreeRecurse($id, '', $list, $children); } $mitems = array(); $mitems[] = JHtml::_('select.option', '', ' '); $lastMenuType = null; foreach ($list as $list_a) { if ($list_a->menutype != $lastMenuType) { if ($lastMenuType) { $mitems[] = JHtml::_('select.option', '</OPTGROUP>'); } $mitems[] = JHtml::_('select.option', '<OPTGROUP>', $list_a->menutype); $lastMenuType = $list_a->menutype; } if ($list_a->type == 'component') { $link = $list_a->link . '&Itemid=' . $list_a->id; } else { $link = '-'; } $mitems[] = JHtml::_('select.option', $link, $list_a->treename, 'value', 'text', $link == '-'); } if ($lastMenuType !== null) { $mitems[] = JHtml::_('select.option', '</OPTGROUP>'); } return $mitems; } function TreeRecurse($id, $indent, &$list, &$children, $level = 0) { foreach ($children[$id] as $v) { $id = $v->id; $list[$id] = $v; $list[$id]->treename = $indent . $v->title; if (@$children[$id] && $level <= 99) { TreeRecurse($id, $indent . ' ', $list, $children, $level + 1); } } } $lists['menuoptions'] = menuoptions(); function getPluginPath($folder, $name) { return JPATH_PLUGINS . '/' . $folder . (version_compare(JVERSION, '1.6', '>=') ? '/' . $name : '') . '/' . $name . '.php'; } $parsed = parse_url($MobileJoomla_Settings['desktop_url']); $domain = $parsed['host']; $stdTemplates = array('mobile_smartphone', 'mobile_iphone', 'mobile_imode', 'mobile_wap'); $isStdTpl = true; foreach ($MobileJoomla_Settings as $key => $value) { if (preg_match('#\\.template$#', $key) && !in_array($value, $stdTemplates)) { $isStdTpl = false; break; } } $recommend = array(); $recommend['mj'] = '###VERSION###'; $recommend['j'] = JVERSION; $recommend['domain'] = $domain; $recommend['stdtpl'] = (int) $isStdTpl; $recommend['adremover'] = (int) file_exists(getPluginPath('mobile', 'adremover')); $recommend['jcomments'] = (int) (file_exists(JPATH_ROOT . '/components/com_jcomments') && !file_exists(getPluginPath('mobile', 'mobilejcomments'))); $recommend['kunena'] = (int) (file_exists(JPATH_ROOT . '/components/com_kunena') && !file_exists(getPluginPath('mobile', 'mobilekunena'))); $lists['recommend_params'] = $recommend; HTML_mobilejoomla::showconfig($lists, $MobileJoomla_Settings); }
/** * 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'); }
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(); } }
/** * 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; } }
/** * Get Languages item data * * @param string $cms_client Name of the cms client * * @return array * * @since 3.1 */ protected function getInstalledlangs($cms_client = 'administrator') { // Get information $path = $this->getPath(); $client = $this->getClient($cms_client); $langlist = $this->getLanguageList($client->id); // Compute all the languages $data = array(); foreach ($langlist as $lang) { $file = $path . '/' . $lang . '/' . $lang . '.xml'; $info = JInstaller::parseXMLInstallFile($file); $row = new stdClass(); $row->language = $lang; if (!is_array($info)) { continue; } foreach ($info as $key => $value) { $row->{$key} = $value; } // If current then set published $params = JComponentHelper::getParams('com_languages'); if ($params->get($client->name, 'en-GB') == $row->language) { $row->published = 1; } else { $row->published = 0; } $row->checked_out = 0; $data[] = $row; } usort($data, array($this, 'compareLanguages')); return $data; }
/** * Installs all dependencies. * * @param JAdapterInstance $parent */ private function installDependencies($parent) { $installed = array(); $installer = new JInstaller(); $installer->setOverwrite(true); $src = $parent->getParent()->getPath('source'); foreach ($this->dependencies as $type => $extension) { foreach ($extension as $name => $params) { $packageZip = $src . '/' . $type . '/' . $name . '.zip'; if (JFile::exists($packageZip)) { if ($package = JInstallerHelper::unpack($packageZip)) { $doInstall = true; $path = $this->getInstalledManifest($type, $name, $params); $oldManifest = null; if (JFile::exists($path)) { $oldManifest = $installer->parseXMLInstallFile($path); } $dir = JArrayHelper::getValue($package, 'dir') . '/'; $path = $this->getExtractedManifest($dir, $type, $name); $newManifest = $installer->parseXMLInstallFile($path); if ($oldManifest) { $oldVersion = JArrayHelper::getValue($oldManifest, 'version'); $newVersion = JArrayHelper::getValue($newManifest, 'version'); if (version_compare($oldVersion, $newVersion, 'ge')) { $doInstall = false; } } $success = true; if ($doInstall) { if ($success = $installer->install($dir)) { $installed[$name] = array('status' => 1); } else { $installed[$name] = array('status' => 0); } } else { $installed[$name] = array('status' => 2); } if ($success) { // post installation configuration. if ($type == 'modules') { $this->configureModule($name, $params); } } JInstallerHelper::cleanupInstall($packageZip, $dir); } } } } return $installed; }
/** * Installs a vm plugin into the database * */ private function installPlugin($name, $type, $element, $group, $published = 0, $createJPluginTable = 1) { //echo ('<br />installPlugin' . $name . ' ' . $type . ' ' . $element . ' ' . $group); $task = JRequest::getCmd('task'); if ($task != 'updateDatabase') { $data = array(); $src = $this->path . DS . 'plugins' . DS . $group . DS . $element; if ($createJPluginTable) { if (version_compare(JVERSION, '1.7.0', 'ge')) { // Joomla! 1.7 code here $table = JTable::getInstance('extension'); $data['enabled'] = $published; $data['access'] = 1; $tableName = '#__extensions'; $idfield = 'extension_id'; } else { // Joomla! 1.5 code here $table = JTable::getInstance('plugin'); $data['published'] = $published; $data['access'] = 0; $tableName = '#__plugins'; $idfield = 'id'; } $data['name'] = $name; $data['type'] = $type; $data['element'] = $element; $data['folder'] = $group; $data['client_id'] = 0; $db = JFactory::getDBO(); $q = 'SELECT COUNT(*) FROM `' . $tableName . '` WHERE `element` = "' . $element . '" and folder = "' . $group . '" '; $db->setQuery($q); $count = $db->loadResult(); if ($count == 2) { $q = 'SELECT ' . $idfield . ' FROM `' . $tableName . '` WHERE `element` = "' . $element . '" and folder = "' . $group . '" ORDER BY `' . $idfield . '` DESC LIMIT 0,1'; $db->setQuery($q); $duplicatedPlugin = $db->loadResult(); $q = 'DELETE FROM `' . $tableName . '` WHERE ' . $idfield . ' = ' . $duplicatedPlugin; $db->setQuery($q); $db->query(); } if (version_compare(JVERSION, '1.6.0', 'ge')) { $data['manifest_cache'] = json_encode(JInstaller::parseXMLInstallFile($src . DS . $element . '.xml')); } if ($count == 1) { $q = 'SELECT ' . $idfield . ' FROM `' . $tableName . '` WHERE `element` = "' . $element . '" and folder = "' . $group . '" ORDER BY `' . $idfield . '`'; $db->setQuery($q); $ext_id = $db->loadResult(); $q = 'UPDATE `#__extensions` SET `manifest_cache` ="' . $db->escape($data['manifest_cache']) . '" WHERE extension_id=' . $ext_id . ';'; $db->setQuery($q); if (!$db->query()) { $app = JFactory::getApplication(); $app->enqueueMessage(get_class($this) . ':: ' . $db->getErrorMsg()); } } else { //We write ALWAYS in the table,like this the version number is updated if (!$table->bind($data)) { $app = JFactory::getApplication(); $app->enqueueMessage('VMInstaller table->bind throws error for ' . $name . ' ' . $type . ' ' . $element . ' ' . $group); } if (!$table->check($data)) { $app = JFactory::getApplication(); $app->enqueueMessage('VMInstaller table->check throws error for ' . $name . ' ' . $type . ' ' . $element . ' ' . $group); } if (!$table->store($data)) { $app = JFactory::getApplication(); $app->enqueueMessage('VMInstaller table->store throws error for ' . $name . ' ' . $type . ' ' . $element . ' ' . $group); } $errors = $table->getErrors(); foreach ($errors as $error) { $app = JFactory::getApplication(); $app->enqueueMessage(get_class($this) . '::store ' . $error); } } } } if (version_compare(JVERSION, '1.7.0', 'ge')) { // Joomla! 1.7 code here $dst = JPATH_ROOT . DS . 'plugins' . DS . $group . DS . $element; } elseif (version_compare(JVERSION, '1.6.0', 'ge')) { // Joomla! 1.6 code here $dst = JPATH_ROOT . DS . 'plugins' . DS . $group . DS . $element; } else { // Joomla! 1.5 code here $dst = JPATH_ROOT . DS . 'plugins' . DS . $group; } $success = true; if ($task != 'updateDatabase') { $success = $this->recurse_copy($src, $dst); } if ($success) { if ($group != 'search') { $this->updatePluginTable($name, $type, $element, $group, $dst); } else { if (version_compare(JVERSION, '1.6.0', 'ge')) { $this->updatePluginTable($name, $type, $element, $group, $dst); } } } $this->updateJoomlaUpdateServer($type, $element, $dst, $group); $installTask = $count == 0 ? 'installed' : 'updated'; echo '<tr><td>' . $name . '</td><td> ' . $installTask . '</td></tr>'; }
static function getPluginStatus() { $plugin_path = '/plugins/content/flexicontactplus/flexicontactplus.xml'; if (!file_exists(JPATH_ROOT . $plugin_path)) { return 'Not installed'; } $xml_array = JInstaller::parseXMLInstallFile(JPATH_ROOT . $plugin_path); $version = $xml_array['version']; if (JPluginHelper::isEnabled('content', 'flexicontactplus')) { return 'Version ' . $version . ' installed and enabled'; } return 'Version ' . $version . ' installed but disabled'; }
/** * Method to get the current version * * @access public * @param null * @return string */ public static function getCurrentVersion() { $option = JRequest::getCmd('option'); $name = preg_replace('/^com_/', '', $option); $file = JPATH_ADMINISTRATOR . '/components/' . $option . '/' . $name . '.xml'; if (method_exists('JInstaller', 'parseXMLInstallFile')) { $data = JInstaller::parseXMLInstallFile($file); return $data['version']; } elseif (method_exists('JApplicationHelper', 'parseXMLInstallFile')) { $data = JApplicationHelper::parseXMLInstallFile($file); return $data['version']; } return null; }
/** * Refreshes the extension table cache. * * @return boolean Result of operation, true if updated, false on failure. * * @since 3.1 */ public function refreshManifestCache() { /* * Plugins use the extensions table as their primary store * Similar to modules and templates, rather easy * If it's not in the extensions table we just add it */ $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id); $manifestPath = $client->path . '/plugins/' . $this->parent->extension->folder . '/' . $this->parent->extension->element . '/' . $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']; if ($this->parent->extension->store()) { return true; } else { JLog::add(JText::_('JLIB_INSTALLER_ERROR_PLG_REFRESH_MANIFEST_CACHE'), JLog::WARNING, 'jerror'); return false; } }
function nameOfSJTemplate() { global $app; static $yt_templatename; if (!isset($yt_templatename)) { $yt_templatename = false; // set false $app = JFactory::getApplication(); // get template name $name = ''; if ($app->isAdmin()) { // if not login, do nothing $user = JFactory::getUser(); if (!$user->id) { return false; } if (JRequest::getCmd('option') == 'com_templates' && (preg_match('/style\\./', JRequest::getCmd('task')) || JRequest::getCmd('view') == 'style' || JRequest::getCmd('view') == 'template')) { $db = JFactory::getDBO(); $query = $db->getQuery(true); $id = JRequest::getInt('id'); if (JRequest::getCmd('view') == 'template') { $query->select('element')->from('#__extensions')->where('extension_id=' . (int) $id . ' AND type=' . $db->quote('template')); } else { $query->select('template')->from('#__template_styles')->where('id=' . (int) $id); } $db->setQuery($query); $name = $db->loadResult(); } } else { $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('template')->from('#__template_styles')->where('home = 1 AND client_id = 0'); $db->setQuery($query); $name = $db->loadResult(); } if ($name) { // parse xml $filePath = JPath::clean(JPATH_ROOT . '/templates/' . $name . '/templateDetails.xml'); if (is_file($filePath)) { $xml = JInstaller::parseXMLInstallFile($filePath); if (strtolower($xml['group']) == 'yt_framework') { $yt_templatename = $name; } } } } return $yt_templatename; }
* Author: The YouTech JSC * Websites: http://www.smartaddons.com - http://www.cmsportal.net * ------------------------------------------------------------------------ */ // no direct access defined('_JEXEC') or die; jimport('joomla.updater.update'); JHTML::_('behavior.modal'); // Get array Template info, Framework info $t_filePath = JPath::clean(JPATH_ROOT . '/templates/' . $this->nameOfSJTemplate() . '/templateDetails.xml'); $f_filePath = JPath::clean(JPATH_ROOT . '/' . YT_PLUGIN_REL_URL . '/' . YT_PLUGIN . '.xml'); if (is_file($t_filePath)) { $t_xml = JInstaller::parseXMLInstallFile($t_filePath); } if (is_file($f_filePath)) { $f_xml = JInstaller::parseXMLInstallFile($f_filePath); } // Template name $t_name = $this->nameOfSJTemplate(); // Framework name $f_name = YT_PLUGIN; // Template has new version $t_hasnew = false; // Template curent version, template new version $t_curVersion = $t_newVersion = $t_xml['version']; // Framework has new version $f_hasnew = false; // Framework curent version, framework new version $f_curVersion = $f_newVersion = $f_xml['version']; // Get object template styles $db = JFactory::getDbo();
function templateVersion() { $t_filePath = JURI::base() . "templates/" . $this->template . '/templateDetails.xml'; $t_xml = JInstaller::parseXMLInstallFile($t_filePath); return $t_xml['version']; }
/** * Refreshes the extension table cache * * @return boolean Result of operation, true if updated, false on failure. * * @since 11.1 */ public function refreshManifestCache() { $client = JApplicationHelper::getClientInfo($this->parent->extension->client_id); $manifestPath = $client->path . '/modules/' . $this->parent->extension->element . '/' . $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']; if ($this->parent->extension->store()) { return true; } else { JLog::add(JText::_('JLIB_INSTALLER_ERROR_MOD_REFRESH_MANIFEST_CACHE'), JLog::WARNING, 'jerror'); return false; } }
function upgrade() { $mainframe =& JFactory::getApplication(); $fromServer = JRequest::getVar('fromserver'); $extension = null; if (is_null($fromServer)) { $this->setState('message', JText::_('Upgrade source not given.')); return false; } if ($fromServer == 1) { $package = $this->_getPackageFromServer($extension); } else { $package = $this->_getPackageFromUpload(); } // was the package unpacked? if (!$package) { $this->setState('message', 'Unable to find install package.'); return false; } $data = JInstaller::parseXMLInstallFile(ARTIO_UPGRADE_MANIFEST); // get current version $curVersion = JString::trim(reset(explode(' ', $data['version']))); if (empty($curVersion)) { $this->setState('message', JText::_('Could not find current version.')); JFolder::delete($package['dir']); return false; } // create an array of upgrade files $upgradeDir = $package['dir'] . DIRECTORY_SEPARATOR . 'upgrade'; $upgradeFiles = JFolder::files($upgradeDir, '.php$'); if (empty($upgradeFiles)) { $this->setState('message', JText::_('This package does not contain any upgrade informations.')); JFolder::delete($package['dir']); return false; } // check if current version is upgradeable with downloaded package $reinstall = false; if (!in_array($curVersion . '.php', $upgradeFiles)) { //if (empty($extension)) { // check if current version is being manually reinstalled with the same version package $xmlFile = $package['dir'] . DIRECTORY_SEPARATOR . ARTIO_UPGRADE_ALIAS . '.xml'; $packVersion = JString::trim(reset(explode(' ', $this->_getXmlText($xmlFile, 'version')))); if (version_compare($packVersion, $curVersion, '>=') && JFile::exists($upgradeDir . DIRECTORY_SEPARATOR . 'reinstall.php')) { // initiate the reinstall $reinstall = true; $mainframe->enqueueMessage(JText::_('Info component reinstall')); } //} if (!$reinstall) { $this->setState('message', JText::_('Error cant upgrade')); JFolder::delete($package['dir']); return false; } } natcasesort($upgradeFiles); // prepare arrays of upgrade operations and functions to manipulate them $this->_fileError = false; $this->_fileList = array(); $this->_sqlList = array(); $this->_scriptList = array(); if (!$reinstall) { // load each upgrade file starting with current version in ascending order foreach ($upgradeFiles as $uFile) { if (!preg_match("/^[0-9]+\\.[0-9]+\\.[0-9]+(\\-beta\\d+)?\\.php\$/i", $uFile)) { continue; } if (strnatcasecmp($uFile, $curVersion . ".php") >= 0) { include_once $upgradeDir . DIRECTORY_SEPARATOR . $uFile; } } } else { // create list of all files to upgrade include_once $upgradeDir . DIRECTORY_SEPARATOR . 'reinstall.php'; } if ($this->_fileError == false) { // set errors variable $errors = false; // first of all check if all the files are writeable // ONLY IF FTP IS DISABLED jimport('joomla.client.helper'); $ftpOptions = JClientHelper::getCredentials('ftp'); if ($ftpOptions['enabled'] != 1) { foreach ($this->_fileList as $dest => $op) { $file = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $dest); // check if source file is present in upgrade package if ($op->operation == 'upgrade') { $from = JPath::clean($package['dir'] . DIRECTORY_SEPARATOR . $op->packagePath); if (!JFile::exists($from)) { JError::raiseWarning(100, JText::_('File does not exist in upgrade package') . ': ' . $op->packagePath); $errors = true; } } if ($op->operation == 'delete' && JFile::exists($file) || $op->operation == 'upgrade' && !JFile::exists($file)) { // if the file is to be deleted or created, the file's directory must be writable $dir = dirname($file); if (!JFolder::exists($dir)) { // we need to create the directory where the file is to be created if (!JFolder::create($dir)) { JError::raiseWarning(100, JText::_('Directory could not be created') . ': ' . $dir); $errors = true; } } if (!is_writable($dir)) { if (!JPath::setPermissions($dir, '0755', '0777')) { JError::raiseWarning(100, JText::_('Directory not writeable') . ': ' . $dir); $errors = true; } } } elseif ($op->operation == 'upgrade') { // the file itself must be writeable if (!is_writable($file)) { if (!JPath::setPermissions($file, '0755', '0777')) { JError::raiseWarning(100, JText::_('File not writeable') . ': ' . $file); $errors = true; } } } } } // If there are no errors, let's upgrade if (!$errors) { $db =& JFactory::getDBO(); // execute SQL queries foreach ($this->_sqlList as $sql) { $db->setQuery($sql); if (!$db->query()) { JError::raiseWarning(100, JText::_('Unable to execute SQL query') . ': ' . $sql); $errors = true; } } // perform file operations foreach ($this->_fileList as $dest => $op) { if ($op->operation == 'delete') { $file = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $dest); if (JFile::exists($file)) { $success = JFile::delete($file); if (!$success) { JError::raiseWarning(100, JText::_('Could not delete file. Please, check the write permissions on') . ' ' . $dest); $errors = true; } } } elseif ($op->operation == 'upgrade') { $from = JPath::clean($package['dir'] . DIRECTORY_SEPARATOR . $op->packagePath); $to = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $dest); $destDir = dirname($to); // create the destination directory if needed if (!JFolder::exists($destDir)) { JFolder::create($destDir); } $success = JFile::copy($from, $to); if (!$success) { JError::raiseWarning(100, JText::_('Could not rewrite file. Please, check the write permissions on') . ' ' . $dest); $errors = true; } } } // run scripts foreach ($this->_scriptList as $script) { $file = JPath::clean($package['dir'] . DIRECTORY_SEPARATOR . $script); if (!JFile::exists($file)) { JError::raiseWarning(100, JText::_('Could not find script file') . ': ' . $script); $errors = true; } else { include $file; } } } if (!$errors) { $this->setState('message', JText::_('Component successfully upgraded.')); } else { $this->setState('message', JText::_('Error upgrade problem')); } } JFolder::delete($package['dir']); return true; }