Bläddra i källkod

Changed the color of the number of PMs notifications to black
Converted the list of available languages to a createList! I know Spuds will be happy! :P

Signed-off-by: emanuele <[email protected]>

emanuele 12 år sedan
förälder
incheckning
4906ddfddc

+ 92 - 30
Sources/ManageLanguages.php

@@ -77,42 +77,104 @@ function AddLanguage()
 
 		$context['smf_search_term'] = htmlspecialchars(trim($_POST['smf_add']));
 
-		// We're going to use this URL.
-		$url = 'http://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => '')));
+		$listOptions = array(
+			'id' => 'smf_languages',
+			'get_items' => array(
+				'function' => 'list_getLanguagesList',
+			),
+			'columns' => array(
+				'name' => array(
+					'header' => array(
+						'value' => $txt['name'],
+					),
+					'data' => array(
+						'db' => 'name',
+					),
+				),
+				'description' => array(
+					'header' => array(
+						'value' => $txt['add_language_smf_desc'],
+					),
+					'data' => array(
+						'db' => 'description',
+					),
+				),
+				'version' => array(
+					'header' => array(
+						'value' => $txt['add_language_smf_version'],
+					),
+					'data' => array(
+						'db' => 'version',
+					),
+				),
+				'utf8' => array(
+					'header' => array(
+						'value' => $txt['add_language_smf_utf8'],
+					),
+					'data' => array(
+						'db' => 'utf8',
+						'style' => 'text-align: center',
+					),
+				),
+				'install_link' => array(
+					'header' => array(
+						'value' => $txt['add_language_smf_install'],
+					),
+					'data' => array(
+						'db' => 'install_link',
+					),
+				),
+			),
+		);
 
-		// Load the class file and stick it into an array.
-		require_once($sourcedir . '/Class-Package.php');
-		$language_list = new xmlArray(fetch_web_data($url), true);
+		require_once($sourcedir . '/Subs-List.php');
+		createList($listOptions);
 
-		// Check it exists.
-		if (!$language_list->exists('languages/language'))
-			$context['smf_error'] = 'no_response';
-		else
+		$context['default_list'] = 'smf_languages';
+	}
+
+	$context['sub_template'] = 'add_language';
+}
+
+function list_getLanguagesList()
+{
+	global $forum_version, $context, $sourcedir, $smcFunc, $txt, $scripturl;
+
+	// We're going to use this URL.
+	$url = 'http://download.simplemachines.org/fetch_language.php?version=' . urlencode(strtr($forum_version, array('SMF ' => '')));
+
+	// Load the class file and stick it into an array.
+	require_once($sourcedir . '/Class-Package.php');
+	$language_list = new xmlArray(fetch_web_data($url), true);
+
+	// Check it exists.
+	if (!$language_list->exists('languages/language'))
+		$context['smf_error'] = 'no_response';
+	else
+	{
+		$language_list = $language_list->path('languages[0]');
+		$lang_files = $language_list->set('language');
+		$smf_languages = array();
+		foreach ($lang_files as $file)
 		{
-			$language_list = $language_list->path('languages[0]');
-			$lang_files = $language_list->set('language');
-			$context['smf_languages'] = array();
-			foreach ($lang_files as $file)
-			{
-				// Were we searching?
-				if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false)
-					continue;
+			// Were we searching?
+			if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false)
+				continue;
 
-				$context['smf_languages'][] = array(
-					'id' => $file->fetch('id'),
-					'name' => $smcFunc['ucwords']($file->fetch('name')),
-					'version' => $file->fetch('version'),
-					'utf8' => $file->fetch('utf8'),
-					'description' => $file->fetch('description'),
-					'link' => $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'],
-				);
-			}
-			if (empty($context['smf_languages']))
-				$context['smf_error'] = 'no_files';
+			$smf_languages[] = array(
+				'id' => $file->fetch('id'),
+				'name' => $smcFunc['ucwords']($file->fetch('name')),
+				'version' => $file->fetch('version'),
+				'utf8' => $file->fetch('utf8') ? $txt['yes'] : $txt['no'],
+				'description' => $file->fetch('description'),
+				'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>',
+			);
 		}
+		if (empty($smf_languages))
+			$context['smf_error'] = 'no_files';
+		else
+			return $smf_languages;
 	}
-
-	$context['sub_template'] = 'add_language';
 }
 
 /**

+ 2 - 29
Themes/default/ManageLanguages.template.php

@@ -477,36 +477,9 @@ function template_add_language()
 	if (!empty($context['smf_languages']))
 	{
 		echo '
-			<div class="information">', $txt['add_language_smf_found'], '</div>
-
-				<table class="table_grid" cellspacing="0" width="100%">
-					<thead>
-						<tr class="catbg">
-							<th class="first_th" scope="col">', $txt['name'], '</th>
-							<th scope="col">', $txt['add_language_smf_desc'], '</th>
-							<th scope="col">', $txt['add_language_smf_version'], '</th>
-							<th scope="col">', $txt['add_language_smf_utf8'], '</th>
-							<th class="last_th" scope="col">', $txt['add_language_smf_install'], '</th>
-						</tr>
-					</thead>
-					<tbody>';
-
-		foreach ($context['smf_languages'] as $language)
-		{
-			// Write each language information out.
-			echo '
-						<tr class="windowbg2">
-							<td align="left">', $language['name'], '</td>
-							<td align="left">', $language['description'], '</td>
-							<td align="left">', $language['version'], '</td>
-							<td align="center">', $language['utf8'] ? $txt['yes'] : $txt['no'], '</td>
-							<td align="left"><a href="', $language['link'], '">', $txt['add_language_smf_install'], '</a></td>
-						</tr>';
-		}
+			<div class="information">', $txt['add_language_smf_found'], '</div>';
 
-		echo '
-					</tbody>
-					</table>';
+		template_show_list('smf_languages');
 	}
 
 	echo '

+ 1 - 1
Themes/default/css/index.css

@@ -1019,7 +1019,7 @@ span.lowerframe span {
 }
 /* Needed for new PM notifications. */
 .dropmenu li strong {
-	color: #fff;
+	color: #000;
 }
 .dropmenu li a {
 	padding: 0 4px 0 4px;

BIN
Themes/penguin/images/selected_open.png