Example #1
0
function com_install()
{
    if (defined('_JEXEC') && class_exists('JApplication')) {
        $config = JFactory::getConfig();
        $config->setValue('config.live_site', substr_replace(JURI::root(), '', -1, 1));
        $url = JURI::root() . 'administrator/index.php?option=com_jcomments&task=postinstall';
        $version = new JVersion();
        if (version_compare('1.6.0', $version->getShortVersion()) > 0) {
            require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'language.php';
            JCommentsInstallerLanguageHelper::convertLanguages15();
        }
    } else {
        global $mainframe;
        $componentPath = $mainframe->getCfg('absolute_path') . DS . 'components' . DS . 'com_jcomments';
        require_once $componentPath . DS . 'libraries' . DS . 'joomlatune' . DS . 'filesystem.php';
        require_once $componentPath . DS . 'jcomments.legacy.php';
        require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'installer.php';
        JCommentsInstallerHelper::extractJCommentsLibraryConvert();
        if (is_file($componentPath . DS . 'libraries' . DS . 'convert' . DS . 'utf8.class.php')) {
            require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'language.php';
            JCommentsInstallerLanguageHelper::convertLanguages10();
        }
        $url = $mainframe->getCfg('live_site') . '/administrator/index2.php?option=com_jcomments&task=postinstall';
    }
    if (headers_sent()) {
        echo '<script type="text/javascript">document.location.href="' . $url . '";</script>';
    } else {
        header('Location: ' . $url);
    }
}
Example #2
0
function com_install()
{
    if (defined('_JEXEC') && class_exists('JApplication')) {
        $config =& JFactory::getConfig();
        $config->setValue('config.live_site', substr_replace(JURI::root(), '', -1, 1));
        $url = JURI::root() . 'administrator/index.php?option=com_jcomments&task=postinstall';
    } else {
        global $mainframe;
        $msg = '';
        $componentPath = $mainframe->getCfg('absolute_path') . DS . 'components' . DS . 'com_jcomments';
        require_once $componentPath . DS . 'libraries' . DS . 'joomlatune' . DS . 'filesystem.php';
        require_once $componentPath . DS . 'jcomments.legacy.php';
        // install libraries for Joomla 1.0
        require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'installer.php';
        JCommentsInstallerHelper::extractJCommentsLibraryConvert();
        if (is_file($componentPath . DS . 'libraries' . DS . 'convert' . DS . 'utf8.class.php')) {
            // prepare language files
            require_once dirname(__FILE__) . DS . 'install' . DS . 'helpers' . DS . 'language.php';
            JCommentsInstallerLanguageHelper::convertLanguages();
        } else {
            $msg = 'Error unpacking JCommentsUtf8 library!';
        }
        $url = $mainframe->getCfg('live_site') . '/administrator/index2.php?option=com_jcomments&task=postinstall';
        if ($msg != '') {
            $url = $url . '&mosmsg=' . $msg;
        }
    }
    if (headers_sent()) {
        echo "<script>document.location.href='{$url}';</script>\n";
    } else {
        header('Location: ' . $url);
    }
}
Example #3
0
 public static function convertLanguages10()
 {
     global $mainframe;
     $joomlaLanguagesPath = $mainframe->getCfg('absolute_path') . '/language';
     $componentPath = $mainframe->getCfg('absolute_path') . '/components/com_jcomments';
     require_once $componentPath . '/libraries/convert/utf8.class.php';
     require_once $componentPath . '/libraries/joomlatune/filesystem.php';
     require_once $componentPath . '/libraries/joomlatune/language.tools.php';
     $codeMap = JoomlaTuneLanguageTools::getLanguageCodes();
     $joomlaLanguageFiles = JoomlaTuneFS::readDirectory($joomlaLanguagesPath, '[a-z]+\\.xml', false, false);
     $joomlaLanguages = array();
     foreach ($joomlaLanguageFiles as $file) {
         $joomlaLanguages[] = str_replace('.xml', '', $file);
     }
     $path = $componentPath . '/languages';
     $filter = '[a-z]{2}-[A-Z]{2}\\.com_jcomments\\.ini';
     $files = JoomlaTuneFS::readDirectory($path, $filter, false, true);
     $files2 = JoomlaTuneFS::readDirectory($path . '/administrator', $filter, false, true);
     $files = array_merge($files, $files2);
     foreach ($files as $file) {
         $m = array();
         preg_match('#([a-z]{2}-[A-Z]{2})#', (string) $file, $m);
         $code = $m[0];
         $language = isset($codeMap[$code]) ? $codeMap[$code][0] : '';
         $charset = isset($codeMap[$code]) ? $codeMap[$code][1] : 'iso-8859-1';
         if ($language != '' && in_array($language, $joomlaLanguages)) {
             if (defined('_ISO2')) {
                 $charset = strtolower(_ISO2);
                 if ($charset == 'utf-8' || $charset == 'utf8') {
                     $newFile = str_replace($code . '.com_jcomments.ini', $language . '.ini', $file);
                     @copy((string) $file, $newFile);
                 } else {
                     JCommentsInstallerLanguageHelper::_convertFile10($file, $code, $charset, $language);
                 }
             } else {
                 JCommentsInstallerLanguageHelper::_convertFile10($file, $code, $charset, $language);
             }
         }
     }
     unset($codeMap);
 }