/** * searches upgrade dir for lang pack files. * * @return string HTML of available lang packs */ function getLangPacks($display_commit = true, $types = array('langpack'), $notice_text = '') { global $mod_strings; global $next_step; global $base_upgrade_dir; if (empty($notice_text)) { $notice_text = $mod_strings['LBL_LANG_PACK_READY']; } $ret = "<tr><td colspan=7 align=left>{$notice_text}</td></tr>"; //$ret .="<table width='100%' cellpadding='0' cellspacing='0' border='0'>"; $ret .= "<tr>\n <td width='20%' ><b>{$mod_strings['LBL_ML_NAME']}</b></td>\n <td width='15%' ><b>{$mod_strings['LBL_ML_VERSION']}</b></td>\n <td width='15%' ><b>{$mod_strings['LBL_ML_PUBLISHED']}</b></td>\n <td width='15%' ><b>{$mod_strings['LBL_ML_UNINSTALLABLE']}</b></td>\n <td width='20%' ><b>{$mod_strings['LBL_ML_DESCRIPTION']}</b></td>\n <td width='7%' ></td>\n <td width='1%' ></td>\n <td width='7%' ></td>\n </tr>\n"; $files = array(); // duh, new installs won't have the upgrade folders if (!is_dir($base_upgrade_dir)) { mkdir_recursive($base_upgrade_dir); } $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); foreach ($subdirs as $subdir) { mkdir_recursive("{$base_upgrade_dir}/{$subdir}"); } $files = findAllFiles($base_upgrade_dir, $files); $hidden_input = ''; unset($_SESSION['hidden_input']); foreach ($files as $file) { if (!preg_match("#.*\\.zip\$#", $file)) { continue; } // skip installed lang packs if (isset($_SESSION['INSTALLED_LANG_PACKS']) && in_array($file, $_SESSION['INSTALLED_LANG_PACKS'])) { continue; } // handle manifest.php $target_manifest = remove_file_extension($file) . '-manifest.php'; $license_file = remove_file_extension($file) . '-license.txt'; include $target_manifest; if (!empty($types)) { if (!in_array(strtolower($manifest['type']), $types)) { continue; } } $md5_matches = array(); if ($manifest['type'] == 'module') { $uh = new UpgradeHistory(); $upgrade_content = clean_path($file); $the_base = basename($upgrade_content); $the_md5 = md5_file($upgrade_content); $md5_matches = $uh->findByMd5($the_md5); } if ($manifest['type'] != 'module' || 0 == sizeof($md5_matches)) { $name = empty($manifest['name']) ? $file : $manifest['name']; $version = empty($manifest['version']) ? '' : $manifest['version']; $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date']; $icon = ''; $description = empty($manifest['description']) ? 'None' : $manifest['description']; $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes'; $manifest_type = $manifest['type']; $commitPackage = getPackButton('commit', $target_manifest, $file, $next_step); $deletePackage = getPackButton('remove', $target_manifest, $file, $next_step); //$ret .="<table width='100%' cellpadding='0' cellspacing='0' border='0'>"; $ret .= "<tr>"; $ret .= "<td width='20%' >" . $name . "</td>"; $ret .= "<td width='15%' >" . $version . "</td>"; $ret .= "<td width='15%' >" . $published_date . "</td>"; $ret .= "<td width='15%' >" . $uninstallable . "</td>"; $ret .= "<td width='20%' >" . $description . "</td>"; if ($display_commit) { $ret .= "<td width='7%'>{$commitPackage}</td>"; } $ret .= "<td width='1%'></td>"; $ret .= "<td width='7%'>{$deletePackage}</td>"; $ret .= "</td></tr>"; $clean_field_name = "accept_lic_" . str_replace('.', '_', urlencode(basename($file))); if (is_file($license_file)) { //rrs $ret .= "<tr><td colspan=6>"; $ret .= getLicenseDisplay('commit', $target_manifest, $file, $next_step, $license_file, $clean_field_name); $ret .= "</td></tr>"; $hidden_input .= "<input type='hidden' name='{$clean_field_name}' id='{$clean_field_name}' value='no'>"; } else { $hidden_input .= "<input type='hidden' name='{$clean_field_name}' id='{$clean_field_name}' value='yes'>"; } } //fi } //rof $_SESSION['hidden_input'] = $hidden_input; if (count($files) > 0) { $ret .= "</tr><td colspan=7>"; $ret .= "<form name='commit' action='install.php' method='POST'>\n <input type='hidden' name='current_step' value='{$next_step}'>\n <input type='hidden' name='goto' value='Re-check'>\n <input type='hidden' name='languagePackAction' value='commit'>\n <input type='hidden' name='install_type' value='custom'>\n </form>\n "; $ret .= "</td></tr>"; } else { $ret .= "</tr><td colspan=7><i>{$mod_strings['LBL_LANG_NO_PACKS']}</i></td></tr>"; } return $ret; }
/** * searches upgrade dir for lang pack files. * * @return string HTML of available lang packs */ function getLangPacks() { global $mod_strings; global $next_step; global $base_upgrade_dir; $ret = "<tr><td colspan=7 align=left>{$mod_strings['LBL_LANG_PACK_READY']}</td></tr>"; $ret .= "<tr>\n\t <td nowrap align=left><b>{$mod_strings['LBL_ML_NAME']}</b></td>\n\t <td nowrap><b>{$mod_strings['LBL_ML_VERSION']}</b></td>\n\t <td nowrap><b>{$mod_strings['LBL_ML_PUBLISHED']}</b></td>\n\t <td nowrap><b>{$mod_strings['LBL_ML_UNINSTALLABLE']}</b></td>\n\t <td nowrap><b>{$mod_strings['LBL_ML_DESCRIPTION']}</b></td>\n </tr>\n"; $files = array(); // duh, new installs won't have the upgrade folders if (!is_dir(getcwd() . "/cache/upload/upgrades")) { $subdirs = array('full', 'langpack', 'module', 'patch', 'theme', 'temp'); foreach ($subdirs as $subdir) { mkdir_recursive("{$base_upgrade_dir}/{$subdir}"); } } $files = findAllFiles(getcwd() . "/cache/upload/upgrades", $files); foreach ($files as $file) { if (!preg_match("#.*\\.zip\$#", $file)) { continue; } // skip installed lang packs if (isset($_SESSION['INSTALLED_LANG_PACKS']) && in_array($file, $_SESSION['INSTALLED_LANG_PACKS'])) { continue; } // handle manifest.php $target_manifest = remove_file_extension($file) . '-manifest.php'; include $target_manifest; $name = empty($manifest['name']) ? $file : $manifest['name']; $version = empty($manifest['version']) ? '' : $manifest['version']; $published_date = empty($manifest['published_date']) ? '' : $manifest['published_date']; $icon = ''; $description = empty($manifest['description']) ? 'None' : $manifest['description']; $uninstallable = empty($manifest['is_uninstallable']) ? 'No' : 'Yes'; $manifest_type = $manifest['type']; $commitPackage = getPackButton('commit', $target_manifest, $file, $next_step); $deletePackage = getPackButton('remove', $target_manifest, $file, $next_step); $ret .= "<tr>"; $ret .= "<td nowrap>" . $name . "</td>"; $ret .= "<td nowrap>" . $version . "</td>"; $ret .= "<td nowrap>" . $published_date . "</td>"; $ret .= "<td nowrap>" . $uninstallable . "</td>"; $ret .= "<td>" . $description . "</td>"; $ret .= "<td nowrap>{$commitPackage}</td>"; $ret .= "<td nowrap>{$deletePackage}</td>"; $ret .= "</td></tr>"; } if (count($files) > 0) { $ret .= "</tr><td colspan=7>"; $ret .= "<form name='commit' action='install.php' method='POST'>\n <input type='hidden' name='current_step' value='{$next_step}'>\n <input type='hidden' name='goto' value='Re-check'>\n <input type='hidden' name='languagePackAction' value='commit'>\n </form>\n "; $ret .= "</td></tr>"; } else { $ret .= "</tr><td colspan=7><i>{$mod_strings['LBL_LANG_NO_PACKS']}</i></td></tr>"; } return $ret; }